summaryrefslogtreecommitdiffstatshomepage
path: root/src
diff options
context:
space:
mode:
author Vas Crabb <vas@vastheman.com>2017-07-23 13:10:14 +1000
committer Vas Crabb <vas@vastheman.com>2017-07-23 13:10:14 +1000
commit3b369d976b6037a34edbc45d6eb9b8bead99f4c8 (patch)
tree7e7b07e1b05bf02c46bdbfe8f7806140c45fdfac /src
parentdbdebf75440e3bce2efc1c7a7b672bf10d0ce709 (diff)
Clean up Galeco Dallas hookup device.
There is no need for a second device for World Rally and Glass, it's the same thing. How the address lines are hooked up for host memory access is part of the driver and can be done with a mirror/mask in the address map provided by the driver. There's also no need for the SRAM trampolines in the device, that can be done entirely through address maps. The drivers need trampolines to do the address swizzling. We should be able to get rid of these when we get better support for 8-bit views of 16-bit components (dooyong drivers also have ugly trampolines for doing this kind of thing).
Diffstat (limited to 'src')
-rw-r--r--src/mame/drivers/gaelco2.cpp23
-rw-r--r--src/mame/drivers/glass.cpp47
-rw-r--r--src/mame/drivers/targeth.cpp19
-rw-r--r--src/mame/drivers/thoop2.cpp22
-rw-r--r--src/mame/drivers/wrally.cpp14
-rw-r--r--src/mame/includes/gaelco2.h2
-rw-r--r--src/mame/includes/glass.h10
-rw-r--r--src/mame/includes/targeth.h43
-rw-r--r--src/mame/includes/thoop2.h26
-rw-r--r--src/mame/includes/wrally.h47
-rw-r--r--src/mame/machine/gaelco2.cpp24
-rw-r--r--src/mame/machine/gaelco_ds5002fp.cpp92
-rw-r--r--src/mame/machine/gaelco_ds5002fp.h50
-rw-r--r--src/mame/machine/wrally.cpp12
14 files changed, 264 insertions, 167 deletions
diff --git a/src/mame/drivers/gaelco2.cpp b/src/mame/drivers/gaelco2.cpp
index 7e2a2bb81dd..5fecd95adea 100644
--- a/src/mame/drivers/gaelco2.cpp
+++ b/src/mame/drivers/gaelco2.cpp
@@ -30,9 +30,11 @@
#include "emu.h"
#include "includes/gaelco2.h"
+#include "machine/gaelco_ds5002fp.h"
+
+#include "cpu/mcs51/mcs51.h"
#include "machine/eepromser.h"
#include "sound/gaelco.h"
-#include "machine/gaelco_ds5002fp.h"
#include "rendlay.h"
#include "screen.h"
@@ -63,6 +65,17 @@ GFXDECODEINFO(0x0200000, 128)
TILELAYOUT16(0x0400000)
GFXDECODEINFO(0x0400000, 128)
+
+
+/*============================================================================
+ COMMON
+ ============================================================================*/
+
+static ADDRESS_MAP_START( mcu_hostmem_map, 0, 8, gaelco2_state )
+ AM_RANGE(0x8000, 0xffff) AM_READWRITE(shareram_r, shareram_w) // confirmed that 0x8000 - 0xffff is a window into 68k shared RAM
+ADDRESS_MAP_END
+
+
/*============================================================================
MANIAC SQUARE (FINAL)
============================================================================*/
@@ -196,7 +209,7 @@ MACHINE_CONFIG_END
static MACHINE_CONFIG_DERIVED( maniacsq_d5002fp, maniacsq )
MCFG_DEVICE_ADD("gaelco_ds5002fp", GAELCO_DS5002FP, XTAL_24MHz / 2) /* ? */
- GAELCO_DS5002FP_SET_SHARE_TAG("shareram")
+ MCFG_DEVICE_ADDRESS_MAP(0, mcu_hostmem_map)
MACHINE_CONFIG_END
ROM_START( maniacsq )
@@ -578,7 +591,7 @@ MACHINE_CONFIG_END
static MACHINE_CONFIG_DERIVED( alighunt_d5002fp, alighunt )
MCFG_DEVICE_ADD("gaelco_ds5002fp", GAELCO_DS5002FP, XTAL_24MHz / 2) /* ? */
- GAELCO_DS5002FP_SET_SHARE_TAG("shareram")
+ MCFG_DEVICE_ADDRESS_MAP(0, mcu_hostmem_map)
MACHINE_CONFIG_END
/*
@@ -835,7 +848,7 @@ MACHINE_CONFIG_END
static MACHINE_CONFIG_DERIVED( touchgo_d5002fp, touchgo )
MCFG_DEVICE_ADD("gaelco_ds5002fp", GAELCO_DS5002FP, XTAL_24MHz / 2) /* ? */
- GAELCO_DS5002FP_SET_SHARE_TAG("shareram")
+ MCFG_DEVICE_ADDRESS_MAP(0, mcu_hostmem_map)
MACHINE_CONFIG_END
/*
@@ -1278,7 +1291,7 @@ static MACHINE_CONFIG_START( wrally2 )
MCFG_CPU_VBLANK_INT_DRIVER("lscreen", gaelco2_state, irq6_line_hold)
MCFG_DEVICE_ADD("gaelco_ds5002fp", GAELCO_DS5002FP, XTAL_24MHz / 2)
- GAELCO_DS5002FP_SET_SHARE_TAG("shareram")
+ MCFG_DEVICE_ADDRESS_MAP(0, mcu_hostmem_map)
MCFG_EEPROM_SERIAL_93C66_ADD("eeprom")
diff --git a/src/mame/drivers/glass.cpp b/src/mame/drivers/glass.cpp
index c7d419d144e..525ff786db8 100644
--- a/src/mame/drivers/glass.cpp
+++ b/src/mame/drivers/glass.cpp
@@ -21,6 +21,19 @@ except for the Promat licensed Korean version which is unprotected.
#include "speaker.h"
+WRITE8_MEMBER(glass_state::shareram_w)
+{
+ // why isn't there an AM_SOMETHING macro for this?
+ reinterpret_cast<u8 *>(m_shareram.target())[BYTE_XOR_BE(offset)] = data;
+}
+
+READ8_MEMBER(glass_state::shareram_r)
+{
+ // why isn't there an AM_SOMETHING macro for this?
+ return reinterpret_cast<u8 const *>(m_shareram.target())[BYTE_XOR_BE(offset)];
+}
+
+
WRITE16_MEMBER(glass_state::clr_int_w)
{
m_cause_interrupt = 1;
@@ -81,23 +94,29 @@ WRITE16_MEMBER(glass_state::coin_w)
}
}
+
+static ADDRESS_MAP_START( mcu_hostmem_map, 0, 8, glass_state )
+ AM_RANGE(0x0000, 0xffff) AM_MASK(0x3fff) AM_READWRITE(shareram_r, shareram_w) // shared RAM with the main CPU
+ADDRESS_MAP_END
+
+
static ADDRESS_MAP_START( glass_map, AS_PROGRAM, 16, glass_state )
- AM_RANGE(0x000000, 0x0fffff) AM_ROM /* ROM */
- AM_RANGE(0x100000, 0x101fff) AM_RAM_WRITE(vram_w) AM_SHARE("videoram") /* Video RAM */
- AM_RANGE(0x102000, 0x102fff) AM_RAM /* Extra Video RAM */
- AM_RANGE(0x108000, 0x108007) AM_WRITEONLY AM_SHARE("vregs") /* Video Registers */
- AM_RANGE(0x108008, 0x108009) AM_WRITE(clr_int_w) /* CLR INT Video */
- AM_RANGE(0x200000, 0x2007ff) AM_RAM_DEVWRITE("palette", palette_device, write) AM_SHARE("palette") /* Palette */
- AM_RANGE(0x440000, 0x440fff) AM_RAM AM_SHARE("spriteram") /* Sprite RAM */
+ AM_RANGE(0x000000, 0x0fffff) AM_ROM // ROM
+ AM_RANGE(0x100000, 0x101fff) AM_RAM_WRITE(vram_w) AM_SHARE("videoram") // Video RAM
+ AM_RANGE(0x102000, 0x102fff) AM_RAM // Extra Video RAM
+ AM_RANGE(0x108000, 0x108007) AM_WRITEONLY AM_SHARE("vregs") // Video Registers
+ AM_RANGE(0x108008, 0x108009) AM_WRITE(clr_int_w) // CLR INT Video
+ AM_RANGE(0x200000, 0x2007ff) AM_RAM_DEVWRITE("palette", palette_device, write) AM_SHARE("palette") // Palette
+ AM_RANGE(0x440000, 0x440fff) AM_RAM AM_SHARE("spriteram") // Sprite RAM
AM_RANGE(0x700000, 0x700001) AM_READ_PORT("DSW2")
AM_RANGE(0x700002, 0x700003) AM_READ_PORT("DSW1")
AM_RANGE(0x700004, 0x700005) AM_READ_PORT("P1")
AM_RANGE(0x700006, 0x700007) AM_READ_PORT("P2")
- AM_RANGE(0x700008, 0x700009) AM_WRITE(blitter_w) /* serial blitter */
- AM_RANGE(0x70000c, 0x70000d) AM_WRITE(OKIM6295_bankswitch_w) /* OKI6295 bankswitch */
- AM_RANGE(0x70000e, 0x70000f) AM_DEVREADWRITE8("oki", okim6295_device, read, write, 0x00ff) /* OKI6295 status register */
- AM_RANGE(0x70000a, 0x70004b) AM_WRITE(coin_w) /* Coin Counters/Lockout */
- AM_RANGE(0xfec000, 0xfeffff) AM_RAM AM_SHARE("shareram") /* Work RAM (partially shared with DS5002FP) */
+ AM_RANGE(0x700008, 0x700009) AM_WRITE(blitter_w) // serial blitter
+ AM_RANGE(0x70000c, 0x70000d) AM_WRITE(OKIM6295_bankswitch_w) // OKI6295 bankswitch
+ AM_RANGE(0x70000e, 0x70000f) AM_DEVREADWRITE8("oki", okim6295_device, read, write, 0x00ff) // OKI6295 status register
+ AM_RANGE(0x70000a, 0x70004b) AM_WRITE(coin_w) // Coin Counters/Lockout
+ AM_RANGE(0xfec000, 0xfeffff) AM_RAM AM_SHARE("shareram") // Work RAM (partially shared with DS5002FP)
ADDRESS_MAP_END
@@ -229,8 +248,8 @@ static MACHINE_CONFIG_START( glass )
MACHINE_CONFIG_END
static MACHINE_CONFIG_DERIVED( glass_ds5002fp, glass )
- MCFG_DEVICE_ADD("gaelco_ds5002fp", GAELCO_DS5002FP_WRALLY, XTAL_24MHz / 2) /* verified on pcb */
- GAELCO_DS5002FP_SET_SHARE_TAG("shareram")
+ MCFG_DEVICE_ADD("gaelco_ds5002fp", GAELCO_DS5002FP, XTAL_24MHz / 2) /* verified on pcb */
+ MCFG_DEVICE_ADDRESS_MAP(0, mcu_hostmem_map)
MACHINE_CONFIG_END
ROM_START( glass ) /* Version 1.1 */
diff --git a/src/mame/drivers/targeth.cpp b/src/mame/drivers/targeth.cpp
index 0bc5f85d6e8..5a9e8626e29 100644
--- a/src/mame/drivers/targeth.cpp
+++ b/src/mame/drivers/targeth.cpp
@@ -106,6 +106,23 @@ WRITE16_MEMBER(targeth_state::coin_counter_w)
machine().bookkeeping().coin_counter_w((offset >> 3) & 0x01, data & 0x01);
}
+WRITE8_MEMBER(targeth_state::shareram_w)
+{
+ // why isn't there an AM_SOMETHING macro for this?
+ reinterpret_cast<u8 *>(m_shareram.target())[BYTE_XOR_BE(offset)] = data;
+}
+
+READ8_MEMBER(targeth_state::shareram_r)
+{
+ // why isn't there an AM_SOMETHING macro for this?
+ return reinterpret_cast<u8 const *>(m_shareram.target())[BYTE_XOR_BE(offset)];
+}
+
+
+static ADDRESS_MAP_START( mcu_hostmem_map, 0, 8, targeth_state )
+ AM_RANGE(0x8000, 0xffff) AM_READWRITE(shareram_r, shareram_w) // confirmed that 0x8000 - 0xffff is a window into 68k shared RAM
+ADDRESS_MAP_END
+
static ADDRESS_MAP_START( main_map, AS_PROGRAM, 16, targeth_state )
AM_RANGE(0x000000, 0x0fffff) AM_ROM
AM_RANGE(0x100000, 0x103fff) AM_RAM_WRITE(vram_w) AM_SHARE("videoram") /* Video RAM */
@@ -234,7 +251,7 @@ static MACHINE_CONFIG_START( targeth )
MCFG_TIMER_DRIVER_ADD_SCANLINE("scantimer", targeth_state, interrupt, "screen", 0, 1)
MCFG_DEVICE_ADD("gaelco_ds5002fp", GAELCO_DS5002FP, XTAL_24MHz / 2)
- GAELCO_DS5002FP_SET_SHARE_TAG("shareram")
+ MCFG_DEVICE_ADDRESS_MAP(0, mcu_hostmem_map)
/* video hardware */
MCFG_SCREEN_ADD("screen", RASTER)
diff --git a/src/mame/drivers/thoop2.cpp b/src/mame/drivers/thoop2.cpp
index 629eacbe4d2..335d33be715 100644
--- a/src/mame/drivers/thoop2.cpp
+++ b/src/mame/drivers/thoop2.cpp
@@ -15,10 +15,14 @@ maybe bad dump of DS5002FP rom, maybe CPU bugs
#include "emu.h"
#include "includes/thoop2.h"
+
#include "machine/gaelco_ds5002fp.h"
+
#include "cpu/m68000/m68000.h"
+#include "cpu/mcs51/mcs51.h"
#include "machine/watchdog.h"
#include "sound/okim6295.h"
+
#include "screen.h"
#include "speaker.h"
@@ -54,6 +58,22 @@ WRITE16_MEMBER(thoop2_state::coin_w)
/* 05b unknown */
}
+WRITE8_MEMBER(thoop2_state::shareram_w)
+{
+ // why isn't there an AM_SOMETHING macro for this?
+ reinterpret_cast<u8 *>(m_shareram.target())[BYTE_XOR_BE(offset)] = data;
+}
+
+READ8_MEMBER(thoop2_state::shareram_r)
+{
+ // why isn't there an AM_SOMETHING macro for this?
+ return reinterpret_cast<u8 const *>(m_shareram.target())[BYTE_XOR_BE(offset)];
+}
+
+
+static ADDRESS_MAP_START( mcu_hostmem_map, 0, 8, thoop2_state )
+ AM_RANGE(0x8000, 0xffff) AM_READWRITE(shareram_r, shareram_w) // confirmed that 0x8000 - 0xffff is a window into 68k shared RAM
+ADDRESS_MAP_END
static ADDRESS_MAP_START( thoop2_map, AS_PROGRAM, 16, thoop2_state )
@@ -202,7 +222,7 @@ static MACHINE_CONFIG_START( thoop2 )
MCFG_CPU_VBLANK_INT_DRIVER("screen", thoop2_state, irq6_line_hold)
MCFG_DEVICE_ADD("gaelco_ds5002fp", GAELCO_DS5002FP, XTAL_24MHz / 2)
- GAELCO_DS5002FP_SET_SHARE_TAG("shareram")
+ MCFG_DEVICE_ADDRESS_MAP(0, mcu_hostmem_map)
MCFG_WATCHDOG_ADD("watchdog")
diff --git a/src/mame/drivers/wrally.cpp b/src/mame/drivers/wrally.cpp
index 6dca3688eaa..62aae7a0506 100644
--- a/src/mame/drivers/wrally.cpp
+++ b/src/mame/drivers/wrally.cpp
@@ -127,13 +127,21 @@ The PCB has a layout that can either use the 4 rom set of I7, I9, I11 & I13 or l
#include "emu.h"
#include "includes/wrally.h"
-#include "cpu/m68000/m68000.h"
#include "machine/gaelco_ds5002fp.h"
+
+#include "cpu/m68000/m68000.h"
+#include "cpu/mcs51/mcs51.h"
#include "sound/okim6295.h"
+
#include "screen.h"
#include "speaker.h"
+static ADDRESS_MAP_START( mcu_hostmem_map, 0, 8, wrally_state )
+ AM_RANGE(0x0000, 0xffff) AM_MASK(0x3fff) AM_READWRITE(shareram_r, shareram_w) // shared RAM with the main CPU
+ADDRESS_MAP_END
+
+
static ADDRESS_MAP_START( wrally_map, AS_PROGRAM, 16, wrally_state )
AM_RANGE(0x000000, 0x0fffff) AM_ROM /* ROM */
AM_RANGE(0x100000, 0x103fff) AM_RAM_WRITE(vram_w) AM_SHARE("videoram") /* encrypted Video RAM */
@@ -260,8 +268,8 @@ static MACHINE_CONFIG_START( wrally )
MCFG_CPU_PROGRAM_MAP(wrally_map)
MCFG_CPU_VBLANK_INT_DRIVER("screen", wrally_state, irq6_line_hold)
- MCFG_DEVICE_ADD("gaelco_ds5002fp", GAELCO_DS5002FP_WRALLY, XTAL_24MHz / 2) /* verified on pcb */
- GAELCO_DS5002FP_SET_SHARE_TAG("shareram")
+ MCFG_DEVICE_ADD("gaelco_ds5002fp", GAELCO_DS5002FP, XTAL_24MHz / 2) /* verified on pcb */
+ MCFG_DEVICE_ADDRESS_MAP(0, mcu_hostmem_map)
/* video hardware */
MCFG_SCREEN_ADD("screen", RASTER)
diff --git a/src/mame/includes/gaelco2.h b/src/mame/includes/gaelco2.h
index d4657749af3..d132b267585 100644
--- a/src/mame/includes/gaelco2.h
+++ b/src/mame/includes/gaelco2.h
@@ -20,6 +20,8 @@ public:
m_shareram(*this, "shareram")
{ }
+ DECLARE_WRITE8_MEMBER(shareram_w);
+ DECLARE_READ8_MEMBER(shareram_r);
DECLARE_WRITE16_MEMBER(gaelco2_coin_w);
DECLARE_WRITE16_MEMBER(gaelco2_coin2_w);
DECLARE_WRITE16_MEMBER(touchgo_coin_w);
diff --git a/src/mame/includes/glass.h b/src/mame/includes/glass.h
index dabe0bb901d..0f4159027c6 100644
--- a/src/mame/includes/glass.h
+++ b/src/mame/includes/glass.h
@@ -9,15 +9,17 @@
class glass_state : public driver_device
{
public:
- glass_state(const machine_config &mconfig, device_type type, const char *tag)
- : driver_device(mconfig, type, tag),
+ glass_state(const machine_config &mconfig, device_type type, const char *tag) :
+ driver_device(mconfig, type, tag),
m_maincpu(*this, "maincpu"),
m_gfxdecode(*this, "gfxdecode"),
m_palette(*this, "palette"),
m_videoram(*this, "videoram"),
m_vregs(*this, "vregs"),
m_spriteram(*this, "spriteram"),
- m_shareram(*this, "shareram") { }
+ m_shareram(*this, "shareram"),
+ m_pant{ nullptr, nullptr }
+ { }
/* devices */
@@ -41,6 +43,8 @@ public:
int m_cause_interrupt;
int m_blitter_serial_buffer[5];
+ DECLARE_WRITE8_MEMBER(shareram_w);
+ DECLARE_READ8_MEMBER(shareram_r);
DECLARE_WRITE16_MEMBER(clr_int_w);
DECLARE_WRITE16_MEMBER(OKIM6295_bankswitch_w);
DECLARE_WRITE16_MEMBER(coin_w);
diff --git a/src/mame/includes/targeth.h b/src/mame/includes/targeth.h
index caa695e2d49..bf84a9e6755 100644
--- a/src/mame/includes/targeth.h
+++ b/src/mame/includes/targeth.h
@@ -1,5 +1,10 @@
// license:BSD-3-Clause
// copyright-holders:Manuel Abadia
+#ifndef MAME_INCLUDES_TARGETH_H
+#define MAME_INCLUDES_TARGETH_H
+
+#pragma once
+
class targeth_state : public driver_device
{
public:
@@ -10,30 +15,40 @@ public:
m_palette(*this, "palette"),
m_videoram(*this, "videoram"),
m_vregs(*this, "vregs"),
- m_spriteram(*this, "spriteram") { }
-
- required_device<cpu_device> m_maincpu;
- required_device<gfxdecode_device> m_gfxdecode;
- required_device<palette_device> m_palette;
-
- required_shared_ptr<uint16_t> m_videoram;
- required_shared_ptr<uint16_t> m_vregs;
- required_shared_ptr<uint16_t> m_spriteram;
-
- tilemap_t *m_pant[2];
+ m_spriteram(*this, "spriteram"),
+ m_shareram(*this, "shareram")
+ { }
DECLARE_WRITE16_MEMBER(OKIM6295_bankswitch_w);
DECLARE_WRITE16_MEMBER(coin_counter_w);
+ DECLARE_WRITE8_MEMBER(shareram_w);
+ DECLARE_READ8_MEMBER(shareram_r);
DECLARE_WRITE16_MEMBER(vram_w);
TILE_GET_INFO_MEMBER(get_tile_info_screen0);
TILE_GET_INFO_MEMBER(get_tile_info_screen1);
- virtual void video_start() override;
- virtual void machine_start() override;
-
TIMER_DEVICE_CALLBACK_MEMBER(interrupt);
uint32_t screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
+
+protected:
+ virtual void video_start() override;
+ virtual void machine_start() override;
+
void draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect);
+
+private:
+ required_device<cpu_device> m_maincpu;
+ required_device<gfxdecode_device> m_gfxdecode;
+ required_device<palette_device> m_palette;
+
+ required_shared_ptr<uint16_t> m_videoram;
+ required_shared_ptr<uint16_t> m_vregs;
+ required_shared_ptr<uint16_t> m_spriteram;
+ optional_shared_ptr<uint16_t> m_shareram;
+
+ tilemap_t *m_pant[2];
};
+
+#endif // MAME_INCLUDES_TARGETH_H
diff --git a/src/mame/includes/thoop2.h b/src/mame/includes/thoop2.h
index 34ac8d40a23..9f74d370e6d 100644
--- a/src/mame/includes/thoop2.h
+++ b/src/mame/includes/thoop2.h
@@ -1,28 +1,39 @@
// license:BSD-3-Clause
// copyright-holders:Manuel Abadia, Peter Ferrie
+#ifndef MAME_INCLUDES_THOOP2_H
+#define MAME_INCLUDES_THOOP2_H
+
+#pragma once
+
class thoop2_state : public driver_device
{
public:
- thoop2_state(const machine_config &mconfig, device_type type, const char *tag)
- : driver_device(mconfig, type, tag),
+ thoop2_state(const machine_config &mconfig, device_type type, const char *tag) :
+ driver_device(mconfig, type, tag),
+ m_pant{ nullptr, nullptr },
m_maincpu(*this, "maincpu"),
m_gfxdecode(*this, "gfxdecode"),
m_palette(*this, "palette"),
m_videoram(*this, "videoram"),
m_vregs(*this, "vregs"),
- m_spriteram(*this, "spriteram")
+ m_spriteram(*this, "spriteram"),
+ m_shareram(*this, "shareram")
{ }
DECLARE_WRITE16_MEMBER(OKIM6295_bankswitch_w);
DECLARE_WRITE16_MEMBER(coin_w);
DECLARE_WRITE16_MEMBER(vram_w);
-
- virtual void machine_start() override;
- virtual void video_start() override;
+ DECLARE_WRITE8_MEMBER(shareram_w);
+ DECLARE_READ8_MEMBER(shareram_r);
TILE_GET_INFO_MEMBER(get_tile_info_screen0);
TILE_GET_INFO_MEMBER(get_tile_info_screen1);
uint32_t screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
+
+protected:
+ virtual void machine_start() override;
+ virtual void video_start() override;
+
void sort_sprites();
void draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect, int pri);
@@ -38,4 +49,7 @@ private:
required_shared_ptr<uint16_t> m_videoram;
required_shared_ptr<uint16_t> m_vregs;
required_shared_ptr<uint16_t> m_spriteram;
+ optional_shared_ptr<uint16_t> m_shareram;
};
+
+#endif // MAME_INCLUDES_THOOP2_H
diff --git a/src/mame/includes/wrally.h b/src/mame/includes/wrally.h
index 4281264cce7..f8529e52599 100644
--- a/src/mame/includes/wrally.h
+++ b/src/mame/includes/wrally.h
@@ -1,31 +1,28 @@
// license:BSD-3-Clause
// copyright-holders:Manuel Abadia, Mike Coates, Nicola Salmoria, Miguel Angel Horna
+#ifndef MAME_INCLUDES_WRALLY_H
+#define MAME_INCLUDES_WRALLY_H
+
+#pragma once
+
class wrally_state : public driver_device
{
public:
- wrally_state(const machine_config &mconfig, device_type type, const char *tag)
- : driver_device(mconfig, type, tag),
+ wrally_state(const machine_config &mconfig, device_type type, const char *tag) :
+ driver_device(mconfig, type, tag),
m_maincpu(*this, "maincpu"),
m_gfxdecode(*this, "gfxdecode"),
m_palette(*this, "palette"),
m_videoram(*this, "videoram"),
m_vregs(*this, "vregs"),
m_spriteram(*this, "spriteram"),
- m_shareram(*this, "shareram") { }
-
- required_device<cpu_device> m_maincpu;
- required_device<gfxdecode_device> m_gfxdecode;
- required_device<palette_device> m_palette;
-
- required_shared_ptr<uint16_t> m_videoram;
- required_shared_ptr<uint16_t> m_vregs;
- required_shared_ptr<uint16_t> m_spriteram;
- required_shared_ptr<uint16_t> m_shareram;
+ m_shareram(*this, "shareram"),
+ m_pant{ nullptr, nullptr }
+ {
+ }
- tilemap_t *m_pant[2];
-
- DECLARE_READ8_MEMBER(dallas_share_r);
- DECLARE_WRITE8_MEMBER(dallas_share_w);
+ DECLARE_READ8_MEMBER(shareram_r);
+ DECLARE_WRITE8_MEMBER(shareram_w);
DECLARE_WRITE16_MEMBER(vram_w);
DECLARE_WRITE16_MEMBER(flipscreen_w);
DECLARE_WRITE16_MEMBER(okim6295_bankswitch_w);
@@ -35,9 +32,25 @@ public:
TILE_GET_INFO_MEMBER(get_tile_info_screen0);
TILE_GET_INFO_MEMBER(get_tile_info_screen1);
+ uint32_t screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
+
+protected:
virtual void machine_start() override;
virtual void video_start() override;
- uint32_t screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
void draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect, int priority);
+
+private:
+ required_device<cpu_device> m_maincpu;
+ required_device<gfxdecode_device> m_gfxdecode;
+ required_device<palette_device> m_palette;
+
+ required_shared_ptr<uint16_t> m_videoram;
+ required_shared_ptr<uint16_t> m_vregs;
+ required_shared_ptr<uint16_t> m_spriteram;
+ required_shared_ptr<uint16_t> m_shareram;
+
+ tilemap_t *m_pant[2];
};
+
+#endif // MAME_INCLUDES_WRALLY_H
diff --git a/src/mame/machine/gaelco2.cpp b/src/mame/machine/gaelco2.cpp
index e6794b5f42a..3b92aed9a81 100644
--- a/src/mame/machine/gaelco2.cpp
+++ b/src/mame/machine/gaelco2.cpp
@@ -10,10 +10,12 @@
***************************************************************************/
#include "emu.h"
-#include "machine/eepromser.h"
#include "includes/gaelco2.h"
+
+#include "machine/eepromser.h"
#include "chd.h"
+
/***************************************************************************
Split even/odd bytes from ROMs in 16 bit mode to different memory areas
@@ -133,6 +135,26 @@ DRIVER_INIT_MEMBER(gaelco2_state,snowboar)
gaelco2_ROM16_split_gfx("gfx2", "gfx1", 0x0800000, 0x0400000, 0x0800000, 0x0c00000);
}
+
+/***************************************************************************
+
+ MCU communication
+
+***************************************************************************/
+
+WRITE8_MEMBER(gaelco2_state::shareram_w)
+{
+ // why isn't there an AM_SOMETHING macro for this?
+ reinterpret_cast<u8 *>(m_shareram.target())[BYTE_XOR_BE(offset)] = data;
+}
+
+READ8_MEMBER(gaelco2_state::shareram_r)
+{
+ // why isn't there an AM_SOMETHING macro for this?
+ return reinterpret_cast<u8 const *>(m_shareram.target())[BYTE_XOR_BE(offset)];
+}
+
+
/***************************************************************************
Coin counters/lockouts
diff --git a/src/mame/machine/gaelco_ds5002fp.cpp b/src/mame/machine/gaelco_ds5002fp.cpp
index 16336e3dc7b..ce05d6a5618 100644
--- a/src/mame/machine/gaelco_ds5002fp.cpp
+++ b/src/mame/machine/gaelco_ds5002fp.cpp
@@ -3,66 +3,44 @@
#include "emu.h"
#include "machine/gaelco_ds5002fp.h"
-DEFINE_DEVICE_TYPE(GAELCO_DS5002FP, gaelco_ds5002fp_device, "gaelco_ds5002fp", "Gaelco DS5002FP")
-DEFINE_DEVICE_TYPE(GAELCO_DS5002FP_WRALLY, gaelco_ds5002fp_wrally_device, "gaelco_ds5002fp_wr", "Gaelco DS5002FP (World Rally)")
+#include "cpu/mcs51/mcs51.h"
+#include "machine/nvram.h"
-gaelco_ds5002fp_device_base::gaelco_ds5002fp_device_base(machine_config const &mconfig, device_type type, char const *tag, device_t *owner, u32 clock)
- : device_t(mconfig, type, tag, owner, clock),
- m_shareram(*this, finder_base::DUMMY_TAG),
- m_sram(*this, "sram")
-{
-}
+DEFINE_DEVICE_TYPE(GAELCO_DS5002FP, gaelco_ds5002fp_device, "gaelco_ds5002fp", "Gaelco DS5002FP")
-void gaelco_ds5002fp_device_base::static_set_share_tag(device_t &device, const char *tag)
-{
- downcast<gaelco_ds5002fp_device_base &>(device).m_shareram.set_tag(tag);
-}
+namespace {
-READ8_MEMBER(gaelco_ds5002fp_device_base::shareram_r)
-{
- uint8_t *shareram = (uint8_t *)m_shareram.target();
- return shareram[BYTE_XOR_BE(offset)];
-}
+ADDRESS_MAP_START( dallas_rom, AS_PROGRAM, 8, gaelco_ds5002fp_device )
+ AM_RANGE(0x00000, 0x07fff) AM_READONLY AM_SHARE("sram")
+ADDRESS_MAP_END
-WRITE8_MEMBER(gaelco_ds5002fp_device_base::shareram_w)
-{
- uint8_t *shareram = (uint8_t *)m_shareram.target();
- shareram[BYTE_XOR_BE(offset)] = data;
-}
+ADDRESS_MAP_START( dallas_ram, AS_IO, 8, gaelco_ds5002fp_device )
+ AM_RANGE(0x00000, 0x0ffff) AM_READWRITE(hostmem_r, hostmem_w)
+ AM_RANGE(0x10000, 0x17fff) AM_RAM AM_SHARE("sram") // yes, the games access it as data and use it for temporary storage!!
+ADDRESS_MAP_END
-READ8_MEMBER(gaelco_ds5002fp_device_base::sram_r)
-{
- return m_sram[offset];
-}
+} // anonymous namespace
-WRITE8_MEMBER(gaelco_ds5002fp_device_base::sram_w)
-{
- m_sram[offset] = data;
-}
-void gaelco_ds5002fp_device_base::device_start()
+gaelco_ds5002fp_device::gaelco_ds5002fp_device(machine_config const &mconfig, char const *tag, device_t *owner, u32 clock)
+ : device_t(mconfig, GAELCO_DS5002FP, tag, owner, clock)
+ , device_memory_interface(mconfig, *this)
+ , m_hostmem_config({ "hostmem", ENDIANNESS_BIG, 8, 16, 0 })
+ , m_hostmem(nullptr)
{
}
-void gaelco_ds5002fp_device_base::device_reset()
+READ8_MEMBER(gaelco_ds5002fp_device::hostmem_r)
{
+ return m_hostmem->read_byte(offset);
}
-gaelco_ds5002fp_device::gaelco_ds5002fp_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock)
- : gaelco_ds5002fp_device_base(mconfig, GAELCO_DS5002FP, tag, owner, clock)
+WRITE8_MEMBER(gaelco_ds5002fp_device::hostmem_w)
{
+ m_hostmem->write_byte(offset, data);
}
-static ADDRESS_MAP_START( dallas_rom, AS_PROGRAM, 8, gaelco_ds5002fp_device )
- AM_RANGE(0x00000, 0x07fff) AM_READ(sram_r) /* Code in SRAM */
-ADDRESS_MAP_END
-
-static ADDRESS_MAP_START( dallas_ram, AS_IO, 8, gaelco_ds5002fp_device )
- AM_RANGE(0x08000, 0x0ffff) AM_READWRITE(shareram_r, shareram_w) /* confirmed that 0x8000 - 0xffff is a window into 68k shared RAM */
- AM_RANGE(0x10000, 0x17fff) AM_RAM AM_SHARE("sram") /* yes, the games access it as data and use it for temporary storage!! */
-ADDRESS_MAP_END
-
MACHINE_CONFIG_MEMBER(gaelco_ds5002fp_device::device_add_mconfig)
MCFG_CPU_ADD("mcu", DS5002FP, DERIVED_CLOCK(1, 1))
MCFG_CPU_PROGRAM_MAP(dallas_rom)
@@ -73,28 +51,12 @@ MACHINE_CONFIG_MEMBER(gaelco_ds5002fp_device::device_add_mconfig)
MCFG_NVRAM_ADD_0FILL("sram")
MACHINE_CONFIG_END
-
-gaelco_ds5002fp_wrally_device::gaelco_ds5002fp_wrally_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock)
- : gaelco_ds5002fp_device_base(mconfig, GAELCO_DS5002FP_WRALLY, tag, owner, clock)
+void gaelco_ds5002fp_device::device_start()
{
+ m_hostmem = &space(0);
}
-static ADDRESS_MAP_START( dallas_rom_wr, AS_PROGRAM, 8, gaelco_ds5002fp_wrally_device )
- AM_RANGE(0x00000, 0x07fff) AM_READ(sram_r) /* Code in SRAM */
-ADDRESS_MAP_END
-
-static ADDRESS_MAP_START( dallas_ram_wr, AS_IO, 8, gaelco_ds5002fp_wrally_device )
- AM_RANGE(0x00000, 0x0ffff) AM_READWRITE(shareram_r, shareram_w) AM_MASK(0x3fff) /* Shared RAM with the main CPU */
- AM_RANGE(0x10000, 0x17fff) AM_RAM AM_SHARE("sram") /*don't think World Rally actually uses it for storage tho */
-ADDRESS_MAP_END
-
-MACHINE_CONFIG_MEMBER(gaelco_ds5002fp_wrally_device::device_add_mconfig)
- MCFG_CPU_ADD("mcu", DS5002FP, DERIVED_CLOCK(1, 1))
- MCFG_CPU_PROGRAM_MAP(dallas_rom_wr)
- MCFG_CPU_IO_MAP(dallas_ram_wr)
-
- MCFG_QUANTUM_PERFECT_CPU("mcu")
-
- MCFG_NVRAM_ADD_0FILL("sram")
-MACHINE_CONFIG_END
-
+device_memory_interface::space_config_vector gaelco_ds5002fp_device::memory_space_config() const
+{
+ return space_config_vector{ std::make_pair(0, &m_hostmem_config) };
+}
diff --git a/src/mame/machine/gaelco_ds5002fp.h b/src/mame/machine/gaelco_ds5002fp.h
index 088f9d11fe9..7c60060db1f 100644
--- a/src/mame/machine/gaelco_ds5002fp.h
+++ b/src/mame/machine/gaelco_ds5002fp.h
@@ -5,54 +5,30 @@
#pragma once
-#include "cpu/mcs51/mcs51.h"
-#include "machine/nvram.h"
-DECLARE_DEVICE_TYPE(GAELCO_DS5002FP, gaelco_ds5002fp_device)
-DECLARE_DEVICE_TYPE(GAELCO_DS5002FP_WRALLY, gaelco_ds5002fp_wrally_device)
+DECLARE_DEVICE_TYPE(GAELCO_DS5002FP, gaelco_ds5002fp_device)
-#define GAELCO_DS5002FP_SET_SHARE_TAG(_tag) \
- gaelco_ds5002fp_device_base::static_set_share_tag(*device, "^" _tag);
-class gaelco_ds5002fp_device_base : public device_t
-{
-public:
- static void static_set_share_tag(device_t &device, const char *tag);
-
- DECLARE_READ8_MEMBER(sram_r);
- DECLARE_WRITE8_MEMBER(sram_w);
- DECLARE_READ8_MEMBER(shareram_r);
- DECLARE_WRITE8_MEMBER(shareram_w);
-
-protected:
- gaelco_ds5002fp_device_base(machine_config const &mconfig, device_type type, char const *tag, device_t *owner, u32 clock);
-
- virtual void device_start() override;
- virtual void device_reset() override;
-
-private:
- required_shared_ptr<uint16_t> m_shareram;
- required_region_ptr<uint8_t> m_sram;
-};
-
-
-class gaelco_ds5002fp_device : public gaelco_ds5002fp_device_base
+class gaelco_ds5002fp_device : public device_t, public device_memory_interface
{
public:
gaelco_ds5002fp_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);
+ // not really public, but address map needs to get them
+ DECLARE_READ8_MEMBER(hostmem_r);
+ DECLARE_WRITE8_MEMBER(hostmem_w);
+
protected:
+ // device_t implementation
virtual void device_add_mconfig(machine_config &config) override;
-};
-
+ virtual void device_start() override;
-class gaelco_ds5002fp_wrally_device : public gaelco_ds5002fp_device_base
-{
-public:
- gaelco_ds5002fp_wrally_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock);
+ // device_memory_interface configuration
+ virtual space_config_vector memory_space_config() const override;
-protected:
- virtual void device_add_mconfig(machine_config &config) override;
+private:
+ address_space_config const m_hostmem_config;
+ address_space *m_hostmem;
};
#endif // MAME_MACHINE_GAELCO_DS5002FP_H
diff --git a/src/mame/machine/wrally.cpp b/src/mame/machine/wrally.cpp
index fd2a536e063..49f8e718982 100644
--- a/src/mame/machine/wrally.cpp
+++ b/src/mame/machine/wrally.cpp
@@ -26,6 +26,18 @@ void wrally_state::machine_start()
***************************************************************************/
+WRITE8_MEMBER(wrally_state::shareram_w)
+{
+ // why isn't there an AM_SOMETHING macro for this?
+ reinterpret_cast<u8 *>(m_shareram.target())[BYTE_XOR_BE(offset)] = data;
+}
+
+READ8_MEMBER(wrally_state::shareram_r)
+{
+ // why isn't there an AM_SOMETHING macro for this?
+ return reinterpret_cast<u8 const *>(m_shareram.target())[BYTE_XOR_BE(offset)];
+}
+
WRITE16_MEMBER(wrally_state::vram_w)
{
data = gaelco_decrypt(space, offset, data, 0x1f, 0x522a);