mirror of
https://github.com/holub/mame
synced 2025-04-17 22:13:04 +03:00
metro/metro.cpp: Split driver state class for different hardware configurations. (#12630)
* Suppress side effects for debugger reads. * Move save state registration and other initialization to machine_start. * Reduced literal tag usage and runtime tag lookups. * Cleaned up switch matrix reading.
This commit is contained in:
parent
1525497f7f
commit
2c631ffc32
File diff suppressed because it is too large
Load Diff
@ -31,19 +31,13 @@ public:
|
||||
, m_audiocpu(*this, "audiocpu")
|
||||
, m_oki(*this, "oki")
|
||||
, m_ymsnd(*this, "ymsnd")
|
||||
, m_essnd(*this, "essnd")
|
||||
, m_vdp(*this, "vdp")
|
||||
, m_vdp2(*this, "vdp2")
|
||||
, m_vdp3(*this, "vdp3")
|
||||
, m_k053936(*this, "k053936")
|
||||
, m_eeprom(*this, "eeprom")
|
||||
, m_gfxdecode(*this, "gfxdecode")
|
||||
, m_screen(*this, "screen")
|
||||
, m_soundlatch(*this, "soundlatch")
|
||||
, m_input_sel(*this, "input_sel")
|
||||
, m_k053936_ram(*this, "k053936_ram")
|
||||
, m_io_dsw(*this, "DSW%u", 0U)
|
||||
, m_io_in(*this, "IN%u", 0U)
|
||||
, m_audiobank(*this, "audiobank")
|
||||
, m_okibank(*this, "okibank")
|
||||
{ }
|
||||
|
||||
void i4100_config(machine_config &config);
|
||||
@ -54,53 +48,94 @@ public:
|
||||
void i4300_config(machine_config &config);
|
||||
void i4300_config_384x224(machine_config &config);
|
||||
void i4300_config_320x240(machine_config &config);
|
||||
void balcube(machine_config &config);
|
||||
void bangball(machine_config &config);
|
||||
void batlbubl(machine_config &config);
|
||||
void daitoa(machine_config &config);
|
||||
void msgogo(machine_config &config);
|
||||
void puzzlet(machine_config &config);
|
||||
|
||||
void init_balcube();
|
||||
void init_karatour();
|
||||
|
||||
protected:
|
||||
virtual void machine_start() override {}
|
||||
|
||||
void ipl_w(u8 data);
|
||||
void coin_lockout_1word_w(u8 data);
|
||||
void coin_lockout_4words_w(offs_t offset, u16 data);
|
||||
u16 balcube_dsw_r(offs_t offset);
|
||||
void puzzlet_irq_enable_w(u8 data);
|
||||
void puzzlet_portb_w(u8 data);
|
||||
|
||||
void ext_irq5_enable_w(int state);
|
||||
|
||||
void vblank_irq(int state);
|
||||
INTERRUPT_GEN_MEMBER(periodic_interrupt);
|
||||
TIMER_DEVICE_CALLBACK_MEMBER(bangball_scanline);
|
||||
void karatour_vblank_irq(int state);
|
||||
void puzzlet_vblank_irq(int state);
|
||||
|
||||
void balcube_map(address_map &map);
|
||||
void bangball_map(address_map &map);
|
||||
void batlbubl_map(address_map &map);
|
||||
void cpu_space_map(address_map &map);
|
||||
void daitoa_map(address_map &map);
|
||||
void msgogo_map(address_map &map);
|
||||
void puzzlet_map(address_map &map);
|
||||
void ymf278_map(address_map &map);
|
||||
|
||||
// devices
|
||||
required_device<cpu_device> m_maincpu;
|
||||
optional_device<cpu_device> m_audiocpu;
|
||||
optional_device<okim6295_device> m_oki;
|
||||
optional_device<device_t> m_ymsnd; // TODO set correct type
|
||||
optional_device<imagetek_i4100_device> m_vdp;
|
||||
optional_device<imagetek_i4220_device> m_vdp2;
|
||||
optional_device<imagetek_i4300_device> m_vdp3;
|
||||
|
||||
required_device<screen_device> m_screen;
|
||||
|
||||
optional_ioport_array<2> m_io_dsw;
|
||||
optional_ioport_array<4> m_io_in;
|
||||
|
||||
optional_memory_bank m_audiobank;
|
||||
|
||||
bool m_ext_irq_enable = false;
|
||||
};
|
||||
|
||||
// with Sound uPD7810
|
||||
class metro_upd7810_state : public metro_state
|
||||
{
|
||||
public:
|
||||
metro_upd7810_state(const machine_config &mconfig, device_type type, const char *tag)
|
||||
: metro_state(mconfig, type, tag)
|
||||
{ }
|
||||
|
||||
void metro_upd7810_sound(machine_config &config);
|
||||
void daitorid_upd7810_sound(machine_config &config);
|
||||
void poitto(machine_config &config);
|
||||
void blzntrnd(machine_config &config);
|
||||
void sankokushi(machine_config &config);
|
||||
void mouja(machine_config &config);
|
||||
void toride2g(machine_config &config);
|
||||
void karatour(machine_config &config);
|
||||
void skyalert(machine_config &config);
|
||||
void gakusai(machine_config &config);
|
||||
void batlbubl(machine_config &config);
|
||||
void pururun(machine_config &config);
|
||||
void vmetal(machine_config &config);
|
||||
void daitorid(machine_config &config);
|
||||
void dharma(machine_config &config);
|
||||
void karatour(machine_config &config);
|
||||
void lastforg(machine_config &config);
|
||||
void lastfort(machine_config &config);
|
||||
void pangpoms(machine_config &config);
|
||||
void poitto(machine_config &config);
|
||||
void pururun(machine_config &config);
|
||||
void puzzli(machine_config &config);
|
||||
void puzzlia(machine_config &config);
|
||||
void pangpoms(machine_config &config);
|
||||
void dokyusp(machine_config &config);
|
||||
void dokyusei(machine_config &config);
|
||||
void daitoa(machine_config &config);
|
||||
void lastfort(machine_config &config);
|
||||
void puzzlet(machine_config &config);
|
||||
void gakusai2(machine_config &config);
|
||||
void balcube(machine_config &config);
|
||||
void msgogo(machine_config &config);
|
||||
void gstrik2(machine_config &config);
|
||||
void lastforg(machine_config &config);
|
||||
void bangball(machine_config &config);
|
||||
void dharma(machine_config &config);
|
||||
void sankokushi(machine_config &config);
|
||||
void skyalert(machine_config &config);
|
||||
void toride2g(machine_config &config);
|
||||
|
||||
void init_karatour();
|
||||
void init_blzntrnd();
|
||||
void init_vmetal();
|
||||
void init_mouja();
|
||||
void init_balcube();
|
||||
void init_dharmak();
|
||||
void init_metro();
|
||||
void init_lastfortg();
|
||||
void init_puzzlet() { save_item(NAME(m_ext_irq_enable)); }
|
||||
|
||||
int custom_soundstatus_r();
|
||||
|
||||
private:
|
||||
protected:
|
||||
virtual void machine_start() override;
|
||||
|
||||
void ipl_w(u8 data);
|
||||
void mouja_irq_timer_ctrl_w(u16 data);
|
||||
private:
|
||||
void sound_data_w(u8 data);
|
||||
TIMER_CALLBACK_MEMBER(sound_data_sync);
|
||||
u8 soundstatus_r();
|
||||
@ -110,121 +145,181 @@ private:
|
||||
void upd7810_porta_w(u8 data);
|
||||
void upd7810_portb_w(u8 data);
|
||||
void daitorid_portb_w(u8 data);
|
||||
void coin_lockout_1word_w(u8 data);
|
||||
void coin_lockout_4words_w(offs_t offset, u16 data);
|
||||
u16 balcube_dsw_r(offs_t offset);
|
||||
u16 gakusai_input_r();
|
||||
void blzntrnd_sh_bankswitch_w(u8 data);
|
||||
void puzzlet_irq_enable_w(u8 data);
|
||||
void puzzlet_portb_w(u8 data);
|
||||
void k053936_w(offs_t offset, u16 data, u16 mem_mask = ~0);
|
||||
void gakusai_oki_bank_hi_w(u8 data);
|
||||
void gakusai_oki_bank_lo_w(u8 data);
|
||||
|
||||
int rxd_r();
|
||||
|
||||
void daitorid_map(address_map &map);
|
||||
void dharma_map(address_map &map);
|
||||
void karatour_map(address_map &map);
|
||||
void kokushi_map(address_map &map);
|
||||
void lastforg_map(address_map &map);
|
||||
void lastfort_map(address_map &map);
|
||||
void pangpoms_map(address_map &map);
|
||||
void poitto_map(address_map &map);
|
||||
void pururun_map(address_map &map);
|
||||
void skyalert_map(address_map &map);
|
||||
void toride2g_map(address_map &map);
|
||||
void upd7810_map(address_map &map);
|
||||
|
||||
// sound related
|
||||
u8 m_sound_data = 0;
|
||||
u16 m_soundstatus = 0;
|
||||
u8 m_porta = 0;
|
||||
u8 m_portb = 0;
|
||||
bool m_busy_sndcpu = false;
|
||||
};
|
||||
|
||||
// with Mahjong input
|
||||
class gakusai_state : public metro_state
|
||||
{
|
||||
public:
|
||||
gakusai_state(const machine_config &mconfig, device_type type, const char *tag)
|
||||
: metro_state(mconfig, type, tag)
|
||||
, m_eeprom(*this, "eeprom")
|
||||
, m_input_sel(*this, "input_sel")
|
||||
, m_io_key(*this, "KEY%u", 0U)
|
||||
{ }
|
||||
|
||||
void dokyusei(machine_config &config);
|
||||
void dokyusp(machine_config &config);
|
||||
void gakusai2(machine_config &config);
|
||||
void gakusai(machine_config &config);
|
||||
|
||||
protected:
|
||||
virtual void machine_start() override;
|
||||
|
||||
private:
|
||||
u16 input_r();
|
||||
void oki_bank_hi_w(u8 data);
|
||||
void oki_bank_lo_w(u8 data);
|
||||
u8 gakusai_eeprom_r();
|
||||
void gakusai_eeprom_w(u8 data);
|
||||
u8 dokyusp_eeprom_r();
|
||||
void dokyusp_eeprom_bit_w(u8 data);
|
||||
void dokyusp_eeprom_reset_w(u8 data);
|
||||
void mouja_sound_rombank_w(u8 data);
|
||||
|
||||
void oki_bank_set();
|
||||
|
||||
void dokyusei_map(address_map &map);
|
||||
void dokyusp_map(address_map &map);
|
||||
void gakusai2_map(address_map &map);
|
||||
void gakusai_map(address_map &map);
|
||||
|
||||
// devices
|
||||
optional_device<eeprom_serial_93cxx_device> m_eeprom;
|
||||
|
||||
// memory pointers
|
||||
required_shared_ptr<u16> m_input_sel;
|
||||
|
||||
required_ioport_array<5> m_io_key;
|
||||
|
||||
// misc
|
||||
u8 m_oki_bank_lo = 0;
|
||||
u8 m_oki_bank_hi = 0;
|
||||
};
|
||||
|
||||
// with ES8712+MSM6585 sound
|
||||
class vmetal_state : public metro_state
|
||||
{
|
||||
public:
|
||||
vmetal_state(const machine_config &mconfig, device_type type, const char *tag)
|
||||
: metro_state(mconfig, type, tag)
|
||||
, m_essnd(*this, "essnd")
|
||||
{ }
|
||||
|
||||
void vmetal(machine_config &config);
|
||||
|
||||
protected:
|
||||
virtual void machine_start() override;
|
||||
|
||||
private:
|
||||
// vmetal
|
||||
void vmetal_control_w(u8 data);
|
||||
void es8712_reset_w(u8 data);
|
||||
void vmetal_es8712_irq(int state);
|
||||
void es8712_irq(int state);
|
||||
|
||||
void main_map(address_map &map);
|
||||
|
||||
// devices
|
||||
required_device<es8712_device> m_essnd;
|
||||
|
||||
// sound related
|
||||
u8 m_essnd_bank = 0;
|
||||
bool m_essnd_gate = false;
|
||||
};
|
||||
|
||||
// with Configurable timer
|
||||
class mouja_state : public metro_state
|
||||
{
|
||||
public:
|
||||
mouja_state(const machine_config &mconfig, device_type type, const char *tag)
|
||||
: metro_state(mconfig, type, tag)
|
||||
, m_okibank(*this, "okibank")
|
||||
{ }
|
||||
|
||||
void mouja(machine_config &config);
|
||||
|
||||
protected:
|
||||
virtual void machine_start() override;
|
||||
|
||||
private:
|
||||
void irq_timer_ctrl_w(u16 data);
|
||||
void sound_rombank_w(u8 data);
|
||||
|
||||
void main_map(address_map &map);
|
||||
void oki_map(address_map &map);
|
||||
|
||||
TIMER_CALLBACK_MEMBER(mouja_irq);
|
||||
|
||||
required_memory_bank m_okibank;
|
||||
|
||||
// irq_related
|
||||
emu_timer *m_mouja_irq_timer = nullptr;
|
||||
};
|
||||
|
||||
// with K053936 PSAC2
|
||||
class blzntrnd_state : public metro_state
|
||||
{
|
||||
public:
|
||||
blzntrnd_state(const machine_config &mconfig, device_type type, const char *tag)
|
||||
: metro_state(mconfig, type, tag)
|
||||
, m_gfxdecode(*this, "gfxdecode")
|
||||
, m_soundlatch(*this, "soundlatch")
|
||||
, m_k053936(*this, "k053936")
|
||||
, m_k053936_ram(*this, "k053936_ram")
|
||||
{ }
|
||||
|
||||
void blzntrnd(machine_config &config);
|
||||
void gstrik2(machine_config &config);
|
||||
|
||||
protected:
|
||||
virtual void machine_start() override;
|
||||
|
||||
private:
|
||||
void audiobank_w(u8 data);
|
||||
void k053936_w(offs_t offset, u16 data, u16 mem_mask = ~0);
|
||||
|
||||
TILE_GET_INFO_MEMBER(k053936_get_tile_info);
|
||||
TILE_GET_INFO_MEMBER(k053936_gstrik2_get_tile_info);
|
||||
TILEMAP_MAPPER_MEMBER(tilemap_scan_gstrik2);
|
||||
DECLARE_VIDEO_START(blzntrnd);
|
||||
DECLARE_VIDEO_START(gstrik2);
|
||||
uint32_t screen_update_psac_vdp2_mix(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect);
|
||||
void vblank_irq(int state);
|
||||
INTERRUPT_GEN_MEMBER(periodic_interrupt);
|
||||
TIMER_DEVICE_CALLBACK_MEMBER(bangball_scanline);
|
||||
void karatour_vblank_irq(int state);
|
||||
void puzzlet_vblank_irq(int state);
|
||||
int rxd_r();
|
||||
u32 screen_update(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect);
|
||||
|
||||
void balcube_map(address_map &map);
|
||||
void bangball_map(address_map &map);
|
||||
void batlbubl_map(address_map &map);
|
||||
void blzntrnd_map(address_map &map);
|
||||
void blzntrnd_sound_io_map(address_map &map);
|
||||
void blzntrnd_sound_map(address_map &map);
|
||||
void cpu_space_map(address_map &map);
|
||||
void daitoa_map(address_map &map);
|
||||
void daitorid_map(address_map &map);
|
||||
void dharma_map(address_map &map);
|
||||
void dokyusei_map(address_map &map);
|
||||
void dokyusp_map(address_map &map);
|
||||
void gakusai2_map(address_map &map);
|
||||
void gakusai_map(address_map &map);
|
||||
void karatour_map(address_map &map);
|
||||
void kokushi_map(address_map &map);
|
||||
void lastforg_map(address_map &map);
|
||||
void lastfort_map(address_map &map);
|
||||
void upd7810_map(address_map &map);
|
||||
void mouja_map(address_map &map);
|
||||
void mouja_okimap(address_map &map);
|
||||
void msgogo_map(address_map &map);
|
||||
void pangpoms_map(address_map &map);
|
||||
void poitto_map(address_map &map);
|
||||
void pururun_map(address_map &map);
|
||||
void puzzlet_map(address_map &map);
|
||||
void skyalert_map(address_map &map);
|
||||
void toride2g_map(address_map &map);
|
||||
void vmetal_map(address_map &map);
|
||||
void ymf278_map(address_map &map);
|
||||
void main_map(address_map &map);
|
||||
void sound_io_map(address_map &map);
|
||||
void sound_map(address_map &map);
|
||||
|
||||
TIMER_CALLBACK_MEMBER(mouja_irq);
|
||||
// devices
|
||||
required_device<gfxdecode_device> m_gfxdecode;
|
||||
required_device<generic_latch_8_device> m_soundlatch;
|
||||
required_device<k053936_device> m_k053936;
|
||||
|
||||
/* devices */
|
||||
required_device<cpu_device> m_maincpu;
|
||||
optional_device<cpu_device> m_audiocpu;
|
||||
optional_device<okim6295_device> m_oki;
|
||||
optional_device<device_t> m_ymsnd; // TODO set correct type
|
||||
optional_device<es8712_device> m_essnd;
|
||||
optional_device<imagetek_i4100_device> m_vdp;
|
||||
optional_device<imagetek_i4220_device> m_vdp2;
|
||||
optional_device<imagetek_i4300_device> m_vdp3;
|
||||
// memory pointers
|
||||
required_shared_ptr<u16> m_k053936_ram;
|
||||
|
||||
optional_device<k053936_device> m_k053936;
|
||||
optional_device<eeprom_serial_93cxx_device> m_eeprom;
|
||||
optional_device<gfxdecode_device> m_gfxdecode;
|
||||
required_device<screen_device> m_screen;
|
||||
optional_device<generic_latch_8_device> m_soundlatch;
|
||||
|
||||
/* memory pointers */
|
||||
optional_shared_ptr<u16> m_input_sel;
|
||||
optional_shared_ptr<u16> m_k053936_ram;
|
||||
|
||||
optional_memory_bank m_audiobank;
|
||||
optional_memory_bank m_okibank;
|
||||
|
||||
/* video-related */
|
||||
tilemap_t *m_k053936_tilemap = nullptr;
|
||||
|
||||
/* irq_related */
|
||||
emu_timer *m_mouja_irq_timer = nullptr;
|
||||
|
||||
/* sound related */
|
||||
u8 m_sound_data = 0;
|
||||
u16 m_soundstatus = 0;
|
||||
int m_porta = 0;
|
||||
int m_portb = 0;
|
||||
int m_busy_sndcpu = 0;
|
||||
int m_essnd_bank = 0;
|
||||
bool m_essnd_gate = false;
|
||||
|
||||
/* misc */
|
||||
int m_gakusai_oki_bank_lo = 0;
|
||||
int m_gakusai_oki_bank_hi = 0;
|
||||
|
||||
void gakusai_oki_bank_set();
|
||||
|
||||
void ext_irq5_enable_w(int state);
|
||||
|
||||
bool m_ext_irq_enable = false;
|
||||
// video-related
|
||||
tilemap_t *m_k053936_tilemap = nullptr;
|
||||
};
|
||||
|
||||
#endif // MAME_METRO_METRO_H
|
||||
|
@ -10,7 +10,7 @@
|
||||
#include "emu.h"
|
||||
#include "metro.h"
|
||||
|
||||
TILE_GET_INFO_MEMBER(metro_state::k053936_get_tile_info)
|
||||
TILE_GET_INFO_MEMBER(blzntrnd_state::k053936_get_tile_info)
|
||||
{
|
||||
int code = m_k053936_ram[tile_index];
|
||||
|
||||
@ -20,39 +20,39 @@ TILE_GET_INFO_MEMBER(metro_state::k053936_get_tile_info)
|
||||
0);
|
||||
}
|
||||
|
||||
TILE_GET_INFO_MEMBER(metro_state::k053936_gstrik2_get_tile_info)
|
||||
TILE_GET_INFO_MEMBER(blzntrnd_state::k053936_gstrik2_get_tile_info)
|
||||
{
|
||||
int code = m_k053936_ram[tile_index];
|
||||
|
||||
tileinfo.set(0,
|
||||
(code & 0x7fff)>>2,
|
||||
(code & 0x7fff) >> 2,
|
||||
0xe,
|
||||
0);
|
||||
}
|
||||
|
||||
void metro_state::k053936_w(offs_t offset, u16 data, u16 mem_mask)
|
||||
void blzntrnd_state::k053936_w(offs_t offset, u16 data, u16 mem_mask)
|
||||
{
|
||||
COMBINE_DATA(&m_k053936_ram[offset]);
|
||||
m_k053936_tilemap->mark_tile_dirty(offset);
|
||||
}
|
||||
|
||||
TILEMAP_MAPPER_MEMBER(metro_state::tilemap_scan_gstrik2)
|
||||
TILEMAP_MAPPER_MEMBER(blzntrnd_state::tilemap_scan_gstrik2)
|
||||
{
|
||||
/* logical (col,row) -> memory offset */
|
||||
return ((row & 0x40) >> 6) | (col << 1) | ((row & 0x80) << 1) | ((row & 0x3f) << 9);
|
||||
}
|
||||
|
||||
VIDEO_START_MEMBER(metro_state,blzntrnd)
|
||||
VIDEO_START_MEMBER(blzntrnd_state,blzntrnd)
|
||||
{
|
||||
m_k053936_tilemap = &machine().tilemap().create(*m_gfxdecode, tilemap_get_info_delegate(*this, FUNC(metro_state::k053936_get_tile_info)), TILEMAP_SCAN_ROWS, 8, 8, 256, 512);
|
||||
m_k053936_tilemap = &machine().tilemap().create(*m_gfxdecode, tilemap_get_info_delegate(*this, FUNC(blzntrnd_state::k053936_get_tile_info)), TILEMAP_SCAN_ROWS, 8, 8, 256, 512);
|
||||
}
|
||||
|
||||
VIDEO_START_MEMBER(metro_state,gstrik2)
|
||||
VIDEO_START_MEMBER(blzntrnd_state,gstrik2)
|
||||
{
|
||||
m_k053936_tilemap = &machine().tilemap().create(*m_gfxdecode, tilemap_get_info_delegate(*this, FUNC(metro_state::k053936_gstrik2_get_tile_info)), tilemap_mapper_delegate(*this, FUNC(metro_state::tilemap_scan_gstrik2)), 16, 16, 128, 256);
|
||||
m_k053936_tilemap = &machine().tilemap().create(*m_gfxdecode, tilemap_get_info_delegate(*this, FUNC(blzntrnd_state::k053936_gstrik2_get_tile_info)), tilemap_mapper_delegate(*this, FUNC(blzntrnd_state::tilemap_scan_gstrik2)), 16, 16, 128, 256);
|
||||
}
|
||||
|
||||
uint32_t metro_state::screen_update_psac_vdp2_mix(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect)
|
||||
u32 blzntrnd_state::screen_update(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect)
|
||||
{
|
||||
/* TODO: bit 5 of reg 7 is off when ROZ is supposed to be disabled
|
||||
* (Blazing Tornado title screen/character select/ending and Grand Striker 2 title/how to play transition)
|
||||
|
Loading…
Reference in New Issue
Block a user