toki.c: added save state support (nw)

This commit is contained in:
Ivan Vangelista 2015-02-04 19:31:41 +01:00
parent bdc1f8b93d
commit 61e7efde1b
3 changed files with 67 additions and 59 deletions

View File

@ -91,11 +91,11 @@ static ADDRESS_MAP_START( toki_map, AS_PROGRAM, 16, toki_state )
AM_RANGE(0x060000, 0x06d7ff) AM_RAM
AM_RANGE(0x06d800, 0x06dfff) AM_RAM AM_SHARE("spriteram")
AM_RANGE(0x06e000, 0x06e7ff) AM_RAM_DEVWRITE("palette", palette_device, write) AM_SHARE("palette")
AM_RANGE(0x06e800, 0x06efff) AM_RAM_WRITE(toki_background1_videoram16_w) AM_SHARE("bg1_vram16")
AM_RANGE(0x06f000, 0x06f7ff) AM_RAM_WRITE(toki_background2_videoram16_w) AM_SHARE("bg2_vram16")
AM_RANGE(0x06f800, 0x06ffff) AM_RAM_WRITE(toki_foreground_videoram16_w) AM_SHARE("videoram")
AM_RANGE(0x06e800, 0x06efff) AM_RAM_WRITE(background1_videoram_w) AM_SHARE("bg1_vram")
AM_RANGE(0x06f000, 0x06f7ff) AM_RAM_WRITE(background2_videoram_w) AM_SHARE("bg2_vram")
AM_RANGE(0x06f800, 0x06ffff) AM_RAM_WRITE(foreground_videoram_w) AM_SHARE("videoram")
AM_RANGE(0x080000, 0x08000d) AM_DEVREADWRITE("seibu_sound", seibu_sound_device, main_word_r, main_word_w)
AM_RANGE(0x0a0000, 0x0a005f) AM_WRITE(toki_control_w) AM_SHARE("scrollram16")
AM_RANGE(0x0a0000, 0x0a005f) AM_WRITE(toki_control_w) AM_SHARE("scrollram")
AM_RANGE(0x0c0000, 0x0c0001) AM_READ_PORT("DSW")
AM_RANGE(0x0c0002, 0x0c0003) AM_READ_PORT("INPUTS")
AM_RANGE(0x0c0004, 0x0c0005) AM_READ_PORT("SYSTEM")
@ -106,16 +106,16 @@ static ADDRESS_MAP_START( tokib_map, AS_PROGRAM, 16, toki_state )
AM_RANGE(0x000000, 0x05ffff) AM_ROM
AM_RANGE(0x060000, 0x06dfff) AM_RAM
AM_RANGE(0x06e000, 0x06e7ff) AM_RAM_DEVWRITE("palette", palette_device, write) AM_SHARE("palette")
AM_RANGE(0x06e800, 0x06efff) AM_RAM_WRITE(toki_background1_videoram16_w) AM_SHARE("bg1_vram16")
AM_RANGE(0x06f000, 0x06f7ff) AM_RAM_WRITE(toki_background2_videoram16_w) AM_SHARE("bg2_vram16")
AM_RANGE(0x06f800, 0x06ffff) AM_RAM_WRITE(toki_foreground_videoram16_w) AM_SHARE("videoram")
AM_RANGE(0x06e800, 0x06efff) AM_RAM_WRITE(background1_videoram_w) AM_SHARE("bg1_vram")
AM_RANGE(0x06f000, 0x06f7ff) AM_RAM_WRITE(background2_videoram_w) AM_SHARE("bg2_vram")
AM_RANGE(0x06f800, 0x06ffff) AM_RAM_WRITE(foreground_videoram_w) AM_SHARE("videoram")
AM_RANGE(0x071000, 0x071001) AM_WRITENOP /* sprite related? seems another scroll register */
/* gets written the same value as 75000a (bg2 scrollx) */
AM_RANGE(0x071804, 0x071807) AM_WRITENOP /* sprite related, always 01be0100 */
AM_RANGE(0x07180e, 0x071e45) AM_WRITEONLY AM_SHARE("spriteram")
AM_RANGE(0x072000, 0x072001) AM_READ(watchdog_reset16_r) /* probably */
AM_RANGE(0x075000, 0x075001) AM_WRITE(tokib_soundcommand16_w)
AM_RANGE(0x075004, 0x07500b) AM_WRITEONLY AM_SHARE("scrollram16")
AM_RANGE(0x075004, 0x07500b) AM_WRITEONLY AM_SHARE("scrollram")
AM_RANGE(0x0c0000, 0x0c0001) AM_READ_PORT("DSW")
AM_RANGE(0x0c0002, 0x0c0003) AM_READ_PORT("INPUTS")
AM_RANGE(0x0c0004, 0x0c0005) AM_READ_PORT("SYSTEM")
@ -826,6 +826,9 @@ DRIVER_INIT_MEMBER(toki_state,tokib)
memcpy (&base[0x18000 + i * 0x800], &temp[0x1800 + i * 0x2000], 0x800);
}
}
save_item(NAME(m_msm5205next));
save_item(NAME(m_toggle));
}
DRIVER_INIT_MEMBER(toki_state,jujuba)
@ -877,15 +880,15 @@ DRIVER_INIT_MEMBER(toki_state,jujuba)
// these 2 are both unique revisions
GAME( 1989, toki, 0, toki, toki, toki_state, toki, ROT0, "TAD Corporation", "Toki (World, set 1)", 0 )
GAME( 1989, tokiu, toki, toki, toki, toki_state, toki, ROT0, "TAD Corporation (Fabtek license)", "Toki (US, set 1)", 0 )
GAME( 1989, toki, 0, toki, toki, toki_state, toki, ROT0, "TAD Corporation", "Toki (World, set 1)", GAME_SUPPORTS_SAVE )
GAME( 1989, tokiu, toki, toki, toki, toki_state, toki, ROT0, "TAD Corporation (Fabtek license)", "Toki (US, set 1)", GAME_SUPPORTS_SAVE )
// these 3 are all the same revision, only the region byte differs
GAME( 1989, tokia, toki, toki, toki, toki_state, toki, ROT0, "TAD Corporation", "Toki (World, set 2)", 0 )
GAME( 1989, tokiua,toki, toki, toki, toki_state, toki, ROT0, "TAD Corporation (Fabtek license)", "Toki (US, set 2)", 0 )
GAME( 1989, juju, toki, toki, toki, toki_state, toki, ROT0, "TAD Corporation", "JuJu Densetsu (Japan)", 0 )
GAME( 1989, tokia, toki, toki, toki, toki_state, toki, ROT0, "TAD Corporation", "Toki (World, set 2)", GAME_SUPPORTS_SAVE )
GAME( 1989, tokiua,toki, toki, toki, toki_state, toki, ROT0, "TAD Corporation (Fabtek license)", "Toki (US, set 2)", GAME_SUPPORTS_SAVE )
GAME( 1989, juju, toki, toki, toki, toki_state, toki, ROT0, "TAD Corporation", "JuJu Densetsu (Japan)", GAME_SUPPORTS_SAVE )
GAME( 1990, tokib, toki, tokib, tokib, toki_state, tokib, ROT0, "bootleg (Datsu)", "Toki (Datsu bootleg)", 0 )
GAME( 1990, jujub, toki, tokib, tokib, toki_state, tokib, ROT0, "bootleg (Playmark)", "JuJu Densetsu (Playmark bootleg)", 0 )
GAME( 1990, tokib, toki, tokib, tokib, toki_state, tokib, ROT0, "bootleg (Datsu)", "Toki (Datsu bootleg)", GAME_SUPPORTS_SAVE )
GAME( 1990, jujub, toki, tokib, tokib, toki_state, tokib, ROT0, "bootleg (Playmark)", "JuJu Densetsu (Playmark bootleg)", GAME_SUPPORTS_SAVE )
/* Sound hardware seems to have been slightly modified, the coins are handled ok, but there is no music and bad sfx. Program roms have a slight bitswap, Flipscreen also seems to be ignored */
GAME( 1989, jujuba, toki, toki, toki, toki_state, jujuba, ROT180, "bootleg", "JuJu Densetsu (Japan, bootleg)", GAME_IMPERFECT_SOUND ) // bootleg of tokia/juju revison
GAME( 1989, jujuba, toki, toki, toki, toki_state, jujuba, ROT180, "bootleg", "JuJu Densetsu (Japan, bootleg)", GAME_IMPERFECT_SOUND | GAME_SUPPORTS_SAVE ) // bootleg of tokia/juju revison

View File

@ -7,24 +7,18 @@ class toki_state : public driver_device
public:
toki_state(const machine_config &mconfig, device_type type, const char *tag)
: driver_device(mconfig, type, tag),
m_spriteram(*this, "spriteram") ,
m_background1_videoram16(*this, "bg1_vram16"),
m_background2_videoram16(*this, "bg2_vram16"),
m_videoram(*this, "videoram"),
m_scrollram16(*this, "scrollram16"),
m_maincpu(*this, "maincpu"),
m_audiocpu(*this, "audiocpu"),
m_seibu_sound(*this, "seibu_sound"),
m_msm(*this, "msm"),
m_gfxdecode(*this, "gfxdecode"),
m_screen(*this, "screen"),
m_palette(*this, "palette") { }
required_device<buffered_spriteram16_device> m_spriteram;
required_shared_ptr<UINT16> m_background1_videoram16;
required_shared_ptr<UINT16> m_background2_videoram16;
required_shared_ptr<UINT16> m_videoram;
required_shared_ptr<UINT16> m_scrollram16;
m_palette(*this, "palette"),
m_spriteram(*this, "spriteram") ,
m_background1_videoram(*this, "bg1_vram"),
m_background2_videoram(*this, "bg2_vram"),
m_videoram(*this, "videoram"),
m_scrollram(*this, "scrollram") { }
required_device<cpu_device> m_maincpu;
required_device<cpu_device> m_audiocpu;
@ -34,30 +28,41 @@ public:
required_device<screen_device> m_screen;
required_device<palette_device> m_palette;
required_device<buffered_spriteram16_device> m_spriteram;
required_shared_ptr<UINT16> m_background1_videoram;
required_shared_ptr<UINT16> m_background2_videoram;
required_shared_ptr<UINT16> m_videoram;
required_shared_ptr<UINT16> m_scrollram;
int m_msm5205next;
int m_toggle;
tilemap_t *m_background_layer;
tilemap_t *m_foreground_layer;
tilemap_t *m_text_layer;
DECLARE_WRITE16_MEMBER(tokib_soundcommand16_w);
DECLARE_READ16_MEMBER(pip16_r);
DECLARE_WRITE8_MEMBER(toki_adpcm_data_w);
DECLARE_WRITE16_MEMBER(tokib_soundcommand_w);
DECLARE_READ16_MEMBER(pip_r);
DECLARE_WRITE16_MEMBER(toki_control_w);
DECLARE_WRITE16_MEMBER(toki_foreground_videoram16_w);
DECLARE_WRITE16_MEMBER(toki_background1_videoram16_w);
DECLARE_WRITE16_MEMBER(toki_background2_videoram16_w);
DECLARE_WRITE8_MEMBER(toki_adpcm_control_w);
DECLARE_WRITE16_MEMBER(foreground_videoram_w);
DECLARE_WRITE16_MEMBER(background1_videoram_w);
DECLARE_WRITE16_MEMBER(background2_videoram_w);
DECLARE_WRITE8_MEMBER(tokib_adpcm_control_w);
DECLARE_WRITE8_MEMBER(tokib_adpcm_data_w);
DECLARE_WRITE_LINE_MEMBER(tokib_adpcm_int);
DECLARE_DRIVER_INIT(tokib);
DECLARE_DRIVER_INIT(jujuba);
DECLARE_DRIVER_INIT(toki);
TILE_GET_INFO_MEMBER(get_text_tile_info);
TILE_GET_INFO_MEMBER(get_back_tile_info);
TILE_GET_INFO_MEMBER(get_fore_tile_info);
virtual void video_start();
UINT32 screen_update_toki(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
UINT32 screen_update_tokib(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
void toki_draw_sprites(bitmap_ind16 &bitmap,const rectangle &cliprect);
void tokib_draw_sprites(bitmap_ind16 &bitmap,const rectangle &cliprect);
DECLARE_WRITE_LINE_MEMBER(toki_adpcm_int);
};

View File

@ -29,7 +29,7 @@ remove all the code writing the $a0000 area.)
WRITE16_MEMBER(toki_state::toki_control_w)
{
m_screen->update_partial(m_screen->vpos() - 1);
COMBINE_DATA(&m_scrollram16[offset]);
COMBINE_DATA(&m_scrollram[offset]);
}
TILE_GET_INFO_MEMBER(toki_state::get_text_tile_info)
@ -48,7 +48,7 @@ TILE_GET_INFO_MEMBER(toki_state::get_text_tile_info)
TILE_GET_INFO_MEMBER(toki_state::get_back_tile_info)
{
int tile = m_background1_videoram16[tile_index];
int tile = m_background1_videoram[tile_index];
int color = (tile >> 12) & 0xf;
tile &= 0xfff;
@ -61,7 +61,7 @@ TILE_GET_INFO_MEMBER(toki_state::get_back_tile_info)
TILE_GET_INFO_MEMBER(toki_state::get_fore_tile_info)
{
int tile = m_background2_videoram16[tile_index];
int tile = m_background2_videoram[tile_index];
int color = (tile >> 12) & 0xf;
tile &= 0xfff;
@ -92,22 +92,22 @@ void toki_state::video_start()
/*************************************/
WRITE16_MEMBER(toki_state::toki_foreground_videoram16_w)
WRITE16_MEMBER(toki_state::foreground_videoram_w)
{
UINT16 *videoram = m_videoram;
COMBINE_DATA(&videoram[offset]);
m_text_layer->mark_tile_dirty(offset);
}
WRITE16_MEMBER(toki_state::toki_background1_videoram16_w)
WRITE16_MEMBER(toki_state::background1_videoram_w)
{
COMBINE_DATA(&m_background1_videoram16[offset]);
COMBINE_DATA(&m_background1_videoram[offset]);
m_background_layer->mark_tile_dirty(offset);
}
WRITE16_MEMBER(toki_state::toki_background2_videoram16_w)
WRITE16_MEMBER(toki_state::background2_videoram_w)
{
COMBINE_DATA(&m_background2_videoram16[offset]);
COMBINE_DATA(&m_background2_videoram[offset]);
m_foreground_layer->mark_tile_dirty(offset);
}
@ -249,25 +249,25 @@ UINT32 toki_state::screen_update_toki(screen_device &screen, bitmap_ind16 &bitma
{
int background_y_scroll,foreground_y_scroll,background_x_scroll,foreground_x_scroll;
background_x_scroll=((m_scrollram16[0x06] &0x7f) << 1)
|((m_scrollram16[0x06] &0x80) >> 7)
|((m_scrollram16[0x05] &0x10) << 4);
background_y_scroll=((m_scrollram16[0x0d]&0x10)<<4)+((m_scrollram16[0x0e]&0x7f)<<1)+((m_scrollram16[0x0e]&0x80)>>7);
background_x_scroll=((m_scrollram[0x06] &0x7f) << 1)
|((m_scrollram[0x06] &0x80) >> 7)
|((m_scrollram[0x05] &0x10) << 4);
background_y_scroll=((m_scrollram[0x0d]&0x10)<<4)+((m_scrollram[0x0e]&0x7f)<<1)+((m_scrollram[0x0e]&0x80)>>7);
m_background_layer->set_scrollx(0, background_x_scroll );
m_background_layer->set_scrolly(0, background_y_scroll );
foreground_x_scroll= ((m_scrollram16[0x16] &0x7f) << 1)
|((m_scrollram16[0x16] &0x80) >> 7)
|((m_scrollram16[0x15] &0x10) << 4);
foreground_y_scroll=((m_scrollram16[0x1d]&0x10)<<4)+((m_scrollram16[0x1e]&0x7f)<<1)+((m_scrollram16[0x1e]&0x80)>>7);
foreground_x_scroll= ((m_scrollram[0x16] &0x7f) << 1)
|((m_scrollram[0x16] &0x80) >> 7)
|((m_scrollram[0x15] &0x10) << 4);
foreground_y_scroll=((m_scrollram[0x1d]&0x10)<<4)+((m_scrollram[0x1e]&0x7f)<<1)+((m_scrollram[0x1e]&0x80)>>7);
m_foreground_layer->set_scrollx(0, foreground_x_scroll );
m_foreground_layer->set_scrolly(0, foreground_y_scroll );
flip_screen_set((m_scrollram16[0x28]&0x8000)==0);
flip_screen_set((m_scrollram[0x28]&0x8000)==0);
if (m_scrollram16[0x28]&0x100) {
if (m_scrollram[0x28]&0x100) {
m_background_layer->draw(screen, bitmap, cliprect, TILEMAP_DRAW_OPAQUE,0);
m_foreground_layer->draw(screen, bitmap, cliprect, 0,0);
} else {
@ -283,12 +283,12 @@ UINT32 toki_state::screen_update_tokib(screen_device &screen, bitmap_ind16 &bitm
{
m_foreground_layer->set_scroll_rows(1);
m_background_layer->set_scroll_rows(1);
m_background_layer->set_scrolly(0, m_scrollram16[0]+1 );
m_background_layer->set_scrollx(0, m_scrollram16[1]-0x103 );
m_foreground_layer->set_scrolly(0, m_scrollram16[2]+1 );
m_foreground_layer->set_scrollx(0, m_scrollram16[3]-0x101 );
m_background_layer->set_scrolly(0, m_scrollram[0]+1 );
m_background_layer->set_scrollx(0, m_scrollram[1]-0x103 );
m_foreground_layer->set_scrolly(0, m_scrollram[2]+1 );
m_foreground_layer->set_scrollx(0, m_scrollram[3]-0x101 );
if (m_scrollram16[3]&0x2000) {
if (m_scrollram[3]&0x2000) {
m_background_layer->draw(screen, bitmap, cliprect, TILEMAP_DRAW_OPAQUE,0);
m_foreground_layer->draw(screen, bitmap, cliprect, 0,0);
} else {