summaryrefslogtreecommitdiffstats
path: root/src/mame/drivers/sshangha.cpp
diff options
context:
space:
mode:
authorGravatarGravatar Ivan Vangelista <mesgnet@yahoo.it>2018-09-10 18:33:38 +0200
committerGravatarGravatar Ivan Vangelista <mesgnet@yahoo.it>2018-09-10 18:33:38 +0200
commit5d7450dfe0b1a531e15fd2a5f5d9eaa7e0d265eb (patch) (github)
tree6444475bac83c3cf5f87164fc34a2b4ab7dddfa2 /src/mame/drivers/sshangha.cpp
parente6214269d8e9a47e04018e557c405b0640def991 (diff)
downloadmame-5d7450dfe0b1a531e15fd2a5f5d9eaa7e0d265eb.tar.bz2
mame-5d7450dfe0b1a531e15fd2a5f5d9eaa7e0d265eb.zip
sshangha.cpp: added save state support, removed MCFG macros (nw)
Diffstat (limited to 'src/mame/drivers/sshangha.cpp')
-rw-r--r--src/mame/drivers/sshangha.cpp193
1 files changed, 92 insertions, 101 deletions
diff --git a/src/mame/drivers/sshangha.cpp b/src/mame/drivers/sshangha.cpp
index 4187993a9b8..cf97d40a778 100644
--- a/src/mame/drivers/sshangha.cpp
+++ b/src/mame/drivers/sshangha.cpp
@@ -10,11 +10,6 @@
Emulation by Bryan McPhail, mish@tendril.co.uk
+ Charles MacDonald, David Haywood
- ToDo:
-
- Palette handling is somewhat hacked, see paletteram16_xbgr_word_be_sprites_w
- - check this on the original set
-
----
Stephh's notes (based on the games M68000 code and some tests) :
@@ -88,7 +83,6 @@ HB-PCB-A5 M6100691A (distributed by Taito)
#include "cpu/m68000/m68000.h"
#include "sound/2203intf.h"
#include "sound/okim6295.h"
-#include "machine/deco146.h"
#include "screen.h"
#include "speaker.h"
@@ -102,7 +96,7 @@ HB-PCB-A5 M6100691A (distributed by Taito)
-READ16_MEMBER(sshangha_state::sshanghb_protection16_r) // bootleg inputs
+READ16_MEMBER(sshangha_state::sshanghab_protection16_r) // bootleg inputs
{
switch (offset)
{
@@ -123,11 +117,6 @@ READ16_MEMBER(sshangha_state::deco_71_r)
return 0xffff;
}
-/******************************************************************************/
-
-void sshangha_state::machine_reset()
-{
-}
/******************************************************************************/
@@ -167,7 +156,7 @@ WRITE16_MEMBER( sshangha_state::sshangha_protection_region_8_146_w )
/*
- Swizzzle palette writes a bit so that the 'tilemap_12_combine_draw' code in the tilemap device works with this game (used for girl, see attract mode)
+ Swizzle palette writes a bit so that the 'tilemap_12_combine_draw' code in the tilemap device works with this game (used for girl, see attract mode)
Normal Palette layout
@@ -214,22 +203,22 @@ void sshangha_state::sshangha_map(address_map &map)
{
map.global_mask(0x3fffff);
map(0x000000, 0x03ffff).rom();
- map(0x100000, 0x10000f).ram().share("sound_shared");
+ map(0x100000, 0x10000f).ram().share(m_sound_shared_ram);
- map(0x200000, 0x201fff).rw(m_deco_tilegen1, FUNC(deco16ic_device::pf1_data_r), FUNC(deco16ic_device::pf1_data_w));
- map(0x202000, 0x203fff).rw(m_deco_tilegen1, FUNC(deco16ic_device::pf2_data_r), FUNC(deco16ic_device::pf2_data_w));
- map(0x204000, 0x2047ff).ram().share("pf1_rowscroll");
- map(0x206000, 0x2067ff).ram().share("pf2_rowscroll");
+ map(0x200000, 0x201fff).rw(m_tilegen, FUNC(deco16ic_device::pf1_data_r), FUNC(deco16ic_device::pf1_data_w));
+ map(0x202000, 0x203fff).rw(m_tilegen, FUNC(deco16ic_device::pf2_data_r), FUNC(deco16ic_device::pf2_data_w));
+ map(0x204000, 0x2047ff).ram().share(m_pf1_rowscroll);
+ map(0x206000, 0x2067ff).ram().share(m_pf2_rowscroll);
map(0x206800, 0x207fff).ram();
- map(0x300000, 0x30000f).w(m_deco_tilegen1, FUNC(deco16ic_device::pf_control_w));
- map(0x320000, 0x320001).w(FUNC(sshangha_state::sshangha_video_w));
+ map(0x300000, 0x30000f).w(m_tilegen, FUNC(deco16ic_device::pf_control_w));
+ map(0x320000, 0x320001).w(FUNC(sshangha_state::video_w));
map(0x320002, 0x320005).nopw();
map(0x320006, 0x320007).nopr(); //irq ack
- map(0x340000, 0x3407ff).mirror(0x800).ram().share("spriteram2");
+ map(0x340000, 0x3407ff).mirror(0x800).ram().share(m_spriteram2);
map(0x350000, 0x350001).r(FUNC(sshangha_state::deco_71_r));
map(0x350000, 0x350007).nopw();
- map(0x360000, 0x3607ff).mirror(0x800).ram().share("spriteram");
+ map(0x360000, 0x3607ff).mirror(0x800).ram().share(m_spriteram);
map(0x370000, 0x370001).r(FUNC(sshangha_state::deco_71_r));
map(0x370000, 0x370007).nopw();
@@ -237,22 +226,22 @@ void sshangha_state::sshangha_map(address_map &map)
map(0x381000, 0x383fff).ram(); // unused palette area
map(0x3e0000, 0x3e3fff).rw(FUNC(sshangha_state::sshangha_protection_region_8_146_r), FUNC(sshangha_state::sshangha_protection_region_8_146_w));
map(0x3ec000, 0x3f3fff).ram();
- map(0x3f4000, 0x3f7fff).rw(FUNC(sshangha_state::sshangha_protection_region_d_146_r), FUNC(sshangha_state::sshangha_protection_region_d_146_w)).share("prot_data");
+ map(0x3f4000, 0x3f7fff).rw(FUNC(sshangha_state::sshangha_protection_region_d_146_r), FUNC(sshangha_state::sshangha_protection_region_d_146_w)).share(m_prot_data);
}
-void sshangha_state::sshanghb_map(address_map &map)
+void sshangha_state::sshanghab_map(address_map &map)
{
map(0x000000, 0x03ffff).rom();
- map(0x084000, 0x0847ff).r(FUNC(sshangha_state::sshanghb_protection16_r));
- map(0x101000, 0x10100f).ram().share("sound_shared"); /* the bootleg writes here */
+ map(0x084000, 0x0847ff).r(FUNC(sshangha_state::sshanghab_protection16_r));
+ map(0x101000, 0x10100f).ram().share(m_sound_shared_ram); /* the bootleg writes here */
- map(0x200000, 0x201fff).rw(m_deco_tilegen1, FUNC(deco16ic_device::pf1_data_r), FUNC(deco16ic_device::pf1_data_w));
- map(0x202000, 0x203fff).rw(m_deco_tilegen1, FUNC(deco16ic_device::pf2_data_r), FUNC(deco16ic_device::pf2_data_w));
- map(0x204000, 0x2047ff).ram().share("pf1_rowscroll");
- map(0x206000, 0x2067ff).ram().share("pf2_rowscroll");
+ map(0x200000, 0x201fff).rw(m_tilegen, FUNC(deco16ic_device::pf1_data_r), FUNC(deco16ic_device::pf1_data_w));
+ map(0x202000, 0x203fff).rw(m_tilegen, FUNC(deco16ic_device::pf2_data_r), FUNC(deco16ic_device::pf2_data_w));
+ map(0x204000, 0x2047ff).ram().share(m_pf1_rowscroll);
+ map(0x206000, 0x2067ff).ram().share(m_pf2_rowscroll);
map(0x206800, 0x207fff).ram();
- map(0x300000, 0x30000f).w(m_deco_tilegen1, FUNC(deco16ic_device::pf_control_w));
- map(0x320000, 0x320001).w(FUNC(sshangha_state::sshangha_video_w));
+ map(0x300000, 0x30000f).w(m_tilegen, FUNC(deco16ic_device::pf_control_w));
+ map(0x320000, 0x320001).w(FUNC(sshangha_state::video_w));
map(0x320002, 0x320005).nopw();
map(0x320006, 0x320007).nopr(); //irq ack
@@ -261,8 +250,8 @@ void sshangha_state::sshanghb_map(address_map &map)
map(0x380000, 0x380fff).ram().rw(FUNC(sshangha_state::palette_r),FUNC(sshangha_state::palette_w)).share("palette");
map(0x381000, 0x383fff).ram(); // unused palette area
- map(0x3c0000, 0x3c07ff).ram().share("spriteram"); // bootleg spriteram
- map(0x3c0800, 0x3c0fff).ram().share("spriteram2");
+ map(0x3c0000, 0x3c07ff).ram().share(m_spriteram); // bootleg spriteram
+ map(0x3c0800, 0x3c0fff).ram().share(m_spriteram2);
map(0xfec000, 0xff3fff).ram();
map(0xff4000, 0xff47ff).ram();
@@ -272,23 +261,23 @@ void sshangha_state::sshanghb_map(address_map &map)
/* 8 "sound latches" shared between main and sound cpus. */
-READ8_MEMBER(sshangha_state::sshangha_sound_shared_r)
+READ8_MEMBER(sshangha_state::sound_shared_r)
{
return m_sound_shared_ram[offset] & 0xff;
}
-WRITE8_MEMBER(sshangha_state::sshangha_sound_shared_w)
+WRITE8_MEMBER(sshangha_state::sound_shared_w)
{
m_sound_shared_ram[offset] = data & 0xff;
}
/* Note: there's rom data after 0x8000 but the game never seem to call a rom bank, left-over? */
-void sshangha_state::sshangha_sound_map(address_map &map)
+void sshangha_state::sound_map(address_map &map)
{
map(0x0000, 0x7fff).rom();
map(0xc000, 0xc001).rw("ymsnd", FUNC(ym2203_device::read), FUNC(ym2203_device::write));
map(0xc200, 0xc201).rw("oki", FUNC(okim6295_device::read), FUNC(okim6295_device::write));
- map(0xf800, 0xf807).rw(FUNC(sshangha_state::sshangha_sound_shared_r), FUNC(sshangha_state::sshangha_sound_shared_w));
+ map(0xf800, 0xf807).rw(FUNC(sshangha_state::sound_shared_r), FUNC(sshangha_state::sound_shared_w));
map(0xf808, 0xffff).ram();
}
@@ -420,79 +409,81 @@ DECO16IC_BANK_CB_MEMBER(sshangha_state::bank_callback)
return (bank >> 4) * 0x1000;
}
-MACHINE_CONFIG_START(sshangha_state::sshangha)
-
+void sshangha_state::sshangha(machine_config &config)
+{
/* basic machine hardware */
- MCFG_DEVICE_ADD("maincpu", M68000, 16_MHz_XTAL) /* CPU marked as 16MHz part */
- MCFG_DEVICE_PROGRAM_MAP(sshangha_map)
- MCFG_DEVICE_VBLANK_INT_DRIVER("screen", sshangha_state, irq6_line_hold)
-
- MCFG_DEVICE_ADD("audiocpu", Z80, 16_MHz_XTAL / 4)
- MCFG_DEVICE_PROGRAM_MAP(sshangha_sound_map)
+ M68000(config, m_maincpu, 16_MHz_XTAL); /* CPU marked as 16MHz part */
+ m_maincpu->set_addrmap(AS_PROGRAM, &sshangha_state::sshangha_map);
+ m_maincpu->set_vblank_int("screen", FUNC(sshangha_state::irq6_line_hold));
- MCFG_QUANTUM_TIME(attotime::from_hz(6000))
+ Z80(config, m_audiocpu, 16_MHz_XTAL / 4);
+ m_audiocpu->set_addrmap(AS_PROGRAM, &sshangha_state::sound_map);
- MCFG_SCREEN_ADD("screen", RASTER)
- MCFG_SCREEN_REFRESH_RATE(60)
- MCFG_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(529))
- MCFG_SCREEN_SIZE(40*8, 32*8)
- MCFG_SCREEN_VISIBLE_AREA(0*8, 40*8-1, 1*8, 31*8-1)
- MCFG_SCREEN_UPDATE_DRIVER(sshangha_state, screen_update_sshangha)
-
- MCFG_DEVICE_ADD("gfxdecode", GFXDECODE, "palette", gfx_sshangha)
- MCFG_PALETTE_ADD("palette", 0x4000)
- MCFG_PALETTE_FORMAT(XBGR)
-
- MCFG_DEVICE_ADD("tilegen1", DECO16IC, 0)
- MCFG_DECO16IC_SPLIT(0)
- MCFG_DECO16IC_PF1_SIZE(DECO_64x32)
- MCFG_DECO16IC_PF2_SIZE(DECO_64x32)
- MCFG_DECO16IC_PF1_TRANS_MASK(0x0f)
- MCFG_DECO16IC_PF2_TRANS_MASK(0x0f)
- MCFG_DECO16IC_PF1_COL_BANK(0x30)
- MCFG_DECO16IC_PF2_COL_BANK(0x20)
- MCFG_DECO16IC_PF1_COL_MASK(0x0f)
- MCFG_DECO16IC_PF2_COL_MASK(0x0f)
- MCFG_DECO16IC_BANK1_CB(sshangha_state, bank_callback)
- MCFG_DECO16IC_BANK2_CB(sshangha_state, bank_callback)
- MCFG_DECO16IC_PF12_8X8_BANK(0)
- MCFG_DECO16IC_PF12_16X16_BANK(1)
- MCFG_DECO16IC_GFXDECODE("gfxdecode")
-
- MCFG_DEVICE_ADD("spritegen1", DECO_SPRITE, 0)
- MCFG_DECO_SPRITE_GFX_REGION(2)
- MCFG_DECO_SPRITE_GFXDECODE("gfxdecode")
-
- MCFG_DEVICE_ADD("spritegen2", DECO_SPRITE, 0)
- MCFG_DECO_SPRITE_GFX_REGION(3)
- MCFG_DECO_SPRITE_GFXDECODE("gfxdecode")
-
- MCFG_DECO146_ADD("ioprot")
- MCFG_DECO146_IN_PORTA_CB(IOPORT("INPUTS"))
- MCFG_DECO146_IN_PORTB_CB(IOPORT("SYSTEM"))
- MCFG_DECO146_IN_PORTC_CB(IOPORT("DSW"))
+ config.m_minimum_quantum = attotime::from_hz(6000);
+
+ screen_device& screen(SCREEN(config, "screen", SCREEN_TYPE_RASTER));
+ screen.set_refresh_hz(60);
+ screen.set_vblank_time(ATTOSECONDS_IN_USEC(529));
+ screen.set_size(40*8, 32*8);
+ screen.set_visarea(0*8, 40*8-1, 1*8, 31*8-1);
+ screen.set_screen_update(FUNC(sshangha_state::screen_update));
+
+ GFXDECODE(config, "gfxdecode", m_palette, gfx_sshangha);
+
+ PALETTE(config, m_palette, 0x4000).set_format(PALETTE_FORMAT_XBGR);
+
+ DECO16IC(config, m_tilegen, 0);
+ m_tilegen->set_split(0);
+ m_tilegen->set_pf1_size(DECO_64x32);
+ m_tilegen->set_pf2_size(DECO_64x32);
+ m_tilegen->set_pf1_trans_mask(0x0f);
+ m_tilegen->set_pf2_trans_mask(0x0f);
+ m_tilegen->set_pf1_col_bank(0x30);
+ m_tilegen->set_pf2_col_bank(0x20);
+ m_tilegen->set_pf1_col_mask(0x0f);
+ m_tilegen->set_pf2_col_mask(0x0f);
+ m_tilegen->set_bank1_callback(FUNC(sshangha_state::bank_callback), this);
+ m_tilegen->set_bank2_callback(FUNC(sshangha_state::bank_callback), this);
+ m_tilegen->set_pf12_8x8_bank(0);
+ m_tilegen->set_pf12_16x16_bank(1);
+ m_tilegen->set_gfxdecode_tag("gfxdecode");
+
+ DECO_SPRITE(config, m_sprgen1, 0);
+ m_sprgen1->set_gfx_region(2);
+ m_sprgen1->set_gfxdecode_tag("gfxdecode");
+
+ DECO_SPRITE(config, m_sprgen2, 0);
+ m_sprgen2->set_gfx_region(3);
+ m_sprgen2->set_gfxdecode_tag("gfxdecode");
+
+ DECO146PROT(config, m_deco146, 0);
+ m_deco146->port_a_cb().set_ioport("INPUTS");
+ m_deco146->port_b_cb().set_ioport("SYSTEM");
+ m_deco146->port_c_cb().set_ioport("DSW");
/* sound hardware */
SPEAKER(config, "lspeaker").front_left(); // sure it's stereo?
SPEAKER(config, "rspeaker").front_right();
- MCFG_DEVICE_ADD("ymsnd", YM2203, 16_MHz_XTAL / 4)
- MCFG_YM2203_IRQ_HANDLER(INPUTLINE("audiocpu", 0))
- MCFG_SOUND_ROUTE(ALL_OUTPUTS, "lspeaker", 0.33)
- MCFG_SOUND_ROUTE(ALL_OUTPUTS, "rspeaker", 0.33)
+ ym2203_device &ymsnd(YM2203(config, "ymsnd", 16_MHz_XTAL / 4));
+ ymsnd.irq_handler().set_inputline(m_audiocpu, 0);
+ ymsnd.add_route(ALL_OUTPUTS, "lspeaker", 0.33);
+ ymsnd.add_route(ALL_OUTPUTS, "rspeaker", 0.33);
- MCFG_DEVICE_ADD("oki", OKIM6295, 16_MHz_XTAL / 8, okim6295_device::PIN7_LOW) // clock frequency & pin 7 not verified
- MCFG_SOUND_ROUTE(ALL_OUTPUTS, "lspeaker", 0.27)
- MCFG_SOUND_ROUTE(ALL_OUTPUTS, "rspeaker", 0.27)
-MACHINE_CONFIG_END
+ okim6295_device &oki(OKIM6295(config, "oki", 16_MHz_XTAL / 8, okim6295_device::PIN7_LOW)); // clock frequency & pin 7 not verified
+ oki.add_route(ALL_OUTPUTS, "lspeaker", 0.27);
+ oki.add_route(ALL_OUTPUTS, "rspeaker", 0.27);
+}
-MACHINE_CONFIG_START(sshangha_state::sshanghb)
+void sshangha_state::sshanghab(machine_config &config)
+{
sshangha(config);
- MCFG_DEVICE_MODIFY("maincpu")
- MCFG_DEVICE_PROGRAM_MAP(sshanghb_map)
-MACHINE_CONFIG_END
+ m_maincpu->set_addrmap(AS_PROGRAM, &sshangha_state::sshanghab_map);
+
+ config.device_remove("ioprot");
+}
/******************************************************************************/
@@ -588,6 +579,6 @@ void sshangha_state::init_sshangha()
}
-GAME( 1992, sshangha, 0, sshangha, sshangha, sshangha_state, init_sshangha, ROT0, "Hot-B", "Super Shanghai Dragon's Eye (World)", 0 )
-GAME( 1992, sshanghaj, sshangha, sshangha, sshangha, sshangha_state, init_sshangha, ROT0, "Hot-B", "Super Shanghai Dragon's Eye (Japan)", 0 )
-GAME( 1992, sshanghab, sshangha, sshanghb, sshangha, sshangha_state, init_sshangha, ROT0, "bootleg", "Super Shanghai Dragon's Eye (World, bootleg)", 0 )
+GAME( 1992, sshangha, 0, sshangha, sshangha, sshangha_state, init_sshangha, ROT0, "Hot-B", "Super Shanghai Dragon's Eye (World)", MACHINE_SUPPORTS_SAVE )
+GAME( 1992, sshanghaj, sshangha, sshangha, sshangha, sshangha_state, init_sshangha, ROT0, "Hot-B", "Super Shanghai Dragon's Eye (Japan)", MACHINE_SUPPORTS_SAVE )
+GAME( 1992, sshanghab, sshangha, sshanghab, sshangha, sshangha_state, init_sshangha, ROT0, "bootleg", "Super Shanghai Dragon's Eye (World, bootleg)", MACHINE_SUPPORTS_SAVE )