irem/m72.cpp: Split driver state for reduce optional finders, Updates: (#12983)

- Fix typename values for boolean flags
- Reduce literal tag usages
- Fix naming
- Fix spacings
- Add notes
This commit is contained in:
cam900 2024-11-17 00:51:48 +09:00 committed by GitHub
parent a3476faf06
commit 7f257cdccd
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 446 additions and 371 deletions

File diff suppressed because it is too large Load Diff

View File

@ -33,6 +33,7 @@
/* PORT_CONFSETTING( 0x0000, "S" ) */ \
PORT_CONFSETTING( 0x0001, "W" )
// Base state
class m72_state : public driver_device
{
public:
@ -40,8 +41,6 @@ public:
driver_device(mconfig, type, tag),
m_maincpu(*this, "maincpu"),
m_soundcpu(*this, "soundcpu"),
m_mcu(*this, "mcu"),
m_dpram(*this, "dpram"),
m_dac(*this, "dac"),
m_audio(*this, "m72"),
m_gfxdecode(*this, "gfxdecode"),
@ -49,23 +48,17 @@ public:
m_palette(*this, "palette"),
m_spriteram(*this, "spriteram"),
m_videoram(*this, "videoram%u", 1U),
m_m82_rowscrollram(*this, "majtitle_rowscr"),
m_spriteram2(*this, "spriteram2"),
m_soundram(*this, "soundram"),
m_paletteram(*this, "paletteram%u", 1U),
m_upd71059c(*this, "upd71059c"),
m_upd4701(*this, {"upd4701l", "upd4701h"}),
m_samples_region(*this, "samples"),
m_io_dsw(*this, "DSW"),
m_fg_tilemap(nullptr),
m_bg_tilemap(nullptr),
m_bg_tilemap_large(nullptr),
m_video_off(0),
m_video_off(false),
m_fg_source(0),
m_bg_source(0),
m_m81_b_b_j3(*this, "JumperJ3"),
m_m82_rowscroll(0),
m_m82_tmcontrol(0)
m_m81_b_b_j3(*this, "JumperJ3")
{
m_scrollx[0] = m_scrollx[1] = 0;
m_scrolly[0] = m_scrolly[1] = 0;
@ -73,38 +66,28 @@ public:
void m72_base(machine_config &config);
void m72_audio_chips(machine_config &config);
void m72_xmultipl(machine_config &config);
void m72_dbreed(machine_config &config);
void m72_dbreedw(machine_config &config);
void cosmccop(machine_config &config);
void poundfor(machine_config &config);
void m72(machine_config &config);
void m81_hharry(machine_config &config);
void m81_xmultipl(machine_config &config);
void kengo(machine_config &config);
void m81_dbreed(machine_config &config);
void m72_8751(machine_config &config);
void m72_airduel(machine_config &config);
void hharryu(machine_config &config);
void rtype2(machine_config &config);
void m82(machine_config &config);
void rtype(machine_config &config);
void imgfightjb(machine_config &config);
void lohtb(machine_config &config);
void imgfight(machine_config &config);
void mrheli(machine_config &config);
void nspiritj(machine_config &config);
void init_dkgenm72();
void init_m72_8751();
void init_dbreedm72();
void init_nspirit();
private:
protected:
virtual void machine_start() override ATTR_COLD;
virtual void machine_reset() override ATTR_COLD;
required_device<cpu_device> m_maincpu;
required_device<cpu_device> m_soundcpu;
optional_device<cpu_device> m_mcu;
optional_device<mb8421_mb8431_16_device> m_dpram;
optional_device<dac_byte_interface> m_dac;
optional_device<m72_audio_device> m_audio;
required_device<gfxdecode_device> m_gfxdecode;
@ -113,13 +96,10 @@ private:
required_device<buffered_spriteram16_device> m_spriteram;
required_shared_ptr_array<u16, 2> m_videoram;
optional_shared_ptr<u16> m_m82_rowscrollram;
optional_shared_ptr<u16> m_spriteram2;
optional_shared_ptr<u8> m_soundram;
required_shared_ptr_array<u16, 2> m_paletteram;
optional_device<pic8259_device> m_upd71059c;
optional_device_array<upd4701_device, 2> m_upd4701;
optional_region_ptr<u8> m_samples_region;
@ -132,23 +112,14 @@ private:
u32 m_raster_irq_position = 0;
tilemap_t *m_fg_tilemap = nullptr;
tilemap_t *m_bg_tilemap = nullptr;
tilemap_t *m_bg_tilemap_large = nullptr;
s32 m_scrollx[2]{};
s32 m_scrolly[2]{};
s32 m_video_off = 0;
bool m_video_off = false;
int m_fg_source = 0;
int m_bg_source = 0;
optional_ioport m_m81_b_b_j3;
// majtitle specific
int m_m82_rowscroll = 0;
u16 m_m82_tmcontrol = 0;
// m72_i8751 specific
u8 m_mcu_sample_latch = 0;
u32 m_mcu_sample_addr = 0;
// common
template<unsigned N> u16 palette_r(offs_t offset);
template<unsigned N> void palette_w(offs_t offset, u16 data, u16 mem_mask);
@ -162,14 +133,6 @@ private:
u8 soundram_r(offs_t offset);
void soundram_w(offs_t offset, u8 data);
// m72_i8751 specific
void main_mcu_w(offs_t offset, u16 data, u16 mem_mask);
void mcu_data_w(offs_t offset, u8 data);
u8 mcu_data_r(offs_t offset);
u8 mcu_sample_r();
void mcu_low_w(u8 data);
void mcu_high_w(u8 data);
u16 protection_r(offs_t offset, u16 mem_mask = ~0);
void protection_w(offs_t offset, u16 data, u16 mem_mask = ~0);
@ -178,30 +141,18 @@ private:
void dbreedm72_sample_trigger_w(offs_t offset, u16 data, u16 mem_mask = ~0);
void dkgenm72_sample_trigger_w(offs_t offset, u16 data, u16 mem_mask = ~0);
void rtype2_port02_w(u8 data);
void poundfor_port02_w(u8 data);
void m82_gfx_ctrl_w(offs_t offset, u16 data, u16 mem_mask);
void m82_tm_ctrl_w(offs_t offset, u16 data, u16 mem_mask);
TILE_GET_INFO_MEMBER(get_bg_tile_info);
TILE_GET_INFO_MEMBER(get_fg_tile_info);
template<unsigned N> TILE_GET_INFO_MEMBER(rtype2_get_tile_info);
TILEMAP_MAPPER_MEMBER(m82_scan_rows);
void machine_start() override ATTR_COLD;
void machine_reset() override ATTR_COLD;
DECLARE_VIDEO_START(m72);
DECLARE_VIDEO_START(dbreedm72);
DECLARE_VIDEO_START(imgfight);
DECLARE_VIDEO_START(mrheli);
DECLARE_VIDEO_START(nspiritj);
DECLARE_VIDEO_START(xmultipl);
DECLARE_VIDEO_START(hharry);
DECLARE_VIDEO_START(rtype2);
DECLARE_VIDEO_START(m82);
DECLARE_VIDEO_START(hharryu);
DECLARE_VIDEO_START(poundfor);
DECLARE_MACHINE_START(kengo);
DECLARE_MACHINE_RESET(kengo);
@ -209,12 +160,9 @@ private:
TIMER_CALLBACK_MEMBER(synch_callback);
TIMER_CALLBACK_MEMBER(scanline_interrupt);
TIMER_CALLBACK_MEMBER(kengo_scanline_interrupt);
TIMER_CALLBACK_MEMBER(delayed_ram16_w);
TIMER_CALLBACK_MEMBER(delayed_ram8_w);
u32 screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
u32 screen_update_m81(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
u32 screen_update_m82(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
inline void m72_m81_get_tile_info(tile_data &tileinfo,int tile_index,const u16 *vram,int gfxnum);
void register_savestate();
inline void changecolor(offs_t color, u8 r, u8 g, u8 b);
@ -224,7 +172,6 @@ private:
void install_protection_handler(const u8 *code,const u8 *crc);
void dbreed_map(address_map &map) ATTR_COLD;
void dbreedm72_map(address_map &map) ATTR_COLD;
void dbreedwm72_map(address_map &map) ATTR_COLD;
void hharry_map(address_map &map) ATTR_COLD;
void hharryu_map(address_map &map) ATTR_COLD;
@ -233,31 +180,149 @@ private:
void lohtb_portmap(address_map &map) ATTR_COLD;
void m72_cpu1_common_map(address_map &map) ATTR_COLD;
void m72_map(address_map &map) ATTR_COLD;
void m72_protected_map(address_map &map) ATTR_COLD;
void m72_portmap(address_map &map) ATTR_COLD;
void m72_protected_portmap(address_map &map) ATTR_COLD;
void m72_airduel_portmap(address_map &map) ATTR_COLD;
void m81_cpu1_common_map(address_map &map) ATTR_COLD;
void m81_portmap(address_map &map) ATTR_COLD;
void m82_map(address_map &map) ATTR_COLD;
void m82_portmap(address_map &map) ATTR_COLD;
void m84_cpu1_common_map(address_map &map) ATTR_COLD;
void m84_portmap(address_map &map) ATTR_COLD;
void m84_v33_portmap(address_map &map) ATTR_COLD;
void i80c31_mem_map(address_map &map) ATTR_COLD;
void mcu_io_map(address_map &map) ATTR_COLD;
void poundfor_portmap(address_map &map) ATTR_COLD;
void poundfor_sound_portmap(address_map &map) ATTR_COLD;
void m84_v35_portmap(address_map &map) ATTR_COLD;
void rtype2_map(address_map &map) ATTR_COLD;
void rtype2_sound_portmap(address_map &map) ATTR_COLD;
void rtype_map(address_map &map) ATTR_COLD;
void rtype_sound_portmap(address_map &map) ATTR_COLD;
void sound_portmap(address_map &map) ATTR_COLD;
void sound_protected_portmap(address_map &map) ATTR_COLD;
void sound_ram_map(address_map &map) ATTR_COLD;
void sound_rom_map(address_map &map) ATTR_COLD;
void xmultipl_map(address_map &map) ATTR_COLD;
};
// M72 with MCU
class m72_mcu_state : public m72_state
{
public:
m72_mcu_state(const machine_config &mconfig, device_type type, const char *tag) :
m72_state(mconfig, type, tag),
m_mcu(*this, "mcu"),
m_dpram(*this, "dpram")
{
}
void m72_8751(machine_config &config);
void m72_airduel(machine_config &config);
void m72_dbreed(machine_config &config);
void m72_xmultipl(machine_config &config);
void imgfight(machine_config &config);
void imgfightjb(machine_config &config);
void mrheli(machine_config &config);
void nspiritj(machine_config &config);
//void init_m72_8751();
protected:
virtual void machine_start() override ATTR_COLD;
virtual void machine_reset() override ATTR_COLD;
private:
required_device<cpu_device> m_mcu;
required_device<mb8421_mb8431_16_device> m_dpram;
// m72_i8751 specific
u32 m_mcu_sample_addr = 0;
// m72_i8751 specific
void main_mcu_w(offs_t offset, u16 data, u16 mem_mask);
void mcu_data_w(offs_t offset, u8 data);
u8 mcu_data_r(offs_t offset);
u8 mcu_sample_r();
void mcu_low_w(u8 data);
void mcu_high_w(u8 data);
DECLARE_VIDEO_START(imgfight);
DECLARE_VIDEO_START(mrheli);
DECLARE_VIDEO_START(nspiritj);
TIMER_CALLBACK_MEMBER(delayed_ram16_w);
TIMER_CALLBACK_MEMBER(delayed_ram8_w);
void dbreedm72_map(address_map &map) ATTR_COLD;
void m72_protected_map(address_map &map) ATTR_COLD;
void m72_protected_portmap(address_map &map) ATTR_COLD;
void m72_airduel_portmap(address_map &map) ATTR_COLD;
void i80c31_mem_map(address_map &map) ATTR_COLD;
void mcu_io_map(address_map &map) ATTR_COLD;
void sound_protected_portmap(address_map &map) ATTR_COLD;
void xmultiplm72_map(address_map &map) ATTR_COLD;
};
// M82 (with modified video features)
class m82_state : public m72_state
{
public:
m82_state(const machine_config &mconfig, device_type type, const char *tag) :
m72_state(mconfig, type, tag),
m_m82_rowscrollram(*this, "majtitle_rowscr"),
m_spriteram2(*this, "spriteram2"),
m_bg_tilemap_large(nullptr),
m_m82_rowscroll(false),
m_m82_tmcontrol(0)
{
}
void m82(machine_config &config);
protected:
virtual void video_start() override ATTR_COLD;
private:
required_shared_ptr<u16> m_m82_rowscrollram;
required_shared_ptr<u16> m_spriteram2;
tilemap_t *m_bg_tilemap_large = nullptr;
// majtitle specific
bool m_m82_rowscroll = false;
u16 m_m82_tmcontrol = 0;
// game specific
void videoram2_m82_w(offs_t offset, u16 data, u16 mem_mask);
void m82_gfx_ctrl_w(offs_t offset, u16 data, u16 mem_mask);
void m82_tm_ctrl_w(offs_t offset, u16 data, u16 mem_mask);
TILEMAP_MAPPER_MEMBER(m82_scan_rows);
u32 screen_update_m82(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
void majtitle_draw_sprites(bitmap_ind16 &bitmap,const rectangle &cliprect);
void m82_map(address_map &map) ATTR_COLD;
void m82_portmap(address_map &map) ATTR_COLD;
};
// M85 (with trackball)
class poundfor_state : public m72_state
{
public:
poundfor_state(const machine_config &mconfig, device_type type, const char *tag) :
m72_state(mconfig, type, tag),
m_upd4701(*this, {"upd4701l", "upd4701h"})
{
}
void poundfor(machine_config &config);
protected:
virtual void video_start() override ATTR_COLD;
private:
required_device_array<upd4701_device, 2> m_upd4701;
// game specific
void poundfor_port02_w(u8 data);
void poundfor_portmap(address_map &map) ATTR_COLD;
void poundfor_sound_portmap(address_map &map) ATTR_COLD;
};
#endif // MAME_IREM_M72_H

View File

@ -131,19 +131,19 @@ VIDEO_START_MEMBER(m72_state,dbreedm72)
m_bg_tilemap->set_transmask(2,0x0001,0xfffe); // for score bar
}
VIDEO_START_MEMBER(m72_state,imgfight)
VIDEO_START_MEMBER(m72_mcu_state,imgfight)
{
VIDEO_START_CALL_MEMBER(m72);
m_bg_tilemap->set_transmask(2,0xff00,0x00ff); // for RAM/ROM & Japan message
}
VIDEO_START_MEMBER(m72_state,mrheli)
VIDEO_START_MEMBER(m72_mcu_state,mrheli)
{
VIDEO_START_CALL_MEMBER(m72);
m_bg_tilemap->set_transmask(2,0x00ff,0xff00); // for Japan message
}
VIDEO_START_MEMBER(m72_state,nspiritj)
VIDEO_START_MEMBER(m72_mcu_state,nspiritj)
{
VIDEO_START_CALL_MEMBER(m72);
m_bg_tilemap->set_transmask(2,0x001f,0xffe0); // for Japan message
@ -180,19 +180,19 @@ VIDEO_START_MEMBER(m72_state,xmultipl)
/* Major Title has a larger background RAM, and rowscroll */
// the Air Duel conversion on the same PCB does not, is it jumper selectable, or a register, or a different RAM chip?
TILEMAP_MAPPER_MEMBER(m72_state::m82_scan_rows)
TILEMAP_MAPPER_MEMBER(m82_state::m82_scan_rows)
{
/* logical (col,row) -> memory offset */
return row*256 + col;
}
VIDEO_START_MEMBER(m72_state,m82)
void m82_state::video_start()
{
m_fg_tilemap = &machine().tilemap().create(*m_gfxdecode, tilemap_get_info_delegate(*this, FUNC(m72_state::rtype2_get_tile_info<0>)), TILEMAP_SCAN_ROWS, 8,8, 64,64);
m_bg_tilemap = &machine().tilemap().create(*m_gfxdecode, tilemap_get_info_delegate(*this, FUNC(m72_state::rtype2_get_tile_info<1>)), TILEMAP_SCAN_ROWS, 8,8, 64,64);
m_fg_tilemap = &machine().tilemap().create(*m_gfxdecode, tilemap_get_info_delegate(*this, FUNC(m82_state::rtype2_get_tile_info<0>)), TILEMAP_SCAN_ROWS, 8,8, 64,64);
m_bg_tilemap = &machine().tilemap().create(*m_gfxdecode, tilemap_get_info_delegate(*this, FUNC(m82_state::rtype2_get_tile_info<1>)), TILEMAP_SCAN_ROWS, 8,8, 64,64);
// The tilemap can be 256x64, but seems to be used at 128x64 (scroll wraparound).
// The layout ramains 256x64, the right half is just not displayed.
m_bg_tilemap_large = &machine().tilemap().create(*m_gfxdecode, tilemap_get_info_delegate(*this, FUNC(m72_state::rtype2_get_tile_info<1>)), tilemap_mapper_delegate(*this, FUNC(m72_state::m82_scan_rows)), 8,8, 128,64);
m_bg_tilemap_large = &machine().tilemap().create(*m_gfxdecode, tilemap_get_info_delegate(*this, FUNC(m82_state::rtype2_get_tile_info<1>)), tilemap_mapper_delegate(*this, FUNC(m82_state::m82_scan_rows)), 8,8, 128,64);
m_fg_tilemap->set_transmask(0,0xffff,0x0001);
m_fg_tilemap->set_transmask(1,0x00ff,0xff01);
@ -262,7 +262,7 @@ VIDEO_START_MEMBER(m72_state,hharryu)
// M85
VIDEO_START_MEMBER(m72_state,poundfor)
void poundfor_state::video_start()
{
VIDEO_START_CALL_MEMBER(rtype2);
@ -287,6 +287,12 @@ void m72_state::videoram1_w(offs_t offset, u16 data, u16 mem_mask)
}
void m72_state::videoram2_w(offs_t offset, u16 data, u16 mem_mask)
{
COMBINE_DATA(&m_videoram[1][offset]);
m_bg_tilemap->mark_tile_dirty(offset/2);
}
void m82_state::videoram2_m82_w(offs_t offset, u16 data, u16 mem_mask)
{
COMBINE_DATA(&m_videoram[1][offset]);
m_bg_tilemap->mark_tile_dirty(offset/2);
@ -294,7 +300,6 @@ void m72_state::videoram2_w(offs_t offset, u16 data, u16 mem_mask)
// m82 has selectable tilemap size
if (m_bg_tilemap_large)
m_bg_tilemap_large->mark_tile_dirty(offset/2);
}
void m72_state::irq_line_w(u16 data)
@ -321,14 +326,14 @@ void m72_state::port02_w(u8 data)
if (data & 0xe0) logerror("write %02x to port 02\n",data);
/* bits 0/1 are coin counters */
machine().bookkeeping().coin_counter_w(0,data & 0x01);
machine().bookkeeping().coin_counter_w(1,data & 0x02);
machine().bookkeeping().coin_counter_w(0, BIT(data, 0));
machine().bookkeeping().coin_counter_w(1, BIT(data, 1));
/* bit 2 is flip screen (handled both by software and hardware) */
flip_screen_set(((data & 0x04) >> 2) ^ ((~m_io_dsw->read() >> 8) & 1));
flip_screen_set(BIT(data, 2) ^ ((~m_io_dsw->read() >> 8) & 1));
/* bit 3 is display disable */
m_video_off = data & 0x08;
m_video_off = BIT(data, 3);
/* bit 4 resets sound CPU (active low) */
if (data & 0x10)
@ -344,19 +349,19 @@ void m72_state::rtype2_port02_w(u8 data)
if (data & 0xe0) logerror("write %02x to port 02\n",data);
/* bits 0/1 are coin counters */
machine().bookkeeping().coin_counter_w(0,data & 0x01);
machine().bookkeeping().coin_counter_w(1,data & 0x02);
machine().bookkeeping().coin_counter_w(0, BIT(data, 0));
machine().bookkeeping().coin_counter_w(1, BIT(data, 1));
/* bit 2 is flip screen (handled both by software and hardware) */
flip_screen_set(((data & 0x04) >> 2) ^ ((~m_io_dsw->read() >> 8) & 1));
flip_screen_set(BIT(data, 2) ^ ((~m_io_dsw->read() >> 8) & 1));
/* bit 3 is display disable */
m_video_off = data & 0x08;
m_video_off = BIT(data, 3);
/* other bits unknown */
}
void m72_state::poundfor_port02_w(u8 data)
void poundfor_state::poundfor_port02_w(u8 data)
{
// bit 5 resets both uPD4701A?
m_upd4701[0]->resetx_w(BIT(data, 5));
@ -370,17 +375,17 @@ void m72_state::poundfor_port02_w(u8 data)
/* the following is mostly a kludge. This register seems to be used for something else */
void m72_state::m82_gfx_ctrl_w(offs_t offset, u16 data, u16 mem_mask)
void m82_state::m82_gfx_ctrl_w(offs_t offset, u16 data, u16 mem_mask)
{
if (ACCESSING_BITS_8_15)
{
if (data & 0xff00) m_m82_rowscroll = 1;
else m_m82_rowscroll = 0;
if (data & 0xff00) m_m82_rowscroll = true;
else m_m82_rowscroll = false;
}
// printf("m82_gfx_ctrl_w %04x\n", data);
}
void m72_state::m82_tm_ctrl_w(offs_t offset, u16 data, u16 mem_mask)
void m82_state::m82_tm_ctrl_w(offs_t offset, u16 data, u16 mem_mask)
{
COMBINE_DATA(&m_m82_tmcontrol);
// printf("tmcontrol %04x\n", m_m82_tmcontrol);
@ -442,21 +447,19 @@ void m72_state::draw_sprites(bitmap_ind16 &bitmap,const rectangle &cliprect)
}
}
void m72_state::majtitle_draw_sprites(bitmap_ind16 &bitmap,const rectangle &cliprect)
void m82_state::majtitle_draw_sprites(bitmap_ind16 &bitmap,const rectangle &cliprect)
{
u16 *spriteram16_2 = m_spriteram2;
for (int offs = 0; offs < m_spriteram2.length(); offs += 4)
{
const int code = spriteram16_2[offs+1];
const u32 color = spriteram16_2[offs+2] & 0x0f;
int sx = -256+(spriteram16_2[offs+3] & 0x3ff);
int sy = 384-(spriteram16_2[offs+0] & 0x1ff);
int flipx = spriteram16_2[offs+2] & 0x0800;
int flipy = spriteram16_2[offs+2] & 0x0400;
const int code = m_spriteram2[offs+1];
const u32 color = m_spriteram2[offs+2] & 0x0f;
int sx = -256+(m_spriteram2[offs+3] & 0x3ff);
int sy = 384-(m_spriteram2[offs+0] & 0x1ff);
int flipx = m_spriteram2[offs+2] & 0x0800;
int flipy = m_spriteram2[offs+2] & 0x0400;
const int w = 1;// << ((spriteram16_2[offs+2] & 0xc000) >> 14);
const int h = 1 << ((spriteram16_2[offs+2] & 0x3000) >> 12);
const int w = 1;// << ((m_spriteram2[offs+2] & 0xc000) >> 14);
const int h = 1 << ((m_spriteram2[offs+2] & 0x3000) >> 12);
sy -= 16 * h;
if (flip_screen())
@ -522,7 +525,7 @@ u32 m72_state::screen_update_m81(screen_device &screen, bitmap_ind16 &bitmap, co
}
u32 m72_state::screen_update_m82(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
u32 m82_state::screen_update_m82(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
{
tilemap_t* tm;