summaryrefslogtreecommitdiffstatshomepage
path: root/src/mess/machine
diff options
context:
space:
mode:
author Fabio Priuli <etabeta78@users.noreply.github.com>2013-03-07 11:09:57 +0000
committer Fabio Priuli <etabeta78@users.noreply.github.com>2013-03-07 11:09:57 +0000
commit7e0b63efa9978e8611337c4ac80ffc293bb527ee (patch)
treeea07d4755edebcd5bb6778abb0ac947def3d6916 /src/mess/machine
parent452c1a885124494ad458022dd19dfe11a9bfbbda (diff)
split ROM/RAM accesses to cart in SNES slot implementation in order to simplify the code. nw.
Diffstat (limited to 'src/mess/machine')
-rw-r--r--src/mess/machine/sns_bsx.c57
-rw-r--r--src/mess/machine/sns_bsx.h8
-rw-r--r--src/mess/machine/sns_rom.c60
-rw-r--r--src/mess/machine/sns_rom.h2
-rw-r--r--src/mess/machine/sns_rom21.c46
-rw-r--r--src/mess/machine/sns_rom21.h2
-rw-r--r--src/mess/machine/sns_sdd1.c14
-rw-r--r--src/mess/machine/sns_sdd1.h3
-rw-r--r--src/mess/machine/sns_sfx.c97
-rw-r--r--src/mess/machine/sns_sfx.h4
-rw-r--r--src/mess/machine/sns_slot.c29
-rw-r--r--src/mess/machine/sns_slot.h12
-rw-r--r--src/mess/machine/sns_spc7110.c107
-rw-r--r--src/mess/machine/sns_spc7110.h4
-rw-r--r--src/mess/machine/sns_sufami.c65
-rw-r--r--src/mess/machine/sns_sufami.h5
16 files changed, 145 insertions, 370 deletions
diff --git a/src/mess/machine/sns_bsx.c b/src/mess/machine/sns_bsx.c
index b3dcca93e84..729a256a947 100644
--- a/src/mess/machine/sns_bsx.c
+++ b/src/mess/machine/sns_bsx.c
@@ -451,21 +451,8 @@ READ8_MEMBER(sns_rom_bsxlo_device::read_l)
int bank = offset / 0x10000;
return m_rom[rom_bank_map[bank] * 0x8000 + (offset & 0x7fff)];
}
- if (offset >= 0x700000 && (offset & 0xffff) < 0x8000)
- {
- if (m_nvram_size > 0x8000)
- {
- // In this case, SRAM is mapped in 0x8000 chunks at diff offsets: 0x700000-0x707fff, 0x710000-0x717fff, etc.
- int mask = (m_nvram_size << 1) - 1;
- mask &= ~0x8000;
- return m_nvram[offset & mask];
- }
- else if (m_nvram_size > 0)
- {
- int mask = m_nvram_size - 1; /* Limit SRAM size to what's actually present */
- return m_nvram[offset & mask];
- }
- }
+ // nothing [40-6f]
+ // RAM [70-7f]
return 0x00;
}
@@ -483,22 +470,7 @@ READ8_MEMBER(sns_rom_bsxlo_device::read_h)
if (m_slot->m_cart && m_slot->m_cart->get_rom_size())
return m_slot->m_cart->read_h(space, offset);
}
-
- if (offset >= 0x700000 && (offset & 0xffff) < 0x8000)
- {
- if (m_nvram_size > 0x8000)
- {
- // In this case, SRAM is mapped in 0x8000 chunks at diff offsets: 0x700000-0x707fff, 0x710000-0x717fff, etc.
- int mask = (m_nvram_size << 1) - 1;
- mask &= ~0x8000;
- return m_nvram[offset & mask];
- }
- else if (m_nvram_size > 0)
- {
- int mask = m_nvram_size - 1; /* Limit SRAM size to what's actually present */
- return m_nvram[offset & mask];
- }
- }
+ // RAM [70-7f]
return 0x00;
}
@@ -519,11 +491,6 @@ READ8_MEMBER(sns_rom_bsxhi_device::read_h)
}
if (offset >= 0x200000 && offset < 0x400000)
{
- if ((offset & 0xffff) >= 0x6000 && (offset & 0xffff) < 0x8000 && m_nvram_size > 0)
- {
- int mask = (m_nvram_size - 1) & 0x7fff;
- return m_nvram[(offset - 0x6000) & mask];
- }
if ((offset & 0xffff) >= 0x8000 && m_slot->m_cart && m_slot->m_cart->get_rom_size())
return m_slot->m_cart->read_h(space, offset);
}
@@ -541,24 +508,6 @@ READ8_MEMBER(sns_rom_bsxhi_device::read_h)
return 0xff;
}
-WRITE8_MEMBER(sns_rom_bsxhi_device::write_l)
-{
- write_h(space, offset, data);
-}
-
-WRITE8_MEMBER(sns_rom_bsxhi_device::write_h)
-{
- if (offset >= 0x200000 && offset < 0x400000)
- {
- if ((offset & 0xffff) >= 0x6000 && (offset & 0xffff) < 0x8000 && m_nvram_size > 0)
- {
- int mask = (m_nvram_size - 1) & 0x7fff;
- m_nvram[(offset - 0x6000) & mask] = data;
- }
- }
-}
-
-
/*-------------------------------------------------
BS-X Memory Packs
-------------------------------------------------*/
diff --git a/src/mess/machine/sns_bsx.h b/src/mess/machine/sns_bsx.h
index baddd2f82d4..6acae3eb1e0 100644
--- a/src/mess/machine/sns_bsx.h
+++ b/src/mess/machine/sns_bsx.h
@@ -84,10 +84,6 @@ public:
// additional reading and writing
virtual DECLARE_READ8_MEMBER(read_l);
virtual DECLARE_READ8_MEMBER(read_h);
-// virtual DECLARE_WRITE8_MEMBER(write_l);
-// virtual DECLARE_WRITE8_MEMBER(write_h);
-// virtual DECLARE_READ8_MEMBER(chip_read);
-// virtual DECLARE_WRITE8_MEMBER(chip_write);
private:
required_device<sns_bsx_cart_slot_device> m_slot;
@@ -109,10 +105,6 @@ public:
// additional reading and writing
virtual DECLARE_READ8_MEMBER(read_l);
virtual DECLARE_READ8_MEMBER(read_h);
- virtual DECLARE_WRITE8_MEMBER(write_l);
- virtual DECLARE_WRITE8_MEMBER(write_h);
- // virtual DECLARE_READ8_MEMBER(chip_read);
- // virtual DECLARE_WRITE8_MEMBER(chip_write);
private:
required_device<sns_bsx_cart_slot_device> m_slot;
diff --git a/src/mess/machine/sns_rom.c b/src/mess/machine/sns_rom.c
index b2eda6435a7..b423fd83a19 100644
--- a/src/mess/machine/sns_rom.c
+++ b/src/mess/machine/sns_rom.c
@@ -82,64 +82,8 @@ READ8_MEMBER(sns_rom_device::read_l)
READ8_MEMBER(sns_rom_device::read_h)
{
- UINT8 value = 0xff;
- UINT16 address = offset & 0xffff;
-
- if (offset < 0x700000)
- {
- int bank = offset / 0x10000;
- value = m_rom[rom_bank_map[bank] * 0x8000 + (offset & 0x7fff)];
- }
- else
- {
- if (address < 0x8000)
- {
- if (m_nvram_size > 0x8000)
- {
- // In this case, SRAM is mapped in 0x8000 chunks at diff offsets: 0x700000-0x707fff, 0x710000-0x717fff, etc.
- int mask = m_nvram_size - 1;
- offset = ((offset - 0x700000) / 0x10000) * 0x8000 + (offset & 0x7fff);
- value = m_nvram[offset & mask];
- }
- else if (m_nvram_size > 0)
- {
- int mask = m_nvram_size - 1; /* Limit SRAM size to what's actually present */
- value = m_nvram[offset & mask];
- }
- else
- value = 0xff; // this should never happened...
- }
- else
- {
- int bank = offset / 0x10000;
- value = m_rom[rom_bank_map[bank] * 0x8000 + (offset & 0x7fff)];
- }
- }
- return value;
-}
-
-WRITE8_MEMBER(sns_rom_device::write_l)
-{
- write_h(space, offset, data);
-}
-
-WRITE8_MEMBER(sns_rom_device::write_h)
-{
- if (offset >= 0x700000) // SRAM
- {
- if (m_nvram_size > 0x8000)
- {
- // In this case, SRAM is mapped in 0x8000 chunks at diff offsets: 0x700000-0x707fff, 0x710000-0x717fff, etc.
- int mask = m_nvram_size - 1;
- offset = ((offset - 0x700000) / 0x10000) * 0x8000 + (offset & 0x7fff);
- m_nvram[offset & mask] = data;
- }
- else if (m_nvram_size > 0)
- {
- int mask = m_nvram_size - 1; /* Limit SRAM size to what's actually present */
- m_nvram[offset & mask] = data;
- }
- }
+ int bank = offset / 0x10000;
+ return m_rom[rom_bank_map[bank] * 0x8000 + (offset & 0x7fff)];
}
diff --git a/src/mess/machine/sns_rom.h b/src/mess/machine/sns_rom.h
index a4062f8cca9..c58885df802 100644
--- a/src/mess/machine/sns_rom.h
+++ b/src/mess/machine/sns_rom.h
@@ -21,8 +21,6 @@ public:
// reading and writing
virtual DECLARE_READ8_MEMBER(read_l);
virtual DECLARE_READ8_MEMBER(read_h);
- virtual DECLARE_WRITE8_MEMBER(write_l);
- virtual DECLARE_WRITE8_MEMBER(write_h);
};
// ======================> sns_rom_pokemon_device
diff --git a/src/mess/machine/sns_rom21.c b/src/mess/machine/sns_rom21.c
index 01d8a4a90b6..c53d5a532f0 100644
--- a/src/mess/machine/sns_rom21.c
+++ b/src/mess/machine/sns_rom21.c
@@ -65,19 +65,6 @@ void sns_rom21_srtc_device::device_start()
READ8_MEMBER(sns_rom21_device::read_l)
{
- UINT16 address = offset & 0xffff;
-
- if (offset >= 0x300000 && offset < 0x400000 && address < 0x8000)
- {
- if (m_nvram_size > 0)
- {
- /* Donkey Kong Country checks this and detects a copier if 0x800 is not masked out due to sram size */
- /* OTOH Secret of Mana does not work properly if sram is not mirrored on later banks */
- int mask = (m_nvram_size - 1) & 0x7fff; /* Limit SRAM size to what's actually present */
- return m_nvram[(offset - 0x6000) & mask];
- }
- }
-
// here ROM banks from 128 to 255, mirrored twice
int bank = (offset & 0x3fffff) / 0x8000;
return m_rom[rom_bank_map[bank + 0x80] * 0x8000 + (offset & 0x7fff)];
@@ -85,44 +72,11 @@ READ8_MEMBER(sns_rom21_device::read_l)
READ8_MEMBER(sns_rom21_device::read_h)
{
- UINT16 address = offset & 0xffff;
-
- if (offset >= 0x300000 && offset < 0x400000 && address < 0x8000)
- {
- if (m_nvram_size > 0)
- {
- /* Donkey Kong Country checks this and detects a copier if 0x800 is not masked out due to sram size */
- /* OTOH Secret of Mana does not work properly if sram is not mirrored on later banks */
- int mask = (m_nvram_size - 1) & 0x7fff; /* Limit SRAM size to what's actually present */
- return m_nvram[(offset - 0x6000) & mask];
- }
- }
-
// here ROM banks from 0 to 127, mirrored twice
int bank = (offset & 0x3fffff) / 0x8000;
return m_rom[rom_bank_map[bank] * 0x8000 + (offset & 0x7fff)];
}
-WRITE8_MEMBER(sns_rom21_device::write_l)
-{
- write_h(space, offset, data);
-}
-
-WRITE8_MEMBER(sns_rom21_device::write_h)
-{
- UINT16 address = offset & 0xffff;
-
- if (offset >= 0x300000 && offset < 0x400000 && address < 0x8000)
- {
- if (m_nvram_size > 0)
- {
- /* Donkey Kong Country checks this and detects a copier if 0x800 is not masked out due to sram size */
- /* OTOH Secret of Mana does not work properly if sram is not mirrored on later banks */
- int mask = (m_nvram_size - 1) & 0x7fff; /* Limit SRAM size to what's actually present */
- m_nvram[(offset - 0x6000) & mask] = data;
- }
- }
-}
// Hi-ROM + S-RTC (used by Daikaijuu Monogatari II)
// same as above but additional read/write handling for the RTC
diff --git a/src/mess/machine/sns_rom21.h b/src/mess/machine/sns_rom21.h
index 659c84fdc0d..14402291c11 100644
--- a/src/mess/machine/sns_rom21.h
+++ b/src/mess/machine/sns_rom21.h
@@ -21,8 +21,6 @@ public:
// reading and writing
virtual DECLARE_READ8_MEMBER(read_l);
virtual DECLARE_READ8_MEMBER(read_h);
- virtual DECLARE_WRITE8_MEMBER(write_l);
- virtual DECLARE_WRITE8_MEMBER(write_h);
};
// ======================> sns_rom21_srtc_device
diff --git a/src/mess/machine/sns_sdd1.c b/src/mess/machine/sns_sdd1.c
index 3bdaaf81ae9..3025086324d 100644
--- a/src/mess/machine/sns_sdd1.c
+++ b/src/mess/machine/sns_sdd1.c
@@ -581,8 +581,6 @@ READ8_MEMBER(sns_rom_sdd1_device::read_l)
{
if (offset < 0x400000)
return m_rom[rom_bank_map[offset / 0x10000] * 0x8000 + (offset & 0x7fff)];
- else if (offset >= 0x700000 && (offset & 0xffff) < 0x8000 && m_nvram_size > 0)
- return m_nvram[offset & 0x1fff];
else
return m_rom[rom_bank_map[(offset - 0x400000) / 0x8000] * 0x8000 + (offset & 0x7fff)];
}
@@ -595,8 +593,14 @@ READ8_MEMBER(sns_rom_sdd1_device::read_h)
return read_l(space, offset);
}
-WRITE8_MEMBER(sns_rom_sdd1_device::write_l)
+
+READ8_MEMBER( sns_rom_sdd1_device::read_ram )
{
- if (offset >= 0x700000 && (offset & 0xffff) < 0x8000 && m_nvram_size > 0) // SRAM
- m_nvram[offset & 0x1fff] = data;
+ return m_nvram[offset & 0x1fff];
}
+
+WRITE8_MEMBER( sns_rom_sdd1_device::write_ram )
+{
+ m_nvram[offset & 0x1fff] = data;
+}
+
diff --git a/src/mess/machine/sns_sdd1.h b/src/mess/machine/sns_sdd1.h
index 2c8c75e4027..76f559fd07a 100644
--- a/src/mess/machine/sns_sdd1.h
+++ b/src/mess/machine/sns_sdd1.h
@@ -150,7 +150,8 @@ public:
// reading and writing
virtual DECLARE_READ8_MEMBER(read_l);
virtual DECLARE_READ8_MEMBER(read_h);
- virtual DECLARE_WRITE8_MEMBER(write_l);
+ virtual DECLARE_READ8_MEMBER(read_ram);
+ virtual DECLARE_WRITE8_MEMBER(write_ram);
virtual DECLARE_READ8_MEMBER(chip_read);
virtual DECLARE_WRITE8_MEMBER(chip_write);
diff --git a/src/mess/machine/sns_sfx.c b/src/mess/machine/sns_sfx.c
index 6fc35228b75..a4c466b6ea3 100644
--- a/src/mess/machine/sns_sfx.c
+++ b/src/mess/machine/sns_sfx.c
@@ -107,77 +107,16 @@ WRITE8_MEMBER( sns_rom_superfx_device::chip_write )
superfx_mmio_write(m_superfx, offset, data);
}
-READ8_MEMBER( sns_rom_superfx_device::read_l )
-{
- UINT16 address = offset & 0xffff;
-
- if (offset < 0x400000)
- {
- if (address >= 0x6000 && address < 0x8000)
- {
- if (superfx_access_ram(m_superfx))
- return sfx_ram[offset & 0x1fff];
- }
- if (address >= 0x8000)
- return m_rom[rom_bank_map[offset / 0x10000] * 0x8000 + (offset & 0x7fff)];
- }
- else if (offset < 0x600000)
- {
- if (superfx_access_rom(m_superfx))
- {
- return m_rom[rom_bank_map[(offset - 0x400000) / 0x8000] * 0x8000 + (offset & 0x7fff)];
- }
- else
- {
- static const UINT8 sfx_data[16] = {
- 0x00, 0x01, 0x00, 0x01, 0x04, 0x01, 0x00, 0x01,
- 0x00, 0x01, 0x08, 0x01, 0x00, 0x01, 0x0c, 0x01,
- };
- return sfx_data[offset & 0x0f];
- }
- }
- else
- {
- if (superfx_access_ram(m_superfx))
- return sfx_ram[offset & 0xfffff];
- }
-
- return 0xff; // should be open bus...
-}
-
-WRITE8_MEMBER( sns_rom_superfx_device::write_l )
+READ8_MEMBER( sns_rom_superfx_device::read_l )
{
- UINT16 address = offset & 0xffff;
- if (offset < 0x400000)
- {
- if (address >= 0x6000 && address < 0x8000)
- {
- if (superfx_access_ram(m_superfx))
- sfx_ram[offset & 0x1fff] = data;
- }
- }
- else if (offset >= 0x600000)
- {
- if (superfx_access_ram(m_superfx))
- sfx_ram[offset & 0xfffff] = data;
- }
+ return read_h(space, offset);
}
READ8_MEMBER(sns_rom_superfx_device::read_h)
{
- UINT16 address = offset & 0xffff;
-
if (offset < 0x400000)
- {
- if (address >= 0x6000 && address < 0x8000)
- {
- if (superfx_access_ram(m_superfx))
- return sfx_ram[offset & 0x1fff];
- }
- if (address >= 0x8000)
- return m_rom[rom_bank_map[offset / 0x10000] * 0x8000 + (offset & 0x7fff)];
- }
+ return m_rom[rom_bank_map[offset / 0x10000] * 0x8000 + (offset & 0x7fff)];
else if (offset < 0x600000)
{
if (superfx_access_rom(m_superfx))
@@ -193,29 +132,19 @@ READ8_MEMBER(sns_rom_superfx_device::read_h)
return sfx_data[offset & 0x0f];
}
}
- else
- {
- if (superfx_access_ram(m_superfx))
- return sfx_ram[offset & 0xfffff];
- }
+ return 0xff; // this handler should never be called for [60-7f]/[e0-ff] ranges
+}
+READ8_MEMBER( sns_rom_superfx_device::read_ram )
+{
+ if (superfx_access_ram(m_superfx))
+ return sfx_ram[offset & 0xfffff];
return 0xff; // should be open bus...
}
-WRITE8_MEMBER( sns_rom_superfx_device::write_h )
+WRITE8_MEMBER( sns_rom_superfx_device::write_ram )
{
- UINT16 address = offset & 0xffff;
- if (offset < 0x400000)
- {
- if (address >= 0x6000 && address < 0x8000)
- {
- if (superfx_access_ram(m_superfx))
- sfx_ram[offset & 0x1fff] = data;
- }
- }
- else if (offset >= 0x600000)
- {
- if (superfx_access_ram(m_superfx))
- sfx_ram[offset & 0xfffff] = data;
- }
+ if (superfx_access_ram(m_superfx))
+ sfx_ram[offset & 0xfffff] = data;
}
+
diff --git a/src/mess/machine/sns_sfx.h b/src/mess/machine/sns_sfx.h
index 3fea338e76b..9d00f2139fe 100644
--- a/src/mess/machine/sns_sfx.h
+++ b/src/mess/machine/sns_sfx.h
@@ -23,9 +23,9 @@ public:
// additional reading and writing
virtual DECLARE_READ8_MEMBER(read_l);
- virtual DECLARE_WRITE8_MEMBER(write_l);
virtual DECLARE_READ8_MEMBER(read_h);
- virtual DECLARE_WRITE8_MEMBER(write_h);
+ virtual DECLARE_READ8_MEMBER(read_ram);
+ virtual DECLARE_WRITE8_MEMBER(write_ram);
virtual DECLARE_READ8_MEMBER(chip_read);
virtual DECLARE_WRITE8_MEMBER(chip_write);
diff --git a/src/mess/machine/sns_slot.c b/src/mess/machine/sns_slot.c
index 1a97f6d1187..31b68812291 100644
--- a/src/mess/machine/sns_slot.c
+++ b/src/mess/machine/sns_slot.c
@@ -5,6 +5,21 @@
(through slot devices)
+ Carts can be mapped in memory in several different ways and accesses to carts depend
+ on the presence of add-on chips (which map their I/O to diff memory areas)
+
+ Hence, carts can interface with the main system through the following handlers
+ * read_l : typically used to read ROM from memory range [00-7f][0000-ffff]
+ * read_h : typically used to read ROM from memory range [80-ff][0000-ffff]
+ * read_ram : used to read (NV)RAM at the appropriate offset (masks has to be applied
+ *before* calling it, if dealing with >32K RAM)
+ * write_ram : used to write (NV)RAM at the appropriate offset
+ * read_chip : used to read add-on chip registers
+ * write_chip : used to write to add-on chip registers
+
+ Also, we define two additional ROM access handlers, write_l & write_h for carts with
+ subslots (e.g. BS-X compatible ones), that need to write to subslot (NV)RAM independently
+ to accesses to their own (NV)RAM.
***********************************************************************************************************/
@@ -843,6 +858,14 @@ READ8_MEMBER(base_sns_cart_slot_device::read_h)
return 0xff;
}
+READ8_MEMBER(base_sns_cart_slot_device::read_ram)
+{
+ if (m_cart)
+ return m_cart->read_ram(space, offset);
+ else
+ return 0xff;
+}
+
READ8_MEMBER(base_sns_cart_slot_device::chip_read)
{
if (m_cart)
@@ -867,6 +890,12 @@ WRITE8_MEMBER(base_sns_cart_slot_device::write_h)
m_cart->write_h(space, offset, data);
}
+WRITE8_MEMBER(base_sns_cart_slot_device::write_ram)
+{
+ if (m_cart)
+ m_cart->write_ram(space, offset, data);
+}
+
WRITE8_MEMBER(base_sns_cart_slot_device::chip_write)
{
if (m_cart)
diff --git a/src/mess/machine/sns_slot.h b/src/mess/machine/sns_slot.h
index da1510a112c..8f17950b04d 100644
--- a/src/mess/machine/sns_slot.h
+++ b/src/mess/machine/sns_slot.h
@@ -58,10 +58,12 @@ public:
virtual ~device_sns_cart_interface();
// reading and writing
- virtual DECLARE_READ8_MEMBER(read_l) { return 0xff; }
- virtual DECLARE_READ8_MEMBER(read_h) { return 0xff; }
- virtual DECLARE_WRITE8_MEMBER(write_l) {}
- virtual DECLARE_WRITE8_MEMBER(write_h) {}
+ virtual DECLARE_READ8_MEMBER(read_l) { return 0xff; } // ROM access in range [00-7f]
+ virtual DECLARE_READ8_MEMBER(read_h) { return 0xff; } // ROM access in range [80-ff]
+ virtual DECLARE_READ8_MEMBER(read_ram) { UINT32 mask = m_nvram_size - 1; return m_nvram[offset & mask]; } // NVRAM access
+ virtual DECLARE_WRITE8_MEMBER(write_l) {} // used by carts with subslots
+ virtual DECLARE_WRITE8_MEMBER(write_h) {} // used by carts with subslots
+ virtual DECLARE_WRITE8_MEMBER(write_ram) { UINT32 mask = m_nvram_size - 1; m_nvram[offset & mask] = data; return; } // NVRAM access
virtual DECLARE_READ8_MEMBER(chip_read) { return 0xff; }
virtual DECLARE_WRITE8_MEMBER(chip_write) {}
@@ -137,8 +139,10 @@ public:
// reading and writing
virtual DECLARE_READ8_MEMBER(read_l);
virtual DECLARE_READ8_MEMBER(read_h);
+ virtual DECLARE_READ8_MEMBER(read_ram);
virtual DECLARE_WRITE8_MEMBER(write_l);
virtual DECLARE_WRITE8_MEMBER(write_h);
+ virtual DECLARE_WRITE8_MEMBER(write_ram);
virtual DECLARE_READ8_MEMBER(chip_read);
virtual DECLARE_WRITE8_MEMBER(chip_write);
diff --git a/src/mess/machine/sns_spc7110.c b/src/mess/machine/sns_spc7110.c
index 5c2d655024c..9f43b201b4b 100644
--- a/src/mess/machine/sns_spc7110.c
+++ b/src/mess/machine/sns_spc7110.c
@@ -1008,67 +1008,6 @@ void sns_rom_spc7110_device::spc7110_update_time(UINT8 offset)
}
}
-READ8_MEMBER(sns_rom_spc7110_device::read_l)
-{
- UINT16 address = offset & 0xffff;
- if (offset < 0x400000)
- {
- if (address >= 0x6000 && address < 0x8000)
- {
- if (offset < 0x10000)
- return m_ram[offset & 0x1fff];
- if (offset >= 0x300000 && offset < 0x310000)
- return m_ram[offset & 0x1fff];
- }
- if (address >= 0x8000)
- return m_rom[rom_bank_map[offset / 0x8000] * 0x8000 + (offset & 0x7fff)];
- }
-
- return 0xff;
-}
-
-READ8_MEMBER(sns_rom_spc7110_device::read_h)
-{
- UINT16 address = offset & 0xfffff;
-
- if (offset < 0x400000)
- {
- if (address >= 0x6000 && address < 0x8000)
- {
- if (offset < 0x10000)
- return m_ram[offset & 0x1fff];
- if (offset >= 0x300000 && offset < 0x310000)
- return m_ram[offset & 0x1fff];
- }
- if (address >= 0x8000)
- return m_rom[rom_bank_map[offset / 0x8000] * 0x8000 + (offset & 0x7fff)];
- }
- else
- {
- switch (offset & 0x300000)
- {
- case 0x000000:
- return m_rom[rom_bank_map[(offset - 0x400000) / 0x8000] * 0x8000 + (offset & 0x7fff)];
- case 0x100000:
- return m_rom[m_dx_offset + address];
- case 0x200000:
- return m_rom[m_ex_offset + address];
- case 0x300000:
- return m_rom[m_fx_offset + address];
- default:
- break;
- }
- }
-
- return 0xff;
-}
-
-WRITE8_MEMBER(sns_rom_spc7110_device::write_l)
-{
- m_ram[offset & 0x1fff] = data;
-}
-
-
READ8_MEMBER(sns_rom_spc7110_device::chip_read)
{
UINT8 *ROM = get_rom_base();
@@ -1640,3 +1579,49 @@ WRITE8_MEMBER(sns_rom_spc7110_device::chip_write)
break;
}
}
+
+READ8_MEMBER(sns_rom_spc7110_device::read_l)
+{
+ if (offset < 0x400000)
+ return m_rom[rom_bank_map[offset / 0x8000] * 0x8000 + (offset & 0x7fff)];
+
+ return 0xff;
+}
+
+READ8_MEMBER(sns_rom_spc7110_device::read_h)
+{
+ UINT16 address = offset & 0xfffff;
+
+ if (offset < 0x400000)
+ return m_rom[rom_bank_map[offset / 0x8000] * 0x8000 + (offset & 0x7fff)];
+ else
+ {
+ switch (offset & 0x300000)
+ {
+ case 0x000000:
+ return m_rom[rom_bank_map[(offset - 0x400000) / 0x8000] * 0x8000 + (offset & 0x7fff)];
+ case 0x100000:
+ return m_rom[m_dx_offset + address];
+ case 0x200000:
+ return m_rom[m_ex_offset + address];
+ case 0x300000:
+ return m_rom[m_fx_offset + address];
+ default:
+ break;
+ }
+ }
+
+ return 0xff;
+}
+
+
+READ8_MEMBER( sns_rom_spc7110_device::read_ram )
+{
+ return m_ram[offset & 0x1fff];
+}
+
+WRITE8_MEMBER( sns_rom_spc7110_device::write_ram )
+{
+ m_ram[offset & 0x1fff] = data;
+}
+
diff --git a/src/mess/machine/sns_spc7110.h b/src/mess/machine/sns_spc7110.h
index 7321707a288..73362a15cb3 100644
--- a/src/mess/machine/sns_spc7110.h
+++ b/src/mess/machine/sns_spc7110.h
@@ -82,7 +82,8 @@ public:
// reading and writing
virtual DECLARE_READ8_MEMBER(read_l);
virtual DECLARE_READ8_MEMBER(read_h);
- virtual DECLARE_WRITE8_MEMBER(write_l);
+ virtual DECLARE_READ8_MEMBER(read_ram);
+ virtual DECLARE_WRITE8_MEMBER(write_ram);
virtual DECLARE_READ8_MEMBER(chip_read);
virtual DECLARE_WRITE8_MEMBER(chip_write);
@@ -198,7 +199,6 @@ public:
// we just use the spc7110 ones for the moment, pending the split of regs 0x4840-0x4842 (RTC) from the base add-on
// virtual DECLARE_READ8_MEMBER(read_l);
// virtual DECLARE_READ8_MEMBER(read_h);
-// virtual DECLARE_WRITE8_MEMBER(write_l);
// virtual DECLARE_READ8_MEMBER(chip_read);
// virtual DECLARE_WRITE8_MEMBER(chip_write);
diff --git a/src/mess/machine/sns_sufami.c b/src/mess/machine/sns_sufami.c
index cbe5bc7e675..489b037fec1 100644
--- a/src/mess/machine/sns_sufami.c
+++ b/src/mess/machine/sns_sufami.c
@@ -81,9 +81,11 @@ READ8_MEMBER(sns_rom_sufami_device::read_l)
READ8_MEMBER(sns_rom_sufami_device::read_h)
{
+ int bank;
+
if (offset < 0x200000) // SUFAMI TURBO ROM
{
- int bank = offset / 0x10000;
+ bank = offset / 0x10000;
return m_rom[rom_bank_map[bank] * 0x8000 + (offset & 0x7fff)];
}
if (offset >= 0x200000 && offset < 0x400000) // SLOT1 STROM
@@ -98,13 +100,21 @@ READ8_MEMBER(sns_rom_sufami_device::read_h)
}
if (offset >= 0x600000 && offset < 0x640000) // SLOT1 RAM
{
- if (m_slot1->m_cart && (offset & 0xffff) > 0x8000)
- return m_slot1->m_cart->read_h(space, offset - 0x600000);
+ if (m_slot1->m_cart && (offset & 0xffff) >= 0x8000)
+ {
+ offset -= 0x600000;
+ bank = offset / 0x10000;
+ return m_slot1->m_cart->read_ram(space, bank * 0x8000 + (offset & 0x7fff));
+ }
}
if (offset >= 0x700000 && offset < 0x740000) // SLOT2 RAM
{
- if (m_slot2->m_cart && (offset & 0xffff) > 0x8000)
- return m_slot2->m_cart->read_h(space, offset - 0x700000);
+ if (m_slot2->m_cart && (offset & 0xffff) >= 0x8000)
+ {
+ offset -= 0x700000;
+ bank = offset / 0x10000;
+ return m_slot2->m_cart->read_ram(space, bank * 0x8000 + (offset & 0x7fff));
+ }
}
return 0xff;
@@ -117,16 +127,25 @@ WRITE8_MEMBER(sns_rom_sufami_device::write_l)
WRITE8_MEMBER(sns_rom_sufami_device::write_h)
{
+ int bank;
if (offset >= 0x600000 && offset < 0x640000) // SLOT1 RAM
{
- if (m_slot1->m_cart && (offset & 0xffff) > 0x8000)
- return m_slot1->m_cart->write_h(space, offset - 0x600000, data);
+ if (m_slot1->m_cart && (offset & 0xffff) >= 0x8000)
+ {
+ offset -= 0x600000;
+ bank = offset / 0x10000;
+ m_slot1->m_cart->write_ram(space, bank * 0x8000 + (offset & 0x7fff), data);
+ }
}
if (offset >= 0x700000 && offset < 0x740000) // SLOT2 RAM
{
- if (m_slot2->m_cart && (offset & 0xffff) > 0x8000)
- return m_slot2->m_cart->write_h(space, offset - 0x700000, data);
+ if (m_slot2->m_cart && (offset & 0xffff) >= 0x8000)
+ {
+ offset -= 0x700000;
+ bank = offset / 0x10000;
+ m_slot2->m_cart->write_ram(space, bank * 0x8000 + (offset & 0x7fff), data);
+ }
}
}
@@ -135,11 +154,6 @@ WRITE8_MEMBER(sns_rom_sufami_device::write_h)
Sufami Turbo 'minicart' emulation
-------------------------------------------------*/
-// Here we're cheating a bit, for the moment, to avoid the need of ST carts as a completely different device
-// which would require separate loading routines
-// Hence, we use low r/w handlers for ROM access and hi r/w handlers for RAM access...
-// Eventually, it might be better to create a separate device for these, with rom_r and ram_r/ram_w handlers
-
READ8_MEMBER(sns_rom_strom_device::read_l)
{
if (offset < 0x200000)
@@ -149,26 +163,3 @@ READ8_MEMBER(sns_rom_strom_device::read_l)
}
return 0xff;
}
-
-READ8_MEMBER(sns_rom_strom_device::read_h)
-{
- if (offset < 0x40000)
- {
- int bank = offset / 0x10000;
- return m_nvram[bank * 0x8000 + (offset & 0x7fff)];
- }
- return 0xff;
-}
-
-WRITE8_MEMBER(sns_rom_strom_device::write_l)
-{
-}
-
-WRITE8_MEMBER(sns_rom_strom_device::write_h)
-{
- if (offset < 0x40000)
- {
- int bank = offset / 0x10000;
- m_nvram[bank * 0x8000 + (offset & 0x7fff)] = data;
- }
-}
diff --git a/src/mess/machine/sns_sufami.h b/src/mess/machine/sns_sufami.h
index f6878afd9c7..c587f8fe85b 100644
--- a/src/mess/machine/sns_sufami.h
+++ b/src/mess/machine/sns_sufami.h
@@ -42,10 +42,7 @@ public:
virtual void device_config_complete() { m_shortname = "sns_strom"; }
// additional reading and writing
- virtual DECLARE_READ8_MEMBER(read_l); // used for ROM
- virtual DECLARE_READ8_MEMBER(read_h); // used for ROM
- virtual DECLARE_WRITE8_MEMBER(write_l); // used for RAM
- virtual DECLARE_WRITE8_MEMBER(write_h); // used for RAM
+ virtual DECLARE_READ8_MEMBER(read_l);
};