Skip to content

msx/msxtr.cpp: Move MSX Turbo-R machines to their own file and implement some devices. #12433

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 26 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
2222674
bus/msx/slot/panasonic08r.cpp: Add MSX Turbo-R firmware mapper.
wilbertpol May 30, 2024
b1ae595
cpu/z80/r800.cpp: Implement basic cpu core details.
wilbertpol May 30, 2024
2c316d8
msx/msx_s1990.cpp: Implement basic functionality to allow switching o…
wilbertpol May 30, 2024
fd38f50
msx/msxtr.cpp: Hookup R800 and S1990 devices for Turbo-R machines.
wilbertpol May 30, 2024
1242fa5
Update mame.lst
wilbertpol May 30, 2024
3d7dcab
Update mame.lst
wilbertpol May 31, 2024
52269e8
msx/msx2p.cpp: Remove fsa1st and fsa1gt definitions.
wilbertpol May 31, 2024
faee628
cpu/z80/r800.cpp: Since the majority of the cpu core in copied from t…
wilbertpol Jun 1, 2024
a00ed43
bus/msx/slot/panasonic08r.cpp: Update notes.
wilbertpol Jun 2, 2024
0c83dff
Merge branch 'master' into msx_turbor
wilbertpol Jun 3, 2024
21bdc98
cpu/z80/z80make.py: Generate full cores.
wilbertpol Jun 4, 2024
80ec087
Start converting R800 to a generated core.
wilbertpol Jun 4, 2024
fc20884
Fully generated r800 core.
wilbertpol Jun 4, 2024
1aaac45
cpu/z80/r800.cpp: Update a comment.
wilbertpol Jun 5, 2024
f4c26e4
Merge branch 'master' into msx_turbor
wilbertpol Jun 5, 2024
d58d600
r800.cpp: Fix do_op.
wilbertpol Jun 5, 2024
b23469c
z80.cpp: Use regular arrays for flags lookup tables.
wilbertpol Jun 5, 2024
447b333
cpu/z80/z80.cpp: Make the flag lookup tables constant.
wilbertpol Jun 5, 2024
86c60d6
Revert "cpu/z80/z80.cpp: Make the flag lookup tables constant."
wilbertpol Jun 8, 2024
9b5ae0f
cpu/z80/z80.cpp: Update spacing in flag lookup table calculation.
wilbertpol Jun 8, 2024
4478686
cpu/z80/r800.cpp: More const.
wilbertpol Jun 8, 2024
31dc7e9
cpu/z80/r800.cpp: Sync with main.
wilbertpol Jun 12, 2024
1953d79
Merge branch 'master' into msx_turbor
wilbertpol Jun 13, 2024
c3535cb
fix merge mistake.
wilbertpol Jun 13, 2024
e662ac1
Merge branch 'master' into msx_turbor
wilbertpol Jun 29, 2024
e3abe81
Mark r800 and s1990 devices as having imperfect timing.
wilbertpol Jun 30, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions scripts/src/bus.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1959,6 +1959,8 @@ if (BUSES["MSX_SLOT"]~=null) then
MAME_DIR .. "src/devices/bus/msx/slot/music.h",
MAME_DIR .. "src/devices/bus/msx/slot/panasonic08.cpp",
MAME_DIR .. "src/devices/bus/msx/slot/panasonic08.h",
MAME_DIR .. "src/devices/bus/msx/slot/panasonic08r.cpp",
MAME_DIR .. "src/devices/bus/msx/slot/panasonic08r.h",
MAME_DIR .. "src/devices/bus/msx/slot/rom.cpp",
MAME_DIR .. "src/devices/bus/msx/slot/rom.h",
MAME_DIR .. "src/devices/bus/msx/slot/ram.cpp",
Expand Down
2 changes: 2 additions & 0 deletions scripts/src/cpu.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3001,11 +3001,13 @@ if CPUS["Z80"] or CPUS["KC80"] or CPUS["Z80N"] then
dependency {
{ MAME_DIR .. "src/devices/cpu/z80/z80.cpp", GEN_DIR .. "emu/cpu/z80/z80.hxx" },
{ MAME_DIR .. "src/devices/cpu/z80/z80.cpp", GEN_DIR .. "emu/cpu/z80/ncs800.hxx" },
{ MAME_DIR .. "src/devices/cpu/z80/r800.cpp", GEN_DIR .. "emu/cpu/z80/r800.hxx" },
}

custombuildtask {
{ MAME_DIR .. "src/devices/cpu/z80/z80.lst", GEN_DIR .. "emu/cpu/z80/z80.hxx", { MAME_DIR .. "src/devices/cpu/z80/z80make.py" }, { "@echo Generating Z80 source file...", PYTHON .. " $(1) $(<) $(@)" } },
{ MAME_DIR .. "src/devices/cpu/z80/z80.lst", GEN_DIR .. "emu/cpu/z80/ncs800.hxx", { MAME_DIR .. "src/devices/cpu/z80/z80make.py" }, { "@echo Generating NSC800 source file...", PYTHON .. " $(1) ncs800 $(<) $(@)" } },
{ MAME_DIR .. "src/devices/cpu/z80/z80.lst", GEN_DIR .. "emu/cpu/z80/r800.hxx", { MAME_DIR .. "src/devices/cpu/z80/z80make.py" }, { "@echo Generating R800 source file...", PYTHON .. " $(1) r800 $(<) $(@)" } },
}
end

Expand Down
214 changes: 214 additions & 0 deletions src/devices/bus/msx/slot/panasonic08r.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,214 @@
// license:BSD-3-Clause
// copyright-holders:Wilbert Pol
/*

Emulation of the firmware mapper as found in Panasonic FS-A1ST and FS-A1GT Turbo-R machines.

TODO:
- FS-A1GT has problems booting, related to this mapper?

Starting at segment
- 000: firmware.
- 028: main ROM.
- 080 - 087: SRAM, 080-081 only on FS-A1ST and 080-083 only on FS-A1GT.
- 100: "ROM disk" (FS-A1GT only).
- 180: main RAM
read & write, or read only?
mirroring?, FS-A1ST has 256KB main RAM

*/

#include "emu.h"
#include "panasonic08r.h"


DEFINE_DEVICE_TYPE(MSX_SLOT_PANASONIC08R, msx_slot_panasonic08r_device, "msx_slot_panasonic08r", "MSX Internal Panasonic08r")


msx_slot_panasonic08r_device::msx_slot_panasonic08r_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock)
: device_t(mconfig, MSX_SLOT_PANASONIC08R, tag, owner, clock)
, msx_internal_slot_interface(mconfig, *this)
, m_nvram(*this, "nvram")
, m_rom_region(*this, finder_base::DUMMY_TAG)
, m_bank(*this, "bank%u", 0U)
, m_view{
{*this, "view0"}, {*this, "view1"}, {*this, "view2"}, {*this, "view3"},
{*this, "view4"}, {*this, "view5"}, {*this, "view6"}, {*this, "view7"}
}
, m_mm(*this, finder_base::DUMMY_TAG)
, m_region_offset(0)
, m_control(0)
{
}


void msx_slot_panasonic08r_device::device_add_mconfig(machine_config &config)
{
NVRAM(config, m_nvram, nvram_device::DEFAULT_ALL_0);
}


void msx_slot_panasonic08r_device::interface_pre_start()
{
if (!m_mm->started())
throw device_missing_dependencies();
}


void msx_slot_panasonic08r_device::device_start()
{
// Sanity checks
if (m_rom_region->bytes() < m_region_offset + 0x400000)
{
fatalerror("Memory region '%s' is too small for the panasonic08r firmware\n", m_rom_region.finder_tag());
}
if (m_sram_size != 0x4000 && m_sram_size != 0x8000)
{
fatalerror("Invalid SRAM size for the panasonic08r firmware\n");
}

m_sram.resize(m_sram_size);

m_nvram->set_base(&m_sram[0], m_sram_size);

save_item(NAME(m_selected_bank));
save_item(NAME(m_control));
save_item(NAME(m_bank9));

for (int i = 0; i < 8; i++)
{
m_bank[i]->configure_entries(0, 0x200, m_rom_region->base() + m_region_offset, 0x2000);
m_bank[i]->configure_entry(0x80, m_sram.data());
m_bank[i]->configure_entry(0x81, m_sram.data() + 0x2000);
if (m_sram_size >= 0x8000)
{
m_bank[i]->configure_entry(0x82, m_sram.data() + 0x4000);
m_bank[i]->configure_entry(0x83, m_sram.data() + 0x6000);
}

// Assuming smaller internal RAM is mirrored.
int internal_ram_banks = m_mm->get_ram().size() / 0x2000;
int start_bank = 0x180;
do {
int nr_banks = internal_ram_banks;
if (start_bank + nr_banks > 0x200)
nr_banks = 0x200 - start_bank;
m_bank[i]->configure_entries(start_bank, nr_banks, m_mm->get_ram().data(), 0x2000);
start_bank += internal_ram_banks;
}
while (start_bank < 0x200);
}

page(0)->install_view(0x0000, 0x1fff, m_view[0]);
m_view[0][0].install_read_bank(0x0000, 0x1fff, m_bank[0]);
m_view[0][1].install_readwrite_bank(0x0000, 0x1fff, m_bank[0]);

page(0)->install_view(0x2000, 0x3fff, m_view[1]);
m_view[1][0].install_read_bank(0x2000, 0x3fff, m_bank[1]);
m_view[1][1].install_readwrite_bank(0x2000, 0x3fff, m_bank[1]);

// no sram writing in 4000-7fff?
page(1)->install_read_bank(0x4000, 0x5fff, m_bank[2]);

page(1)->install_view(0x6000, 0x7fff, m_view[3]);
m_view[3][0].install_read_bank(0x6000, 0x7fff, m_bank[3]);
m_view[3][1].install_read_bank(0x6000, 0x7fff, m_bank[3]);
m_view[3][1].install_read_handler(0x7ff0, 0x7ff7, emu::rw_delegate(*this, FUNC(msx_slot_panasonic08r_device::bank_r)));
page(1)->install_write_handler(0x6000, 0x6000, emu::rw_delegate(*this, FUNC(msx_slot_panasonic08r_device::bank_w<0>)));
page(1)->install_write_handler(0x6400, 0x6400, emu::rw_delegate(*this, FUNC(msx_slot_panasonic08r_device::bank_w<1>)));
page(1)->install_write_handler(0x6800, 0x6800, emu::rw_delegate(*this, FUNC(msx_slot_panasonic08r_device::bank_w<2>)));
page(1)->install_write_handler(0x6c00, 0x6c00, emu::rw_delegate(*this, FUNC(msx_slot_panasonic08r_device::bank_w<3>)));
page(1)->install_write_handler(0x7000, 0x7000, emu::rw_delegate(*this, FUNC(msx_slot_panasonic08r_device::bank_w<4>)));
page(1)->install_write_handler(0x7400, 0x7400, emu::rw_delegate(*this, FUNC(msx_slot_panasonic08r_device::bank_w<6>)));
page(1)->install_write_handler(0x7800, 0x7800, emu::rw_delegate(*this, FUNC(msx_slot_panasonic08r_device::bank_w<5>)));
page(1)->install_write_handler(0x7c00, 0x7c00, emu::rw_delegate(*this, FUNC(msx_slot_panasonic08r_device::bank_w<7>)));
page(1)->install_readwrite_handler(0x7ff8, 0x7ff8, emu::rw_delegate(*this, FUNC(msx_slot_panasonic08r_device::bank9_r)), emu::rw_delegate(*this, FUNC(msx_slot_panasonic08r_device::bank9_w)));
page(1)->install_write_handler(0x7ff9, 0x7ff9, emu::rw_delegate(*this, FUNC(msx_slot_panasonic08r_device::control_w)));

page(2)->install_view(0x8000, 0x9fff, m_view[4]);
m_view[4][0].install_read_bank(0x8000, 0x9fff, m_bank[4]);
m_view[4][1].install_readwrite_bank(0x8000, 0x9fff, m_bank[4]);

page(2)->install_view(0xa000, 0xbfff, m_view[5]);
m_view[5][0].install_read_bank(0xa000, 0xbfff, m_bank[5]);
m_view[5][1].install_readwrite_bank(0xa000, 0xbfff, m_bank[5]);

page(3)->install_view(0xc000, 0xdfff, m_view[6]);
m_view[6][0].install_read_bank(0xc000, 0xdfff, m_bank[6]);
m_view[6][1].install_readwrite_bank(0xc000, 0xdfff, m_bank[6]);

page(3)->install_view(0xe000, 0xffff, m_view[7]);
m_view[7][0].install_read_bank(0xe000, 0xffff, m_bank[7]);
m_view[7][1].install_readwrite_bank(0xe000, 0xffff, m_bank[7]);
}


void msx_slot_panasonic08r_device::device_reset()
{
m_control = 0;
m_bank9 = 0;
for (int i = 0 ; i < 8; i++)
{
m_selected_bank[i] = 0;
m_bank[i]->set_entry(0);
if (i != 2)
m_view[i].select(0);
}
}


template <int Bank>
void msx_slot_panasonic08r_device::set_view()
{
bool ram_active = (m_selected_bank[Bank] >= 0x80 && m_selected_bank[Bank] < 0x84);
if (Bank == 3)
m_view[3].select(BIT(m_control, 2) ? 1 : 0);
else if (Bank != 2)
m_view[Bank].select(ram_active ? 1 : 0);
}


template <int Bank>
void msx_slot_panasonic08r_device::bank_w(u8 data)
{
u16 bank = data;

if (BIT(m_control, 4))
bank |= (BIT(m_bank9, Bank) << 8);
m_selected_bank[Bank] = bank;
m_bank[Bank]->set_entry(bank);
set_view<Bank>();
}


u8 msx_slot_panasonic08r_device::bank_r(offs_t offset)
{
return m_selected_bank[offset] & 0xff;
}


void msx_slot_panasonic08r_device::control_w(u8 data)
{
m_control = data;
set_view<3>();
}


u8 msx_slot_panasonic08r_device::bank9_r()
{
return m_bank9;
}


void msx_slot_panasonic08r_device::bank9_w(u8 data)
{
m_bank9 = data;
bank_w<0>(m_selected_bank[0]);
bank_w<1>(m_selected_bank[1]);
bank_w<2>(m_selected_bank[2]);
bank_w<3>(m_selected_bank[3]);
bank_w<4>(m_selected_bank[4]);
bank_w<5>(m_selected_bank[5]);
bank_w<6>(m_selected_bank[6]);
bank_w<7>(m_selected_bank[7]);
}
55 changes: 55 additions & 0 deletions src/devices/bus/msx/slot/panasonic08r.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
// license:BSD-3-Clause
// copyright-holders:Wilbert Pol
#ifndef MAME_BUS_MSX_SLOT_PANASONIC08R_H
#define MAME_BUS_MSX_SLOT_PANASONIC08R_H

#pragma once

#include "ram_mm.h"
#include "slot.h"
#include "machine/nvram.h"


DECLARE_DEVICE_TYPE(MSX_SLOT_PANASONIC08R, msx_slot_panasonic08r_device)


class msx_slot_panasonic08r_device : public device_t, public msx_internal_slot_interface
{
public:
msx_slot_panasonic08r_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock);

// configuration helpers
template <typename T> msx_slot_panasonic08r_device &set_mm_tag(T &&tag) { m_mm.set_tag(std::forward<T>(tag)); return *this; }
void set_rom_start(const char *region, u32 offset) { m_rom_region.set_tag(region); m_region_offset = offset; }
msx_slot_panasonic08r_device &set_sram_size(u16 size) { m_sram_size = size; return *this; }

protected:
virtual void interface_pre_start() override;
virtual void device_start() override;
virtual void device_reset() override;

virtual void device_add_mconfig(machine_config &config) override;

private:
template <int Bank> void set_view();
template <int Bank> void bank_w(u8 data);
u8 bank_r(offs_t offset);
void control_w(u8 data);
u8 bank9_r();
void bank9_w(u8 data);

u16 m_sram_size = 0x4000;
required_device<nvram_device> m_nvram;
required_memory_region m_rom_region;
memory_bank_array_creator<8> m_bank;
memory_view m_view[8];
required_device<msx_slot_ram_mm_device> m_mm;
u32 m_region_offset;
u16 m_selected_bank[8];
u8 m_control;
u8 m_bank9;
std::vector<u8> m_sram;
};


#endif // MAME_BUS_MSX_SLOT_PANASONIC08R_H
3 changes: 3 additions & 0 deletions src/devices/bus/msx/slot/ram_mm.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ class msx_slot_ram_mm_device : public device_t, public msx_internal_slot_interfa
msx_slot_ram_mm_device &set_total_size(u32 total_size) { m_total_size = total_size; return *this; }
msx_slot_ram_mm_device &set_unused_bits(u8 unused_bits) { m_unused_bits = unused_bits; return *this; }

// Backdoor for the Turbo-R firmware/internal mapper to access internal RAM.
std::vector<u8> &get_ram() { return m_ram; }

protected:
virtual void device_start() override;

Expand Down
3 changes: 2 additions & 1 deletion src/devices/bus/msx/slot/slot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ pages; and multiple pieces of rom/ram/components can occur in a single slot.
#include "slot.h"

msx_internal_slot_interface::msx_internal_slot_interface(const machine_config &mconfig, device_t &device)
: m_mem_space(device, finder_base::DUMMY_TAG, -1)
: device_interface(device, "msx_internal_slot")
, m_mem_space(device, finder_base::DUMMY_TAG, -1)
, m_io_space(device, finder_base::DUMMY_TAG, -1)
, m_maincpu(device, finder_base::DUMMY_TAG)
, m_start_address(0)
Expand Down
2 changes: 1 addition & 1 deletion src/devices/bus/msx/slot/slot.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ pages; and multiple pieces of rom/ram/components can occur in a single slot.

#pragma once

class msx_internal_slot_interface
class msx_internal_slot_interface : public device_interface
{
public:
msx_internal_slot_interface(const msx_internal_slot_interface &device) = delete;
Expand Down
Loading
Loading