diff options
author | Aaron Giles <aaron@aarongiles.com> | 2011-03-03 17:22:05 +0000 |
---|---|---|
committer | Aaron Giles <aaron@aarongiles.com> | 2011-03-03 17:22:05 +0000 |
commit | 92d1d14efc889ee37f3aa7ed7991b6a93d8413a8 (patch) | |
tree | 07731d4f981ece547c28d21b32739f3d840cb3ed /src/mame/drivers/r2dtank.c | |
parent | 74deaf0a952e228f761a6320d30f5187e2103777 (diff) |
Updated sigma/stern/subsino/tatsumi/tch/tecfri/technos/tehkan to driver_devices.
[Atari Ace]
Diffstat (limited to 'src/mame/drivers/r2dtank.c')
-rw-r--r-- | src/mame/drivers/r2dtank.c | 77 |
1 files changed, 46 insertions, 31 deletions
diff --git a/src/mame/drivers/r2dtank.c b/src/mame/drivers/r2dtank.c index e4ef65a6d6e..7caff58bb96 100644 --- a/src/mame/drivers/r2dtank.c +++ b/src/mame/drivers/r2dtank.c @@ -41,18 +41,27 @@ RAM = 4116 (x11) #include "machine/nvram.h" +#define NUM_PENS (8) + #define LOG_AUDIO_COMM (0) #define MAIN_CPU_MASTER_CLOCK (11200000) #define PIXEL_CLOCK (MAIN_CPU_MASTER_CLOCK / 2) #define CRTC_CLOCK (MAIN_CPU_MASTER_CLOCK / 16) - -static UINT8 *r2dtank_videoram; -static UINT8 *r2dtank_colorram; -static UINT8 flipscreen; -static UINT32 ttl74123_output; -static UINT8 AY8910_selected; +class r2dtank_state : public driver_device +{ +public: + r2dtank_state(running_machine &machine, const driver_device_config_base &config) + : driver_device(machine, config) { } + + UINT8 *videoram; + UINT8 *colorram; + UINT8 flipscreen; + UINT32 ttl74123_output; + UINT8 AY8910_selected; + pen_t pens[NUM_PENS]; +}; @@ -133,6 +142,7 @@ if (LOG_AUDIO_COMM) logerror("%08X CPU#1 Audio Answer Write: %x\n", cpu_get_pc static WRITE8_DEVICE_HANDLER( AY8910_select_w ) { + r2dtank_state *state = device->machine->driver_data<r2dtank_state>(); /* not sure what all the bits mean: D0 - ????? definetely used D1 - not used? @@ -140,7 +150,7 @@ static WRITE8_DEVICE_HANDLER( AY8910_select_w ) D3 - selects ay8910 #0 D4 - selects ay8910 #1 D5-D7 - not used */ - AY8910_selected = data; + state->AY8910_selected = data; if (LOG_AUDIO_COMM) logerror("%s: CPU#1 AY8910_select_w: %x\n", device->machine->describe_context(), data); } @@ -148,12 +158,13 @@ if (LOG_AUDIO_COMM) logerror("%s: CPU#1 AY8910_select_w: %x\n", device->machin static READ8_DEVICE_HANDLER( AY8910_port_r ) { + r2dtank_state *state = device->machine->driver_data<r2dtank_state>(); UINT8 ret = 0; - if (AY8910_selected & 0x08) + if (state->AY8910_selected & 0x08) ret = ay8910_r(device->machine->device("ay1"), 0); - if (AY8910_selected & 0x10) + if (state->AY8910_selected & 0x10) ret = ay8910_r(device->machine->device("ay2"), 0); return ret; @@ -162,11 +173,12 @@ static READ8_DEVICE_HANDLER( AY8910_port_r ) static WRITE8_DEVICE_HANDLER( AY8910_port_w ) { - if (AY8910_selected & 0x08) - ay8910_data_address_w(device->machine->device("ay1"), AY8910_selected >> 2, data); + r2dtank_state *state = device->machine->driver_data<r2dtank_state>(); + if (state->AY8910_selected & 0x08) + ay8910_data_address_w(device->machine->device("ay1"), state->AY8910_selected >> 2, data); - if (AY8910_selected & 0x10) - ay8910_data_address_w(device->machine->device("ay2"), AY8910_selected >> 2, data); + if (state->AY8910_selected & 0x10) + ay8910_data_address_w(device->machine->device("ay2"), state->AY8910_selected >> 2, data); } @@ -207,15 +219,17 @@ static const ay8910_interface ay8910_2_interface = static WRITE8_DEVICE_HANDLER( ttl74123_output_changed ) { + r2dtank_state *state = device->machine->driver_data<r2dtank_state>(); device_t *pia = device->machine->device("pia_main"); pia6821_ca1_w(pia, data); - ttl74123_output = data; + state->ttl74123_output = data; } static CUSTOM_INPUT( get_ttl74123_output ) { - return ttl74123_output; + r2dtank_state *state = field->port->machine->driver_data<r2dtank_state>(); + return state->ttl74123_output; } @@ -274,10 +288,11 @@ static const pia6821_interface pia_audio_intf = static MACHINE_START( r2dtank ) { + r2dtank_state *state = machine->driver_data<r2dtank_state>(); /* setup for save states */ - state_save_register_global(machine, flipscreen); - state_save_register_global(machine, ttl74123_output); - state_save_register_global(machine, AY8910_selected); + state_save_register_global(machine, state->flipscreen); + state_save_register_global(machine, state->ttl74123_output); + state_save_register_global(machine, state->AY8910_selected); } @@ -288,32 +303,32 @@ static MACHINE_START( r2dtank ) * *************************************/ -#define NUM_PENS (8) - static WRITE_LINE_DEVICE_HANDLER( flipscreen_w ) { - flipscreen = !state; + r2dtank_state *drvstate = device->machine->driver_data<r2dtank_state>(); + drvstate->flipscreen = !state; } static MC6845_BEGIN_UPDATE( begin_update ) { + r2dtank_state *state = device->machine->driver_data<r2dtank_state>(); /* create the pens */ offs_t i; - static pen_t pens[NUM_PENS]; for (i = 0; i < NUM_PENS; i++) { - pens[i] = MAKE_RGB(pal1bit(i >> 2), pal1bit(i >> 1), pal1bit(i >> 0)); + state->pens[i] = MAKE_RGB(pal1bit(i >> 2), pal1bit(i >> 1), pal1bit(i >> 0)); } - return pens; + return state->pens; } static MC6845_UPDATE_ROW( update_row ) { + r2dtank_state *state = device->machine->driver_data<r2dtank_state>(); UINT8 cx; pen_t *pens = (pen_t *)param; @@ -329,17 +344,17 @@ static MC6845_UPDATE_ROW( update_row ) ((ra << 5) & 0x00e0) | ((ma << 0) & 0x001f); - if (flipscreen) + if (state->flipscreen) offs = offs ^ 0x1fff; - data = r2dtank_videoram[offs]; - fore_color = (r2dtank_colorram[offs] >> 5) & 0x07; + data = state->videoram[offs]; + fore_color = (state->colorram[offs] >> 5) & 0x07; for (i = 0; i < 8; i++) { UINT8 bit, color; - if (flipscreen) + if (state->flipscreen) { bit = data & 0x01; data = data >> 1; @@ -405,9 +420,9 @@ static WRITE8_DEVICE_HANDLER( pia_comp_w ) static ADDRESS_MAP_START( r2dtank_main_map, ADDRESS_SPACE_PROGRAM, 8 ) - AM_RANGE(0x0000, 0x1fff) AM_RAM AM_BASE(&r2dtank_videoram) + AM_RANGE(0x0000, 0x1fff) AM_RAM AM_BASE_MEMBER(r2dtank_state, videoram) AM_RANGE(0x2000, 0x3fff) AM_RAM - AM_RANGE(0x4000, 0x5fff) AM_RAM AM_BASE(&r2dtank_colorram) + AM_RANGE(0x4000, 0x5fff) AM_RAM AM_BASE_MEMBER(r2dtank_state, colorram) AM_RANGE(0x6000, 0x7fff) AM_RAM AM_RANGE(0x8000, 0x8003) AM_DEVREADWRITE("pia_main", pia6821_r, pia_comp_w) AM_RANGE(0x8004, 0x8004) AM_READWRITE(audio_answer_r, audio_command_w) @@ -516,7 +531,7 @@ INPUT_PORTS_END * *************************************/ -static MACHINE_CONFIG_START( r2dtank, driver_device ) +static MACHINE_CONFIG_START( r2dtank, r2dtank_state ) MCFG_CPU_ADD("maincpu", M6809,3000000) /* ?? too fast ? */ MCFG_CPU_PROGRAM_MAP(r2dtank_main_map) |