Added driver data struct to crgolf.c and clayshoo.c

This commit is contained in:
Fabio Priuli 2009-11-22 23:57:31 +00:00
parent 81c34417d0
commit 8c0bcf5093
4 changed files with 174 additions and 126 deletions

View File

@ -17,15 +17,18 @@
#include "machine/8255ppi.h" #include "machine/8255ppi.h"
typedef struct _clayshoo_state clayshoo_state;
struct _clayshoo_state
{
/* memory pointers */
UINT8 * videoram;
size_t videoram_size;
static UINT8 *clayshoo_videoram; /* misc */
static size_t clayshoo_videoram_size; emu_timer *analog_timer_1, *analog_timer_2;
UINT8 input_port_select;
static UINT8 input_port_select; UINT8 analog_port_val;
static UINT8 analog_port_val; };
static emu_timer *analog_timer_1;
static emu_timer *analog_timer_2;
/************************************* /*************************************
@ -36,11 +39,12 @@ static emu_timer *analog_timer_2;
static WRITE8_DEVICE_HANDLER( input_port_select_w ) static WRITE8_DEVICE_HANDLER( input_port_select_w )
{ {
input_port_select = data; clayshoo_state *state = (clayshoo_state *)device->machine->driver_data;
state->input_port_select = data;
} }
static UINT8 difficulty_input_port_r(running_machine *machine, int bit) static UINT8 difficulty_input_port_r( running_machine *machine, int bit )
{ {
UINT8 ret = 0; UINT8 ret = 0;
@ -60,21 +64,20 @@ static UINT8 difficulty_input_port_r(running_machine *machine, int bit)
static READ8_DEVICE_HANDLER( input_port_r ) static READ8_DEVICE_HANDLER( input_port_r )
{ {
clayshoo_state *state = (clayshoo_state *)device->machine->driver_data;
UINT8 ret = 0; UINT8 ret = 0;
switch (input_port_select) switch (state->input_port_select)
{ {
case 0x01: ret = input_port_read(device->machine, "IN0"); break; case 0x01: ret = input_port_read(device->machine, "IN0"); break;
case 0x02: ret = input_port_read(device->machine, "IN1"); break; case 0x02: ret = input_port_read(device->machine, "IN1"); break;
case 0x04: ret = (input_port_read(device->machine, "IN2") & 0xf0) | case 0x04: ret = (input_port_read(device->machine, "IN2") & 0xf0) | difficulty_input_port_r(device->machine, 0) |
difficulty_input_port_r(device->machine, 0) |
(difficulty_input_port_r(device->machine, 3) << 2); break; (difficulty_input_port_r(device->machine, 3) << 2); break;
case 0x08: ret = input_port_read(device->machine, "IN3"); break; case 0x08: ret = input_port_read(device->machine, "IN3"); break;
case 0x10: case 0x10:
case 0x20: break; /* these two are not really used */ case 0x20: break; /* these two are not really used */
default: logerror("Unexpected port read: %02X\n", input_port_select); default: logerror("Unexpected port read: %02X\n", state->input_port_select);
} }
return ret; return ret;
} }
@ -88,11 +91,12 @@ static READ8_DEVICE_HANDLER( input_port_r )
static TIMER_CALLBACK( reset_analog_bit ) static TIMER_CALLBACK( reset_analog_bit )
{ {
analog_port_val &= ~param; clayshoo_state *state = (clayshoo_state *)machine->driver_data;
state->analog_port_val &= ~param;
} }
static attotime compute_duration(const device_config *device, int analog_pos) static attotime compute_duration( const device_config *device, int analog_pos )
{ {
/* the 58 comes from the length of the loop used to /* the 58 comes from the length of the loop used to
read the analog position */ read the analog position */
@ -102,27 +106,31 @@ static attotime compute_duration(const device_config *device, int analog_pos)
static WRITE8_HANDLER( analog_reset_w ) static WRITE8_HANDLER( analog_reset_w )
{ {
clayshoo_state *state = (clayshoo_state *)space->machine->driver_data;
/* reset the analog value, and start the two times that will fire /* reset the analog value, and start the two times that will fire
off in a short period proportional to the position of the off in a short period proportional to the position of the
analog control and set the appropriate bit. */ analog control and set the appropriate bit. */
analog_port_val = 0xff; state->analog_port_val = 0xff;
timer_adjust_oneshot(analog_timer_1, compute_duration(space->cpu, input_port_read(space->machine, "AN1")), 0x02); timer_adjust_oneshot(state->analog_timer_1, compute_duration(space->cpu, input_port_read(space->machine, "AN1")), 0x02);
timer_adjust_oneshot(analog_timer_2, compute_duration(space->cpu, input_port_read(space->machine, "AN2")), 0x01); timer_adjust_oneshot(state->analog_timer_2, compute_duration(space->cpu, input_port_read(space->machine, "AN2")), 0x01);
} }
static READ8_HANDLER( analog_r ) static READ8_HANDLER( analog_r )
{ {
return analog_port_val; clayshoo_state *state = (clayshoo_state *)space->machine->driver_data;
return state->analog_port_val;
} }
static void create_analog_timers(running_machine *machine) static void create_analog_timers( running_machine *machine )
{ {
analog_timer_1 = timer_alloc(machine, reset_analog_bit, NULL); clayshoo_state *state = (clayshoo_state *)machine->driver_data;
analog_timer_2 = timer_alloc(machine, reset_analog_bit, NULL); state->analog_timer_1 = timer_alloc(machine, reset_analog_bit, NULL);
state->analog_timer_2 = timer_alloc(machine, reset_analog_bit, NULL);
} }
@ -156,11 +164,12 @@ static const ppi8255_interface ppi8255_intf[2] =
static MACHINE_START( clayshoo ) static MACHINE_START( clayshoo )
{ {
clayshoo_state *state = (clayshoo_state *)machine->driver_data;
create_analog_timers(machine); create_analog_timers(machine);
/* register for state saving */ /* register for state saving */
state_save_register_global(machine, input_port_select); state_save_register_global(machine, state->input_port_select);
state_save_register_global(machine, analog_port_val); state_save_register_global(machine, state->analog_port_val);
} }
@ -173,15 +182,15 @@ static MACHINE_START( clayshoo )
static VIDEO_UPDATE( clayshoo ) static VIDEO_UPDATE( clayshoo )
{ {
clayshoo_state *state = (clayshoo_state *)screen->machine->driver_data;
offs_t offs; offs_t offs;
for (offs = 0; offs < clayshoo_videoram_size; offs++) for (offs = 0; offs < state->videoram_size; offs++)
{ {
int i; int i;
UINT8 x = offs << 3; UINT8 x = offs << 3;
UINT8 y = ~(offs >> 5); UINT8 y = ~(offs >> 5);
UINT8 data = clayshoo_videoram[offs]; UINT8 data = state->videoram[offs];
for (i = 0; i < 8; i++) for (i = 0; i < 8; i++)
{ {
@ -208,7 +217,7 @@ static ADDRESS_MAP_START( main_map, ADDRESS_SPACE_PROGRAM, 8 )
AM_RANGE(0x0000, 0x1fff) AM_ROM AM_RANGE(0x0000, 0x1fff) AM_ROM
AM_RANGE(0x2000, 0x23ff) AM_RAM AM_RANGE(0x2000, 0x23ff) AM_RAM
AM_RANGE(0x4000, 0x47ff) AM_ROM AM_RANGE(0x4000, 0x47ff) AM_ROM
AM_RANGE(0x8000, 0x97ff) AM_RAM AM_BASE(&clayshoo_videoram) AM_SIZE(&clayshoo_videoram_size) /* 6k of video ram according to readme */ AM_RANGE(0x8000, 0x97ff) AM_RAM AM_BASE_MEMBER(clayshoo_state, videoram) AM_SIZE_MEMBER(clayshoo_state, videoram_size) /* 6k of video ram according to readme */
AM_RANGE(0x9800, 0xa800) AM_WRITENOP /* not really mapped, but cleared */ AM_RANGE(0x9800, 0xa800) AM_WRITENOP /* not really mapped, but cleared */
AM_RANGE(0xc800, 0xc800) AM_READWRITE(analog_r, analog_reset_w) AM_RANGE(0xc800, 0xc800) AM_READWRITE(analog_r, analog_reset_w)
ADDRESS_MAP_END ADDRESS_MAP_END
@ -301,8 +310,19 @@ INPUT_PORTS_END
* *
*************************************/ *************************************/
static MACHINE_RESET( clayshoo )
{
clayshoo_state *state = (clayshoo_state *)machine->driver_data;
state->input_port_select = 0;
state->analog_port_val = 0;
}
static MACHINE_DRIVER_START( clayshoo ) static MACHINE_DRIVER_START( clayshoo )
/* driver data */
MDRV_DRIVER_DATA(clayshoo_state)
/* basic machine hardware */ /* basic machine hardware */
MDRV_CPU_ADD("maincpu", Z80,5068000/4) /* 5.068/4 Mhz (divider is a guess) */ MDRV_CPU_ADD("maincpu", Z80,5068000/4) /* 5.068/4 Mhz (divider is a guess) */
MDRV_CPU_PROGRAM_MAP(main_map) MDRV_CPU_PROGRAM_MAP(main_map)
@ -310,6 +330,7 @@ static MACHINE_DRIVER_START( clayshoo )
MDRV_CPU_VBLANK_INT("screen", irq0_line_hold) MDRV_CPU_VBLANK_INT("screen", irq0_line_hold)
MDRV_MACHINE_START(clayshoo) MDRV_MACHINE_START(clayshoo)
MDRV_MACHINE_RESET(clayshoo)
/* video hardware */ /* video hardware */
MDRV_VIDEO_UPDATE(clayshoo) MDRV_VIDEO_UPDATE(clayshoo)
@ -350,4 +371,4 @@ ROM_END
* *
*************************************/ *************************************/
GAME( 1979, clayshoo, 0, clayshoo, clayshoo, 0, ROT0, "Allied Leisure", "Clay Shoot", GAME_NO_SOUND | GAME_SUPPORTS_SAVE) GAME( 1979, clayshoo, 0, clayshoo, clayshoo, 0, ROT0, "Allied Leisure", "Clay Shoot", GAME_NO_SOUND | GAME_SUPPORTS_SAVE )

View File

@ -11,17 +11,17 @@
Known bugs: Known bugs:
* not sure if the analog inputs are handled correctly * not sure if the analog inputs are handled correctly
Text Strings in sound CPU ROM read: Text Strings in sound CPU ROM read:
ARIES ELECA ARIES ELECA
1984JAN15 V-0 1984JAN15 V-0
Text Strings in the bootleg sound CPU ROM read: Text Strings in the bootleg sound CPU ROM read:
WHO AM I? (In place of "ARIES ELECA") WHO AM I? (In place of "ARIES ELECA")
1984JULY1 V-1 (In place of "1984JAN15 V-0") 1984JULY1 V-1 (In place of "1984JAN15 V-0")
1984 COPYRIGHT BY WHO 1984 COPYRIGHT BY WHO
2008-08 2008-08
Dip locations and factory settings verified with manual Dip locations and factory settings verified with manual
**************************************************************************** ****************************************************************************
@ -36,18 +36,6 @@ Dip locations and factory settings verified with manual
#include "sound/msm5205.h" #include "sound/msm5205.h"
/* constants */
#define MASTER_CLOCK 18432000
/* local variables */
static UINT8 port_select;
static UINT8 main_to_sound_data, sound_to_main_data;
static UINT16 sample_offset;
static UINT8 sample_count;
/************************************* /*************************************
* *
* ROM banking * ROM banking
@ -62,19 +50,32 @@ static WRITE8_HANDLER( rom_bank_select_w )
static MACHINE_START( crgolf ) static MACHINE_START( crgolf )
{ {
crgolf_state *state = (crgolf_state *)machine->driver_data;
/* configure the banking */ /* configure the banking */
memory_configure_bank(machine, 1, 0, 16, memory_region(machine, "maincpu") + 0x10000, 0x2000); memory_configure_bank(machine, 1, 0, 16, memory_region(machine, "maincpu") + 0x10000, 0x2000);
memory_set_bank(machine, 1, 0); memory_set_bank(machine, 1, 0);
/* register for save states */ /* register for save states */
state_save_register_global(machine, port_select); state_save_register_global(machine, state->port_select);
state_save_register_global(machine, main_to_sound_data); state_save_register_global(machine, state->main_to_sound_data);
state_save_register_global(machine, sound_to_main_data); state_save_register_global(machine, state->sound_to_main_data);
state_save_register_global(machine, sample_offset); state_save_register_global(machine, state->sample_offset);
state_save_register_global(machine, sample_count); state_save_register_global(machine, state->sample_count);
} }
static MACHINE_RESET( crgolf )
{
crgolf_state *state = (crgolf_state *)machine->driver_data;
state->port_select = 0;
state->main_to_sound_data = 0;
state->sound_to_main_data = 0;
state->sample_offset = 0;
state->sample_count = 0;
}
/************************************* /*************************************
* *
@ -85,8 +86,9 @@ static MACHINE_START( crgolf )
static READ8_HANDLER( switch_input_r ) static READ8_HANDLER( switch_input_r )
{ {
static const char *const portnames[] = { "IN0", "IN1", "P1", "P2", "DSW", "UNUSED0", "UNUSED1" }; static const char *const portnames[] = { "IN0", "IN1", "P1", "P2", "DSW", "UNUSED0", "UNUSED1" };
crgolf_state *state = (crgolf_state *)space->machine->driver_data;
return input_port_read(space->machine, portnames[port_select]); return input_port_read(space->machine, portnames[state->port_select]);
} }
@ -98,13 +100,15 @@ static READ8_HANDLER( analog_input_r )
static WRITE8_HANDLER( switch_input_select_w ) static WRITE8_HANDLER( switch_input_select_w )
{ {
if (!(data & 0x40)) port_select = 6; crgolf_state *state = (crgolf_state *)space->machine->driver_data;
if (!(data & 0x20)) port_select = 5;
if (!(data & 0x10)) port_select = 4; if (!(data & 0x40)) state->port_select = 6;
if (!(data & 0x08)) port_select = 3; if (!(data & 0x20)) state->port_select = 5;
if (!(data & 0x04)) port_select = 2; if (!(data & 0x10)) state->port_select = 4;
if (!(data & 0x02)) port_select = 1; if (!(data & 0x08)) state->port_select = 3;
if (!(data & 0x01)) port_select = 0; if (!(data & 0x04)) state->port_select = 2;
if (!(data & 0x02)) state->port_select = 1;
if (!(data & 0x01)) state->port_select = 0;
} }
@ -123,8 +127,10 @@ static WRITE8_HANDLER( unknown_w )
static TIMER_CALLBACK( main_to_sound_callback ) static TIMER_CALLBACK( main_to_sound_callback )
{ {
crgolf_state *state = (crgolf_state *)machine->driver_data;
cputag_set_input_line(machine, "audiocpu", INPUT_LINE_NMI, ASSERT_LINE); cputag_set_input_line(machine, "audiocpu", INPUT_LINE_NMI, ASSERT_LINE);
main_to_sound_data = param; state->main_to_sound_data = param;
} }
@ -136,8 +142,10 @@ static WRITE8_HANDLER( main_to_sound_w )
static READ8_HANDLER( main_to_sound_r ) static READ8_HANDLER( main_to_sound_r )
{ {
crgolf_state *state = (crgolf_state *)space->machine->driver_data;
cputag_set_input_line(space->machine, "audiocpu", INPUT_LINE_NMI, CLEAR_LINE); cputag_set_input_line(space->machine, "audiocpu", INPUT_LINE_NMI, CLEAR_LINE);
return main_to_sound_data; return state->main_to_sound_data;
} }
@ -150,8 +158,10 @@ static READ8_HANDLER( main_to_sound_r )
static TIMER_CALLBACK( sound_to_main_callback ) static TIMER_CALLBACK( sound_to_main_callback )
{ {
crgolf_state *state = (crgolf_state *)machine->driver_data;
cputag_set_input_line(machine, "maincpu", INPUT_LINE_NMI, ASSERT_LINE); cputag_set_input_line(machine, "maincpu", INPUT_LINE_NMI, ASSERT_LINE);
sound_to_main_data = param; state->sound_to_main_data = param;
} }
@ -163,8 +173,10 @@ static WRITE8_HANDLER( sound_to_main_w )
static READ8_HANDLER( sound_to_main_r ) static READ8_HANDLER( sound_to_main_r )
{ {
crgolf_state *state = (crgolf_state *)space->machine->driver_data;
cputag_set_input_line(space->machine, "maincpu", INPUT_LINE_NMI, CLEAR_LINE); cputag_set_input_line(space->machine, "maincpu", INPUT_LINE_NMI, CLEAR_LINE);
return sound_to_main_data; return state->sound_to_main_data;
} }
@ -175,24 +187,26 @@ static READ8_HANDLER( sound_to_main_r )
* *
*************************************/ *************************************/
static void vck_callback(const device_config *device) static void vck_callback( const device_config *device )
{ {
crgolf_state *state = (crgolf_state *)device->machine->driver_data;
/* only play back if we have data remaining */ /* only play back if we have data remaining */
if (sample_count != 0xff) if (state->sample_count != 0xff)
{ {
UINT8 data = memory_region(device->machine, "adpcm")[sample_offset >> 1]; UINT8 data = memory_region(device->machine, "adpcm")[state->sample_offset >> 1];
/* write the next nibble and advance */ /* write the next nibble and advance */
msm5205_data_w(device, (data >> (4 * (~sample_offset & 1))) & 0x0f); msm5205_data_w(device, (data >> (4 * (~state->sample_offset & 1))) & 0x0f);
sample_offset++; state->sample_offset++;
/* every 256 clocks, we decrement the length */ /* every 256 clocks, we decrement the length */
if (!(sample_offset & 0xff)) if (!(state->sample_offset & 0xff))
{ {
sample_count--; state->sample_count--;
/* if we hit 0xff, automatically turn off playback */ /* if we hit 0xff, automatically turn off playback */
if (sample_count == 0xff) if (state->sample_count == 0xff)
msm5205_reset_w(device, 1); msm5205_reset_w(device, 1);
} }
} }
@ -201,6 +215,8 @@ static void vck_callback(const device_config *device)
static WRITE8_DEVICE_HANDLER( crgolfhi_sample_w ) static WRITE8_DEVICE_HANDLER( crgolfhi_sample_w )
{ {
crgolf_state *state = (crgolf_state *)device->machine->driver_data;
switch (offset) switch (offset)
{ {
/* offset 0 holds the MSM5205 in reset */ /* offset 0 holds the MSM5205 in reset */
@ -210,12 +226,12 @@ static WRITE8_DEVICE_HANDLER( crgolfhi_sample_w )
/* offset 1 is the length/256 nibbles */ /* offset 1 is the length/256 nibbles */
case 1: case 1:
sample_count = data; state->sample_count = data;
break; break;
/* offset 2 is the offset/256 nibbles */ /* offset 2 is the offset/256 nibbles */
case 2: case 2:
sample_offset = data << 8; state->sample_offset = data << 8;
break; break;
/* offset 3 turns on playback */ /* offset 3 turns on playback */
@ -237,11 +253,11 @@ static ADDRESS_MAP_START( main_map, ADDRESS_SPACE_PROGRAM, 8 )
AM_RANGE(0x0000, 0x3fff) AM_ROM AM_RANGE(0x0000, 0x3fff) AM_ROM
AM_RANGE(0x4000, 0x5fff) AM_RAM AM_RANGE(0x4000, 0x5fff) AM_RAM
AM_RANGE(0x6000, 0x7fff) AM_ROMBANK(1) AM_RANGE(0x6000, 0x7fff) AM_ROMBANK(1)
AM_RANGE(0x8003, 0x8003) AM_WRITEONLY AM_BASE(&crgolf_color_select) AM_RANGE(0x8003, 0x8003) AM_WRITEONLY AM_BASE_MEMBER(crgolf_state, color_select)
AM_RANGE(0x8004, 0x8004) AM_WRITEONLY AM_BASE(&crgolf_screen_flip) AM_RANGE(0x8004, 0x8004) AM_WRITEONLY AM_BASE_MEMBER(crgolf_state, screen_flip)
AM_RANGE(0x8005, 0x8005) AM_WRITEONLY AM_BASE(&crgolf_screen_select) AM_RANGE(0x8005, 0x8005) AM_WRITEONLY AM_BASE_MEMBER(crgolf_state, screen_select)
AM_RANGE(0x8006, 0x8006) AM_WRITEONLY AM_BASE(&crgolf_screenb_enable) AM_RANGE(0x8006, 0x8006) AM_WRITEONLY AM_BASE_MEMBER(crgolf_state, screenb_enable)
AM_RANGE(0x8007, 0x8007) AM_WRITEONLY AM_BASE(&crgolf_screena_enable) AM_RANGE(0x8007, 0x8007) AM_WRITEONLY AM_BASE_MEMBER(crgolf_state, screena_enable)
AM_RANGE(0x8800, 0x8800) AM_READWRITE(sound_to_main_r, main_to_sound_w) AM_RANGE(0x8800, 0x8800) AM_READWRITE(sound_to_main_r, main_to_sound_w)
AM_RANGE(0x9000, 0x9000) AM_WRITE(rom_bank_select_w) AM_RANGE(0x9000, 0x9000) AM_WRITE(rom_bank_select_w)
AM_RANGE(0xa000, 0xffff) AM_READWRITE(crgolf_videoram_r, crgolf_videoram_w) AM_RANGE(0xa000, 0xffff) AM_READWRITE(crgolf_videoram_r, crgolf_videoram_w)
@ -365,6 +381,9 @@ static const msm5205_interface msm5205_intf =
static MACHINE_DRIVER_START( crgolf ) static MACHINE_DRIVER_START( crgolf )
/* driver data */
MDRV_DRIVER_DATA(crgolf_state)
/* basic machine hardware */ /* basic machine hardware */
MDRV_CPU_ADD("maincpu", Z80,MASTER_CLOCK/3/2) MDRV_CPU_ADD("maincpu", Z80,MASTER_CLOCK/3/2)
MDRV_CPU_PROGRAM_MAP(main_map) MDRV_CPU_PROGRAM_MAP(main_map)
@ -375,6 +394,7 @@ static MACHINE_DRIVER_START( crgolf )
MDRV_CPU_VBLANK_INT("screen", irq0_line_hold) MDRV_CPU_VBLANK_INT("screen", irq0_line_hold)
MDRV_MACHINE_START(crgolf) MDRV_MACHINE_START(crgolf)
MDRV_MACHINE_RESET(crgolf)
MDRV_QUANTUM_TIME(HZ(6000)) MDRV_QUANTUM_TIME(HZ(6000))
/* video hardware */ /* video hardware */

View File

@ -4,13 +4,29 @@
**************************************************************************/ **************************************************************************/
/*----------- defined in video/crgolf.c -----------*/ #define MASTER_CLOCK 18432000
extern UINT8 *crgolf_color_select;
extern UINT8 *crgolf_screen_flip; typedef struct _crgolf_state crgolf_state;
extern UINT8 *crgolf_screen_select; struct _crgolf_state
extern UINT8 *crgolf_screenb_enable; {
extern UINT8 *crgolf_screena_enable; /* memory pointers */
UINT8 * videoram_a;
UINT8 * videoram_b;
UINT8 * color_select;
UINT8 * screen_flip;
UINT8 * screen_select;
UINT8 * screena_enable;
UINT8 * screenb_enable;
/* misc */
UINT8 port_select;
UINT8 main_to_sound_data, sound_to_main_data;
UINT16 sample_offset;
UINT8 sample_count;
};
/*----------- defined in video/crgolf.c -----------*/
WRITE8_HANDLER( crgolf_videoram_w ); WRITE8_HANDLER( crgolf_videoram_w );
READ8_HANDLER( crgolf_videoram_r ); READ8_HANDLER( crgolf_videoram_r );

View File

@ -12,20 +12,6 @@
#define VIDEORAM_SIZE (0x2000 * 3) #define VIDEORAM_SIZE (0x2000 * 3)
/* globals */
UINT8 *crgolf_color_select;
UINT8 *crgolf_screen_flip;
UINT8 *crgolf_screen_select;
UINT8 *crgolf_screenb_enable;
UINT8 *crgolf_screena_enable;
/* local variables */
static UINT8 *crgolf_videoram_a;
static UINT8 *crgolf_videoram_b;
/************************************* /*************************************
* *
* Video RAM access * Video RAM access
@ -34,21 +20,24 @@ static UINT8 *crgolf_videoram_b;
WRITE8_HANDLER( crgolf_videoram_w ) WRITE8_HANDLER( crgolf_videoram_w )
{ {
if (*crgolf_screen_select & 1) crgolf_state *state = (crgolf_state *)space->machine->driver_data;
crgolf_videoram_b[offset] = data;
if (*state->screen_select & 1)
state->videoram_b[offset] = data;
else else
crgolf_videoram_a[offset] = data; state->videoram_a[offset] = data;
} }
READ8_HANDLER( crgolf_videoram_r ) READ8_HANDLER( crgolf_videoram_r )
{ {
crgolf_state *state = (crgolf_state *)space->machine->driver_data;
UINT8 ret; UINT8 ret;
if (*crgolf_screen_select & 1) if (*state->screen_select & 1)
ret = crgolf_videoram_b[offset]; ret = state->videoram_b[offset];
else else
ret = crgolf_videoram_a[offset]; ret = state->videoram_a[offset];
return ret; return ret;
} }
@ -61,7 +50,7 @@ READ8_HANDLER( crgolf_videoram_r )
* *
*************************************/ *************************************/
static void get_pens(running_machine *machine, pen_t *pens) static void get_pens( running_machine *machine, pen_t *pens )
{ {
offs_t offs; offs_t offs;
const UINT8 *prom = memory_region(machine, "proms"); const UINT8 *prom = memory_region(machine, "proms");
@ -103,13 +92,15 @@ static void get_pens(running_machine *machine, pen_t *pens)
static VIDEO_START( crgolf ) static VIDEO_START( crgolf )
{ {
crgolf_state *state = (crgolf_state *)machine->driver_data;
/* allocate memory for the two bitmaps */ /* allocate memory for the two bitmaps */
crgolf_videoram_a = auto_alloc_array(machine, UINT8, VIDEORAM_SIZE); state->videoram_a = auto_alloc_array(machine, UINT8, VIDEORAM_SIZE);
crgolf_videoram_b = auto_alloc_array(machine, UINT8, VIDEORAM_SIZE); state->videoram_b = auto_alloc_array(machine, UINT8, VIDEORAM_SIZE);
/* register for save states */ /* register for save states */
state_save_register_global_pointer(machine, crgolf_videoram_a, VIDEORAM_SIZE); state_save_register_global_pointer(machine, state->videoram_a, VIDEORAM_SIZE);
state_save_register_global_pointer(machine, crgolf_videoram_b, VIDEORAM_SIZE); state_save_register_global_pointer(machine, state->videoram_b, VIDEORAM_SIZE);
} }
@ -122,7 +113,8 @@ static VIDEO_START( crgolf )
static VIDEO_UPDATE( crgolf ) static VIDEO_UPDATE( crgolf )
{ {
int flip = *crgolf_screen_flip & 1; crgolf_state *state = (crgolf_state *)screen->machine->driver_data;
int flip = *state->screen_flip & 1;
offs_t offs; offs_t offs;
pen_t pens[NUM_PENS]; pen_t pens[NUM_PENS];
@ -137,12 +129,12 @@ static VIDEO_UPDATE( crgolf )
UINT8 y = (offs & 0x1fe0) >> 5; UINT8 y = (offs & 0x1fe0) >> 5;
UINT8 x = (offs & 0x001f) << 3; UINT8 x = (offs & 0x001f) << 3;
UINT8 data_a0 = crgolf_videoram_a[0x2000 | offs]; UINT8 data_a0 = state->videoram_a[0x2000 | offs];
UINT8 data_a1 = crgolf_videoram_a[0x0000 | offs]; UINT8 data_a1 = state->videoram_a[0x0000 | offs];
UINT8 data_a2 = crgolf_videoram_a[0x4000 | offs]; UINT8 data_a2 = state->videoram_a[0x4000 | offs];
UINT8 data_b0 = crgolf_videoram_b[0x2000 | offs]; UINT8 data_b0 = state->videoram_b[0x2000 | offs];
UINT8 data_b1 = crgolf_videoram_b[0x0000 | offs]; UINT8 data_b1 = state->videoram_b[0x0000 | offs];
UINT8 data_b2 = crgolf_videoram_b[0x4000 | offs]; UINT8 data_b2 = state->videoram_b[0x4000 | offs];
if (flip) if (flip)
{ {
@ -157,10 +149,10 @@ static VIDEO_UPDATE( crgolf )
UINT8 data_b = 0; UINT8 data_b = 0;
UINT8 data_a = 0; UINT8 data_a = 0;
if (~*crgolf_screena_enable & 1) if (~*state->screena_enable & 1)
data_a = ((data_a0 & 0x80) >> 7) | ((data_a1 & 0x80) >> 6) | ((data_a2 & 0x80) >> 5); data_a = ((data_a0 & 0x80) >> 7) | ((data_a1 & 0x80) >> 6) | ((data_a2 & 0x80) >> 5);
if (~*crgolf_screenb_enable & 1) if (~*state->screenb_enable & 1)
data_b = ((data_b0 & 0x80) >> 7) | ((data_b1 & 0x80) >> 6) | ((data_b2 & 0x80) >> 5); data_b = ((data_b0 & 0x80) >> 7) | ((data_b1 & 0x80) >> 6) | ((data_b2 & 0x80) >> 5);
/* screen A has priority over B */ /* screen A has priority over B */
@ -170,7 +162,7 @@ static VIDEO_UPDATE( crgolf )
color = data_b | 0x08; color = data_b | 0x08;
/* add HI bit if enabled */ /* add HI bit if enabled */
if (*crgolf_color_select) if (*state->color_select)
color = color | 0x10; color = color | 0x10;
*BITMAP_ADDR32(bitmap, y, x) = pens[color]; *BITMAP_ADDR32(bitmap, y, x) = pens[color];
@ -194,7 +186,6 @@ static VIDEO_UPDATE( crgolf )
} }
/************************************* /*************************************
* *
* Machine driver * Machine driver