fgoal.c: killed anonymous timer, enabled save state support (nw)

This commit is contained in:
Ivan Vangelista 2015-02-28 10:00:09 +01:00
parent bc6d208c90
commit 5a18715fca
3 changed files with 83 additions and 77 deletions

View File

@ -98,30 +98,30 @@ TIMER_CALLBACK_MEMBER(fgoal_state::interrupt_callback)
if (scanline > 256)
scanline = 0;
timer_set(m_screen->time_until_pos(scanline), TIMER_INTERRUPT);
m_interrupt_timer->adjust(m_screen->time_until_pos(scanline));
}
unsigned fgoal_state::video_ram_address( )
unsigned fgoal_state::video_ram_address( )
{
return 0x4000 | (m_row << 5) | (m_col >> 3);
}
READ8_MEMBER(fgoal_state::fgoal_analog_r)
READ8_MEMBER(fgoal_state::analog_r)
{
return ioport(m_fgoal_player ? "PADDLE1" : "PADDLE0")->read(); /* PCB can be jumpered to use a single dial */
return ioport(m_player ? "PADDLE1" : "PADDLE0")->read(); /* PCB can be jumpered to use a single dial */
}
CUSTOM_INPUT_MEMBER(fgoal_state::fgoal_80_r)
CUSTOM_INPUT_MEMBER(fgoal_state::_80_r)
{
UINT8 ret = (m_screen->vpos() & 0x80) ? 1 : 0;
return ret;
}
READ8_MEMBER(fgoal_state::fgoal_nmi_reset_r)
READ8_MEMBER(fgoal_state::nmi_reset_r)
{
m_maincpu->set_input_line(INPUT_LINE_NMI, CLEAR_LINE);
@ -129,7 +129,7 @@ READ8_MEMBER(fgoal_state::fgoal_nmi_reset_r)
}
READ8_MEMBER(fgoal_state::fgoal_irq_reset_r)
READ8_MEMBER(fgoal_state::irq_reset_r)
{
m_maincpu->set_input_line(0, CLEAR_LINE);
@ -137,42 +137,42 @@ READ8_MEMBER(fgoal_state::fgoal_irq_reset_r)
}
READ8_MEMBER(fgoal_state::fgoal_row_r)
READ8_MEMBER(fgoal_state::row_r)
{
return m_row;
}
WRITE8_MEMBER(fgoal_state::fgoal_row_w)
WRITE8_MEMBER(fgoal_state::row_w)
{
m_row = data;
m_mb14241->shift_data_w(space, 0, 0);
}
WRITE8_MEMBER(fgoal_state::fgoal_col_w)
WRITE8_MEMBER(fgoal_state::col_w)
{
m_col = data;
m_mb14241->shift_count_w(space, 0, data);
}
READ8_MEMBER(fgoal_state::fgoal_address_hi_r)
READ8_MEMBER(fgoal_state::address_hi_r)
{
return video_ram_address() >> 8;
}
READ8_MEMBER(fgoal_state::fgoal_address_lo_r)
READ8_MEMBER(fgoal_state::address_lo_r)
{
return video_ram_address() & 0xff;
}
READ8_MEMBER(fgoal_state::fgoal_shifter_r)
READ8_MEMBER(fgoal_state::shifter_r)
{
UINT8 v = m_mb14241->shift_result_r(space, 0);
return BITSWAP8(v, 7, 6, 5, 4, 3, 2, 1, 0);
}
READ8_MEMBER(fgoal_state::fgoal_shifter_reverse_r)
READ8_MEMBER(fgoal_state::shifter_reverse_r)
{
UINT8 v = m_mb14241->shift_result_r(space, 0);
@ -180,7 +180,7 @@ READ8_MEMBER(fgoal_state::fgoal_shifter_reverse_r)
}
WRITE8_MEMBER(fgoal_state::fgoal_sound1_w)
WRITE8_MEMBER(fgoal_state::sound1_w)
{
/* BIT0 => SX2 */
/* BIT1 => SX1 */
@ -193,7 +193,7 @@ WRITE8_MEMBER(fgoal_state::fgoal_sound1_w)
}
WRITE8_MEMBER(fgoal_state::fgoal_sound2_w)
WRITE8_MEMBER(fgoal_state::sound2_w)
{
/* BIT0 => CX0 */
/* BIT1 => SX6 */
@ -201,7 +201,7 @@ WRITE8_MEMBER(fgoal_state::fgoal_sound2_w)
/* BIT3 => SX5 */
/* BIT4 => SX4 */
/* BIT5 => SX3 */
m_fgoal_player = data & 1;
m_player = data & 1;
}
@ -209,31 +209,31 @@ static ADDRESS_MAP_START( cpu_map, AS_PROGRAM, 8, fgoal_state )
AM_RANGE(0x0000, 0x00ef) AM_RAM
AM_RANGE(0x00f0, 0x00f0) AM_READ(fgoal_row_r)
AM_RANGE(0x00f1, 0x00f1) AM_READ(fgoal_analog_r)
AM_RANGE(0x00f0, 0x00f0) AM_READ(row_r)
AM_RANGE(0x00f1, 0x00f1) AM_READ(analog_r)
AM_RANGE(0x00f2, 0x00f2) AM_READ_PORT("IN0")
AM_RANGE(0x00f3, 0x00f3) AM_READ_PORT("IN1")
AM_RANGE(0x00f4, 0x00f4) AM_READ(fgoal_address_hi_r)
AM_RANGE(0x00f5, 0x00f5) AM_READ(fgoal_address_lo_r)
AM_RANGE(0x00f6, 0x00f6) AM_READ(fgoal_shifter_r)
AM_RANGE(0x00f7, 0x00f7) AM_READ(fgoal_shifter_reverse_r)
AM_RANGE(0x00f8, 0x00fb) AM_READ(fgoal_nmi_reset_r)
AM_RANGE(0x00fc, 0x00ff) AM_READ(fgoal_irq_reset_r)
AM_RANGE(0x00f4, 0x00f4) AM_READ(address_hi_r)
AM_RANGE(0x00f5, 0x00f5) AM_READ(address_lo_r)
AM_RANGE(0x00f6, 0x00f6) AM_READ(shifter_r)
AM_RANGE(0x00f7, 0x00f7) AM_READ(shifter_reverse_r)
AM_RANGE(0x00f8, 0x00fb) AM_READ(nmi_reset_r)
AM_RANGE(0x00fc, 0x00ff) AM_READ(irq_reset_r)
AM_RANGE(0x00f0, 0x00f0) AM_WRITE(fgoal_row_w)
AM_RANGE(0x00f1, 0x00f1) AM_WRITE(fgoal_col_w)
AM_RANGE(0x00f2, 0x00f2) AM_WRITE(fgoal_row_w)
AM_RANGE(0x00f3, 0x00f3) AM_WRITE(fgoal_col_w)
AM_RANGE(0x00f0, 0x00f0) AM_WRITE(row_w)
AM_RANGE(0x00f1, 0x00f1) AM_WRITE(col_w)
AM_RANGE(0x00f2, 0x00f2) AM_WRITE(row_w)
AM_RANGE(0x00f3, 0x00f3) AM_WRITE(col_w)
AM_RANGE(0x00f4, 0x00f7) AM_DEVWRITE("mb14241", mb14241_device, shift_data_w)
AM_RANGE(0x00f8, 0x00fb) AM_WRITE(fgoal_sound1_w)
AM_RANGE(0x00fc, 0x00ff) AM_WRITE(fgoal_sound2_w)
AM_RANGE(0x00f8, 0x00fb) AM_WRITE(sound1_w)
AM_RANGE(0x00fc, 0x00ff) AM_WRITE(sound2_w)
AM_RANGE(0x0100, 0x03ff) AM_RAM
AM_RANGE(0x4000, 0x7fff) AM_RAM AM_SHARE("video_ram")
AM_RANGE(0x8000, 0x8000) AM_WRITE(fgoal_ypos_w)
AM_RANGE(0x8001, 0x8001) AM_WRITE(fgoal_xpos_w)
AM_RANGE(0x8002, 0x8002) AM_WRITE(fgoal_color_w)
AM_RANGE(0x8000, 0x8000) AM_WRITE(ypos_w)
AM_RANGE(0x8001, 0x8001) AM_WRITE(xpos_w)
AM_RANGE(0x8002, 0x8002) AM_WRITE(color_w)
AM_RANGE(0xa000, 0xbfff) AM_ROM
AM_RANGE(0xd000, 0xffff) AM_ROM
@ -266,7 +266,7 @@ static INPUT_PORTS_START( fgoal )
/* extra credit score changes depending on player's performance */
PORT_START("IN1")
PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_SPECIAL ) PORT_CUSTOM_MEMBER(DEVICE_SELF, fgoal_state,fgoal_80_r, NULL) /* 128V */
PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_SPECIAL ) PORT_CUSTOM_MEMBER(DEVICE_SELF, fgoal_state, _80_r, NULL) /* 128V */
PORT_DIPNAME( 0x40, 0x00, DEF_STR( Cabinet ))
PORT_DIPSETTING( 0x00, DEF_STR( Upright ))
PORT_DIPSETTING( 0x40, DEF_STR( Cocktail ))
@ -338,10 +338,12 @@ GFXDECODE_END
void fgoal_state::machine_start()
{
m_interrupt_timer = timer_alloc(TIMER_INTERRUPT);
save_item(NAME(m_xpos));
save_item(NAME(m_ypos));
save_item(NAME(m_current_color));
save_item(NAME(m_fgoal_player));
save_item(NAME(m_player));
save_item(NAME(m_row));
save_item(NAME(m_col));
save_item(NAME(m_prev_coin));
@ -349,12 +351,12 @@ void fgoal_state::machine_start()
void fgoal_state::machine_reset()
{
timer_set(m_screen->time_until_pos(0), TIMER_INTERRUPT);
m_interrupt_timer->adjust(m_screen->time_until_pos(0));
m_xpos = 0;
m_ypos = 0;
m_current_color = 0;
m_fgoal_player = 0;
m_player = 0;
m_row = 0;
m_col = 0;
m_prev_coin = 0;
@ -375,7 +377,7 @@ static MACHINE_CONFIG_START( fgoal, fgoal_state )
MCFG_SCREEN_REFRESH_RATE(60)
MCFG_SCREEN_SIZE(256, 263)
MCFG_SCREEN_VISIBLE_AREA(0, 255, 16, 255)
MCFG_SCREEN_UPDATE_DRIVER(fgoal_state, screen_update_fgoal)
MCFG_SCREEN_UPDATE_DRIVER(fgoal_state, screen_update)
MCFG_SCREEN_PALETTE("palette")
MCFG_GFXDECODE_ADD("gfxdecode", "palette", fgoal)
@ -433,5 +435,5 @@ ROM_START( fgoala )
ROM_END
GAME( 1979, fgoal, 0, fgoal, fgoal, driver_device, 0, ROT90, "Taito", "Field Goal (set 1)", GAME_NO_SOUND )
GAME( 1979, fgoala, fgoal, fgoal, fgoal, driver_device, 0, ROT90, "Taito", "Field Goal (set 2)", GAME_NO_SOUND )
GAME( 1979, fgoal, 0, fgoal, fgoal, driver_device, 0, ROT90, "Taito", "Field Goal (set 1)", GAME_NO_SOUND | GAME_SUPPORTS_SAVE )
GAME( 1979, fgoala, fgoal, fgoal, fgoal, driver_device, 0, ROT90, "Taito", "Field Goal (set 2)", GAME_NO_SOUND | GAME_SUPPORTS_SAVE )

View File

@ -10,13 +10,19 @@ public:
fgoal_state(const machine_config &mconfig, device_type type, const char *tag)
: driver_device(mconfig, type, tag),
m_video_ram(*this, "video_ram"),
m_maincpu(*this, "maincpu"),
m_mb14241(*this, "mb14241"),
m_gfxdecode(*this, "gfxdecode"),
m_screen(*this, "screen"),
m_palette(*this, "palette")
{ }
m_palette(*this, "palette"),
m_video_ram(*this, "video_ram") { }
/* devices */
required_device<cpu_device> m_maincpu;
required_device<mb14241_device> m_mb14241;
required_device<gfxdecode_device> m_gfxdecode;
required_device<screen_device> m_screen;
required_device<palette_device> m_palette;
/* memory pointers */
required_shared_ptr<UINT8> m_video_ram;
@ -29,42 +35,40 @@ public:
int m_current_color;
/* misc */
int m_fgoal_player;
int m_player;
UINT8 m_row;
UINT8 m_col;
int m_prev_coin;
emu_timer *m_interrupt_timer;
/* devices */
required_device<cpu_device> m_maincpu;
required_device<mb14241_device> m_mb14241;
required_device<gfxdecode_device> m_gfxdecode;
required_device<screen_device> m_screen;
required_device<palette_device> m_palette;
DECLARE_READ8_MEMBER(analog_r);
DECLARE_READ8_MEMBER(nmi_reset_r);
DECLARE_READ8_MEMBER(irq_reset_r);
DECLARE_READ8_MEMBER(row_r);
DECLARE_WRITE8_MEMBER(row_w);
DECLARE_WRITE8_MEMBER(col_w);
DECLARE_READ8_MEMBER(address_hi_r);
DECLARE_READ8_MEMBER(address_lo_r);
DECLARE_READ8_MEMBER(shifter_r);
DECLARE_READ8_MEMBER(shifter_reverse_r);
DECLARE_WRITE8_MEMBER(sound1_w);
DECLARE_WRITE8_MEMBER(sound2_w);
DECLARE_WRITE8_MEMBER(color_w);
DECLARE_WRITE8_MEMBER(ypos_w);
DECLARE_WRITE8_MEMBER(xpos_w);
DECLARE_CUSTOM_INPUT_MEMBER(_80_r);
TIMER_CALLBACK_MEMBER(interrupt_callback);
DECLARE_READ8_MEMBER(fgoal_analog_r);
DECLARE_READ8_MEMBER(fgoal_nmi_reset_r);
DECLARE_READ8_MEMBER(fgoal_irq_reset_r);
DECLARE_READ8_MEMBER(fgoal_row_r);
DECLARE_WRITE8_MEMBER(fgoal_row_w);
DECLARE_WRITE8_MEMBER(fgoal_col_w);
DECLARE_READ8_MEMBER(fgoal_address_hi_r);
DECLARE_READ8_MEMBER(fgoal_address_lo_r);
DECLARE_READ8_MEMBER(fgoal_shifter_r);
DECLARE_READ8_MEMBER(fgoal_shifter_reverse_r);
DECLARE_WRITE8_MEMBER(fgoal_sound1_w);
DECLARE_WRITE8_MEMBER(fgoal_sound2_w);
DECLARE_WRITE8_MEMBER(fgoal_color_w);
DECLARE_WRITE8_MEMBER(fgoal_ypos_w);
DECLARE_WRITE8_MEMBER(fgoal_xpos_w);
DECLARE_CUSTOM_INPUT_MEMBER(fgoal_80_r);
virtual void machine_start();
virtual void machine_reset();
virtual void video_start();
DECLARE_PALETTE_INIT(fgoal);
UINT32 screen_update_fgoal(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
TIMER_CALLBACK_MEMBER(interrupt_callback);
UINT32 screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
int intensity(int bits);
unsigned video_ram_address( );
unsigned video_ram_address( );
protected:
virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr);

View File

@ -8,19 +8,19 @@
#include "includes/fgoal.h"
WRITE8_MEMBER(fgoal_state::fgoal_color_w)
WRITE8_MEMBER(fgoal_state::color_w)
{
m_current_color = data & 3;
}
WRITE8_MEMBER(fgoal_state::fgoal_ypos_w)
WRITE8_MEMBER(fgoal_state::ypos_w)
{
m_ypos = data;
}
WRITE8_MEMBER(fgoal_state::fgoal_xpos_w)
WRITE8_MEMBER(fgoal_state::xpos_w)
{
m_xpos = data;
}
@ -36,7 +36,7 @@ void fgoal_state::video_start()
}
UINT32 fgoal_state::screen_update_fgoal(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
UINT32 fgoal_state::screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
{
const UINT8* VRAM = m_video_ram;
@ -46,10 +46,10 @@ UINT32 fgoal_state::screen_update_fgoal(screen_device &screen, bitmap_ind16 &bit
/* draw color overlay foreground and background */
if (m_fgoal_player == 1 && (ioport("IN1")->read() & 0x40))
if (m_player == 1 && (ioport("IN1")->read() & 0x40))
{
m_gfxdecode->gfx(0)->zoom_opaque(m_fgbitmap,cliprect,
0, (m_fgoal_player << 2) | m_current_color,
0, (m_player << 2) | m_current_color,
1, 1,
0, 16,
0x40000,
@ -65,7 +65,7 @@ UINT32 fgoal_state::screen_update_fgoal(screen_device &screen, bitmap_ind16 &bit
else
{
m_gfxdecode->gfx(0)->zoom_opaque(m_fgbitmap,cliprect,
0, (m_fgoal_player << 2) | m_current_color,
0, (m_player << 2) | m_current_color,
0, 0,
0, 0,
0x40000,