speedbal.c, timelimt.c: added save state support (nw)

This commit is contained in:
Ivan Vangelista 2015-03-05 18:18:31 +01:00
parent 8301a2478d
commit a47ce0dc43
6 changed files with 104 additions and 91 deletions

View File

@ -33,7 +33,14 @@ Interrupt frequency on audio CPU is not a periodical signal, but there are a lot
#include "includes/speedbal.h"
#include "speedbal.lh"
WRITE8_MEMBER(speedbal_state::speedbal_coincounter_w)
void speedbal_state::machine_start()
{
save_item(NAME(m_leds_start));
save_item(NAME(m_leds_shiftreg));
}
WRITE8_MEMBER(speedbal_state::coincounter_w)
{
coin_counter_w(machine(), 0, data & 0x80);
coin_counter_w(machine(), 1, data & 0x40);
@ -44,16 +51,16 @@ WRITE8_MEMBER(speedbal_state::speedbal_coincounter_w)
static ADDRESS_MAP_START( main_cpu_map, AS_PROGRAM, 8, speedbal_state )
AM_RANGE(0x0000, 0xdbff) AM_ROM
AM_RANGE(0xdc00, 0xdfff) AM_RAM AM_SHARE("share1") // shared with SOUND
AM_RANGE(0xe000, 0xe1ff) AM_RAM_WRITE(speedbal_background_videoram_w) AM_SHARE("bg_videoram")
AM_RANGE(0xe800, 0xefff) AM_RAM_WRITE(speedbal_foreground_videoram_w) AM_SHARE("fg_videoram")
AM_RANGE(0xe000, 0xe1ff) AM_RAM_WRITE(background_videoram_w) AM_SHARE("bg_videoram")
AM_RANGE(0xe800, 0xefff) AM_RAM_WRITE(foreground_videoram_w) AM_SHARE("fg_videoram")
AM_RANGE(0xf000, 0xf5ff) AM_RAM_DEVWRITE("palette", palette_device, write) AM_SHARE("palette")
AM_RANGE(0xf600, 0xfeff) AM_RAM
AM_RANGE(0xff00, 0xffff) AM_RAM AM_SHARE("spriteram")
ADDRESS_MAP_END
WRITE8_MEMBER(speedbal_state::speedbal_maincpu_50_w)
WRITE8_MEMBER(speedbal_state::maincpu_50_w)
{
//logerror("%s: speedbal_maincpu_50_w %02x\n", this->machine().describe_context(), data);
//logerror("%s: maincpu_50_w %02x\n", this->machine().describe_context(), data);
}
static ADDRESS_MAP_START( main_cpu_io_map, AS_IO, 8, speedbal_state )
@ -62,8 +69,8 @@ static ADDRESS_MAP_START( main_cpu_io_map, AS_IO, 8, speedbal_state )
AM_RANGE(0x10, 0x10) AM_READ_PORT("DSW1")
AM_RANGE(0x20, 0x20) AM_READ_PORT("P1")
AM_RANGE(0x30, 0x30) AM_READ_PORT("P2")
AM_RANGE(0x40, 0x40) AM_WRITE(speedbal_coincounter_w)
AM_RANGE(0x50, 0x50) AM_WRITE(speedbal_maincpu_50_w)
AM_RANGE(0x40, 0x40) AM_WRITE(coincounter_w)
AM_RANGE(0x50, 0x50) AM_WRITE(maincpu_50_w)
ADDRESS_MAP_END
static ADDRESS_MAP_START( sound_cpu_map, AS_PROGRAM, 8, speedbal_state )
@ -264,7 +271,7 @@ static MACHINE_CONFIG_START( speedbal, speedbal_state )
MCFG_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(2500) /* not accurate */)
MCFG_SCREEN_SIZE(32*8, 32*8)
MCFG_SCREEN_VISIBLE_AREA(0*8, 32*8-1, 2*8, 30*8-1)
MCFG_SCREEN_UPDATE_DRIVER(speedbal_state, screen_update_speedbal)
MCFG_SCREEN_UPDATE_DRIVER(speedbal_state, screen_update)
MCFG_SCREEN_PALETTE("palette")
MCFG_GFXDECODE_ADD("gfxdecode", "palette", speedbal)
@ -375,5 +382,5 @@ DRIVER_INIT_MEMBER(speedbal_state,musicbal)
GAMEL( 1987, speedbal, 0, speedbal, speedbal, speedbal_state, speedbal, ROT270, "Tecfri / Desystem S.A.", "Speed Ball", 0, layout_speedbal )
GAMEL( 1988, musicbal, 0, speedbal, musicbal, speedbal_state, musicbal, ROT270, "Tecfri / Desystem S.A.", "Music Ball", 0, layout_speedbal )
GAMEL( 1987, speedbal, 0, speedbal, speedbal, speedbal_state, speedbal, ROT270, "Tecfri / Desystem S.A.", "Speed Ball", GAME_SUPPORTS_SAVE, layout_speedbal )
GAMEL( 1988, musicbal, 0, speedbal, musicbal, speedbal_state, musicbal, ROT270, "Tecfri / Desystem S.A.", "Music Ball", GAME_SUPPORTS_SAVE, layout_speedbal )

View File

@ -21,6 +21,7 @@ Notes:
void timelimt_state::machine_start()
{
save_item(NAME(m_nmi_enabled));
}
void timelimt_state::machine_reset()
@ -44,8 +45,8 @@ WRITE8_MEMBER(timelimt_state::sound_reset_w)
static ADDRESS_MAP_START( main_map, AS_PROGRAM, 8, timelimt_state )
AM_RANGE(0x0000, 0x7fff) AM_ROM /* rom */
AM_RANGE(0x8000, 0x87ff) AM_RAM /* ram */
AM_RANGE(0x8800, 0x8bff) AM_RAM_WRITE(timelimt_videoram_w) AM_SHARE("videoram") /* video ram */
AM_RANGE(0x9000, 0x97ff) AM_RAM_WRITE(timelimt_bg_videoram_w) AM_SHARE("bg_videoram")/* background ram */
AM_RANGE(0x8800, 0x8bff) AM_RAM_WRITE(videoram_w) AM_SHARE("videoram") /* video ram */
AM_RANGE(0x9000, 0x97ff) AM_RAM_WRITE(bg_videoram_w) AM_SHARE("bg_videoram")/* background ram */
AM_RANGE(0x9800, 0x98ff) AM_RAM AM_SHARE("spriteram") /* sprite ram */
AM_RANGE(0xa000, 0xa000) AM_READ_PORT("INPUTS")
AM_RANGE(0xa800, 0xa800) AM_READ_PORT("SYSTEM")
@ -54,9 +55,9 @@ static ADDRESS_MAP_START( main_map, AS_PROGRAM, 8, timelimt_state )
AM_RANGE(0xb003, 0xb003) AM_WRITE(sound_reset_w)/* sound reset ? */
AM_RANGE(0xb800, 0xb800) AM_WRITE(soundlatch_byte_w) /* sound write */
AM_RANGE(0xb800, 0xb800) AM_READNOP /* NMI ack? */
AM_RANGE(0xc800, 0xc800) AM_WRITE(timelimt_scroll_x_lsb_w)
AM_RANGE(0xc801, 0xc801) AM_WRITE(timelimt_scroll_x_msb_w)
AM_RANGE(0xc802, 0xc802) AM_WRITE(timelimt_scroll_y_w)
AM_RANGE(0xc800, 0xc800) AM_WRITE(scroll_x_lsb_w)
AM_RANGE(0xc801, 0xc801) AM_WRITE(scroll_x_msb_w)
AM_RANGE(0xc802, 0xc802) AM_WRITE(scroll_y_w)
AM_RANGE(0xc803, 0xc803) AM_WRITENOP /* ???? bit 0 used only */
AM_RANGE(0xc804, 0xc804) AM_WRITENOP /* ???? not used */
ADDRESS_MAP_END
@ -204,7 +205,7 @@ GFXDECODE_END
/***************************************************************************/
INTERRUPT_GEN_MEMBER(timelimt_state::timelimt_irq)
INTERRUPT_GEN_MEMBER(timelimt_state::irq)
{
if ( m_nmi_enabled )
device.execute().set_input_line(INPUT_LINE_NMI, PULSE_LINE);
@ -218,7 +219,7 @@ static MACHINE_CONFIG_START( timelimt, timelimt_state )
MCFG_CPU_ADD("maincpu", Z80, 5000000) /* 5.000 MHz */
MCFG_CPU_PROGRAM_MAP(main_map)
MCFG_CPU_IO_MAP(main_io_map)
MCFG_CPU_VBLANK_INT_DRIVER("screen", timelimt_state, timelimt_irq)
MCFG_CPU_VBLANK_INT_DRIVER("screen", timelimt_state, irq)
MCFG_CPU_ADD("audiocpu", Z80,18432000/6) /* 3.072 MHz */
MCFG_CPU_PROGRAM_MAP(sound_map)
@ -234,7 +235,7 @@ static MACHINE_CONFIG_START( timelimt, timelimt_state )
MCFG_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(0))
MCFG_SCREEN_SIZE(32*8, 32*8)
MCFG_SCREEN_VISIBLE_AREA(0*8, 32*8-1, 2*8, 30*8-1)
MCFG_SCREEN_UPDATE_DRIVER(timelimt_state, screen_update_timelimt)
MCFG_SCREEN_UPDATE_DRIVER(timelimt_state, screen_update)
MCFG_SCREEN_PALETTE("palette")
MCFG_GFXDECODE_ADD("gfxdecode", "palette", timelimt)
@ -317,5 +318,5 @@ ROM_START( progress )
ROM_LOAD( "57.bin", 0x0040, 0x0020, CRC(18455a79) SHA1(e4d64368560e3116a922588129f5f91a4c520f7d) )
ROM_END
GAME( 1983, timelimt, 0, timelimt, timelimt, driver_device, 0, ROT90, "Chuo Co. Ltd", "Time Limit", GAME_IMPERFECT_COLORS )
GAME( 1984, progress, 0, timelimt, progress, driver_device, 0, ROT90, "Chuo Co. Ltd", "Progress", 0 )
GAME( 1983, timelimt, 0, timelimt, timelimt, driver_device, 0, ROT90, "Chuo Co. Ltd", "Time Limit", GAME_IMPERFECT_COLORS | GAME_SUPPORTS_SAVE )
GAME( 1984, progress, 0, timelimt, progress, driver_device, 0, ROT90, "Chuo Co. Ltd", "Progress", GAME_SUPPORTS_SAVE )

View File

@ -4,41 +4,42 @@ public:
speedbal_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_spriteram(*this, "spriteram"),
m_background_videoram(*this, "bg_videoram"),
m_foreground_videoram(*this, "fg_videoram"),
m_gfxdecode(*this, "gfxdecode"),
m_palette(*this, "palette")
m_foreground_videoram(*this, "fg_videoram")
{ }
required_device<cpu_device> m_maincpu;
required_shared_ptr<UINT8> m_spriteram;
required_shared_ptr<UINT8> m_background_videoram;
required_shared_ptr<UINT8> m_foreground_videoram;
required_device<gfxdecode_device> m_gfxdecode;
required_device<palette_device> m_palette;
required_shared_ptr<UINT8> m_spriteram;
required_shared_ptr<UINT8> m_background_videoram;
required_shared_ptr<UINT8> m_foreground_videoram;
bool m_leds_start;
UINT32 m_leds_shiftreg;
tilemap_t *m_bg_tilemap;
tilemap_t *m_fg_tilemap;
DECLARE_DRIVER_INIT(speedbal);
DECLARE_DRIVER_INIT(musicbal);
virtual void machine_start();
virtual void video_start();
DECLARE_WRITE8_MEMBER(speedbal_coincounter_w);
DECLARE_WRITE8_MEMBER(speedbal_foreground_videoram_w);
DECLARE_WRITE8_MEMBER(speedbal_background_videoram_w);
DECLARE_WRITE8_MEMBER(speedbal_maincpu_50_w);
DECLARE_WRITE8_MEMBER(coincounter_w);
DECLARE_WRITE8_MEMBER(foreground_videoram_w);
DECLARE_WRITE8_MEMBER(background_videoram_w);
DECLARE_WRITE8_MEMBER(maincpu_50_w);
DECLARE_WRITE8_MEMBER(leds_output_block);
DECLARE_WRITE8_MEMBER(leds_start_block);
DECLARE_WRITE8_MEMBER(leds_shift_bit);
TILE_GET_INFO_MEMBER(get_tile_info_bg);
TILE_GET_INFO_MEMBER(get_tile_info_fg);
virtual void video_start();
UINT32 screen_update_speedbal(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
UINT32 screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
void draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect);
};

View File

@ -3,40 +3,47 @@ class timelimt_state : public driver_device
public:
timelimt_state(const machine_config &mconfig, device_type type, const char *tag)
: driver_device(mconfig, type, tag),
m_videoram(*this, "videoram"),
m_bg_videoram(*this, "bg_videoram"),
m_spriteram(*this, "spriteram"),
m_maincpu(*this, "maincpu"),
m_audiocpu(*this, "audiocpu"),
m_gfxdecode(*this, "gfxdecode"),
m_palette(*this, "palette") { }
m_palette(*this, "palette"),
m_videoram(*this, "videoram"),
m_bg_videoram(*this, "bg_videoram"),
m_spriteram(*this, "spriteram") { }
required_shared_ptr<UINT8> m_videoram;
int m_nmi_enabled;
required_shared_ptr<UINT8> m_bg_videoram;
int m_scrollx;
int m_scrolly;
tilemap_t *m_bg_tilemap;
tilemap_t *m_fg_tilemap;
required_shared_ptr<UINT8> m_spriteram;
DECLARE_WRITE8_MEMBER(nmi_enable_w);
DECLARE_WRITE8_MEMBER(sound_reset_w);
DECLARE_WRITE8_MEMBER(timelimt_videoram_w);
DECLARE_WRITE8_MEMBER(timelimt_bg_videoram_w);
DECLARE_WRITE8_MEMBER(timelimt_scroll_x_lsb_w);
DECLARE_WRITE8_MEMBER(timelimt_scroll_x_msb_w);
DECLARE_WRITE8_MEMBER(timelimt_scroll_y_w);
TILE_GET_INFO_MEMBER(get_bg_tile_info);
TILE_GET_INFO_MEMBER(get_fg_tile_info);
virtual void machine_start();
virtual void machine_reset();
virtual void video_start();
DECLARE_PALETTE_INIT(timelimt);
UINT32 screen_update_timelimt(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
INTERRUPT_GEN_MEMBER(timelimt_irq);
void draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect);
required_device<cpu_device> m_maincpu;
required_device<cpu_device> m_audiocpu;
required_device<gfxdecode_device> m_gfxdecode;
required_device<palette_device> m_palette;
required_shared_ptr<UINT8> m_videoram;
required_shared_ptr<UINT8> m_bg_videoram;
required_shared_ptr<UINT8> m_spriteram;
int m_nmi_enabled;
int m_scrollx;
int m_scrolly;
tilemap_t *m_bg_tilemap;
tilemap_t *m_fg_tilemap;
DECLARE_WRITE8_MEMBER(nmi_enable_w);
DECLARE_WRITE8_MEMBER(sound_reset_w);
DECLARE_WRITE8_MEMBER(videoram_w);
DECLARE_WRITE8_MEMBER(bg_videoram_w);
DECLARE_WRITE8_MEMBER(scroll_x_lsb_w);
DECLARE_WRITE8_MEMBER(scroll_x_msb_w);
DECLARE_WRITE8_MEMBER(scroll_y_w);
TILE_GET_INFO_MEMBER(get_bg_tile_info);
TILE_GET_INFO_MEMBER(get_fg_tile_info);
virtual void machine_start();
virtual void machine_reset();
virtual void video_start();
DECLARE_PALETTE_INIT(timelimt);
UINT32 screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
void draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect);
INTERRUPT_GEN_MEMBER(irq);
};

View File

@ -54,7 +54,7 @@ void speedbal_state::video_start()
* *
*************************************/
WRITE8_MEMBER(speedbal_state::speedbal_foreground_videoram_w)
WRITE8_MEMBER(speedbal_state::foreground_videoram_w)
{
m_foreground_videoram[offset] = data;
m_fg_tilemap->mark_tile_dirty(offset>>1);
@ -66,7 +66,7 @@ WRITE8_MEMBER(speedbal_state::speedbal_foreground_videoram_w)
* *
*************************************/
WRITE8_MEMBER(speedbal_state::speedbal_background_videoram_w)
WRITE8_MEMBER(speedbal_state::background_videoram_w)
{
m_background_videoram[offset] = data;
m_bg_tilemap->mark_tile_dirty(offset>>1);
@ -81,22 +81,21 @@ WRITE8_MEMBER(speedbal_state::speedbal_background_videoram_w)
void speedbal_state::draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect)
{
UINT8 *spriteram = m_spriteram;
int x,y,code,color,offset,flipx,flipy;
/* Drawing sprites: 64 in total */
for (offset = 0;offset < m_spriteram.bytes();offset += 4)
{
if(!(spriteram[offset + 2] & 0x80))
if(!(m_spriteram[offset + 2] & 0x80))
continue;
x = 243 - spriteram[offset + 3];
y = 239 - spriteram[offset + 0];
x = 243 - m_spriteram[offset + 3];
y = 239 - m_spriteram[offset + 0];
code = (spriteram[offset + 1]) | ((spriteram[offset + 2] & 0x40) << 2);
code = (m_spriteram[offset + 1]) | ((m_spriteram[offset + 2] & 0x40) << 2);
color = spriteram[offset + 2] & 0x0f;
color = m_spriteram[offset + 2] & 0x0f;
flipx = flipy = 0;
@ -121,7 +120,7 @@ void speedbal_state::draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprec
* *
*************************************/
UINT32 speedbal_state::screen_update_speedbal(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
UINT32 speedbal_state::screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
{
m_bg_tilemap->draw(screen, bitmap, cliprect, TILEMAP_DRAW_LAYER1, 0);
m_fg_tilemap->draw(screen, bitmap, cliprect, TILEMAP_DRAW_LAYER1, 0);

View File

@ -61,8 +61,7 @@ TILE_GET_INFO_MEMBER(timelimt_state::get_bg_tile_info)
TILE_GET_INFO_MEMBER(timelimt_state::get_fg_tile_info)
{
UINT8 *videoram = m_videoram;
SET_TILE_INFO_MEMBER(0, videoram[tile_index], 0, 0);
SET_TILE_INFO_MEMBER(0, m_videoram[tile_index], 0, 0);
}
void timelimt_state::video_start()
@ -74,36 +73,38 @@ void timelimt_state::video_start()
8, 8, 32, 32);
m_fg_tilemap->set_transparent_pen(0);
save_item(NAME(m_scrollx));
save_item(NAME(m_scrolly));
}
/***************************************************************************/
WRITE8_MEMBER(timelimt_state::timelimt_videoram_w)
WRITE8_MEMBER(timelimt_state::videoram_w)
{
UINT8 *videoram = m_videoram;
videoram[offset] = data;
m_videoram[offset] = data;
m_fg_tilemap->mark_tile_dirty(offset);
}
WRITE8_MEMBER(timelimt_state::timelimt_bg_videoram_w)
WRITE8_MEMBER(timelimt_state::bg_videoram_w)
{
m_bg_videoram[offset] = data;
m_bg_tilemap->mark_tile_dirty(offset);
}
WRITE8_MEMBER(timelimt_state::timelimt_scroll_x_lsb_w)
WRITE8_MEMBER(timelimt_state::scroll_x_lsb_w)
{
m_scrollx &= 0x100;
m_scrollx |= data & 0xff;
}
WRITE8_MEMBER(timelimt_state::timelimt_scroll_x_msb_w)
WRITE8_MEMBER(timelimt_state::scroll_x_msb_w)
{
m_scrollx &= 0xff;
m_scrollx |= ( data & 1 ) << 8;
}
WRITE8_MEMBER(timelimt_state::timelimt_scroll_y_w)
WRITE8_MEMBER(timelimt_state::scroll_y_w)
{
m_scrolly = data;
}
@ -111,17 +112,14 @@ WRITE8_MEMBER(timelimt_state::timelimt_scroll_y_w)
void timelimt_state::draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect)
{
UINT8 *spriteram = m_spriteram;
int offs;
for( offs = m_spriteram.bytes(); offs >= 0; offs -= 4 )
for( int offs = m_spriteram.bytes(); offs >= 0; offs -= 4 )
{
int sy = 240 - spriteram[offs];
int sx = spriteram[offs+3];
int code = spriteram[offs+1] & 0x3f;
int attr = spriteram[offs+2];
int flipy = spriteram[offs+1] & 0x80;
int flipx = spriteram[offs+1] & 0x40;
int sy = 240 - m_spriteram[offs];
int sx = m_spriteram[offs+3];
int code = m_spriteram[offs+1] & 0x3f;
int attr = m_spriteram[offs+2];
int flipy = m_spriteram[offs+1] & 0x80;
int flipx = m_spriteram[offs+1] & 0x40;
code += ( attr & 0x80 ) ? 0x40 : 0x00;
code += ( attr & 0x40 ) ? 0x80 : 0x00;
@ -135,7 +133,7 @@ void timelimt_state::draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprec
}
UINT32 timelimt_state::screen_update_timelimt(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
UINT32 timelimt_state::screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
{
m_bg_tilemap->set_scrollx(0, m_scrollx);
m_bg_tilemap->set_scrolly(0, m_scrolly);