From 15d6716ee302a78e1124416d4afd530b8326c5a0 Mon Sep 17 00:00:00 2001 From: Aaron Giles Date: Sat, 12 Feb 2011 18:12:15 +0000 Subject: [PATCH] Eliminated global/static variables in a aristocr/atlus/bfm/bmc/ capcom/cinemat/dataeast drivers by introducing/using driver_device classes. [Atari Ace] --- src/emu/cpu/sh2/sh2.c | 4 +- src/emu/cpu/sh2/sh2.h | 4 +- src/emu/cpu/sh2/sh2comn.c | 22 +- src/emu/cpu/sh2/sh2comn.h | 4 +- src/mame/audio/cchasm.c | 67 +-- src/mame/audio/cinemat.c | 224 ++++----- src/mame/audio/cps3.c | 2 +- src/mame/drivers/86lions.c | 19 +- src/mame/drivers/aristmk4.c | 201 ++++---- src/mame/drivers/aristmk5.c | 45 +- src/mame/drivers/battlera.c | 23 +- src/mame/drivers/bfcobra.c | 267 ++++++----- src/mame/drivers/bfm_sc1.c | 268 ++++++----- src/mame/drivers/bfm_sc2.c | 871 +++++++++++++++++++---------------- src/mame/drivers/bfmsys85.c | 149 +++--- src/mame/drivers/bmcbowl.c | 85 ++-- src/mame/drivers/caswin.c | 42 +- src/mame/drivers/cchasm.c | 4 +- src/mame/drivers/cinemat.c | 66 +-- src/mame/drivers/cps3.c | 570 +++++++++++------------ src/mame/drivers/darkseal.c | 15 +- src/mame/drivers/dec0.c | 140 +++--- src/mame/drivers/deco32.c | 348 +++++++------- src/mame/drivers/deco_ld.c | 33 +- src/mame/drivers/deco_mlc.c | 64 +-- src/mame/drivers/deshoros.c | 62 ++- src/mame/drivers/dlair.c | 66 +-- src/mame/drivers/koftball.c | 83 ++-- src/mame/drivers/madalien.c | 34 +- src/mame/drivers/mitchell.c | 58 ++- src/mame/drivers/pcktgal.c | 14 +- src/mame/drivers/powerins.c | 23 +- src/mame/drivers/progolf.c | 73 +-- src/mame/drivers/rmhaihai.c | 82 ++-- src/mame/drivers/srumbler.c | 6 +- src/mame/drivers/sshangha.c | 41 +- src/mame/drivers/stadhero.c | 8 +- src/mame/drivers/tigeroad.c | 53 +-- src/mame/drivers/tryout.c | 2 +- src/mame/drivers/tumbleb.c | 20 +- src/mame/drivers/vulgus.c | 10 +- src/mame/includes/battlera.h | 28 ++ src/mame/includes/cchasm.h | 19 +- src/mame/includes/cinemat.h | 33 ++ src/mame/includes/cps3.h | 54 ++- src/mame/includes/darkseal.h | 24 +- src/mame/includes/dec0.h | 54 ++- src/mame/includes/deco32.h | 74 ++- src/mame/includes/deco_mlc.h | 22 +- src/mame/includes/madalien.h | 33 +- src/mame/includes/mitchell.h | 2 + src/mame/includes/pcktgal.h | 3 + src/mame/includes/powerins.h | 20 +- src/mame/includes/srumbler.h | 16 +- src/mame/includes/sshangha.h | 28 +- src/mame/includes/stadhero.h | 20 +- src/mame/includes/tigeroad.h | 4 + src/mame/includes/tryout.h | 8 +- src/mame/includes/tumbleb.h | 2 + src/mame/includes/vulgus.h | 20 +- src/mame/machine/dec0.c | 182 ++++---- src/mame/machine/megadriv.c | 2 +- src/mame/mame.mak | 10 +- src/mame/video/battlera.c | 205 ++++----- src/mame/video/bfm_dm01.c | 10 +- src/mame/video/bfm_dm01.h | 2 +- src/mame/video/cchasm.c | 14 +- src/mame/video/cinemat.c | 72 ++- src/mame/video/darkseal.c | 90 ++-- src/mame/video/dec0.c | 213 +++++---- src/mame/video/deco32.c | 669 ++++++++++++++------------- src/mame/video/deco_mlc.c | 42 +- src/mame/video/madalien.c | 132 +++--- src/mame/video/pcktgal.c | 9 +- src/mame/video/powerins.c | 67 ++- src/mame/video/srumbler.c | 50 +- src/mame/video/sshangha.c | 128 ++--- src/mame/video/stadhero.c | 50 +- src/mame/video/tigeroad.c | 37 +- src/mame/video/tryout.c | 82 ++-- src/mame/video/vulgus.c | 51 +- 81 files changed, 3747 insertions(+), 3006 deletions(-) diff --git a/src/emu/cpu/sh2/sh2.c b/src/emu/cpu/sh2/sh2.c index 6df35052682..6ed10b4ab29 100644 --- a/src/emu/cpu/sh2/sh2.c +++ b/src/emu/cpu/sh2/sh2.c @@ -2147,8 +2147,8 @@ static CPU_RESET( sh2 ) sh2_state *sh2 = get_safe_token(device); emu_timer *tsave, *tsaved0, *tsaved1; UINT32 *m; - int (*dma_callback_kludge)(UINT32 src, UINT32 dst, UINT32 data, int size); - int (*dma_callback_fifo_data_available)(UINT32 src, UINT32 dst, UINT32 data, int size); + int (*dma_callback_kludge)(device_t *device, UINT32 src, UINT32 dst, UINT32 data, int size); + int (*dma_callback_fifo_data_available)(device_t *device, UINT32 src, UINT32 dst, UINT32 data, int size); int save_is_slave; void (*f)(UINT32 data); diff --git a/src/emu/cpu/sh2/sh2.h b/src/emu/cpu/sh2/sh2.h index 873e7471f46..8ed16c75aa8 100644 --- a/src/emu/cpu/sh2/sh2.h +++ b/src/emu/cpu/sh2/sh2.h @@ -61,8 +61,8 @@ typedef struct _sh2_cpu_core sh2_cpu_core; struct _sh2_cpu_core { int is_slave; - int (*dma_callback_kludge)(UINT32 src, UINT32 dst, UINT32 data, int size); - int (*dma_callback_fifo_data_available)(UINT32 src, UINT32 dst, UINT32 data, int size); + int (*dma_callback_kludge)(device_t *device, UINT32 src, UINT32 dst, UINT32 data, int size); + int (*dma_callback_fifo_data_available)(device_t *device, UINT32 src, UINT32 dst, UINT32 data, int size); }; DECLARE_LEGACY_CPU_DEVICE(SH1, sh1); diff --git a/src/emu/cpu/sh2/sh2comn.c b/src/emu/cpu/sh2/sh2comn.c index 69c2ea6f5aa..6cd5b690da1 100644 --- a/src/emu/cpu/sh2/sh2comn.c +++ b/src/emu/cpu/sh2/sh2comn.c @@ -209,7 +209,7 @@ void sh2_do_dma(sh2_state *sh2, int dma) if (sh2->dma_callback_fifo_data_available) { - int available = sh2->dma_callback_fifo_data_available(tempsrc, tempdst, 0, sh2->active_dma_size[dma]); + int available = sh2->dma_callback_fifo_data_available(sh2->device, tempsrc, tempdst, 0, sh2->active_dma_size[dma]); if (!available) { @@ -226,7 +226,7 @@ void sh2_do_dma(sh2_state *sh2, int dma) dmadata = sh2->program->read_byte(tempsrc); - if (sh2->dma_callback_kludge) dmadata = sh2->dma_callback_kludge(tempsrc, tempdst, dmadata, sh2->active_dma_size[dma]); + if (sh2->dma_callback_kludge) dmadata = sh2->dma_callback_kludge(sh2->device, tempsrc, tempdst, dmadata, sh2->active_dma_size[dma]); sh2->program->write_byte(tempdst, dmadata); if(sh2->active_dma_incs[dma] == 2) @@ -257,7 +257,7 @@ void sh2_do_dma(sh2_state *sh2, int dma) if (sh2->dma_callback_fifo_data_available) { - int available = sh2->dma_callback_fifo_data_available(tempsrc, tempdst, 0, sh2->active_dma_size[dma]); + int available = sh2->dma_callback_fifo_data_available(sh2->device, tempsrc, tempdst, 0, sh2->active_dma_size[dma]); if (!available) { @@ -274,7 +274,7 @@ void sh2_do_dma(sh2_state *sh2, int dma) // check: should this really be using read_word_32 / write_word_32? dmadata = sh2->program->read_word(tempsrc); - if (sh2->dma_callback_kludge) dmadata = sh2->dma_callback_kludge(tempsrc, tempdst, dmadata, sh2->active_dma_size[dma]); + if (sh2->dma_callback_kludge) dmadata = sh2->dma_callback_kludge(sh2->device, tempsrc, tempdst, dmadata, sh2->active_dma_size[dma]); sh2->program->write_word(tempdst, dmadata); if(sh2->active_dma_incs[dma] == 2) @@ -304,7 +304,7 @@ void sh2_do_dma(sh2_state *sh2, int dma) if (sh2->dma_callback_fifo_data_available) { - int available = sh2->dma_callback_fifo_data_available(tempsrc, tempdst, 0, sh2->active_dma_size[dma]); + int available = sh2->dma_callback_fifo_data_available(sh2->device, tempsrc, tempdst, 0, sh2->active_dma_size[dma]); if (!available) { @@ -320,7 +320,7 @@ void sh2_do_dma(sh2_state *sh2, int dma) #endif dmadata = sh2->program->read_dword(tempsrc); - if (sh2->dma_callback_kludge) dmadata = sh2->dma_callback_kludge(tempsrc, tempdst, dmadata, sh2->active_dma_size[dma]); + if (sh2->dma_callback_kludge) dmadata = sh2->dma_callback_kludge(sh2->device, tempsrc, tempdst, dmadata, sh2->active_dma_size[dma]); sh2->program->write_dword(tempdst, dmadata); if(sh2->active_dma_incs[dma] == 2) @@ -349,7 +349,7 @@ void sh2_do_dma(sh2_state *sh2, int dma) if (sh2->dma_callback_fifo_data_available) { - int available = sh2->dma_callback_fifo_data_available(tempsrc, tempdst, 0, sh2->active_dma_size[dma]); + int available = sh2->dma_callback_fifo_data_available(sh2->device, tempsrc, tempdst, 0, sh2->active_dma_size[dma]); if (!available) { @@ -365,19 +365,19 @@ void sh2_do_dma(sh2_state *sh2, int dma) #endif dmadata = sh2->program->read_dword(tempsrc); - if (sh2->dma_callback_kludge) dmadata = sh2->dma_callback_kludge(tempsrc, tempdst, dmadata, sh2->active_dma_size[dma]); + if (sh2->dma_callback_kludge) dmadata = sh2->dma_callback_kludge(sh2->device, tempsrc, tempdst, dmadata, sh2->active_dma_size[dma]); sh2->program->write_dword(tempdst, dmadata); dmadata = sh2->program->read_dword(tempsrc+4); - if (sh2->dma_callback_kludge) dmadata = sh2->dma_callback_kludge(tempsrc, tempdst, dmadata, sh2->active_dma_size[dma]); + if (sh2->dma_callback_kludge) dmadata = sh2->dma_callback_kludge(sh2->device, tempsrc, tempdst, dmadata, sh2->active_dma_size[dma]); sh2->program->write_dword(tempdst+4, dmadata); dmadata = sh2->program->read_dword(tempsrc+8); - if (sh2->dma_callback_kludge) dmadata = sh2->dma_callback_kludge(tempsrc, tempdst, dmadata, sh2->active_dma_size[dma]); + if (sh2->dma_callback_kludge) dmadata = sh2->dma_callback_kludge(sh2->device, tempsrc, tempdst, dmadata, sh2->active_dma_size[dma]); sh2->program->write_dword(tempdst+8, dmadata); dmadata = sh2->program->read_dword(tempsrc+12); - if (sh2->dma_callback_kludge) dmadata = sh2->dma_callback_kludge(tempsrc, tempdst, dmadata, sh2->active_dma_size[dma]); + if (sh2->dma_callback_kludge) dmadata = sh2->dma_callback_kludge(sh2->device, tempsrc, tempdst, dmadata, sh2->active_dma_size[dma]); sh2->program->write_dword(tempdst+12, dmadata); if(sh2->active_dma_incd[dma] == 2) diff --git a/src/emu/cpu/sh2/sh2comn.h b/src/emu/cpu/sh2/sh2comn.h index ddab61f65fe..9f2509a0146 100644 --- a/src/emu/cpu/sh2/sh2comn.h +++ b/src/emu/cpu/sh2/sh2comn.h @@ -148,8 +148,8 @@ typedef struct UINT32 active_dma_count[2]; int is_slave, cpu_type; - int (*dma_callback_kludge)(UINT32 src, UINT32 dst, UINT32 data, int size); - int (*dma_callback_fifo_data_available)(UINT32 src, UINT32 dst, UINT32 data, int size); + int (*dma_callback_kludge)(device_t *device, UINT32 src, UINT32 dst, UINT32 data, int size); + int (*dma_callback_fifo_data_available)(device_t *device, UINT32 src, UINT32 dst, UINT32 data, int size); void (*ftcsr_read_callback)(UINT32 data); diff --git a/src/mame/audio/cchasm.c b/src/mame/audio/cchasm.c index 2d39370ba10..61eef77b63f 100644 --- a/src/mame/audio/cchasm.c +++ b/src/mame/audio/cchasm.c @@ -11,51 +11,54 @@ #include "sound/ay8910.h" #include "sound/dac.h" -static int sound_flags; -static int coin_flag; -static device_t *ctc; WRITE8_HANDLER( cchasm_reset_coin_flag_w ) { - if (coin_flag) + cchasm_state *state = space->machine->driver_data(); + if (state->coin_flag) { - coin_flag = 0; - z80ctc_trg0_w(ctc, coin_flag); + state->coin_flag = 0; + z80ctc_trg0_w(state->ctc, state->coin_flag); } } INPUT_CHANGED( cchasm_set_coin_flag ) { - if (!newval && !coin_flag) + cchasm_state *state = field->port->machine->driver_data(); + if (!newval && !state->coin_flag) { - coin_flag = 1; - z80ctc_trg0_w(ctc, coin_flag); + state->coin_flag = 1; + z80ctc_trg0_w(state->ctc, state->coin_flag); } } READ8_HANDLER( cchasm_coin_sound_r ) { + cchasm_state *state = space->machine->driver_data(); UINT8 coin = (input_port_read(space->machine, "IN3") >> 4) & 0x7; - return sound_flags | (coin_flag << 3) | coin; + return state->sound_flags | (state->coin_flag << 3) | coin; } READ8_HANDLER( cchasm_soundlatch2_r ) { - sound_flags &= ~0x80; - z80ctc_trg2_w(ctc, 0); + cchasm_state *state = space->machine->driver_data(); + state->sound_flags &= ~0x80; + z80ctc_trg2_w(state->ctc, 0); return soundlatch2_r(space, offset); } WRITE8_HANDLER( cchasm_soundlatch4_w ) { - sound_flags |= 0x40; + cchasm_state *state = space->machine->driver_data(); + state->sound_flags |= 0x40; soundlatch4_w(space, offset, data); cputag_set_input_line(space->machine, "maincpu", 1, HOLD_LINE); } WRITE16_HANDLER( cchasm_io_w ) { - static int led; + cchasm_state *state = space->machine->driver_data(); + //static int led; if (ACCESSING_BITS_8_15) { @@ -66,13 +69,13 @@ WRITE16_HANDLER( cchasm_io_w ) soundlatch_w (space, offset, data); break; case 1: - sound_flags |= 0x80; + state->sound_flags |= 0x80; soundlatch2_w (space, offset, data); - z80ctc_trg2_w(ctc, 1); + z80ctc_trg2_w(state->ctc, 1); cputag_set_input_line(space->machine, "audiocpu", INPUT_LINE_NMI, PULSE_LINE); break; case 2: - led = data; + //led = data; break; } } @@ -80,15 +83,16 @@ WRITE16_HANDLER( cchasm_io_w ) READ16_HANDLER( cchasm_io_r ) { + cchasm_state *state = space->machine->driver_data(); switch (offset & 0xf) { case 0x0: return soundlatch3_r (space, offset) << 8; case 0x1: - sound_flags &= ~0x40; + state->sound_flags &= ~0x40; return soundlatch4_r (space,offset) << 8; case 0x2: - return (sound_flags| (input_port_read(space->machine, "IN3") & 0x07) | 0x08) << 8; + return (state->sound_flags| (input_port_read(space->machine, "IN3") & 0x07) | 0x08) << 8; case 0x5: return input_port_read(space->machine, "IN2") << 8; case 0x8: @@ -98,26 +102,26 @@ READ16_HANDLER( cchasm_io_r ) } } -static int channel_active[2]; -static int output[2]; static WRITE_LINE_DEVICE_HANDLER( ctc_timer_1_w ) { + cchasm_state *drvstate = device->machine->driver_data(); if (state) /* rising edge */ { - output[0] ^= 0x7f; - channel_active[0] = 1; - dac_data_w(device->machine->device("dac1"), output[0]); + drvstate->output[0] ^= 0x7f; + drvstate->channel_active[0] = 1; + dac_data_w(device->machine->device("dac1"), drvstate->output[0]); } } static WRITE_LINE_DEVICE_HANDLER( ctc_timer_2_w ) { + cchasm_state *drvstate = device->machine->driver_data(); if (state) /* rising edge */ { - output[1] ^= 0x7f; - channel_active[1] = 1; - dac_data_w(device->machine->device("dac2"), output[0]); + drvstate->output[1] ^= 0x7f; + drvstate->channel_active[1] = 1; + dac_data_w(device->machine->device("dac2"), drvstate->output[0]); } } @@ -132,9 +136,10 @@ Z80CTC_INTERFACE( cchasm_ctc_intf ) SOUND_START( cchasm ) { - coin_flag = 0; - sound_flags = 0; - output[0] = 0; output[1] = 0; + cchasm_state *state = machine->driver_data(); + state->coin_flag = 0; + state->sound_flags = 0; + state->output[0] = 0; state->output[1] = 0; - ctc = machine->device("ctc"); + state->ctc = machine->device("ctc"); } diff --git a/src/mame/audio/cinemat.c b/src/mame/audio/cinemat.c index f47f1fca85f..4286a9eddfb 100644 --- a/src/mame/audio/cinemat.c +++ b/src/mame/audio/cinemat.c @@ -38,11 +38,11 @@ #define SOUNDVAL_RISING_EDGE(bit) RISING_EDGE(bit, bits_changed, sound_val) #define SOUNDVAL_FALLING_EDGE(bit) FALLING_EDGE(bit, bits_changed, sound_val) -#define SHIFTREG_RISING_EDGE(bit) RISING_EDGE(bit, (last_shift ^ current_shift), current_shift) -#define SHIFTREG_FALLING_EDGE(bit) FALLING_EDGE(bit, (last_shift ^ current_shift), current_shift) +#define SHIFTREG_RISING_EDGE(bit) RISING_EDGE(bit, (state->last_shift ^ state->current_shift), state->current_shift) +#define SHIFTREG_FALLING_EDGE(bit) FALLING_EDGE(bit, (state->last_shift ^ state->current_shift), state->current_shift) -#define SHIFTREG2_RISING_EDGE(bit) RISING_EDGE(bit, (last_shift2 ^ current_shift), current_shift) -#define SHIFTREG2_FALLING_EDGE(bit) FALLING_EDGE(bit, (last_shift2 ^ current_shift), current_shift) +#define SHIFTREG2_RISING_EDGE(bit) RISING_EDGE(bit, (state->last_shift2 ^ state->current_shift), state->current_shift) +#define SHIFTREG2_FALLING_EDGE(bit) FALLING_EDGE(bit, (state->last_shift2 ^ state->current_shift), state->current_shift) @@ -53,20 +53,10 @@ *************************************/ static void (*sound_handler)(running_machine *,UINT8 sound_val, UINT8 bits_changed); -static UINT8 sound_control; /* general shift register variables */ -static UINT32 current_shift; -static UINT32 last_shift; -static UINT32 last_shift2; -static UINT32 current_pitch; -static UINT32 last_frame; /* Rockola sound variables */ -static UINT8 sound_fifo[16]; -static UINT8 sound_fifo_in; -static UINT8 sound_fifo_out; -static UINT8 last_portb_write; @@ -78,14 +68,15 @@ static UINT8 last_portb_write; WRITE8_HANDLER( cinemat_sound_control_w ) { - UINT8 oldval = sound_control; + cinemat_state *state = space->machine->driver_data(); + UINT8 oldval = state->sound_control; /* form an 8-bit value with the new bit */ - sound_control = (sound_control & ~(1 << offset)) | ((data & 1) << offset); + state->sound_control = (state->sound_control & ~(1 << offset)) | ((data & 1) << offset); /* if something changed, call the sound subroutine */ - if ((sound_control != oldval) && sound_handler) - (*sound_handler)(space->machine, sound_control, sound_control ^ oldval); + if ((state->sound_control != oldval) && sound_handler) + (*sound_handler)(space->machine, state->sound_control, state->sound_control ^ oldval); } @@ -98,22 +89,24 @@ WRITE8_HANDLER( cinemat_sound_control_w ) static MACHINE_START( generic ) { + cinemat_state *state = machine->driver_data(); /* register for save states */ - state_save_register_global(machine, sound_control); - state_save_register_global(machine, current_shift); - state_save_register_global(machine, last_shift); - state_save_register_global(machine, last_shift2); - state_save_register_global(machine, current_pitch); - state_save_register_global(machine, last_frame); - state_save_register_global_array(machine, sound_fifo); - state_save_register_global(machine, sound_fifo_in); - state_save_register_global(machine, sound_fifo_out); - state_save_register_global(machine, last_portb_write); + state_save_register_global(machine, state->sound_control); + state_save_register_global(machine, state->current_shift); + state_save_register_global(machine, state->last_shift); + state_save_register_global(machine, state->last_shift2); + state_save_register_global(machine, state->current_pitch); + state_save_register_global(machine, state->last_frame); + state_save_register_global_array(machine, state->sound_fifo); + state_save_register_global(machine, state->sound_fifo_in); + state_save_register_global(machine, state->sound_fifo_out); + state_save_register_global(machine, state->last_portb_write); } static void generic_init(running_machine *machine, void (*callback)(running_machine *,UINT8, UINT8)) { + cinemat_state *state = machine->driver_data(); /* call the standard init */ MACHINE_RESET_CALL(cinemat); @@ -121,18 +114,18 @@ static void generic_init(running_machine *machine, void (*callback)(running_mach sound_handler = callback; /* reset sound control */ - sound_control = 0x9f; + state->sound_control = 0x9f; /* reset shift register values */ - current_shift = 0xffff; - last_shift = 0xffff; - last_shift2 = 0xffff; + state->current_shift = 0xffff; + state->last_shift = 0xffff; + state->last_shift2 = 0xffff; /* reset frame counters */ - last_frame = 0; + state->last_frame = 0; /* reset Star Castle pitch */ - current_pitch = 0x10000; + state->current_pitch = 0x10000; } @@ -299,12 +292,13 @@ static const samples_interface speedfrk_samples_interface = static void speedfrk_sound_w(running_machine *machine, UINT8 sound_val, UINT8 bits_changed) { + cinemat_state *state = machine->driver_data(); device_t *samples = machine->device("samples"); /* on the falling edge of bit 0x08, clock the inverse of bit 0x04 into the top of the shiftreg */ if (SOUNDVAL_FALLING_EDGE(0x08)) { - current_shift = ((current_shift >> 1) & 0x7fff) | ((~sound_val << 13) & 1); + state->current_shift = ((state->current_shift >> 1) & 0x7fff) | ((~sound_val << 13) & 1); /* high 12 bits control the frequency - counts from value to $FFF, carry triggers */ /* another counter */ @@ -513,13 +507,14 @@ static const samples_interface tailg_samples_interface = static void tailg_sound_w(running_machine *machine, UINT8 sound_val, UINT8 bits_changed) { + cinemat_state *state = machine->driver_data(); /* the falling edge of bit 0x10 clocks bit 0x08 into the mux selected by bits 0x07 */ if (SOUNDVAL_FALLING_EDGE(0x10)) { device_t *samples = machine->device("samples"); /* update the shift register (actually just a simple mux) */ - current_shift = (current_shift & ~(1 << (sound_val & 7))) | (((sound_val >> 3) & 1) << (sound_val & 7)); + state->current_shift = (state->current_shift & ~(1 << (sound_val & 7))) | (((sound_val >> 3) & 1) << (sound_val & 7)); /* explosion - falling edge */ if (SHIFTREG_FALLING_EDGE(0x01)) @@ -552,10 +547,10 @@ static void tailg_sound_w(running_machine *machine, UINT8 sound_val, UINT8 bits_ sample_start(samples, 5, 5, 0); /* LED */ - set_led_status(machine, 0, current_shift & 0x40); + set_led_status(machine, 0, state->current_shift & 0x40); /* remember the previous value */ - last_shift = current_shift; + state->last_shift = state->current_shift; } } @@ -674,11 +669,12 @@ static const samples_interface armora_samples_interface = static void armora_sound_w(running_machine *machine, UINT8 sound_val, UINT8 bits_changed) { + cinemat_state *state = machine->driver_data(); device_t *samples = machine->device("samples"); /* on the rising edge of bit 0x10, clock bit 0x80 into the shift register */ if (SOUNDVAL_RISING_EDGE(0x10)) - current_shift = ((current_shift >> 1) & 0x7f) | (sound_val & 0x80); + state->current_shift = ((state->current_shift >> 1) & 0x7f) | (sound_val & 0x80); /* execute on the rising edge of bit 0x01 */ if (SOUNDVAL_RISING_EDGE(0x01)) @@ -702,7 +698,7 @@ static void armora_sound_w(running_machine *machine, UINT8 sound_val, UINT8 bits sample_start(samples, 3, 3, 0); /* remember the previous value */ - last_shift = current_shift; + state->last_shift = state->current_shift; } /* tank sound - 0=on, 1=off */ @@ -776,18 +772,19 @@ static const samples_interface ripoff_samples_interface = static void ripoff_sound_w(running_machine *machine, UINT8 sound_val, UINT8 bits_changed) { + cinemat_state *state = machine->driver_data(); device_t *samples = machine->device("samples"); /* on the rising edge of bit 0x02, clock bit 0x01 into the shift register */ if (SOUNDVAL_RISING_EDGE(0x02)) - current_shift = ((current_shift >> 1) & 0x7f) | ((sound_val << 7) & 0x80); + state->current_shift = ((state->current_shift >> 1) & 0x7f) | ((sound_val << 7) & 0x80); /* execute on the rising edge of bit 0x04 */ if (SOUNDVAL_RISING_EDGE(0x04)) { /* background - 0=on, 1=off, selected by bits 0x38 */ - if ((((current_shift ^ last_shift) & 0x38) && !(current_shift & 0x04)) || SHIFTREG_FALLING_EDGE(0x04)) - sample_start(samples, 5, 5 + ((current_shift >> 5) & 7), 1); + if ((((state->current_shift ^ state->last_shift) & 0x38) && !(state->current_shift & 0x04)) || SHIFTREG_FALLING_EDGE(0x04)) + sample_start(samples, 5, 5 + ((state->current_shift >> 5) & 7), 1); if (SHIFTREG_RISING_EDGE(0x04)) sample_stop(samples, 5); @@ -802,7 +799,7 @@ static void ripoff_sound_w(running_machine *machine, UINT8 sound_val, UINT8 bits sample_stop(samples, 1); /* remember the previous value */ - last_shift = current_shift; + state->last_shift = state->current_shift; } /* torpedo - falling edge */ @@ -864,12 +861,13 @@ static const samples_interface starcas_samples_interface = static void starcas_sound_w(running_machine *machine, UINT8 sound_val, UINT8 bits_changed) { + cinemat_state *state = machine->driver_data(); device_t *samples = machine->device("samples"); UINT32 target_pitch; /* on the rising edge of bit 0x10, clock bit 0x80 into the shift register */ if (SOUNDVAL_RISING_EDGE(0x10)) - current_shift = ((current_shift >> 1) & 0x7f) | (sound_val & 0x80); + state->current_shift = ((state->current_shift >> 1) & 0x7f) | (sound_val & 0x80); /* execute on the rising edge of bit 0x01 */ if (SOUNDVAL_RISING_EDGE(0x01)) @@ -901,22 +899,22 @@ static void starcas_sound_w(running_machine *machine, UINT8 sound_val, UINT8 bit sample_stop(samples, 4); /* latch the drone pitch */ - target_pitch = (current_shift & 7) + ((current_shift & 2) << 2); + target_pitch = (state->current_shift & 7) + ((state->current_shift & 2) << 2); target_pitch = 0x5800 + (target_pitch << 12); /* once per frame slide the pitch toward the target */ - if (machine->primary_screen->frame_number() > last_frame) + if (machine->primary_screen->frame_number() > state->last_frame) { - if (current_pitch > target_pitch) - current_pitch -= 225; - if (current_pitch < target_pitch) - current_pitch += 150; - sample_set_freq(samples, 4, current_pitch); - last_frame = machine->primary_screen->frame_number(); + if (state->current_pitch > target_pitch) + state->current_pitch -= 225; + if (state->current_pitch < target_pitch) + state->current_pitch += 150; + sample_set_freq(samples, 4, state->current_pitch); + state->last_frame = machine->primary_screen->frame_number(); } /* remember the previous value */ - last_shift = current_shift; + state->last_shift = state->current_shift; } /* loud explosion - falling edge */ @@ -978,18 +976,18 @@ static const samples_interface solarq_samples_interface = static void solarq_sound_w(running_machine *machine, UINT8 sound_val, UINT8 bits_changed) { + cinemat_state *state = machine->driver_data(); device_t *samples = machine->device("samples"); - static float target_volume, current_volume; /* on the rising edge of bit 0x10, clock bit 0x80 into the shift register */ if (SOUNDVAL_RISING_EDGE(0x10)) - current_shift = ((current_shift >> 1) & 0x7fff) | ((sound_val << 8) & 0x8000); + state->current_shift = ((state->current_shift >> 1) & 0x7fff) | ((sound_val << 8) & 0x8000); /* execute on the rising edge of bit 0x02 */ if (SOUNDVAL_RISING_EDGE(0x02)) { /* only the upper 8 bits matter */ - current_shift >>= 8; + state->current_shift >>= 8; /* loud explosion - falling edge */ if (SHIFTREG_FALLING_EDGE(0x80)) @@ -1002,25 +1000,25 @@ static void solarq_sound_w(running_machine *machine, UINT8 sound_val, UINT8 bits /* thrust - 0=on, 1=off */ if (SHIFTREG_FALLING_EDGE(0x20)) { - target_volume = 1.0; + state->target_volume = 1.0; if (!sample_playing(samples, 2)) sample_start(samples, 2, 2, 1); } if (SHIFTREG_RISING_EDGE(0x20)) - target_volume = 0; + state->target_volume = 0; /* ramp the thrust volume */ - if (sample_playing(samples, 2) && machine->primary_screen->frame_number() > last_frame) + if (sample_playing(samples, 2) && machine->primary_screen->frame_number() > state->last_frame) { - if (current_volume > target_volume) - current_volume -= 0.078f; - if (current_volume < target_volume) - current_volume += 0.078f; - if (current_volume > 0) - sample_set_volume(samples, 2, current_volume); + if (state->current_volume > state->target_volume) + state->current_volume -= 0.078f; + if (state->current_volume < state->target_volume) + state->current_volume += 0.078f; + if (state->current_volume > 0) + sample_set_volume(samples, 2, state->current_volume); else sample_stop(samples, 2); - last_frame = machine->primary_screen->frame_number(); + state->last_frame = machine->primary_screen->frame_number(); } /* fire - falling edge */ @@ -1042,7 +1040,7 @@ static void solarq_sound_w(running_machine *machine, UINT8 sound_val, UINT8 bits sample_start(samples, 6, 6, 0); /* remember the previous value */ - last_shift = current_shift; + state->last_shift = state->current_shift; } /* clock music data on the rising edge of bit 0x01 */ @@ -1057,15 +1055,15 @@ static void solarq_sound_w(running_machine *machine, UINT8 sound_val, UINT8 bits sample_stop(samples, 7); /* set the frequency */ - freq = 56818.181818 / (4096 - (current_shift & 0xfff)); + freq = 56818.181818 / (4096 - (state->current_shift & 0xfff)); sample_set_freq(samples, 7, 44100 * freq / 1050); /* set the volume */ - vol = (~current_shift >> 12) & 7; + vol = (~state->current_shift >> 12) & 7; sample_set_volume(samples, 7, vol / 7.0); /* remember the previous value */ - last_shift2 = current_shift; + state->last_shift2 = state->current_shift; } } @@ -1119,17 +1117,18 @@ static const samples_interface boxingb_samples_interface = static void boxingb_sound_w(running_machine *machine, UINT8 sound_val, UINT8 bits_changed) { + cinemat_state *state = machine->driver_data(); device_t *samples = machine->device("samples"); /* on the rising edge of bit 0x10, clock bit 0x80 into the shift register */ if (SOUNDVAL_RISING_EDGE(0x10)) - current_shift = ((current_shift >> 1) & 0x7fff) | ((sound_val << 8) & 0x8000); + state->current_shift = ((state->current_shift >> 1) & 0x7fff) | ((sound_val << 8) & 0x8000); /* execute on the rising edge of bit 0x02 */ if (SOUNDVAL_RISING_EDGE(0x02)) { /* only the upper 8 bits matter */ - current_shift >>= 8; + state->current_shift >>= 8; /* soft explosion - falling edge */ if (SHIFTREG_FALLING_EDGE(0x80)) @@ -1166,7 +1165,7 @@ static void boxingb_sound_w(running_machine *machine, UINT8 sound_val, UINT8 bit sample_start(samples, 7, 7, 0); /* remember the previous value */ - last_shift = current_shift; + state->last_shift = state->current_shift; } /* clock music data on the rising edge of bit 0x01 */ @@ -1181,11 +1180,11 @@ static void boxingb_sound_w(running_machine *machine, UINT8 sound_val, UINT8 bit sample_stop(samples, 8); /* set the frequency */ - freq = 56818.181818 / (4096 - (current_shift & 0xfff)); + freq = 56818.181818 / (4096 - (state->current_shift & 0xfff)); sample_set_freq(samples, 8, 44100 * freq / 1050); /* set the volume */ - vol = (~current_shift >> 12) & 3; + vol = (~state->current_shift >> 12) & 3; sample_set_volume(samples, 8, vol / 3.0); /* cannon - falling edge */ @@ -1193,7 +1192,7 @@ static void boxingb_sound_w(running_machine *machine, UINT8 sound_val, UINT8 bit sample_start(samples, 9, 9, 0); /* remember the previous value */ - last_shift2 = current_shift; + state->last_shift2 = state->current_shift; } /* bounce - rising edge */ @@ -1251,12 +1250,13 @@ static const samples_interface wotw_samples_interface = static void wotw_sound_w(running_machine *machine, UINT8 sound_val, UINT8 bits_changed) { + cinemat_state *state = machine->driver_data(); device_t *samples = machine->device("samples"); UINT32 target_pitch; /* on the rising edge of bit 0x10, clock bit 0x80 into the shift register */ if (SOUNDVAL_RISING_EDGE(0x10)) - current_shift = ((current_shift >> 1) & 0x7f) | (sound_val & 0x80); + state->current_shift = ((state->current_shift >> 1) & 0x7f) | (sound_val & 0x80); /* execute on the rising edge of bit 0x01 */ if (SOUNDVAL_RISING_EDGE(0x01)) @@ -1288,22 +1288,22 @@ static void wotw_sound_w(running_machine *machine, UINT8 sound_val, UINT8 bits_c sample_stop(samples, 4); /* latch the drone pitch */ - target_pitch = (current_shift & 7) + ((current_shift & 2) << 2); + target_pitch = (state->current_shift & 7) + ((state->current_shift & 2) << 2); target_pitch = 0x10000 + (target_pitch << 12); /* once per frame slide the pitch toward the target */ - if (machine->primary_screen->frame_number() > last_frame) + if (machine->primary_screen->frame_number() > state->last_frame) { - if (current_pitch > target_pitch) - current_pitch -= 300; - if (current_pitch < target_pitch) - current_pitch += 200; - sample_set_freq(samples, 4, current_pitch); - last_frame = machine->primary_screen->frame_number(); + if (state->current_pitch > target_pitch) + state->current_pitch -= 300; + if (state->current_pitch < target_pitch) + state->current_pitch += 200; + sample_set_freq(samples, 4, state->current_pitch); + state->last_frame = machine->primary_screen->frame_number(); } /* remember the previous value */ - last_shift = current_shift; + state->last_shift = state->current_shift; } /* loud explosion - falling edge */ @@ -1365,12 +1365,13 @@ static const samples_interface wotwc_samples_interface = static void wotwc_sound_w(running_machine *machine, UINT8 sound_val, UINT8 bits_changed) { + cinemat_state *state = machine->driver_data(); device_t *samples = machine->device("samples"); UINT32 target_pitch; /* on the rising edge of bit 0x10, clock bit 0x80 into the shift register */ if (SOUNDVAL_RISING_EDGE(0x10)) - current_shift = ((current_shift >> 1) & 0x7f) | (sound_val & 0x80); + state->current_shift = ((state->current_shift >> 1) & 0x7f) | (sound_val & 0x80); /* execute on the rising edge of bit 0x01 */ if (SOUNDVAL_RISING_EDGE(0x01)) @@ -1402,22 +1403,22 @@ static void wotwc_sound_w(running_machine *machine, UINT8 sound_val, UINT8 bits_ sample_stop(samples, 4); /* latch the drone pitch */ - target_pitch = (current_shift & 7) + ((current_shift & 2) << 2); + target_pitch = (state->current_shift & 7) + ((state->current_shift & 2) << 2); target_pitch = 0x10000 + (target_pitch << 12); /* once per frame slide the pitch toward the target */ - if (machine->primary_screen->frame_number() > last_frame) + if (machine->primary_screen->frame_number() > state->last_frame) { - if (current_pitch > target_pitch) - current_pitch -= 300; - if (current_pitch < target_pitch) - current_pitch += 200; - sample_set_freq(samples, 4, current_pitch); - last_frame = machine->primary_screen->frame_number(); + if (state->current_pitch > target_pitch) + state->current_pitch -= 300; + if (state->current_pitch < target_pitch) + state->current_pitch += 200; + sample_set_freq(samples, 4, state->current_pitch); + state->last_frame = machine->primary_screen->frame_number(); } /* remember the previous value */ - last_shift = current_shift; + state->last_shift = state->current_shift; } /* loud explosion - falling edge */ @@ -1459,8 +1460,9 @@ MACHINE_CONFIG_END static TIMER_CALLBACK( synced_sound_w ) { - sound_fifo[sound_fifo_in] = param; - sound_fifo_in = (sound_fifo_in + 1) % 16; + cinemat_state *state = machine->driver_data(); + state->sound_fifo[state->sound_fifo_in] = param; + state->sound_fifo_in = (state->sound_fifo_in + 1) % 16; } @@ -1477,33 +1479,36 @@ static void demon_sound_w(running_machine *machine, UINT8 sound_val, UINT8 bits_ static READ8_DEVICE_HANDLER( sound_porta_r ) { + cinemat_state *state = device->machine->driver_data(); /* bits 0-3 are the sound data; bit 4 is the data ready */ - return sound_fifo[sound_fifo_out] | ((sound_fifo_in != sound_fifo_out) << 4); + return state->sound_fifo[state->sound_fifo_out] | ((state->sound_fifo_in != state->sound_fifo_out) << 4); } static READ8_DEVICE_HANDLER( sound_portb_r ) { - return last_portb_write; + cinemat_state *state = device->machine->driver_data(); + return state->last_portb_write; } static WRITE8_DEVICE_HANDLER( sound_portb_w ) { + cinemat_state *state = device->machine->driver_data(); /* watch for a 0->1 edge on bit 0 ("shift out") to advance the data pointer */ - if ((data & 1) != (last_portb_write & 1) && (data & 1) != 0) - sound_fifo_out = (sound_fifo_out + 1) % 16; + if ((data & 1) != (state->last_portb_write & 1) && (data & 1) != 0) + state->sound_fifo_out = (state->sound_fifo_out + 1) % 16; /* watch for a 0->1 edge of bit 1 ("hard reset") to reset the FIFO */ - if ((data & 2) != (last_portb_write & 2) && (data & 2) != 0) - sound_fifo_in = sound_fifo_out = 0; + if ((data & 2) != (state->last_portb_write & 2) && (data & 2) != 0) + state->sound_fifo_in = state->sound_fifo_out = 0; /* bit 2 controls the global mute */ - if ((data & 4) != (last_portb_write & 4)) + if ((data & 4) != (state->last_portb_write & 4)) device->machine->sound().system_mute(data & 4); /* remember the last value written */ - last_portb_write = data; + state->last_portb_write = data; } @@ -1546,12 +1551,13 @@ static Z80CTC_INTERFACE( demon_z80ctc_interface ) static MACHINE_RESET( demon_sound ) { + cinemat_state *state = machine->driver_data(); /* generic init */ generic_init(machine, demon_sound_w); /* reset the FIFO */ - sound_fifo_in = sound_fifo_out = 0; - last_portb_write = 0xff; + state->sound_fifo_in = state->sound_fifo_out = 0; + state->last_portb_write = 0xff; /* turn off channel A on AY8910 #0 because it is used as a low-pass filter */ ay8910_set_volume(machine->device("ay1"), 0, 0); diff --git a/src/mame/audio/cps3.c b/src/mame/audio/cps3.c index a5ebecafa22..5d359db6246 100644 --- a/src/mame/audio/cps3.c +++ b/src/mame/audio/cps3.c @@ -40,7 +40,7 @@ static STREAM_UPDATE( cps3_stream_update ) // the actual 'user5' region only exists on the nocd sets, on the others it's allocated in the initialization. // it's a shared gfx/sound region, so can't be allocated as part of the sound device. - state->base = (INT8*)cps3_user5region; + state->base = (INT8*)device->machine->driver_data()->user5region; /* Clear the buffers */ memset(outputs[0], 0, samples*sizeof(*outputs[0])); diff --git a/src/mame/drivers/86lions.c b/src/mame/drivers/86lions.c index f4489891f35..0a8bf8e1e02 100644 --- a/src/mame/drivers/86lions.c +++ b/src/mame/drivers/86lions.c @@ -33,7 +33,17 @@ Changes 02/06/2009 - Palindrome #include "sound/ay8910.h" #include "machine/6522via.h" -static UINT8 *lions_vram; + +class _86lions_state : public driver_device +{ +public: + _86lions_state(running_machine &machine, const driver_device_config_base &config) + : driver_device(machine, config) { } + + UINT8 *lions_vram; +}; + + static VIDEO_START(lions) { @@ -41,6 +51,7 @@ static VIDEO_START(lions) static VIDEO_UPDATE(lions) { + _86lions_state *state = screen->machine->driver_data<_86lions_state>(); const gfx_element *gfx = screen->machine->gfx[0]; int count = 0; @@ -50,7 +61,7 @@ static VIDEO_UPDATE(lions) { for (x=0;x<38;x++) { - int tile = lions_vram[count+1]|lions_vram[count]<<8; + int tile = state->lions_vram[count+1]|state->lions_vram[count]<<8; tile&=0x1ff; //int colour = tile>>12; drawgfx_opaque(bitmap,cliprect,gfx,tile,0,0,0,x*8,y*8); @@ -75,7 +86,7 @@ static READ8_HANDLER( test_r ) static ADDRESS_MAP_START( lions_map, ADDRESS_SPACE_PROGRAM, 8 ) - AM_RANGE(0x0000, 0x07ff) AM_RAM AM_BASE(&lions_vram) + AM_RANGE(0x0000, 0x07ff) AM_RAM AM_BASE_MEMBER(_86lions_state, lions_vram) AM_RANGE(0x0800, 0x0fff) AM_RAM AM_RANGE(0x1800, 0x1800) AM_DEVWRITE("crtc", mc6845_address_w) AM_RANGE(0x1801, 0x1801) AM_DEVREADWRITE("crtc", mc6845_register_r, mc6845_register_w) @@ -340,7 +351,7 @@ static PALETTE_INIT( lions ) } } -static MACHINE_CONFIG_START( lions, driver_device ) +static MACHINE_CONFIG_START( lions, _86lions_state ) /* basic machine hardware */ MCFG_CPU_ADD("maincpu", M6809, MAIN_CLOCK/4) /* 3 MHz.(guess) */ MCFG_CPU_PROGRAM_MAP(lions_map) diff --git a/src/mame/drivers/aristmk4.c b/src/mame/drivers/aristmk4.c index d339a82a892..e7c304a3b80 100644 --- a/src/mame/drivers/aristmk4.c +++ b/src/mame/drivers/aristmk4.c @@ -107,27 +107,37 @@ #include "machine/nvram.h" -int rtc_address_strobe = 0; -int rtc_data_strobe = 0; +class aristmk4_state : public driver_device +{ +public: + aristmk4_state(running_machine &machine, const driver_device_config_base &config) + : driver_device(machine, config) { } + + int rtc_address_strobe; + int rtc_data_strobe; + device_t *samples; + UINT8 *shapeRomPtr; + UINT8 shapeRom[0xc000]; + UINT8 *mkiv_vram; + UINT8 *nvram; + UINT8 psg_data; + int ay8910_1; + int ay8910_2; + int u3_p0_w; + UINT8 cgdrsw; + UINT8 ripple; + int hopper_motor; + int inscrd; + int cashcade_c; +}; + + + -device_t *samples; -UINT8 *shapeRomPtr; // pointer to tile_gfx shape roms -UINT8 shapeRom[0xc000]; // shaperom restore array. -static UINT8 *mkiv_vram; -static UINT8 *nvram; // backup -static UINT8 psg_data; -static int ay8910_1; -static int ay8910_2; -static int u3_p0_w; -static UINT8 cgdrsw; -static UINT8 ripple; -static int hopper_motor; -static int inscrd; /* Partial Caschcade protocol */ -static int cashcade_p[] ={0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf0}; -static int cashcade_c = 0; +static const UINT8 cashcade_p[] ={0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf0}; static VIDEO_START(aristmk4) { @@ -140,6 +150,7 @@ static VIDEO_START(aristmk4) INLINE void uBackgroundColour(running_machine *machine) { + aristmk4_state *state = machine->driver_data(); /* SW7 can be set when the main door is open, this allows the colours for the background to be adjusted whilst the machine is running. @@ -150,29 +161,30 @@ INLINE void uBackgroundColour(running_machine *machine) { case 0x00: // restore defaults - memcpy(shapeRomPtr,shapeRom, sizeof(shapeRom)); // restore defaults, both switches off + memcpy(state->shapeRomPtr,state->shapeRom, sizeof(state->shapeRom)); // restore defaults, both switches off // OE enabled on both shapes break; case 0x01: // unselect U22 via SW7 . OE on U22 is low. - memset(&shapeRomPtr[0x4000],0xff,0x2000); // fill unused space with 0xff - memcpy(&shapeRomPtr[0xa000],&shapeRom[0xa000], 0x2000); // restore defaults here + memset(&state->shapeRomPtr[0x4000],0xff,0x2000); // fill unused space with 0xff + memcpy(&state->shapeRomPtr[0xa000],&state->shapeRom[0xa000], 0x2000); // restore defaults here break; case 0x02: // unselect U47 via SW7 . OE on U47 is low. - memcpy(&shapeRomPtr[0x4000],&shapeRom[0x4000], 0x2000); - memset(&shapeRomPtr[0xa000],0xff,0x2000); + memcpy(&state->shapeRomPtr[0x4000],&state->shapeRom[0x4000], 0x2000); + memset(&state->shapeRomPtr[0xa000],0xff,0x2000); break; case 0x03: // unselect U47 & u22 via SW7. both output enable low. - memset(&shapeRomPtr[0x4000],0xff,0x2000); - memset(&shapeRomPtr[0xa000],0xff,0x2000); + memset(&state->shapeRomPtr[0x4000],0xff,0x2000); + memset(&state->shapeRomPtr[0xa000],0xff,0x2000); break; } } static VIDEO_UPDATE(aristmk4) { + aristmk4_state *state = screen->machine->driver_data(); const gfx_element *gfx = screen->machine->gfx[0]; int x,y; int count = 0; @@ -186,14 +198,14 @@ static VIDEO_UPDATE(aristmk4) { for (x=38;x--;) { - color = ((mkiv_vram[count]) & 0xe0) >> 5; - tile = (mkiv_vram[count+1]|mkiv_vram[count]<<8) & 0x3ff; - bgtile = (mkiv_vram[count+1]|mkiv_vram[count]<<8) & 0xff; // first 256 tiles + color = ((state->mkiv_vram[count]) & 0xe0) >> 5; + tile = (state->mkiv_vram[count+1]|state->mkiv_vram[count]<<8) & 0x3ff; + bgtile = (state->mkiv_vram[count+1]|state->mkiv_vram[count]<<8) & 0xff; // first 256 tiles uBackgroundColour(screen->machine); // read sw7 gfx_element_decode(gfx, bgtile); // force the machine to update only the first 256 tiles. // as we only update the background, not the entire display. - flipx = ((mkiv_vram[count]) & 0x04); - flipy = ((mkiv_vram[count]) & 0x08); + flipx = ((state->mkiv_vram[count]) & 0x04); + flipy = ((state->mkiv_vram[count]) & 0x08); drawgfx_opaque(bitmap,cliprect,gfx,tile,color,flipx,flipy,(38-x-1)<<3,(27-y-1)<<3); count+=2; } @@ -203,42 +215,47 @@ static VIDEO_UPDATE(aristmk4) static READ8_HANDLER(ldsw) { + aristmk4_state *state = space->machine->driver_data(); int U3_p2_ret= input_port_read(space->machine, "5002"); if(U3_p2_ret & 0x1) { return 0; } - return cgdrsw = input_port_read(space->machine, "CGDRSW"); + return state->cgdrsw = input_port_read(space->machine, "CGDRSW"); } static READ8_HANDLER(cgdrr) { + aristmk4_state *state = space->machine->driver_data(); - if(cgdrsw) // is the LC closed + if(state->cgdrsw) // is the LC closed { - return ripple; // return a positive value from the ripple counter + return state->ripple; // return a positive value from the state->ripple counter } return 0x0; // otherwise the counter outputs are set low. } static WRITE8_HANDLER(cgdrw) { + aristmk4_state *state = space->machine->driver_data(); - ripple = data; + state->ripple = data; } static WRITE8_HANDLER(u3_p0) { + aristmk4_state *state = space->machine->driver_data(); - u3_p0_w = data; - //logerror("u3_p0_w: %02X\n",u3_p0_w); + state->u3_p0_w = data; + //logerror("u3_p0_w: %02X\n",state->u3_p0_w); } static READ8_HANDLER(u3_p2) { + aristmk4_state *state = space->machine->driver_data(); int u3_p2_ret= input_port_read(space->machine, "5002"); int u3_p3_ret= input_port_read(space->machine, "5003"); @@ -246,18 +263,18 @@ static READ8_HANDLER(u3_p2) output_set_lamp_value(19, (u3_p2_ret >> 4) & 1); //auditkey light output_set_lamp_value(20, (u3_p3_ret >> 2) & 1); //jackpotkey light - if (u3_p0_w&0x20) // DOPTE on + if (state->u3_p0_w&0x20) // DOPTE on { if (u3_p3_ret&0x02) // door closed u3_p2_ret = u3_p2_ret^0x08; // DOPTI on } - if (inscrd==0) + if (state->inscrd==0) { - inscrd=input_port_read(space->machine, "insertcoin"); + state->inscrd=input_port_read(space->machine, "insertcoin"); } - if (inscrd==1) + if (state->inscrd==1) u3_p2_ret=u3_p2_ret^0x02; return u3_p2_ret; @@ -297,8 +314,9 @@ static READ8_HANDLER(mkiv_pia_ina) static WRITE8_HANDLER(mkiv_pia_outa) { + aristmk4_state *state = space->machine->driver_data(); mc146818_device *mc = space->machine->device("rtc"); - if(rtc_data_strobe) + if(state->rtc_data_strobe) { mc->write(*space,1,data); //logerror("rtc protocol write data: %02X\n",data); @@ -316,7 +334,8 @@ static WRITE8_HANDLER(mkiv_pia_outa) //output ca2 static WRITE8_DEVICE_HANDLER(mkiv_pia_ca2) { - rtc_address_strobe = data; + aristmk4_state *state = device->machine->driver_data(); + state->rtc_address_strobe = data; // logerror("address strobe %02X\n", address_strobe); } @@ -324,7 +343,8 @@ static WRITE8_DEVICE_HANDLER(mkiv_pia_ca2) //output cb2 static WRITE8_DEVICE_HANDLER(mkiv_pia_cb2) { - rtc_data_strobe = data; + aristmk4_state *state = device->machine->driver_data(); + state->rtc_data_strobe = data; //logerror("data strobe: %02X\n", data); } @@ -333,6 +353,7 @@ static WRITE8_DEVICE_HANDLER(mkiv_pia_cb2) //output b static WRITE8_DEVICE_HANDLER(mkiv_pia_outb) { + aristmk4_state *state = device->machine->driver_data(); UINT8 emet[5]; int i = 0; @@ -351,7 +372,7 @@ static WRITE8_DEVICE_HANDLER(mkiv_pia_outb) if(emet[i]) { //logerror("Mechanical meter %d pulse: %02d\n",i+1, emet[i]); - sample_start(samples,i,0, FALSE); // pulse sound for mechanical meters + sample_start(state->samples,i,0, FALSE); // pulse sound for mechanical meters } } @@ -383,15 +404,17 @@ VERSATILE INTERFACE ADAPTER CONFIGURATION static TIMER_CALLBACK(coin_input_reset) { + aristmk4_state *state = machine->driver_data(); - inscrd=0; //reset credit input after 150msec + state->inscrd=0; //reset credit input after 150msec } static TIMER_CALLBACK(hopper_reset) { + aristmk4_state *state = machine->driver_data(); - hopper_motor=0x01; + state->hopper_motor=0x01; } @@ -400,15 +423,16 @@ static TIMER_CALLBACK(hopper_reset) static READ8_DEVICE_HANDLER(via_a_r) { + aristmk4_state *state = device->machine->driver_data(); int psg_ret=0; - if (ay8910_1&0x03) // SW1 read. + if (state->ay8910_1&0x03) // SW1 read. { psg_ret = ay8910_r(device->machine->device("ay1"), 0); //logerror("PSG porta ay1 returned %02X\n",psg_ret); } - else if (ay8910_2&0x03) //i don't think we read anything from Port A on ay2, Can be removed once game works ok. + else if (state->ay8910_2&0x03) //i don't think we read anything from Port A on ay2, Can be removed once game works ok. { psg_ret = ay8910_r(device->machine->device("ay2"), 0); //logerror("PSG porta ay2 returned %02X\n",psg_ret); @@ -420,6 +444,7 @@ static READ8_DEVICE_HANDLER(via_a_r) static READ8_DEVICE_HANDLER(via_b_r) { + aristmk4_state *state = device->machine->driver_data(); int ret=input_port_read(device->machine, "via_port_b"); @@ -432,7 +457,7 @@ static READ8_DEVICE_HANDLER(via_b_r) /* Coin input... CBOPT2 goes LOW, then the optic detectors OPTA1 / OPTB1 detect the coin passing */ /* The timer causes one credit, per 150ms or so... */ - switch(inscrd) + switch(state->inscrd) { case 0x00: @@ -440,12 +465,12 @@ static READ8_DEVICE_HANDLER(via_b_r) case 0x01: ret=ret^0x10; - inscrd++; + state->inscrd++; break; case 0x02: ret=ret^0x20; - inscrd++; + state->inscrd++; device->machine->scheduler().timer_set(attotime::from_msec(150), FUNC(coin_input_reset)); break; @@ -456,12 +481,12 @@ static READ8_DEVICE_HANDLER(via_b_r) // if user presses collect.. send coins to hopper. - switch(hopper_motor) + switch(state->hopper_motor) { case 0x00: ret=ret^0x40; device->machine->scheduler().timer_set(attotime::from_msec(175), FUNC(hopper_reset)); - hopper_motor=0x02; + state->hopper_motor=0x02; break; case 0x01: break; //default @@ -476,37 +501,39 @@ static READ8_DEVICE_HANDLER(via_b_r) static WRITE8_DEVICE_HANDLER(via_a_w) -{ //via_b_w will handle sending the data to the ay8910, so just write the data for it to use later +{ + aristmk4_state *state = device->machine->driver_data(); //via_b_w will handle sending the data to the ay8910, so just write the data for it to use later //logerror("VIA port A write %02X\n",data); - psg_data = data; + state->psg_data = data; } static WRITE8_DEVICE_HANDLER(via_b_w) { - ay8910_1 = ( data & 0x0F ) ; //only need first 4 bits per schematics + aristmk4_state *state = device->machine->driver_data(); + state->ay8910_1 = ( data & 0x0F ) ; //only need first 4 bits per schematics //NOTE: when bit 4 is off, we write to AY1, when bit 4 is on, we write to AY2 - ay8910_2 = ay8910_1; + state->ay8910_2 = state->ay8910_1; - if ( ay8910_2 & 0x08 ) // is bit 4 on ? + if ( state->ay8910_2 & 0x08 ) // is bit 4 on ? { - ay8910_2 = (ay8910_2 | 0x02) ; // bit 2 is turned on as bit 4 hooks to bit 2 in the schematics - ay8910_1 = 0x00; // write only to ay2 + state->ay8910_2 = (state->ay8910_2 | 0x02) ; // bit 2 is turned on as bit 4 hooks to bit 2 in the schematics + state->ay8910_1 = 0x00; // write only to ay2 } else { - ay8910_2 = 0x00; // write only to ay1 + state->ay8910_2 = 0x00; // write only to ay1 } //only need bc1/bc2 and bdir so drop bit 4. - ay8910_1 = (ay8910_1 & 0x07); - ay8910_2 = (ay8910_2 & 0x07); + state->ay8910_1 = (state->ay8910_1 & 0x07); + state->ay8910_2 = (state->ay8910_2 & 0x07); //PSG ay1 - switch(ay8910_1) + switch(state->ay8910_1) { case 0x00: //INACT -Nothing to do here. Inactive PSG @@ -517,26 +544,26 @@ static WRITE8_DEVICE_HANDLER(via_b_w) case 0x06: //WRITE { - ay8910_data_w( device->machine->device("ay1"), 0 , psg_data ); - //logerror("VIA Port A write data ay1: %02X\n",psg_data); + ay8910_data_w( device->machine->device("ay1"), 0 , state->psg_data ); + //logerror("VIA Port A write data ay1: %02X\n",state->psg_data); break; } case 0x07: //LATCH Address (set register) { - ay8910_address_w( device->machine->device("ay1"), 0 , psg_data ); - //logerror("VIA Port B write register ay1: %02X\n",psg_data); + ay8910_address_w( device->machine->device("ay1"), 0 , state->psg_data ); + //logerror("VIA Port B write register ay1: %02X\n",state->psg_data); break; } default: - //logerror("Unknown PSG state on ay1: %02X\n",ay8910_1); + //logerror("Unknown PSG state on ay1: %02X\n",state->ay8910_1); break; } //PSG ay2 - switch(ay8910_2) + switch(state->ay8910_2) { case 0x00: //INACT - Nothing to do here. Inactive PSG @@ -550,20 +577,20 @@ static WRITE8_DEVICE_HANDLER(via_b_w) case 0x06: //WRITE { - ay8910_data_w( device->machine->device("ay2"), 0 , psg_data ); - //logerror("VIA Port A write data ay2: %02X\n",psg_data); + ay8910_data_w( device->machine->device("ay2"), 0 , state->psg_data ); + //logerror("VIA Port A write data ay2: %02X\n",state->psg_data); break; } case 0x07: //LATCH Address (set register) { - ay8910_address_w( device->machine->device("ay2"), 0 , psg_data ); - //logerror("VIA Port B write register ay2: %02X\n",psg_data); + ay8910_address_w( device->machine->device("ay2"), 0 , state->psg_data ); + //logerror("VIA Port B write register ay2: %02X\n",state->psg_data); break; } default: - //logerror("Unknown PSG state on ay2: %02X\n",ay8910_2); + //logerror("Unknown PSG state on ay2: %02X\n",state->ay8910_2); break; } @@ -597,14 +624,15 @@ static WRITE8_DEVICE_HANDLER(via_ca2_w) static WRITE8_DEVICE_HANDLER(via_cb2_w) { + aristmk4_state *state = device->machine->driver_data(); // CB2 = hopper motor (HOPMO1). When it is 0x01, it is not running (active low) // when it goes to 0, we're expecting to coins to be paid out, handled in via_b_r // as soon as it is 1, HOPCO1 to remain 'ON' if (data==0x01) - hopper_motor=data; - else if (hopper_motor<0x02) - hopper_motor=data; + state->hopper_motor=data; + else if (state->hopper_motor<0x02) + state->hopper_motor=data; } @@ -658,8 +686,9 @@ static WRITE8_DEVICE_HANDLER(zn434_w) static READ8_HANDLER(cashcade_r) { + aristmk4_state *state = space->machine->driver_data(); /* work around for cashcade games */ - return cashcade_p[(cashcade_c++)%15]; + return cashcade_p[(state->cashcade_c++)%15]; } static WRITE8_HANDLER(mk4_printer_w) @@ -673,7 +702,7 @@ static READ8_HANDLER(mk4_printer_r) } static ADDRESS_MAP_START( aristmk4_map, ADDRESS_SPACE_PROGRAM, 8 ) - AM_RANGE(0x0000, 0x07ff) AM_RAM AM_BASE(&mkiv_vram) // video ram - chips U49 / U50 + AM_RANGE(0x0000, 0x07ff) AM_RAM AM_BASE_MEMBER(aristmk4_state, mkiv_vram) // video ram - chips U49 / U50 AM_RANGE(0x0800, 0x17ff) AM_RAM AM_RANGE(0x1800, 0x1800) AM_DEVWRITE("crtc", mc6845_address_w) AM_RANGE(0x1801, 0x1801) AM_DEVREADWRITE("crtc", mc6845_register_r, mc6845_register_w) @@ -1168,16 +1197,18 @@ static PALETTE_INIT( aristmk4 ) static DRIVER_INIT( aristmk4 ) { - shapeRomPtr = (UINT8 *)machine->region("tile_gfx")->base(); - memcpy(shapeRom,shapeRomPtr,sizeof(shapeRom)); // back up - nvram = auto_alloc_array(machine, UINT8, 0x1000); + aristmk4_state *state = machine->driver_data(); + state->shapeRomPtr = (UINT8 *)machine->region("tile_gfx")->base(); + memcpy(state->shapeRom,state->shapeRomPtr,sizeof(state->shapeRom)); // back up + state->nvram = auto_alloc_array(machine, UINT8, 0x1000); } static MACHINE_START( aristmk4 ) { + aristmk4_state *state = machine->driver_data(); - samples = machine->device("samples"); - state_save_register_global_pointer(machine, nvram, 0x1000); // nvram + state->samples = machine->device("samples"); + state_save_register_global_pointer(machine, state->nvram, 0x1000); // state->nvram } @@ -1197,7 +1228,7 @@ static MACHINE_RESET( aristmk4 ) } -static MACHINE_CONFIG_START( aristmk4, driver_device ) +static MACHINE_CONFIG_START( aristmk4, aristmk4_state ) /* basic machine hardware */ MCFG_CPU_ADD("maincpu", M6809, MAIN_CLOCK/8) // 1.5mhz (goldenc needs a bit faster for some reason) diff --git a/src/mame/drivers/aristmk5.c b/src/mame/drivers/aristmk5.c index 4a48f744f22..173aec332b4 100644 --- a/src/mame/drivers/aristmk5.c +++ b/src/mame/drivers/aristmk5.c @@ -63,20 +63,33 @@ #include "includes/archimds.h" //#include "machine/i2cmem.h" -static emu_timer *mk5_2KHz_timer; -static UINT8 ext_latch; + +class aristmk5_state : public driver_device +{ +public: + aristmk5_state(running_machine &machine, const driver_device_config_base &config) + : driver_device(machine, config) { } + + emu_timer *mk5_2KHz_timer; + UINT8 ext_latch; + UINT8 flyback; +}; + + static WRITE32_HANDLER( mk5_ext_latch_w ) { + aristmk5_state *state = space->machine->driver_data(); /* this banks "something" */ - ext_latch = data & 1; + state->ext_latch = data & 1; } static READ32_HANDLER( ext_timer_latch_r ) { + aristmk5_state *state = space->machine->driver_data(); /* reset 2KHz timer */ ioc_regs[IRQ_STATUS_A] &= 0xfe; - mk5_2KHz_timer->adjust(attotime::from_hz(2000)); + state->mk5_2KHz_timer->adjust(attotime::from_hz(2000)); return 0xffffffff; //value doesn't matter apparently } @@ -84,7 +97,8 @@ static READ32_HANDLER( ext_timer_latch_r ) /* same as plain AA but with the I2C unconnected */ static READ32_HANDLER( mk5_ioc_r ) { - static UINT32 ioc_addr; + aristmk5_state *state = space->machine->driver_data(); + UINT32 ioc_addr; ioc_addr = offset*4; ioc_addr >>= 16; @@ -92,15 +106,14 @@ static READ32_HANDLER( mk5_ioc_r ) if(((ioc_addr == 0x20) || (ioc_addr == 0x30)) && (offset & 0x1f) == 0) { - static UINT8 flyback; //internal name for vblank here int vert_pos; vert_pos = space->machine->primary_screen->vpos(); - flyback = (vert_pos <= vidc_regs[VIDC_VDSR] || vert_pos >= vidc_regs[VIDC_VDER]) ? 0x80 : 0x00; + state->flyback = (vert_pos <= vidc_regs[VIDC_VDSR] || vert_pos >= vidc_regs[VIDC_VDER]) ? 0x80 : 0x00; //i2c_data = (i2cmem_sda_read(space->machine->device("i2cmem")) & 1); - return (flyback) | (ioc_regs[CONTROL] & 0x7c) | (1<<1) | 1; + return (state->flyback) | (ioc_regs[CONTROL] & 0x7c) | (1<<1) | 1; } return archimedes_ioc_r(space,offset,mem_mask); @@ -108,13 +121,14 @@ static READ32_HANDLER( mk5_ioc_r ) static WRITE32_HANDLER( mk5_ioc_w ) { - static UINT32 ioc_addr; + aristmk5_state *state = space->machine->driver_data(); + UINT32 ioc_addr; ioc_addr = offset*4; ioc_addr >>= 16; ioc_addr &= 0x37; - if(!ext_latch) + if(!state->ext_latch) { if(((ioc_addr == 0x20) || (ioc_addr == 0x30)) && (offset & 0x1f) == 0) { @@ -219,25 +233,28 @@ static DRIVER_INIT( aristmk5 ) static TIMER_CALLBACK( mk5_2KHz_callback ) { + aristmk5_state *state = machine->driver_data(); ioc_regs[4] |= 1; - mk5_2KHz_timer->adjust(attotime::never); + state->mk5_2KHz_timer->adjust(attotime::never); } static MACHINE_START( aristmk5 ) { + aristmk5_state *state = machine->driver_data(); archimedes_init(machine); // reset the DAC to centerline //dac_signed_data_w(machine->device("dac"), 0x80); - mk5_2KHz_timer = machine->scheduler().timer_alloc(FUNC(mk5_2KHz_callback)); + state->mk5_2KHz_timer = machine->scheduler().timer_alloc(FUNC(mk5_2KHz_callback)); } static MACHINE_RESET( aristmk5 ) { + aristmk5_state *state = machine->driver_data(); archimedes_reset(machine); - mk5_2KHz_timer->adjust(attotime::from_hz(2000)); + state->mk5_2KHz_timer->adjust(attotime::from_hz(2000)); ioc_regs[IRQ_STATUS_B] |= 0x40; //hack, set keyboard irq empty to be ON @@ -273,7 +290,7 @@ static const i2cmem_interface i2cmem_interface = }; #endif -static MACHINE_CONFIG_START( aristmk5, driver_device ) +static MACHINE_CONFIG_START( aristmk5, aristmk5_state ) MCFG_CPU_ADD("maincpu", ARM, 10000000) // ? MCFG_CPU_PROGRAM_MAP(aristmk5_map) diff --git a/src/mame/drivers/battlera.c b/src/mame/drivers/battlera.c index 832c5846116..aa5a29fc56f 100644 --- a/src/mame/drivers/battlera.c +++ b/src/mame/drivers/battlera.c @@ -28,7 +28,6 @@ #include "sound/c6280.h" #include "includes/battlera.h" -static int control_port_select; /******************************************************************************/ @@ -45,12 +44,14 @@ static WRITE8_HANDLER( battlera_sound_w ) static WRITE8_HANDLER( control_data_w ) { - control_port_select=data; + battlera_state *state = space->machine->driver_data(); + state->control_port_select=data; } static READ8_HANDLER( control_data_r ) { - switch (control_port_select) + battlera_state *state = space->machine->driver_data(); + switch (state->control_port_select) { case 0xfe: return input_port_read(space->machine, "IN0"); /* Player 1 */ case 0xfd: return input_port_read(space->machine, "IN1"); /* Player 2 */ @@ -83,23 +84,23 @@ ADDRESS_MAP_END /******************************************************************************/ -static int msm5205next; static void battlera_adpcm_int(device_t *device) { - static int toggle; + battlera_state *state = device->machine->driver_data(); - msm5205_data_w(device,msm5205next >> 4); - msm5205next <<= 4; + msm5205_data_w(device,state->msm5205next >> 4); + state->msm5205next <<= 4; - toggle = 1 - toggle; - if (toggle) + state->toggle = 1 - state->toggle; + if (state->toggle) cputag_set_input_line(device->machine, "audiocpu", 1, HOLD_LINE); } static WRITE8_HANDLER( battlera_adpcm_data_w ) { - msm5205next = data; + battlera_state *state = space->machine->driver_data(); + state->msm5205next = data; } static WRITE8_DEVICE_HANDLER( battlera_adpcm_reset_w ) @@ -229,7 +230,7 @@ static const c6280_interface c6280_config = "audiocpu" }; -static MACHINE_CONFIG_START( battlera, driver_device ) +static MACHINE_CONFIG_START( battlera, battlera_state ) /* basic machine hardware */ MCFG_CPU_ADD("maincpu", H6280,21477200/3) diff --git a/src/mame/drivers/bfcobra.c b/src/mame/drivers/bfcobra.c index ecd37d20526..3bc0591126f 100644 --- a/src/mame/drivers/bfcobra.c +++ b/src/mame/drivers/bfcobra.c @@ -81,6 +81,42 @@ #include "sound/ay8910.h" #include "machine/nvram.h" + +class bfcobra_state : public driver_device +{ +public: + bfcobra_state(running_machine &machine, const driver_device_config_base &config) + : driver_device(machine, config) { } + + UINT8 bank_data[4]; + UINT8 *work_ram; + UINT8 *video_ram; + UINT8 h_scroll; + UINT8 v_scroll; + UINT8 flip_8; + UINT8 flip_22; + UINT8 videomode; + UINT8 z80_m6809_line; + UINT8 m6809_z80_line; + UINT8 data_r; + UINT8 data_t; + int irq_state; + int acia_irq; + int vblank_irq; + int blitter_irq; + UINT8 z80_int; + UINT8 z80_inten; + UINT32 meter_latch; + UINT32 mux_input; + UINT32 mux_outputlatch; + UINT8 col4bit[16]; + UINT8 col3bit[16]; + UINT8 col8bit[256]; + UINT8 col7bit[256]; + UINT8 col6bit[256]; +}; + + /* Defines */ @@ -88,37 +124,6 @@ #define M6809_XTAL 1000000 -/* - Globals -*/ -static UINT8 bank_data[4]; -static UINT8 *work_ram; -static UINT8 *video_ram; -static UINT8 h_scroll; -static UINT8 v_scroll; -static UINT8 flip_8; -static UINT8 flip_22; -static UINT8 videomode; - -/* UART source/sinks */ -static UINT8 z80_m6809_line; -static UINT8 m6809_z80_line; -static UINT8 data_r; -static UINT8 data_t; - -static int irq_state; -static int acia_irq; -static int vblank_irq; -static int blitter_irq; - -static UINT8 z80_int; -static UINT8 z80_inten; - -/* EM and lamps stuff */ -static UINT32 meter_latch; -static UINT32 mux_input; -static UINT32 mux_outputlatch; - /* Function prototypes */ @@ -127,12 +132,13 @@ INLINE void z80_bank(running_machine *machine, int num, int data); static void update_irqs(running_machine *machine) { - int newstate = blitter_irq || vblank_irq || acia_irq; + bfcobra_state *state = machine->driver_data(); + int newstate = state->blitter_irq || state->vblank_irq || state->acia_irq; - if (newstate != irq_state) + if (newstate != state->irq_state) { - irq_state = newstate; - cputag_set_input_line(machine, "maincpu", 0, irq_state ? ASSERT_LINE : CLEAR_LINE); + state->irq_state = newstate; + cputag_set_input_line(machine, "maincpu", 0, state->irq_state ? ASSERT_LINE : CLEAR_LINE); } } @@ -292,37 +298,34 @@ static const UINT8 col3bit_default[16]= RED_7 | GREEN_7 | BLUE_3 }; -static UINT8 col4bit[16]; -static UINT8 col3bit[16]; -static UINT8 col8bit[256]; -static UINT8 col7bit[256]; -static UINT8 col6bit[256]; static const UINT8 col76index[] = {0, 2, 4, 7}; static VIDEO_START( bfcobra ) { + bfcobra_state *state = machine->driver_data(); int i; - memcpy(col4bit, col4bit_default, sizeof(col4bit)); - memcpy(col3bit, col3bit_default, sizeof(col3bit)); + memcpy(state->col4bit, col4bit_default, sizeof(state->col4bit)); + memcpy(state->col3bit, col3bit_default, sizeof(state->col3bit)); for (i = 0; i < 256; ++i) { UINT8 col; - col8bit[i] = i; + state->col8bit[i] = i; col = i & 0x7f; col = (col & 0x1f) | (col76index[ ( (col & 0x60) >> 5 ) & 3] << 5); - col7bit[i] = col; + state->col7bit[i] = col; col = (col & 3) | (col76index[( (col & 0x0c) >> 2) & 3] << 2 ) | (col76index[( (col & 0x30) >> 4) & 3] << 5 ); - col6bit[i] = col; + state->col6bit[i] = col; } } static VIDEO_UPDATE( bfcobra ) { + bfcobra_state *state = screen->machine->driver_data(); int x, y; UINT8 *src; UINT32 *dest; @@ -332,39 +335,39 @@ static VIDEO_UPDATE( bfcobra ) /* Select screen has to be programmed into two registers */ /* No idea what happens if the registers are different */ - if (flip_8 & 0x40 && flip_22 & 0x40) + if (state->flip_8 & 0x40 && state->flip_22 & 0x40) offset = 0x10000; else offset = 0; - if(videomode & 0x20) + if(state->videomode & 0x20) { - hirescol = col3bit; - lorescol = col7bit; + hirescol = state->col3bit; + lorescol = state->col7bit; } - else if(videomode & 0x40) + else if(state->videomode & 0x40) { - hirescol = col4bit; - lorescol = col6bit; + hirescol = state->col4bit; + lorescol = state->col6bit; } else { - hirescol = col4bit; - lorescol = col8bit; + hirescol = state->col4bit; + lorescol = state->col8bit; } for (y = cliprect->min_y; y <= cliprect->max_y; ++y) { - UINT16 y_offset = (y + v_scroll) * 256; - src = &video_ram[offset + y_offset]; + UINT16 y_offset = (y + state->v_scroll) * 256; + src = &state->video_ram[offset + y_offset]; dest = BITMAP_ADDR32(bitmap, y, 0); for (x = cliprect->min_x; x <= cliprect->max_x / 2; ++x) { - UINT8 x_offset = x + h_scroll; + UINT8 x_offset = x + state->h_scroll; UINT8 pen = *(src + x_offset); - if ( ( videomode & 0x81 ) == 1 || (videomode & 0x80 && pen & 0x80) ) + if ( ( state->videomode & 0x81 ) == 1 || (state->videomode & 0x80 && pen & 0x80) ) { *dest++ = screen->machine->pens[hirescol[pen & 0x0f]]; *dest++ = screen->machine->pens[hirescol[(pen >> 4) & 0x0f]]; @@ -382,6 +385,7 @@ static VIDEO_UPDATE( bfcobra ) INLINE UINT8* blitter_get_addr(running_machine *machine, UINT32 addr) { + bfcobra_state *state = machine->driver_data(); if (addr < 0x10000) { /* Is this region fixed? */ @@ -390,17 +394,17 @@ INLINE UINT8* blitter_get_addr(running_machine *machine, UINT32 addr) else if(addr < 0x20000) { addr &= 0xffff; - addr += (bank_data[0] & 1) ? 0x10000 : 0; + addr += (state->bank_data[0] & 1) ? 0x10000 : 0; - return (UINT8*)(machine->region("user1")->base() + addr + ((bank_data[0] >> 1) * 0x20000)); + return (UINT8*)(machine->region("user1")->base() + addr + ((state->bank_data[0] >> 1) * 0x20000)); } else if (addr >= 0x20000 && addr < 0x40000) { - return (UINT8*)&video_ram[addr - 0x20000]; + return (UINT8*)&state->video_ram[addr - 0x20000]; } else { - return (UINT8*)&work_ram[addr - 0x40000]; + return (UINT8*)&state->work_ram[addr - 0x40000]; } } @@ -823,6 +827,7 @@ static WRITE8_HANDLER( ramdac_w ) static READ8_HANDLER( chipset_r ) { + bfcobra_state *state = space->machine->driver_data(); UINT8 val = 0xff; switch(offset) @@ -831,18 +836,18 @@ static READ8_HANDLER( chipset_r ) case 2: case 3: { - val = bank_data[offset]; + val = state->bank_data[offset]; break; } case 6: { /* TODO */ - val = vblank_irq << 4; + val = state->vblank_irq << 4; break; } case 7: { - vblank_irq = 0; + state->vblank_irq = 0; val = 0x1; /* TODO */ @@ -877,6 +882,7 @@ static READ8_HANDLER( chipset_r ) static WRITE8_HANDLER( chipset_w ) { + bfcobra_state *state = space->machine->driver_data(); switch (offset) { case 0x01: @@ -887,42 +893,42 @@ static WRITE8_HANDLER( chipset_w ) popmessage("%x: Unusual bank access (%x)\n", cpu_get_previouspc(space->cpu), data); data &= 0x3f; - bank_data[offset] = data; + state->bank_data[offset] = data; z80_bank(space->machine, offset, data); break; } case 0x08: { - flip_8 = data; + state->flip_8 = data; break; } case 9: - videomode = data; + state->videomode = data; break; case 0x0B: { - h_scroll = data; + state->h_scroll = data; break; } case 0x0C: { - v_scroll = data; + state->v_scroll = data; break; } case 0x0E: { - col4bit[5] = data; - col3bit[5] = data; - col3bit[5 + 8] = data; + state->col4bit[5] = data; + state->col3bit[5] = data; + state->col3bit[5 + 8] = data; break; } case 0x0f: { - col4bit[6] = data; - col3bit[6] = data; - col3bit[6 + 8] = data; + state->col4bit[6] = data; + state->col3bit[6] = data; + state->col3bit[6 + 8] = data; break; } case 0x18: @@ -953,7 +959,7 @@ static WRITE8_HANDLER( chipset_w ) } case 0x22: { - flip_22 = data; + state->flip_22 = data; break; } default: @@ -965,30 +971,32 @@ static WRITE8_HANDLER( chipset_w ) INLINE void z80_bank(running_machine *machine, int num, int data) { + bfcobra_state *state = machine->driver_data(); static const char * const bank_names[] = { "bank1", "bank2", "bank3" }; if (data < 0x08) { - UINT32 offset = ((bank_data[0] >> 1) * 0x20000) + ((0x4000 * data) ^ ((bank_data[0] & 1) ? 0 : 0x10000)); + UINT32 offset = ((state->bank_data[0] >> 1) * 0x20000) + ((0x4000 * data) ^ ((state->bank_data[0] & 1) ? 0 : 0x10000)); memory_set_bankptr(machine, bank_names[num - 1], machine->region("user1")->base() + offset); } else if (data < 0x10) { - memory_set_bankptr(machine, bank_names[num - 1], &video_ram[(data - 0x08) * 0x4000]); + memory_set_bankptr(machine, bank_names[num - 1], &state->video_ram[(data - 0x08) * 0x4000]); } else { - memory_set_bankptr(machine, bank_names[num - 1], &work_ram[(data - 0x10) * 0x4000]); + memory_set_bankptr(machine, bank_names[num - 1], &state->work_ram[(data - 0x10) * 0x4000]); } } static WRITE8_HANDLER( rombank_w ) { - bank_data[0] = data; - z80_bank(space->machine, 1, bank_data[1]); - z80_bank(space->machine, 2, bank_data[2]); - z80_bank(space->machine, 3, bank_data[3]); + bfcobra_state *state = space->machine->driver_data(); + state->bank_data[0] = data; + z80_bank(space->machine, 1, state->bank_data[1]); + z80_bank(space->machine, 2, state->bank_data[2]); + z80_bank(space->machine, 3, state->bank_data[3]); } @@ -1281,6 +1289,7 @@ WRITE8_HANDLER( fd_ctrl_w ) static MACHINE_RESET( bfcobra ) { + bfcobra_state *state = machine->driver_data(); unsigned int pal; for (pal = 0; pal < 256; ++pal) @@ -1288,11 +1297,11 @@ static MACHINE_RESET( bfcobra ) palette_set_color_rgb(machine, pal, pal3bit((pal>>5)&7), pal3bit((pal>>2)&7), pal2bit(pal&3)); } - bank_data[0] = 1; + state->bank_data[0] = 1; memset(&ramdac, 0, sizeof(ramdac)); reset_fdc(); - irq_state = blitter_irq = vblank_irq = acia_irq = 0; + state->irq_state = state->blitter_irq = state->vblank_irq = state->acia_irq = 0; } /*************************************************************************** @@ -1352,16 +1361,18 @@ static READ8_HANDLER( int_latch_r ) /* TODO */ static READ8_HANDLER( meter_r ) { - return meter_latch; + bfcobra_state *state = space->machine->driver_data(); + return state->meter_latch; } /* TODO: This is borrowed from Scorpion 1 */ static WRITE8_HANDLER( meter_w ) { + bfcobra_state *state = space->machine->driver_data(); int i; - int changed = meter_latch ^ data; + int changed = state->meter_latch ^ data; - meter_latch = data; + state->meter_latch = data; /* When a meter is triggered, the current drawn is sensed. If a meter @@ -1380,20 +1391,22 @@ static WRITE8_HANDLER( meter_w ) /* TODO */ static READ8_HANDLER( latch_r ) { - return mux_input; + bfcobra_state *state = space->machine->driver_data(); + return state->mux_input; } static WRITE8_HANDLER( latch_w ) { + bfcobra_state *state = space->machine->driver_data(); /* TODO: This is borrowed from Scorpion 1 */ switch(offset) { case 0: { - int changed = mux_outputlatch ^ data; + int changed = state->mux_outputlatch ^ data; static const char *const port[] = { "STROBE0", "STROBE1", "STROBE2", "STROBE3", "STROBE4", "STROBE5", "STROBE6", "STROBE7" }; - mux_outputlatch = data; + state->mux_outputlatch = data; /* Clock has changed */ if (changed & 0x08) @@ -1402,7 +1415,7 @@ static WRITE8_HANDLER( latch_w ) /* Clock is low */ if (!(data & 0x08)) - mux_input = input_port_read(space->machine, port[input_strobe]); + state->mux_input = input_port_read(space->machine, port[input_strobe]); } break; } @@ -1561,11 +1574,12 @@ INPUT_PORTS_END */ static void init_ram(running_machine *machine) { + bfcobra_state *state = machine->driver_data(); /* 768kB work RAM */ - work_ram = auto_alloc_array_clear(machine, UINT8, 0xC0000); + state->work_ram = auto_alloc_array_clear(machine, UINT8, 0xC0000); /* 128kB video RAM */ - video_ram = auto_alloc_array_clear(machine, UINT8, 0x20000); + state->video_ram = auto_alloc_array_clear(machine, UINT8, 0x20000); } /* @@ -1574,17 +1588,20 @@ static void init_ram(running_machine *machine) static READ_LINE_DEVICE_HANDLER( z80_acia_rx_r ) { - return m6809_z80_line; + bfcobra_state *state = device->machine->driver_data(); + return state->m6809_z80_line; } static WRITE_LINE_DEVICE_HANDLER( z80_acia_tx_w ) { - z80_m6809_line = state; + bfcobra_state *drvstate = device->machine->driver_data(); + drvstate->z80_m6809_line = state; } static WRITE_LINE_DEVICE_HANDLER( z80_acia_irq ) { - acia_irq = state ? CLEAR_LINE : ASSERT_LINE; + bfcobra_state *drvstate = device->machine->driver_data(); + drvstate->acia_irq = state ? CLEAR_LINE : ASSERT_LINE; update_irqs(device->machine); } @@ -1602,12 +1619,14 @@ static ACIA6850_INTERFACE( z80_acia_if ) static READ_LINE_DEVICE_HANDLER( m6809_acia_rx_r ) { - return z80_m6809_line; + bfcobra_state *state = device->machine->driver_data(); + return state->z80_m6809_line; } static WRITE_LINE_DEVICE_HANDLER( m6809_acia_tx_w ) { - m6809_z80_line = state; + bfcobra_state *drvstate = device->machine->driver_data(); + drvstate->m6809_z80_line = state; } static WRITE_LINE_DEVICE_HANDLER( m6809_data_irq ) @@ -1629,12 +1648,14 @@ static ACIA6850_INTERFACE( m6809_acia_if ) static READ_LINE_DEVICE_HANDLER( data_acia_rx_r ) { - return data_r; + bfcobra_state *state = device->machine->driver_data(); + return state->data_r; } static WRITE_LINE_DEVICE_HANDLER( data_acia_tx_w ) { - data_t = state; + bfcobra_state *drvstate = device->machine->driver_data(); + drvstate->data_t = state; } @@ -1654,6 +1675,7 @@ static ACIA6850_INTERFACE( data_acia_if ) /* TODO: Driver vs Machine Init */ static DRIVER_INIT( bfcobra ) { + bfcobra_state *state = machine->driver_data(); /* 6809 ROM address and data lines are scrambled. This is the same scrambling as Scorpion 2. @@ -1689,31 +1711,31 @@ static DRIVER_INIT( bfcobra ) init_ram(machine); - bank_data[0] = 1; - bank_data[1] = 0; - bank_data[2] = 0; - bank_data[3] = 0; + state->bank_data[0] = 1; + state->bank_data[1] = 0; + state->bank_data[2] = 0; + state->bank_data[3] = 0; /* Fixed 16kB ROM region */ memory_set_bankptr(machine, "bank4", machine->region("user1")->base()); /* TODO: Properly sort out the data ACIA */ - data_r = 1; + state->data_r = 1; /* Finish this */ - state_save_register_global(machine, z80_m6809_line); - state_save_register_global(machine, m6809_z80_line); - state_save_register_global(machine, data_r); - state_save_register_global(machine, data_t); - state_save_register_global(machine, h_scroll); - state_save_register_global(machine, v_scroll); - state_save_register_global(machine, flip_8); - state_save_register_global(machine, flip_22); - state_save_register_global(machine, z80_int); - state_save_register_global(machine, z80_inten); - state_save_register_global_array(machine, bank_data); - state_save_register_global_pointer(machine, work_ram, 0xc0000); - state_save_register_global_pointer(machine, video_ram, 0x20000); + state_save_register_global(machine, state->z80_m6809_line); + state_save_register_global(machine, state->m6809_z80_line); + state_save_register_global(machine, state->data_r); + state_save_register_global(machine, state->data_t); + state_save_register_global(machine, state->h_scroll); + state_save_register_global(machine, state->v_scroll); + state_save_register_global(machine, state->flip_8); + state_save_register_global(machine, state->flip_22); + state_save_register_global(machine, state->z80_int); + state_save_register_global(machine, state->z80_inten); + state_save_register_global_array(machine, state->bank_data); + state_save_register_global_pointer(machine, state->work_ram, 0xc0000); + state_save_register_global_pointer(machine, state->video_ram, 0x20000); } /* TODO */ @@ -1725,11 +1747,12 @@ static INTERRUPT_GEN( timer_irq ) /* TODO */ static INTERRUPT_GEN( vblank_gen ) { - vblank_irq = 1; + bfcobra_state *state = device->machine->driver_data(); + state->vblank_irq = 1; update_irqs(device->machine); } -static MACHINE_CONFIG_START( bfcobra, driver_device ) +static MACHINE_CONFIG_START( bfcobra, bfcobra_state ) MCFG_CPU_ADD("maincpu", Z80, Z80_XTAL) MCFG_CPU_PROGRAM_MAP(z80_prog_map) MCFG_CPU_IO_MAP(z80_io_map) diff --git a/src/mame/drivers/bfm_sc1.c b/src/mame/drivers/bfm_sc1.c index 3940f8bf08e..18ec73aae21 100644 --- a/src/mame/drivers/bfm_sc1.c +++ b/src/mame/drivers/bfm_sc1.c @@ -93,6 +93,39 @@ Optional (on expansion card) (Viper) #include "sound/upd7759.h" #include "machine/nvram.h" #include "bfm_sc1.lh" + + +class bfm_sc1_state : public driver_device +{ +public: + bfm_sc1_state(running_machine &machine, const driver_device_config_base &config) + : driver_device(machine, config) { } + + int mmtr_latch; + int triac_latch; + int vfd_latch; + int irq_status; + int optic_pattern; + int acia_status; + int locked; + int is_timer_enabled; + int reel_changed; + int coin_inhibits; + int mux1_outputlatch; + int mux1_datalo; + int mux1_datahi; + int mux1_input; + int mux2_outputlatch; + int mux2_datalo; + int mux2_datahi; + int mux2_input; + int watchdog_cnt; + int watchdog_kicked; + UINT8 Lamps[256]; + UINT8 sc1_Inputs[64]; + UINT8 codec_data[256]; +}; + #define VFD_RESET 0x20 #define VFD_CLOCK1 0x80 #define VFD_DATA 0x40 @@ -102,49 +135,27 @@ Optional (on expansion card) (Viper) // local vars ///////////////////////////////////////////////////////////// -static int mmtr_latch; // mechanical meter latch -static int triac_latch; // payslide triac latch -static int vfd_latch; // vfd latch -static int irq_status; // custom chip IRQ status -static int optic_pattern; // reel optics -static int acia_status; // MC6850 status -static int locked; // hardware lock/unlock status (0=unlocked) -static int is_timer_enabled; -static int reel_changed; -static int coin_inhibits; -static int mux1_outputlatch; -static int mux1_datalo; -static int mux1_datahi; -static int mux1_input; -static int mux2_outputlatch; -static int mux2_datalo; -static int mux2_datahi; -static int mux2_input; -static int watchdog_cnt; -static int watchdog_kicked; // user interface stuff /////////////////////////////////////////////////// -static UINT8 Lamps[256]; // 256 multiplexed lamps -static UINT8 sc1_Inputs[64]; // 64? multiplexed inputs /////////////////////////////////////////////////////////////////////////// -static void Scorpion1_SetSwitchState(int strobe, int data, int state) +static void Scorpion1_SetSwitchState(bfm_sc1_state *drvstate, int strobe, int data, int state) { - if ( state ) sc1_Inputs[strobe] |= (1<sc1_Inputs[strobe] |= (1<sc1_Inputs[strobe] &= ~(1<sc1_Inputs[strobe] & (1<machine->driver_data(); + if ( state->watchdog_kicked ) { - watchdog_cnt = 0; - watchdog_kicked = 0; + state->watchdog_cnt = 0; + state->watchdog_kicked = 0; } else { - watchdog_cnt++; - if ( watchdog_cnt > 2 ) // this is a hack, i don't know what the watchdog timeout is, 3 IRQ's works fine + state->watchdog_cnt++; + if ( state->watchdog_cnt > 2 ) // this is a hack, i don't know what the watchdog timeout is, 3 IRQ's works fine { // reset board device->machine->schedule_soft_reset();// reset entire machine. CPU 0 should be enough, but that doesn't seem to work !! return; } } - if ( is_timer_enabled ) + if ( state->is_timer_enabled ) { - irq_status = 0x01 |0x02; //0xff; + state->irq_status = 0x01 |0x02; //0xff; - sc1_Inputs[2] = input_port_read(device->machine,"STROBE0"); + state->sc1_Inputs[2] = input_port_read(device->machine,"STROBE0"); generic_pulse_irq_line(device->machine->device("maincpu"), M6809_IRQ_LINE); } @@ -189,9 +201,10 @@ static INTERRUPT_GEN( timer_irq ) static READ8_HANDLER( irqlatch_r ) { - int result = irq_status | 0x02; + bfm_sc1_state *state = space->machine->driver_data(); + int result = state->irq_status | 0x02; - irq_status = 0; + state->irq_status = 0; return result; } @@ -200,19 +213,20 @@ static READ8_HANDLER( irqlatch_r ) static WRITE8_HANDLER( reel12_w ) { - if ( locked & 0x01 ) - { // hardware is still locked, - if ( data == 0x46 ) locked &= ~0x01; + bfm_sc1_state *state = space->machine->driver_data(); + if ( state->locked & 0x01 ) + { // hardware is still state->locked, + if ( data == 0x46 ) state->locked &= ~0x01; } else { - if ( stepper_update(0, data>>4) ) reel_changed |= 0x01; - if ( stepper_update(1, data ) ) reel_changed |= 0x02; + if ( stepper_update(0, data>>4) ) state->reel_changed |= 0x01; + if ( stepper_update(1, data ) ) state->reel_changed |= 0x02; - if ( stepper_optic_state(0) ) optic_pattern |= 0x01; - else optic_pattern &= ~0x01; - if ( stepper_optic_state(1) ) optic_pattern |= 0x02; - else optic_pattern &= ~0x02; + if ( stepper_optic_state(0) ) state->optic_pattern |= 0x01; + else state->optic_pattern &= ~0x01; + if ( stepper_optic_state(1) ) state->optic_pattern |= 0x02; + else state->optic_pattern &= ~0x02; } awp_draw_reel(0); awp_draw_reel(1); @@ -222,19 +236,20 @@ static WRITE8_HANDLER( reel12_w ) static WRITE8_HANDLER( reel34_w ) { - if ( locked & 0x02 ) - { // hardware is still locked, - if ( data == 0x42 ) locked &= ~0x02; + bfm_sc1_state *state = space->machine->driver_data(); + if ( state->locked & 0x02 ) + { // hardware is still state->locked, + if ( data == 0x42 ) state->locked &= ~0x02; } else { - if ( stepper_update(2, data>>4) ) reel_changed |= 0x04; - if ( stepper_update(3, data ) ) reel_changed |= 0x08; + if ( stepper_update(2, data>>4) ) state->reel_changed |= 0x04; + if ( stepper_update(3, data ) ) state->reel_changed |= 0x08; - if ( stepper_optic_state(2) ) optic_pattern |= 0x04; - else optic_pattern &= ~0x04; - if ( stepper_optic_state(3) ) optic_pattern |= 0x08; - else optic_pattern &= ~0x08; + if ( stepper_optic_state(2) ) state->optic_pattern |= 0x04; + else state->optic_pattern &= ~0x04; + if ( stepper_optic_state(3) ) state->optic_pattern |= 0x08; + else state->optic_pattern &= ~0x08; } awp_draw_reel(2); awp_draw_reel(3); @@ -244,13 +259,14 @@ static WRITE8_HANDLER( reel34_w ) static WRITE8_HANDLER( reel56_w ) { - if ( stepper_update(4, data>>4) ) reel_changed |= 0x10; - if ( stepper_update(5, data ) ) reel_changed |= 0x20; + bfm_sc1_state *state = space->machine->driver_data(); + if ( stepper_update(4, data>>4) ) state->reel_changed |= 0x10; + if ( stepper_update(5, data ) ) state->reel_changed |= 0x20; - if ( stepper_optic_state(4) ) optic_pattern |= 0x10; - else optic_pattern &= ~0x10; - if ( stepper_optic_state(5) ) optic_pattern |= 0x20; - else optic_pattern &= ~0x20; + if ( stepper_optic_state(4) ) state->optic_pattern |= 0x10; + else state->optic_pattern &= ~0x10; + if ( stepper_optic_state(5) ) state->optic_pattern |= 0x20; + else state->optic_pattern &= ~0x20; awp_draw_reel(5); awp_draw_reel(6); } @@ -261,16 +277,17 @@ static WRITE8_HANDLER( reel56_w ) static WRITE8_HANDLER( mmtr_w ) { + bfm_sc1_state *state = space->machine->driver_data(); int i; - if ( locked & 0x04 ) - { // hardware is still locked, - locked &= ~0x04; + if ( state->locked & 0x04 ) + { // hardware is still state->locked, + state->locked &= ~0x04; } else { - int changed = mmtr_latch ^ data; + int changed = state->mmtr_latch ^ data; - mmtr_latch = data; + state->mmtr_latch = data; for (i=0; i<8; i++) { @@ -287,7 +304,8 @@ static WRITE8_HANDLER( mmtr_w ) static READ8_HANDLER( mmtr_r ) { - return mmtr_latch; + bfm_sc1_state *state = space->machine->driver_data(); + return state->mmtr_latch; } /////////////////////////////////////////////////////////////////////////// @@ -308,9 +326,10 @@ static READ8_DEVICE_HANDLER( nec_r ) static WRITE8_HANDLER( vfd_w ) { - int changed = vfd_latch ^ data; + bfm_sc1_state *state = space->machine->driver_data(); + int changed = state->vfd_latch ^ data; - vfd_latch = data; + state->vfd_latch = data; if ( changed ) { @@ -388,7 +407,8 @@ static int receive_from_adder(void) static READ8_HANDLER( mux1latch_r ) { - return mux1_input; + bfm_sc1_state *state = space->machine->driver_data(); + return state->mux1_input; } ///////////////////////////////////////////////////////////////////////////////////// @@ -409,9 +429,10 @@ static READ8_HANDLER( mux1dathi_r ) static WRITE8_HANDLER( mux1latch_w ) { - int changed = mux1_outputlatch ^ data; + bfm_sc1_state *state = space->machine->driver_data(); + int changed = state->mux1_outputlatch ^ data; static const char *const portnames[] = { "STROBE0", "STROBE1", "STROBE2", "STROBE3", "STROBE4", "STROBE5", "STROBE6", "STROBE7" }; - mux1_outputlatch = data; + state->mux1_outputlatch = data; if ( changed & 0x08 ) { // clock changed @@ -427,8 +448,8 @@ static WRITE8_HANDLER( mux1latch_w ) for ( i = 0; i < 8; i++ ) { - Lamps[ BFM_strcnv[offset ] ] = mux1_datalo & pattern?1:0; - Lamps[ BFM_strcnv[offset+8] ] = mux1_datahi & pattern?1:0; + state->Lamps[ BFM_strcnv[offset ] ] = state->mux1_datalo & pattern?1:0; + state->Lamps[ BFM_strcnv[offset+8] ] = state->mux1_datahi & pattern?1:0; pattern<<=1; offset++; } @@ -437,16 +458,16 @@ static WRITE8_HANDLER( mux1latch_w ) { for ( i = 0; i < 256; i++ ) { - output_set_lamp_value(i, Lamps[i]); + output_set_lamp_value(i, state->Lamps[i]); } } } if ( !(data & 0x08) ) { - sc1_Inputs[ input_strobe ] = input_port_read(space->machine,portnames[input_strobe]); + state->sc1_Inputs[ input_strobe ] = input_port_read(space->machine,portnames[input_strobe]); - mux1_input = sc1_Inputs[ input_strobe ]; + state->mux1_input = state->sc1_Inputs[ input_strobe ]; } } } @@ -455,21 +476,24 @@ static WRITE8_HANDLER( mux1latch_w ) static WRITE8_HANDLER( mux1datlo_w ) { - mux1_datalo = data; + bfm_sc1_state *state = space->machine->driver_data(); + state->mux1_datalo = data; } ///////////////////////////////////////////////////////////////////////////////////// static WRITE8_HANDLER( mux1dathi_w ) { - mux1_datahi = data; + bfm_sc1_state *state = space->machine->driver_data(); + state->mux1_datahi = data; } ///////////////////////////////////////////////////////////////////////////////////// static READ8_HANDLER( mux2latch_r ) { - return mux2_input; + bfm_sc1_state *state = space->machine->driver_data(); + return state->mux2_input; } ///////////////////////////////////////////////////////////////////////////////////// @@ -490,9 +514,10 @@ static READ8_HANDLER( mux2dathi_r ) static WRITE8_HANDLER( mux2latch_w ) { - int changed = mux2_outputlatch ^ data; + bfm_sc1_state *state = space->machine->driver_data(); + int changed = state->mux2_outputlatch ^ data; - mux2_outputlatch = data; + state->mux2_outputlatch = data; if ( changed & 0x08 ) { // clock changed @@ -507,8 +532,8 @@ static WRITE8_HANDLER( mux2latch_w ) for ( i = 0; i < 8; i++ ) { - Lamps[ BFM_strcnv[offset ] ] = mux2_datalo & pattern?1:0; - Lamps[ BFM_strcnv[offset+8] ] = mux2_datahi & pattern?1:0; + state->Lamps[ BFM_strcnv[offset ] ] = state->mux2_datalo & pattern?1:0; + state->Lamps[ BFM_strcnv[offset+8] ] = state->mux2_datahi & pattern?1:0; pattern<<=1; offset++; } @@ -516,7 +541,7 @@ static WRITE8_HANDLER( mux2latch_w ) if ( !(data & 0x08) ) { - mux2_input = 0x3F ^ optic_pattern; + state->mux2_input = 0x3F ^ state->optic_pattern; } } } @@ -525,21 +550,24 @@ static WRITE8_HANDLER( mux2latch_w ) static WRITE8_HANDLER( mux2datlo_w ) { - mux2_datalo = data; + bfm_sc1_state *state = space->machine->driver_data(); + state->mux2_datalo = data; } ///////////////////////////////////////////////////////////////////////////////////// static WRITE8_HANDLER( mux2dathi_w ) { - mux2_datahi = data; + bfm_sc1_state *state = space->machine->driver_data(); + state->mux2_datahi = data; } ///////////////////////////////////////////////////////////////////////////////////// static WRITE8_HANDLER( watchdog_w ) { - watchdog_kicked = 1; + bfm_sc1_state *state = space->machine->driver_data(); + state->watchdog_kicked = 1; } ///////////////////////////////////////////////////////////////////////////////////// @@ -560,7 +588,8 @@ static WRITE8_HANDLER( aciadata_w ) static READ8_HANDLER( aciastat_r ) { - return acia_status; + bfm_sc1_state *state = space->machine->driver_data(); + return state->acia_status; } ///////////////////////////////////////////////////////////////////////////////////// @@ -576,14 +605,16 @@ static READ8_HANDLER( aciadata_r ) static WRITE8_HANDLER( triac_w ) { - triac_latch = data; + bfm_sc1_state *state = space->machine->driver_data(); + state->triac_latch = data; } ///////////////////////////////////////////////////////////////////////////////////// static READ8_HANDLER( triac_r ) { - return triac_latch; + bfm_sc1_state *state = space->machine->driver_data(); + return state->triac_latch; } ///////////////////////////////////////////////////////////////////////////////////// @@ -653,11 +684,11 @@ static const UINT8 DataDecode[]= 0 }; -static UINT8 codec_data[256]; static void decode_sc1(running_machine *machine,const char *rom_region) { + bfm_sc1_state *state = machine->driver_data(); UINT8 *tmp, *rom; rom = machine->region(rom_region)->base(); @@ -685,7 +716,7 @@ static void decode_sc1(running_machine *machine,const char *rom_region) pattern <<= 1; } while ( *(++tab) ); - codec_data[i] = newdata; + state->codec_data[i] = newdata; } for ( address = 0; address < 0x10000; address++) @@ -702,7 +733,7 @@ static void decode_sc1(running_machine *machine,const char *rom_region) pattern <<= 1; } while ( *(++tab) ); - rom[newaddress] = codec_data[ tmp[address] ]; + rom[newaddress] = state->codec_data[ tmp[address] ]; } auto_free( machine, tmp ); } @@ -711,21 +742,22 @@ static void decode_sc1(running_machine *machine,const char *rom_region) static MACHINE_RESET( bfm_sc1 ) { + bfm_sc1_state *state = machine->driver_data(); BFM_BD1_init(0); - vfd_latch = 0; - mmtr_latch = 0; - triac_latch = 0; - irq_status = 0; - is_timer_enabled = 1; - coin_inhibits = 0; - mux1_outputlatch = 0x08; // clock HIGH - mux1_datalo = 0; - mux1_datahi = 0; - mux1_input = 0; - mux2_outputlatch = 0x08; // clock HIGH - mux2_datalo = 0; - mux2_datahi = 0; - mux2_input = 0; + state->vfd_latch = 0; + state->mmtr_latch = 0; + state->triac_latch = 0; + state->irq_status = 0; + state->is_timer_enabled = 1; + state->coin_inhibits = 0; + state->mux1_outputlatch = 0x08; // clock HIGH + state->mux1_datalo = 0; + state->mux1_datahi = 0; + state->mux1_input = 0; + state->mux2_outputlatch = 0x08; // clock HIGH + state->mux2_datalo = 0; + state->mux2_datahi = 0; + state->mux2_input = 0; BFM_BD1_reset(0); // reset display1 BFM_BD1_reset(1); // reset display2 @@ -741,12 +773,12 @@ static MACHINE_RESET( bfm_sc1 ) if ( stepper_optic_state(i) ) pattern |= 1<optic_pattern = pattern; } - acia_status = 0x02; // MC6850 transmit buffer empty !!! - locked = 0x07; // hardware is locked + state->acia_status = 0x02; // MC6850 transmit buffer empty !!! + state->locked = 0x07; // hardware is state->locked // init rom bank //////////////////////////////////////////////////////////////////// { @@ -1240,7 +1272,7 @@ INPUT_PORTS_END // machine driver for scorpion1 board /////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////// -static MACHINE_CONFIG_START( scorpion1, driver_device ) +static MACHINE_CONFIG_START( scorpion1, bfm_sc1_state ) MCFG_MACHINE_RESET(bfm_sc1) // main scorpion1 board initialisation MCFG_CPU_ADD("maincpu", M6809, MASTER_CLOCK/4) // 6809 CPU at 1 Mhz MCFG_CPU_PROGRAM_MAP(memmap) // setup read and write memorymap @@ -1335,6 +1367,7 @@ ROM_END static void sc1_common_init(running_machine *machine, int reels, int decrypt) { + bfm_sc1_state *state = machine->driver_data(); UINT8 *rom, i; rom = machine->region("maincpu")->base(); @@ -1343,7 +1376,7 @@ static void sc1_common_init(running_machine *machine, int reels, int decrypt) memcpy(&rom[0x10000], &rom[0x00000], 0x2000); } - memset(sc1_Inputs, 0, sizeof(sc1_Inputs)); + memset(state->sc1_Inputs, 0, sizeof(state->sc1_Inputs)); // setup n default 96 half step reels /////////////////////////////////////////// for ( i = 0; i < reels; i++ ) @@ -1389,15 +1422,16 @@ static DRIVER_INIT(rou029) static DRIVER_INIT(clatt) { + bfm_sc1_state *state = machine->driver_data(); sc1_common_init(machine,6,1); MechMtr_config(machine,8); BFM_BD1_init(0); - Scorpion1_SetSwitchState(3,2,1); - Scorpion1_SetSwitchState(3,3,1); - Scorpion1_SetSwitchState(3,6,1); - Scorpion1_SetSwitchState(4,1,1); + Scorpion1_SetSwitchState(state,3,2,1); + Scorpion1_SetSwitchState(state,3,3,1); + Scorpion1_SetSwitchState(state,3,6,1); + Scorpion1_SetSwitchState(state,4,1,1); } ///////////////////////////////////////////////////////////////////////////////////// diff --git a/src/mame/drivers/bfm_sc2.c b/src/mame/drivers/bfm_sc2.c index 494bc1abb58..8b3d67d0c46 100644 --- a/src/mame/drivers/bfm_sc2.c +++ b/src/mame/drivers/bfm_sc2.c @@ -163,6 +163,65 @@ Adder hardware: #include "sltblgtk.lh" #include "slots.lh" +class bfm_sc2_state : public driver_device +{ +public: + bfm_sc2_state(running_machine &machine, const driver_device_config_base &config) + : driver_device(machine, config) { } + + int sc2gui_update_mmtr; + UINT8 *nvram; + UINT8 key[16]; + UINT8 e2ram[1024]; + int mmtr_latch; + int triac_latch; + int vfd1_latch; + int vfd2_latch; + int irq_status; + int optic_pattern; + int uart1_data; + int uart2_data; + int data_to_uart1; + int data_to_uart2; + int locked; + int is_timer_enabled; + int reel_changed; + int coin_inhibits; + int irq_timer_stat; + int expansion_latch; + int global_volume; + int volume_override; + int sc2_show_door; + int sc2_door_state; + int reel12_latch; + int reel34_latch; + int reel56_latch; + int pay_latch; + int slide_states[6]; + int slide_pay_sensor[6]; + int has_hopper; + int triac_select; + int hopper_running; + int hopper_coin_sense; + int timercnt; + int watchdog_cnt; + int watchdog_kicked; + UINT8 Lamps[256]; + UINT8 sc2_Inputs[64]; + UINT8 input_override[64]; + int e2reg; + int e2state; + int e2cnt; + int e2data; + int e2address; + int e2rw; + int e2data_pin; + int e2dummywrite; + int e2data_to_read; + UINT8 codec_data[256]; +}; + + #ifdef MAME_DEBUG #define VERBOSE 1 #else @@ -178,64 +237,27 @@ Adder hardware: // local prototypes /////////////////////////////////////////////////////// -static int get_scorpion2_uart_status(void); // retrieve status of uart on scorpion2 board +static int read_e2ram(running_machine *machine); +static void e2ram_reset(running_machine *machine); + +// global vars //////////////////////////////////////////////////////////// -static int read_e2ram(void); -static void e2ram_reset(void); // local vars ///////////////////////////////////////////////////////////// -static UINT8 key[16]; // security device on gamecard (video games only) -static UINT8 e2ram[1024]; // x24C08 e2ram -static int mmtr_latch; // mechanical meter latch -static int triac_latch; // payslide triac latch -static int vfd1_latch; // vfd1 latch -static int vfd2_latch; // vfd2 latch -static int irq_status; // custom chip IRQ status -static int optic_pattern; // reel optics -static int uart1_data; -static int uart2_data; -static int data_to_uart1; -static int data_to_uart2; -static int locked; // hardware lock/unlock status (0=unlocked) -static int is_timer_enabled; -static int reel_changed; -static int coin_inhibits; -static int irq_timer_stat; -static int expansion_latch; -static int global_volume; // 0-31 -static int volume_override; // 0 / 1 -static int sc2_show_door; // flag <>0, show door state -static int sc2_door_state; // door switch strobe/data -static int reel12_latch; -static int reel34_latch; -static int reel56_latch; -static int pay_latch; -static int slide_states[6]; -static int slide_pay_sensor[6]; -static int has_hopper; // flag <>0, scorpion2 board has hopper connected -static int triac_select; -static int hopper_running; // flag <>0, hopper is running used in some scorpion2 videogames -static int hopper_coin_sense; -static int timercnt; // timer counts up every IRQ (=1000 times a second) -static int watchdog_cnt; -static int watchdog_kicked; // user interface stuff /////////////////////////////////////////////////// -static UINT8 Lamps[256]; -static UINT8 sc2_Inputs[64]; -static UINT8 input_override[64];// bit pattern, bit set means this input is overriden and cannot be changed with switches /* INPUTS layout @@ -281,7 +303,7 @@ static int receive_from_adder(void) /////////////////////////////////////////////////////////////////////////// -static int get_scorpion2_uart_status(void) +static int get_scorpion2_uart_status(running_machine *machine) { int status = 0; @@ -297,42 +319,43 @@ static int get_scorpion2_uart_status(void) static void on_scorpion2_reset(running_machine *machine) { - vfd1_latch = 0; - vfd2_latch = 0; - mmtr_latch = 0; - triac_latch = 0; - irq_status = 0; - is_timer_enabled = 1; - coin_inhibits = 0; - irq_timer_stat = 0; - expansion_latch = 0; - global_volume = 0; - volume_override = 0; - triac_select = 0; - pay_latch = 0; + bfm_sc2_state *state = machine->driver_data(); + state->vfd1_latch = 0; + state->vfd2_latch = 0; + state->mmtr_latch = 0; + state->triac_latch = 0; + state->irq_status = 0; + state->is_timer_enabled = 1; + state->coin_inhibits = 0; + state->irq_timer_stat = 0; + state->expansion_latch = 0; + state->global_volume = 0; + state->volume_override = 0; + state->triac_select = 0; + state->pay_latch = 0; - reel12_latch = 0; - reel34_latch = 0; - reel56_latch = 0; + state->reel12_latch = 0; + state->reel34_latch = 0; + state->reel56_latch = 0; - hopper_running = 0; // for video games - hopper_coin_sense = 0; + state->hopper_running = 0; // for video games + state->hopper_coin_sense = 0; - slide_states[0] = 0; - slide_states[1] = 0; - slide_states[2] = 0; - slide_states[3] = 0; - slide_states[4] = 0; - slide_states[5] = 0; + state->slide_states[0] = 0; + state->slide_states[1] = 0; + state->slide_states[2] = 0; + state->slide_states[3] = 0; + state->slide_states[4] = 0; + state->slide_states[5] = 0; - watchdog_cnt = 0; - watchdog_kicked = 0; + state->watchdog_cnt = 0; + state->watchdog_kicked = 0; BFM_BD1_reset(0); // reset display1 BFM_BD1_reset(1); // reset display2 - e2ram_reset(); + e2ram_reset(machine); devtag_reset(machine, "ymsnd"); @@ -350,14 +373,14 @@ send data to them, although obviously there's no response. */ if ( stepper_optic_state(i) ) pattern |= 1<optic_pattern = pattern; } - locked = 0; + state->locked = 0; // make sure no inputs are overidden //////////////////////////////////// - memset(input_override, 0, sizeof(input_override)); + memset(state->input_override, 0, sizeof(state->input_override)); // init rom bank //////////////////////////////////////////////////////// @@ -373,32 +396,33 @@ send data to them, although obviously there's no response. */ /////////////////////////////////////////////////////////////////////////// -void Scorpion2_SetSwitchState(int strobe, int data, int state) +void Scorpion2_SetSwitchState(running_machine *machine, int strobe, int data, int state) { + bfm_sc2_state *drvstate = machine->driver_data(); if ( strobe < 11 && data < 8 ) { if ( strobe < 8 ) { - input_override[strobe] |= (1<input_override[strobe] |= (1<sc2_Inputs[strobe] |= (1<sc2_Inputs[strobe] &= ~(1< 2 ) { - input_override[strobe-8+4] |= (1<<(data+2)); + drvstate->input_override[strobe-8+4] |= (1<<(data+2)); - if ( state ) sc2_Inputs[strobe-8+4] |= (1<<(data+2)); - else sc2_Inputs[strobe-8+4] &= ~(1<<(data+2)); + if ( state ) drvstate->sc2_Inputs[strobe-8+4] |= (1<<(data+2)); + else drvstate->sc2_Inputs[strobe-8+4] &= ~(1<<(data+2)); } else { - input_override[strobe-8] |= (1<<(data+5)); + drvstate->input_override[strobe-8] |= (1<<(data+5)); - if ( state ) sc2_Inputs[strobe-8] |= (1 << (data+5)); - else sc2_Inputs[strobe-8] &= ~(1 << (data+5)); + if ( state ) drvstate->sc2_Inputs[strobe-8] |= (1 << (data+5)); + else drvstate->sc2_Inputs[strobe-8] &= ~(1 << (data+5)); } } } @@ -406,25 +430,26 @@ void Scorpion2_SetSwitchState(int strobe, int data, int state) /////////////////////////////////////////////////////////////////////////// -int Scorpion2_GetSwitchState(int strobe, int data) +int Scorpion2_GetSwitchState(running_machine *machine, int strobe, int data) { + bfm_sc2_state *drvstate = machine->driver_data(); int state = 0; if ( strobe < 11 && data < 8 ) { if ( strobe < 8 ) { - state = (sc2_Inputs[strobe] & (1<sc2_Inputs[strobe] & (1< 2 ) { - state = (sc2_Inputs[strobe-8+4] & (1<<(data+2)) ) ? 1 : 0; + state = (drvstate->sc2_Inputs[strobe-8+4] & (1<<(data+2)) ) ? 1 : 0; } else { - state = (sc2_Inputs[strobe-8] & (1 << (data+5)) ) ? 1 : 0; + state = (drvstate->sc2_Inputs[strobe-8] & (1 << (data+5)) ) ? 1 : 0; } } } @@ -435,21 +460,22 @@ int Scorpion2_GetSwitchState(int strobe, int data) static NVRAM_HANDLER( bfm_sc2 ) { + bfm_sc2_state *state = machine->driver_data(); static const UINT8 init_e2ram[10] = { 1, 4, 10, 20, 0, 1, 1, 4, 10, 20 }; if ( read_or_write ) { // writing - file->write(e2ram,sizeof(e2ram)); + file->write(state->e2ram,sizeof(state->e2ram)); } else { // reading if ( file ) { - file->read(e2ram,sizeof(e2ram)); + file->read(state->e2ram,sizeof(state->e2ram)); } else { - memset(e2ram,0x00,sizeof(e2ram)); - memcpy(e2ram,init_e2ram,sizeof(init_e2ram)); + memset(state->e2ram,0x00,sizeof(state->e2ram)); + memcpy(state->e2ram,init_e2ram,sizeof(init_e2ram)); } } } @@ -458,7 +484,8 @@ static NVRAM_HANDLER( bfm_sc2 ) static WRITE8_HANDLER( watchdog_w ) { - watchdog_kicked = 1; + bfm_sc2_state *state = space->machine->driver_data(); + state->watchdog_kicked = 1; } /////////////////////////////////////////////////////////////////////////// @@ -472,17 +499,18 @@ static WRITE8_HANDLER( bankswitch_w ) static INTERRUPT_GEN( timer_irq ) { - timercnt++; + bfm_sc2_state *state = device->machine->driver_data(); + state->timercnt++; - if ( watchdog_kicked ) + if ( state->watchdog_kicked ) { - watchdog_cnt = 0; - watchdog_kicked = 0; + state->watchdog_cnt = 0; + state->watchdog_kicked = 0; } else { - watchdog_cnt++; - if ( watchdog_cnt > 2 ) // this is a hack, i don't know what the watchdog timeout is, 3 IRQ's works fine + state->watchdog_cnt++; + if ( state->watchdog_cnt > 2 ) // this is a hack, i don't know what the watchdog timeout is, 3 IRQ's works fine { // reset board device->machine->schedule_soft_reset(); // reset entire machine. CPU 0 should be enough, but that doesn't seem to work !! on_scorpion2_reset(device->machine); @@ -490,10 +518,10 @@ static INTERRUPT_GEN( timer_irq ) } } - if ( is_timer_enabled ) + if ( state->is_timer_enabled ) { - irq_timer_stat = 0x01; - irq_status = 0x02; + state->irq_timer_stat = 0x01; + state->irq_status = 0x02; generic_pulse_irq_line(device, M6809_IRQ_LINE); } @@ -503,33 +531,34 @@ static INTERRUPT_GEN( timer_irq ) static WRITE8_HANDLER( reel12_vid_w ) // in a video cabinet this is used to drive a hopper { - reel12_latch = data; + bfm_sc2_state *state = space->machine->driver_data(); + state->reel12_latch = data; - if ( has_hopper ) + if ( state->has_hopper ) { - int oldhop = hopper_running; + int oldhop = state->hopper_running; if ( data & 0x01 ) { // hopper power if ( data & 0x02 ) { - hopper_running = 1; + state->hopper_running = 1; } else { - hopper_running = 0; + state->hopper_running = 0; } } else { - //hopper_coin_sense = 0; - hopper_running = 0; + //state->hopper_coin_sense = 0; + state->hopper_running = 0; } - if ( oldhop != hopper_running ) + if ( oldhop != state->hopper_running ) { - hopper_coin_sense = 0; - oldhop = hopper_running; + state->hopper_coin_sense = 0; + oldhop = state->hopper_running; } } } @@ -538,15 +567,16 @@ static WRITE8_HANDLER( reel12_vid_w ) // in a video cabinet this is used to dri static WRITE8_HANDLER( reel34_w ) { - reel34_latch = data; + bfm_sc2_state *state = space->machine->driver_data(); + state->reel34_latch = data; - if ( stepper_update(2, data ) ) reel_changed |= 0x04; - if ( stepper_update(3, data>>4) ) reel_changed |= 0x08; + if ( stepper_update(2, data ) ) state->reel_changed |= 0x04; + if ( stepper_update(3, data>>4) ) state->reel_changed |= 0x08; - if ( stepper_optic_state(2) ) optic_pattern |= 0x04; - else optic_pattern &= ~0x04; - if ( stepper_optic_state(3) ) optic_pattern |= 0x08; - else optic_pattern &= ~0x08; + if ( stepper_optic_state(2) ) state->optic_pattern |= 0x04; + else state->optic_pattern &= ~0x04; + if ( stepper_optic_state(3) ) state->optic_pattern |= 0x08; + else state->optic_pattern &= ~0x08; awp_draw_reel(2); awp_draw_reel(3); @@ -556,15 +586,16 @@ static WRITE8_HANDLER( reel34_w ) static WRITE8_HANDLER( reel56_w ) { - reel56_latch = data; + bfm_sc2_state *state = space->machine->driver_data(); + state->reel56_latch = data; - if ( stepper_update(4, data ) ) reel_changed |= 0x10; - if ( stepper_update(5, data>>4) ) reel_changed |= 0x20; + if ( stepper_update(4, data ) ) state->reel_changed |= 0x10; + if ( stepper_update(5, data>>4) ) state->reel_changed |= 0x20; - if ( stepper_optic_state(4) ) optic_pattern |= 0x10; - else optic_pattern &= ~0x10; - if ( stepper_optic_state(5) ) optic_pattern |= 0x20; - else optic_pattern &= ~0x20; + if ( stepper_optic_state(4) ) state->optic_pattern |= 0x10; + else state->optic_pattern &= ~0x10; + if ( stepper_optic_state(5) ) state->optic_pattern |= 0x20; + else state->optic_pattern &= ~0x20; awp_draw_reel(4); awp_draw_reel(5); @@ -576,10 +607,11 @@ static WRITE8_HANDLER( reel56_w ) static WRITE8_HANDLER( mmtr_w ) { + bfm_sc2_state *state = space->machine->driver_data(); int i; - int changed = mmtr_latch ^ data; + int changed = state->mmtr_latch ^ data; - mmtr_latch = data; + state->mmtr_latch = data; for (i = 0; i<8; i++) { @@ -595,18 +627,19 @@ static WRITE8_HANDLER( mmtr_w ) static WRITE8_HANDLER( mux_output_w ) { + bfm_sc2_state *state = space->machine->driver_data(); int i; int off = offset<<3; for (i=0; i<8; i++) { - Lamps[ off+i ] = (data & (1 << i)) != 0; + state->Lamps[ off+i ] = (data & (1 << i)) != 0; } if (offset == 0) // update all lamps after strobe 0 has been updated (HACK) { for ( i = 0; i < 256; i++ ) { - output_set_lamp_value(i, Lamps[i]); + output_set_lamp_value(i, state->Lamps[i]); } } } @@ -615,23 +648,24 @@ static WRITE8_HANDLER( mux_output_w ) static READ8_HANDLER( mux_input_r ) { + bfm_sc2_state *state = space->machine->driver_data(); int result = 0xFF,t1,t2; static const char *const port[] = { "STROBE0", "STROBE1", "STROBE2", "STROBE3", "STROBE4", "STROBE5", "STROBE6", "STROBE7", "STROBE8", "STROBE9", "STROBE10", "STROBE11" }; if (offset < 8) { int idx = (offset & 4) ? 4 : 8; - t1 = input_override[offset]; // strobe 0-7 data 0-4 - t2 = input_override[offset+idx]; // strobe 8-B data 0-4 + t1 = state->input_override[offset]; // strobe 0-7 data 0-4 + t2 = state->input_override[offset+idx]; // strobe 8-B data 0-4 - t1 = (sc2_Inputs[offset] & t1) | ( ( input_port_read(space->machine, port[offset]) & ~t1) & 0x1F); + t1 = (state->sc2_Inputs[offset] & t1) | ( ( input_port_read(space->machine, port[offset]) & ~t1) & 0x1F); if (idx == 8) - t2 = (sc2_Inputs[offset+8] & t2) | ( ( input_port_read(space->machine, port[offset+8]) & ~t2) << 5); + t2 = (state->sc2_Inputs[offset+8] & t2) | ( ( input_port_read(space->machine, port[offset+8]) & ~t2) << 5); else - t2 = (sc2_Inputs[offset+4] & t2) | ( ( ( input_port_read(space->machine, port[offset+4]) & ~t2) << 2) & 0x60); + t2 = (state->sc2_Inputs[offset+4] & t2) | ( ( ( input_port_read(space->machine, port[offset+4]) & ~t2) << 2) & 0x60); - sc2_Inputs[offset] = (sc2_Inputs[offset] & ~0x1F) | t1; - sc2_Inputs[offset+idx] = (sc2_Inputs[offset+idx] & ~0x60) | t2; + state->sc2_Inputs[offset] = (state->sc2_Inputs[offset] & ~0x1F) | t1; + state->sc2_Inputs[offset+idx] = (state->sc2_Inputs[offset+idx] & ~0x60) | t2; result = t1 | t2; } @@ -666,15 +700,16 @@ static WRITE8_HANDLER( unknown_w ) static WRITE8_HANDLER( volume_override_w ) { - int old = volume_override; + bfm_sc2_state *state = space->machine->driver_data(); + int old = state->volume_override; - volume_override = data?1:0; + state->volume_override = data?1:0; - if ( old != volume_override ) + if ( old != state->volume_override ) { ym2413_device *ym = space->machine->device("ymsnd"); upd7759_device *upd = space->machine->device("upd"); - float percent = volume_override? 1.0f : (32-global_volume)/32.0f; + float percent = state->volume_override? 1.0f : (32-state->global_volume)/32.0f; ym->set_output_gain(0, percent); ym->set_output_gain(1, percent); @@ -694,10 +729,11 @@ static WRITE8_DEVICE_HANDLER( nec_reset_w ) static WRITE8_DEVICE_HANDLER( nec_latch_w ) { + bfm_sc2_state *state = device->machine->driver_data(); int bank = 0; if ( data & 0x80 ) bank |= 0x01; - if ( expansion_latch & 2 ) bank |= 0x02; + if ( state->expansion_latch & 2 ) bank |= 0x02; upd7759_set_bank_base(device, bank*0x20000); @@ -710,26 +746,27 @@ static WRITE8_DEVICE_HANDLER( nec_latch_w ) static READ8_HANDLER( vfd_status_hop_r ) // on video games, hopper inputs are connected to this { + bfm_sc2_state *state = space->machine->driver_data(); // b7 = NEC busy // b6 = alpha busy (also matrix board) // b5 - b0 = reel optics int result = 0; - if ( has_hopper ) + if ( state->has_hopper ) { result |= 0x04; // hopper high level result |= 0x08; // hopper low level result |= 0x01|0x02; - if ( hopper_running ) + if ( state->hopper_running ) { result &= ~0x01; // set motor running input - if ( timercnt & 0x04 ) hopper_coin_sense ^= 1; // toggle coin seen + if ( state->timercnt & 0x04 ) state->hopper_coin_sense ^= 1; // toggle coin seen - if ( hopper_coin_sense ) result &= ~0x02; // update coin seen input + if ( state->hopper_coin_sense ) result &= ~0x02; // update coin seen input } } @@ -742,9 +779,10 @@ static READ8_HANDLER( vfd_status_hop_r ) // on video games, hopper inputs are co static WRITE8_HANDLER( expansion_latch_w ) { - int changed = expansion_latch^data; + bfm_sc2_state *state = space->machine->driver_data(); + int changed = state->expansion_latch^data; - expansion_latch = data; + state->expansion_latch = data; // bit0, 1 = lamp mux disabled, 0 = lamp mux enabled // bit1, ? used in Del's millions @@ -761,17 +799,17 @@ static WRITE8_HANDLER( expansion_latch_w ) { // changed from high to low, if ( !(data & 0x08) ) { - if ( global_volume < 31 ) global_volume++; //0-31 expressed as 1-32 + if ( state->global_volume < 31 ) state->global_volume++; //0-31 expressed as 1-32 } else { - if ( global_volume > 0 ) global_volume--; + if ( state->global_volume > 0 ) state->global_volume--; } { ym2413_device *ym = space->machine->device("ymsnd"); upd7759_device *upd = space->machine->device("upd"); - float percent = volume_override ? 1.0f : (32-global_volume)/32.0f; + float percent = state->volume_override ? 1.0f : (32-state->global_volume)/32.0f; ym->set_output_gain(0, percent); ym->set_output_gain(1, percent); @@ -798,15 +836,17 @@ static WRITE8_HANDLER( muxena_w ) static WRITE8_HANDLER( timerirq_w ) { - is_timer_enabled = data & 1; + bfm_sc2_state *state = space->machine->driver_data(); + state->is_timer_enabled = data & 1; } /////////////////////////////////////////////////////////////////////////// static READ8_HANDLER( timerirqclr_r ) { - irq_timer_stat = 0; - irq_status = 0; + bfm_sc2_state *state = space->machine->driver_data(); + state->irq_timer_stat = 0; + state->irq_status = 0; return 0; } @@ -815,9 +855,10 @@ static READ8_HANDLER( timerirqclr_r ) static READ8_HANDLER( irqstatus_r ) { - int result = irq_status | irq_timer_stat | 0x80; // 0x80 = ~MUXERROR + bfm_sc2_state *state = space->machine->driver_data(); + int result = state->irq_status | state->irq_timer_stat | 0x80; // 0x80 = ~MUXERROR - irq_timer_stat = 0; + state->irq_timer_stat = 0; return result; } @@ -826,9 +867,10 @@ static READ8_HANDLER( irqstatus_r ) static WRITE8_HANDLER( coininhib_w ) { - int changed = coin_inhibits^data,i,p; + bfm_sc2_state *state = space->machine->driver_data(); + int changed = state->coin_inhibits^data,i,p; - coin_inhibits = data; + state->coin_inhibits = data; p = 0x01; i = 0; @@ -857,18 +899,20 @@ static READ8_HANDLER( coin_input_r ) static WRITE8_HANDLER( payout_latch_w ) { - pay_latch = data; + bfm_sc2_state *state = space->machine->driver_data(); + state->pay_latch = data; } /////////////////////////////////////////////////////////////////////////// static WRITE8_HANDLER( payout_triac_w ) { - if ( triac_select == 0x57 ) + bfm_sc2_state *state = space->machine->driver_data(); + if ( state->triac_select == 0x57 ) { int slide = 0; - switch ( pay_latch ) + switch ( state->pay_latch ) { case 0x01: slide = 1; break; @@ -893,28 +937,28 @@ static WRITE8_HANDLER( payout_triac_w ) { if ( data == 0x4D ) { - if ( !slide_states[slide] ) + if ( !state->slide_states[slide] ) { - if ( slide_pay_sensor[slide] ) + if ( state->slide_pay_sensor[slide] ) { - int strobe = slide_pay_sensor[slide]>>4, data = slide_pay_sensor[slide]&0x0F; + int strobe = state->slide_pay_sensor[slide]>>4, data = state->slide_pay_sensor[slide]&0x0F; - Scorpion2_SetSwitchState(strobe, data, 0); + Scorpion2_SetSwitchState(space->machine, strobe, data, 0); } - slide_states[slide] = 1; + state->slide_states[slide] = 1; } } else { - if ( slide_states[slide] ) + if ( state->slide_states[slide] ) { - if ( slide_pay_sensor[slide] ) + if ( state->slide_pay_sensor[slide] ) { - int strobe = slide_pay_sensor[slide]>>4, data = slide_pay_sensor[slide]&0x0F; + int strobe = state->slide_pay_sensor[slide]>>4, data = state->slide_pay_sensor[slide]&0x0F; - Scorpion2_SetSwitchState(strobe, data, 1); + Scorpion2_SetSwitchState(space->machine, strobe, data, 1); } - slide_states[slide] = 0; + state->slide_states[slide] = 0; } } } @@ -925,14 +969,16 @@ static WRITE8_HANDLER( payout_triac_w ) static WRITE8_HANDLER( payout_select_w ) { - triac_select = data; + bfm_sc2_state *state = space->machine->driver_data(); + state->triac_select = data; } /////////////////////////////////////////////////////////////////////////// static WRITE8_HANDLER( vfd1_data_w ) { - vfd1_latch = data; + bfm_sc2_state *state = space->machine->driver_data(); + state->vfd1_latch = data; BFM_BD1_newdata(0, data); BFM_BD1_draw(0); } @@ -941,7 +987,8 @@ static WRITE8_HANDLER( vfd1_data_w ) static WRITE8_HANDLER( vfd2_data_w ) { - vfd2_latch = data; + bfm_sc2_state *state = space->machine->driver_data(); + state->vfd2_latch = data; BFM_BD1_newdata(1, data); BFM_BD1_draw(1); } @@ -962,10 +1009,11 @@ static WRITE8_HANDLER( vfd_reset_w ) static READ8_HANDLER( uart1stat_r ) { + bfm_sc2_state *state = space->machine->driver_data(); int status = 0x06; - if ( data_to_uart1 ) status |= 0x01; - if ( !data_to_uart2 ) status |= 0x02; + if ( state->data_to_uart1 ) status |= 0x01; + if ( !state->data_to_uart2 ) status |= 0x02; return status; } @@ -973,7 +1021,8 @@ static READ8_HANDLER( uart1stat_r ) static READ8_HANDLER( uart1data_r ) { - return uart1_data; + bfm_sc2_state *state = space->machine->driver_data(); + return state->uart1_data; } ////////////////////////////////////////////////////////////////////////// @@ -986,18 +1035,20 @@ static WRITE8_HANDLER( uart1ctrl_w ) static WRITE8_HANDLER( uart1data_w ) { - data_to_uart2 = 1; - uart1_data = data; + bfm_sc2_state *state = space->machine->driver_data(); + state->data_to_uart2 = 1; + state->uart1_data = data; UART_LOG(("uart1:%x\n", data)); } /////////////////////////////////////////////////////////////////////////// static READ8_HANDLER( uart2stat_r ) { + bfm_sc2_state *state = space->machine->driver_data(); int status = 0x06; - if ( data_to_uart2 ) status |= 0x01; - if ( !data_to_uart1 ) status |= 0x02; + if ( state->data_to_uart2 ) status |= 0x01; + if ( !state->data_to_uart1 ) status |= 0x02; return status; } @@ -1005,7 +1056,8 @@ static READ8_HANDLER( uart2stat_r ) static READ8_HANDLER( uart2data_r ) { - return uart2_data; + bfm_sc2_state *state = space->machine->driver_data(); + return state->uart2_data; } /////////////////////////////////////////////////////////////////////////// @@ -1019,8 +1071,9 @@ static WRITE8_HANDLER( uart2ctrl_w ) static WRITE8_HANDLER( uart2data_w ) { - data_to_uart1 = 1; - uart2_data = data; + bfm_sc2_state *state = space->machine->driver_data(); + state->data_to_uart1 = 1; + state->uart2_data = data; UART_LOG(("uart2:%x\n", data)); } @@ -1048,18 +1101,19 @@ static READ8_HANDLER( vid_uart_rx_r ) static READ8_HANDLER( vid_uart_ctrl_r ) { - return get_scorpion2_uart_status(); + return get_scorpion2_uart_status(space->machine); } /////////////////////////////////////////////////////////////////////////// static READ8_HANDLER( key_r ) { - int result = key[ offset ]; + bfm_sc2_state *state = space->machine->driver_data(); + int result = state->key[ offset ]; if ( offset == 7 ) { - result = (result & 0xFE) | read_e2ram(); + result = (result & 0xFE) | read_e2ram(space->machine); } return result; @@ -1076,56 +1130,48 @@ on a simple two wire bus. */ -static int e2reg; -static int e2state; -static int e2cnt; -static int e2data; -static int e2address; -static int e2rw; -static int e2data_pin; -static int e2dummywrite; -static int e2data_to_read; #define SCL 0x01 //SCL pin (clock) #define SDA 0x02 //SDA pin (data) -static void e2ram_reset(void) +static void e2ram_reset(running_machine *machine) { - e2reg = 0; - e2state = 0; - e2address = 0; - e2rw = 0; - e2data_pin = 0; - e2data = (SDA|SCL); - e2dummywrite = 0; - e2data_to_read = 0; + bfm_sc2_state *state = machine->driver_data(); + state->e2reg = 0; + state->e2state = 0; + state->e2address = 0; + state->e2rw = 0; + state->e2data_pin = 0; + state->e2data = (SDA|SCL); + state->e2dummywrite = 0; + state->e2data_to_read = 0; } -static int recdata(int changed, int data) +static int recdata(bfm_sc2_state *state, int changed, int data) { int res = 1; - if ( e2cnt < 8 ) + if ( state->e2cnt < 8 ) { res = 0; if ( (changed & SCL) && (data & SCL) ) { // clocked in new data - int pattern = 1 << (7-e2cnt); + int pattern = 1 << (7-state->e2cnt); - if ( data & SDA ) e2data |= pattern; - else e2data &= ~pattern; + if ( data & SDA ) state->e2data |= pattern; + else state->e2data &= ~pattern; - e2data_pin = e2data_to_read & 0x80 ? 1 : 0; + state->e2data_pin = state->e2data_to_read & 0x80 ? 1 : 0; - e2data_to_read <<= 1; + state->e2data_to_read <<= 1; - LOG(("e2d pin= %d\n", e2data_pin)); + LOG(("e2d pin= %d\n", state->e2data_pin)); - e2cnt++; - if ( e2cnt >= 8 ) + state->e2cnt++; + if ( state->e2cnt >= 8 ) { res++; } @@ -1155,15 +1201,16 @@ static int recAck(int changed, int data) // static WRITE8_HANDLER( e2ram_w ) -{ // b0 = clock b1 = data +{ + bfm_sc2_state *state = space->machine->driver_data(); // b0 = clock b1 = data int changed, ack; data ^= (SDA|SCL); // invert signals - changed = (e2reg^data) & 0x03; + changed = (state->e2reg^data) & 0x03; - e2reg = data; + state->e2reg = data; if ( changed ) { @@ -1173,13 +1220,13 @@ static WRITE8_HANDLER( e2ram_w ) ( !(changed & SCL) && (data & SCL) ) // SCL=1 and not changed ) { // X24C08 Start condition (1->0 on SDA while SCL=1) - e2dummywrite = ( e2state == 5 ); + state->e2dummywrite = ( state->e2state == 5 ); - LOG(("e2ram: c:%d d:%d Start condition dummywrite=%d\n", (data & SCL)?1:0, (data&SDA)?1:0, e2dummywrite )); + LOG(("e2ram: c:%d d:%d Start condition dummywrite=%d\n", (data & SCL)?1:0, (data&SDA)?1:0, state->e2dummywrite )); - e2state = 1; // ready for commands - e2cnt = 0; - e2data = 0; + state->e2state = 1; // ready for commands + state->e2cnt = 0; + state->e2data = 0; break; } @@ -1188,25 +1235,25 @@ static WRITE8_HANDLER( e2ram_w ) ) { // X24C08 Stop condition (0->1 on SDA while SCL=1) LOG(("e2ram: c:%d d:%d Stop condition\n", (data & SCL)?1:0, (data&SDA)?1:0 )); - e2state = 0; - e2data = 0; + state->e2state = 0; + state->e2data = 0; break; } - switch ( e2state ) + switch ( state->e2state ) { case 1: // Receiving address + R/W bit - if ( recdata(changed, data) ) + if ( recdata(state, changed, data) ) { - e2address = (e2address & 0x00FF) | ((e2data>>1) & 0x03) << 8; - e2cnt = 0; - e2rw = e2data & 1; + state->e2address = (state->e2address & 0x00FF) | ((state->e2data>>1) & 0x03) << 8; + state->e2cnt = 0; + state->e2rw = state->e2data & 1; LOG(("e2ram: Slave address received !! device id=%01X device adr=%01d high order adr %0X RW=%d) %02X\n", - e2data>>4, (e2data & 0x08)?1:0, (e2data>>1) & 0x03, e2rw , e2data )); + state->e2data>>4, (state->e2data & 0x08)?1:0, (state->e2data>>1) & 0x03, state->e2rw , state->e2data )); - e2state = 2; + state->e2state = 2; } break; @@ -1215,59 +1262,59 @@ static WRITE8_HANDLER( e2ram_w ) ack = recAck(changed,data); if ( ack ) { - e2data_pin = 0; + state->e2data_pin = 0; if ( ack < 0 ) { LOG(("ACK = 0\n")); - e2state = 0; + state->e2state = 0; } else { LOG(("ACK = 1\n")); - if ( e2dummywrite ) + if ( state->e2dummywrite ) { - e2dummywrite = 0; + state->e2dummywrite = 0; - e2data_to_read = e2ram[e2address]; + state->e2data_to_read = state->e2ram[state->e2address]; - if ( e2rw & 1 ) e2state = 7; // read data - else e2state = 0; //?not sure + if ( state->e2rw & 1 ) state->e2state = 7; // read data + else state->e2state = 0; //?not sure } else { - if ( e2rw & 1 ) e2state = 7; // reading - else e2state = 3; // writing + if ( state->e2rw & 1 ) state->e2state = 7; // reading + else state->e2state = 3; // writing } - switch ( e2state ) + switch ( state->e2state ) { case 7: - LOG(("read address %04X\n",e2address)); - e2data_to_read = e2ram[e2address]; + LOG(("read address %04X\n",state->e2address)); + state->e2data_to_read = state->e2ram[state->e2address]; break; case 3: LOG(("write, awaiting address\n")); break; default: - LOG(("?unknow action %04X\n",e2address)); + LOG(("?unknow action %04X\n",state->e2address)); break; } } - e2data = 0; + state->e2data = 0; } break; case 3: // writing data, receiving address - if ( recdata(changed, data) ) + if ( recdata(state, changed, data) ) { - e2data_pin = 0; - e2address = (e2address & 0xFF00) | e2data; + state->e2data_pin = 0; + state->e2address = (state->e2address & 0xFF00) | state->e2data; - LOG(("write address = %04X waiting for ACK\n", e2address)); - e2state = 4; - e2cnt = 0; - e2data = 0; + LOG(("write address = %04X waiting for ACK\n", state->e2address)); + state->e2state = 4; + state->e2cnt = 0; + state->e2data = 0; } break; @@ -1276,27 +1323,27 @@ static WRITE8_HANDLER( e2ram_w ) ack = recAck(changed,data); if ( ack ) { - e2data_pin = 0; // pin=0, no error !! + state->e2data_pin = 0; // pin=0, no error !! if ( ack < 0 ) { - e2state = 0; + state->e2state = 0; LOG(("ACK = 0, cancel write\n" )); } else { - e2state = 5; + state->e2state = 5; LOG(("ACK = 1, awaiting data to write\n" )); } } break; case 5: // receive data to write - if ( recdata(changed, data) ) + if ( recdata(state, changed, data) ) { - LOG(("write data = %02X received, awaiting ACK\n", e2data)); - e2cnt = 0; - e2state = 6; // wait ack + LOG(("write data = %02X received, awaiting ACK\n", state->e2data)); + state->e2cnt = 0; + state->e2state = 6; // wait ack } break; @@ -1307,31 +1354,31 @@ static WRITE8_HANDLER( e2ram_w ) { if ( ack < 0 ) { - e2state = 0; + state->e2state = 0; LOG(("ACK=0, write canceled\n")); } else { - LOG(("ACK=1, writing %02X to %04X\n", e2data, e2address)); + LOG(("ACK=1, writing %02X to %04X\n", state->e2data, state->e2address)); - e2ram[e2address] = e2data; + state->e2ram[state->e2address] = state->e2data; - e2address = (e2address & ~0x000F) | ((e2address+1)&0x0F); + state->e2address = (state->e2address & ~0x000F) | ((state->e2address+1)&0x0F); - e2state = 5; // write next address + state->e2state = 5; // write next address } } break; case 7: // receive address from read - if ( recdata(changed, data) ) + if ( recdata(state, changed, data) ) { - //e2data_pin = 0; + //state->e2data_pin = 0; - LOG(("address read, data = %02X waiting for ACK\n", e2data )); + LOG(("address read, data = %02X waiting for ACK\n", state->e2data )); - e2state = 8; + state->e2state = 8; } break; @@ -1339,16 +1386,16 @@ static WRITE8_HANDLER( e2ram_w ) if ( recAck(changed, data) ) { - e2state = 7; + state->e2state = 7; - e2address = (e2address & ~0x0F) | ((e2address+1)&0x0F); // lower 4 bits wrap around + state->e2address = (state->e2address & ~0x0F) | ((state->e2address+1)&0x0F); // lower 4 bits wrap around - e2data_to_read = e2ram[e2address]; + state->e2data_to_read = state->e2ram[state->e2address]; - LOG(("ready for next address %04X\n", e2address)); + LOG(("ready for next address %04X\n", state->e2address)); - e2cnt = 0; - e2data = 0; + state->e2cnt = 0; + state->e2data = 0; } break; @@ -1362,11 +1409,12 @@ static WRITE8_HANDLER( e2ram_w ) } } -static int read_e2ram(void) +static int read_e2ram(running_machine *machine) { - LOG(("e2ram: r %d (%02X) \n", e2data_pin, e2data_to_read )); + bfm_sc2_state *state = machine->driver_data(); + LOG(("e2ram: r %d (%02X) \n", state->e2data_pin, state->e2data_to_read )); - return e2data_pin; + return state->e2data_pin; } static const UINT16 AddressDecode[]= @@ -1382,11 +1430,11 @@ static const UINT8 DataDecode[]= 0 }; -static UINT8 codec_data[256]; /////////////////////////////////////////////////////////////////////////// static void decode_mainrom(running_machine *machine, const char *rom_region) { + bfm_sc2_state *state = machine->driver_data(); UINT8 *tmp, *rom; rom = machine->region(rom_region)->base(); @@ -1413,7 +1461,7 @@ static void decode_mainrom(running_machine *machine, const char *rom_region) pattern <<= 1; } while ( *(++tab) ); - codec_data[i] = newdata; + state->codec_data[i] = newdata; } for ( address = 0; address < 0x10000; address++) @@ -1430,7 +1478,7 @@ static void decode_mainrom(running_machine *machine, const char *rom_region) pattern <<= 1; } while ( *(++tab) ); - rom[newaddress] = codec_data[ tmp[address] ]; + rom[newaddress] = state->codec_data[ tmp[address] ]; } auto_free(machine, tmp); } @@ -1448,14 +1496,15 @@ static MACHINE_RESET( init ) on_scorpion2_reset(machine); BFM_BD1_init(0); BFM_BD1_init(1); - //BFM_dm01_reset(); No known video based game has a Matrix board + //BFM_dm01_reset(machine); No known video based game has a Matrix board } static VIDEO_UPDATE( addersc2 ) { - if ( sc2_show_door ) + bfm_sc2_state *state = screen->machine->driver_data(); + if ( state->sc2_show_door ) { - output_set_value("door",( Scorpion2_GetSwitchState(sc2_door_state>>4, sc2_door_state & 0x0F) ) ); + output_set_value("door",( Scorpion2_GetSwitchState(screen->machine,state->sc2_door_state>>4, state->sc2_door_state & 0x0F) ) ); } return VIDEO_UPDATE_CALL(adder2); @@ -2173,7 +2222,7 @@ INPUT_PORTS_END // machine driver for scorpion2 board + adder2 expansion ////////////////// /////////////////////////////////////////////////////////////////////////// -static MACHINE_CONFIG_START( scorpion2_vid, driver_device ) +static MACHINE_CONFIG_START( scorpion2_vid, bfm_sc2_state ) MCFG_MACHINE_RESET( init ) // main scorpion2 board initialisation MCFG_QUANTUM_TIME(attotime::from_hz(960)) // needed for serial communication !! MCFG_CPU_ADD("maincpu", M6809, MASTER_CLOCK/4 ) // 6809 CPU at 2 Mhz @@ -2212,6 +2261,7 @@ MACHINE_CONFIG_END static void sc2_common_init(running_machine *machine, int decrypt) { + bfm_sc2_state *state = machine->driver_data(); UINT8 *rom; if (decrypt) decode_mainrom(machine, "maincpu"); // decode main rom @@ -2222,17 +2272,18 @@ static void sc2_common_init(running_machine *machine, int decrypt) memcpy(&rom[0x10000], &rom[0x00000], 0x2000); } - memset(sc2_Inputs, 0, sizeof(sc2_Inputs)); // clear all inputs + memset(state->sc2_Inputs, 0, sizeof(state->sc2_Inputs)); // clear all inputs } static void adder2_common_init(running_machine *machine) { + bfm_sc2_state *state = machine->driver_data(); UINT8 *pal; pal = machine->region("proms")->base(); if ( pal ) { - memcpy(key, pal, 8); + memcpy(state->key, pal, 8); } } @@ -2240,88 +2291,93 @@ static void adder2_common_init(running_machine *machine) static DRIVER_INIT (quintoon) { + bfm_sc2_state *state = machine->driver_data(); sc2_common_init(machine, 1); adder2_decode_char_roms(machine); MechMtr_config(machine,8); // setup mech meters - has_hopper = 0; + state->has_hopper = 0; - Scorpion2_SetSwitchState(3,0,1); // tube1 level switch - Scorpion2_SetSwitchState(3,1,1); // tube2 level switch - Scorpion2_SetSwitchState(3,2,1); // tube3 level switch + Scorpion2_SetSwitchState(machine,3,0,1); // tube1 level switch + Scorpion2_SetSwitchState(machine,3,1,1); // tube2 level switch + Scorpion2_SetSwitchState(machine,3,2,1); // tube3 level switch - Scorpion2_SetSwitchState(5,2,1); - Scorpion2_SetSwitchState(6,4,1); + Scorpion2_SetSwitchState(machine,5,2,1); + Scorpion2_SetSwitchState(machine,6,4,1); - sc2_show_door = 1; - sc2_door_state = 0x41; + state->sc2_show_door = 1; + state->sc2_door_state = 0x41; } // dutch pyramid intialisation ////////////////////////////////////////////// static DRIVER_INIT( pyramid ) { + bfm_sc2_state *state = machine->driver_data(); sc2_common_init(machine, 1); adder2_decode_char_roms(machine); // decode GFX roms adder2_common_init(machine); - has_hopper = 1; + state->has_hopper = 1; - Scorpion2_SetSwitchState(3,0,1); // tube1 level switch - Scorpion2_SetSwitchState(3,1,1); // tube2 level switch - Scorpion2_SetSwitchState(3,2,1); // tube3 level switch + Scorpion2_SetSwitchState(machine,3,0,1); // tube1 level switch + Scorpion2_SetSwitchState(machine,3,1,1); // tube2 level switch + Scorpion2_SetSwitchState(machine,3,2,1); // tube3 level switch - sc2_show_door = 1; - sc2_door_state = 0x41; + state->sc2_show_door = 1; + state->sc2_door_state = 0x41; } // belgian slots initialisation ///////////////////////////////////////////// static DRIVER_INIT( sltsbelg ) { + bfm_sc2_state *state = machine->driver_data(); sc2_common_init(machine, 1); adder2_decode_char_roms(machine); // decode GFX roms adder2_common_init(machine); - has_hopper = 1; + state->has_hopper = 1; - sc2_show_door = 1; - sc2_door_state = 0x41; + state->sc2_show_door = 1; + state->sc2_door_state = 0x41; } // other dutch adder games //////////////////////////////////////////////// static DRIVER_INIT( adder_dutch ) { + bfm_sc2_state *state = machine->driver_data(); sc2_common_init(machine, 1); adder2_decode_char_roms(machine); // decode GFX roms adder2_common_init(machine); - has_hopper = 0; + state->has_hopper = 0; - Scorpion2_SetSwitchState(3,0,1); // tube1 level switch - Scorpion2_SetSwitchState(3,1,1); // tube2 level switch - Scorpion2_SetSwitchState(3,2,1); // tube3 level switch + Scorpion2_SetSwitchState(machine,3,0,1); // tube1 level switch + Scorpion2_SetSwitchState(machine,3,1,1); // tube2 level switch + Scorpion2_SetSwitchState(machine,3,2,1); // tube3 level switch - sc2_show_door = 1; - sc2_door_state = 0x41; + state->sc2_show_door = 1; + state->sc2_door_state = 0x41; } // golden crown ////////////////////////////////////////////////////////// static DRIVER_INIT( gldncrwn ) { + bfm_sc2_state *state = machine->driver_data(); sc2_common_init(machine, 1); adder2_decode_char_roms(machine); // decode GFX roms adder2_common_init(machine); - has_hopper = 0; + state->has_hopper = 0; - Scorpion2_SetSwitchState(3,0,1); // tube1 level switch - Scorpion2_SetSwitchState(3,1,1); // tube2 level switch - Scorpion2_SetSwitchState(3,2,1); // tube3 level switch + Scorpion2_SetSwitchState(machine,3,0,1); // tube1 level switch + Scorpion2_SetSwitchState(machine,3,1,1); // tube2 level switch + Scorpion2_SetSwitchState(machine,3,2,1); // tube3 level switch - sc2_show_door = 0; - sc2_door_state = 0x41; + state->sc2_show_door = 0; + state->sc2_door_state = 0x41; } // ROM definition UK Quintoon //////////////////////////////////////////// @@ -2597,18 +2653,20 @@ GAMEL( 1997, gldncrwn, 0, scorpion2_vid, gldncrwn, gldncrwn, 0, "BFM #include "awpvid14.lh" #include "awpvid16.lh" + /* Reels 1 and 2 */ static WRITE8_HANDLER( reel12_w ) { - reel12_latch = data; + bfm_sc2_state *state = space->machine->driver_data(); + state->reel12_latch = data; - if ( stepper_update(0, data ) ) reel_changed |= 0x01; - if ( stepper_update(1, data>>4) ) reel_changed |= 0x02; + if ( stepper_update(0, data ) ) state->reel_changed |= 0x01; + if ( stepper_update(1, data>>4) ) state->reel_changed |= 0x02; - if ( stepper_optic_state(0) ) optic_pattern |= 0x01; - else optic_pattern &= ~0x01; - if ( stepper_optic_state(1) ) optic_pattern |= 0x02; - else optic_pattern &= ~0x02; + if ( stepper_optic_state(0) ) state->optic_pattern |= 0x01; + else state->optic_pattern &= ~0x01; + if ( stepper_optic_state(1) ) state->optic_pattern |= 0x02; + else state->optic_pattern &= ~0x02; awp_draw_reel(0); awp_draw_reel(1); @@ -2618,11 +2676,12 @@ static WRITE8_HANDLER( reel12_w ) /* VFD Status */ static READ8_HANDLER( vfd_status_r ) { + bfm_sc2_state *state = space->machine->driver_data(); /* b7 = NEC busy */ /* b6 = alpha busy (also matrix board) */ /* b5 - b0 = reel optics */ - int result = optic_pattern; + int result = state->optic_pattern; if ( !upd7759_busy_r(space->machine->device("upd")) ) result |= 0x80; @@ -2632,11 +2691,12 @@ static READ8_HANDLER( vfd_status_r ) /* VFD Status and data */ static READ8_HANDLER( vfd_status_dm01_r ) { + bfm_sc2_state *state = space->machine->driver_data(); /* b7 = NEC busy */ /* b6 = alpha busy (also matrix board) */ /* b5 - b0 = reel optics */ - int result = optic_pattern; + int result = state->optic_pattern; if ( !upd7759_busy_r(space->machine->device("upd")) ) result |= 0x80; @@ -2648,7 +2708,8 @@ static READ8_HANDLER( vfd_status_dm01_r ) static WRITE8_HANDLER( vfd1_data_dm01_w ) { - vfd1_latch = data; + bfm_sc2_state *state = space->machine->driver_data(); + state->vfd1_latch = data; BFM_dm01_writedata(space->machine,data); } @@ -2701,7 +2762,7 @@ static MACHINE_RESET( awp_init ) static MACHINE_RESET( dm01_init ) { on_scorpion2_reset(machine); - BFM_dm01_reset(); + BFM_dm01_reset(machine); } @@ -2755,7 +2816,7 @@ ADDRESS_MAP_END /* memory map for scorpion3 board */ static ADDRESS_MAP_START( sc3_memmap, ADDRESS_SPACE_PROGRAM, 8 ) - AM_RANGE(0x0000, 0x1fff) AM_RAM AM_SHARE("nvram")//8k + AM_RANGE(0x0000, 0x1fff) AM_RAM AM_SHARE("nvram") //8k AM_RANGE(0x2000, 0x2000) AM_READ(vfd_status_r) AM_RANGE(0x2000, 0x20FF) AM_WRITE(reel12_w) AM_RANGE(0x2100, 0x21FF) AM_WRITE(reel34_w) @@ -2804,7 +2865,7 @@ ADDRESS_MAP_END /* memory map for scorpion2 board + dm01 dot matrix board */ static ADDRESS_MAP_START( memmap_sc2_dm01, ADDRESS_SPACE_PROGRAM, 8 ) - AM_RANGE(0x0000, 0x1fff) AM_RAM AM_SHARE("nvram")//8k + AM_RANGE(0x0000, 0x1fff) AM_RAM AM_SHARE("nvram") //8k AM_RANGE(0x2000, 0x2000) AM_READ(vfd_status_dm01_r) AM_RANGE(0x2000, 0x20FF) AM_WRITE(reel12_w) AM_RANGE(0x2100, 0x21FF) AM_WRITE(reel34_w) @@ -3925,7 +3986,7 @@ INPUT_PORTS_END /* machine driver for scorpion2 board */ -static MACHINE_CONFIG_START( scorpion2, driver_device ) +static MACHINE_CONFIG_START( scorpion2, bfm_sc2_state ) MCFG_MACHINE_RESET(awp_init) MCFG_CPU_ADD("maincpu", M6809, MASTER_CLOCK/4 ) MCFG_CPU_PROGRAM_MAP(sc2_memmap) @@ -3954,7 +4015,7 @@ MACHINE_CONFIG_END /* machine driver for scorpion2 board + matrix board */ -static MACHINE_CONFIG_START( scorpion2_dm01, driver_device ) +static MACHINE_CONFIG_START( scorpion2_dm01, bfm_sc2_state ) MCFG_MACHINE_RESET(dm01_init) MCFG_QUANTUM_TIME(attotime::from_hz(960)) // needed for serial communication !! MCFG_CPU_ADD("maincpu", M6809, MASTER_CLOCK/4 ) @@ -3995,64 +4056,67 @@ static void sc2awp_common_init(running_machine *machine,int reels, int decrypt) static DRIVER_INIT (bbrkfst) { + bfm_sc2_state *state = machine->driver_data(); sc2awp_common_init(machine,5, 1); MechMtr_config(machine,8); BFM_BD1_init(0); BFM_BD1_init(1); - has_hopper = 0; + state->has_hopper = 0; - Scorpion2_SetSwitchState(4,0, 1); /* GBP1 Low Level Switch */ - Scorpion2_SetSwitchState(4,1, 1); /* 20p Low Level Switch */ - Scorpion2_SetSwitchState(4,2, 1); /* Token Front Low Level Switch */ - Scorpion2_SetSwitchState(4,3, 1); /* Token Rear Low Level Switch */ - Scorpion2_SetSwitchState(4,4, 1); - Scorpion2_SetSwitchState(6,0, 0); - Scorpion2_SetSwitchState(6,1, 1); - Scorpion2_SetSwitchState(6,2, 0); - Scorpion2_SetSwitchState(6,3, 1); + Scorpion2_SetSwitchState(machine,4,0, 1); /* GBP1 Low Level Switch */ + Scorpion2_SetSwitchState(machine,4,1, 1); /* 20p Low Level Switch */ + Scorpion2_SetSwitchState(machine,4,2, 1); /* Token Front Low Level Switch */ + Scorpion2_SetSwitchState(machine,4,3, 1); /* Token Rear Low Level Switch */ + Scorpion2_SetSwitchState(machine,4,4, 1); + Scorpion2_SetSwitchState(machine,6,0, 0); + Scorpion2_SetSwitchState(machine,6,1, 1); + Scorpion2_SetSwitchState(machine,6,2, 0); + Scorpion2_SetSwitchState(machine,6,3, 1); } static DRIVER_INIT (drwho) { + bfm_sc2_state *state = machine->driver_data(); sc2awp_common_init(machine,4, 1); MechMtr_config(machine,8); BFM_BD1_init(0); BFM_BD1_init(1); - has_hopper = 0; + state->has_hopper = 0; - Scorpion2_SetSwitchState(4,0, 0); /* GBP1 Low Level Switch */ - Scorpion2_SetSwitchState(4,1, 0); /* 20p Low Level Switch */ - Scorpion2_SetSwitchState(4,2, 0); /* Token Front Low Level Switch */ - Scorpion2_SetSwitchState(4,3, 0); /* Token Rear Low Level Switch */ - Scorpion2_SetSwitchState(7,0, 0); /* GBP1 High Level Switch */ - Scorpion2_SetSwitchState(7,1, 0); /* 20P High Level Switch */ - Scorpion2_SetSwitchState(7,2, 0); /* Token Front High Level Switch */ - Scorpion2_SetSwitchState(7,3, 0); /* Token Rear High Level Switch */ + Scorpion2_SetSwitchState(machine,4,0, 0); /* GBP1 Low Level Switch */ + Scorpion2_SetSwitchState(machine,4,1, 0); /* 20p Low Level Switch */ + Scorpion2_SetSwitchState(machine,4,2, 0); /* Token Front Low Level Switch */ + Scorpion2_SetSwitchState(machine,4,3, 0); /* Token Rear Low Level Switch */ + Scorpion2_SetSwitchState(machine,7,0, 0); /* GBP1 High Level Switch */ + Scorpion2_SetSwitchState(machine,7,1, 0); /* 20P High Level Switch */ + Scorpion2_SetSwitchState(machine,7,2, 0); /* Token Front High Level Switch */ + Scorpion2_SetSwitchState(machine,7,3, 0); /* Token Rear High Level Switch */ } static DRIVER_INIT (drwhon) { + bfm_sc2_state *state = machine->driver_data(); sc2awp_common_init(machine,4, 0); MechMtr_config(machine,8); BFM_BD1_init(0); BFM_BD1_init(1); - has_hopper = 0; + state->has_hopper = 0; - Scorpion2_SetSwitchState(4,0, 0); /* GBP1 Low Level Switch */ - Scorpion2_SetSwitchState(4,1, 0); /* 20p Low Level Switch */ - Scorpion2_SetSwitchState(4,2, 0); /* Token Front Low Level Switch */ - Scorpion2_SetSwitchState(4,3, 0); /* Token Rear Low Level Switch */ - Scorpion2_SetSwitchState(7,0, 0); /* GBP1 High Level Switch */ - Scorpion2_SetSwitchState(7,1, 0); /* 20P High Level Switch */ - Scorpion2_SetSwitchState(7,2, 0); /* Token Front High Level Switch */ - Scorpion2_SetSwitchState(7,3, 0); /* Token Rear High Level Switch */ + Scorpion2_SetSwitchState(machine,4,0, 0); /* GBP1 Low Level Switch */ + Scorpion2_SetSwitchState(machine,4,1, 0); /* 20p Low Level Switch */ + Scorpion2_SetSwitchState(machine,4,2, 0); /* Token Front Low Level Switch */ + Scorpion2_SetSwitchState(machine,4,3, 0); /* Token Rear Low Level Switch */ + Scorpion2_SetSwitchState(machine,7,0, 0); /* GBP1 High Level Switch */ + Scorpion2_SetSwitchState(machine,7,1, 0); /* 20P High Level Switch */ + Scorpion2_SetSwitchState(machine,7,2, 0); /* Token Front High Level Switch */ + Scorpion2_SetSwitchState(machine,7,3, 0); /* Token Rear High Level Switch */ } @@ -4066,79 +4130,82 @@ static DRIVER_INIT (focus) static DRIVER_INIT (cpeno1) { + bfm_sc2_state *state = machine->driver_data(); sc2awp_common_init(machine,6, 1); MechMtr_config(machine,5); - Scorpion2_SetSwitchState(3,3,1); /* 5p play */ - Scorpion2_SetSwitchState(3,4,1); /* 20p play */ + Scorpion2_SetSwitchState(machine,3,3,1); /* 5p play */ + Scorpion2_SetSwitchState(machine,3,4,1); /* 20p play */ - Scorpion2_SetSwitchState(4,0,1); /* pay tube low (1 pound front) */ - Scorpion2_SetSwitchState(4,1,1); /* pay tube low (20p) */ - Scorpion2_SetSwitchState(4,2,1); /* pay tube low (?1 right) */ - Scorpion2_SetSwitchState(4,3,1); /* pay tube low (?1 left) */ + Scorpion2_SetSwitchState(machine,4,0,1); /* pay tube low (1 pound front) */ + Scorpion2_SetSwitchState(machine,4,1,1); /* pay tube low (20p) */ + Scorpion2_SetSwitchState(machine,4,2,1); /* pay tube low (?1 right) */ + Scorpion2_SetSwitchState(machine,4,3,1); /* pay tube low (?1 left) */ - Scorpion2_SetSwitchState(5,0,1); /* pay sensor (GBP1 front) */ - Scorpion2_SetSwitchState(5,1,1); /* pay sensor (20 p) */ - Scorpion2_SetSwitchState(5,2,1); /* pay sensor (1 right) */ - Scorpion2_SetSwitchState(5,3,1); /* pay sensor (?1 left) */ - Scorpion2_SetSwitchState(5,4,1); /* payout unit present */ + Scorpion2_SetSwitchState(machine,5,0,1); /* pay sensor (GBP1 front) */ + Scorpion2_SetSwitchState(machine,5,1,1); /* pay sensor (20 p) */ + Scorpion2_SetSwitchState(machine,5,2,1); /* pay sensor (1 right) */ + Scorpion2_SetSwitchState(machine,5,3,1); /* pay sensor (?1 left) */ + Scorpion2_SetSwitchState(machine,5,4,1); /* payout unit present */ - slide_pay_sensor[0] = 0x50; - slide_pay_sensor[1] = 0x51; - slide_pay_sensor[2] = 0x52; - slide_pay_sensor[3] = 0x53; - slide_pay_sensor[4] = 0; - slide_pay_sensor[5] = 0; + state->slide_pay_sensor[0] = 0x50; + state->slide_pay_sensor[1] = 0x51; + state->slide_pay_sensor[2] = 0x52; + state->slide_pay_sensor[3] = 0x53; + state->slide_pay_sensor[4] = 0; + state->slide_pay_sensor[5] = 0; - Scorpion2_SetSwitchState(6,0,1); /* ? percentage key */ - Scorpion2_SetSwitchState(6,1,1); - Scorpion2_SetSwitchState(6,2,1); - Scorpion2_SetSwitchState(6,3,1); - Scorpion2_SetSwitchState(6,4,1); + Scorpion2_SetSwitchState(machine,6,0,1); /* ? percentage key */ + Scorpion2_SetSwitchState(machine,6,1,1); + Scorpion2_SetSwitchState(machine,6,2,1); + Scorpion2_SetSwitchState(machine,6,3,1); + Scorpion2_SetSwitchState(machine,6,4,1); - Scorpion2_SetSwitchState(7,0,0); /* GBP1 High Level Switch */ - Scorpion2_SetSwitchState(7,1,0); /* 20P High Level Switch */ - Scorpion2_SetSwitchState(7,2,0); /* Token Front High Level Switch */ - Scorpion2_SetSwitchState(7,3,0); /* Token Rear High Level Switch */ + Scorpion2_SetSwitchState(machine,7,0,0); /* GBP1 High Level Switch */ + Scorpion2_SetSwitchState(machine,7,1,0); /* 20P High Level Switch */ + Scorpion2_SetSwitchState(machine,7,2,0); /* Token Front High Level Switch */ + Scorpion2_SetSwitchState(machine,7,3,0); /* Token Rear High Level Switch */ - sc2_show_door = 1; - sc2_door_state = 0x31; + state->sc2_show_door = 1; + state->sc2_door_state = 0x31; - has_hopper = 0; + state->has_hopper = 0; } static DRIVER_INIT (bfmcgslm) { + bfm_sc2_state *state = machine->driver_data(); sc2awp_common_init(machine,6, 1); MechMtr_config(machine,8); BFM_BD1_init(0); - has_hopper = 0; + state->has_hopper = 0; } static DRIVER_INIT (luvjub) { + bfm_sc2_state *state = machine->driver_data(); sc2awp_common_init(machine,6, 1); MechMtr_config(machine,8); - has_hopper = 0; + state->has_hopper = 0; - Scorpion2_SetSwitchState(3,0,1); - Scorpion2_SetSwitchState(3,1,1); + Scorpion2_SetSwitchState(machine,3,0,1); + Scorpion2_SetSwitchState(machine,3,1,1); - Scorpion2_SetSwitchState(4,0,1); - Scorpion2_SetSwitchState(4,1,1); - Scorpion2_SetSwitchState(4,2,1); - Scorpion2_SetSwitchState(4,3,1); + Scorpion2_SetSwitchState(machine,4,0,1); + Scorpion2_SetSwitchState(machine,4,1,1); + Scorpion2_SetSwitchState(machine,4,2,1); + Scorpion2_SetSwitchState(machine,4,3,1); - Scorpion2_SetSwitchState(6,0,1); - Scorpion2_SetSwitchState(6,1,1); - Scorpion2_SetSwitchState(6,2,1); - Scorpion2_SetSwitchState(6,3,0); + Scorpion2_SetSwitchState(machine,6,0,1); + Scorpion2_SetSwitchState(machine,6,1,1); + Scorpion2_SetSwitchState(machine,6,2,1); + Scorpion2_SetSwitchState(machine,6,3,0); - Scorpion2_SetSwitchState(7,0,0); - Scorpion2_SetSwitchState(7,1,0); - Scorpion2_SetSwitchState(7,2,0); - Scorpion2_SetSwitchState(7,3,0); + Scorpion2_SetSwitchState(machine,7,0,0); + Scorpion2_SetSwitchState(machine,7,1,0); + Scorpion2_SetSwitchState(machine,7,2,0); + Scorpion2_SetSwitchState(machine,7,3,0); } /********************************************* diff --git a/src/mame/drivers/bfmsys85.c b/src/mame/drivers/bfmsys85.c index 9d5930e5c51..4135842658f 100644 --- a/src/mame/drivers/bfmsys85.c +++ b/src/mame/drivers/bfmsys85.c @@ -67,6 +67,32 @@ ___________________________________________________________________________ #include "sound/ay8910.h" #include "machine/nvram.h" + +class bfmsys85_state : public driver_device +{ +public: + bfmsys85_state(running_machine &machine, const driver_device_config_base &config) + : driver_device(machine, config) { } + + int mmtr_latch; + int triac_latch; + int vfd_latch; + int irq_status; + int optic_pattern; + int locked; + int is_timer_enabled; + int reel_changed; + int coin_inhibits; + int mux_output_strobe; + int mux_input_strobe; + int mux_input; + UINT8 Lamps[128]; + UINT8 Inputs[64]; + UINT8 sys85_data_line_r; + UINT8 sys85_data_line_t; +}; + + #define VFD_RESET 0x20 #define VFD_CLOCK1 0x80 #define VFD_DATA 0x40 @@ -78,39 +104,25 @@ ___________________________________________________________________________ // local vars ///////////////////////////////////////////////////////////// -static int mmtr_latch; // mechanical meter latch -static int triac_latch; // payslide triac latch -static int vfd_latch; // vfd latch -static int irq_status; // custom chip IRQ status -static int optic_pattern; // reel optics -static int locked; // hardware lock/unlock status (0=unlocked) -static int is_timer_enabled; -static int reel_changed; -static int coin_inhibits; -static int mux_output_strobe; -static int mux_input_strobe; -static int mux_input; // user interface stuff /////////////////////////////////////////////////// -static UINT8 Lamps[128]; // 128 multiplexed lamps -static UINT8 Inputs[64]; // ?? multiplexed inputs /////////////////////////////////////////////////////////////////////////// // Serial Communications (Where does this go?) //////////////////////////// /////////////////////////////////////////////////////////////////////////// -static UINT8 sys85_data_line_r; -static UINT8 sys85_data_line_t; static READ_LINE_DEVICE_HANDLER( sys85_data_r ) { - return sys85_data_line_r; + bfmsys85_state *state = device->machine->driver_data(); + return state->sys85_data_line_r; } static WRITE_LINE_DEVICE_HANDLER( sys85_data_w ) { - sys85_data_line_t = state; + bfmsys85_state *drvstate = device->machine->driver_data(); + drvstate->sys85_data_line_t = state; } static ACIA6850_INTERFACE( m6809_acia_if ) @@ -128,15 +140,16 @@ static ACIA6850_INTERFACE( m6809_acia_if ) static MACHINE_RESET( bfm_sys85 ) { - vfd_latch = 0; - mmtr_latch = 0; - triac_latch = 0; - irq_status = 0; - is_timer_enabled = 1; - coin_inhibits = 0; - mux_output_strobe = 0; - mux_input_strobe = 0; - mux_input = 0; + bfmsys85_state *state = machine->driver_data(); + state->vfd_latch = 0; + state->mmtr_latch = 0; + state->triac_latch = 0; + state->irq_status = 0; + state->is_timer_enabled = 1; + state->coin_inhibits = 0; + state->mux_output_strobe = 0; + state->mux_input_strobe = 0; + state->mux_input = 0; ROC10937_reset(0); // reset display1 @@ -149,9 +162,9 @@ static MACHINE_RESET( bfm_sys85 ) stepper_reset_position(i); if ( stepper_optic_state(i) ) pattern |= 1<optic_pattern = pattern; } - locked = 0x00; // hardware is NOT locked + state->locked = 0x00; // hardware is NOT state->locked } /////////////////////////////////////////////////////////////////////////// @@ -164,9 +177,10 @@ static WRITE8_HANDLER( watchdog_w ) static INTERRUPT_GEN( timer_irq ) { - if ( is_timer_enabled ) + bfmsys85_state *state = device->machine->driver_data(); + if ( state->is_timer_enabled ) { - irq_status = 0x01 |0x02; //0xff; + state->irq_status = 0x01 |0x02; //0xff; generic_pulse_irq_line(device, M6809_IRQ_LINE); } } @@ -175,9 +189,10 @@ static INTERRUPT_GEN( timer_irq ) static READ8_HANDLER( irqlatch_r ) { - int result = irq_status | 0x02; + bfmsys85_state *state = space->machine->driver_data(); + int result = state->irq_status | 0x02; - irq_status = 0; + state->irq_status = 0; return result; } @@ -186,13 +201,14 @@ static READ8_HANDLER( irqlatch_r ) static WRITE8_HANDLER( reel12_w ) { - if ( stepper_update(0, data>>4) ) reel_changed |= 0x01; - if ( stepper_update(1, data ) ) reel_changed |= 0x02; + bfmsys85_state *state = space->machine->driver_data(); + if ( stepper_update(0, data>>4) ) state->reel_changed |= 0x01; + if ( stepper_update(1, data ) ) state->reel_changed |= 0x02; - if ( stepper_optic_state(0) ) optic_pattern |= 0x01; - else optic_pattern &= ~0x01; - if ( stepper_optic_state(1) ) optic_pattern |= 0x02; - else optic_pattern &= ~0x02; + if ( stepper_optic_state(0) ) state->optic_pattern |= 0x01; + else state->optic_pattern &= ~0x01; + if ( stepper_optic_state(1) ) state->optic_pattern |= 0x02; + else state->optic_pattern &= ~0x02; awp_draw_reel(0); awp_draw_reel(1); } @@ -201,13 +217,14 @@ static WRITE8_HANDLER( reel12_w ) static WRITE8_HANDLER( reel34_w ) { - if ( stepper_update(2, data>>4) ) reel_changed |= 0x04; - if ( stepper_update(3, data ) ) reel_changed |= 0x08; + bfmsys85_state *state = space->machine->driver_data(); + if ( stepper_update(2, data>>4) ) state->reel_changed |= 0x04; + if ( stepper_update(3, data ) ) state->reel_changed |= 0x08; - if ( stepper_optic_state(2) ) optic_pattern |= 0x04; - else optic_pattern &= ~0x04; - if ( stepper_optic_state(3) ) optic_pattern |= 0x08; - else optic_pattern &= ~0x08; + if ( stepper_optic_state(2) ) state->optic_pattern |= 0x04; + else state->optic_pattern &= ~0x04; + if ( stepper_optic_state(3) ) state->optic_pattern |= 0x08; + else state->optic_pattern &= ~0x08; awp_draw_reel(2); awp_draw_reel(3); } @@ -218,10 +235,11 @@ static WRITE8_HANDLER( reel34_w ) static WRITE8_HANDLER( mmtr_w ) { + bfmsys85_state *state = space->machine->driver_data(); int i; - int changed = mmtr_latch ^ data; + int changed = state->mmtr_latch ^ data; - mmtr_latch = data; + state->mmtr_latch = data; for (i=0; i<8; i++) if ( changed & (1 << i) ) MechMtr_update(i, data & (1 << i) ); @@ -232,15 +250,17 @@ static WRITE8_HANDLER( mmtr_w ) static READ8_HANDLER( mmtr_r ) { - return mmtr_latch; + bfmsys85_state *state = space->machine->driver_data(); + return state->mmtr_latch; } /////////////////////////////////////////////////////////////////////////// static WRITE8_HANDLER( vfd_w ) { - int changed = vfd_latch ^ data; + bfmsys85_state *state = space->machine->driver_data(); + int changed = state->vfd_latch ^ data; - vfd_latch = data; + state->vfd_latch = data; if ( changed ) { @@ -294,6 +314,7 @@ static const UINT8 BFM_strcnv85[] = static WRITE8_HANDLER( mux_ctrl_w ) { + bfmsys85_state *state = space->machine->driver_data(); switch ( data & 0xF0 ) { case 0x10: @@ -306,15 +327,15 @@ static WRITE8_HANDLER( mux_ctrl_w ) case 0x40: //logerror(" sys85 mux: read strobe"); - mux_input_strobe = data & 0x07; + state->mux_input_strobe = data & 0x07; - if ( mux_input_strobe == 5 ) Inputs[5] = 0xFF ^ optic_pattern; + if ( state->mux_input_strobe == 5 ) state->Inputs[5] = 0xFF ^ state->optic_pattern; - mux_input = ~Inputs[mux_input_strobe]; + state->mux_input = ~state->Inputs[state->mux_input_strobe]; break; case 0x80: - mux_output_strobe = data & 0x0F; + state->mux_output_strobe = data & 0x0F; break; case 0xC0: @@ -336,28 +357,30 @@ static READ8_HANDLER( mux_ctrl_r ) static WRITE8_HANDLER( mux_data_w ) { + bfmsys85_state *state = space->machine->driver_data(); int pattern = 0x01, i, - off = mux_output_strobe<<4; + off = state->mux_output_strobe<<4; for ( i = 0; i < 8; i++ ) { - Lamps[BFM_strcnv85[off]] = data & pattern ? 1 : 0; + state->Lamps[BFM_strcnv85[off]] = data & pattern ? 1 : 0; pattern <<= 1; off++; } - if (mux_output_strobe == 0) + if (state->mux_output_strobe == 0) { for ( i = 0; i < 128; i++ ) { - output_set_lamp_value(i, Lamps[i]); + output_set_lamp_value(i, state->Lamps[i]); } } } static READ8_HANDLER( mux_data_r ) { - return mux_input; + bfmsys85_state *state = space->machine->driver_data(); + return state->mux_input; } /////////////////////////////////////////////////////////////////////////// @@ -372,14 +395,16 @@ static WRITE8_HANDLER( mux_enable_w ) static WRITE8_HANDLER( triac_w ) { - triac_latch = data; + bfmsys85_state *state = space->machine->driver_data(); + state->triac_latch = data; } /////////////////////////////////////////////////////////////////////////// static READ8_HANDLER( triac_r ) { - return triac_latch; + bfmsys85_state *state = space->machine->driver_data(); + return state->triac_latch; } // machine start (called only once) //////////////////////////////////////// @@ -433,7 +458,7 @@ ADDRESS_MAP_END // machine driver for system85 board ////////////////////////////////////// -static MACHINE_CONFIG_START( bfmsys85, driver_device ) +static MACHINE_CONFIG_START( bfmsys85, bfmsys85_state ) MCFG_MACHINE_START(bfm_sys85) // main system85 board initialisation MCFG_MACHINE_RESET(bfm_sys85) MCFG_CPU_ADD("maincpu", M6809, MASTER_CLOCK/4) // 6809 CPU at 1 Mhz diff --git a/src/mame/drivers/bmcbowl.c b/src/mame/drivers/bmcbowl.c index d5a4a42172d..efd2e5e16c9 100644 --- a/src/mame/drivers/bmcbowl.c +++ b/src/mame/drivers/bmcbowl.c @@ -107,14 +107,24 @@ Main board: #include "sound/ay8910.h" #include "sound/okim6295.h" -static UINT16 *bmcbowl_vid1; -static UINT16 *bmcbowl_vid2; -static UINT8 *bmc_colorram; -static UINT8 *stats_ram; -static size_t stats_ram_size; -static int clr_offset=0; -static int bmc_input=0; +class bmcbowl_state : public driver_device +{ +public: + bmcbowl_state(running_machine &machine, const driver_device_config_base &config) + : driver_device(machine, config) { } + + UINT16 *vid1; + UINT16 *vid2; + UINT8 *bmc_colorram; + UINT8 *stats_ram; + size_t stats_ram_size; + int clr_offset; + int bmc_input; +}; + + + #define NVRAM_HACK @@ -124,6 +134,7 @@ static VIDEO_START( bmcbowl ) static VIDEO_UPDATE( bmcbowl ) { + bmcbowl_state *state = screen->machine->driver_data(); /* 280x230,4 bitmap layers, 8bpp, missing scroll and priorities (maybe fixed ones) @@ -137,28 +148,28 @@ static VIDEO_UPDATE( bmcbowl ) { for (x=0;x<280;x+=2) { - pixdat = bmcbowl_vid2[0x8000+z]; + pixdat = state->vid2[0x8000+z]; if(pixdat&0xff) *BITMAP_ADDR16(bitmap, y, x+1) = (pixdat&0xff); if(pixdat>>8) *BITMAP_ADDR16(bitmap, y, x) = (pixdat>>8); - pixdat = bmcbowl_vid2[z]; + pixdat = state->vid2[z]; if(pixdat&0xff) *BITMAP_ADDR16(bitmap, y, x+1) = (pixdat&0xff); if(pixdat>>8) *BITMAP_ADDR16(bitmap, y, x) = (pixdat>>8); - pixdat = bmcbowl_vid1[0x8000+z]; + pixdat = state->vid1[0x8000+z]; if(pixdat&0xff) *BITMAP_ADDR16(bitmap, y, x+1) = (pixdat&0xff); if(pixdat>>8) *BITMAP_ADDR16(bitmap, y, x) = (pixdat>>8); - pixdat = bmcbowl_vid1[z]; + pixdat = state->vid1[z]; if(pixdat&0xff) *BITMAP_ADDR16(bitmap, y, x+1) = (pixdat&0xff); @@ -195,14 +206,16 @@ static READ16_HANDLER( bmc_protection_r ) static WRITE16_HANDLER( bmc_RAMDAC_offset_w ) { - clr_offset=data*3; + bmcbowl_state *state = space->machine->driver_data(); + state->clr_offset=data*3; } static WRITE16_HANDLER( bmc_RAMDAC_color_w ) { - bmc_colorram[clr_offset]=data; - palette_set_color_rgb(space->machine,clr_offset/3,pal6bit(bmc_colorram[(clr_offset/3)*3]),pal6bit(bmc_colorram[(clr_offset/3)*3+1]),pal6bit(bmc_colorram[(clr_offset/3)*3+2])); - clr_offset=(clr_offset+1)%768; + bmcbowl_state *state = space->machine->driver_data(); + state->bmc_colorram[state->clr_offset]=data; + palette_set_color_rgb(space->machine,state->clr_offset/3,pal6bit(state->bmc_colorram[(state->clr_offset/3)*3]),pal6bit(state->bmc_colorram[(state->clr_offset/3)*3+1]),pal6bit(state->bmc_colorram[(state->clr_offset/3)*3+2])); + state->clr_offset=(state->clr_offset+1)%768; } static WRITE16_HANDLER( scroll_w ) @@ -276,36 +289,37 @@ static const UINT8 bmc_nv3[]= }; -static void init_stats(const UINT8 *table, int table_len, int address) +static void init_stats(bmcbowl_state *state, const UINT8 *table, int table_len, int address) { int i; for (i=0; istats_ram[address+2*i]=table[i]; } #endif static NVRAM_HANDLER( bmcbowl ) { + bmcbowl_state *state = machine->driver_data(); int i; if (read_or_write) - file->write(stats_ram, stats_ram_size); + file->write(state->stats_ram, state->stats_ram_size); else #ifdef NVRAM_HACK - for (i = 0; i < stats_ram_size; i++) - stats_ram[i] = 0xff; + for (i = 0; i < state->stats_ram_size; i++) + state->stats_ram[i] = 0xff; - init_stats(bmc_nv1,ARRAY_LENGTH(bmc_nv1),0); - init_stats(bmc_nv2,ARRAY_LENGTH(bmc_nv2),0x3b0); - init_stats(bmc_nv3,ARRAY_LENGTH(bmc_nv3),0xfe2); + init_stats(state,bmc_nv1,ARRAY_LENGTH(bmc_nv1),0); + init_stats(state,bmc_nv2,ARRAY_LENGTH(bmc_nv2),0x3b0); + init_stats(state,bmc_nv3,ARRAY_LENGTH(bmc_nv3),0xfe2); #else if (file) - file->read(stats_ram, stats_ram_size); + file->read(state->stats_ram, state->stats_ram_size); else - for (i = 0; i < stats_ram_size; i++) - stats_ram[i] = 0xff; + for (i = 0; i < state->stats_ram_size; i++) + state->stats_ram[i] = 0xff; #endif } @@ -327,12 +341,12 @@ static ADDRESS_MAP_START( bmcbowl_mem, ADDRESS_SPACE_PROGRAM, 16 ) AM_RANGE(0x092800, 0x092803) AM_DEVWRITE8("aysnd", ay8910_data_address_w, 0xff00) AM_RANGE(0x092802, 0x092803) AM_DEVREAD8("aysnd", ay8910_r, 0xff00) AM_RANGE(0x093802, 0x093803) AM_READ_PORT("IN0") - AM_RANGE(0x095000, 0x095fff) AM_RAM AM_BASE((UINT16 **)&stats_ram) AM_SIZE(&stats_ram_size) /* 8 bit */ + AM_RANGE(0x095000, 0x095fff) AM_RAM AM_BASE_MEMBER(bmcbowl_state, stats_ram) AM_SIZE_MEMBER(bmcbowl_state, stats_ram_size) /* 8 bit */ AM_RANGE(0x097000, 0x097001) AM_READNOP AM_RANGE(0x140000, 0x1bffff) AM_ROM - AM_RANGE(0x1c0000, 0x1effff) AM_RAM AM_BASE(&bmcbowl_vid1) + AM_RANGE(0x1c0000, 0x1effff) AM_RAM AM_BASE_MEMBER(bmcbowl_state, vid1) AM_RANGE(0x1f0000, 0x1fffff) AM_RAM - AM_RANGE(0x200000, 0x21ffff) AM_RAM AM_BASE(&bmcbowl_vid2) + AM_RANGE(0x200000, 0x21ffff) AM_RAM AM_BASE_MEMBER(bmcbowl_state, vid2) AM_RANGE(0x28c000, 0x28c001) AM_DEVREADWRITE8_MODERN("oki", okim6295_device, read, write, 0xff00) @@ -432,19 +446,21 @@ INPUT_PORTS_END static READ8_DEVICE_HANDLER(dips1_r) { - switch(bmc_input) + bmcbowl_state *state = device->machine->driver_data(); + switch(state->bmc_input) { case 0x00: return input_port_read(device->machine, "IN1"); case 0x40: return input_port_read(device->machine, "IN2"); } - logerror("%s:unknown input - %X\n",device->machine->describe_context(),bmc_input); + logerror("%s:unknown input - %X\n",device->machine->describe_context(),state->bmc_input); return 0xff; } static WRITE8_DEVICE_HANDLER(input_mux_w) { - bmc_input=data; + bmcbowl_state *state = device->machine->driver_data(); + state->bmc_input=data; } @@ -480,7 +496,7 @@ static INTERRUPT_GEN( bmc_interrupt ) cpu_set_input_line(device, 2, HOLD_LINE); } -static MACHINE_CONFIG_START( bmcbowl, driver_device ) +static MACHINE_CONFIG_START( bmcbowl, bmcbowl_state ) MCFG_CPU_ADD("maincpu", M68000, 21477270/2 ) MCFG_CPU_PROGRAM_MAP(bmcbowl_mem) MCFG_CPU_VBLANK_INT_HACK(bmc_interrupt,2) @@ -536,7 +552,8 @@ ROM_END static DRIVER_INIT(bmcbowl) { - bmc_colorram = auto_alloc_array(machine, UINT8, 768); + bmcbowl_state *state = machine->driver_data(); + state->bmc_colorram = auto_alloc_array(machine, UINT8, 768); } GAME( 1994, bmcbowl, 0, bmcbowl, bmcbowl, bmcbowl, ROT0, "BMC", "BMC Bowling", GAME_IMPERFECT_SOUND | GAME_IMPERFECT_GRAPHICS ) diff --git a/src/mame/drivers/caswin.c b/src/mame/drivers/caswin.c index 3254c15b161..bccbaad0b31 100644 --- a/src/mame/drivers/caswin.c +++ b/src/mame/drivers/caswin.c @@ -46,13 +46,25 @@ TODO: #include "sound/ay8910.h" #include "machine/nvram.h" -static UINT8 *sc0_vram,*sc0_attr; -static tilemap_t *sc0_tilemap; + +class caswin_state : public driver_device +{ +public: + caswin_state(running_machine &machine, const driver_device_config_base &config) + : driver_device(machine, config) { } + + UINT8 *sc0_vram; + UINT8 *sc0_attr; + tilemap_t *sc0_tilemap; +}; + + static TILE_GET_INFO( get_sc0_tile_info ) { - int tile = (sc0_vram[tile_index] | ((sc0_attr[tile_index] & 0x70)<<4)) & 0x7ff; - int colour = sc0_attr[tile_index] & 0xf; + caswin_state *state = machine->driver_data(); + int tile = (state->sc0_vram[tile_index] | ((state->sc0_attr[tile_index] & 0x70)<<4)) & 0x7ff; + int colour = state->sc0_attr[tile_index] & 0xf; SET_TILE_INFO( 0, @@ -63,25 +75,29 @@ static TILE_GET_INFO( get_sc0_tile_info ) static VIDEO_START(vvillage) { - sc0_tilemap = tilemap_create(machine, get_sc0_tile_info,tilemap_scan_rows,8,8,32,32); + caswin_state *state = machine->driver_data(); + state->sc0_tilemap = tilemap_create(machine, get_sc0_tile_info,tilemap_scan_rows,8,8,32,32); } static VIDEO_UPDATE(vvillage) { - tilemap_draw(bitmap,cliprect,sc0_tilemap,0,0); + caswin_state *state = screen->machine->driver_data(); + tilemap_draw(bitmap,cliprect,state->sc0_tilemap,0,0); return 0; } static WRITE8_HANDLER( sc0_vram_w ) { - sc0_vram[offset] = data; - tilemap_mark_tile_dirty(sc0_tilemap,offset); + caswin_state *state = space->machine->driver_data(); + state->sc0_vram[offset] = data; + tilemap_mark_tile_dirty(state->sc0_tilemap,offset); } static WRITE8_HANDLER( sc0_attr_w ) { - sc0_attr[offset] = data; - tilemap_mark_tile_dirty(sc0_tilemap,offset); + caswin_state *state = space->machine->driver_data(); + state->sc0_attr[offset] = data; + tilemap_mark_tile_dirty(state->sc0_tilemap,offset); } /*These two are tested during the two cherry sub-games.I really don't know what is supposed to do...*/ @@ -137,8 +153,8 @@ static ADDRESS_MAP_START( vvillage_mem, ADDRESS_SPACE_PROGRAM, 8 ) AM_RANGE(0x0000, 0x7fff) AM_ROM AM_RANGE(0xa000, 0xa000) AM_READ(vvillage_rng_r) //accessed by caswin only AM_RANGE(0xe000, 0xe7ff) AM_RAM AM_SHARE("nvram") - AM_RANGE(0xf000, 0xf3ff) AM_RAM_WRITE(sc0_vram_w) AM_BASE(&sc0_vram) - AM_RANGE(0xf800, 0xfbff) AM_RAM_WRITE(sc0_attr_w) AM_BASE(&sc0_attr) + AM_RANGE(0xf000, 0xf3ff) AM_RAM_WRITE(sc0_vram_w) AM_BASE_MEMBER(caswin_state, sc0_vram) + AM_RANGE(0xf800, 0xfbff) AM_RAM_WRITE(sc0_attr_w) AM_BASE_MEMBER(caswin_state, sc0_attr) ADDRESS_MAP_END static ADDRESS_MAP_START( vvillage_io, ADDRESS_SPACE_IO, 8 ) @@ -275,7 +291,7 @@ static PALETTE_INIT( caswin ) } -static MACHINE_CONFIG_START( vvillage, driver_device ) +static MACHINE_CONFIG_START( vvillage, caswin_state ) /* basic machine hardware */ MCFG_CPU_ADD("maincpu", Z80,4000000) /* ? MHz */ MCFG_CPU_PROGRAM_MAP(vvillage_mem) diff --git a/src/mame/drivers/cchasm.c b/src/mame/drivers/cchasm.c index 55a91582248..c406f8eef4d 100644 --- a/src/mame/drivers/cchasm.c +++ b/src/mame/drivers/cchasm.c @@ -38,7 +38,7 @@ static ADDRESS_MAP_START( memmap, ADDRESS_SPACE_PROGRAM, 16 ) AM_RANGE(0x060000, 0x060001) AM_READ_PORT("DSW") AM_WRITE(cchasm_led_w) AM_RANGE(0x070000, 0x070001) AM_WRITE(watchdog_reset16_w) AM_RANGE(0xf80000, 0xf800ff) AM_READWRITE(cchasm_io_r,cchasm_io_w) - AM_RANGE(0xffb000, 0xffffff) AM_RAM AM_BASE(&cchasm_ram) + AM_RANGE(0xffb000, 0xffffff) AM_RAM AM_BASE_MEMBER(cchasm_state, ram) ADDRESS_MAP_END /************************************* @@ -153,7 +153,7 @@ static const z80_daisy_config daisy_chain[] = * *************************************/ -static MACHINE_CONFIG_START( cchasm, driver_device ) +static MACHINE_CONFIG_START( cchasm, cchasm_state ) /* basic machine hardware */ MCFG_CPU_ADD("maincpu", M68000,CCHASM_68K_CLOCK) /* 8 MHz (from schematics) */ diff --git a/src/mame/drivers/cinemat.c b/src/mame/drivers/cinemat.c index efe315fb256..9df25a8a88f 100644 --- a/src/mame/drivers/cinemat.c +++ b/src/mame/drivers/cinemat.c @@ -43,17 +43,6 @@ #define MASTER_CLOCK XTAL_19_923MHz - -static UINT16 *rambase; - -static UINT8 coin_detected; -static UINT8 coin_last_reset; - -static UINT8 mux_select; -static int gear; - - - /************************************* * * General machine init @@ -62,20 +51,22 @@ static int gear; static MACHINE_START( cinemat ) { - state_save_register_global(machine, coin_detected); - state_save_register_global(machine, coin_last_reset); - state_save_register_global(machine, mux_select); + cinemat_state *state = machine->driver_data(); + state_save_register_global(machine, state->coin_detected); + state_save_register_global(machine, state->coin_last_reset); + state_save_register_global(machine, state->mux_select); } MACHINE_RESET( cinemat ) { + cinemat_state *state = machine->driver_data(); /* reset the coin states */ - coin_detected = 0; - coin_last_reset = 0; + state->coin_detected = 0; + state->coin_last_reset = 0; /* reset mux select */ - mux_select = 0; + state->mux_select = 0; } @@ -108,15 +99,17 @@ static READ8_HANDLER( switches_r ) static INPUT_CHANGED( coin_inserted ) { + cinemat_state *state = field->port->machine->driver_data(); /* on the falling edge of a new coin, set the coin_detected flag */ if (newval == 0) - coin_detected = 1; + state->coin_detected = 1; } static READ8_HANDLER( coin_input_r ) { - return !coin_detected; + cinemat_state *state = space->machine->driver_data(); + return !state->coin_detected; } @@ -129,16 +122,18 @@ static READ8_HANDLER( coin_input_r ) static WRITE8_HANDLER( coin_reset_w ) { + cinemat_state *state = space->machine->driver_data(); /* on the rising edge of a coin reset, clear the coin_detected flag */ - if (coin_last_reset != data && data != 0) - coin_detected = 0; - coin_last_reset = data; + if (state->coin_last_reset != data && data != 0) + state->coin_detected = 0; + state->coin_last_reset = data; } static WRITE8_HANDLER( mux_select_w ) { - mux_select = data; + cinemat_state *state = space->machine->driver_data(); + state->mux_select = data; cinemat_sound_control_w(space, 0x07, data); } @@ -152,12 +147,13 @@ static WRITE8_HANDLER( mux_select_w ) static UINT8 joystick_read(device_t *device) { + cinemat_state *state = device->machine->driver_data(); if (device->machine->phase() != MACHINE_PHASE_RUNNING) return 0; else { int xval = (INT16)(cpu_get_reg(device, CCPU_X) << 4) >> 4; - return (input_port_read_safe(device->machine, mux_select ? "ANALOGX" : "ANALOGY", 0) - xval) < 0x800; + return (input_port_read_safe(device->machine, state->mux_select ? "ANALOGX" : "ANALOGY", 0) - xval) < 0x800; } } @@ -187,17 +183,18 @@ static READ8_HANDLER( speedfrk_wheel_r ) static READ8_HANDLER( speedfrk_gear_r ) { + cinemat_state *state = space->machine->driver_data(); int gearval = input_port_read(space->machine, "GEAR"); /* check the fake gear input port and determine the bit settings for the gear */ if ((gearval & 0x0f) != 0x0f) - gear = gearval & 0x0f; + state->gear = gearval & 0x0f; - /* add the start key into the mix -- note that it overlaps 4th gear */ + /* add the start key into the mix -- note that it overlaps 4th state->gear */ if (!(input_port_read(space->machine, "INPUTS") & 0x80)) - gear &= ~0x08; + state->gear &= ~0x08; - return (gear >> offset) & 1; + return (state->gear >> offset) & 1; } @@ -255,8 +252,9 @@ static READ8_HANDLER( sundance_inputs_r ) static READ8_HANDLER( boxingb_dial_r ) { + cinemat_state *state = space->machine->driver_data(); int value = input_port_read(space->machine, "DIAL"); - if (!mux_select) offset += 4; + if (!state->mux_select) offset += 4; return (value >> offset) & 1; } @@ -319,7 +317,7 @@ static ADDRESS_MAP_START( data_map, ADDRESS_SPACE_DATA, 16 ) ADDRESS_MAP_END static ADDRESS_MAP_START( data_map_qb3, ADDRESS_SPACE_DATA, 16 ) - AM_RANGE(0x0000, 0x03ff) AM_RAMBANK("bank1") AM_BASE(&rambase) + AM_RANGE(0x0000, 0x03ff) AM_RAMBANK("bank1") AM_BASE_MEMBER(cinemat_state, rambase) ADDRESS_MAP_END @@ -992,7 +990,7 @@ static const ccpu_config config_jmi = * *************************************/ -static MACHINE_CONFIG_START( cinemat_nojmi_4k, driver_device ) +static MACHINE_CONFIG_START( cinemat_nojmi_4k, cinemat_state ) /* basic machine hardware */ MCFG_CPU_ADD("maincpu", CCPU, MASTER_CLOCK/4) @@ -1459,7 +1457,8 @@ ROM_END static DRIVER_INIT( speedfrk ) { - gear = 0xe; + cinemat_state *state = machine->driver_data(); + state->gear = 0xe; memory_install_read8_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_IO), 0x00, 0x03, 0, 0, speedfrk_wheel_r); memory_install_read8_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_IO), 0x04, 0x06, 0, 0, speedfrk_gear_r); } @@ -1486,10 +1485,11 @@ static DRIVER_INIT( boxingb ) static DRIVER_INIT( qb3 ) { + cinemat_state *state = machine->driver_data(); memory_install_read8_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_IO), 0x0f, 0x0f, 0, 0, qb3_frame_r); memory_install_write8_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_IO), 0x00, 0x00, 0, 0, qb3_ram_bank_w); - memory_configure_bank(machine, "bank1", 0, 4, rambase, 0x100*2); + memory_configure_bank(machine, "bank1", 0, 4, state->rambase, 0x100*2); } diff --git a/src/mame/drivers/cps3.c b/src/mame/drivers/cps3.c index 95c1cfe7782..c124bfc11b2 100644 --- a/src/mame/drivers/cps3.c +++ b/src/mame/drivers/cps3.c @@ -337,44 +337,6 @@ Notes: #define DMA_XOR(a) ((a) ^ NATIVE_ENDIAN_VALUE_LE_BE(1,2)) - -static fujitsu_29f016a_device *simm[7][8]; - -static UINT32* decrypted_bios; - -static UINT32* decrypted_gamerom; -static UINT32 cram_gfxflash_bank; -static UINT32* cps3_nops; - -static UINT32* tilemap20_regs_base; -static UINT32* tilemap30_regs_base; -static UINT32* tilemap40_regs_base; -static UINT32* tilemap50_regs_base; - -static UINT32* cps3_0xc0000000_ram; -static UINT32* cps3_0xc0000000_ram_decrypted; - -static UINT32* cps3_char_ram; - -static UINT32* cps3_spriteram; -static UINT32* cps3_eeprom; -static UINT32* cps3_fullscreenzoom; - -static UINT32 cps3_ss_pal_base = 0; -static UINT32* cps3_colourram; -static UINT32 cps3_unk_vidregs[0x20/4]; -static UINT32 cps3_ss_bank_base = 0; - -static UINT32 cps3_screenwidth; -//cdrom_file* cps3_cd; - -static UINT32* cps3_mame_colours;//[0x20000]; // actual values to write to 32-bit bitmap - -static bitmap_t *renderbuffer_bitmap; -static rectangle renderbuffer_clip; - -static UINT8* cps3_user4region; -UINT8* cps3_user5region; #define USER4REGION_LENGTH 0x800000*2 #define USER5REGION_LENGTH 0x800000*10 @@ -390,6 +352,7 @@ INLINE void cps3_drawgfxzoom(bitmap_t *dest_bmp,const rectangle *clip,const gfx_ int transparency,int transparent_color, int scalex, int scaley,bitmap_t *pri_buffer,UINT32 pri_mask) { + cps3_state *state = gfx->machine->driver_data(); rectangle myclip; // UINT8 al; @@ -436,7 +399,7 @@ INLINE void cps3_drawgfxzoom(bitmap_t *dest_bmp,const rectangle *clip,const gfx_ { // const pen_t *pal = &gfx->colortable[gfx->color_granularity * (color % gfx->total_colors)]; UINT32 palbase = (gfx->color_granularity * color) & 0x1ffff; - const pen_t *pal = &cps3_mame_colours[palbase]; + const pen_t *pal = &state->mame_colours[palbase]; const UINT8 *source_base = gfx_element_get_data(gfx, code % gfx->total_elements); int sprite_screen_height = (scaley*gfx->height+0x8000)>>16; @@ -616,8 +579,6 @@ DIRECT_UPDATE_HANDLER( cps3_direct_handler ); /* Encryption */ -static UINT32 cps3_key1, cps3_key2; -static int cps3_altEncryption; // sfiii2 has different encryption, data isn't encrypted outside of the bios static UINT16 rotate_left(UINT16 value, int n) { @@ -657,16 +618,17 @@ static UINT32 cps3_mask(UINT32 address, UINT32 key1, UINT32 key2) static void cps3_decrypt_bios(running_machine *machine) { + cps3_state *state = machine->driver_data(); int i; UINT32 *coderegion = (UINT32*)machine->region("user1")->base(); - decrypted_bios = (UINT32*)machine->region("user1")->base(); + state->decrypted_bios = (UINT32*)machine->region("user1")->base(); for (i=0;i<0x80000;i+=4) { UINT32 dword = coderegion[i/4]; - UINT32 xormask = cps3_mask(i, cps3_key1, cps3_key2); - decrypted_bios[i/4] = dword ^ xormask; + UINT32 xormask = cps3_mask(i, state->key1, state->key2); + state->decrypted_bios[i/4] = dword ^ xormask; } #if 0 /* Dump to file */ @@ -679,7 +641,7 @@ static void cps3_decrypt_bios(running_machine *machine) fp=fopen(filename, "w+b"); if (fp) { - fwrite(decrypted_bios, 0x080000, 1, fp); + fwrite(state->decrypted_bios, 0x080000, 1, fp); fclose(fp); } } @@ -687,28 +649,34 @@ static void cps3_decrypt_bios(running_machine *machine) } -static DRIVER_INIT( cps3 ) +static void init_common(running_machine *machine, UINT32 key1, UINT32 key2, int altEncryption) { - // cache pointers to regions - cps3_user4region = machine->region("user4")->base(); - cps3_user5region = machine->region("user5")->base(); + cps3_state *state = machine->driver_data(); - if (!cps3_user4region) cps3_user4region = auto_alloc_array(machine, UINT8, USER4REGION_LENGTH); - if (!cps3_user5region) cps3_user5region = auto_alloc_array(machine, UINT8, USER5REGION_LENGTH); + state->key1 = key1; + state->key2 = key2; + state->altEncryption = altEncryption; + + // cache pointers to regions + state->user4region = machine->region("user4")->base(); + state->user5region = machine->region("user5")->base(); + + if (!state->user4region) state->user4region = auto_alloc_array(machine, UINT8, USER4REGION_LENGTH); + if (!state->user5region) state->user5region = auto_alloc_array(machine, UINT8, USER5REGION_LENGTH); // set strict verify sh2drc_set_options(machine->device("maincpu"), SH2DRC_STRICT_VERIFY); cps3_decrypt_bios(machine); - decrypted_gamerom = auto_alloc_array(machine, UINT32, 0x1000000/4); + state->decrypted_gamerom = auto_alloc_array(machine, UINT32, 0x1000000/4); /* just some NOPs for the game to execute if it crashes and starts executing unmapped addresses - this prevents MAME from crashing */ - cps3_nops = auto_alloc(machine, UINT32); - cps3_nops[0] = 0x00090009; + state->nops = auto_alloc(machine, UINT32); + state->nops[0] = 0x00090009; - cps3_0xc0000000_ram_decrypted = auto_alloc_array(machine, UINT32, 0x400/4); + state->_0xc0000000_ram_decrypted = auto_alloc_array(machine, UINT32, 0x400/4); address_space *main = machine->device("maincpu")->space(AS_PROGRAM); main->set_direct_update_handler(direct_update_delegate_create_static(cps3_direct_handler, *machine)); @@ -717,18 +685,18 @@ static DRIVER_INIT( cps3 ) astring tempstr; for (int simmnum = 0; simmnum < 7; simmnum++) for (int chipnum = 0; chipnum < 8; chipnum++) - simm[simmnum][chipnum] = machine->device(tempstr.format("simm%d.%d", simmnum + 1, chipnum)); + state->simm[simmnum][chipnum] = machine->device(tempstr.format("simm%d.%d", simmnum + 1, chipnum)); - cps3_eeprom = auto_alloc_array(machine, UINT32, 0x400/4); - machine->device("eeprom")->set_base(cps3_eeprom, 0x400); + state->eeprom = auto_alloc_array(machine, UINT32, 0x400/4); + machine->device("eeprom")->set_base(state->eeprom, 0x400); } -static DRIVER_INIT( jojo ) { cps3_key1 = 0x02203ee3; cps3_key2 = 0x01301972; cps3_altEncryption = 0; DRIVER_INIT_CALL(cps3); } -static DRIVER_INIT( jojoba ) { cps3_key1 = 0x23323ee3; cps3_key2 = 0x03021972; cps3_altEncryption = 0; DRIVER_INIT_CALL(cps3); } -static DRIVER_INIT( sfiii ) { cps3_key1 = 0xb5fe053e; cps3_key2 = 0xfc03925a; cps3_altEncryption = 0; DRIVER_INIT_CALL(cps3); } -static DRIVER_INIT( sfiii2 ) { cps3_key1 = 0x00000000; cps3_key2 = 0x00000000; cps3_altEncryption = 1; DRIVER_INIT_CALL(cps3); } -static DRIVER_INIT( sfiii3 ) { cps3_key1 = 0xa55432b4; cps3_key2 = 0x0c129981; cps3_altEncryption = 0; DRIVER_INIT_CALL(cps3); } -static DRIVER_INIT( redearth ){ cps3_key1 = 0x9e300ab1; cps3_key2 = 0xa175b82c; cps3_altEncryption = 0; DRIVER_INIT_CALL(cps3); } +static DRIVER_INIT( jojo ) { init_common(machine, 0x02203ee3, 0x01301972, 0); } +static DRIVER_INIT( jojoba ) { init_common(machine, 0x23323ee3, 0x03021972, 0); } +static DRIVER_INIT( sfiii ) { init_common(machine, 0xb5fe053e, 0xfc03925a, 0); } +static DRIVER_INIT( sfiii2 ) { init_common(machine, 0x00000000, 0x00000000, 1); } +static DRIVER_INIT( sfiii3 ) { init_common(machine, 0xa55432b4, 0x0c129981, 0); } +static DRIVER_INIT( redearth ){ init_common(machine, 0x9e300ab1, 0xa175b82c, 0); } /* GFX decodes */ @@ -760,12 +728,12 @@ static const gfx_layout cps3_tiles8x8_layout = 64*8 }; -static UINT32* cps3_ss_ram; -static void cps3_set_mame_colours(running_machine *machine, int colournum, UINT16 data, UINT32 fadeval ) +static void cps3_set_mame_colours(running_machine *machine, int colournum, UINT16 data, UINT32 fadeval) { + cps3_state *state = machine->driver_data(); int r,g,b; - UINT16* dst = (UINT16*)cps3_colourram; + UINT16* dst = (UINT16*)state->colourram; r = (data >> 0) & 0x1f; @@ -795,48 +763,49 @@ static void cps3_set_mame_colours(running_machine *machine, int colournum, UINT1 dst[colournum] = data; - cps3_mame_colours[colournum] = (r << (16+3)) | (g << (8+3)) | (b << (0+3)); + state->mame_colours[colournum] = (r << (16+3)) | (g << (8+3)) | (b << (0+3)); - if (colournum<0x10000) palette_set_color(machine,colournum,cps3_mame_colours[colournum]/* MAKE_RGB(r<<3,g<<3,b<<3)*/);//cps3_mame_colours[colournum]); + if (colournum<0x10000) palette_set_color(machine,colournum,state->mame_colours[colournum]/* MAKE_RGB(r<<3,g<<3,b<<3)*/);//state->mame_colours[colournum]); } static VIDEO_START(cps3) { - cps3_ss_ram = auto_alloc_array(machine, UINT32, 0x10000/4); - memset(cps3_ss_ram, 0x00, 0x10000); - state_save_register_global_pointer(machine, cps3_ss_ram, 0x10000/4); + cps3_state *state = machine->driver_data(); + state->ss_ram = auto_alloc_array(machine, UINT32, 0x10000/4); + memset(state->ss_ram, 0x00, 0x10000); + state_save_register_global_pointer(machine, state->ss_ram, 0x10000/4); - cps3_char_ram = auto_alloc_array(machine, UINT32, 0x800000/4); - memset(cps3_char_ram, 0x00, 0x800000); - state_save_register_global_pointer(machine, cps3_char_ram, 0x800000 /4); + state->char_ram = auto_alloc_array(machine, UINT32, 0x800000/4); + memset(state->char_ram, 0x00, 0x800000); + state_save_register_global_pointer(machine, state->char_ram, 0x800000 /4); /* create the char set (gfx will then be updated dynamically from RAM) */ - machine->gfx[0] = gfx_element_alloc(machine, &cps3_tiles8x8_layout, (UINT8 *)cps3_ss_ram, machine->total_colors() / 16, 0); + machine->gfx[0] = gfx_element_alloc(machine, &cps3_tiles8x8_layout, (UINT8 *)state->ss_ram, machine->total_colors() / 16, 0); //decode_ssram(); /* create the char set (gfx will then be updated dynamically from RAM) */ - machine->gfx[1] = gfx_element_alloc(machine, &cps3_tiles16x16_layout, (UINT8 *)cps3_char_ram, machine->total_colors() / 64, 0); + machine->gfx[1] = gfx_element_alloc(machine, &cps3_tiles16x16_layout, (UINT8 *)state->char_ram, machine->total_colors() / 64, 0); machine->gfx[1]->color_granularity = 64; //decode_charram(); - cps3_mame_colours = auto_alloc_array(machine, UINT32, 0x80000/4); - memset(cps3_mame_colours, 0x00, 0x80000); + state->mame_colours = auto_alloc_array(machine, UINT32, 0x80000/4); + memset(state->mame_colours, 0x00, 0x80000); - cps3_screenwidth = 384; + state->screenwidth = 384; // the renderbuffer can be twice the size of the screen, this allows us to handle framebuffer zoom values // between 0x00 and 0x80 (0x40 is normal, 0x80 would be 'view twice as much', 0x20 is 'view half as much') - renderbuffer_bitmap = auto_bitmap_alloc(machine,512*2,224*2,machine->primary_screen->format()); + state->renderbuffer_bitmap = auto_bitmap_alloc(machine,512*2,224*2,machine->primary_screen->format()); - renderbuffer_clip.min_x = 0; - renderbuffer_clip.max_x = cps3_screenwidth-1; - renderbuffer_clip.min_y = 0; - renderbuffer_clip.max_y = 224-1; + state->renderbuffer_clip.min_x = 0; + state->renderbuffer_clip.max_x = state->screenwidth-1; + state->renderbuffer_clip.min_y = 0; + state->renderbuffer_clip.max_y = 224-1; - bitmap_fill(renderbuffer_bitmap,&renderbuffer_clip,0x3f); + bitmap_fill(state->renderbuffer_bitmap,&state->renderbuffer_clip,0x3f); } @@ -844,7 +813,8 @@ static VIDEO_START(cps3) static void cps3_draw_tilemapsprite_line(running_machine *machine, int tmnum, int drawline, bitmap_t *bitmap, const rectangle *cliprect ) { - UINT32* tmapregs[4] = { tilemap20_regs_base, tilemap30_regs_base, tilemap40_regs_base, tilemap50_regs_base }; + cps3_state *state = machine->driver_data(); + UINT32* tmapregs[4] = { state->tilemap20_regs_base, state->tilemap30_regs_base, state->tilemap40_regs_base, state->tilemap50_regs_base }; UINT32* regs; int line; int scrolly; @@ -885,7 +855,7 @@ static void cps3_draw_tilemapsprite_line(running_machine *machine, int tmnum, in // printf("linebase %08x\n", linebase); scrollx = (regs[0]&0xffff0000)>>16; - scrollx+= (cps3_spriteram[linebase+((line+16-4)&0x3ff)]>>16)&0x3ff; + scrollx+= (state->spriteram[linebase+((line+16-4)&0x3ff)]>>16)&0x3ff; } @@ -909,7 +879,7 @@ static void cps3_draw_tilemapsprite_line(running_machine *machine, int tmnum, in int bpp; int xflip,yflip; - dat = cps3_spriteram[mapbase+((tileline&63)*64)+((x+scrollx/16)&63)]; + dat = state->spriteram[mapbase+((tileline&63)*64)+((x+scrollx/16)&63)]; tileno = (dat & 0xffff0000)>>17; colour = (dat & 0x000001ff)>>0; bpp = (dat & 0x0000200)>>9; @@ -926,6 +896,7 @@ static void cps3_draw_tilemapsprite_line(running_machine *machine, int tmnum, in static VIDEO_UPDATE(cps3) { + cps3_state *state = screen->machine->driver_data(); int y,x, count; attoseconds_t period = screen->frame_period().attoseconds; rectangle visarea = screen->visible_area(); @@ -941,11 +912,11 @@ static VIDEO_UPDATE(cps3) /* registers are normally 002a006f 01ef01c6 widescreen mode = 00230076 026501c6 only SFIII2 uses widescreen, I don't know exactly which register controls it */ - if (((cps3_fullscreenzoom[1]&0xffff0000)>>16)==0x0265) + if (((state->fullscreenzoom[1]&0xffff0000)>>16)==0x0265) { - if (cps3_screenwidth!=496) + if (state->screenwidth!=496) { - cps3_screenwidth = 496; + state->screenwidth = 496; visarea.min_x = 0; visarea.max_x = 496-1; visarea.min_y = 0; visarea.max_y = 224-1; screen->configure(496, 224, visarea, period); @@ -953,17 +924,17 @@ static VIDEO_UPDATE(cps3) } else { - if (cps3_screenwidth!=384) + if (state->screenwidth!=384) { - cps3_screenwidth = 384; + state->screenwidth = 384; visarea.min_x = 0; visarea.max_x = 384-1; visarea.min_y = 0; visarea.max_y = 224-1; screen->configure(384, 224, visarea, period); } } - fullscreenzoomx = cps3_fullscreenzoom[3] & 0x000000ff; - fullscreenzoomy = cps3_fullscreenzoom[3] & 0x000000ff; + fullscreenzoomx = state->fullscreenzoom[3] & 0x000000ff; + fullscreenzoomy = state->fullscreenzoom[3] & 0x000000ff; /* clamp at 0x80, I don't know if this is accurate */ if (fullscreenzoomx>0x80) fullscreenzoomx = 0x80; if (fullscreenzoomy>0x80) fullscreenzoomy = 0x80; @@ -971,12 +942,12 @@ static VIDEO_UPDATE(cps3) fszx = (fullscreenzoomx<<16)/0x40; fszy = (fullscreenzoomy<<16)/0x40; - renderbuffer_clip.min_x = 0; - renderbuffer_clip.max_x = ((cps3_screenwidth*fszx)>>16)-1; - renderbuffer_clip.min_y = 0; - renderbuffer_clip.max_y = ((224*fszx)>>16)-1; + state->renderbuffer_clip.min_x = 0; + state->renderbuffer_clip.max_x = ((state->screenwidth*fszx)>>16)-1; + state->renderbuffer_clip.min_y = 0; + state->renderbuffer_clip.max_y = ((224*fszx)>>16)-1; - bitmap_fill(renderbuffer_bitmap,&renderbuffer_clip,0); + bitmap_fill(state->renderbuffer_bitmap,&state->renderbuffer_clip,0); /* Sprites */ { @@ -985,37 +956,37 @@ static VIDEO_UPDATE(cps3) //printf("Spritelist start:\n"); for (i=0x00000/4;i<0x2000/4;i+=4) { - int xpos = (cps3_spriteram[i+1]&0x03ff0000)>>16; - int ypos = cps3_spriteram[i+1]&0x000003ff; + int xpos = (state->spriteram[i+1]&0x03ff0000)>>16; + int ypos = state->spriteram[i+1]&0x000003ff; int j; - int gscroll = (cps3_spriteram[i+0]&0x70000000)>>28; - int length = (cps3_spriteram[i+0]&0x01ff0000)>>16; // how many entries in the sprite table - UINT32 start = (cps3_spriteram[i+0]&0x00007ff0)>>4; + int gscroll = (state->spriteram[i+0]&0x70000000)>>28; + int length = (state->spriteram[i+0]&0x01ff0000)>>16; // how many entries in the sprite table + UINT32 start = (state->spriteram[i+0]&0x00007ff0)>>4; - int whichbpp = (cps3_spriteram[i+2]&0x40000000)>>30; // not 100% sure if this is right, jojo title / characters - int whichpal = (cps3_spriteram[i+2]&0x20000000)>>29; - int global_xflip = (cps3_spriteram[i+2]&0x10000000)>>28; - int global_yflip = (cps3_spriteram[i+2]&0x08000000)>>27; - int global_alpha = (cps3_spriteram[i+2]&0x04000000)>>26; // alpha / shadow? set on sfiii2 shadows, and big black image in jojo intro - int global_bpp = (cps3_spriteram[i+2]&0x02000000)>>25; - int global_pal = (cps3_spriteram[i+2]&0x01ff0000)>>16; + int whichbpp = (state->spriteram[i+2]&0x40000000)>>30; // not 100% sure if this is right, jojo title / characters + int whichpal = (state->spriteram[i+2]&0x20000000)>>29; + int global_xflip = (state->spriteram[i+2]&0x10000000)>>28; + int global_yflip = (state->spriteram[i+2]&0x08000000)>>27; + int global_alpha = (state->spriteram[i+2]&0x04000000)>>26; // alpha / shadow? set on sfiii2 shadows, and big black image in jojo intro + int global_bpp = (state->spriteram[i+2]&0x02000000)>>25; + int global_pal = (state->spriteram[i+2]&0x01ff0000)>>16; - int gscrollx = (cps3_unk_vidregs[gscroll]&0x03ff0000)>>16; - int gscrolly = (cps3_unk_vidregs[gscroll]&0x000003ff)>>0; + int gscrollx = (state->unk_vidregs[gscroll]&0x03ff0000)>>16; + int gscrolly = (state->unk_vidregs[gscroll]&0x000003ff)>>0; start = (start * 0x100) >> 2; - if ((cps3_spriteram[i+0]&0xf0000000) == 0x80000000) + if ((state->spriteram[i+0]&0xf0000000) == 0x80000000) break; for (j=0;j<(length)*4;j+=4) { - UINT32 value1 = (cps3_spriteram[start+j+0]); - UINT32 value2 = (cps3_spriteram[start+j+1]); - UINT32 value3 = (cps3_spriteram[start+j+2]); + UINT32 value1 = (state->spriteram[start+j+0]); + UINT32 value2 = (state->spriteram[start+j+1]); + UINT32 value3 = (state->spriteram[start+j+2]); - //UINT8* srcdata = (UINT8*)cps3_char_ram; + //UINT8* srcdata = (UINT8*)state->char_ram; //UINT32 sourceoffset = (value1 >>14)&0x7fffff; int count; @@ -1053,7 +1024,7 @@ static VIDEO_UPDATE(cps3) //int endline; //int height = (value3 & 0x7f000000)>>24; int uu; - UINT32* tmapregs[4] = { tilemap20_regs_base, tilemap30_regs_base, tilemap40_regs_base, tilemap50_regs_base }; + UINT32* tmapregs[4] = { state->tilemap20_regs_base, state->tilemap30_regs_base, state->tilemap40_regs_base, state->tilemap50_regs_base }; UINT32* regs; regs = tmapregs[tilemapnum]; //endline = value2; @@ -1075,7 +1046,7 @@ static VIDEO_UPDATE(cps3) { for (uu=0;uu<1023;uu++) { - cps3_draw_tilemapsprite_line(screen->machine, tilemapnum, uu, renderbuffer_bitmap, &renderbuffer_clip ); + cps3_draw_tilemapsprite_line(screen->machine, tilemapnum, uu, state->renderbuffer_bitmap, &state->renderbuffer_clip ); } } bg_drawn[tilemapnum] = 1; @@ -1162,11 +1133,11 @@ static VIDEO_UPDATE(cps3) if (global_alpha || alpha) { - cps3_drawgfxzoom(renderbuffer_bitmap,&renderbuffer_clip,screen->machine->gfx[1],realtileno,actualpal,0^flipx,0^flipy,current_xpos,current_ypos,CPS3_TRANSPARENCY_PEN_INDEX_BLEND,0,xinc,yinc, NULL, 0); + cps3_drawgfxzoom(state->renderbuffer_bitmap,&state->renderbuffer_clip,screen->machine->gfx[1],realtileno,actualpal,0^flipx,0^flipy,current_xpos,current_ypos,CPS3_TRANSPARENCY_PEN_INDEX_BLEND,0,xinc,yinc, NULL, 0); } else { - cps3_drawgfxzoom(renderbuffer_bitmap,&renderbuffer_clip,screen->machine->gfx[1],realtileno,actualpal,0^flipx,0^flipy,current_xpos,current_ypos,CPS3_TRANSPARENCY_PEN_INDEX,0,xinc,yinc, NULL, 0); + cps3_drawgfxzoom(state->renderbuffer_bitmap,&state->renderbuffer_clip,screen->machine->gfx[1],realtileno,actualpal,0^flipx,0^flipy,current_xpos,current_ypos,CPS3_TRANSPARENCY_PEN_INDEX,0,xinc,yinc, NULL, 0); } count++; } @@ -1193,12 +1164,12 @@ static VIDEO_UPDATE(cps3) for (rendery=0;rendery<224;rendery++) { dstbitmap = BITMAP_ADDR32(bitmap, rendery, 0); - srcbitmap = BITMAP_ADDR32(renderbuffer_bitmap, srcy>>16, 0); + srcbitmap = BITMAP_ADDR32(state->renderbuffer_bitmap, srcy>>16, 0); srcx=0; - for (renderx=0;renderxscreenwidth;renderx++) { - dstbitmap[renderx] = cps3_mame_colours[srcbitmap[srcx>>16]&0x1ffff]; + dstbitmap[renderx] = state->mame_colours[srcbitmap[srcx>>16]&0x1ffff]; srcx += fszx; } @@ -1210,26 +1181,26 @@ static VIDEO_UPDATE(cps3) /* Copy the first 0x800 colours to be used for fg layer rendering */ // for (offset=0;offset<0x200;offset++) // { -// int palreadbase = (cps3_ss_pal_base << 9); -// palette_set_color(machine,offset,cps3_mame_colours[palreadbase+offset]); +// int palreadbase = (state->ss_pal_base << 9); +// palette_set_color(machine,offset,state->mame_colours[palreadbase+offset]); // } // fg layer { // bank select? (sfiii2 intro) - if (cps3_ss_bank_base & 0x01000000) count = 0x000; + if (state->ss_bank_base & 0x01000000) count = 0x000; else count = 0x800; for (y=0;y<32;y++) { for (x=0;x<64;x++) { - UINT32 data = cps3_ss_ram[count]; // +0x800 = 2nd bank, used on sfiii2 intro.. + UINT32 data = state->ss_ram[count]; // +0x800 = 2nd bank, used on sfiii2 intro.. UINT32 tile = (data >> 16) & 0x1ff; int pal = (data&0x003f) >> 1; int flipx = (data & 0x0080) >> 7; int flipy = (data & 0x0040) >> 6; - pal += cps3_ss_pal_base << 5; + pal += state->ss_pal_base << 5; tile+=0x200; cps3_drawgfxzoom(bitmap, cliprect, screen->machine->gfx[0],tile,pal,flipx,flipy,x*8,y*8,CPS3_TRANSPARENCY_PEN,0,0x10000,0x10000,NULL,0); @@ -1242,14 +1213,16 @@ static VIDEO_UPDATE(cps3) static READ32_HANDLER( cps3_ssram_r ) { + cps3_state *state = space->machine->driver_data(); if (offset>0x8000/4) - return LITTLE_ENDIANIZE_INT32(cps3_ss_ram[offset]); + return LITTLE_ENDIANIZE_INT32(state->ss_ram[offset]); else - return cps3_ss_ram[offset]; + return state->ss_ram[offset]; } static WRITE32_HANDLER( cps3_ssram_w ) { + cps3_state *state = space->machine->driver_data(); if (offset>0x8000/4) { // we only want to endian-flip the character data, the tilemap info is fine @@ -1258,20 +1231,22 @@ static WRITE32_HANDLER( cps3_ssram_w ) gfx_element_mark_dirty(space->machine->gfx[0], offset/16); } - COMBINE_DATA(&cps3_ss_ram[offset]); + COMBINE_DATA(&state->ss_ram[offset]); } static WRITE32_HANDLER( cps3_0xc0000000_ram_w ) { - COMBINE_DATA( &cps3_0xc0000000_ram[offset] ); + cps3_state *state = space->machine->driver_data(); + COMBINE_DATA( &state->_0xc0000000_ram[offset] ); // store a decrypted copy - cps3_0xc0000000_ram_decrypted[offset] = cps3_0xc0000000_ram[offset]^cps3_mask(offset*4+0xc0000000, cps3_key1, cps3_key2); + state->_0xc0000000_ram_decrypted[offset] = state->_0xc0000000_ram[offset]^cps3_mask(offset*4+0xc0000000, state->key1, state->key2); } DIRECT_UPDATE_HANDLER( cps3_direct_handler ) { + cps3_state *state = machine->driver_data(); // if(DEBUG_PRINTF) printf("address %04x\n",address); /* BIOS ROM */ @@ -1283,10 +1258,10 @@ DIRECT_UPDATE_HANDLER( cps3_direct_handler ) /* RAM */ else if (address >= 0x06000000 && address <= 0x06ffffff) { - UINT8 *decrypted = (UINT8*)decrypted_gamerom; + UINT8 *decrypted = (UINT8*)state->decrypted_gamerom; UINT8 *raw = decrypted; - if (cps3_altEncryption) raw = (UINT8*) cps3_user4region; + if (state->altEncryption) raw = (UINT8*) state->user4region; direct.explicit_configure(0x06000000, 0x06ffffff, 0x00ffffff, raw, decrypted); @@ -1294,26 +1269,26 @@ DIRECT_UPDATE_HANDLER( cps3_direct_handler ) } else if (address >= 0xc0000000 && address <= 0xc00003ff) { - //direct->decrypted = (void*)cps3_0xc0000000_ram_decrypted; - direct.explicit_configure(0xc0000000, 0xc00003ff, 0x3ff, (UINT8*)cps3_0xc0000000_ram, (UINT8*)cps3_0xc0000000_ram_decrypted); + //direct->decrypted = (void*)state->_0xc0000000_ram_decrypted; + direct.explicit_configure(0xc0000000, 0xc00003ff, 0x3ff, (UINT8*)state->_0xc0000000_ram, (UINT8*)state->_0xc0000000_ram_decrypted); return ~0; } /* anything else falls through to NOPs */ - direct.explicit_configure(address, address, 0, (UINT8*)cps3_nops, (UINT8*)cps3_nops); + direct.explicit_configure(address, address, 0, (UINT8*)state->nops, (UINT8*)state->nops); return ~0; } -static UINT32 cram_bank = 0; static WRITE32_HANDLER( cram_bank_w ) { + cps3_state *state = space->machine->driver_data(); if (ACCESSING_BITS_0_7) { // this seems to be related to accesses to the 0x04100000 region - if (cram_bank != data) + if (state->cram_bank != data) { - cram_bank = data; + state->cram_bank = data; //if(data&0xfffffff0) //bank_w 00000000, ffff0000 //bank_w 00000001, ffff0000 @@ -1337,17 +1312,19 @@ static WRITE32_HANDLER( cram_bank_w ) static READ32_HANDLER( cram_data_r ) { - UINT32 fulloffset = (((cram_bank&0x7)*0x100000)/4) + offset; + cps3_state *state = space->machine->driver_data(); + UINT32 fulloffset = (((state->cram_bank&0x7)*0x100000)/4) + offset; - return LITTLE_ENDIANIZE_INT32(cps3_char_ram[fulloffset]); + return LITTLE_ENDIANIZE_INT32(state->char_ram[fulloffset]); } static WRITE32_HANDLER( cram_data_w ) { - UINT32 fulloffset = (((cram_bank&0x7)*0x100000)/4) + offset; + cps3_state *state = space->machine->driver_data(); + UINT32 fulloffset = (((state->cram_bank&0x7)*0x100000)/4) + offset; mem_mask = LITTLE_ENDIANIZE_INT32(mem_mask); data = LITTLE_ENDIANIZE_INT32(data); - COMBINE_DATA(&cps3_char_ram[fulloffset]); + COMBINE_DATA(&state->char_ram[fulloffset]); gfx_element_mark_dirty(space->machine->gfx[1], fulloffset/0x40); } @@ -1355,11 +1332,12 @@ static WRITE32_HANDLER( cram_data_w ) static READ32_HANDLER( cps3_gfxflash_r ) { + cps3_state *state = space->machine->driver_data(); UINT32 result = 0; - if (cram_gfxflash_bank&1) offset += 0x200000/4; + if (state->cram_gfxflash_bank&1) offset += 0x200000/4; - fujitsu_29f016a_device *chip0 = simm[2 + cram_gfxflash_bank/8][(cram_gfxflash_bank % 8) & ~1]; - fujitsu_29f016a_device *chip1 = simm[2 + cram_gfxflash_bank/8][(cram_gfxflash_bank % 8) | 1]; + fujitsu_29f016a_device *chip0 = state->simm[2 + state->cram_gfxflash_bank/8][(state->cram_gfxflash_bank % 8) & ~1]; + fujitsu_29f016a_device *chip1 = state->simm[2 + state->cram_gfxflash_bank/8][(state->cram_gfxflash_bank % 8) | 1]; if (chip0 == NULL || chip1 == NULL) return 0xffffffff; @@ -1386,18 +1364,19 @@ static READ32_HANDLER( cps3_gfxflash_r ) result |= chip1->read( (offset<<1)+0x1 ) << 0; } - //printf("read GFX flash chips addr %02x returning %08x mem_mask %08x crambank %08x gfxbank %08x\n", offset*2, result,mem_mask, cram_bank, cram_gfxflash_bank ); + //printf("read GFX flash chips addr %02x returning %08x mem_mask %08x crambank %08x gfxbank %08x\n", offset*2, result,mem_mask, state->cram_bank, state->cram_gfxflash_bank ); return result; } static WRITE32_HANDLER( cps3_gfxflash_w ) { + cps3_state *state = space->machine->driver_data(); int command; - if (cram_gfxflash_bank&1) offset += 0x200000/4; + if (state->cram_gfxflash_bank&1) offset += 0x200000/4; - fujitsu_29f016a_device *chip0 = simm[2 + cram_gfxflash_bank/8][(cram_gfxflash_bank % 8) & ~1]; - fujitsu_29f016a_device *chip1 = simm[2 + cram_gfxflash_bank/8][(cram_gfxflash_bank % 8) | 1]; + fujitsu_29f016a_device *chip0 = state->simm[2 + state->cram_gfxflash_bank/8][(state->cram_gfxflash_bank % 8) & ~1]; + fujitsu_29f016a_device *chip1 = state->simm[2 + state->cram_gfxflash_bank/8][(state->cram_gfxflash_bank % 8) | 1]; if (chip0 == NULL || chip1 == NULL) return; @@ -1431,11 +1410,11 @@ static WRITE32_HANDLER( cps3_gfxflash_w ) /* make a copy in the linear memory region we actually use for drawing etc. having it stored in interleaved flash roms isnt' very useful */ { - UINT32* romdata = (UINT32*)cps3_user5region; + UINT32* romdata = (UINT32*)state->user5region; int real_offset = 0; UINT32 newdata; - real_offset = ((cram_gfxflash_bank&0x3e) * 0x200000) + offset*4; + real_offset = ((state->cram_gfxflash_bank&0x3e) * 0x200000) + offset*4; newdata =((chip0->read_raw(((offset*2)&0xfffffffe)+0)<<8) | (chip0->read_raw(((offset*2)&0xfffffffe)+1)<<24) | @@ -1449,32 +1428,33 @@ static WRITE32_HANDLER( cps3_gfxflash_w ) -static UINT32 cps3_flashmain_r(int which, UINT32 offset, UINT32 mem_mask) +static UINT32 cps3_flashmain_r(address_space *space, int which, UINT32 offset, UINT32 mem_mask) { + cps3_state *state = space->machine->driver_data(); UINT32 result = 0; - if (simm[which][0] == NULL || simm[which][1] == NULL || simm[which][2] == NULL || simm[which][3] == NULL) + if (state->simm[which][0] == NULL || state->simm[which][1] == NULL || state->simm[which][2] == NULL || state->simm[which][3] == NULL) return 0xffffffff; if (ACCESSING_BITS_24_31) // Flash 1 { // logerror("read flash chip %d addr %02x\n", base+0, offset*4 ); - result |= (simm[which][0]->read(offset)<<24); + result |= (state->simm[which][0]->read(offset)<<24); } if (ACCESSING_BITS_16_23) // Flash 1 { // logerror("read flash chip %d addr %02x\n", base+1, offset*4 ); - result |= (simm[which][1]->read(offset)<<16); + result |= (state->simm[which][1]->read(offset)<<16); } if (ACCESSING_BITS_8_15) // Flash 1 { // logerror("read flash chip %d addr %02x\n", base+2, offset*4 ); - result |= (simm[which][2]->read(offset)<<8); + result |= (state->simm[which][2]->read(offset)<<8); } if (ACCESSING_BITS_0_7) // Flash 1 { // logerror("read flash chip %d addr %02x\n", base+3, offset*4 ); - result |= (simm[which][3]->read(offset)<<0); + result |= (state->simm[which][3]->read(offset)<<0); } // if (base==4) logerror("read flash chips addr %02x returning %08x\n", offset*4, result ); @@ -1486,60 +1466,63 @@ static UINT32 cps3_flashmain_r(int which, UINT32 offset, UINT32 mem_mask) static READ32_HANDLER( cps3_flash1_r ) { - UINT32 retvalue = cps3_flashmain_r(0, offset,mem_mask); + cps3_state *state = space->machine->driver_data(); + UINT32 retvalue = cps3_flashmain_r(space, 0, offset,mem_mask); - if (cps3_altEncryption) return retvalue; + if (state->altEncryption) return retvalue; - retvalue = retvalue ^ cps3_mask(0x6000000+offset*4, cps3_key1, cps3_key2); + retvalue = retvalue ^ cps3_mask(0x6000000+offset*4, state->key1, state->key2); return retvalue; } static READ32_HANDLER( cps3_flash2_r ) { - UINT32 retvalue = cps3_flashmain_r(1, offset,mem_mask); + cps3_state *state = space->machine->driver_data(); + UINT32 retvalue = cps3_flashmain_r(space, 1, offset,mem_mask); - if (cps3_altEncryption) return retvalue; + if (state->altEncryption) return retvalue; - retvalue = retvalue ^ cps3_mask(0x6800000+offset*4, cps3_key1, cps3_key2); + retvalue = retvalue ^ cps3_mask(0x6800000+offset*4, state->key1, state->key2); return retvalue; } static void cps3_flashmain_w(running_machine *machine, int which, UINT32 offset, UINT32 data, UINT32 mem_mask) { + cps3_state *state = machine->driver_data(); int command; - if (simm[which][0] == NULL || simm[which][1] == NULL || simm[which][2] == NULL || simm[which][3] == NULL) + if (state->simm[which][0] == NULL || state->simm[which][1] == NULL || state->simm[which][2] == NULL || state->simm[which][3] == NULL) return; if (ACCESSING_BITS_24_31) // Flash 1 { command = (data >> 24) & 0xff; - logerror("write to flash chip %s addr %02x cmd %02x\n", simm[which][0]->tag(), offset, command); - simm[which][0]->write(offset, command); + logerror("write to flash chip %s addr %02x cmd %02x\n", state->simm[which][0]->tag(), offset, command); + state->simm[which][0]->write(offset, command); } if (ACCESSING_BITS_16_23) // Flash 2 { command = (data >> 16) & 0xff; - logerror("write to flash chip %s addr %02x cmd %02x\n", simm[which][1]->tag(), offset, command); - simm[which][1]->write(offset, command); + logerror("write to flash chip %s addr %02x cmd %02x\n", state->simm[which][1]->tag(), offset, command); + state->simm[which][1]->write(offset, command); } if (ACCESSING_BITS_8_15) // Flash 2 { command = (data >> 8) & 0xff; - logerror("write to flash chip %s addr %02x cmd %02x\n", simm[which][2]->tag(), offset, command); - simm[which][2]->write(offset, command); + logerror("write to flash chip %s addr %02x cmd %02x\n", state->simm[which][2]->tag(), offset, command); + state->simm[which][2]->write(offset, command); } if (ACCESSING_BITS_0_7) // Flash 2 { command = (data >> 0) & 0xff; - logerror("write to flash chip %s addr %02x cmd %02x\n", simm[which][3]->tag(), offset, command); - simm[which][3]->write(offset, command); + logerror("write to flash chip %s addr %02x cmd %02x\n", state->simm[which][3]->tag(), offset, command); + state->simm[which][3]->write(offset, command); } /* copy data into regions to execute from */ { - UINT32* romdata = (UINT32*)cps3_user4region; - UINT32* romdata2 = (UINT32*)decrypted_gamerom; + UINT32* romdata = (UINT32*)state->user4region; + UINT32* romdata2 = (UINT32*)state->decrypted_gamerom; int real_offset = 0; UINT32 newdata; @@ -1552,15 +1535,15 @@ static void cps3_flashmain_w(running_machine *machine, int which, UINT32 offset, real_offset += 0x800000; } - newdata = (simm[which][0]->read_raw(offset)<<24) | - (simm[which][1]->read_raw(offset)<<16) | - (simm[which][2]->read_raw(offset)<<8) | - (simm[which][3]->read_raw(offset)<<0); + newdata = (state->simm[which][0]->read_raw(offset)<<24) | + (state->simm[which][1]->read_raw(offset)<<16) | + (state->simm[which][2]->read_raw(offset)<<8) | + (state->simm[which][3]->read_raw(offset)<<0); - //printf("%08x %08x %08x %08x %08x\n",offset, romdata2[offset], romdata[offset], newdata, newdata^cps3_mask(0x6000000+real_offset, cps3_key1, cps3_key2) ); + //printf("%08x %08x %08x %08x %08x\n",offset, romdata2[offset], romdata[offset], newdata, newdata^cps3_mask(0x6000000+real_offset, state->key1, state->key2) ); romdata[offset] = newdata; - romdata2[offset] = newdata^cps3_mask(0x6000000+real_offset, cps3_key1, cps3_key2); + romdata2[offset] = newdata^cps3_mask(0x6000000+real_offset, state->key1, state->key2); } } @@ -1576,6 +1559,7 @@ static WRITE32_HANDLER( cps3_flash2_w ) static WRITE32_HANDLER( cram_gfxflash_bank_w ) { + cps3_state *state = space->machine->driver_data(); if (ACCESSING_BITS_24_31) { //printf("cram_gfxflash_bank_w MSB32 %08x\n",data); @@ -1619,8 +1603,8 @@ static WRITE32_HANDLER( cram_gfxflash_bank_w ) SIMM 7 (Rom 70/71) ** NOT USED (would follow on in sequence tho) */ - cram_gfxflash_bank = (data & 0xffff0000) >> 16; - cram_gfxflash_bank-= 0x0002;// as with sound access etc. first 4 meg is 'special' and skipped + state->cram_gfxflash_bank = (data & 0xffff0000) >> 16; + state->cram_gfxflash_bank-= 0x0002;// as with sound access etc. first 4 meg is 'special' and skipped } if (ACCESSING_BITS_0_7) @@ -1653,16 +1637,16 @@ static READ32_HANDLER( cps3_40C0004_r ) /* EEPROM access is a little odd, I think it accesses eeprom through some kind of additional interface, as these writes aren't normal for the type of eeprom we have */ -static UINT16 cps3_current_eeprom_read; static READ32_HANDLER( cps3_eeprom_r ) { + cps3_state *state = space->machine->driver_data(); int addr = offset*4; if (addr>=0x100 && addr<=0x17f) { - if (ACCESSING_BITS_24_31) cps3_current_eeprom_read = (cps3_eeprom[offset-0x100/4] & 0xffff0000)>>16; - else cps3_current_eeprom_read = (cps3_eeprom[offset-0x100/4] & 0x0000ffff)>>0; + if (ACCESSING_BITS_24_31) state->current_eeprom_read = (state->eeprom[offset-0x100/4] & 0xffff0000)>>16; + else state->current_eeprom_read = (state->eeprom[offset-0x100/4] & 0x0000ffff)>>0; // read word to latch... return 0x00000000; } @@ -1672,8 +1656,8 @@ static READ32_HANDLER( cps3_eeprom_r ) if (ACCESSING_BITS_24_31) return 0; else { - //if(DEBUG_PRINTF) printf("reading %04x from eeprom\n", cps3_current_eeprom_read); - return cps3_current_eeprom_read; + //if(DEBUG_PRINTF) printf("reading %04x from eeprom\n", state->current_eeprom_read); + return state->current_eeprom_read; } } else @@ -1686,12 +1670,13 @@ static READ32_HANDLER( cps3_eeprom_r ) static WRITE32_HANDLER( cps3_eeprom_w ) { + cps3_state *state = space->machine->driver_data(); int addr = offset*4; if (addr>=0x080 && addr<=0x0ff) { offset -= 0x80/4; - COMBINE_DATA(&cps3_eeprom[offset]); + COMBINE_DATA(&state->eeprom[offset]); // write word to storage } @@ -1738,77 +1723,74 @@ static WRITE32_HANDLER( cps3_cdrom_w ) static WRITE32_HANDLER( cps3_ss_bank_base_w ) { + cps3_state *state = space->machine->driver_data(); // might be scroll registers or something else.. // used to display bank with 'insert coin' on during sfiii2 attract intro - COMBINE_DATA(&cps3_ss_bank_base); + COMBINE_DATA(&state->ss_bank_base); // printf("cps3_ss_bank_base_w %08x %08x\n", data, mem_mask); } static WRITE32_HANDLER( cps3_ss_pal_base_w ) { + cps3_state *state = space->machine->driver_data(); if(DEBUG_PRINTF) printf ("cps3_ss_pal_base_w %08x %08x\n", data, mem_mask); if(ACCESSING_BITS_24_31) { - cps3_ss_pal_base = (data & 0x00ff0000)>>16; + state->ss_pal_base = (data & 0x00ff0000)>>16; - if (data & 0xff000000) printf("cps3_ss_pal_base MSB32 upper bits used %04x \n", data); + if (data & 0xff000000) printf("ss_pal_base MSB32 upper bits used %04x \n", data); } else { - // printf("cps3_ss_pal_base LSB32 used %04x \n", data); + // printf("ss_pal_base LSB32 used %04x \n", data); } } // +0 X +2 Y +4 unknown +6 enable (&0x8000) +8 low part tilemap base, high part linescroll base // (a word each) -static UINT32 paldma_source; -static UINT32 paldma_realsource; -static UINT32 paldma_dest; -static UINT32 paldma_fade; -static UINT32 paldma_other2; -static UINT32 paldma_length; static WRITE32_HANDLER( cps3_palettedma_w ) { + cps3_state *state = space->machine->driver_data(); if (offset==0) { - COMBINE_DATA(&paldma_source); - paldma_realsource = (paldma_source<<1)-0x400000; + COMBINE_DATA(&state->paldma_source); + state->paldma_realsource = (state->paldma_source<<1)-0x400000; } else if (offset==1) { - COMBINE_DATA(&paldma_dest); + COMBINE_DATA(&state->paldma_dest); } else if (offset==2) { - COMBINE_DATA(&paldma_fade); + COMBINE_DATA(&state->paldma_fade); } else if (offset==3) { - COMBINE_DATA(&paldma_other2); + COMBINE_DATA(&state->paldma_other2); if (ACCESSING_BITS_24_31) { - paldma_length = (data & 0xffff0000)>>16; + state->paldma_length = (data & 0xffff0000)>>16; } if (ACCESSING_BITS_0_7) { if (data & 0x0002) { int i; - UINT16* src = (UINT16*)cps3_user5region; - // if(DEBUG_PRINTF) printf("CPS3 pal dma start %08x (real: %08x) dest %08x fade %08x other2 %08x (length %04x)\n", paldma_source, paldma_realsource, paldma_dest, paldma_fade, paldma_other2, paldma_length); + UINT16* src = (UINT16*)state->user5region; + // if(DEBUG_PRINTF) printf("CPS3 pal dma start %08x (real: %08x) dest %08x fade %08x other2 %08x (length %04x)\n", state->paldma_source, state->paldma_realsource, state->paldma_dest, state->paldma_fade, state->paldma_other2, state->paldma_length); - for (i=0;ipaldma_length;i++) { - UINT16 coldata = src[BYTE_XOR_BE(((paldma_realsource>>1)+i))]; + UINT16 coldata = src[BYTE_XOR_BE(((state->paldma_realsource>>1)+i))]; - //if (paldma_fade!=0) printf("%08x\n",paldma_fade); + //if (state->paldma_fade!=0) printf("%08x\n",state->paldma_fade); - cps3_set_mame_colours(space->machine, (paldma_dest+i)^1, coldata, paldma_fade); + cps3_set_mame_colours(space->machine, (state->paldma_dest+i)^1, coldata, state->paldma_fade); } @@ -1821,20 +1803,16 @@ static WRITE32_HANDLER( cps3_palettedma_w ) } -static UINT32 chardma_source; -static UINT32 chardma_other; //static UINT8* current_table; -static UINT32 current_table_address; -static int cps3_rle_length = 0; -static int last_normal_byte = 0; static UINT32 process_byte( running_machine *machine, UINT8 real_byte, UINT32 destination, int max_length ) { - UINT8* dest = (UINT8*)cps3_char_ram; + cps3_state *state = machine->driver_data(); + UINT8* dest = (UINT8*)state->char_ram; //printf("process byte for destination %08x\n", destination); @@ -1845,18 +1823,18 @@ static UINT32 process_byte( running_machine *machine, UINT8 real_byte, UINT32 de int tranfercount = 0; //printf("Set RLE Mode\n"); - cps3_rle_length = (real_byte&0x3f)+1; + state->rle_length = (real_byte&0x3f)+1; - //printf("RLE Operation (length %08x\n", cps3_rle_length ); + //printf("RLE Operation (length %08x\n", state->rle_length ); - while (cps3_rle_length) + while (state->rle_length) { - dest[((destination+tranfercount)&0x7fffff)^3] = (last_normal_byte&0x3f); + dest[((destination+tranfercount)&0x7fffff)^3] = (state->last_normal_byte&0x3f); gfx_element_mark_dirty(machine->gfx[1], ((destination+tranfercount)&0x7fffff)/0x100); //printf("RLE WRite Byte %08x, %02x\n", destination+tranfercount, real_byte); tranfercount++; - cps3_rle_length--; + state->rle_length--; max_length--; if ((destination+tranfercount) > 0x7fffff) return max_length; @@ -1870,7 +1848,7 @@ static UINT32 process_byte( running_machine *machine, UINT8 real_byte, UINT32 de { //printf("Write Normal Data\n"); dest[(destination&0x7fffff)^3] = real_byte; - last_normal_byte = real_byte; + state->last_normal_byte = real_byte; gfx_element_mark_dirty(machine->gfx[1], (destination&0x7fffff)/0x100); return 1; } @@ -1878,11 +1856,12 @@ static UINT32 process_byte( running_machine *machine, UINT8 real_byte, UINT32 de static void cps3_do_char_dma( running_machine *machine, UINT32 real_source, UINT32 real_destination, UINT32 real_length ) { - UINT8* sourcedata = (UINT8*)cps3_user5region; + cps3_state *state = machine->driver_data(); + UINT8* sourcedata = (UINT8*)state->user5region; int length_remaining; - last_normal_byte = 0; - cps3_rle_length = 0; + state->last_normal_byte = 0; + state->rle_length = 0; length_remaining = real_length; while (length_remaining) { @@ -1897,7 +1876,7 @@ static void cps3_do_char_dma( running_machine *machine, UINT32 real_source, UINT UINT32 length_processed; current_byte &= 0x7f; - real_byte = sourcedata[DMA_XOR((current_table_address+current_byte*2+0))]; + real_byte = sourcedata[DMA_XOR((state->current_table_address+current_byte*2+0))]; //if (real_byte&0x80) return; length_processed = process_byte( machine, real_byte, real_destination, length_remaining ); length_remaining-=length_processed; // subtract the number of bytes the operation has taken @@ -1905,7 +1884,7 @@ static void cps3_do_char_dma( running_machine *machine, UINT32 real_source, UINT if (real_destination>0x7fffff) return; if (length_remaining<=0) return; // if we've expired, exit - real_byte = sourcedata[DMA_XOR((current_table_address+current_byte*2+1))]; + real_byte = sourcedata[DMA_XOR((state->current_table_address+current_byte*2+1))]; //if (real_byte&0x80) return; length_processed = process_byte( machine, real_byte, real_destination, length_remaining ); length_remaining-=length_processed; // subtract the number of bytes the operation has taken @@ -1927,34 +1906,33 @@ static void cps3_do_char_dma( running_machine *machine, UINT32 real_source, UINT } } -static unsigned short lastb; -static unsigned short lastb2; static UINT32 ProcessByte8(running_machine *machine,UINT8 b,UINT32 dst_offset) { - UINT8* destRAM = (UINT8*)cps3_char_ram; + cps3_state *state = machine->driver_data(); + UINT8* destRAM = (UINT8*)state->char_ram; int l=0; - if(lastb==lastb2) //rle + if(state->lastb==state->lastb2) //rle { int i; int rle=(b+1)&0xff; for(i=0;ilastb; gfx_element_mark_dirty(machine->gfx[1], (dst_offset&0x7fffff)/0x100); dst_offset++; ++l; } - lastb2=0xffff; + state->lastb2=0xffff; return l; } else { - lastb2=lastb; - lastb=b; + state->lastb2=state->lastb; + state->lastb=b; destRAM[(dst_offset&0x7fffff)^3] = b; gfx_element_mark_dirty(machine->gfx[1], (dst_offset&0x7fffff)/0x100); return 1; @@ -1963,12 +1941,13 @@ static UINT32 ProcessByte8(running_machine *machine,UINT8 b,UINT32 dst_offset) static void cps3_do_alt_char_dma( running_machine *machine, UINT32 src, UINT32 real_dest, UINT32 real_length ) { - UINT8* px = (UINT8*)cps3_user5region; + cps3_state *state = machine->driver_data(); + UINT8* px = (UINT8*)state->user5region; UINT32 start = real_dest; UINT32 ds = real_dest; - lastb=0xfffe; - lastb2=0xffff; + state->lastb=0xfffe; + state->lastb2=0xffff; while(1) { @@ -1984,9 +1963,9 @@ static void cps3_do_alt_char_dma( running_machine *machine, UINT32 src, UINT32 r { UINT8 real_byte; p&=0x7f; - real_byte = px[DMA_XOR((current_table_address+p*2+0))]; + real_byte = px[DMA_XOR((state->current_table_address+p*2+0))]; ds+=ProcessByte8(machine,real_byte,ds); - real_byte = px[DMA_XOR((current_table_address+p*2+1))]; + real_byte = px[DMA_XOR((state->current_table_address+p*2+1))]; ds+=ProcessByte8(machine,real_byte,ds); } else @@ -2004,15 +1983,16 @@ static void cps3_do_alt_char_dma( running_machine *machine, UINT32 src, UINT32 r static void cps3_process_character_dma(running_machine *machine, UINT32 address) { + cps3_state *state = machine->driver_data(); int i; //printf("charDMA start:\n"); for (i = 0; i < 0x1000; i += 3) { - UINT32 dat1 = LITTLE_ENDIANIZE_INT32(cps3_char_ram[i + 0 + (address)]); - UINT32 dat2 = LITTLE_ENDIANIZE_INT32(cps3_char_ram[i + 1 + (address)]); - UINT32 dat3 = LITTLE_ENDIANIZE_INT32(cps3_char_ram[i + 2 + (address)]); + UINT32 dat1 = LITTLE_ENDIANIZE_INT32(state->char_ram[i + 0 + (address)]); + UINT32 dat2 = LITTLE_ENDIANIZE_INT32(state->char_ram[i + 1 + (address)]); + UINT32 dat3 = LITTLE_ENDIANIZE_INT32(state->char_ram[i + 2 + (address)]); UINT32 real_source = (dat3 << 1) - 0x400000; UINT32 real_destination = dat2 << 3; UINT32 real_length = (((dat1 & 0x001fffff) + 1) << 3); @@ -2027,7 +2007,7 @@ static void cps3_process_character_dma(running_machine *machine, UINT32 address) /* Sets a table used by the decompression routines */ { /* We should probably copy this, but a pointer to it is fine for our purposes as the data doesn't change */ - current_table_address = real_source; + state->current_table_address = real_source; } cputag_set_input_line(machine, "maincpu", 10, ASSERT_LINE); } @@ -2056,14 +2036,15 @@ static void cps3_process_character_dma(running_machine *machine, UINT32 address) static WRITE32_HANDLER( cps3_characterdma_w ) { + cps3_state *state = space->machine->driver_data(); if(DEBUG_PRINTF) printf("chardma_w %08x %08x %08x\n", offset, data, mem_mask); if (offset==0) { - //COMBINE_DATA(&chardma_source); + //COMBINE_DATA(&state->chardma_source); if (ACCESSING_BITS_0_7) { - chardma_source = data & 0x0000ffff; + state->chardma_source = data & 0x0000ffff; } if (ACCESSING_BITS_24_31) { @@ -2072,29 +2053,29 @@ static WRITE32_HANDLER( cps3_characterdma_w ) } else if (offset==1) { - COMBINE_DATA(&chardma_other); + COMBINE_DATA(&state->chardma_other); if (ACCESSING_BITS_24_31) { if ((data>>16) & 0x0040) { UINT32 list_address; - list_address = (chardma_source | ((chardma_other&0x003f0000))); + list_address = (state->chardma_source | ((state->chardma_other&0x003f0000))); - //printf("chardma_w activated %08x %08x (address = cram %08x)\n", chardma_source, chardma_other, list_address*4 ); + //printf("chardma_w activated %08x %08x (address = cram %08x)\n", state->chardma_source, state->chardma_other, list_address*4 ); cps3_process_character_dma(space->machine, list_address); } else { - if(DEBUG_PRINTF) printf("chardma_w NOT activated %08x %08x\n", chardma_source, chardma_other ); + if(DEBUG_PRINTF) printf("chardma_w NOT activated %08x %08x\n", state->chardma_source, state->chardma_other ); } if ((data>>16) & 0xff80) - if(DEBUG_PRINTF) printf("chardma_w unknown bits in activate command %08x %08x\n", chardma_source, chardma_other ); + if(DEBUG_PRINTF) printf("chardma_w unknown bits in activate command %08x %08x\n", state->chardma_source, state->chardma_other ); } else { - if(DEBUG_PRINTF) printf("chardma_w LSB32 write to activate command %08x %08x\n", chardma_source, chardma_other ); + if(DEBUG_PRINTF) printf("chardma_w LSB32 write to activate command %08x %08x\n", state->chardma_source, state->chardma_other ); } } } @@ -2111,19 +2092,22 @@ static WRITE32_HANDLER( cps3_irq12_ack_w ) static WRITE32_HANDLER( cps3_unk_vidregs_w ) { - COMBINE_DATA(&cps3_unk_vidregs[offset]); + cps3_state *state = space->machine->driver_data(); + COMBINE_DATA(&state->unk_vidregs[offset]); } static READ32_HANDLER( cps3_colourram_r ) { - UINT16* src = (UINT16*)cps3_colourram; + cps3_state *state = space->machine->driver_data(); + UINT16* src = (UINT16*)state->colourram; return src[offset*2+1] | (src[offset*2+0]<<16); } static WRITE32_HANDLER( cps3_colourram_w ) { -// COMBINE_DATA(&cps3_colourram[offset]); + //cps3_state *state = space->machine->driver_data(); +// COMBINE_DATA(&state->colourram[offset]); if (ACCESSING_BITS_24_31) { @@ -2136,19 +2120,18 @@ static WRITE32_HANDLER( cps3_colourram_w ) } } -static UINT32* cps3_mainram; /* there are more unknown writes, but you get the idea */ static ADDRESS_MAP_START( cps3_map, ADDRESS_SPACE_PROGRAM, 32 ) AM_RANGE(0x00000000, 0x0007ffff) AM_ROM AM_REGION("user1", 0) // Bios ROM - AM_RANGE(0x02000000, 0x0207ffff) AM_RAM AM_BASE(&cps3_mainram) // Main RAM + AM_RANGE(0x02000000, 0x0207ffff) AM_RAM AM_BASE_MEMBER(cps3_state, mainram) // Main RAM AM_RANGE(0x03000000, 0x030003ff) AM_RAM // 'FRAM' (SFIII memory test mode ONLY) -// AM_RANGE(0x04000000, 0x0407dfff) AM_RAM AM_BASE(&cps3_spriteram)//AM_WRITEONLY // Sprite RAM (jojoba tests this size) - AM_RANGE(0x04000000, 0x0407ffff) AM_RAM AM_BASE(&cps3_spriteram)//AM_WRITEONLY // Sprite RAM +// AM_RANGE(0x04000000, 0x0407dfff) AM_RAM AM_BASE_MEMBER(cps3_state, spriteram)//AM_WRITEONLY // Sprite RAM (jojoba tests this size) + AM_RANGE(0x04000000, 0x0407ffff) AM_RAM AM_BASE_MEMBER(cps3_state, spriteram)//AM_WRITEONLY // Sprite RAM - AM_RANGE(0x04080000, 0x040bffff) AM_READWRITE(cps3_colourram_r, cps3_colourram_w) AM_BASE(&cps3_colourram) // Colour RAM (jojoba tests this size) 0x20000 colours?! + AM_RANGE(0x04080000, 0x040bffff) AM_READWRITE(cps3_colourram_r, cps3_colourram_w) AM_BASE_MEMBER(cps3_state, colourram) // Colour RAM (jojoba tests this size) 0x20000 colours?! // video registers of some kind probably AM_RANGE(0x040C0000, 0x040C0003) AM_READ(cps3_40C0000_r)//?? every frame @@ -2157,12 +2140,12 @@ static ADDRESS_MAP_START( cps3_map, ADDRESS_SPACE_PROGRAM, 32 ) AM_RANGE(0x040C000c, 0x040C000f) AM_READ(cps3_vbl_r)// AM_WRITENOP/ AM_RANGE(0x040C0000, 0x040C001f) AM_WRITE(cps3_unk_vidregs_w) - AM_RANGE(0x040C0020, 0x040C002b) AM_WRITEONLY AM_BASE(&tilemap20_regs_base) - AM_RANGE(0x040C0030, 0x040C003b) AM_WRITEONLY AM_BASE(&tilemap30_regs_base) - AM_RANGE(0x040C0040, 0x040C004b) AM_WRITEONLY AM_BASE(&tilemap40_regs_base) - AM_RANGE(0x040C0050, 0x040C005b) AM_WRITEONLY AM_BASE(&tilemap50_regs_base) + AM_RANGE(0x040C0020, 0x040C002b) AM_WRITEONLY AM_BASE_MEMBER(cps3_state, tilemap20_regs_base) + AM_RANGE(0x040C0030, 0x040C003b) AM_WRITEONLY AM_BASE_MEMBER(cps3_state, tilemap30_regs_base) + AM_RANGE(0x040C0040, 0x040C004b) AM_WRITEONLY AM_BASE_MEMBER(cps3_state, tilemap40_regs_base) + AM_RANGE(0x040C0050, 0x040C005b) AM_WRITEONLY AM_BASE_MEMBER(cps3_state, tilemap50_regs_base) - AM_RANGE(0x040C0060, 0x040C007f) AM_RAM AM_BASE(&cps3_fullscreenzoom) + AM_RANGE(0x040C0060, 0x040C007f) AM_RAM AM_BASE_MEMBER(cps3_state, fullscreenzoom) AM_RANGE(0x040C0094, 0x040C009b) AM_WRITE(cps3_characterdma_w) @@ -2201,7 +2184,7 @@ static ADDRESS_MAP_START( cps3_map, ADDRESS_SPACE_PROGRAM, 32 ) AM_RANGE(0x06000000, 0x067fffff) AM_READWRITE( cps3_flash1_r, cps3_flash1_w ) /* Flash ROMs simm 1 */ AM_RANGE(0x06800000, 0x06ffffff) AM_READWRITE( cps3_flash2_r, cps3_flash2_w ) /* Flash ROMs simm 2 */ - AM_RANGE(0xc0000000, 0xc00003ff) AM_RAM_WRITE( cps3_0xc0000000_ram_w ) AM_BASE(&cps3_0xc0000000_ram) /* Executes code from here */ + AM_RANGE(0xc0000000, 0xc00003ff) AM_RAM_WRITE( cps3_0xc0000000_ram_w ) AM_BASE_MEMBER(cps3_state, _0xc0000000_ram) /* Executes code from here */ ADDRESS_MAP_END @@ -2260,7 +2243,7 @@ static INTERRUPT_GEN(cps3_other_interrupt) } -//static sh2_cpu_core sh2cp_conf_slave = { 1 }; +//static sh2_cpu_core sh2cp_conf_slave = { 1, NULL }; static const SCSIConfigTable dev_table = @@ -2288,7 +2271,8 @@ static MACHINE_START( cps3 ) static MACHINE_RESET( cps3 ) { - current_table_address = -1; + cps3_state *state = machine->driver_data(); + state->current_table_address = -1; // copy data from flashroms back into user regions + decrypt into regions we execute/draw from. copy_from_nvram(machine); @@ -2299,35 +2283,36 @@ static MACHINE_RESET( cps3 ) // make a copy in the regions we execute code / draw gfx from static void copy_from_nvram(running_machine *machine) { - UINT32* romdata = (UINT32*)cps3_user4region; - UINT32* romdata2 = (UINT32*)decrypted_gamerom; + cps3_state *state = machine->driver_data(); + UINT32* romdata = (UINT32*)state->user4region; + UINT32* romdata2 = (UINT32*)state->decrypted_gamerom; int i; /* copy + decrypt program roms which have been loaded from flashroms/nvram */ for (i=0;i<0x800000;i+=4) { UINT32 data; - data = ((simm[0][0]->read_raw(i/4)<<24) | (simm[0][1]->read_raw(i/4)<<16) | (simm[0][2]->read_raw(i/4)<<8) | (simm[0][3]->read_raw(i/4)<<0)); + data = ((state->simm[0][0]->read_raw(i/4)<<24) | (state->simm[0][1]->read_raw(i/4)<<16) | (state->simm[0][2]->read_raw(i/4)<<8) | (state->simm[0][3]->read_raw(i/4)<<0)); - // printf("%08x %08x %08x %08x\n",romdata[i/4],data, romdata2[i/4], data ^ cps3_mask(i+0x6000000, cps3_key1, cps3_key2)); + // printf("%08x %08x %08x %08x\n",romdata[i/4],data, romdata2[i/4], data ^ cps3_mask(i+0x6000000, state->key1, state->key2)); romdata[i/4] = data; - romdata2[i/4] = data ^ cps3_mask(i+0x6000000, cps3_key1, cps3_key2); + romdata2[i/4] = data ^ cps3_mask(i+0x6000000, state->key1, state->key2); } romdata += 0x800000/4; romdata2 += 0x800000/4; - if (simm[1][0] != NULL) + if (state->simm[1][0] != NULL) for (i=0;i<0x800000;i+=4) { UINT32 data; - data = ((simm[1][0]->read_raw(i/4)<<24) | (simm[1][1]->read_raw(i/4)<<16) | (simm[1][2]->read_raw(i/4)<<8) | (simm[1][3]->read_raw(i/4)<<0)); + data = ((state->simm[1][0]->read_raw(i/4)<<24) | (state->simm[1][1]->read_raw(i/4)<<16) | (state->simm[1][2]->read_raw(i/4)<<8) | (state->simm[1][3]->read_raw(i/4)<<0)); - // printf("%08x %08x %08x %08x\n",romdata[i/4],data, romdata2[i/4], data ^ cps3_mask(i+0x6800000, cps3_key1, cps3_key2) ); + // printf("%08x %08x %08x %08x\n",romdata[i/4],data, romdata2[i/4], data ^ cps3_mask(i+0x6800000, state->key1, state->key2) ); romdata[i/4] = data; - romdata2[i/4] = data ^ cps3_mask(i+0x6800000, cps3_key1, cps3_key2); + romdata2[i/4] = data ^ cps3_mask(i+0x6800000, state->key1, state->key2); } /* copy gfx from loaded flashroms to user reigon 5, where it's used */ @@ -2336,13 +2321,13 @@ static void copy_from_nvram(running_machine *machine) int flashnum = 0; int countoffset = 0; - romdata = (UINT32*)cps3_user5region; + romdata = (UINT32*)state->user5region; for (thebase = 0;thebase < len/2; thebase+=0x200000) { // printf("flashnums %d. %d\n",flashnum, flashnum+1); - fujitsu_29f016a_device *flash0 = simm[2 + flashnum/8][flashnum % 8 + 0]; - fujitsu_29f016a_device *flash1 = simm[2 + flashnum/8][flashnum % 8 + 1]; + fujitsu_29f016a_device *flash0 = state->simm[2 + flashnum/8][flashnum % 8 + 0]; + fujitsu_29f016a_device *flash1 = state->simm[2 + flashnum/8][flashnum % 8 + 1]; if (flash0 == NULL || flash1 == NULL) continue; if (flash0 != NULL && flash1 != NULL) @@ -2384,8 +2369,9 @@ static void copy_from_nvram(running_machine *machine) } -static int cps3_dma_callback(UINT32 src, UINT32 dst, UINT32 data, int size) +static int cps3_dma_callback(device_t *device, UINT32 src, UINT32 dst, UINT32 data, int size) { + cps3_state *state = device->machine->driver_data(); /* on the actual CPS3 hardware the SH2 DMA bypasses the encryption. @@ -2408,17 +2394,17 @@ static int cps3_dma_callback(UINT32 src, UINT32 dst, UINT32 data, int size) if (src<0x80000) { int offs = (src&0x07ffff)>>2; - data = data ^ cps3_mask(offs*4, cps3_key1, cps3_key2); + data = data ^ cps3_mask(offs*4, state->key1, state->key2); } else if (src>=0x6000000 && src<0x6800000) { int offs = (src&0x07fffff)>>2; - if (!cps3_altEncryption) data = data ^ cps3_mask(0x6000000+offs*4, cps3_key1, cps3_key2); + if (!state->altEncryption) data = data ^ cps3_mask(0x6000000+offs*4, state->key1, state->key2); } else if (src>=0x6800000 && src<0x7000000) { int offs = (src&0x07fffff)>>2; - if (!cps3_altEncryption) data = data ^ cps3_mask(0x6800000+offs*4, cps3_key1, cps3_key2); + if (!state->altEncryption) data = data ^ cps3_mask(0x6800000+offs*4, state->key1, state->key2); } else { @@ -2509,7 +2495,7 @@ static MACHINE_CONFIG_FRAGMENT( simm6_128mbit ) MCFG_FUJITSU_29F016A_ADD("simm6.7") MACHINE_CONFIG_END -static MACHINE_CONFIG_START( cps3, driver_device ) +static MACHINE_CONFIG_START( cps3, cps3_state ) /* basic machine hardware */ MCFG_CPU_ADD("maincpu", SH2, 6250000*4) // external clock is 6.25 Mhz, it sets the intenral multiplier to 4x (this should probably be handled in the core..) MCFG_CPU_PROGRAM_MAP(cps3_map) diff --git a/src/mame/drivers/darkseal.c b/src/mame/drivers/darkseal.c index b3dc6994f2f..2368610f58c 100644 --- a/src/mame/drivers/darkseal.c +++ b/src/mame/drivers/darkseal.c @@ -21,7 +21,6 @@ #include "sound/okim6295.h" #include "includes/darkseal.h" -static UINT16 *darkseal_ram; /******************************************************************************/ @@ -61,18 +60,18 @@ static READ16_HANDLER( darkseal_control_r ) static ADDRESS_MAP_START( darkseal_map, ADDRESS_SPACE_PROGRAM, 16 ) AM_RANGE(0x000000, 0x07ffff) AM_ROM - AM_RANGE(0x100000, 0x103fff) AM_RAM AM_BASE(&darkseal_ram) + AM_RANGE(0x100000, 0x103fff) AM_RAM AM_BASE_MEMBER(darkseal_state, ram) AM_RANGE(0x120000, 0x1207ff) AM_RAM AM_BASE_SIZE_GENERIC(spriteram) AM_RANGE(0x140000, 0x140fff) AM_RAM_WRITE(darkseal_palette_24bit_rg_w) AM_BASE_GENERIC(paletteram) AM_RANGE(0x141000, 0x141fff) AM_RAM_WRITE(darkseal_palette_24bit_b_w) AM_BASE_GENERIC(paletteram2) AM_RANGE(0x180000, 0x18000f) AM_READWRITE(darkseal_control_r, darkseal_control_w) AM_RANGE(0x200000, 0x200fff) AM_WRITE(darkseal_pf3b_data_w) /* 2nd half of pf3, only used on last level */ - AM_RANGE(0x202000, 0x203fff) AM_WRITE(darkseal_pf3_data_w) AM_BASE(&darkseal_pf3_data) - AM_RANGE(0x220000, 0x220fff) AM_RAM AM_BASE(&darkseal_pf12_row) - AM_RANGE(0x222000, 0x222fff) AM_RAM AM_BASE(&darkseal_pf34_row) + AM_RANGE(0x202000, 0x203fff) AM_WRITE(darkseal_pf3_data_w) AM_BASE_MEMBER(darkseal_state, pf3_data) + AM_RANGE(0x220000, 0x220fff) AM_RAM AM_BASE_MEMBER(darkseal_state, pf12_row) + AM_RANGE(0x222000, 0x222fff) AM_RAM AM_BASE_MEMBER(darkseal_state, pf34_row) AM_RANGE(0x240000, 0x24000f) AM_WRITE(darkseal_control_0_w) - AM_RANGE(0x260000, 0x261fff) AM_WRITE(darkseal_pf2_data_w) AM_BASE(&darkseal_pf2_data) - AM_RANGE(0x262000, 0x263fff) AM_WRITE(darkseal_pf1_data_w) AM_BASE(&darkseal_pf1_data) + AM_RANGE(0x260000, 0x261fff) AM_WRITE(darkseal_pf2_data_w) AM_BASE_MEMBER(darkseal_state, pf2_data) + AM_RANGE(0x262000, 0x263fff) AM_WRITE(darkseal_pf1_data_w) AM_BASE_MEMBER(darkseal_state, pf1_data) AM_RANGE(0x2a0000, 0x2a000f) AM_WRITE(darkseal_control_1_w) ADDRESS_MAP_END @@ -227,7 +226,7 @@ static const ym2151_interface ym2151_config = sound_irq }; -static MACHINE_CONFIG_START( darkseal, driver_device ) +static MACHINE_CONFIG_START( darkseal, darkseal_state ) /* basic machine hardware */ MCFG_CPU_ADD("maincpu", M68000,12000000) /* Custom chip 59 */ diff --git a/src/mame/drivers/dec0.c b/src/mame/drivers/dec0.c index 572ff043e24..403097a123e 100644 --- a/src/mame/drivers/dec0.c +++ b/src/mame/drivers/dec0.c @@ -162,11 +162,7 @@ Notes: #include "sound/msm5205.h" -UINT16 *dec0_ram; -UINT8 *robocop_shared_ram; -static UINT8 automat_adpcm_byte; -static int automat_msm5205_vclk_toggle; /******************************************************************************/ @@ -205,7 +201,7 @@ static WRITE16_HANDLER( dec0_control_w ) break; case 0xe: /* Reset Intel 8751? - not sure, all the games write here at startup */ - dec0_i8751_reset(); + dec0_i8751_reset(space->machine); logerror("CPU #0 PC %06x: warning - write %02x to unmapped memory address %06x\n",cpu_get_pc(space->cpu),data,0x30c010+(offset<<1)); break; @@ -281,33 +277,33 @@ static ADDRESS_MAP_START( dec0_map, ADDRESS_SPACE_PROGRAM, 16 ) AM_RANGE(0x000000, 0x05ffff) AM_ROM AM_RANGE(0x240000, 0x240007) AM_WRITE(dec0_pf1_control_0_w) /* text layer */ AM_RANGE(0x240010, 0x240017) AM_WRITE(dec0_pf1_control_1_w) - AM_RANGE(0x242000, 0x24207f) AM_WRITEONLY AM_BASE(&dec0_pf1_colscroll) - AM_RANGE(0x242400, 0x2427ff) AM_WRITEONLY AM_BASE(&dec0_pf1_rowscroll) + AM_RANGE(0x242000, 0x24207f) AM_WRITEONLY AM_BASE_MEMBER(dec0_state, pf1_colscroll) + AM_RANGE(0x242400, 0x2427ff) AM_WRITEONLY AM_BASE_MEMBER(dec0_state, pf1_rowscroll) AM_RANGE(0x242800, 0x243fff) AM_RAM /* Robocop only */ - AM_RANGE(0x244000, 0x245fff) AM_RAM_WRITE(dec0_pf1_data_w) AM_BASE(&dec0_pf1_data) + AM_RANGE(0x244000, 0x245fff) AM_RAM_WRITE(dec0_pf1_data_w) AM_BASE_MEMBER(dec0_state, pf1_data) AM_RANGE(0x246000, 0x246007) AM_WRITE(dec0_pf2_control_0_w) /* first tile layer */ AM_RANGE(0x246010, 0x246017) AM_WRITE(dec0_pf2_control_1_w) - AM_RANGE(0x248000, 0x24807f) AM_WRITEONLY AM_BASE(&dec0_pf2_colscroll) - AM_RANGE(0x248400, 0x2487ff) AM_WRITEONLY AM_BASE(&dec0_pf2_rowscroll) - AM_RANGE(0x24a000, 0x24a7ff) AM_RAM_WRITE(dec0_pf2_data_w) AM_BASE(&dec0_pf2_data) + AM_RANGE(0x248000, 0x24807f) AM_WRITEONLY AM_BASE_MEMBER(dec0_state, pf2_colscroll) + AM_RANGE(0x248400, 0x2487ff) AM_WRITEONLY AM_BASE_MEMBER(dec0_state, pf2_rowscroll) + AM_RANGE(0x24a000, 0x24a7ff) AM_RAM_WRITE(dec0_pf2_data_w) AM_BASE_MEMBER(dec0_state, pf2_data) AM_RANGE(0x24c000, 0x24c007) AM_WRITE(dec0_pf3_control_0_w) /* second tile layer */ AM_RANGE(0x24c010, 0x24c017) AM_WRITE(dec0_pf3_control_1_w) - AM_RANGE(0x24c800, 0x24c87f) AM_RAM AM_BASE(&dec0_pf3_colscroll) - AM_RANGE(0x24cc00, 0x24cfff) AM_WRITEONLY AM_BASE(&dec0_pf3_rowscroll) - AM_RANGE(0x24d000, 0x24d7ff) AM_RAM_WRITE(dec0_pf3_data_w) AM_BASE(&dec0_pf3_data) + AM_RANGE(0x24c800, 0x24c87f) AM_RAM AM_BASE_MEMBER(dec0_state, pf3_colscroll) + AM_RANGE(0x24cc00, 0x24cfff) AM_WRITEONLY AM_BASE_MEMBER(dec0_state, pf3_rowscroll) + AM_RANGE(0x24d000, 0x24d7ff) AM_RAM_WRITE(dec0_pf3_data_w) AM_BASE_MEMBER(dec0_state, pf3_data) AM_RANGE(0x300000, 0x30001f) AM_READ(dec0_rotary_r) AM_RANGE(0x30c000, 0x30c00b) AM_READ(dec0_controls_r) AM_RANGE(0x30c010, 0x30c01f) AM_WRITE(dec0_control_w) /* Priority, sound, etc. */ AM_RANGE(0x310000, 0x3107ff) AM_RAM_WRITE(dec0_paletteram_rg_w) AM_BASE_GENERIC(paletteram) AM_RANGE(0x314000, 0x3147ff) AM_RAM_WRITE(dec0_paletteram_b_w) AM_BASE_GENERIC(paletteram2) - AM_RANGE(0xff8000, 0xffbfff) AM_RAM AM_BASE(&dec0_ram) /* Main ram */ + AM_RANGE(0xff8000, 0xffbfff) AM_RAM AM_BASE_MEMBER(dec0_state, ram) /* Main ram */ AM_RANGE(0xffc000, 0xffc7ff) AM_RAM AM_BASE_GENERIC(spriteram) /* Sprites */ ADDRESS_MAP_END static ADDRESS_MAP_START( robocop_sub_map, ADDRESS_SPACE_PROGRAM, 8 ) AM_RANGE(0x000000, 0x00ffff) AM_ROM AM_RANGE(0x1f0000, 0x1f1fff) AM_RAM /* Main ram */ - AM_RANGE(0x1f2000, 0x1f3fff) AM_RAM AM_BASE(&robocop_shared_ram) /* Shared ram */ + AM_RANGE(0x1f2000, 0x1f3fff) AM_RAM AM_BASE_MEMBER(dec0_state, robocop_shared_ram) /* Shared ram */ AM_RANGE(0x1ff400, 0x1ff403) AM_WRITE(h6280_irq_status_w) ADDRESS_MAP_END @@ -326,12 +322,12 @@ static ADDRESS_MAP_START( slyspy_map, ADDRESS_SPACE_PROGRAM, 16 ) AM_RANGE(0x000000, 0x05ffff) AM_ROM /* These locations aren't real! They are just there so memory is allocated */ - AM_RANGE(0x200000, 0x2007ff) AM_WRITENOP AM_BASE(&dec0_pf2_data) - AM_RANGE(0x202000, 0x203fff) AM_WRITENOP AM_BASE(&dec0_pf1_data) - AM_RANGE(0x232000, 0x23207f) AM_WRITENOP AM_BASE(&dec0_pf2_colscroll) - AM_RANGE(0x232400, 0x2327ff) AM_WRITENOP AM_BASE(&dec0_pf2_rowscroll) - AM_RANGE(0x23c000, 0x23c07f) AM_WRITENOP AM_BASE(&dec0_pf1_colscroll) - AM_RANGE(0x23c400, 0x23c7ff) AM_WRITENOP AM_BASE(&dec0_pf1_rowscroll) + AM_RANGE(0x200000, 0x2007ff) AM_WRITENOP AM_BASE_MEMBER(dec0_state, pf2_data) + AM_RANGE(0x202000, 0x203fff) AM_WRITENOP AM_BASE_MEMBER(dec0_state, pf1_data) + AM_RANGE(0x232000, 0x23207f) AM_WRITENOP AM_BASE_MEMBER(dec0_state, pf2_colscroll) + AM_RANGE(0x232400, 0x2327ff) AM_WRITENOP AM_BASE_MEMBER(dec0_state, pf2_rowscroll) + AM_RANGE(0x23c000, 0x23c07f) AM_WRITENOP AM_BASE_MEMBER(dec0_state, pf1_colscroll) + AM_RANGE(0x23c400, 0x23c7ff) AM_WRITENOP AM_BASE_MEMBER(dec0_state, pf1_rowscroll) AM_RANGE(0x244000, 0x244001) AM_READ(slyspy_state_r) AM_WRITENOP /* protection */ @@ -347,11 +343,11 @@ static ADDRESS_MAP_START( slyspy_map, ADDRESS_SPACE_PROGRAM, 16 ) /* Pf3 is unaffected by protection */ AM_RANGE(0x300000, 0x300007) AM_WRITE(dec0_pf3_control_0_w) AM_RANGE(0x300010, 0x300017) AM_WRITE(dec0_pf3_control_1_w) - AM_RANGE(0x300800, 0x30087f) AM_WRITEONLY AM_BASE(&dec0_pf3_colscroll) - AM_RANGE(0x300c00, 0x300fff) AM_WRITEONLY AM_BASE(&dec0_pf3_rowscroll) - AM_RANGE(0x301000, 0x3017ff) AM_WRITE(dec0_pf3_data_w) AM_BASE(&dec0_pf3_data) + AM_RANGE(0x300800, 0x30087f) AM_WRITEONLY AM_BASE_MEMBER(dec0_state, pf3_colscroll) + AM_RANGE(0x300c00, 0x300fff) AM_WRITEONLY AM_BASE_MEMBER(dec0_state, pf3_rowscroll) + AM_RANGE(0x301000, 0x3017ff) AM_WRITE(dec0_pf3_data_w) AM_BASE_MEMBER(dec0_state, pf3_data) - AM_RANGE(0x304000, 0x307fff) AM_RAM AM_BASE(&dec0_ram) /* Sly spy main ram */ + AM_RANGE(0x304000, 0x307fff) AM_RAM AM_BASE_MEMBER(dec0_state, ram) /* Sly spy main ram */ AM_RANGE(0x308000, 0x3087ff) AM_RAM AM_BASE_GENERIC(spriteram) /* Sprites */ AM_RANGE(0x310000, 0x3107ff) AM_RAM_WRITE(paletteram16_xxxxBBBBGGGGRRRR_word_w) AM_BASE_GENERIC(paletteram) AM_RANGE(0x314000, 0x314003) AM_WRITE(slyspy_control_w) @@ -361,7 +357,7 @@ ADDRESS_MAP_END static ADDRESS_MAP_START( midres_map, ADDRESS_SPACE_PROGRAM, 16 ) AM_RANGE(0x000000, 0x07ffff) AM_ROM - AM_RANGE(0x100000, 0x103fff) AM_RAM AM_BASE(&dec0_ram) + AM_RANGE(0x100000, 0x103fff) AM_RAM AM_BASE_MEMBER(dec0_state, ram) AM_RANGE(0x120000, 0x1207ff) AM_RAM AM_BASE_GENERIC(spriteram) AM_RANGE(0x140000, 0x1407ff) AM_WRITE(paletteram16_xxxxBBBBGGGGRRRR_word_w) AM_BASE_GENERIC(paletteram) AM_RANGE(0x160000, 0x160001) AM_WRITE(dec0_priority_w) @@ -371,22 +367,22 @@ static ADDRESS_MAP_START( midres_map, ADDRESS_SPACE_PROGRAM, 16 ) AM_RANGE(0x200000, 0x200007) AM_WRITE(dec0_pf2_control_0_w) AM_RANGE(0x200010, 0x200017) AM_WRITE(dec0_pf2_control_1_w) - AM_RANGE(0x220000, 0x2207ff) AM_WRITE(dec0_pf2_data_w) AM_BASE(&dec0_pf2_data) + AM_RANGE(0x220000, 0x2207ff) AM_WRITE(dec0_pf2_data_w) AM_BASE_MEMBER(dec0_state, pf2_data) AM_RANGE(0x220800, 0x220fff) AM_WRITE(dec0_pf2_data_w) /* mirror address used in end sequence */ - AM_RANGE(0x240000, 0x24007f) AM_RAM AM_BASE(&dec0_pf2_colscroll) - AM_RANGE(0x240400, 0x2407ff) AM_RAM AM_BASE(&dec0_pf2_rowscroll) + AM_RANGE(0x240000, 0x24007f) AM_RAM AM_BASE_MEMBER(dec0_state, pf2_colscroll) + AM_RANGE(0x240400, 0x2407ff) AM_RAM AM_BASE_MEMBER(dec0_state, pf2_rowscroll) AM_RANGE(0x280000, 0x280007) AM_WRITE(dec0_pf3_control_0_w) AM_RANGE(0x280010, 0x280017) AM_WRITE(dec0_pf3_control_1_w) - AM_RANGE(0x2a0000, 0x2a07ff) AM_WRITE(dec0_pf3_data_w) AM_BASE(&dec0_pf3_data) - AM_RANGE(0x2c0000, 0x2c007f) AM_RAM AM_BASE(&dec0_pf3_colscroll) - AM_RANGE(0x2c0400, 0x2c07ff) AM_RAM AM_BASE(&dec0_pf3_rowscroll) + AM_RANGE(0x2a0000, 0x2a07ff) AM_WRITE(dec0_pf3_data_w) AM_BASE_MEMBER(dec0_state, pf3_data) + AM_RANGE(0x2c0000, 0x2c007f) AM_RAM AM_BASE_MEMBER(dec0_state, pf3_colscroll) + AM_RANGE(0x2c0400, 0x2c07ff) AM_RAM AM_BASE_MEMBER(dec0_state, pf3_rowscroll) AM_RANGE(0x300000, 0x300007) AM_WRITE(dec0_pf1_control_0_w) AM_RANGE(0x300010, 0x300017) AM_WRITE(dec0_pf1_control_1_w) - AM_RANGE(0x320000, 0x321fff) AM_WRITE(dec0_pf1_data_w) AM_BASE(&dec0_pf1_data) - AM_RANGE(0x340000, 0x34007f) AM_RAM AM_BASE(&dec0_pf1_colscroll) - AM_RANGE(0x340400, 0x3407ff) AM_RAM AM_BASE(&dec0_pf1_rowscroll) + AM_RANGE(0x320000, 0x321fff) AM_WRITE(dec0_pf1_data_w) AM_BASE_MEMBER(dec0_state, pf1_data) + AM_RANGE(0x340000, 0x34007f) AM_RAM AM_BASE_MEMBER(dec0_state, pf1_colscroll) + AM_RANGE(0x340400, 0x3407ff) AM_RAM AM_BASE_MEMBER(dec0_state, pf1_rowscroll) AM_RANGE(0x320000, 0x321fff) AM_RAM ADDRESS_MAP_END @@ -429,25 +425,25 @@ static ADDRESS_MAP_START( secretab_map, ADDRESS_SPACE_PROGRAM, 16 ) AM_RANGE(0x000000, 0x05ffff) AM_ROM AM_RANGE(0x240000, 0x240007) AM_WRITE(dec0_pf2_control_0_w) AM_RANGE(0x240010, 0x240017) AM_WRITE(dec0_pf2_control_1_w) - AM_RANGE(0x246000, 0x247fff) AM_RAM_WRITE(dec0_pf2_data_w) AM_BASE(&dec0_pf2_data) -// AM_RANGE(0x240000, 0x24007f) AM_RAM AM_BASE(&dec0_pf2_colscroll) -// AM_RANGE(0x240400, 0x2407ff) AM_RAM AM_BASE(&dec0_pf2_rowscroll) + AM_RANGE(0x246000, 0x247fff) AM_RAM_WRITE(dec0_pf2_data_w) AM_BASE_MEMBER(dec0_state, pf2_data) +// AM_RANGE(0x240000, 0x24007f) AM_RAM AM_BASE_MEMBER(dec0_state, pf2_colscroll) +// AM_RANGE(0x240400, 0x2407ff) AM_RAM AM_BASE_MEMBER(dec0_state, pf2_rowscroll) // AM_RANGE(0x200000, 0x300007) AM_WRITE(dec0_pf1_control_0_w) // AM_RANGE(0x300010, 0x300017) AM_WRITE(dec0_pf1_control_1_w) - AM_RANGE(0x24e000, 0x24ffff) AM_RAM_WRITE(dec0_pf1_data_w) AM_BASE(&dec0_pf1_data) -// AM_RANGE(0x340000, 0x34007f) AM_RAM AM_BASE(&dec0_pf1_colscroll) -// AM_RANGE(0x340400, 0x3407ff) AM_RAM AM_BASE(&dec0_pf1_rowscroll) + AM_RANGE(0x24e000, 0x24ffff) AM_RAM_WRITE(dec0_pf1_data_w) AM_BASE_MEMBER(dec0_state, pf1_data) +// AM_RANGE(0x340000, 0x34007f) AM_RAM AM_BASE_MEMBER(dec0_state, pf1_colscroll) +// AM_RANGE(0x340400, 0x3407ff) AM_RAM AM_BASE_MEMBER(dec0_state, pf1_rowscroll) AM_RANGE(0x314008, 0x31400f) AM_READ(slyspy_controls_r) // AM_RANGE(0x314000, 0x314003) AM_WRITE(slyspy_control_w) AM_RANGE(0x300000, 0x300007) AM_WRITE(dec0_pf3_control_0_w) AM_RANGE(0x300010, 0x300017) AM_WRITE(dec0_pf3_control_1_w) - AM_RANGE(0x300800, 0x30087f) AM_RAM AM_BASE(&dec0_pf3_colscroll) - AM_RANGE(0x300c00, 0x300fff) AM_RAM AM_BASE(&dec0_pf3_rowscroll) - AM_RANGE(0x301000, 0x3017ff) AM_RAM_WRITE(dec0_pf3_data_w) AM_BASE(&dec0_pf3_data) - AM_RANGE(0x301800, 0x307fff) AM_RAM AM_BASE(&dec0_ram) /* Sly spy main ram */ + AM_RANGE(0x300800, 0x30087f) AM_RAM AM_BASE_MEMBER(dec0_state, pf3_colscroll) + AM_RANGE(0x300c00, 0x300fff) AM_RAM AM_BASE_MEMBER(dec0_state, pf3_rowscroll) + AM_RANGE(0x301000, 0x3017ff) AM_RAM_WRITE(dec0_pf3_data_w) AM_BASE_MEMBER(dec0_state, pf3_data) + AM_RANGE(0x301800, 0x307fff) AM_RAM AM_BASE_MEMBER(dec0_state, ram) /* Sly spy main ram */ AM_RANGE(0x310000, 0x3107ff) AM_RAM_WRITE(paletteram16_xxxxBBBBGGGGRRRR_word_w) AM_BASE_GENERIC(paletteram) AM_RANGE(0xb08000, 0xb087ff) AM_RAM AM_BASE_GENERIC(spriteram) /* Sprites */ ADDRESS_MAP_END @@ -457,36 +453,37 @@ static ADDRESS_MAP_START( automat_map, ADDRESS_SPACE_PROGRAM, 16 ) AM_RANGE(0x240000, 0x240007) AM_WRITE(dec0_pf1_control_0_w) /* text layer */ AM_RANGE(0x240010, 0x240017) AM_WRITE(dec0_pf1_control_1_w) - AM_RANGE(0x242000, 0x24207f) AM_WRITEONLY AM_BASE(&dec0_pf1_colscroll) - AM_RANGE(0x242400, 0x2427ff) AM_WRITEONLY AM_BASE(&dec0_pf1_rowscroll) + AM_RANGE(0x242000, 0x24207f) AM_WRITEONLY AM_BASE_MEMBER(dec0_state, pf1_colscroll) + AM_RANGE(0x242400, 0x2427ff) AM_WRITEONLY AM_BASE_MEMBER(dec0_state, pf1_rowscroll) AM_RANGE(0x242800, 0x243fff) AM_RAM /* Robocop only */ - AM_RANGE(0x244000, 0x245fff) AM_RAM_WRITE(dec0_pf1_data_w) AM_BASE(&dec0_pf1_data) + AM_RANGE(0x244000, 0x245fff) AM_RAM_WRITE(dec0_pf1_data_w) AM_BASE_MEMBER(dec0_state, pf1_data) AM_RANGE(0x246000, 0x246007) AM_WRITE(dec0_pf2_control_0_w) /* first tile layer */ AM_RANGE(0x246010, 0x246017) AM_WRITE(dec0_pf2_control_1_w) - AM_RANGE(0x248000, 0x24807f) AM_WRITEONLY AM_BASE(&dec0_pf2_colscroll) - AM_RANGE(0x248400, 0x2487ff) AM_WRITEONLY AM_BASE(&dec0_pf2_rowscroll) + AM_RANGE(0x248000, 0x24807f) AM_WRITEONLY AM_BASE_MEMBER(dec0_state, pf2_colscroll) + AM_RANGE(0x248400, 0x2487ff) AM_WRITEONLY AM_BASE_MEMBER(dec0_state, pf2_rowscroll) - AM_RANGE(0x24a000, 0x24a7ff) AM_RAM_WRITE(dec0_pf2_data_w) AM_BASE(&dec0_pf2_data) + AM_RANGE(0x24a000, 0x24a7ff) AM_RAM_WRITE(dec0_pf2_data_w) AM_BASE_MEMBER(dec0_state, pf2_data) AM_RANGE(0x24c000, 0x24c007) AM_WRITE(dec0_pf3_control_0_w) /* second tile layer */ AM_RANGE(0x24c010, 0x24c017) AM_WRITE(dec0_pf3_control_1_w) - AM_RANGE(0x24c800, 0x24c87f) AM_RAM AM_BASE(&dec0_pf3_colscroll) - AM_RANGE(0x24cc00, 0x24cfff) AM_WRITEONLY AM_BASE(&dec0_pf3_rowscroll) - AM_RANGE(0x24d000, 0x24d7ff) AM_RAM_WRITE(dec0_pf3_data_w) AM_BASE(&dec0_pf3_data) + AM_RANGE(0x24c800, 0x24c87f) AM_RAM AM_BASE_MEMBER(dec0_state, pf3_colscroll) + AM_RANGE(0x24cc00, 0x24cfff) AM_WRITEONLY AM_BASE_MEMBER(dec0_state, pf3_rowscroll) + AM_RANGE(0x24d000, 0x24d7ff) AM_RAM_WRITE(dec0_pf3_data_w) AM_BASE_MEMBER(dec0_state, pf3_data) AM_RANGE(0x300000, 0x30001f) AM_READ(dec0_rotary_r) AM_RANGE(0x30c000, 0x30c00b) AM_READ(dec0_controls_r) AM_RANGE(0x30c000, 0x30c01f) AM_WRITE(automat_control_w) /* Priority, sound, etc. */ AM_RANGE(0x310000, 0x3107ff) AM_RAM_WRITE(paletteram16_xxxxBBBBGGGGRRRR_word_w) AM_BASE_GENERIC(paletteram) AM_RANGE(0x314000, 0x3147ff) AM_RAM AM_RANGE(0x400008, 0x400009) AM_WRITE(dec0_priority_w) // NEW - AM_RANGE(0xff8000, 0xffbfff) AM_RAM AM_BASE(&dec0_ram) /* Main ram */ + AM_RANGE(0xff8000, 0xffbfff) AM_RAM AM_BASE_MEMBER(dec0_state, ram) /* Main ram */ AM_RANGE(0xffc000, 0xffc7ff) AM_RAM AM_BASE_GENERIC(spriteram) /* Sprites */ ADDRESS_MAP_END static WRITE8_HANDLER( automat_adpcm_w ) { - automat_adpcm_byte = data; + dec0_state *state = space->machine->driver_data(); + state->automat_adpcm_byte = data; } static ADDRESS_MAP_START( automat_s_map, ADDRESS_SPACE_PROGRAM, 8 ) @@ -1122,17 +1119,18 @@ static const ym3812_interface ym3812b_interface = static void automat_vclk_cb(device_t *device) { - if (automat_msm5205_vclk_toggle == 0) + dec0_state *state = device->machine->driver_data(); + if (state->automat_msm5205_vclk_toggle == 0) { - msm5205_data_w(device, automat_adpcm_byte & 0xf); + msm5205_data_w(device, state->automat_adpcm_byte & 0xf); } else { - msm5205_data_w(device, automat_adpcm_byte >> 4); + msm5205_data_w(device, state->automat_adpcm_byte >> 4); cputag_set_input_line(device->machine, "maincpu", INPUT_LINE_NMI, PULSE_LINE); } - automat_msm5205_vclk_toggle ^= 1; + state->automat_msm5205_vclk_toggle ^= 1; } static const msm5205_interface msm5205_config = @@ -1142,7 +1140,7 @@ static const msm5205_interface msm5205_config = }; -static MACHINE_CONFIG_START( automat, driver_device ) +static MACHINE_CONFIG_START( automat, dec0_state ) /* basic machine hardware */ MCFG_CPU_ADD("maincpu", M68000, 10000000) @@ -1186,7 +1184,7 @@ static MACHINE_CONFIG_START( automat, driver_device ) MACHINE_CONFIG_END -static MACHINE_CONFIG_START( hbarrel, driver_device ) +static MACHINE_CONFIG_START( hbarrel, dec0_state ) /* basic machine hardware */ MCFG_CPU_ADD("maincpu", M68000, XTAL_20MHz / 2) @@ -1230,7 +1228,7 @@ static MACHINE_CONFIG_START( hbarrel, driver_device ) MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.80) MACHINE_CONFIG_END -static MACHINE_CONFIG_START( baddudes, driver_device ) +static MACHINE_CONFIG_START( baddudes, dec0_state ) /* basic machine hardware */ MCFG_CPU_ADD("maincpu", M68000, XTAL_20MHz / 2) @@ -1271,7 +1269,7 @@ static MACHINE_CONFIG_START( baddudes, driver_device ) MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.80) MACHINE_CONFIG_END -static MACHINE_CONFIG_START( birdtry, driver_device ) +static MACHINE_CONFIG_START( birdtry, dec0_state ) /* basic machine hardware */ MCFG_CPU_ADD("maincpu", M68000, XTAL_20MHz / 2) @@ -1312,7 +1310,7 @@ static MACHINE_CONFIG_START( birdtry, driver_device ) MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.80) MACHINE_CONFIG_END -static MACHINE_CONFIG_START( robocop, driver_device ) +static MACHINE_CONFIG_START( robocop, dec0_state ) /* basic machine hardware */ MCFG_CPU_ADD("maincpu", M68000, XTAL_20MHz / 2) @@ -1358,7 +1356,7 @@ static MACHINE_CONFIG_START( robocop, driver_device ) MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.80) MACHINE_CONFIG_END -static MACHINE_CONFIG_START( robocopb, driver_device ) +static MACHINE_CONFIG_START( robocopb, dec0_state ) /* basic machine hardware */ MCFG_CPU_ADD("maincpu", M68000, 10000000) @@ -1399,7 +1397,7 @@ static MACHINE_CONFIG_START( robocopb, driver_device ) MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.80) MACHINE_CONFIG_END -static MACHINE_CONFIG_START( hippodrm, driver_device ) +static MACHINE_CONFIG_START( hippodrm, dec0_state ) /* basic machine hardware */ MCFG_CPU_ADD("maincpu", M68000, XTAL_20MHz / 2) @@ -1445,7 +1443,7 @@ static MACHINE_CONFIG_START( hippodrm, driver_device ) MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.80) MACHINE_CONFIG_END -static MACHINE_CONFIG_START( slyspy, driver_device ) +static MACHINE_CONFIG_START( slyspy, dec0_state ) /* basic machine hardware */ MCFG_CPU_ADD("maincpu", M68000, XTAL_20MHz/2) /* verified on pcb (20MHZ OSC) 68000P12 running at 10Mhz */ @@ -1486,7 +1484,7 @@ static MACHINE_CONFIG_START( slyspy, driver_device ) MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.80) MACHINE_CONFIG_END -static MACHINE_CONFIG_START( secretab, driver_device ) +static MACHINE_CONFIG_START( secretab, dec0_state ) /* basic machine hardware */ MCFG_CPU_ADD("maincpu", M68000, XTAL_20MHz/2) /* verified on pcb (20MHZ OSC) 68000P12 running at 10Mhz */ @@ -1528,7 +1526,7 @@ static MACHINE_CONFIG_START( secretab, driver_device ) MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.80) MACHINE_CONFIG_END -static MACHINE_CONFIG_START( midres, driver_device ) +static MACHINE_CONFIG_START( midres, dec0_state ) /* basic machine hardware */ MCFG_CPU_ADD("maincpu", M68000, XTAL_20MHz/2) /* verified on pcb (20MHZ OSC) 68000P12 running at 10Mhz */ diff --git a/src/mame/drivers/deco32.c b/src/mame/drivers/deco32.c index 930fe62abac..333ddf014dc 100644 --- a/src/mame/drivers/deco32.c +++ b/src/mame/drivers/deco32.c @@ -237,24 +237,22 @@ Notes: #include "sound/okim6295.h" #include "sound/bsmt2000.h" -static UINT32 *deco32_ram; -static int raster_enable; -static timer_device *raster_irq_timer; -static UINT8 nslasher_sound_irq; /**********************************************************************************/ static WRITE32_HANDLER( deco32_pf12_control_w ) { - COMBINE_DATA(&deco32_pf12_control[offset]); + deco32_state *state = space->machine->driver_data(); + COMBINE_DATA(&state->pf12_control[offset]); space->machine->primary_screen->update_partial(space->machine->primary_screen->vpos()); } static WRITE32_HANDLER( deco32_pf34_control_w ) { - COMBINE_DATA(&deco32_pf34_control[offset]); + deco32_state *state = space->machine->driver_data(); + COMBINE_DATA(&state->pf34_control[offset]); space->machine->primary_screen->update_partial(space->machine->primary_screen->vpos()); } @@ -303,23 +301,24 @@ static READ32_HANDLER( deco32_irq_controller_r ) static WRITE32_HANDLER( deco32_irq_controller_w ) { + deco32_state *state = space->machine->driver_data(); int scanline; switch (offset) { case 0: /* IRQ enable - probably an irq mask, but only values used are 0xc8 and 0xca */ // logerror("%08x: IRQ write %d %08x\n",cpu_get_pc(space->cpu),offset,data); - raster_enable=(data&0xff)==0xc8; /* 0xca seems to be off */ + state->raster_enable=(data&0xff)==0xc8; /* 0xca seems to be off */ break; case 1: /* Raster IRQ scanline position, only valid for values between 1 & 239 (0 and 240-256 do NOT generate IRQ's) */ scanline=(data&0xff); - if (raster_enable && scanline>0 && scanline<240) + if (state->raster_enable && scanline>0 && scanline<240) { // needs +16 for the raster to align on captaven intro? (might just be our screen size / visible area / layer offsets need adjusting instead) - raster_irq_timer->adjust(space->machine->primary_screen->time_until_pos(scanline+16, 320)); + state->raster_irq_timer->adjust(space->machine->primary_screen->time_until_pos(scanline+16, 320)); } else - raster_irq_timer->reset(); + state->raster_irq_timer->reset(); break; case 2: /* VBL irq ack */ break; @@ -404,42 +403,43 @@ static READ32_HANDLER( lockload_gun_mirror_r ) static READ32_HANDLER( dragngun_prot_r ) { + deco32_state *state = space->machine->driver_data(); // logerror("%08x:Read prot %08x (%08x)\n",cpu_get_pc(space->cpu),offset<<1,mem_mask); - static int strobe=0; - if (!strobe) strobe=8; - else strobe=0; + if (!state->strobe) state->strobe=8; + else state->strobe=0; //definitely vblank in locked load switch (offset<<1) { case 0x140/2: return 0xffff0000 | input_port_read(space->machine, "IN0"); /* IN0 */ - case 0xadc/2: return 0xffff0000 | input_port_read(space->machine, "IN1") | strobe; /* IN1 */ + case 0xadc/2: return 0xffff0000 | input_port_read(space->machine, "IN1") | state->strobe; /* IN1 */ case 0x6a0/2: return 0xffff0000 | input_port_read(space->machine, "DSW"); /* IN2 (Dip switch) */ } return 0xffffffff; } -static int dragngun_lightgun_port; static READ32_HANDLER( dragngun_lightgun_r ) { + deco32_state *state = space->machine->driver_data(); /* Ports 0-3 are read, but seem unused */ - switch (dragngun_lightgun_port) { + switch (state->dragngun_lightgun_port) { case 4: return input_port_read(space->machine, "LIGHT0_X"); case 5: return input_port_read(space->machine, "LIGHT1_X"); case 6: return input_port_read(space->machine, "LIGHT0_Y"); case 7: return input_port_read(space->machine, "LIGHT1_Y"); } -// logerror("Illegal lightgun port %d read \n",dragngun_lightgun_port); +// logerror("Illegal lightgun port %d read \n",state->dragngun_lightgun_port); return 0; } static WRITE32_HANDLER( dragngun_lightgun_w ) { -// logerror("Lightgun port %d\n",dragngun_lightgun_port); - dragngun_lightgun_port=offset; + deco32_state *state = space->machine->driver_data(); +// logerror("Lightgun port %d\n",state->dragngun_lightgun_port); + state->dragngun_lightgun_port=offset; } static READ32_DEVICE_HANDLER( dragngun_eeprom_r ) @@ -460,14 +460,14 @@ static WRITE32_DEVICE_HANDLER( dragngun_eeprom_w ) /**********************************************************************************/ -static int tattass_eprom_bit; static READ32_HANDLER( tattass_prot_r ) { + deco32_state *state = space->machine->driver_data(); switch (offset<<1) { case 0x280: return input_port_read(space->machine, "IN0") << 16; case 0x4c4: return input_port_read(space->machine, "IN1") << 16; - case 0x35a: return tattass_eprom_bit << 16; + case 0x35a: return state->tattass_eprom_bit << 16; } logerror("%08x:Read prot %08x (%08x)\n",cpu_get_pc(space->cpu),offset<<1,mem_mask); @@ -488,12 +488,7 @@ static WRITE32_HANDLER( tattass_prot_w ) static WRITE32_HANDLER( tattass_control_w ) { - static int lastClock=0; - static char buffer[32]; - static int bufPtr=0; - static int pendingCommand=0; /* 1 = read, 2 = write */ - static int readBitCount=0; - static int byteAddr=0; + deco32_state *state = space->machine->driver_data(); eeprom_device *eeprom = space->machine->device("eeprom"); address_space *eeprom_space = eeprom->space(); @@ -520,71 +515,71 @@ static WRITE32_HANDLER( tattass_control_w ) */ if ((data&0x40)==0) { - if (bufPtr) { + if (state->bufPtr) { int i; - logerror("Eprom reset (bit count %d): ",readBitCount); - for (i=0; ireadBitCount); + for (i=0; ibufPtr; i++) + logerror("%s",state->buffer[i] ? "1" : "0"); logerror("\n"); } - bufPtr=0; - pendingCommand=0; - readBitCount=0; + state->bufPtr=0; + state->pendingCommand=0; + state->readBitCount=0; } /* Eprom has been clocked */ - if (lastClock==0 && data&0x20 && data&0x40) { - if (bufPtr>=32) { + if (state->lastClock==0 && data&0x20 && data&0x40) { + if (state->bufPtr>=32) { logerror("Eprom overflow!"); - bufPtr=0; + state->bufPtr=0; } /* Handle pending read */ - if (pendingCommand==1) { - int d=readBitCount/8; - int m=7-(readBitCount%8); - int a=(byteAddr+d)%1024; + if (state->pendingCommand==1) { + int d=state->readBitCount/8; + int m=7-(state->readBitCount%8); + int a=(state->byteAddr+d)%1024; int b=eeprom_space->read_byte(a); - tattass_eprom_bit=(b>>m)&1; + state->tattass_eprom_bit=(b>>m)&1; - readBitCount++; - lastClock=data&0x20; + state->readBitCount++; + state->lastClock=data&0x20; return; } /* Handle pending write */ - if (pendingCommand==2) { - buffer[bufPtr++]=(data&0x10)>>4; + if (state->pendingCommand==2) { + state->buffer[state->bufPtr++]=(data&0x10)>>4; - if (bufPtr==32) { - int b=(buffer[24]<<7)|(buffer[25]<<6)|(buffer[26]<<5)|(buffer[27]<<4) - |(buffer[28]<<3)|(buffer[29]<<2)|(buffer[30]<<1)|(buffer[31]<<0); + if (state->bufPtr==32) { + int b=(state->buffer[24]<<7)|(state->buffer[25]<<6)|(state->buffer[26]<<5)|(state->buffer[27]<<4) + |(state->buffer[28]<<3)|(state->buffer[29]<<2)|(state->buffer[30]<<1)|(state->buffer[31]<<0); - eeprom_space->write_byte(byteAddr, b); + eeprom_space->write_byte(state->byteAddr, b); } - lastClock=data&0x20; + state->lastClock=data&0x20; return; } - buffer[bufPtr++]=(data&0x10)>>4; - if (bufPtr==24) { + state->buffer[state->bufPtr++]=(data&0x10)>>4; + if (state->bufPtr==24) { /* Decode addr */ - byteAddr=(buffer[3]<<9)|(buffer[4]<<8) - |(buffer[16]<<7)|(buffer[17]<<6)|(buffer[18]<<5)|(buffer[19]<<4) - |(buffer[20]<<3)|(buffer[21]<<2)|(buffer[22]<<1)|(buffer[23]<<0); + state->byteAddr=(state->buffer[3]<<9)|(state->buffer[4]<<8) + |(state->buffer[16]<<7)|(state->buffer[17]<<6)|(state->buffer[18]<<5)|(state->buffer[19]<<4) + |(state->buffer[20]<<3)|(state->buffer[21]<<2)|(state->buffer[22]<<1)|(state->buffer[23]<<0); /* Check for read command */ - if (buffer[0] && buffer[1]) { - tattass_eprom_bit=(eeprom_space->read_byte(byteAddr)>>7)&1; - readBitCount=1; - pendingCommand=1; + if (state->buffer[0] && state->buffer[1]) { + state->tattass_eprom_bit=(eeprom_space->read_byte(state->byteAddr)>>7)&1; + state->readBitCount=1; + state->pendingCommand=1; } /* Check for write command */ - else if (buffer[0]==0x0 && buffer[1]==0x0) { - pendingCommand=2; + else if (state->buffer[0]==0x0 && state->buffer[1]==0x0) { + state->pendingCommand=2; } else { logerror("Detected unknown eprom command\n"); @@ -594,11 +589,11 @@ static WRITE32_HANDLER( tattass_control_w ) } else { if (!(data&0x40)) { logerror("Cs set low\n"); - bufPtr=0; + state->bufPtr=0; } } - lastClock=data&0x20; + state->lastClock=data&0x20; return; } @@ -655,6 +650,7 @@ static WRITE32_HANDLER( nslasher_eeprom_w ) static WRITE32_HANDLER( nslasher_prot_w ) { + deco32_state *state = space->machine->driver_data(); //logerror("%08x:write prot %08x (%08x) %08x\n",cpu_get_pc(space->cpu),offset<<1,mem_mask,data); /* Only sound port of chip is used - no protection */ @@ -662,8 +658,8 @@ static WRITE32_HANDLER( nslasher_prot_w ) /* bit 1 of nslasher_sound_irq specifies IRQ command writes */ soundlatch_w(space,0,(data>>16)&0xff); - nslasher_sound_irq |= 0x02; - cputag_set_input_line(space->machine, "audiocpu", 0, (nslasher_sound_irq != 0) ? ASSERT_LINE : CLEAR_LINE); + state->nslasher_sound_irq |= 0x02; + cputag_set_input_line(space->machine, "audiocpu", 0, (state->nslasher_sound_irq != 0) ? ASSERT_LINE : CLEAR_LINE); } } @@ -676,7 +672,7 @@ static ADDRESS_MAP_START( captaven_map, ADDRESS_SPACE_PROGRAM, 32 ) AM_RANGE(0x100000, 0x100003) AM_WRITE(buffer_spriteram32_w) AM_RANGE(0x108000, 0x108003) AM_WRITENOP /* ? */ AM_RANGE(0x110000, 0x110fff) AM_RAM AM_BASE_SIZE_GENERIC(spriteram) /* Sprites */ - AM_RANGE(0x120000, 0x127fff) AM_RAM AM_BASE(&deco32_ram) /* Main RAM */ + AM_RANGE(0x120000, 0x127fff) AM_RAM AM_BASE_MEMBER(deco32_state, ram) /* Main RAM */ AM_RANGE(0x128000, 0x128fff) AM_READ(captaven_prot_r) AM_RANGE(0x1280c8, 0x1280cb) AM_WRITE(deco32_sound_w) AM_RANGE(0x130000, 0x131fff) AM_RAM_WRITE(deco32_nonbuffered_palette_w) AM_BASE_GENERIC(paletteram) /* Palette RAM */ @@ -686,22 +682,22 @@ static ADDRESS_MAP_START( captaven_map, ADDRESS_SPACE_PROGRAM, 32 ) AM_RANGE(0x178000, 0x178003) AM_WRITE(deco32_pri_w) - AM_RANGE(0x180000, 0x18001f) AM_RAM_WRITE(deco32_pf12_control_w) AM_BASE(&deco32_pf12_control) - AM_RANGE(0x190000, 0x191fff) AM_RAM_WRITE(deco32_pf1_data_w) AM_BASE(&deco32_pf1_data) + AM_RANGE(0x180000, 0x18001f) AM_RAM_WRITE(deco32_pf12_control_w) AM_BASE_MEMBER(deco32_state, pf12_control) + AM_RANGE(0x190000, 0x191fff) AM_RAM_WRITE(deco32_pf1_data_w) AM_BASE_MEMBER(deco32_state, pf1_data) AM_RANGE(0x192000, 0x193fff) AM_WRITE(deco32_pf1_data_w) /* Mirror address - bug in program code */ - AM_RANGE(0x194000, 0x195fff) AM_RAM_WRITE(deco32_pf2_data_w) AM_BASE(&deco32_pf2_data) - AM_RANGE(0x1a0000, 0x1a1fff) AM_RAM AM_BASE(&deco32_pf1_rowscroll) - AM_RANGE(0x1a4000, 0x1a5fff) AM_RAM AM_BASE(&deco32_pf2_rowscroll) + AM_RANGE(0x194000, 0x195fff) AM_RAM_WRITE(deco32_pf2_data_w) AM_BASE_MEMBER(deco32_state, pf2_data) + AM_RANGE(0x1a0000, 0x1a1fff) AM_RAM AM_BASE_MEMBER(deco32_state, pf1_rowscroll) + AM_RANGE(0x1a4000, 0x1a5fff) AM_RAM AM_BASE_MEMBER(deco32_state, pf2_rowscroll) - AM_RANGE(0x1c0000, 0x1c001f) AM_RAM_WRITE(deco32_pf34_control_w) AM_BASE(&deco32_pf34_control) - AM_RANGE(0x1d0000, 0x1d1fff) AM_RAM_WRITE(deco32_pf3_data_w) AM_BASE(&deco32_pf3_data) - AM_RANGE(0x1e0000, 0x1e1fff) AM_RAM AM_BASE(&deco32_pf3_rowscroll) + AM_RANGE(0x1c0000, 0x1c001f) AM_RAM_WRITE(deco32_pf34_control_w) AM_BASE_MEMBER(deco32_state, pf34_control) + AM_RANGE(0x1d0000, 0x1d1fff) AM_RAM_WRITE(deco32_pf3_data_w) AM_BASE_MEMBER(deco32_state, pf3_data) + AM_RANGE(0x1e0000, 0x1e1fff) AM_RAM AM_BASE_MEMBER(deco32_state, pf3_rowscroll) ADDRESS_MAP_END static ADDRESS_MAP_START( fghthist_map, ADDRESS_SPACE_PROGRAM, 32 ) AM_RANGE(0x000000, 0x001fff) AM_ROM AM_WRITE(deco32_pf1_data_w) AM_RANGE(0x000000, 0x0fffff) AM_ROM - AM_RANGE(0x100000, 0x11ffff) AM_RAM AM_BASE(&deco32_ram) + AM_RANGE(0x100000, 0x11ffff) AM_RAM AM_BASE_MEMBER(deco32_state, ram) AM_RANGE(0x120020, 0x12002f) AM_READ(fghthist_control_r) AM_RANGE(0x12002c, 0x12002f) AM_WRITE(fghthist_eeprom_w) AM_RANGE(0x1201fc, 0x1201ff) AM_WRITE(deco32_sound_w) @@ -715,17 +711,17 @@ static ADDRESS_MAP_START( fghthist_map, ADDRESS_SPACE_PROGRAM, 32 ) AM_RANGE(0x179000, 0x179fff) AM_RAM AM_BASE_GENERIC(spriteram2) // ? AM_RANGE(0x17c010, 0x17c013) AM_WRITE(buffer_spriteram32_w) - AM_RANGE(0x182000, 0x183fff) AM_RAM_WRITE(deco32_pf1_data_w) AM_BASE(&deco32_pf1_data) - AM_RANGE(0x184000, 0x185fff) AM_RAM_WRITE(deco32_pf2_data_w) AM_BASE(&deco32_pf2_data) - AM_RANGE(0x192000, 0x192fff) AM_RAM AM_BASE(&deco32_pf1_rowscroll) - AM_RANGE(0x194000, 0x194fff) AM_RAM AM_BASE(&deco32_pf2_rowscroll) - AM_RANGE(0x1a0000, 0x1a001f) AM_RAM_WRITE(deco32_pf12_control_w) AM_BASE(&deco32_pf12_control) + AM_RANGE(0x182000, 0x183fff) AM_RAM_WRITE(deco32_pf1_data_w) AM_BASE_MEMBER(deco32_state, pf1_data) + AM_RANGE(0x184000, 0x185fff) AM_RAM_WRITE(deco32_pf2_data_w) AM_BASE_MEMBER(deco32_state, pf2_data) + AM_RANGE(0x192000, 0x192fff) AM_RAM AM_BASE_MEMBER(deco32_state, pf1_rowscroll) + AM_RANGE(0x194000, 0x194fff) AM_RAM AM_BASE_MEMBER(deco32_state, pf2_rowscroll) + AM_RANGE(0x1a0000, 0x1a001f) AM_RAM_WRITE(deco32_pf12_control_w) AM_BASE_MEMBER(deco32_state, pf12_control) - AM_RANGE(0x1c2000, 0x1c3fff) AM_RAM_WRITE(deco32_pf3_data_w) AM_BASE(&deco32_pf3_data) - AM_RANGE(0x1c4000, 0x1c5fff) AM_RAM_WRITE(deco32_pf4_data_w) AM_BASE(&deco32_pf4_data) - AM_RANGE(0x1d2000, 0x1d2fff) AM_RAM AM_BASE(&deco32_pf3_rowscroll) - AM_RANGE(0x1d4000, 0x1d4fff) AM_RAM AM_BASE(&deco32_pf4_rowscroll) - AM_RANGE(0x1e0000, 0x1e001f) AM_RAM_WRITE(deco32_pf34_control_w) AM_BASE(&deco32_pf34_control) + AM_RANGE(0x1c2000, 0x1c3fff) AM_RAM_WRITE(deco32_pf3_data_w) AM_BASE_MEMBER(deco32_state, pf3_data) + AM_RANGE(0x1c4000, 0x1c5fff) AM_RAM_WRITE(deco32_pf4_data_w) AM_BASE_MEMBER(deco32_state, pf4_data) + AM_RANGE(0x1d2000, 0x1d2fff) AM_RAM AM_BASE_MEMBER(deco32_state, pf3_rowscroll) + AM_RANGE(0x1d4000, 0x1d4fff) AM_RAM AM_BASE_MEMBER(deco32_state, pf4_rowscroll) + AM_RANGE(0x1e0000, 0x1e001f) AM_RAM_WRITE(deco32_pf34_control_w) AM_BASE_MEMBER(deco32_state, pf34_control) AM_RANGE(0x16c000, 0x16c01f) AM_READNOP AM_RANGE(0x17c000, 0x17c03f) AM_READNOP @@ -736,7 +732,7 @@ ADDRESS_MAP_END static ADDRESS_MAP_START( fghthsta_memmap, ADDRESS_SPACE_PROGRAM, 32 ) AM_RANGE(0x000000, 0x0fffff) AM_ROM - AM_RANGE(0x100000, 0x11ffff) AM_RAM AM_BASE(&deco32_ram) + AM_RANGE(0x100000, 0x11ffff) AM_RAM AM_BASE_MEMBER(deco32_state, ram) AM_RANGE(0x140000, 0x140003) AM_WRITENOP /* VBL irq ack */ AM_RANGE(0x150000, 0x150003) AM_WRITE(fghthist_eeprom_w) /* Volume port/Eprom */ @@ -748,17 +744,17 @@ static ADDRESS_MAP_START( fghthsta_memmap, ADDRESS_SPACE_PROGRAM, 32 ) AM_RANGE(0x17c010, 0x17c013) AM_WRITE(buffer_spriteram32_w) AM_RANGE(0x17c020, 0x17c023) AM_READNOP - AM_RANGE(0x182000, 0x183fff) AM_RAM_WRITE(deco32_pf1_data_w) AM_BASE(&deco32_pf1_data) - AM_RANGE(0x184000, 0x185fff) AM_RAM_WRITE(deco32_pf2_data_w) AM_BASE(&deco32_pf2_data) - AM_RANGE(0x192000, 0x192fff) AM_RAM AM_BASE(&deco32_pf1_rowscroll) - AM_RANGE(0x194000, 0x194fff) AM_RAM AM_BASE(&deco32_pf2_rowscroll) - AM_RANGE(0x1a0000, 0x1a001f) AM_RAM_WRITE(deco32_pf12_control_w) AM_BASE(&deco32_pf12_control) + AM_RANGE(0x182000, 0x183fff) AM_RAM_WRITE(deco32_pf1_data_w) AM_BASE_MEMBER(deco32_state, pf1_data) + AM_RANGE(0x184000, 0x185fff) AM_RAM_WRITE(deco32_pf2_data_w) AM_BASE_MEMBER(deco32_state, pf2_data) + AM_RANGE(0x192000, 0x192fff) AM_RAM AM_BASE_MEMBER(deco32_state, pf1_rowscroll) + AM_RANGE(0x194000, 0x194fff) AM_RAM AM_BASE_MEMBER(deco32_state, pf2_rowscroll) + AM_RANGE(0x1a0000, 0x1a001f) AM_RAM_WRITE(deco32_pf12_control_w) AM_BASE_MEMBER(deco32_state, pf12_control) - AM_RANGE(0x1c2000, 0x1c3fff) AM_RAM_WRITE(deco32_pf3_data_w) AM_BASE(&deco32_pf3_data) - AM_RANGE(0x1c4000, 0x1c5fff) AM_RAM_WRITE(deco32_pf4_data_w) AM_BASE(&deco32_pf4_data) - AM_RANGE(0x1d2000, 0x1d2fff) AM_RAM AM_BASE(&deco32_pf3_rowscroll) - AM_RANGE(0x1d4000, 0x1d4fff) AM_RAM AM_BASE(&deco32_pf4_rowscroll) - AM_RANGE(0x1e0000, 0x1e001f) AM_RAM_WRITE(deco32_pf34_control_w) AM_BASE(&deco32_pf34_control) + AM_RANGE(0x1c2000, 0x1c3fff) AM_RAM_WRITE(deco32_pf3_data_w) AM_BASE_MEMBER(deco32_state, pf3_data) + AM_RANGE(0x1c4000, 0x1c5fff) AM_RAM_WRITE(deco32_pf4_data_w) AM_BASE_MEMBER(deco32_state, pf4_data) + AM_RANGE(0x1d2000, 0x1d2fff) AM_RAM AM_BASE_MEMBER(deco32_state, pf3_rowscroll) + AM_RANGE(0x1d4000, 0x1d4fff) AM_RAM AM_BASE_MEMBER(deco32_state, pf4_rowscroll) + AM_RANGE(0x1e0000, 0x1e001f) AM_RAM_WRITE(deco32_pf34_control_w) AM_BASE_MEMBER(deco32_state, pf34_control) AM_RANGE(0x200000, 0x200fff) AM_READWRITE(deco16_146_fghthist_prot_r, deco16_146_fghthist_prot_w) AM_BASE(&deco32_prot_ram) ADDRESS_MAP_END @@ -767,7 +763,7 @@ ADDRESS_MAP_END // raster effects appear to need some work on it anyway? static ADDRESS_MAP_START( dragngun_map, ADDRESS_SPACE_PROGRAM, 32 ) AM_RANGE(0x000000, 0x0fffff) AM_ROM - AM_RANGE(0x100000, 0x11ffff) AM_RAM AM_BASE(&deco32_ram) + AM_RANGE(0x100000, 0x11ffff) AM_RAM AM_BASE_MEMBER(deco32_state, ram) AM_RANGE(0x120000, 0x120fff) AM_READ(dragngun_prot_r) AM_RANGE(0x1204c0, 0x1204c3) AM_WRITE(deco32_sound_w) AM_RANGE(0x128000, 0x12800f) AM_READWRITE(deco32_irq_controller_r, deco32_irq_controller_w) @@ -775,27 +771,27 @@ static ADDRESS_MAP_START( dragngun_map, ADDRESS_SPACE_PROGRAM, 32 ) AM_RANGE(0x138000, 0x138003) AM_NOP /* Palette dma complete in bit 0x8? ack? return 0 else tight loop */ AM_RANGE(0x138008, 0x13800b) AM_WRITE(deco32_palette_dma_w) -// AM_RANGE(0x180000, 0x18001f) AM_RAM_WRITE(deco32_pf12_control_w) AM_BASE(&deco32_pf12_control) - AM_RANGE(0x180000, 0x18001f) AM_RAM AM_BASE(&deco32_pf12_control) - AM_RANGE(0x190000, 0x191fff) AM_RAM_WRITE(deco32_pf1_data_w) AM_BASE(&deco32_pf1_data) - AM_RANGE(0x194000, 0x195fff) AM_RAM_WRITE(deco32_pf2_data_w) AM_BASE(&deco32_pf2_data) - AM_RANGE(0x1a0000, 0x1a0fff) AM_RAM AM_BASE(&deco32_pf1_rowscroll) - AM_RANGE(0x1a4000, 0x1a4fff) AM_RAM AM_BASE(&deco32_pf2_rowscroll) +// AM_RANGE(0x180000, 0x18001f) AM_RAM_WRITE(deco32_pf12_control_w) AM_BASE_MEMBER(deco32_state, pf12_control) + AM_RANGE(0x180000, 0x18001f) AM_RAM AM_BASE_MEMBER(deco32_state, pf12_control) + AM_RANGE(0x190000, 0x191fff) AM_RAM_WRITE(deco32_pf1_data_w) AM_BASE_MEMBER(deco32_state, pf1_data) + AM_RANGE(0x194000, 0x195fff) AM_RAM_WRITE(deco32_pf2_data_w) AM_BASE_MEMBER(deco32_state, pf2_data) + AM_RANGE(0x1a0000, 0x1a0fff) AM_RAM AM_BASE_MEMBER(deco32_state, pf1_rowscroll) + AM_RANGE(0x1a4000, 0x1a4fff) AM_RAM AM_BASE_MEMBER(deco32_state, pf2_rowscroll) -// AM_RANGE(0x1c0000, 0x1c001f) AM_RAM_WRITE(deco32_pf34_control_w) AM_BASE(&deco32_pf34_control) - AM_RANGE(0x1c0000, 0x1c001f) AM_RAM AM_BASE(&deco32_pf34_control) - AM_RANGE(0x1d0000, 0x1d1fff) AM_RAM_WRITE(deco32_pf3_data_w) AM_BASE(&deco32_pf3_data) - AM_RANGE(0x1d4000, 0x1d5fff) AM_RAM_WRITE(deco32_pf4_data_w) AM_BASE(&deco32_pf4_data) - AM_RANGE(0x1e0000, 0x1e0fff) AM_RAM AM_BASE(&deco32_pf3_rowscroll) - AM_RANGE(0x1e4000, 0x1e4fff) AM_RAM AM_BASE(&deco32_pf4_rowscroll) +// AM_RANGE(0x1c0000, 0x1c001f) AM_RAM_WRITE(deco32_pf34_control_w) AM_BASE_MEMBER(deco32_state, pf34_control) + AM_RANGE(0x1c0000, 0x1c001f) AM_RAM AM_BASE_MEMBER(deco32_state, pf34_control) + AM_RANGE(0x1d0000, 0x1d1fff) AM_RAM_WRITE(deco32_pf3_data_w) AM_BASE_MEMBER(deco32_state, pf3_data) + AM_RANGE(0x1d4000, 0x1d5fff) AM_RAM_WRITE(deco32_pf4_data_w) AM_BASE_MEMBER(deco32_state, pf4_data) + AM_RANGE(0x1e0000, 0x1e0fff) AM_RAM AM_BASE_MEMBER(deco32_state, pf3_rowscroll) + AM_RANGE(0x1e4000, 0x1e4fff) AM_RAM AM_BASE_MEMBER(deco32_state, pf4_rowscroll) AM_RANGE(0x204800, 0x204fff) AM_RAM // ace? 0x10 byte increments only // 13f ff stuff - AM_RANGE(0x208000, 0x208fff) AM_RAM AM_BASE(&dragngun_sprite_layout_0_ram) - AM_RANGE(0x20c000, 0x20cfff) AM_RAM AM_BASE(&dragngun_sprite_layout_1_ram) - AM_RANGE(0x210000, 0x217fff) AM_RAM AM_BASE(&dragngun_sprite_lookup_0_ram) - AM_RANGE(0x218000, 0x21ffff) AM_RAM AM_BASE(&dragngun_sprite_lookup_1_ram) + AM_RANGE(0x208000, 0x208fff) AM_RAM AM_BASE_MEMBER(deco32_state, dragngun_sprite_layout_0_ram) + AM_RANGE(0x20c000, 0x20cfff) AM_RAM AM_BASE_MEMBER(deco32_state, dragngun_sprite_layout_1_ram) + AM_RANGE(0x210000, 0x217fff) AM_RAM AM_BASE_MEMBER(deco32_state, dragngun_sprite_lookup_0_ram) + AM_RANGE(0x218000, 0x21ffff) AM_RAM AM_BASE_MEMBER(deco32_state, dragngun_sprite_lookup_1_ram) AM_RANGE(0x220000, 0x221fff) AM_RAM AM_BASE_SIZE_GENERIC(spriteram) /* Main spriteram */ AM_RANGE(0x228000, 0x2283ff) AM_RAM //0x10 byte increments only @@ -816,7 +812,7 @@ ADDRESS_MAP_END static ADDRESS_MAP_START( lockload_map, ADDRESS_SPACE_PROGRAM, 32 ) AM_RANGE(0x000000, 0x0fffff) AM_ROM - AM_RANGE(0x100000, 0x11ffff) AM_RAM AM_BASE(&deco32_ram) + AM_RANGE(0x100000, 0x11ffff) AM_RAM AM_BASE_MEMBER(deco32_state, ram) AM_RANGE(0x120000, 0x120fff) AM_READ(dragngun_prot_r) AM_RANGE(0x1204c0, 0x1204c3) AM_WRITE(deco32_sound_w) AM_RANGE(0x128000, 0x12800f) AM_READWRITE(deco32_irq_controller_r, deco32_irq_controller_w) @@ -828,25 +824,25 @@ static ADDRESS_MAP_START( lockload_map, ADDRESS_SPACE_PROGRAM, 32 ) AM_RANGE(0x170000, 0x170007) AM_READ(lockload_gun_mirror_r) /* Not on Dragongun */ AM_RANGE(0x178008, 0x17800f) AM_WRITENOP /* Gun read ACK's */ -// AM_RANGE(0x180000, 0x18001f) AM_RAM_WRITE(deco32_pf12_control_w) AM_BASE(&deco32_pf12_control) - AM_RANGE(0x180000, 0x18001f) AM_RAM AM_BASE(&deco32_pf12_control) - AM_RANGE(0x190000, 0x191fff) AM_RAM_WRITE(deco32_pf1_data_w) AM_BASE(&deco32_pf1_data) - AM_RANGE(0x194000, 0x195fff) AM_RAM_WRITE(deco32_pf2_data_w) AM_BASE(&deco32_pf2_data) - AM_RANGE(0x1a0000, 0x1a0fff) AM_RAM AM_BASE(&deco32_pf1_rowscroll) - AM_RANGE(0x1a4000, 0x1a4fff) AM_RAM AM_BASE(&deco32_pf2_rowscroll) +// AM_RANGE(0x180000, 0x18001f) AM_RAM_WRITE(deco32_pf12_control_w) AM_BASE_MEMBER(deco32_state, pf12_control) + AM_RANGE(0x180000, 0x18001f) AM_RAM AM_BASE_MEMBER(deco32_state, pf12_control) + AM_RANGE(0x190000, 0x191fff) AM_RAM_WRITE(deco32_pf1_data_w) AM_BASE_MEMBER(deco32_state, pf1_data) + AM_RANGE(0x194000, 0x195fff) AM_RAM_WRITE(deco32_pf2_data_w) AM_BASE_MEMBER(deco32_state, pf2_data) + AM_RANGE(0x1a0000, 0x1a0fff) AM_RAM AM_BASE_MEMBER(deco32_state, pf1_rowscroll) + AM_RANGE(0x1a4000, 0x1a4fff) AM_RAM AM_BASE_MEMBER(deco32_state, pf2_rowscroll) -// AM_RANGE(0x1c0000, 0x1c001f) AM_RAM_WRITE(deco32_pf34_control_w) AM_BASE(&deco32_pf34_control) - AM_RANGE(0x1c0000, 0x1c001f) AM_RAM AM_BASE(&deco32_pf34_control) - AM_RANGE(0x1d0000, 0x1d1fff) AM_RAM_WRITE(deco32_pf3_data_w) AM_BASE(&deco32_pf3_data) - AM_RANGE(0x1d4000, 0x1d5fff) AM_RAM_WRITE(deco32_pf4_data_w) AM_BASE(&deco32_pf4_data) - AM_RANGE(0x1e0000, 0x1e0fff) AM_RAM AM_BASE(&deco32_pf3_rowscroll) - AM_RANGE(0x1e4000, 0x1e4fff) AM_RAM AM_BASE(&deco32_pf4_rowscroll) +// AM_RANGE(0x1c0000, 0x1c001f) AM_RAM_WRITE(deco32_pf34_control_w) AM_BASE_MEMBER(deco32_state, pf34_control) + AM_RANGE(0x1c0000, 0x1c001f) AM_RAM AM_BASE_MEMBER(deco32_state, pf34_control) + AM_RANGE(0x1d0000, 0x1d1fff) AM_RAM_WRITE(deco32_pf3_data_w) AM_BASE_MEMBER(deco32_state, pf3_data) + AM_RANGE(0x1d4000, 0x1d5fff) AM_RAM_WRITE(deco32_pf4_data_w) AM_BASE_MEMBER(deco32_state, pf4_data) + AM_RANGE(0x1e0000, 0x1e0fff) AM_RAM AM_BASE_MEMBER(deco32_state, pf3_rowscroll) + AM_RANGE(0x1e4000, 0x1e4fff) AM_RAM AM_BASE_MEMBER(deco32_state, pf4_rowscroll) AM_RANGE(0x204800, 0x204fff) AM_RAM //0x10 byte increments only - AM_RANGE(0x208000, 0x208fff) AM_RAM AM_BASE(&dragngun_sprite_layout_0_ram) - AM_RANGE(0x20c000, 0x20cfff) AM_RAM AM_BASE(&dragngun_sprite_layout_1_ram) - AM_RANGE(0x210000, 0x217fff) AM_RAM AM_BASE(&dragngun_sprite_lookup_0_ram) - AM_RANGE(0x218000, 0x21ffff) AM_RAM AM_BASE(&dragngun_sprite_lookup_1_ram) + AM_RANGE(0x208000, 0x208fff) AM_RAM AM_BASE_MEMBER(deco32_state, dragngun_sprite_layout_0_ram) + AM_RANGE(0x20c000, 0x20cfff) AM_RAM AM_BASE_MEMBER(deco32_state, dragngun_sprite_layout_1_ram) + AM_RANGE(0x210000, 0x217fff) AM_RAM AM_BASE_MEMBER(deco32_state, dragngun_sprite_lookup_0_ram) + AM_RANGE(0x218000, 0x21ffff) AM_RAM AM_BASE_MEMBER(deco32_state, dragngun_sprite_lookup_1_ram) AM_RANGE(0x220000, 0x221fff) AM_RAM AM_BASE_SIZE_GENERIC(spriteram) /* Main spriteram */ AM_RANGE(0x228000, 0x2283ff) AM_RAM //0x10 byte increments only @@ -866,14 +862,14 @@ static ADDRESS_MAP_START( tattass_map, ADDRESS_SPACE_PROGRAM, 32 ) AM_RANGE(0x000000, 0x0f7fff) AM_ROM AM_RANGE(0x0f8000, 0x0fffff) AM_ROM AM_WRITENOP - AM_RANGE(0x100000, 0x11ffff) AM_RAM AM_BASE(&deco32_ram) + AM_RANGE(0x100000, 0x11ffff) AM_RAM AM_BASE_MEMBER(deco32_state, ram) AM_RANGE(0x120000, 0x120003) AM_NOP /* ACIA (unused) */ AM_RANGE(0x130000, 0x130003) AM_WRITENOP /* Coin port (unused?) */ AM_RANGE(0x140000, 0x140003) AM_WRITENOP /* Vblank ack */ AM_RANGE(0x150000, 0x150003) AM_WRITE(tattass_control_w) /* Volume port/Eprom/Priority */ AM_RANGE(0x162000, 0x162fff) AM_RAM /* 'Jack' RAM!? */ - AM_RANGE(0x163000, 0x16309f) AM_RAM_WRITE(deco32_ace_ram_w) AM_BASE(&deco32_ace_ram) + AM_RANGE(0x163000, 0x16309f) AM_RAM_WRITE(deco32_ace_ram_w) AM_BASE_MEMBER(deco32_state, ace_ram) AM_RANGE(0x164000, 0x164003) AM_WRITENOP /* Palette control BG2/3 ($1a constant) */ AM_RANGE(0x164004, 0x164007) AM_WRITENOP /* Palette control Obj1 ($6 constant) */ AM_RANGE(0x164008, 0x16400b) AM_WRITENOP /* Palette control Obj2 ($5 constant) */ @@ -892,29 +888,29 @@ static ADDRESS_MAP_START( tattass_map, ADDRESS_SPACE_PROGRAM, 32 ) AM_RANGE(0x17c010, 0x17c013) AM_WRITE(buffer_spriteram32_2_w) AM_RANGE(0x17c018, 0x17c01b) AM_WRITENOP /* Sprite 'CPU' (unused) */ - AM_RANGE(0x182000, 0x183fff) AM_RAM_WRITE(deco32_pf1_data_w) AM_BASE(&deco32_pf1_data) - AM_RANGE(0x184000, 0x185fff) AM_RAM_WRITE(deco32_pf2_data_w) AM_BASE(&deco32_pf2_data) - AM_RANGE(0x192000, 0x193fff) AM_RAM AM_BASE(&deco32_pf1_rowscroll) - AM_RANGE(0x194000, 0x195fff) AM_RAM AM_BASE(&deco32_pf2_rowscroll) - AM_RANGE(0x1a0000, 0x1a001f) AM_RAM_WRITE(deco32_pf12_control_w) AM_BASE(&deco32_pf12_control) + AM_RANGE(0x182000, 0x183fff) AM_RAM_WRITE(deco32_pf1_data_w) AM_BASE_MEMBER(deco32_state, pf1_data) + AM_RANGE(0x184000, 0x185fff) AM_RAM_WRITE(deco32_pf2_data_w) AM_BASE_MEMBER(deco32_state, pf2_data) + AM_RANGE(0x192000, 0x193fff) AM_RAM AM_BASE_MEMBER(deco32_state, pf1_rowscroll) + AM_RANGE(0x194000, 0x195fff) AM_RAM AM_BASE_MEMBER(deco32_state, pf2_rowscroll) + AM_RANGE(0x1a0000, 0x1a001f) AM_RAM_WRITE(deco32_pf12_control_w) AM_BASE_MEMBER(deco32_state, pf12_control) - AM_RANGE(0x1c2000, 0x1c3fff) AM_RAM_WRITE(deco32_pf3_data_w) AM_BASE(&deco32_pf3_data) - AM_RANGE(0x1c4000, 0x1c5fff) AM_RAM_WRITE(deco32_pf4_data_w) AM_BASE(&deco32_pf4_data) - AM_RANGE(0x1d2000, 0x1d3fff) AM_RAM AM_BASE(&deco32_pf3_rowscroll) - AM_RANGE(0x1d4000, 0x1d5fff) AM_RAM AM_BASE(&deco32_pf4_rowscroll) - AM_RANGE(0x1e0000, 0x1e001f) AM_RAM_WRITE(deco32_pf34_control_w) AM_BASE(&deco32_pf34_control) + AM_RANGE(0x1c2000, 0x1c3fff) AM_RAM_WRITE(deco32_pf3_data_w) AM_BASE_MEMBER(deco32_state, pf3_data) + AM_RANGE(0x1c4000, 0x1c5fff) AM_RAM_WRITE(deco32_pf4_data_w) AM_BASE_MEMBER(deco32_state, pf4_data) + AM_RANGE(0x1d2000, 0x1d3fff) AM_RAM AM_BASE_MEMBER(deco32_state, pf3_rowscroll) + AM_RANGE(0x1d4000, 0x1d5fff) AM_RAM AM_BASE_MEMBER(deco32_state, pf4_rowscroll) + AM_RANGE(0x1e0000, 0x1e001f) AM_RAM_WRITE(deco32_pf34_control_w) AM_BASE_MEMBER(deco32_state, pf34_control) AM_RANGE(0x200000, 0x200fff) AM_READWRITE(tattass_prot_r, tattass_prot_w) AM_BASE(&deco32_prot_ram) ADDRESS_MAP_END static ADDRESS_MAP_START( nslasher_map, ADDRESS_SPACE_PROGRAM, 32 ) AM_RANGE(0x000000, 0x0fffff) AM_ROM - AM_RANGE(0x100000, 0x11ffff) AM_RAM AM_BASE(&deco32_ram) + AM_RANGE(0x100000, 0x11ffff) AM_RAM AM_BASE_MEMBER(deco32_state, ram) AM_RANGE(0x120000, 0x1200ff) AM_NOP /* ACIA (unused) */ AM_RANGE(0x140000, 0x140003) AM_WRITENOP /* Vblank ack */ AM_RANGE(0x150000, 0x150003) AM_WRITE(nslasher_eeprom_w) /* Volume port/Eprom/Priority */ - AM_RANGE(0x163000, 0x16309f) AM_RAM_WRITE(deco32_ace_ram_w) AM_BASE(&deco32_ace_ram) /* 'Ace' RAM!? */ + AM_RANGE(0x163000, 0x16309f) AM_RAM_WRITE(deco32_ace_ram_w) AM_BASE_MEMBER(deco32_state, ace_ram) /* 'Ace' RAM!? */ AM_RANGE(0x164000, 0x164003) AM_WRITENOP /* Palette control BG2/3 ($1a constant) */ AM_RANGE(0x164004, 0x164007) AM_WRITENOP /* Palette control Obj1 ($4 constant) */ AM_RANGE(0x164008, 0x16400b) AM_WRITENOP /* Palette control Obj2 ($6 constant) */ @@ -932,37 +928,37 @@ static ADDRESS_MAP_START( nslasher_map, ADDRESS_SPACE_PROGRAM, 32 ) AM_RANGE(0x17c010, 0x17c013) AM_WRITE(buffer_spriteram32_2_w) AM_RANGE(0x17c018, 0x17c01b) AM_WRITENOP /* Sprite 'CPU' (unused) */ - AM_RANGE(0x182000, 0x183fff) AM_RAM_WRITE(deco32_pf1_data_w) AM_BASE(&deco32_pf1_data) - AM_RANGE(0x184000, 0x185fff) AM_RAM_WRITE(deco32_pf2_data_w) AM_BASE(&deco32_pf2_data) - AM_RANGE(0x192000, 0x193fff) AM_RAM AM_BASE(&deco32_pf1_rowscroll) - AM_RANGE(0x194000, 0x195fff) AM_RAM AM_BASE(&deco32_pf2_rowscroll) - AM_RANGE(0x1a0000, 0x1a001f) AM_RAM_WRITE(deco32_pf12_control_w) AM_BASE(&deco32_pf12_control) + AM_RANGE(0x182000, 0x183fff) AM_RAM_WRITE(deco32_pf1_data_w) AM_BASE_MEMBER(deco32_state, pf1_data) + AM_RANGE(0x184000, 0x185fff) AM_RAM_WRITE(deco32_pf2_data_w) AM_BASE_MEMBER(deco32_state, pf2_data) + AM_RANGE(0x192000, 0x193fff) AM_RAM AM_BASE_MEMBER(deco32_state, pf1_rowscroll) + AM_RANGE(0x194000, 0x195fff) AM_RAM AM_BASE_MEMBER(deco32_state, pf2_rowscroll) + AM_RANGE(0x1a0000, 0x1a001f) AM_RAM_WRITE(deco32_pf12_control_w) AM_BASE_MEMBER(deco32_state, pf12_control) - AM_RANGE(0x1c2000, 0x1c3fff) AM_RAM_WRITE(deco32_pf3_data_w) AM_BASE(&deco32_pf3_data) - AM_RANGE(0x1c4000, 0x1c5fff) AM_RAM_WRITE(deco32_pf4_data_w) AM_BASE(&deco32_pf4_data) - AM_RANGE(0x1d2000, 0x1d3fff) AM_RAM AM_BASE(&deco32_pf3_rowscroll) - AM_RANGE(0x1d4000, 0x1d5fff) AM_RAM AM_BASE(&deco32_pf4_rowscroll) - AM_RANGE(0x1e0000, 0x1e001f) AM_RAM_WRITE(deco32_pf34_control_w) AM_BASE(&deco32_pf34_control) + AM_RANGE(0x1c2000, 0x1c3fff) AM_RAM_WRITE(deco32_pf3_data_w) AM_BASE_MEMBER(deco32_state, pf3_data) + AM_RANGE(0x1c4000, 0x1c5fff) AM_RAM_WRITE(deco32_pf4_data_w) AM_BASE_MEMBER(deco32_state, pf4_data) + AM_RANGE(0x1d2000, 0x1d3fff) AM_RAM AM_BASE_MEMBER(deco32_state, pf3_rowscroll) + AM_RANGE(0x1d4000, 0x1d5fff) AM_RAM AM_BASE_MEMBER(deco32_state, pf4_rowscroll) + AM_RANGE(0x1e0000, 0x1e001f) AM_RAM_WRITE(deco32_pf34_control_w) AM_BASE_MEMBER(deco32_state, pf34_control) AM_RANGE(0x200000, 0x200fff) AM_READWRITE(nslasher_prot_r, nslasher_prot_w) AM_BASE(&deco32_prot_ram) ADDRESS_MAP_END /******************************************************************************/ -static UINT8 bsmt_latch; -static UINT8 bsmt_reset; static WRITE8_HANDLER(deco32_bsmt_reset_w) { - UINT8 diff = data ^ bsmt_reset; - bsmt_reset = data; + deco32_state *state = space->machine->driver_data(); + UINT8 diff = data ^ state->bsmt_reset; + state->bsmt_reset = data; if ((diff & 0x80) && !(data & 0x80)) devtag_reset(space->machine, "bsmt"); } static WRITE8_HANDLER(deco32_bsmt0_w) { - bsmt_latch = data; + deco32_state *state = space->machine->driver_data(); + state->bsmt_latch = data; } static void bsmt_ready_callback(bsmt2000_device &device) @@ -972,9 +968,10 @@ static void bsmt_ready_callback(bsmt2000_device &device) static WRITE8_HANDLER(deco32_bsmt1_w) { + deco32_state *state = space->machine->driver_data(); bsmt2000_device *bsmt = space->machine->device("bsmt"); bsmt->write_reg(offset ^ 0xff); - bsmt->write_data((bsmt_latch << 8) | data); + bsmt->write_data((state->bsmt_latch << 8) | data); cputag_set_input_line(space->machine, "audiocpu", M6809_IRQ_LINE, CLEAR_LINE); /* BSMT is not ready */ } @@ -1007,9 +1004,10 @@ ADDRESS_MAP_END static READ8_HANDLER(latch_r) { + deco32_state *state = space->machine->driver_data(); /* bit 1 of nslasher_sound_irq specifies IRQ command writes */ - nslasher_sound_irq &= ~0x02; - cputag_set_input_line(space->machine, "audiocpu", 0, (nslasher_sound_irq != 0) ? ASSERT_LINE : CLEAR_LINE); + state->nslasher_sound_irq &= ~0x02; + cputag_set_input_line(space->machine, "audiocpu", 0, (state->nslasher_sound_irq != 0) ? ASSERT_LINE : CLEAR_LINE); return soundlatch_r(space,0); } @@ -1612,12 +1610,13 @@ static void sound_irq(device_t *device, int state) static void sound_irq_nslasher(device_t *device, int state) { + deco32_state *drvstate = device->machine->driver_data(); /* bit 0 of nslasher_sound_irq specifies IRQ from sound chip */ if (state) - nslasher_sound_irq |= 0x01; + drvstate->nslasher_sound_irq |= 0x01; else - nslasher_sound_irq &= ~0x01; - cputag_set_input_line(device->machine, "audiocpu", 0, (nslasher_sound_irq != 0) ? ASSERT_LINE : CLEAR_LINE); + drvstate->nslasher_sound_irq &= ~0x01; + cputag_set_input_line(device->machine, "audiocpu", 0, (drvstate->nslasher_sound_irq != 0) ? ASSERT_LINE : CLEAR_LINE); } static WRITE8_DEVICE_HANDLER( sound_bankswitch_w ) @@ -1650,7 +1649,8 @@ static const eeprom_interface eeprom_interface_tattass = static MACHINE_RESET( deco32 ) { - raster_irq_timer = machine->device("int_timer"); + deco32_state *state = machine->driver_data(); + state->raster_irq_timer = machine->device("int_timer"); } static INTERRUPT_GEN( deco32_vbl_interrupt ) @@ -1663,7 +1663,7 @@ static INTERRUPT_GEN( tattass_snd_interrupt ) cpu_set_input_line(device, M6809_FIRQ_LINE, HOLD_LINE); } -static MACHINE_CONFIG_START( captaven, driver_device ) +static MACHINE_CONFIG_START( captaven, deco32_state ) /* basic machine hardware */ MCFG_CPU_ADD("maincpu", ARM, XTAL_28MHz/4) /* verified on pcb (Data East 101 custom)*/ @@ -1710,7 +1710,7 @@ static MACHINE_CONFIG_START( captaven, driver_device ) MCFG_SOUND_ROUTE(ALL_OUTPUTS, "rspeaker", 0.35) MACHINE_CONFIG_END -static MACHINE_CONFIG_START( fghthist, driver_device ) +static MACHINE_CONFIG_START( fghthist, deco32_state ) /* basic machine hardware */ MCFG_CPU_ADD("maincpu", ARM, 28000000/4) @@ -1754,7 +1754,7 @@ static MACHINE_CONFIG_START( fghthist, driver_device ) MCFG_SOUND_ROUTE(ALL_OUTPUTS, "rspeaker", 0.35) MACHINE_CONFIG_END -static MACHINE_CONFIG_START( fghthsta, driver_device ) +static MACHINE_CONFIG_START( fghthsta, deco32_state ) /* basic machine hardware */ MCFG_CPU_ADD("maincpu", ARM, 28000000/4) @@ -1798,7 +1798,7 @@ static MACHINE_CONFIG_START( fghthsta, driver_device ) MCFG_SOUND_ROUTE(ALL_OUTPUTS, "rspeaker", 0.35) MACHINE_CONFIG_END -static MACHINE_CONFIG_START( dragngun, driver_device ) +static MACHINE_CONFIG_START( dragngun, deco32_state ) /* basic machine hardware */ MCFG_CPU_ADD("maincpu", ARM, 28000000/4) @@ -1850,7 +1850,7 @@ static MACHINE_CONFIG_START( dragngun, driver_device ) MCFG_SOUND_ROUTE(ALL_OUTPUTS, "rspeaker", 1.0) MACHINE_CONFIG_END -static MACHINE_CONFIG_START( lockload, driver_device ) +static MACHINE_CONFIG_START( lockload, deco32_state ) /* basic machine hardware */ MCFG_CPU_ADD("maincpu", ARM, 28000000/4) @@ -1902,7 +1902,7 @@ static MACHINE_CONFIG_START( lockload, driver_device ) MCFG_SOUND_ROUTE(ALL_OUTPUTS, "rspeaker", 1.0) MACHINE_CONFIG_END -static MACHINE_CONFIG_START( tattass, driver_device ) +static MACHINE_CONFIG_START( tattass, deco32_state ) /* basic machine hardware */ MCFG_CPU_ADD("maincpu", ARM, 28000000/4) /* Unconfirmed */ @@ -1939,7 +1939,7 @@ static MACHINE_CONFIG_START( tattass, driver_device ) MCFG_SOUND_ROUTE(1, "rspeaker", 1.0) MACHINE_CONFIG_END -static MACHINE_CONFIG_START( nslasher, driver_device ) +static MACHINE_CONFIG_START( nslasher, deco32_state ) /* basic machine hardware */ MCFG_CPU_ADD("maincpu", ARM, 28322000/4) diff --git a/src/mame/drivers/deco_ld.c b/src/mame/drivers/deco_ld.c index 598948429fd..2d17efd097a 100644 --- a/src/mame/drivers/deco_ld.c +++ b/src/mame/drivers/deco_ld.c @@ -114,12 +114,13 @@ public: : driver_device(machine, config) { } UINT8 *videoram; + UINT8 vram_bank; + device_t *laserdisc; + UINT8 laserdisc_data; + int nmimask; }; -static UINT8 vram_bank; -static device_t *laserdisc; -static UINT8 laserdisc_data; static VIDEO_UPDATE( rblaster ) { @@ -135,7 +136,7 @@ static VIDEO_UPDATE( rblaster ) for (x=0;x<32;x++) { int tile = videoram[count]; - int colour = (vram_bank & 0x7); + int colour = (state->vram_bank & 0x7); drawgfx_opaque(bitmap,cliprect,gfx,tile,colour,0,0,x*8,y*8); count++; @@ -155,12 +156,14 @@ static WRITE8_HANDLER( rblaster_sound_w ) static WRITE8_HANDLER( rblaster_vram_bank_w ) { - vram_bank = data; + deco_ld_state *state = space->machine->driver_data(); + state->vram_bank = data; } static READ8_HANDLER( laserdisc_r ) { - UINT8 result = laserdisc_data_r(laserdisc); + deco_ld_state *state = space->machine->driver_data(); + UINT8 result = laserdisc_data_r(state->laserdisc); mame_printf_debug("laserdisc_r = %02X\n", result); return result; } @@ -168,7 +171,8 @@ static READ8_HANDLER( laserdisc_r ) static WRITE8_HANDLER( laserdisc_w ) { - laserdisc_data = data; + deco_ld_state *state = space->machine->driver_data(); + state->laserdisc_data = data; } static READ8_HANDLER( test_r ) @@ -229,11 +233,17 @@ static ADDRESS_MAP_START( rblaster_map, ADDRESS_SPACE_PROGRAM, 8 ) ADDRESS_MAP_END /* sound arrangement is pratically identical to Zero Target. */ -static int nmimask; -//static WRITE8_HANDLER( nmimask_w ) { nmimask = data & 0x80; } +#ifdef UNUSED_FUNCTION +static WRITE8_HANDLER( nmimask_w ) +{ + deco_ld_state *state = space->machine->driver_data(); + state->nmimask = data & 0x80; +} +#endif -static INTERRUPT_GEN ( sound_interrupt ) { if (!nmimask) cpu_set_input_line(device, INPUT_LINE_NMI, PULSE_LINE); } +static INTERRUPT_GEN ( sound_interrupt ) { + deco_ld_state *state = device->machine->driver_data(); if (!state->nmimask) cpu_set_input_line(device, INPUT_LINE_NMI, PULSE_LINE); } static ADDRESS_MAP_START( rblaster_sound_map, ADDRESS_SPACE_PROGRAM, 8 ) @@ -497,7 +507,8 @@ GFXDECODE_END static MACHINE_START( rblaster ) { - laserdisc = machine->device("laserdisc"); + deco_ld_state *state = machine->driver_data(); + state->laserdisc = machine->device("laserdisc"); } static MACHINE_CONFIG_START( rblaster, deco_ld_state ) diff --git a/src/mame/drivers/deco_mlc.c b/src/mame/drivers/deco_mlc.c index 4838381d300..751aa48ca59 100644 --- a/src/mame/drivers/deco_mlc.c +++ b/src/mame/drivers/deco_mlc.c @@ -104,11 +104,6 @@ #include "cpu/sh2/sh2.h" #include "includes/deco_mlc.h" -static UINT32 *mlc_ram, *irq_ram; -static timer_device *raster_irq_timer; -static int mainCpuIsArm; -static int mlc_raster_table[9][256]; -static UINT32 vbl_i; /***************************************************************************/ @@ -158,10 +153,11 @@ static WRITE32_HANDLER( avengrs_palette_w ) static READ32_HANDLER( decomlc_vbl_r ) { - vbl_i ^=0xffffffff; + deco_mlc_state *state = space->machine->driver_data(); + state->vbl_i ^=0xffffffff; //logerror("vbl r %08x\n", cpu_get_pc(space->cpu)); // Todo: Vblank probably in $10 - return vbl_i; + return state->vbl_i; } static READ32_HANDLER( mlc_scanline_r ) @@ -172,24 +168,25 @@ static READ32_HANDLER( mlc_scanline_r ) static TIMER_DEVICE_CALLBACK( interrupt_gen ) { + deco_mlc_state *state = timer.machine->driver_data(); // logerror("hit scanline IRQ %d (%08x)\n", machine->primary_screen->vpos(), info.i); - cputag_set_input_line(timer.machine, "maincpu", mainCpuIsArm ? ARM_IRQ_LINE : 1, HOLD_LINE); + cputag_set_input_line(timer.machine, "maincpu", state->mainCpuIsArm ? ARM_IRQ_LINE : 1, HOLD_LINE); } static WRITE32_HANDLER( mlc_irq_w ) { - static int lastScanline[9]={ 0, 0, 0, 0, 0, 0, 0, 0, 0 }; + deco_mlc_state *state = space->machine->driver_data(); int scanline=space->machine->primary_screen->vpos(); - irq_ram[offset]=data&0xffff; + state->irq_ram[offset]=data&0xffff; switch (offset*4) { case 0x10: /* IRQ ack. Value written doesn't matter */ - cputag_set_input_line(space->machine, "maincpu", mainCpuIsArm ? ARM_IRQ_LINE : 1, CLEAR_LINE); + cputag_set_input_line(space->machine, "maincpu", state->mainCpuIsArm ? ARM_IRQ_LINE : 1, CLEAR_LINE); return; case 0x14: /* Prepare scanline interrupt */ - raster_irq_timer->adjust(space->machine->primary_screen->time_until_pos(irq_ram[0x14/4])); - //logerror("prepare scanline to fire at %d (currently on %d)\n", irq_ram[0x14/4], space->machine->primary_screen->vpos()); + state->raster_irq_timer->adjust(space->machine->primary_screen->time_until_pos(state->irq_ram[0x14/4])); + //logerror("prepare scanline to fire at %d (currently on %d)\n", state->irq_ram[0x14/4], space->machine->primary_screen->vpos()); return; case 0x18: case 0x1c: @@ -203,17 +200,17 @@ static WRITE32_HANDLER( mlc_irq_w ) if (scanline > 255) scanline = 255; /* Update scanlines up to present line */ - while (lastScanline[offset-6]lastScanline[offset-6]mlc_raster_table[offset-6][state->lastScanline[offset-6]+1]=state->mlc_raster_table[offset-6][state->lastScanline[offset-6]]; + state->lastScanline[offset-6]++; } - if (lastScanline[offset-6] > scanline) - lastScanline[offset-6]=0; + if (state->lastScanline[offset-6] > scanline) + state->lastScanline[offset-6]=0; /* Set current scanline value */ - mlc_raster_table[offset-6][scanline]=data&0xffff; + state->mlc_raster_table[offset-6][scanline]=data&0xffff; break; default: @@ -230,7 +227,8 @@ static READ32_HANDLER(mlc_spriteram_r) static READ32_HANDLER(mlc_vram_r) { - return mlc_vram[offset]&0xffff; + deco_mlc_state *state = space->machine->driver_data(); + return state->mlc_vram[offset]&0xffff; } static READ32_HANDLER(stadhr96_prot_146_r) @@ -262,15 +260,15 @@ static READ32_HANDLER(stadhr96_prot_146_r) static ADDRESS_MAP_START( decomlc_map, ADDRESS_SPACE_PROGRAM, 32 ) AM_RANGE(0x0000000, 0x00fffff) AM_ROM AM_MIRROR(0xff000000) - AM_RANGE(0x0100000, 0x011ffff) AM_RAM AM_BASE(&mlc_ram) AM_MIRROR(0xff000000) + AM_RANGE(0x0100000, 0x011ffff) AM_RAM AM_BASE_MEMBER(deco_mlc_state, mlc_ram) AM_MIRROR(0xff000000) AM_RANGE(0x0200000, 0x020000f) AM_READNOP AM_MIRROR(0xff000000)/* IRQ control? */ AM_RANGE(0x0200070, 0x0200073) AM_READ(decomlc_vbl_r) AM_MIRROR(0xff000000) AM_RANGE(0x0200074, 0x0200077) AM_READ(mlc_scanline_r) AM_MIRROR(0xff000000) AM_RANGE(0x0200078, 0x020007f) AM_READ(test2_r) AM_MIRROR(0xff000000) - AM_RANGE(0x0200000, 0x020007f) AM_WRITE(mlc_irq_w) AM_BASE(&irq_ram) AM_MIRROR(0xff000000) - AM_RANGE(0x0200080, 0x02000ff) AM_RAM AM_BASE(&mlc_clip_ram) AM_MIRROR(0xff000000) + AM_RANGE(0x0200000, 0x020007f) AM_WRITE(mlc_irq_w) AM_BASE_MEMBER(deco_mlc_state, irq_ram) AM_MIRROR(0xff000000) + AM_RANGE(0x0200080, 0x02000ff) AM_RAM AM_BASE_MEMBER(deco_mlc_state, mlc_clip_ram) AM_MIRROR(0xff000000) AM_RANGE(0x0204000, 0x0206fff) AM_RAM_READ(mlc_spriteram_r) AM_BASE_SIZE_GENERIC(spriteram) AM_MIRROR(0xff000000) - AM_RANGE(0x0280000, 0x029ffff) AM_RAM_READ(mlc_vram_r) AM_BASE(&mlc_vram) AM_MIRROR(0xff000000) + AM_RANGE(0x0280000, 0x029ffff) AM_RAM_READ(mlc_vram_r) AM_BASE_MEMBER(deco_mlc_state, mlc_vram) AM_MIRROR(0xff000000) AM_RANGE(0x0300000, 0x0307fff) AM_RAM_WRITE(avengrs_palette_w) AM_BASE_GENERIC(paletteram) AM_MIRROR(0xff000000) AM_RANGE(0x0400000, 0x0400003) AM_READ_PORT("INPUTS") AM_MIRROR(0xff000000) AM_RANGE(0x0440000, 0x044001f) AM_READ(test3_r) AM_MIRROR(0xff000000) @@ -374,11 +372,12 @@ GFXDECODE_END static MACHINE_RESET( mlc ) { - vbl_i = 0xffffffff; - raster_irq_timer = machine->device("int_timer"); + deco_mlc_state *state = machine->driver_data(); + state->vbl_i = 0xffffffff; + state->raster_irq_timer = machine->device("int_timer"); } -static MACHINE_CONFIG_START( avengrgs, driver_device ) +static MACHINE_CONFIG_START( avengrgs, deco_mlc_state ) /* basic machine hardware */ MCFG_CPU_ADD("maincpu", SH2,42000000/2) /* 21 MHz clock confirmed on real board */ @@ -411,7 +410,7 @@ static MACHINE_CONFIG_START( avengrgs, driver_device ) MCFG_SOUND_ROUTE(1, "rspeaker", 1.0) MACHINE_CONFIG_END -static MACHINE_CONFIG_START( mlc, driver_device ) +static MACHINE_CONFIG_START( mlc, deco_mlc_state ) /* basic machine hardware */ MCFG_CPU_ADD("maincpu", ARM,42000000/6) /* 42 MHz -> 7MHz clock confirmed on real board */ @@ -725,7 +724,8 @@ static void descramble_sound( running_machine *machine ) static READ32_HANDLER( avengrgs_speedup_r ) { - UINT32 a=mlc_ram[0x89a0/4]; + deco_mlc_state *state = space->machine->driver_data(); + UINT32 a=state->mlc_ram[0x89a0/4]; UINT32 p=cpu_get_pc(space->cpu); if ((p==0x3234 || p==0x32dc) && (a&1)) cpu_spinuntil_int(space->cpu); @@ -735,6 +735,7 @@ static READ32_HANDLER( avengrgs_speedup_r ) static DRIVER_INIT( avengrgs ) { + deco_mlc_state *state = machine->driver_data(); // init options sh2drc_set_options(machine->device("maincpu"), SH2DRC_FASTEST_OPTIONS); @@ -742,18 +743,19 @@ static DRIVER_INIT( avengrgs ) sh2drc_add_pcflush(machine->device("maincpu"), 0x3234); sh2drc_add_pcflush(machine->device("maincpu"), 0x32dc); - mainCpuIsArm = 0; + state->mainCpuIsArm = 0; memory_install_read32_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0x01089a0, 0x01089a3, 0, 0, avengrgs_speedup_r ); descramble_sound(machine); } static DRIVER_INIT( mlc ) { + deco_mlc_state *state = machine->driver_data(); /* The timing in the ARM core isn't as accurate as it should be, so bump up the effective clock rate here to compensate otherwise we have slowdowns in Skull Fung where there probably shouldn't be. */ machine->device("maincpu")->set_clock_scale(2.0f); - mainCpuIsArm = 1; + state->mainCpuIsArm = 1; deco156_decrypt(machine); descramble_sound(machine); } diff --git a/src/mame/drivers/deshoros.c b/src/mame/drivers/deshoros.c index 23c4013e1fb..251c00a8d27 100644 --- a/src/mame/drivers/deshoros.c +++ b/src/mame/drivers/deshoros.c @@ -15,86 +15,101 @@ TODO: #include "emu.h" #include "cpu/m6809/m6809.h" -static UINT8 *io_ram; + +class deshoros_state : public driver_device +{ +public: + deshoros_state(running_machine &machine, const driver_device_config_base &config) + : driver_device(machine, config) { } + + UINT8 *io_ram; + char led_array[21]; + UINT8 bank; +}; + + /*Temporary,to show something on screen...*/ -static char led_array[21]; static VIDEO_START( deshoros ) { - static UINT8 i; + deshoros_state *state = machine->driver_data(); + UINT8 i; for(i=0;i<20;i++) - led_array[i] = 0x20; - led_array[20] = 0; + state->led_array[i] = 0x20; + state->led_array[20] = 0; } static VIDEO_UPDATE( deshoros ) { - popmessage("%s",led_array); + deshoros_state *state = screen->machine->driver_data(); + popmessage("%s",state->led_array); return 0; } /*I don't know it this is 100% correct,might be different...*/ -static void update_led_array(UINT8 new_data) +static void update_led_array(deshoros_state *state, UINT8 new_data) { - static UINT8 i; + UINT8 i; /*scroll the data*/ for(i=0;i<19;i++) - led_array[i] = led_array[i+1]; + state->led_array[i] = state->led_array[i+1]; /*update the data*/ - led_array[19] = new_data; + state->led_array[19] = new_data; } -static UINT8 bank; static void answer_bankswitch(running_machine *machine,UINT8 new_bank) { - if(bank!=new_bank) + deshoros_state *state = machine->driver_data(); + if(state->bank!=new_bank) { UINT8 *ROM = machine->region("data")->base(); UINT32 bankaddress; - bank = new_bank; - bankaddress = 0 + 0x6000 * bank; + state->bank = new_bank; + bankaddress = 0 + 0x6000 * state->bank; memory_set_bankptr(machine, "bank1", &ROM[bankaddress]); } } static READ8_HANDLER( io_r ) { + deshoros_state *state = space->machine->driver_data(); switch(offset) { case 0x00: return 0xff; //printer read case 0x03: return input_port_read(space->machine, "KEY0" ); case 0x04: return input_port_read(space->machine, "KEY1" ); case 0x05: return input_port_read(space->machine, "SYSTEM" ); - case 0x0a: return io_ram[offset]; //"buzzer" 0 read - case 0x0b: return io_ram[offset]; //"buzzer" 1 read + case 0x0a: return state->io_ram[offset]; //"buzzer" 0 read + case 0x0b: return state->io_ram[offset]; //"buzzer" 1 read } // printf("R -> [%02x]\n",offset); - return io_ram[offset]; + return state->io_ram[offset]; } static WRITE8_HANDLER( io_w ) { + deshoros_state *state = space->machine->driver_data(); switch(offset) { case 0x00: /*Printer data*/ return; - case 0x02: update_led_array(data); return; - case 0x05: coin_lockout_w(space->machine, 0,io_ram[offset] & 1);return; + case 0x02: update_led_array(state, data); return; + case 0x05: coin_lockout_w(space->machine, 0,state->io_ram[offset] & 1);return; case 0x06: /*Printer IRQ enable*/ return; // case 0x0a: "buzzer" 0 write // case 0x0b: "buzzer" 1 write case 0x0c: answer_bankswitch(space->machine,data&0x03); return; //data & 0x10 enabled too,dunno if it is worth to shift the data... } - io_ram[offset] = data; + state->io_ram[offset] = data; // printf("%02x -> [%02x]\n",data,offset); } static ADDRESS_MAP_START( main_map, ADDRESS_SPACE_PROGRAM, 8 ) AM_RANGE(0x0000, 0x5fff) AM_ROMBANK("bank1") AM_RANGE(0x8000, 0x87ff) AM_RAM - AM_RANGE(0x9000, 0x900f) AM_READWRITE(io_r,io_w) AM_BASE(&io_ram) //i/o area + AM_RANGE(0x9000, 0x900f) AM_READWRITE(io_r,io_w) AM_BASE_MEMBER(deshoros_state, io_ram) //i/o area AM_RANGE(0xc000, 0xffff) AM_ROM ADDRESS_MAP_END @@ -151,10 +166,11 @@ static INTERRUPT_GEN( deshoros_irq ) static MACHINE_RESET( deshoros ) { - bank = -1; + deshoros_state *state = machine->driver_data(); + state->bank = -1; } -static MACHINE_CONFIG_START( deshoros, driver_device ) +static MACHINE_CONFIG_START( deshoros, deshoros_state ) /* basic machine hardware */ MCFG_CPU_ADD("maincpu",M6809,2000000) diff --git a/src/mame/drivers/dlair.c b/src/mame/drivers/dlair.c index 2290282c147..ca6b40d3780 100644 --- a/src/mame/drivers/dlair.c +++ b/src/mame/drivers/dlair.c @@ -51,6 +51,10 @@ public: : driver_device(machine, config) { } UINT8 *videoram; + laserdisc_device *laserdisc; + UINT8 last_misc; + UINT8 laserdisc_type; + UINT8 laserdisc_data; }; @@ -76,11 +80,7 @@ public: * *************************************/ -static laserdisc_device *laserdisc; -static UINT8 last_misc; -static UINT8 laserdisc_type; -static UINT8 laserdisc_data; static const UINT8 led_map[16] = { 0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7c,0x07,0x7f,0x67,0x77,0x7c,0x39,0x5e,0x79,0x00 }; @@ -101,15 +101,17 @@ static void dleuro_interrupt(device_t *device, int state) static WRITE8_DEVICE_HANDLER( serial_transmit ) { - laserdisc_data_w(laserdisc, data); + dlair_state *state = device->machine->driver_data(); + laserdisc_data_w(state->laserdisc, data); } static int serial_receive(device_t *device, int channel) { + dlair_state *state = device->machine->driver_data(); /* if we still have data to send, do it now */ - if (channel == 0 && laserdisc_line_r(laserdisc, LASERDISC_LINE_DATA_AVAIL) == ASSERT_LINE) - return laserdisc_data_r(laserdisc); + if (channel == 0 && laserdisc_line_r(state->laserdisc, LASERDISC_LINE_DATA_AVAIL) == ASSERT_LINE) + return laserdisc_data_r(state->laserdisc); return -1; } @@ -197,17 +199,19 @@ static VIDEO_UPDATE( dleuro ) static MACHINE_START( dlair ) { - laserdisc = machine->device("laserdisc"); + dlair_state *state = machine->driver_data(); + state->laserdisc = machine->device("laserdisc"); } static MACHINE_RESET( dlair ) { + dlair_state *state = machine->driver_data(); /* determine the laserdisc player from the DIP switches */ - if (laserdisc_type == LASERDISC_TYPE_VARIABLE) + if (state->laserdisc_type == LASERDISC_TYPE_VARIABLE) { int newtype = (input_port_read(machine, "DSW2") & 0x08) ? LASERDISC_TYPE_PIONEER_LDV1000 : LASERDISC_TYPE_PIONEER_PR7820; - laserdisc_set_type(laserdisc, newtype); + laserdisc_set_type(state->laserdisc, newtype); } } @@ -241,6 +245,7 @@ static INTERRUPT_GEN( vblank_callback ) static WRITE8_HANDLER( misc_w ) { + dlair_state *state = space->machine->driver_data(); /* D0-D3 = B0-B3 D4 = coin counter @@ -248,22 +253,23 @@ static WRITE8_HANDLER( misc_w ) D6 = ENTER D7 = INT/EXT */ - UINT8 diff = data ^ last_misc; - last_misc = data; + UINT8 diff = data ^ state->last_misc; + state->last_misc = data; coin_counter_w(space->machine, 0, (~data >> 4) & 1); /* on bit 5 going low, push the data out to the laserdisc player */ if ((diff & 0x20) && !(data & 0x20)) - laserdisc_data_w(laserdisc, laserdisc_data); + laserdisc_data_w(state->laserdisc, state->laserdisc_data); /* on bit 6 going low, we need to signal enter */ - laserdisc_line_w(laserdisc, LASERDISC_LINE_ENTER, (data & 0x40) ? CLEAR_LINE : ASSERT_LINE); + laserdisc_line_w(state->laserdisc, LASERDISC_LINE_ENTER, (data & 0x40) ? CLEAR_LINE : ASSERT_LINE); } static WRITE8_HANDLER( dleuro_misc_w ) { + dlair_state *state = space->machine->driver_data(); /* D0 = CHAR GEN ON+ D1 = KILL VIDEO+ @@ -274,18 +280,18 @@ static WRITE8_HANDLER( dleuro_misc_w ) D6 = ENTER D7 = INT/EXT */ - UINT8 diff = data ^ last_misc; - last_misc = data; + UINT8 diff = data ^ state->last_misc; + state->last_misc = data; coin_counter_w(space->machine, 1, (~data >> 3) & 1); coin_counter_w(space->machine, 0, (~data >> 4) & 1); /* on bit 5 going low, push the data out to the laserdisc player */ if ((diff & 0x20) && !(data & 0x20)) - laserdisc_data_w(laserdisc, laserdisc_data); + laserdisc_data_w(state->laserdisc, state->laserdisc_data); /* on bit 6 going low, we need to signal enter */ - laserdisc_line_w(laserdisc, LASERDISC_LINE_ENTER, (data & 0x40) ? CLEAR_LINE : ASSERT_LINE); + laserdisc_line_w(state->laserdisc, LASERDISC_LINE_ENTER, (data & 0x40) ? CLEAR_LINE : ASSERT_LINE); } @@ -310,13 +316,14 @@ static WRITE8_HANDLER( led_den2_w ) static CUSTOM_INPUT( laserdisc_status_r ) { - switch (laserdisc_get_type(laserdisc)) + dlair_state *state = field->port->machine->driver_data(); + switch (laserdisc_get_type(state->laserdisc)) { case LASERDISC_TYPE_PIONEER_PR7820: return 0; case LASERDISC_TYPE_PIONEER_LDV1000: - return (laserdisc_line_r(laserdisc, LASERDISC_LINE_STATUS) == ASSERT_LINE) ? 0 : 1; + return (laserdisc_line_r(state->laserdisc, LASERDISC_LINE_STATUS) == ASSERT_LINE) ? 0 : 1; case LASERDISC_TYPE_PHILLIPS_22VP932: return 0; @@ -327,13 +334,14 @@ static CUSTOM_INPUT( laserdisc_status_r ) static CUSTOM_INPUT( laserdisc_command_r ) { - switch (laserdisc_get_type(laserdisc)) + dlair_state *state = field->port->machine->driver_data(); + switch (laserdisc_get_type(state->laserdisc)) { case LASERDISC_TYPE_PIONEER_PR7820: - return (laserdisc_line_r(laserdisc, LASERDISC_LINE_READY) == ASSERT_LINE) ? 0 : 1; + return (laserdisc_line_r(state->laserdisc, LASERDISC_LINE_READY) == ASSERT_LINE) ? 0 : 1; case LASERDISC_TYPE_PIONEER_LDV1000: - return (laserdisc_line_r(laserdisc, LASERDISC_LINE_COMMAND) == ASSERT_LINE) ? 0 : 1; + return (laserdisc_line_r(state->laserdisc, LASERDISC_LINE_COMMAND) == ASSERT_LINE) ? 0 : 1; case LASERDISC_TYPE_PHILLIPS_22VP932: return 0; @@ -344,7 +352,8 @@ static CUSTOM_INPUT( laserdisc_command_r ) static READ8_HANDLER( laserdisc_r ) { - UINT8 result = laserdisc_data_r(laserdisc); + dlair_state *state = space->machine->driver_data(); + UINT8 result = laserdisc_data_r(state->laserdisc); mame_printf_debug("laserdisc_r = %02X\n", result); return result; } @@ -352,7 +361,8 @@ static READ8_HANDLER( laserdisc_r ) static WRITE8_HANDLER( laserdisc_w ) { - laserdisc_data = data; + dlair_state *state = space->machine->driver_data(); + state->laserdisc_data = data; } @@ -939,13 +949,15 @@ ROM_END static DRIVER_INIT( fixed ) { - laserdisc_type = LASERDISC_TYPE_FIXED; + dlair_state *state = machine->driver_data(); + state->laserdisc_type = LASERDISC_TYPE_FIXED; } static DRIVER_INIT( variable ) { - laserdisc_type = LASERDISC_TYPE_VARIABLE; + dlair_state *state = machine->driver_data(); + state->laserdisc_type = LASERDISC_TYPE_VARIABLE; } diff --git a/src/mame/drivers/koftball.c b/src/mame/drivers/koftball.c index 7285b191ce7..c3cb04f1686 100644 --- a/src/mame/drivers/koftball.c +++ b/src/mame/drivers/koftball.c @@ -34,14 +34,27 @@ ft5_v6_c4.u58 / #include "sound/okim6295.h" -static UINT16 *bmc_1_videoram, *bmc_2_videoram,*main_ram; -static tilemap_t *tilemap_1,*tilemap_2; -static UINT8 *bmc_colorram; -static int clr_offset=0; +class koftball_state : public driver_device +{ +public: + koftball_state(running_machine &machine, const driver_device_config_base &config) + : driver_device(machine, config) { } + + UINT16 *bmc_1_videoram; + UINT16 *bmc_2_videoram; + UINT16 *main_ram; + tilemap_t *tilemap_1; + tilemap_t *tilemap_2; + UINT8 *bmc_colorram; + int clr_offset; + UINT16 prot_data; +}; + static TILE_GET_INFO( get_t1_tile_info ) { - int data = bmc_1_videoram[tile_index]; + koftball_state *state = machine->driver_data(); + int data = state->bmc_1_videoram[tile_index]; SET_TILE_INFO( 0, data, @@ -51,7 +64,8 @@ static TILE_GET_INFO( get_t1_tile_info ) static TILE_GET_INFO( get_t2_tile_info ) { - int data = bmc_2_videoram[tile_index]; + koftball_state *state = machine->driver_data(); + int data = state->bmc_2_videoram[tile_index]; SET_TILE_INFO( 0, data, @@ -61,34 +75,39 @@ static TILE_GET_INFO( get_t2_tile_info ) static VIDEO_START( koftball ) { - tilemap_1 = tilemap_create(machine, get_t1_tile_info,tilemap_scan_rows,8,8,64,32); - tilemap_2 = tilemap_create(machine, get_t2_tile_info,tilemap_scan_rows,8,8,64,32); + koftball_state *state = machine->driver_data(); + state->tilemap_1 = tilemap_create(machine, get_t1_tile_info,tilemap_scan_rows,8,8,64,32); + state->tilemap_2 = tilemap_create(machine, get_t2_tile_info,tilemap_scan_rows,8,8,64,32); - tilemap_set_transparent_pen(tilemap_1,0); + tilemap_set_transparent_pen(state->tilemap_1,0); } static VIDEO_UPDATE( koftball ) { - tilemap_draw( bitmap, cliprect, tilemap_2, 0, 0); - tilemap_draw( bitmap, cliprect, tilemap_1, 0, 0); + koftball_state *state = screen->machine->driver_data(); + tilemap_draw( bitmap, cliprect, state->tilemap_2, 0, 0); + tilemap_draw( bitmap, cliprect, state->tilemap_1, 0, 0); return 0; } static WRITE16_HANDLER( bmc_RAMDAC_offset_w ) { - clr_offset=data*3; + koftball_state *state = space->machine->driver_data(); + state->clr_offset=data*3; } static WRITE16_HANDLER( bmc_RAMDAC_color_w ) { - bmc_colorram[clr_offset]=data; - palette_set_color_rgb(space->machine,clr_offset/3,pal6bit(bmc_colorram[(clr_offset/3)*3]),pal6bit(bmc_colorram[(clr_offset/3)*3+1]),pal6bit(bmc_colorram[(clr_offset/3)*3+2])); - clr_offset=(clr_offset+1)%768; + koftball_state *state = space->machine->driver_data(); + state->bmc_colorram[state->clr_offset]=data; + palette_set_color_rgb(space->machine,state->clr_offset/3,pal6bit(state->bmc_colorram[(state->clr_offset/3)*3]),pal6bit(state->bmc_colorram[(state->clr_offset/3)*3+1]),pal6bit(state->bmc_colorram[(state->clr_offset/3)*3+2])); + state->clr_offset=(state->clr_offset+1)%768; } static READ16_HANDLER( bmc_RAMDAC_color_r ) { - return bmc_colorram[clr_offset]; + koftball_state *state = space->machine->driver_data(); + return state->bmc_colorram[state->clr_offset]; } static READ16_HANDLER(random_number_r) @@ -96,11 +115,11 @@ static READ16_HANDLER(random_number_r) return space->machine->rand(); } -static UINT16 prot_data; static READ16_HANDLER(prot_r) { - switch(prot_data) + koftball_state *state = space->machine->driver_data(); + switch(state->prot_data) { case 0x0000: return 0x0d00; case 0xff00: return 0x8d00; @@ -108,33 +127,36 @@ static READ16_HANDLER(prot_r) case 0x8000: return 0x0f0f; } - logerror("unk prot r %x %x\n",prot_data, cpu_get_previouspc(space->cpu)); + logerror("unk prot r %x %x\n",state->prot_data, cpu_get_previouspc(space->cpu)); return space->machine->rand(); } static WRITE16_HANDLER(prot_w) { - COMBINE_DATA(&prot_data); + koftball_state *state = space->machine->driver_data(); + COMBINE_DATA(&state->prot_data); } static WRITE16_HANDLER(bmc_1_videoram_w) { - COMBINE_DATA(&bmc_1_videoram[offset]); - tilemap_mark_tile_dirty(tilemap_1, offset); + koftball_state *state = space->machine->driver_data(); + COMBINE_DATA(&state->bmc_1_videoram[offset]); + tilemap_mark_tile_dirty(state->tilemap_1, offset); } static WRITE16_HANDLER(bmc_2_videoram_w) { - COMBINE_DATA(&bmc_2_videoram[offset]); - tilemap_mark_tile_dirty(tilemap_2, offset); + koftball_state *state = space->machine->driver_data(); + COMBINE_DATA(&state->bmc_2_videoram[offset]); + tilemap_mark_tile_dirty(state->tilemap_2, offset); } static ADDRESS_MAP_START( koftball_mem, ADDRESS_SPACE_PROGRAM, 16 ) AM_RANGE(0x000000, 0x01ffff) AM_ROM - AM_RANGE(0x220000, 0x22ffff) AM_RAM AM_BASE(&main_ram) + AM_RANGE(0x220000, 0x22ffff) AM_RAM AM_BASE_MEMBER(koftball_state, main_ram) - AM_RANGE(0x260000, 0x260fff) AM_WRITE(bmc_1_videoram_w) AM_BASE(&bmc_1_videoram) - AM_RANGE(0x261000, 0x261fff) AM_WRITE(bmc_2_videoram_w) AM_BASE(&bmc_2_videoram) + AM_RANGE(0x260000, 0x260fff) AM_WRITE(bmc_1_videoram_w) AM_BASE_MEMBER(koftball_state, bmc_1_videoram) + AM_RANGE(0x261000, 0x261fff) AM_WRITE(bmc_2_videoram_w) AM_BASE_MEMBER(koftball_state, bmc_2_videoram) AM_RANGE(0x262000, 0x26ffff) AM_RAM AM_RANGE(0x280000, 0x28ffff) AM_RAM /* unused ? */ @@ -202,7 +224,7 @@ static GFXDECODE_START( koftball ) GFXDECODE_END -static MACHINE_CONFIG_START( koftball, driver_device ) +static MACHINE_CONFIG_START( koftball, koftball_state ) MCFG_CPU_ADD("maincpu", M68000, 21477270/2 ) MCFG_CPU_PROGRAM_MAP(koftball_mem) MCFG_CPU_VBLANK_INT_HACK(bmc_interrupt,3) @@ -271,14 +293,15 @@ static const UINT16 nvram[]= #endif static DRIVER_INIT(koftball) { - bmc_colorram = auto_alloc_array(machine, UINT8, 768); + koftball_state *state = machine->driver_data(); + state->bmc_colorram = auto_alloc_array(machine, UINT8, 768); #if NVRAM_HACK { int offset=0; while(nvram[offset]!=0xffff) { - main_ram[offset]=nvram[offset]; + state->main_ram[offset]=nvram[offset]; ++offset; } } diff --git a/src/mame/drivers/madalien.c b/src/mame/drivers/madalien.c index b76f184336d..37d29a142b5 100644 --- a/src/mame/drivers/madalien.c +++ b/src/mame/drivers/madalien.c @@ -16,10 +16,6 @@ #define SOUND_CLOCK XTAL_4MHz -static UINT8 *shift_hi; -static UINT8 *shift_lo; - - static INPUT_CHANGED( coin_inserted ) { /* coin insertion causes an NMI */ @@ -36,13 +32,15 @@ INLINE UINT8 shift_common(running_machine *machine, UINT8 hi, UINT8 lo) static READ8_HANDLER( shift_r ) { - return shift_common(space->machine, *shift_hi, *shift_lo); + madalien_state *state = space->machine->driver_data(); + return shift_common(space->machine, *state->shift_hi, *state->shift_lo); } static READ8_HANDLER( shift_rev_r ) { - UINT8 hi = *shift_hi ^ 0x07; - UINT8 lo = BITSWAP8(*shift_lo,0,1,2,3,4,5,6,7); + madalien_state *state = space->machine->driver_data(); + UINT8 hi = *state->shift_hi ^ 0x07; + UINT8 lo = BITSWAP8(*state->shift_lo,0,1,2,3,4,5,6,7); UINT8 ret = shift_common(space->machine, hi, lo); @@ -83,22 +81,22 @@ static WRITE8_DEVICE_HANDLER( madalien_portB_w ) static ADDRESS_MAP_START( main_map, ADDRESS_SPACE_PROGRAM, 8 ) AM_RANGE(0x0000, 0x03ff) AM_RAM - AM_RANGE(0x6000, 0x63ff) AM_RAM_WRITE(madalien_videoram_w) AM_BASE(&madalien_videoram) + AM_RANGE(0x6000, 0x63ff) AM_RAM_WRITE(madalien_videoram_w) AM_BASE_MEMBER(madalien_state, videoram) AM_RANGE(0x6400, 0x67ff) AM_RAM - AM_RANGE(0x6800, 0x7fff) AM_RAM_WRITE(madalien_charram_w) AM_BASE(&madalien_charram) + AM_RANGE(0x6800, 0x7fff) AM_RAM_WRITE(madalien_charram_w) AM_BASE_MEMBER(madalien_state, charram) AM_RANGE(0x8000, 0x8000) AM_MIRROR(0x0ff0) AM_DEVWRITE("crtc", mc6845_address_w) AM_RANGE(0x8001, 0x8001) AM_MIRROR(0x0ff0) AM_DEVREADWRITE("crtc", mc6845_register_r, mc6845_register_w) - AM_RANGE(0x8004, 0x8004) AM_MIRROR(0x0ff0) AM_WRITEONLY AM_BASE(&madalien_video_control) + AM_RANGE(0x8004, 0x8004) AM_MIRROR(0x0ff0) AM_WRITEONLY AM_BASE_MEMBER(madalien_state, video_control) AM_RANGE(0x8005, 0x8005) AM_MIRROR(0x0ff0) AM_WRITE(madalien_output_w) AM_RANGE(0x8006, 0x8006) AM_MIRROR(0x0ff0) AM_READWRITE(soundlatch2_r, madalien_sound_command_w) - AM_RANGE(0x8008, 0x8008) AM_MIRROR(0x07f0) AM_RAM_READ(shift_r) AM_BASE(&shift_hi) - AM_RANGE(0x8009, 0x8009) AM_MIRROR(0x07f0) AM_RAM_READ(shift_rev_r) AM_BASE(&shift_lo) - AM_RANGE(0x800b, 0x800b) AM_MIRROR(0x07f0) AM_WRITEONLY AM_BASE(&madalien_video_flags) - AM_RANGE(0x800c, 0x800c) AM_MIRROR(0x07f0) AM_WRITEONLY AM_BASE(&madalien_headlight_pos) - AM_RANGE(0x800d, 0x800d) AM_MIRROR(0x07f0) AM_WRITEONLY AM_BASE(&madalien_edge1_pos) - AM_RANGE(0x800e, 0x800e) AM_MIRROR(0x07f0) AM_WRITEONLY AM_BASE(&madalien_edge2_pos) - AM_RANGE(0x800f, 0x800f) AM_MIRROR(0x07f0) AM_WRITEONLY AM_BASE(&madalien_scroll) + AM_RANGE(0x8008, 0x8008) AM_MIRROR(0x07f0) AM_RAM_READ(shift_r) AM_BASE_MEMBER(madalien_state, shift_hi) + AM_RANGE(0x8009, 0x8009) AM_MIRROR(0x07f0) AM_RAM_READ(shift_rev_r) AM_BASE_MEMBER(madalien_state, shift_lo) + AM_RANGE(0x800b, 0x800b) AM_MIRROR(0x07f0) AM_WRITEONLY AM_BASE_MEMBER(madalien_state, video_flags) + AM_RANGE(0x800c, 0x800c) AM_MIRROR(0x07f0) AM_WRITEONLY AM_BASE_MEMBER(madalien_state, headlight_pos) + AM_RANGE(0x800d, 0x800d) AM_MIRROR(0x07f0) AM_WRITEONLY AM_BASE_MEMBER(madalien_state, edge1_pos) + AM_RANGE(0x800e, 0x800e) AM_MIRROR(0x07f0) AM_WRITEONLY AM_BASE_MEMBER(madalien_state, edge2_pos) + AM_RANGE(0x800f, 0x800f) AM_MIRROR(0x07f0) AM_WRITEONLY AM_BASE_MEMBER(madalien_state, scroll) AM_RANGE(0x9000, 0x9000) AM_MIRROR(0x0ff0) AM_READ_PORT("PLAYER1") AM_RANGE(0x9001, 0x9001) AM_MIRROR(0x0ff0) AM_READ_PORT("DSW") @@ -172,7 +170,7 @@ static const ay8910_interface ay8910_config = }; -static MACHINE_CONFIG_START( madalien, driver_device ) +static MACHINE_CONFIG_START( madalien, madalien_state ) /* main CPU */ MCFG_CPU_ADD("maincpu", M6502, MADALIEN_MAIN_CLOCK / 8) /* 1324kHz */ diff --git a/src/mame/drivers/mitchell.c b/src/mame/drivers/mitchell.c index 47f4b482aea..a6e06a00b66 100644 --- a/src/mame/drivers/mitchell.c +++ b/src/mame/drivers/mitchell.c @@ -93,22 +93,20 @@ static const eeprom_interface eeprom_intf = "0111" /* erase command */ }; -static UINT8 *nvram; -static size_t nvram_size; - static NVRAM_HANDLER( mitchell ) { + mitchell_state *state = machine->driver_data(); if (read_or_write) { - if (nvram_size) /* Super Pang, Block Block */ - file->write(nvram,nvram_size); /* NVRAM */ + if (state->nvram_size) /* Super Pang, Block Block */ + file->write(state->nvram,state->nvram_size); /* NVRAM */ } else { if (file) { - if (nvram_size) /* Super Pang, Block Block */ - file->read(nvram,nvram_size); /* NVRAM */ + if (state->nvram_size) /* Super Pang, Block Block */ + file->read(state->nvram,state->nvram_size); /* NVRAM */ } } } @@ -2117,7 +2115,7 @@ static DRIVER_INIT( dokaben ) { mitchell_state *state = machine->driver_data(); state->input_type = 0; - nvram_size = 0; + state->nvram_size = 0; mgakuen2_decode(machine); configure_banks(machine); } @@ -2125,7 +2123,7 @@ static DRIVER_INIT( pang ) { mitchell_state *state = machine->driver_data(); state->input_type = 0; - nvram_size = 0; + state->nvram_size = 0; pang_decode(machine); configure_banks(machine); } @@ -2133,7 +2131,7 @@ static DRIVER_INIT( pangb ) { mitchell_state *state = machine->driver_data(); state->input_type = 0; - nvram_size = 0; + state->nvram_size = 0; bootleg_decode(machine); configure_banks(machine); } @@ -2141,7 +2139,7 @@ static DRIVER_INIT( cworld ) { mitchell_state *state = machine->driver_data(); state->input_type = 0; - nvram_size = 0; + state->nvram_size = 0; cworld_decode(machine); configure_banks(machine); } @@ -2149,7 +2147,7 @@ static DRIVER_INIT( hatena ) { mitchell_state *state = machine->driver_data(); state->input_type = 0; - nvram_size = 0; + state->nvram_size = 0; hatena_decode(machine); configure_banks(machine); } @@ -2157,8 +2155,8 @@ static DRIVER_INIT( spang ) { mitchell_state *state = machine->driver_data(); state->input_type = 3; - nvram_size = 0x80; - nvram = &machine->region("maincpu")->base()[0xe000]; /* NVRAM */ + state->nvram_size = 0x80; + state->nvram = &machine->region("maincpu")->base()[0xe000]; /* NVRAM */ spang_decode(machine); configure_banks(machine); } @@ -2167,8 +2165,8 @@ static DRIVER_INIT( spangbl ) { mitchell_state *state = machine->driver_data(); state->input_type = 3; - nvram_size = 0x80; - nvram = &machine->region("maincpu")->base()[0xe000]; /* NVRAM */ + state->nvram_size = 0x80; + state->nvram = &machine->region("maincpu")->base()[0xe000]; /* NVRAM */ bootleg_decode(machine); configure_banks(machine); } @@ -2177,8 +2175,8 @@ static DRIVER_INIT( spangj ) { mitchell_state *state = machine->driver_data(); state->input_type = 3; - nvram_size = 0x80; - nvram = &machine->region("maincpu")->base()[0xe000]; /* NVRAM */ + state->nvram_size = 0x80; + state->nvram = &machine->region("maincpu")->base()[0xe000]; /* NVRAM */ spangj_decode(machine); configure_banks(machine); } @@ -2186,8 +2184,8 @@ static DRIVER_INIT( sbbros ) { mitchell_state *state = machine->driver_data(); state->input_type = 3; - nvram_size = 0x80; - nvram = &machine->region("maincpu")->base()[0xe000]; /* NVRAM */ + state->nvram_size = 0x80; + state->nvram = &machine->region("maincpu")->base()[0xe000]; /* NVRAM */ sbbros_decode(machine); configure_banks(machine); } @@ -2195,7 +2193,7 @@ static DRIVER_INIT( qtono1 ) { mitchell_state *state = machine->driver_data(); state->input_type = 0; - nvram_size = 0; + state->nvram_size = 0; qtono1_decode(machine); configure_banks(machine); } @@ -2203,7 +2201,7 @@ static DRIVER_INIT( qsangoku ) { mitchell_state *state = machine->driver_data(); state->input_type = 0; - nvram_size = 0; + state->nvram_size = 0; qsangoku_decode(machine); configure_banks(machine); } @@ -2219,7 +2217,7 @@ static DRIVER_INIT( mgakuen2 ) { mitchell_state *state = machine->driver_data(); state->input_type = 1; - nvram_size = 0; + state->nvram_size = 0; mgakuen2_decode(machine); configure_banks(machine); } @@ -2227,7 +2225,7 @@ static DRIVER_INIT( pkladies ) { mitchell_state *state = machine->driver_data(); state->input_type = 1; - nvram_size = 0; + state->nvram_size = 0; mgakuen2_decode(machine); configure_banks(machine); } @@ -2235,7 +2233,7 @@ static DRIVER_INIT( pkladiesbl ) { mitchell_state *state = machine->driver_data(); state->input_type = 1; - nvram_size = 0; + state->nvram_size = 0; bootleg_decode(machine); configure_banks(machine); } @@ -2243,7 +2241,7 @@ static DRIVER_INIT( marukin ) { mitchell_state *state = machine->driver_data(); state->input_type = 1; - nvram_size = 0; + state->nvram_size = 0; marukin_decode(machine); configure_banks(machine); } @@ -2251,8 +2249,8 @@ static DRIVER_INIT( block ) { mitchell_state *state = machine->driver_data(); state->input_type = 2; - nvram_size = 0x80; - nvram = &machine->region("maincpu")->base()[0xff80]; /* NVRAM */ + state->nvram_size = 0x80; + state->nvram = &machine->region("maincpu")->base()[0xff80]; /* NVRAM */ block_decode(machine); configure_banks(machine); } @@ -2260,8 +2258,8 @@ static DRIVER_INIT( blockbl ) { mitchell_state *state = machine->driver_data(); state->input_type = 2; - nvram_size = 0x80; - nvram = &machine->region("maincpu")->base()[0xff80]; /* NVRAM */ + state->nvram_size = 0x80; + state->nvram = &machine->region("maincpu")->base()[0xff80]; /* NVRAM */ bootleg_decode(machine); configure_banks(machine); } diff --git a/src/mame/drivers/pcktgal.c b/src/mame/drivers/pcktgal.c index dc21dd034b7..8d5264c2a29 100644 --- a/src/mame/drivers/pcktgal.c +++ b/src/mame/drivers/pcktgal.c @@ -43,23 +43,23 @@ static WRITE8_HANDLER( pcktgal_sound_w ) cputag_set_input_line(space->machine, "audiocpu", INPUT_LINE_NMI, PULSE_LINE); } -static int msm5205next; static void pcktgal_adpcm_int(device_t *device) { - static int toggle; + pcktgal_state *state = device->machine->driver_data(); - msm5205_data_w(device,msm5205next >> 4); - msm5205next<<=4; + msm5205_data_w(device,state->msm5205next >> 4); + state->msm5205next<<=4; - toggle = 1 - toggle; - if (toggle) + state->toggle = 1 - state->toggle; + if (state->toggle) cputag_set_input_line(device->machine, "audiocpu", M6502_IRQ_LINE, HOLD_LINE); } static WRITE8_HANDLER( pcktgal_adpcm_data_w ) { - msm5205next=data; + pcktgal_state *state = space->machine->driver_data(); + state->msm5205next=data; } static READ8_DEVICE_HANDLER( pcktgal_adpcm_reset_r ) diff --git a/src/mame/drivers/powerins.c b/src/mame/drivers/powerins.c index 994049e3f02..3e00e4d7226 100644 --- a/src/mame/drivers/powerins.c +++ b/src/mame/drivers/powerins.c @@ -43,18 +43,18 @@ TODO: ***************************************************************************/ -static int oki_bank; static WRITE16_HANDLER( powerins_okibank_w ) { + powerins_state *state = space->machine->driver_data(); if (ACCESSING_BITS_0_7) { UINT8 *RAM = space->machine->region("oki1")->base(); int new_bank = data & 0x7; - if (new_bank != oki_bank) + if (new_bank != state->oki_bank) { - oki_bank = new_bank; + state->oki_bank = new_bank; memcpy(&RAM[0x30000],&RAM[0x40000 + 0x10000*new_bank],0x10000); } } @@ -84,9 +84,9 @@ static ADDRESS_MAP_START( powerins_map, ADDRESS_SPACE_PROGRAM, 16 ) AM_RANGE(0x10001e, 0x10001f) AM_WRITE(powerins_soundlatch_w) // Sound Latch AM_RANGE(0x100030, 0x100031) AM_WRITE(powerins_okibank_w) // Sound AM_RANGE(0x120000, 0x120fff) AM_RAM_WRITE(powerins_paletteram16_w) AM_BASE_GENERIC(paletteram) // Palette - AM_RANGE(0x130000, 0x130007) AM_RAM AM_BASE(&powerins_vctrl_0) // VRAM 0 Control - AM_RANGE(0x140000, 0x143fff) AM_RAM_WRITE(powerins_vram_0_w) AM_BASE(&powerins_vram_0) // VRAM 0 - AM_RANGE(0x170000, 0x170fff) AM_RAM_WRITE(powerins_vram_1_w) AM_BASE(&powerins_vram_1) // VRAM 1 + AM_RANGE(0x130000, 0x130007) AM_RAM AM_BASE_MEMBER(powerins_state, vctrl_0) // VRAM 0 Control + AM_RANGE(0x140000, 0x143fff) AM_RAM_WRITE(powerins_vram_0_w) AM_BASE_MEMBER(powerins_state, vram_0) // VRAM 0 + AM_RANGE(0x170000, 0x170fff) AM_RAM_WRITE(powerins_vram_1_w) AM_BASE_MEMBER(powerins_state, vram_1) // VRAM 1 AM_RANGE(0x171000, 0x171fff) AM_WRITE(powerins_vram_1_w) // Mirror of VRAM 1? AM_RANGE(0x180000, 0x18ffff) AM_RAM AM_BASE_GENERIC(spriteram) // RAM + Sprites ADDRESS_MAP_END @@ -105,9 +105,9 @@ static ADDRESS_MAP_START( powerina_map, ADDRESS_SPACE_PROGRAM, 16 ) AM_RANGE(0x100030, 0x100031) AM_WRITE(powerins_okibank_w) // Sound AM_RANGE(0x10003e, 0x10003f) AM_DEVREADWRITE8_MODERN("oki1", okim6295_device, read, write, 0x00ff) // (used by powerina) AM_RANGE(0x120000, 0x120fff) AM_RAM_WRITE(powerins_paletteram16_w) AM_BASE_GENERIC(paletteram) // Palette - AM_RANGE(0x130000, 0x130007) AM_RAM AM_BASE(&powerins_vctrl_0) // VRAM 0 Control - AM_RANGE(0x140000, 0x143fff) AM_RAM_WRITE(powerins_vram_0_w) AM_BASE(&powerins_vram_0) // VRAM 0 - AM_RANGE(0x170000, 0x170fff) AM_RAM_WRITE(powerins_vram_1_w) AM_BASE(&powerins_vram_1) // VRAM 1 + AM_RANGE(0x130000, 0x130007) AM_RAM AM_BASE_MEMBER(powerins_state, vctrl_0) // VRAM 0 Control + AM_RANGE(0x140000, 0x143fff) AM_RAM_WRITE(powerins_vram_0_w) AM_BASE_MEMBER(powerins_state, vram_0) // VRAM 0 + AM_RANGE(0x170000, 0x170fff) AM_RAM_WRITE(powerins_vram_1_w) AM_BASE_MEMBER(powerins_state, vram_1) // VRAM 1 AM_RANGE(0x171000, 0x171fff) AM_WRITE(powerins_vram_1_w) // Mirror of VRAM 1? AM_RANGE(0x180000, 0x18ffff) AM_RAM AM_BASE_GENERIC(spriteram) // RAM + Sprites ADDRESS_MAP_END @@ -315,7 +315,8 @@ GFXDECODE_END static MACHINE_RESET( powerins ) { - oki_bank = -1; // samples bank "unitialised" + powerins_state *state = machine->driver_data(); + state->oki_bank = -1; // samples bank "unitialised" } static void irqhandler(device_t *device, int irq) @@ -339,7 +340,7 @@ static const nmk112_interface powerins_nmk112_intf = }; -static MACHINE_CONFIG_START( powerins, driver_device ) +static MACHINE_CONFIG_START( powerins, powerins_state ) /* basic machine hardware */ MCFG_CPU_ADD("maincpu", M68000, 12000000) /* 12MHz */ diff --git a/src/mame/drivers/progolf.c b/src/mame/drivers/progolf.c index 108c47efe85..2149e016aa3 100644 --- a/src/mame/drivers/progolf.c +++ b/src/mame/drivers/progolf.c @@ -63,25 +63,26 @@ public: : driver_device(machine, config) { } UINT8 *videoram; + UINT8 char_pen; + UINT8 char_pen_vreg; + UINT8 *fg_fb; + UINT8 *fbram; + UINT8 scrollx_hi; + UINT8 scrollx_lo; + UINT8 gfx_switch; + UINT8 sound_cmd; }; -static UINT8 char_pen,char_pen_vreg; -static UINT8 *progolf_fg_fb; -static UINT8 *progolf_fbram; -static UINT8 scrollx_hi; -static UINT8 scrollx_lo; -static UINT8 progolf_gfx_switch; -static UINT8 sound_cmd; static VIDEO_START( progolf ) { progolf_state *state = machine->driver_data(); - scrollx_hi = 0; - scrollx_lo = 0; + state->scrollx_hi = 0; + state->scrollx_lo = 0; - progolf_fg_fb = auto_alloc_array(machine, UINT8, 0x2000*8); + state->fg_fb = auto_alloc_array(machine, UINT8, 0x2000*8); state->videoram = auto_alloc_array(machine, UINT8, 0x1000); } @@ -93,7 +94,7 @@ static VIDEO_UPDATE( progolf ) int count,color,x,y,xi,yi; { - int scroll = (scrollx_lo | ((scrollx_hi & 0x03) << 8)); + int scroll = (state->scrollx_lo | ((state->scrollx_hi & 0x03) << 8)); count = 0; @@ -124,7 +125,7 @@ static VIDEO_UPDATE( progolf ) { for (xi=0;xi<8;xi++) { - color = progolf_fg_fb[(xi+yi*8)+count*0x40]; + color = state->fg_fb[(xi+yi*8)+count*0x40]; if((x+yi) <= cliprect->max_x && (256-y+xi) <= cliprect->max_y && color != 0) *BITMAP_ADDR16(bitmap, x+yi, 256-y+xi) = screen->machine->pens[(color & 0x7)]; @@ -141,41 +142,45 @@ static VIDEO_UPDATE( progolf ) static WRITE8_HANDLER( progolf_charram_w ) { + progolf_state *state = space->machine->driver_data(); int i; - progolf_fbram[offset] = data; + state->fbram[offset] = data; - if(char_pen == 7) + if(state->char_pen == 7) { for(i=0;i<8;i++) - progolf_fg_fb[offset*8+i] = 0; + state->fg_fb[offset*8+i] = 0; } else { for(i=0;i<8;i++) { - if(progolf_fg_fb[offset*8+i] == char_pen) - progolf_fg_fb[offset*8+i] = data & (1<<(7-i)) ? char_pen : 0; + if(state->fg_fb[offset*8+i] == state->char_pen) + state->fg_fb[offset*8+i] = data & (1<<(7-i)) ? state->char_pen : 0; else - progolf_fg_fb[offset*8+i] = data & (1<<(7-i)) ? progolf_fg_fb[offset*8+i]|char_pen : progolf_fg_fb[offset*8+i]; + state->fg_fb[offset*8+i] = data & (1<<(7-i)) ? state->fg_fb[offset*8+i]|state->char_pen : state->fg_fb[offset*8+i]; } } } static WRITE8_HANDLER( progolf_char_vregs_w ) { - char_pen = data & 0x07; - progolf_gfx_switch = data & 0xf0; - char_pen_vreg = data & 0x30; + progolf_state *state = space->machine->driver_data(); + state->char_pen = data & 0x07; + state->gfx_switch = data & 0xf0; + state->char_pen_vreg = data & 0x30; } static WRITE8_HANDLER( progolf_scrollx_lo_w ) { - scrollx_lo = data; + progolf_state *state = space->machine->driver_data(); + state->scrollx_lo = data; } static WRITE8_HANDLER( progolf_scrollx_hi_w ) { - scrollx_hi = data; + progolf_state *state = space->machine->driver_data(); + state->scrollx_hi = data; } static WRITE8_HANDLER( progolf_flip_screen_w ) @@ -187,14 +192,16 @@ static WRITE8_HANDLER( progolf_flip_screen_w ) static WRITE8_HANDLER( audio_command_w ) { - sound_cmd = data; + progolf_state *state = space->machine->driver_data(); + state->sound_cmd = data; cputag_set_input_line(space->machine, "audiocpu", 0, ASSERT_LINE); } static READ8_HANDLER( audio_command_r ) { + progolf_state *state = space->machine->driver_data(); cputag_set_input_line(space->machine, "audiocpu", 0, CLEAR_LINE); - return sound_cmd; + return state->sound_cmd; } static READ8_HANDLER( progolf_videoram_r ) @@ -205,20 +212,20 @@ static READ8_HANDLER( progolf_videoram_r ) if (offset >= 0x0800) { - if (progolf_gfx_switch == 0x50) + if (state->gfx_switch == 0x50) return gfx_rom[offset]; - else if (progolf_gfx_switch == 0x60) + else if (state->gfx_switch == 0x60) return gfx_rom[offset + 0x1000]; - else if (progolf_gfx_switch == 0x70) + else if (state->gfx_switch == 0x70) return gfx_rom[offset + 0x2000]; else return videoram[offset]; } else { - if (progolf_gfx_switch == 0x10) + if (state->gfx_switch == 0x10) return gfx_rom[offset]; - else if (progolf_gfx_switch == 0x20) + else if (state->gfx_switch == 0x20) return gfx_rom[offset + 0x1000]; - else if (progolf_gfx_switch == 0x30) + else if (state->gfx_switch == 0x30) return gfx_rom[offset + 0x2000]; else return videoram[offset]; @@ -229,13 +236,13 @@ static WRITE8_HANDLER( progolf_videoram_w ) { progolf_state *state = space->machine->driver_data(); UINT8 *videoram = state->videoram; - //if(progolf_gfx_switch & 0x40) + //if(state->gfx_switch & 0x40) videoram[offset] = data; } static ADDRESS_MAP_START( main_cpu, ADDRESS_SPACE_PROGRAM, 8 ) AM_RANGE(0x0000, 0x5fff) AM_RAM - AM_RANGE(0x6000, 0x7fff) AM_RAM_WRITE(progolf_charram_w) AM_BASE(&progolf_fbram) + AM_RANGE(0x6000, 0x7fff) AM_RAM_WRITE(progolf_charram_w) AM_BASE_MEMBER(progolf_state, fbram) AM_RANGE(0x8000, 0x8fff) AM_READWRITE(progolf_videoram_r,progolf_videoram_w) AM_RANGE(0x9000, 0x9000) AM_READ_PORT("IN2") AM_WRITE(progolf_char_vregs_w) AM_RANGE(0x9200, 0x9200) AM_READ_PORT("P1") AM_WRITE(progolf_scrollx_hi_w) //p1 inputs diff --git a/src/mame/drivers/rmhaihai.c b/src/mame/drivers/rmhaihai.c index e0b9bf8f5d0..6c2a61bac14 100644 --- a/src/mame/drivers/rmhaihai.c +++ b/src/mame/drivers/rmhaihai.c @@ -33,50 +33,66 @@ TODO: #include "sound/ay8910.h" #include "sound/msm5205.h" -static int gfxbank; -static UINT8 *videoram; -static UINT8 *colorram; -static tilemap_t *bg_tilemap; + +class rmhaihai_state : public driver_device +{ +public: + rmhaihai_state(running_machine &machine, const driver_device_config_base &config) + : driver_device(machine, config) { } + + int gfxbank; + UINT8 *videoram; + UINT8 *colorram; + tilemap_t *bg_tilemap; + int keyboard_cmd; +}; + + static WRITE8_HANDLER( rmhaihai_videoram_w ) { - videoram[offset] = data; - tilemap_mark_tile_dirty(bg_tilemap, offset); + rmhaihai_state *state = space->machine->driver_data(); + state->videoram[offset] = data; + tilemap_mark_tile_dirty(state->bg_tilemap, offset); } static WRITE8_HANDLER( rmhaihai_colorram_w ) { - colorram[offset] = data; - tilemap_mark_tile_dirty(bg_tilemap, offset); + rmhaihai_state *state = space->machine->driver_data(); + state->colorram[offset] = data; + tilemap_mark_tile_dirty(state->bg_tilemap, offset); } static TILE_GET_INFO( get_bg_tile_info ) { - int attr = colorram[tile_index]; - int code = videoram[tile_index] + (gfxbank << 12) + ((attr & 0x07) << 8) + ((attr & 0x80) << 4); - int color = (gfxbank << 5) + (attr >> 3); + rmhaihai_state *state = machine->driver_data(); + int attr = state->colorram[tile_index]; + int code = state->videoram[tile_index] + (state->gfxbank << 12) + ((attr & 0x07) << 8) + ((attr & 0x80) << 4); + int color = (state->gfxbank << 5) + (attr >> 3); SET_TILE_INFO(0, code, color, 0); } static VIDEO_START( rmhaihai ) { - bg_tilemap = tilemap_create(machine, get_bg_tile_info, tilemap_scan_rows, + rmhaihai_state *state = machine->driver_data(); + state->bg_tilemap = tilemap_create(machine, get_bg_tile_info, tilemap_scan_rows, 8, 8, 64, 32); } static VIDEO_UPDATE( rmhaihai ) { - tilemap_draw(bitmap, cliprect, bg_tilemap, 0, 0); + rmhaihai_state *state = screen->machine->driver_data(); + tilemap_draw(bitmap, cliprect, state->bg_tilemap, 0, 0); return 0; } -static int keyboard_cmd; static READ8_HANDLER( keyboard_r ) { + rmhaihai_state *state = space->machine->driver_data(); static const char *const keynames[] = { "KEY0", "KEY1" }; logerror("%04x: keyboard_r\n",cpu_get_pc(space->cpu)); @@ -100,24 +116,24 @@ static READ8_HANDLER( keyboard_r ) case 0x5c7b: // rmhaihai, rmhaisei, rmhaijin case 0x5950: // rmhaihib case 0x5bf3: // themj, but the test is NOPed out! - return 0xcc; /* keyboard_cmd = 0xcb */ + return 0xcc; /* state->keyboard_cmd = 0xcb */ case 0x13a: // additional checks done by rmhaijin - if (keyboard_cmd == 0x3b) return 0xdd; - if (keyboard_cmd == 0x85) return 0xdc; - if (keyboard_cmd == 0xf2) return 0xd6; - if (keyboard_cmd == 0xc1) return 0x8f; - if (keyboard_cmd == 0xd0) return 0x08; + if (state->keyboard_cmd == 0x3b) return 0xdd; + if (state->keyboard_cmd == 0x85) return 0xdc; + if (state->keyboard_cmd == 0xf2) return 0xd6; + if (state->keyboard_cmd == 0xc1) return 0x8f; + if (state->keyboard_cmd == 0xd0) return 0x08; return 0; case 0x140: // additional checks done by rmhaisei case 0x155: // additional checks done by themj, but they are patched out! - if (keyboard_cmd == 0x11) return 0x57; - if (keyboard_cmd == 0x3e) return 0xda; - if (keyboard_cmd == 0x48) return 0x74; - if (keyboard_cmd == 0x5d) return 0x46; - if (keyboard_cmd == 0xd0) return 0x08; + if (state->keyboard_cmd == 0x11) return 0x57; + if (state->keyboard_cmd == 0x3e) return 0xda; + if (state->keyboard_cmd == 0x48) return 0x74; + if (state->keyboard_cmd == 0x5d) return 0x46; + if (state->keyboard_cmd == 0xd0) return 0x08; return 0; } @@ -127,8 +143,9 @@ static READ8_HANDLER( keyboard_r ) static WRITE8_HANDLER( keyboard_w ) { + rmhaihai_state *state = space->machine->driver_data(); logerror("%04x: keyboard_w %02x\n",cpu_get_pc(space->cpu),data); - keyboard_cmd = data; + state->keyboard_cmd = data; } static READ8_HANDLER( samples_r ) @@ -145,6 +162,7 @@ static WRITE8_DEVICE_HANDLER( adpcm_w ) static WRITE8_HANDLER( ctrl_w ) { + rmhaihai_state *state = space->machine->driver_data(); flip_screen_set(space->machine, data & 0x01); // (data & 0x02) is switched on and off in service mode @@ -154,7 +172,7 @@ static WRITE8_HANDLER( ctrl_w ) // (data & 0x10) is medal in service mode - gfxbank = (data & 0x40) >> 6; /* rmhaisei only */ + state->gfxbank = (data & 0x40) >> 6; /* rmhaisei only */ } static WRITE8_HANDLER( themj_rombank_w ) @@ -176,8 +194,8 @@ static MACHINE_RESET( themj ) static ADDRESS_MAP_START( rmhaihai_map, ADDRESS_SPACE_PROGRAM, 8 ) AM_RANGE(0x0000, 0x9fff) AM_ROM AM_RANGE(0xa000, 0xa7ff) AM_RAM - AM_RANGE(0xa800, 0xafff) AM_RAM_WRITE(rmhaihai_colorram_w) AM_BASE(&colorram) - AM_RANGE(0xb000, 0xb7ff) AM_RAM_WRITE(rmhaihai_videoram_w) AM_BASE(&videoram) + AM_RANGE(0xa800, 0xafff) AM_RAM_WRITE(rmhaihai_colorram_w) AM_BASE_MEMBER(rmhaihai_state, colorram) + AM_RANGE(0xb000, 0xb7ff) AM_RAM_WRITE(rmhaihai_videoram_w) AM_BASE_MEMBER(rmhaihai_state, videoram) AM_RANGE(0xb83c, 0xb83c) AM_WRITENOP // ?? AM_RANGE(0xbc00, 0xbc00) AM_WRITENOP // ?? AM_RANGE(0xc000, 0xdfff) AM_ROM @@ -201,8 +219,8 @@ static ADDRESS_MAP_START( themj_map, ADDRESS_SPACE_PROGRAM, 8 ) AM_RANGE(0x0000, 0x7fff) AM_ROM AM_RANGE(0x8000, 0x9fff) AM_ROMBANK("bank1") AM_RANGE(0xa000, 0xa7ff) AM_RAM - AM_RANGE(0xa800, 0xafff) AM_RAM_WRITE(rmhaihai_colorram_w) AM_BASE(&colorram) - AM_RANGE(0xb000, 0xb7ff) AM_RAM_WRITE(rmhaihai_videoram_w) AM_BASE(&videoram) + AM_RANGE(0xa800, 0xafff) AM_RAM_WRITE(rmhaihai_colorram_w) AM_BASE_MEMBER(rmhaihai_state, colorram) + AM_RANGE(0xb000, 0xb7ff) AM_RAM_WRITE(rmhaihai_videoram_w) AM_BASE_MEMBER(rmhaihai_state, videoram) AM_RANGE(0xc000, 0xdfff) AM_ROMBANK("bank2") AM_RANGE(0xe000, 0xffff) AM_ROM ADDRESS_MAP_END @@ -437,7 +455,7 @@ static const msm5205_interface msm5205_config = -static MACHINE_CONFIG_START( rmhaihai, driver_device ) +static MACHINE_CONFIG_START( rmhaihai, rmhaihai_state ) /* basic machine hardware */ MCFG_CPU_ADD("maincpu",Z80,20000000/4) /* 5 MHz ??? */ diff --git a/src/mame/drivers/srumbler.c b/src/mame/drivers/srumbler.c index 0f1ccd01419..38a29d55b83 100644 --- a/src/mame/drivers/srumbler.c +++ b/src/mame/drivers/srumbler.c @@ -72,7 +72,7 @@ Ignore the warnings about writing to unmapped memory. static ADDRESS_MAP_START( srumbler_map, ADDRESS_SPACE_PROGRAM, 8 ) AM_RANGE(0x0000, 0x1dff) AM_RAM /* RAM (of 1 sort or another) */ AM_RANGE(0x1e00, 0x1fff) AM_RAM AM_BASE_SIZE_GENERIC(spriteram) - AM_RANGE(0x2000, 0x3fff) AM_RAM_WRITE(srumbler_background_w) AM_BASE(&srumbler_backgroundram) + AM_RANGE(0x2000, 0x3fff) AM_RAM_WRITE(srumbler_background_w) AM_BASE_MEMBER(srumbler_state, backgroundram) AM_RANGE(0x4008, 0x4008) AM_READ_PORT("SYSTEM") AM_WRITE(srumbler_bankswitch_w) AM_RANGE(0x4009, 0x4009) AM_READ_PORT("P1") AM_WRITE(srumbler_4009_w) AM_RANGE(0x400a, 0x400a) AM_READ_PORT("P2") @@ -80,7 +80,7 @@ static ADDRESS_MAP_START( srumbler_map, ADDRESS_SPACE_PROGRAM, 8 ) AM_RANGE(0x400c, 0x400c) AM_READ_PORT("DSW2") AM_RANGE(0x400a, 0x400d) AM_WRITE(srumbler_scroll_w) AM_RANGE(0x400e, 0x400e) AM_WRITE(soundlatch_w) - AM_RANGE(0x5000, 0x5fff) AM_ROMBANK("5000") AM_WRITE(srumbler_foreground_w) AM_BASE(&srumbler_foregroundram) /* Banked ROM */ + AM_RANGE(0x5000, 0x5fff) AM_ROMBANK("5000") AM_WRITE(srumbler_foreground_w) AM_BASE_MEMBER(srumbler_state, foregroundram) /* Banked ROM */ AM_RANGE(0x6000, 0x6fff) AM_ROMBANK("6000") /* Banked ROM */ AM_RANGE(0x6000, 0x6fff) AM_WRITENOP /* Video RAM 2 ??? (not used) */ AM_RANGE(0x7000, 0x7fff) AM_ROMBANK("7000") /* Banked ROM */ @@ -231,7 +231,7 @@ GFXDECODE_END -static MACHINE_CONFIG_START( srumbler, driver_device ) +static MACHINE_CONFIG_START( srumbler, srumbler_state ) /* basic machine hardware */ MCFG_CPU_ADD("maincpu", M6809, 1500000) /* 1.5 MHz (?) */ diff --git a/src/mame/drivers/sshangha.c b/src/mame/drivers/sshangha.c index 3d8a31833df..4df9bfde180 100644 --- a/src/mame/drivers/sshangha.c +++ b/src/mame/drivers/sshangha.c @@ -60,15 +60,14 @@ Stephh's notes (based on the games M68000 code and some tests) : #define SSHANGHA_HACK 0 -static UINT16 *sshangha_prot_data; -static UINT16 *sshangha_sound_shared_ram; /******************************************************************************/ static WRITE16_HANDLER( sshangha_protection16_w ) { - COMBINE_DATA(&sshangha_prot_data[offset]); + sshangha_state *state = space->machine->driver_data(); + COMBINE_DATA(&state->prot_data[offset]); logerror("CPU #0 PC %06x: warning - write unmapped control address %06x %04x\n",cpu_get_pc(space->cpu),offset<<1,data); } @@ -76,6 +75,7 @@ static WRITE16_HANDLER( sshangha_protection16_w ) /* Protection/IO chip 146 */ static READ16_HANDLER( sshangha_protection16_r ) { + sshangha_state *state = space->machine->driver_data(); switch (offset) { case 0x050 >> 1: @@ -89,11 +89,12 @@ static READ16_HANDLER( sshangha_protection16_r ) } logerror("CPU #0 PC %06x: warning - read unmapped control address %06x\n",cpu_get_pc(space->cpu),offset<<1); - return sshangha_prot_data[offset]; + return state->prot_data[offset]; } static READ16_HANDLER( sshanghb_protection16_r ) { + sshangha_state *state = space->machine->driver_data(); switch (offset) { case 0x050 >> 1: @@ -104,7 +105,7 @@ static READ16_HANDLER( sshanghb_protection16_r ) return input_port_read(space->machine, "DSW"); } - return sshangha_prot_data[offset]; + return state->prot_data[offset]; } /* Probably returns 0xffff when sprite DMA is complete, the game waits on it */ @@ -131,12 +132,12 @@ static MACHINE_RESET( sshangha ) static ADDRESS_MAP_START( sshangha_map, ADDRESS_SPACE_PROGRAM, 16 ) AM_RANGE(0x000000, 0x03ffff) AM_ROM - AM_RANGE(0x100000, 0x10000f) AM_RAM AM_BASE(&sshangha_sound_shared_ram) + AM_RANGE(0x100000, 0x10000f) AM_RAM AM_BASE_MEMBER(sshangha_state, sound_shared_ram) - AM_RANGE(0x200000, 0x201fff) AM_RAM_WRITE(sshangha_pf1_data_w) AM_BASE(&sshangha_pf1_data) - AM_RANGE(0x202000, 0x203fff) AM_RAM_WRITE(sshangha_pf2_data_w) AM_BASE(&sshangha_pf2_data) - AM_RANGE(0x204000, 0x2047ff) AM_RAM AM_BASE(&sshangha_pf1_rowscroll) - AM_RANGE(0x206000, 0x2067ff) AM_RAM AM_BASE(&sshangha_pf2_rowscroll) + AM_RANGE(0x200000, 0x201fff) AM_RAM_WRITE(sshangha_pf1_data_w) AM_BASE_MEMBER(sshangha_state, pf1_data) + AM_RANGE(0x202000, 0x203fff) AM_RAM_WRITE(sshangha_pf2_data_w) AM_BASE_MEMBER(sshangha_state, pf2_data) + AM_RANGE(0x204000, 0x2047ff) AM_RAM AM_BASE_MEMBER(sshangha_state, pf1_rowscroll) + AM_RANGE(0x206000, 0x2067ff) AM_RAM AM_BASE_MEMBER(sshangha_state, pf2_rowscroll) AM_RANGE(0x206800, 0x207fff) AM_RAM AM_RANGE(0x300000, 0x30000f) AM_WRITE(sshangha_control_0_w) AM_RANGE(0x320000, 0x320001) AM_WRITE(sshangha_video_w) @@ -152,18 +153,18 @@ static ADDRESS_MAP_START( sshangha_map, ADDRESS_SPACE_PROGRAM, 16 ) AM_RANGE(0x380000, 0x383fff) AM_RAM_WRITE(paletteram16_xbgr_word_be_w) AM_BASE_GENERIC(paletteram) AM_RANGE(0x3c0000, 0x3c0fff) AM_RAM /* Sprite ram buffer on bootleg only?? */ AM_RANGE(0xfec000, 0xff3fff) AM_RAM - AM_RANGE(0xff4000, 0xff47ff) AM_READWRITE(sshangha_protection16_r,sshangha_protection16_w) AM_BASE(&sshangha_prot_data) + AM_RANGE(0xff4000, 0xff47ff) AM_READWRITE(sshangha_protection16_r,sshangha_protection16_w) AM_BASE_MEMBER(sshangha_state, prot_data) ADDRESS_MAP_END static ADDRESS_MAP_START( sshanghb_map, ADDRESS_SPACE_PROGRAM, 16 ) AM_RANGE(0x000000, 0x03ffff) AM_ROM AM_RANGE(0x084000, 0x0847ff) AM_READ(sshanghb_protection16_r) - AM_RANGE(0x101000, 0x10100f) AM_RAM AM_BASE(&sshangha_sound_shared_ram) /* the bootleg writes here */ + AM_RANGE(0x101000, 0x10100f) AM_RAM AM_BASE_MEMBER(sshangha_state, sound_shared_ram) /* the bootleg writes here */ - AM_RANGE(0x200000, 0x201fff) AM_RAM_WRITE(sshangha_pf1_data_w) AM_BASE(&sshangha_pf1_data) - AM_RANGE(0x202000, 0x203fff) AM_RAM_WRITE(sshangha_pf2_data_w) AM_BASE(&sshangha_pf2_data) - AM_RANGE(0x204000, 0x2047ff) AM_RAM AM_BASE(&sshangha_pf1_rowscroll) - AM_RANGE(0x206000, 0x2067ff) AM_RAM AM_BASE(&sshangha_pf2_rowscroll) + AM_RANGE(0x200000, 0x201fff) AM_RAM_WRITE(sshangha_pf1_data_w) AM_BASE_MEMBER(sshangha_state, pf1_data) + AM_RANGE(0x202000, 0x203fff) AM_RAM_WRITE(sshangha_pf2_data_w) AM_BASE_MEMBER(sshangha_state, pf2_data) + AM_RANGE(0x204000, 0x2047ff) AM_RAM AM_BASE_MEMBER(sshangha_state, pf1_rowscroll) + AM_RANGE(0x206000, 0x2067ff) AM_RAM AM_BASE_MEMBER(sshangha_state, pf2_rowscroll) AM_RANGE(0x206800, 0x207fff) AM_RAM AM_RANGE(0x300000, 0x30000f) AM_WRITE(sshangha_control_0_w) AM_RANGE(0x320000, 0x320001) AM_WRITE(sshangha_video_w) @@ -188,12 +189,14 @@ ADDRESS_MAP_END static READ8_HANDLER(sshangha_sound_shared_r) { - return sshangha_sound_shared_ram[offset] & 0xff; + sshangha_state *state = space->machine->driver_data(); + return state->sound_shared_ram[offset] & 0xff; } static WRITE8_HANDLER(sshangha_sound_shared_w) { - sshangha_sound_shared_ram[offset] = data & 0xff; + sshangha_state *state = space->machine->driver_data(); + state->sound_shared_ram[offset] = data & 0xff; } /* Note: there's rom data after 0x8000 but the game never seem to call a rom bank, left-over? */ @@ -342,7 +345,7 @@ static const ym2203_interface ym2203_config = irqhandler }; -static MACHINE_CONFIG_START( sshangha, driver_device ) +static MACHINE_CONFIG_START( sshangha, sshangha_state ) /* basic machine hardware */ MCFG_CPU_ADD("maincpu", M68000, 28000000/2) diff --git a/src/mame/drivers/stadhero.c b/src/mame/drivers/stadhero.c index d7b5ef8cb06..5b2e058887e 100644 --- a/src/mame/drivers/stadhero.c +++ b/src/mame/drivers/stadhero.c @@ -55,9 +55,9 @@ static WRITE16_HANDLER( stadhero_control_w ) static ADDRESS_MAP_START( main_map, ADDRESS_SPACE_PROGRAM, 16 ) AM_RANGE(0x000000, 0x01ffff) AM_ROM - AM_RANGE(0x200000, 0x2007ff) AM_RAM_WRITE(stadhero_pf1_data_w) AM_BASE(&stadhero_pf1_data) - AM_RANGE(0x240000, 0x240007) AM_RAM AM_BASE(&stadhero_pf2_control_0) - AM_RANGE(0x240010, 0x240017) AM_WRITEONLY AM_BASE(&stadhero_pf2_control_1) + AM_RANGE(0x200000, 0x2007ff) AM_RAM_WRITE(stadhero_pf1_data_w) AM_BASE_MEMBER(stadhero_state, pf1_data) + AM_RANGE(0x240000, 0x240007) AM_RAM AM_BASE_MEMBER(stadhero_state, pf2_control_0) + AM_RANGE(0x240010, 0x240017) AM_WRITEONLY AM_BASE_MEMBER(stadhero_state, pf2_control_1) AM_RANGE(0x260000, 0x261fff) AM_READWRITE(stadhero_pf2_data_r, stadhero_pf2_data_w) AM_RANGE(0x30c000, 0x30c00b) AM_READWRITE(stadhero_control_r, stadhero_control_w) AM_RANGE(0x310000, 0x3107ff) AM_RAM_WRITE(paletteram16_xxxxBBBBGGGGRRRR_word_w) AM_BASE_GENERIC(paletteram) @@ -208,7 +208,7 @@ static const ym3812_interface ym3812_config = /******************************************************************************/ -static MACHINE_CONFIG_START( stadhero, driver_device ) +static MACHINE_CONFIG_START( stadhero, stadhero_state ) /* basic machine hardware */ MCFG_CPU_ADD("maincpu", M68000, 10000000) diff --git a/src/mame/drivers/tigeroad.c b/src/mame/drivers/tigeroad.c index d809c4bc0ef..906d2e6e846 100644 --- a/src/mame/drivers/tigeroad.c +++ b/src/mame/drivers/tigeroad.c @@ -27,7 +27,6 @@ Memory Overview: #include "includes/tigeroad.h" -static UINT16 *ram16; /* F1 Dream protection code written by Eric Hustvedt (hustvedt@ma.ultranet.com). @@ -82,6 +81,7 @@ static const int f1dream_2450_lookup[32] = { static void f1dream_protection_w(address_space *space) { + tigeroad_state *state = space->machine->driver_data(); int indx; int value = 255; int prevpc = cpu_get_previouspc(space->cpu); @@ -89,63 +89,64 @@ static void f1dream_protection_w(address_space *space) if (prevpc == 0x244c) { /* Called once, when a race is started.*/ - indx = ram16[0x3ff0/2]; - ram16[0x3fe6/2] = f1dream_2450_lookup[indx]; - ram16[0x3fe8/2] = f1dream_2450_lookup[++indx]; - ram16[0x3fea/2] = f1dream_2450_lookup[++indx]; - ram16[0x3fec/2] = f1dream_2450_lookup[++indx]; + indx = state->ram16[0x3ff0/2]; + state->ram16[0x3fe6/2] = f1dream_2450_lookup[indx]; + state->ram16[0x3fe8/2] = f1dream_2450_lookup[++indx]; + state->ram16[0x3fea/2] = f1dream_2450_lookup[++indx]; + state->ram16[0x3fec/2] = f1dream_2450_lookup[++indx]; } else if (prevpc == 0x613a) { /* Called for every sprite on-screen.*/ - if (ram16[0x3ff6/2] < 15) + if (state->ram16[0x3ff6/2] < 15) { - indx = f1dream_613ea_lookup[ram16[0x3ff6/2]] - ram16[0x3ff4/2]; + indx = f1dream_613ea_lookup[state->ram16[0x3ff6/2]] - state->ram16[0x3ff4/2]; if (indx > 255) { indx <<= 4; - indx += ram16[0x3ff6/2] & 0x00ff; + indx += state->ram16[0x3ff6/2] & 0x00ff; value = f1dream_613eb_lookup[indx]; } } - ram16[0x3ff2/2] = value; + state->ram16[0x3ff2/2] = value; } else if (prevpc == 0x17b70) { /* Called only before a real race, not a time trial.*/ - if (ram16[0x3ff0/2] >= 0x04) indx = 128; - else if (ram16[0x3ff0/2] > 0x02) indx = 96; - else if (ram16[0x3ff0/2] == 0x02) indx = 64; - else if (ram16[0x3ff0/2] == 0x01) indx = 32; + if (state->ram16[0x3ff0/2] >= 0x04) indx = 128; + else if (state->ram16[0x3ff0/2] > 0x02) indx = 96; + else if (state->ram16[0x3ff0/2] == 0x02) indx = 64; + else if (state->ram16[0x3ff0/2] == 0x01) indx = 32; else indx = 0; - indx += ram16[0x3fee/2]; + indx += state->ram16[0x3fee/2]; if (indx < 128) { - ram16[0x3fe6/2] = f1dream_17b74_lookup[indx]; - ram16[0x3fe8/2] = f1dream_17b74_lookup[++indx]; - ram16[0x3fea/2] = f1dream_17b74_lookup[++indx]; - ram16[0x3fec/2] = f1dream_17b74_lookup[++indx]; + state->ram16[0x3fe6/2] = f1dream_17b74_lookup[indx]; + state->ram16[0x3fe8/2] = f1dream_17b74_lookup[++indx]; + state->ram16[0x3fea/2] = f1dream_17b74_lookup[++indx]; + state->ram16[0x3fec/2] = f1dream_17b74_lookup[++indx]; } else { - ram16[0x3fe6/2] = 0x00ff; - ram16[0x3fe8/2] = 0x00ff; - ram16[0x3fea/2] = 0x00ff; - ram16[0x3fec/2] = 0x00ff; + state->ram16[0x3fe6/2] = 0x00ff; + state->ram16[0x3fe8/2] = 0x00ff; + state->ram16[0x3fea/2] = 0x00ff; + state->ram16[0x3fec/2] = 0x00ff; } } else if ((prevpc == 0x27f8) || (prevpc == 0x511a) || (prevpc == 0x5142) || (prevpc == 0x516a)) { /* The main CPU stuffs the byte for the soundlatch into 0xfffffd.*/ - soundlatch_w(space,2,ram16[0x3ffc/2]); + soundlatch_w(space,2,state->ram16[0x3ffc/2]); } } static WRITE16_HANDLER( f1dream_control_w ) { - logerror("protection write, PC: %04x FFE1 Value:%01x\n",cpu_get_pc(space->cpu), ram16[0x3fe0/2]); + tigeroad_state *state = space->machine->driver_data(); + logerror("protection write, PC: %04x FFE1 Value:%01x\n",cpu_get_pc(space->cpu), state->ram16[0x3fe0/2]); f1dream_protection_w(space); } @@ -178,7 +179,7 @@ static ADDRESS_MAP_START( main_map, ADDRESS_SPACE_PROGRAM, 16 ) AM_RANGE(0xfe8000, 0xfe8003) AM_WRITE(tigeroad_scroll_w) AM_RANGE(0xfe800e, 0xfe800f) AM_WRITEONLY /* fe800e = watchdog or IRQ acknowledge */ AM_RANGE(0xff8200, 0xff867f) AM_RAM_WRITE(paletteram16_xxxxRRRRGGGGBBBB_word_w) AM_BASE_GENERIC(paletteram) - AM_RANGE(0xffc000, 0xffffff) AM_RAM AM_BASE(&ram16) + AM_RANGE(0xffc000, 0xffffff) AM_RAM AM_BASE_MEMBER(tigeroad_state, ram16) ADDRESS_MAP_END diff --git a/src/mame/drivers/tryout.c b/src/mame/drivers/tryout.c index acba1c497cb..85da8e426ed 100644 --- a/src/mame/drivers/tryout.c +++ b/src/mame/drivers/tryout.c @@ -67,7 +67,7 @@ static ADDRESS_MAP_START( main_cpu, ADDRESS_SPACE_PROGRAM, 8 ) AM_RANGE(0xe301, 0xe301) AM_WRITE(tryout_flipscreen_w) AM_RANGE(0xe302, 0xe302) AM_WRITE(tryout_bankswitch_w) AM_RANGE(0xe401, 0xe401) AM_WRITE(tryout_vram_bankswitch_w) - AM_RANGE(0xe402, 0xe404) AM_WRITEONLY AM_BASE(&tryout_gfx_control) + AM_RANGE(0xe402, 0xe404) AM_WRITEONLY AM_BASE_MEMBER(tryout_state, gfx_control) AM_RANGE(0xe414, 0xe414) AM_WRITE(tryout_sound_w) AM_RANGE(0xe417, 0xe417) AM_WRITE(tryout_nmi_ack_w) AM_RANGE(0xfff0, 0xffff) AM_ROM AM_REGION("maincpu", 0xbff0) /* reset vectors */ diff --git a/src/mame/drivers/tumbleb.c b/src/mame/drivers/tumbleb.c index 11fd0bdafb2..4858c0109e0 100644 --- a/src/mame/drivers/tumbleb.c +++ b/src/mame/drivers/tumbleb.c @@ -888,8 +888,6 @@ static READ8_HANDLER( prot_io_r ) return 0x00; } -static UINT8 semicom_prot_offset = 0x00; -static UINT16 protbase = 0x0000; // probably not endian safe static WRITE8_HANDLER( prot_io_w ) @@ -900,25 +898,25 @@ static WRITE8_HANDLER( prot_io_w ) { case 0x00: { - UINT16 word = state->mainram[(protbase/2) + semicom_prot_offset]; + UINT16 word = state->mainram[(state->protbase/2) + state->semicom_prot_offset]; word = (word & 0xff00) | (data << 0); - state->mainram[(protbase/2) + semicom_prot_offset] = word; + state->mainram[(state->protbase/2) + state->semicom_prot_offset] = word; break; } case 0x01: { - UINT16 word = state->mainram[(protbase/2) + semicom_prot_offset]; + UINT16 word = state->mainram[(state->protbase/2) + state->semicom_prot_offset]; word = (word & 0x00ff) | (data << 8); - state->mainram[(protbase/2) + semicom_prot_offset] = word; + state->mainram[(state->protbase/2) + state->semicom_prot_offset] = word; break; } case 0x02: // offset { - semicom_prot_offset = data; + state->semicom_prot_offset = data; break; } @@ -3443,7 +3441,7 @@ static DRIVER_INIT( htchctch ) int i, len = machine->region("user1")->bytes(); /* simulate RAM initialization done by the protection MCU */ /* verified on real hardware */ -// static UINT16 htchctch_mcu68k[] = +// static const UINT16 htchctch_mcu68k[] = // { // /* moved to protdata.bin file .. */ // }; @@ -3744,18 +3742,20 @@ static DRIVER_INIT( chokchok ) static DRIVER_INIT( wlstar ) { + tumbleb_state *state = machine->driver_data(); tumblepb_gfx1_rearrange(machine); /* slightly different banking */ memory_install_write16_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0x100002, 0x100003, 0, 0, wlstar_tilebank_w); - protbase = 0x0000; + state->protbase = 0x0000; } static DRIVER_INIT( wondl96 ) { + tumbleb_state *state = machine->driver_data(); DRIVER_INIT_CALL( wlstar ); - protbase = 0x0200; + state->protbase = 0x0200; } static DRIVER_INIT ( dquizgo ) diff --git a/src/mame/drivers/vulgus.c b/src/mame/drivers/vulgus.c index ef1c3e43bae..390d1dad4bd 100644 --- a/src/mame/drivers/vulgus.c +++ b/src/mame/drivers/vulgus.c @@ -63,13 +63,13 @@ static ADDRESS_MAP_START( main_map, ADDRESS_SPACE_PROGRAM, 8 ) AM_RANGE(0xc003, 0xc003) AM_READ_PORT("DSW1") AM_RANGE(0xc004, 0xc004) AM_READ_PORT("DSW2") AM_RANGE(0xc800, 0xc800) AM_WRITE(soundlatch_w) - AM_RANGE(0xc802, 0xc803) AM_RAM AM_BASE(&vulgus_scroll_low) + AM_RANGE(0xc802, 0xc803) AM_RAM AM_BASE_MEMBER(vulgus_state, scroll_low) AM_RANGE(0xc804, 0xc804) AM_WRITE(vulgus_c804_w) AM_RANGE(0xc805, 0xc805) AM_WRITE(vulgus_palette_bank_w) - AM_RANGE(0xc902, 0xc903) AM_RAM AM_BASE(&vulgus_scroll_high) + AM_RANGE(0xc902, 0xc903) AM_RAM AM_BASE_MEMBER(vulgus_state, scroll_high) AM_RANGE(0xcc00, 0xcc7f) AM_RAM AM_BASE_SIZE_GENERIC(spriteram) - AM_RANGE(0xd000, 0xd7ff) AM_RAM_WRITE(vulgus_fgvideoram_w) AM_BASE(&vulgus_fgvideoram) - AM_RANGE(0xd800, 0xdfff) AM_RAM_WRITE(vulgus_bgvideoram_w) AM_BASE(&vulgus_bgvideoram) + AM_RANGE(0xd000, 0xd7ff) AM_RAM_WRITE(vulgus_fgvideoram_w) AM_BASE_MEMBER(vulgus_state, fgvideoram) + AM_RANGE(0xd800, 0xdfff) AM_RAM_WRITE(vulgus_bgvideoram_w) AM_BASE_MEMBER(vulgus_state, bgvideoram) AM_RANGE(0xe000, 0xefff) AM_RAM ADDRESS_MAP_END @@ -217,7 +217,7 @@ GFXDECODE_END -static MACHINE_CONFIG_START( vulgus, driver_device ) +static MACHINE_CONFIG_START( vulgus, vulgus_state ) /* basic machine hardware */ MCFG_CPU_ADD("maincpu", Z80, 4000000) /* 4 MHz (?) */ diff --git a/src/mame/includes/battlera.h b/src/mame/includes/battlera.h index 8e94e8d3436..4414c0e8bcf 100644 --- a/src/mame/includes/battlera.h +++ b/src/mame/includes/battlera.h @@ -1,3 +1,31 @@ +class battlera_state : public driver_device +{ +public: + battlera_state(running_machine &machine, const driver_device_config_base &config) + : driver_device(machine, config) { } + + int control_port_select; + int msm5205next; + int toggle; + int HuC6270_registers[20]; + int VDC_register; + int vram_ptr; + UINT8 *HuC6270_vram; + UINT8 *vram_dirty; + bitmap_t *tile_bitmap; + bitmap_t *front_bitmap; + UINT32 tile_dirtyseq; + int current_scanline; + int inc_value; + int irq_enable; + int rcr_enable; + int sb_enable; + int bb_enable; + int bldwolf_vblank; + UINT8 blank_tile[32]; +}; + + /*----------- defined in video/battlera.c -----------*/ VIDEO_UPDATE( battlera ); diff --git a/src/mame/includes/cchasm.h b/src/mame/includes/cchasm.h index 70a779d5d89..da96e59fc56 100644 --- a/src/mame/includes/cchasm.h +++ b/src/mame/includes/cchasm.h @@ -6,6 +6,23 @@ #include "machine/z80ctc.h" +class cchasm_state : public driver_device +{ +public: + cchasm_state(running_machine &machine, const driver_device_config_base &config) + : driver_device(machine, config) { } + + int sound_flags; + int coin_flag; + device_t *ctc; + int channel_active[2]; + int output[2]; + UINT16 *ram; + int xcenter; + int ycenter; +}; + + /*----------- defined in machine/cchasm.c -----------*/ WRITE16_HANDLER( cchasm_led_w ); @@ -28,8 +45,6 @@ SOUND_START( cchasm ); /*----------- defined in video/cchasm.c -----------*/ -extern UINT16 *cchasm_ram; - WRITE16_HANDLER( cchasm_refresh_control_w ); VIDEO_START( cchasm ); diff --git a/src/mame/includes/cinemat.h b/src/mame/includes/cinemat.h index 6b7fc89ef43..f11b4ade9c9 100644 --- a/src/mame/includes/cinemat.h +++ b/src/mame/includes/cinemat.h @@ -5,6 +5,39 @@ *************************************************************************/ +class cinemat_state : public driver_device +{ +public: + cinemat_state(running_machine &machine, const driver_device_config_base &config) + : driver_device(machine, config) { } + + UINT8 sound_control; + UINT32 current_shift; + UINT32 last_shift; + UINT32 last_shift2; + UINT32 current_pitch; + UINT32 last_frame; + UINT8 sound_fifo[16]; + UINT8 sound_fifo_in; + UINT8 sound_fifo_out; + UINT8 last_portb_write; + float target_volume; + float current_volume; + UINT16 *rambase; + UINT8 coin_detected; + UINT8 coin_last_reset; + UINT8 mux_select; + int gear; + int color_mode; + rgb_t vector_color; + INT16 lastx; + INT16 lasty; + UINT8 last_control; + int qb3_lastx; + int qb3_lasty; +}; + + /*----------- defined in drivers/cinemat.c -----------*/ MACHINE_RESET( cinemat ); diff --git a/src/mame/includes/cps3.h b/src/mame/includes/cps3.h index b00a0c29989..925ff16ec77 100644 --- a/src/mame/includes/cps3.h +++ b/src/mame/includes/cps3.h @@ -5,10 +5,60 @@ ****************************************************************************/ #include "devlegcy.h" +#include "machine/intelfsh.h" -/*----------- defined in drivers/cps3.c -----------*/ +class cps3_state : public driver_device +{ +public: + cps3_state(running_machine &machine, const driver_device_config_base &config) + : driver_device(machine, config) { } -extern UINT8* cps3_user5region; + fujitsu_29f016a_device *simm[7][8]; + UINT32* decrypted_bios; + UINT32* decrypted_gamerom; + UINT32 cram_gfxflash_bank; + UINT32* nops; + UINT32* tilemap20_regs_base; + UINT32* tilemap30_regs_base; + UINT32* tilemap40_regs_base; + UINT32* tilemap50_regs_base; + UINT32* _0xc0000000_ram; + UINT32* _0xc0000000_ram_decrypted; + UINT32* char_ram; + UINT32* spriteram; + UINT32* eeprom; + UINT32* fullscreenzoom; + UINT32 ss_pal_base; + UINT32* colourram; + UINT32 unk_vidregs[0x20/4]; + UINT32 ss_bank_base; + UINT32 screenwidth; + UINT32* mame_colours; + bitmap_t *renderbuffer_bitmap; + rectangle renderbuffer_clip; + UINT8* user4region; + UINT32 key1; + UINT32 key2; + int altEncryption; + UINT32* ss_ram; + UINT32 cram_bank; + UINT16 current_eeprom_read; + UINT32 paldma_source; + UINT32 paldma_realsource; + UINT32 paldma_dest; + UINT32 paldma_fade; + UINT32 paldma_other2; + UINT32 paldma_length; + UINT32 chardma_source; + UINT32 chardma_other; + UINT32 current_table_address; + int rle_length; + int last_normal_byte; + unsigned short lastb; + unsigned short lastb2; + UINT32* mainram; + UINT8* user5region; +}; /*----------- defined in audio/cps3.c -----------*/ diff --git a/src/mame/includes/darkseal.h b/src/mame/includes/darkseal.h index 7f3418dc355..0114b7c7564 100644 --- a/src/mame/includes/darkseal.h +++ b/src/mame/includes/darkseal.h @@ -1,7 +1,25 @@ -/*----------- defined in video/darkseal.c -----------*/ +class darkseal_state : public driver_device +{ +public: + darkseal_state(running_machine &machine, const driver_device_config_base &config) + : driver_device(machine, config) { } -extern UINT16 *darkseal_pf12_row, *darkseal_pf34_row; -extern UINT16 *darkseal_pf1_data,*darkseal_pf2_data,*darkseal_pf3_data; + UINT16 *ram; + UINT16 *pf12_row; + UINT16 *pf34_row; + UINT16 *pf1_data; + UINT16 *pf2_data; + UINT16 *pf3_data; + UINT16 control_0[8]; + UINT16 control_1[8]; + tilemap_t *pf1_tilemap; + tilemap_t *pf2_tilemap; + tilemap_t *pf3_tilemap; + int flipscreen; +}; + + +/*----------- defined in video/darkseal.c -----------*/ VIDEO_START( darkseal ); VIDEO_UPDATE( darkseal ); diff --git a/src/mame/includes/dec0.h b/src/mame/includes/dec0.h index 213153a1cdf..1b817e310af 100644 --- a/src/mame/includes/dec0.h +++ b/src/mame/includes/dec0.h @@ -1,7 +1,50 @@ -/*----------- defined in drivers/dec0.c -----------*/ +class dec0_state : public driver_device +{ +public: + dec0_state(running_machine &machine, const driver_device_config_base &config) + : driver_device(machine, config) { } + + UINT8 automat_adpcm_byte; + int automat_msm5205_vclk_toggle; + UINT16 *ram; + UINT8 *robocop_shared_ram; + UINT16 *pf1_rowscroll; + UINT16 *pf2_rowscroll; + UINT16 *pf3_rowscroll; + UINT16 *pf1_colscroll; + UINT16 *pf2_colscroll; + UINT16 *pf3_colscroll; + UINT16 *pf1_data; + UINT16 *pf2_data; + UINT16 *pf3_data; + int GAME; + int i8751_return; + int i8751_command; + int slyspy_state; + int share[0xff]; + int hippodrm_msb; + int hippodrm_lsb; + UINT8 i8751_ports[4]; + tilemap_t *pf1_tilemap_0; + tilemap_t *pf1_tilemap_1; + tilemap_t *pf1_tilemap_2; + tilemap_t *pf2_tilemap_0; + tilemap_t *pf2_tilemap_1; + tilemap_t *pf2_tilemap_2; + tilemap_t *pf3_tilemap_0; + tilemap_t *pf3_tilemap_1; + tilemap_t *pf3_tilemap_2; + UINT16 pf1_control_0[4]; + UINT16 pf1_control_1[4]; + UINT16 pf2_control_0[4]; + UINT16 pf2_control_1[4]; + UINT16 pf3_control_0[4]; + UINT16 pf3_control_1[4]; + UINT16 *spriteram; + UINT16 pri; + int buffer[0x20]; +}; -extern UINT16 *dec0_ram; -extern UINT8 *robocop_shared_ram; /*----------- defined in video/dec0.c -----------*/ @@ -16,9 +59,6 @@ VIDEO_UPDATE( hippodrm ); VIDEO_UPDATE( slyspy ); VIDEO_UPDATE( midres ); -extern UINT16 *dec0_pf1_rowscroll,*dec0_pf2_rowscroll,*dec0_pf3_rowscroll; -extern UINT16 *dec0_pf1_colscroll,*dec0_pf2_colscroll,*dec0_pf3_colscroll; -extern UINT16 *dec0_pf1_data,*dec0_pf2_data,*dec0_pf3_data; WRITE16_HANDLER( dec0_pf1_control_0_w ); WRITE16_HANDLER( dec0_pf1_control_1_w ); @@ -63,7 +103,7 @@ DRIVER_INIT( hbarrel ); DRIVER_INIT( birdtry ); extern void dec0_i8751_write(running_machine *machine, int data); -extern void dec0_i8751_reset(void); +extern void dec0_i8751_reset(running_machine *machine); READ8_HANDLER( hippodrm_prot_r ); WRITE8_HANDLER( dec0_mcu_port_w ); READ8_HANDLER( dec0_mcu_port_r ); diff --git a/src/mame/includes/deco32.h b/src/mame/includes/deco32.h index e1290c708b7..470e919cd1f 100644 --- a/src/mame/includes/deco32.h +++ b/src/mame/includes/deco32.h @@ -1,3 +1,69 @@ +class deco32_state : public driver_device +{ +public: + deco32_state(running_machine &machine, const driver_device_config_base &config) + : driver_device(machine, config) { } + + UINT32 *ram; + int raster_enable; + timer_device *raster_irq_timer; + UINT8 nslasher_sound_irq; + int strobe; + int dragngun_lightgun_port; + int tattass_eprom_bit; + int lastClock; + char buffer[32]; + int bufPtr; + int pendingCommand; + int readBitCount; + int byteAddr; + UINT8 bsmt_latch; + UINT8 bsmt_reset; + UINT32 *pf1_data; + UINT32 *pf2_data; + UINT32 *pf3_data; + UINT32 *pf4_data; + UINT32 *pf12_control; + UINT32 *pf34_control; + UINT32 *pf1_rowscroll; + UINT32 *pf2_rowscroll; + UINT32 *pf3_rowscroll; + UINT32 *pf4_rowscroll; + UINT32 *dragngun_sprite_layout_0_ram; + UINT32 *dragngun_sprite_layout_1_ram; + UINT32 *dragngun_sprite_lookup_0_ram; + UINT32 *dragngun_sprite_lookup_1_ram; + UINT32 *ace_ram; + UINT16 *raster_display_list; + int raster_display_position; + UINT8 *dirty_palette; + tilemap_t *pf1_tilemap; + tilemap_t *pf1a_tilemap; + tilemap_t *pf2_tilemap; + tilemap_t *pf3_tilemap; + tilemap_t *pf4_tilemap; + int pf1_bank; + int pf2_bank; + int pf3_bank; + int pf4_bank; + int pf1_flip; + int pf2_flip; + int pf3_flip; + int pf4_flip; + int pf2_colourbank; + int pf4_colourbank; + int pri; + bitmap_t *sprite0_mix_bitmap; + bitmap_t *sprite1_mix_bitmap; + bitmap_t *tilemap_alpha_bitmap; + UINT32 dragngun_sprite_ctrl; + int ace_ram_dirty; + int has_ace_ram; + bitmap_t *sprite_priority_bitmap; + int last_pf3_bank; +}; + + /*----------- defined in video/deco32.c -----------*/ VIDEO_START( captaven ); @@ -14,14 +80,6 @@ VIDEO_UPDATE( fghthist ); VIDEO_UPDATE( dragngun ); VIDEO_UPDATE( nslasher ); -extern UINT32 *deco32_pf1_data,*deco32_pf2_data,*deco32_pf3_data,*deco32_pf4_data; -extern UINT32 *deco32_pf12_control,*deco32_pf34_control; -extern UINT32 *deco32_pf1_rowscroll,*deco32_pf2_rowscroll,*deco32_pf3_rowscroll,*deco32_pf4_rowscroll; -extern UINT32 *dragngun_sprite_layout_0_ram, *dragngun_sprite_layout_1_ram; -extern UINT32 *dragngun_sprite_lookup_0_ram, *dragngun_sprite_lookup_1_ram; -extern UINT32 *deco32_ace_ram; -extern UINT16 *deco32_raster_display_list; -extern int deco32_raster_display_position; WRITE32_HANDLER( deco32_pf1_data_w ); WRITE32_HANDLER( deco32_pf2_data_w ); diff --git a/src/mame/includes/deco_mlc.h b/src/mame/includes/deco_mlc.h index 7b0c3baf387..7f0ebcff690 100644 --- a/src/mame/includes/deco_mlc.h +++ b/src/mame/includes/deco_mlc.h @@ -1,6 +1,24 @@ -/*----------- defined in video/deco_mlc.c -----------*/ +class deco_mlc_state : public driver_device +{ +public: + deco_mlc_state(running_machine &machine, const driver_device_config_base &config) + : driver_device(machine, config) { } -extern UINT32 *mlc_vram, *mlc_clip_ram; + UINT32 *mlc_ram; + UINT32 *irq_ram; + timer_device *raster_irq_timer; + int mainCpuIsArm; + int mlc_raster_table[9][256]; + UINT32 vbl_i; + int lastScanline[9]; + UINT32 *mlc_vram; + UINT32 *mlc_clip_ram; + UINT32 colour_mask; + UINT32 *mlc_buffered_spriteram; +}; + + +/*----------- defined in video/deco_mlc.c -----------*/ VIDEO_START( mlc ); VIDEO_UPDATE( mlc ); diff --git a/src/mame/includes/madalien.h b/src/mame/includes/madalien.h index 50b5b5ed3b7..e90b3f6a8e2 100644 --- a/src/mame/includes/madalien.h +++ b/src/mame/includes/madalien.h @@ -12,18 +12,31 @@ #define MADALIEN_MAIN_CLOCK XTAL_10_595MHz +class madalien_state : public driver_device +{ +public: + madalien_state(running_machine &machine, const driver_device_config_base &config) + : driver_device(machine, config) { } + + UINT8 *shift_hi; + UINT8 *shift_lo; + UINT8 *videoram; + UINT8 *charram; + UINT8 *video_flags; + UINT8 *video_control; + UINT8 *scroll; + UINT8 *edge1_pos; + UINT8 *edge2_pos; + UINT8 *headlight_pos; + tilemap_t *tilemap_fg; + tilemap_t *tilemap_edge1[4]; + tilemap_t *tilemap_edge2[4]; + bitmap_t *headlight_bitmap; +}; + + /*----------- defined in video/madalien.c -----------*/ -extern UINT8 *madalien_videoram; -extern UINT8 *madalien_charram; - -extern UINT8 *madalien_video_flags; -extern UINT8 *madalien_video_control; -extern UINT8 *madalien_scroll; -extern UINT8 *madalien_edge1_pos; -extern UINT8 *madalien_edge2_pos; -extern UINT8 *madalien_headlight_pos; - MACHINE_CONFIG_EXTERN( madalien_video ); WRITE8_HANDLER( madalien_videoram_w ); diff --git a/src/mame/includes/mitchell.h b/src/mame/includes/mitchell.h index 3edda2e41d3..476f6f4c9dc 100644 --- a/src/mame/includes/mitchell.h +++ b/src/mame/includes/mitchell.h @@ -39,6 +39,8 @@ public: /* devices */ optional_device audiocpu; optional_device oki; + UINT8 *nvram; + size_t nvram_size; }; diff --git a/src/mame/includes/pcktgal.h b/src/mame/includes/pcktgal.h index 957b4aed68d..e8c29197be4 100644 --- a/src/mame/includes/pcktgal.h +++ b/src/mame/includes/pcktgal.h @@ -5,6 +5,9 @@ public: : driver_device(machine, config) { } UINT8 *videoram; + int msm5205next; + int toggle; + tilemap_t *bg_tilemap; }; diff --git a/src/mame/includes/powerins.h b/src/mame/includes/powerins.h index 2b384706156..2e9621676b6 100644 --- a/src/mame/includes/powerins.h +++ b/src/mame/includes/powerins.h @@ -1,7 +1,21 @@ -/*----------- defined in video/powerins.c -----------*/ +class powerins_state : public driver_device +{ +public: + powerins_state(running_machine &machine, const driver_device_config_base &config) + : driver_device(machine, config) { } -extern UINT16 *powerins_vram_0, *powerins_vctrl_0; -extern UINT16 *powerins_vram_1, *powerins_vctrl_1; + int oki_bank; + UINT16 *vram_0; + UINT16 *vctrl_0; + UINT16 *vram_1; + UINT16 *vctrl_1; + tilemap_t *tilemap_0; + tilemap_t *tilemap_1; + int tile_bank; +}; + + +/*----------- defined in video/powerins.c -----------*/ WRITE16_HANDLER( powerins_flipscreen_w ); WRITE16_HANDLER( powerins_tilebank_w ); diff --git a/src/mame/includes/srumbler.h b/src/mame/includes/srumbler.h index 6cc22fc0d66..3c9da4aee6c 100644 --- a/src/mame/includes/srumbler.h +++ b/src/mame/includes/srumbler.h @@ -1,6 +1,18 @@ -/*----------- defined in video/srumbler.c -----------*/ +class srumbler_state : public driver_device +{ +public: + srumbler_state(running_machine &machine, const driver_device_config_base &config) + : driver_device(machine, config) { } -extern UINT8 *srumbler_backgroundram,*srumbler_foregroundram; + UINT8 *backgroundram; + UINT8 *foregroundram; + tilemap_t *bg_tilemap; + tilemap_t *fg_tilemap; + int scroll[4]; +}; + + +/*----------- defined in video/srumbler.c -----------*/ WRITE8_HANDLER( srumbler_background_w ); WRITE8_HANDLER( srumbler_foreground_w ); diff --git a/src/mame/includes/sshangha.h b/src/mame/includes/sshangha.h index 68cb2e2efb1..ff6b5b5245c 100644 --- a/src/mame/includes/sshangha.h +++ b/src/mame/includes/sshangha.h @@ -1,8 +1,28 @@ -/*----------- defined in video/sshangha.c -----------*/ +class sshangha_state : public driver_device +{ +public: + sshangha_state(running_machine &machine, const driver_device_config_base &config) + : driver_device(machine, config) { } -extern UINT16 *sshangha_pf1_data; -extern UINT16 *sshangha_pf2_data; -extern UINT16 *sshangha_pf1_rowscroll, *sshangha_pf2_rowscroll; + UINT16 *prot_data; + UINT16 *sound_shared_ram; + UINT16 *pf1_data; + UINT16 *pf2_data; + UINT16 *pf1_rowscroll; + UINT16 *pf2_rowscroll; + UINT16 control_0[8]; + tilemap_t *pf1_8x8_tilemap; + tilemap_t *pf1_16x16_tilemap; + tilemap_t *pf2_tilemap; + int pf1_bank; + int pf2_bank; + int video_control; + int last_pf1_bank; + int last_pf2_bank; +}; + + +/*----------- defined in video/sshangha.c -----------*/ VIDEO_START( sshangha ); VIDEO_UPDATE( sshangha ); diff --git a/src/mame/includes/stadhero.h b/src/mame/includes/stadhero.h index 6bbdb183541..05a162b6452 100644 --- a/src/mame/includes/stadhero.h +++ b/src/mame/includes/stadhero.h @@ -1,8 +1,20 @@ -/*----------- defined in video/stadhero.c -----------*/ +class stadhero_state : public driver_device +{ +public: + stadhero_state(running_machine &machine, const driver_device_config_base &config) + : driver_device(machine, config) { } -extern UINT16 *stadhero_pf1_data; -extern UINT16 *stadhero_pf2_control_0; -extern UINT16 *stadhero_pf2_control_1; + UINT16 *pf1_data; + UINT16 *pf2_control_0; + UINT16 *pf2_control_1; + UINT16 *pf2_data; + tilemap_t *pf1_tilemap; + tilemap_t *pf2_tilemap; + int flipscreen; +}; + + +/*----------- defined in video/stadhero.c -----------*/ VIDEO_START( stadhero ); VIDEO_UPDATE( stadhero ); diff --git a/src/mame/includes/tigeroad.h b/src/mame/includes/tigeroad.h index 829b0f41532..65d3c412e2e 100644 --- a/src/mame/includes/tigeroad.h +++ b/src/mame/includes/tigeroad.h @@ -5,6 +5,10 @@ public: : driver_device(machine, config) { } UINT16 *videoram; + UINT16 *ram16; + int bgcharbank; + tilemap_t *bg_tilemap; + tilemap_t *fg_tilemap; }; diff --git a/src/mame/includes/tryout.h b/src/mame/includes/tryout.h index eed751b86e9..fdb380587fe 100644 --- a/src/mame/includes/tryout.h +++ b/src/mame/includes/tryout.h @@ -5,13 +5,17 @@ public: : driver_device(machine, config) { } UINT8 *videoram; + UINT8 *gfx_control; + tilemap_t *fg_tilemap; + tilemap_t *bg_tilemap; + UINT8 vram_bank; + UINT8 *vram; + UINT8 *vram_gfx; }; /*----------- defined in video/tryout.c -----------*/ -extern UINT8 *tryout_gfx_control; - READ8_HANDLER( tryout_vram_r ); WRITE8_HANDLER( tryout_videoram_w ); WRITE8_HANDLER( tryout_vram_w ); diff --git a/src/mame/includes/tumbleb.h b/src/mame/includes/tumbleb.h index a8ebc20e377..7a0956f9783 100644 --- a/src/mame/includes/tumbleb.h +++ b/src/mame/includes/tumbleb.h @@ -31,6 +31,8 @@ public: device_t *maincpu; device_t *audiocpu; device_t *oki; + UINT8 semicom_prot_offset; + UINT16 protbase; }; /*----------- defined in video/tumbleb.c -----------*/ diff --git a/src/mame/includes/vulgus.h b/src/mame/includes/vulgus.h index ce284a1c25d..5e0310b110b 100644 --- a/src/mame/includes/vulgus.h +++ b/src/mame/includes/vulgus.h @@ -1,8 +1,20 @@ -/*----------- defined in video/vulgus.c -----------*/ +class vulgus_state : public driver_device +{ +public: + vulgus_state(running_machine &machine, const driver_device_config_base &config) + : driver_device(machine, config) { } -extern UINT8 *vulgus_fgvideoram; -extern UINT8 *vulgus_bgvideoram; -extern UINT8 *vulgus_scroll_low,*vulgus_scroll_high; + UINT8 *fgvideoram; + UINT8 *bgvideoram; + UINT8 *scroll_low; + UINT8 *scroll_high; + int palette_bank; + tilemap_t *fg_tilemap; + tilemap_t *bg_tilemap; +}; + + +/*----------- defined in video/vulgus.c -----------*/ WRITE8_HANDLER( vulgus_fgvideoram_w ); WRITE8_HANDLER( vulgus_bgvideoram_w ); diff --git a/src/mame/machine/dec0.c b/src/mame/machine/dec0.c index 6d255085930..15749710e61 100644 --- a/src/mame/machine/dec0.c +++ b/src/mame/machine/dec0.c @@ -11,12 +11,12 @@ Data East machine functions - Bryan McPhail, mish@tendril.co.uk #include "cpu/h6280/h6280.h" #include "cpu/mcs51/mcs51.h" -static int GAME,i8751_return,i8751_command,slyspy_state; /******************************************************************************/ READ16_HANDLER( dec0_controls_r ) { + dec0_state *state = space->machine->driver_data(); switch (offset<<1) { case 0: /* Player 1 & 2 joystick & buttons */ @@ -29,8 +29,8 @@ READ16_HANDLER( dec0_controls_r ) return input_port_read(space->machine, "DSW"); case 8: /* Intel 8751 mc, Bad Dudes & Heavy Barrel only */ - //logerror("CPU #0 PC %06x: warning - read i8751 %06x - %04x\n", cpu_get_pc(space->cpu), 0x30c000+offset, i8751_return); - return i8751_return; + //logerror("CPU #0 PC %06x: warning - read i8751 %06x - %04x\n", cpu_get_pc(space->cpu), 0x30c000+offset, state->i8751_return); + return state->i8751_return; } logerror("CPU #0 PC %06x: warning - read unmapped memory address %06x\n", cpu_get_pc(space->cpu), 0x30c000+offset); @@ -154,19 +154,22 @@ READ16_HANDLER( slyspy_protection_r ) WRITE16_HANDLER( slyspy_state_w ) { - slyspy_state=0; + dec0_state *state = space->machine->driver_data(); + state->slyspy_state=0; } READ16_HANDLER( slyspy_state_r ) { - slyspy_state++; - slyspy_state=slyspy_state%4; + dec0_state *state = space->machine->driver_data(); + state->slyspy_state++; + state->slyspy_state=state->slyspy_state%4; return 0; /* Value doesn't mater */ } WRITE16_HANDLER( slyspy_240000_w ) { - switch (slyspy_state) { + dec0_state *state = space->machine->driver_data(); + switch (state->slyspy_state) { case 0x3: dec0_pf1_data_w(space,offset,data,mem_mask); return; @@ -178,36 +181,39 @@ WRITE16_HANDLER( slyspy_240000_w ) else if (offset<0x10) dec0_pf2_control_1_w(space,offset-0x8,data,mem_mask); return; } - logerror("Wrote to 240000 %02x at %04x %04x (Trap %02x)\n",offset,cpu_get_pc(space->cpu),data,slyspy_state); + logerror("Wrote to 240000 %02x at %04x %04x (Trap %02x)\n",offset,cpu_get_pc(space->cpu),data,state->slyspy_state); } WRITE16_HANDLER( slyspy_242000_w ) { - switch (slyspy_state) { + dec0_state *state = space->machine->driver_data(); + switch (state->slyspy_state) { case 0x2: /* Trap A */ dec0_pf1_data_w(space,offset,data,mem_mask); return; case 0x0: /* Trap C */ - if (offset<0x40) COMBINE_DATA(&dec0_pf2_colscroll[offset]); - else if (offset<0x300) COMBINE_DATA(&dec0_pf2_rowscroll[offset-0x200]); + if (offset<0x40) COMBINE_DATA(&state->pf2_colscroll[offset]); + else if (offset<0x300) COMBINE_DATA(&state->pf2_rowscroll[offset-0x200]); return; } - logerror("Wrote to 242000 %02x at %04x %04x (Trap %02x)\n",offset,cpu_get_pc(space->cpu),data,slyspy_state); + logerror("Wrote to 242000 %02x at %04x %04x (Trap %02x)\n",offset,cpu_get_pc(space->cpu),data,state->slyspy_state); } WRITE16_HANDLER( slyspy_246000_w ) { - switch (slyspy_state) { + dec0_state *state = space->machine->driver_data(); + switch (state->slyspy_state) { case 0x0: dec0_pf2_data_w(space,offset,data,mem_mask); return; } - logerror("Wrote to 246000 %02x at %04x %04x (Trap %02x)\n",offset,cpu_get_pc(space->cpu),data,slyspy_state); + logerror("Wrote to 246000 %02x at %04x %04x (Trap %02x)\n",offset,cpu_get_pc(space->cpu),data,state->slyspy_state); } WRITE16_HANDLER( slyspy_248000_w ) { - switch (slyspy_state) { + dec0_state *state = space->machine->driver_data(); + switch (state->slyspy_state) { case 0x1: dec0_pf1_data_w(space,offset,data,mem_mask); return; @@ -219,75 +225,81 @@ WRITE16_HANDLER( slyspy_248000_w ) else if (offset<0x10) dec0_pf1_control_1_w(space,offset-0x8,data,mem_mask); return; } - logerror("Wrote to 248000 %02x at %04x %04x (Trap %02x)\n",offset,cpu_get_pc(space->cpu),data,slyspy_state); + logerror("Wrote to 248000 %02x at %04x %04x (Trap %02x)\n",offset,cpu_get_pc(space->cpu),data,state->slyspy_state); } WRITE16_HANDLER( slyspy_24c000_w ) { - switch (slyspy_state) { + dec0_state *state = space->machine->driver_data(); + switch (state->slyspy_state) { case 0x1: /* Trap 9 */ dec0_pf2_data_w(space,offset,data,mem_mask); return; case 0x0: /* Trap C */ - if (offset<0x40) COMBINE_DATA(&dec0_pf1_colscroll[offset]); - else if (offset<0x300) COMBINE_DATA(&dec0_pf1_rowscroll[offset-0x200]); + if (offset<0x40) COMBINE_DATA(&state->pf1_colscroll[offset]); + else if (offset<0x300) COMBINE_DATA(&state->pf1_rowscroll[offset-0x200]); return; } - logerror("Wrote to 24c000 %02x at %04x %04x (Trap %02x)\n",offset,cpu_get_pc(space->cpu),data,slyspy_state); + logerror("Wrote to 24c000 %02x at %04x %04x (Trap %02x)\n",offset,cpu_get_pc(space->cpu),data,state->slyspy_state); } WRITE16_HANDLER( slyspy_24e000_w ) { - switch (slyspy_state) { + dec0_state *state = space->machine->driver_data(); + switch (state->slyspy_state) { case 0x2: case 0x0: dec0_pf1_data_w(space,offset,data,mem_mask); return; } - logerror("Wrote to 24e000 %02x at %04x %04x (Trap %02x)\n",offset,cpu_get_pc(space->cpu),data,slyspy_state); + logerror("Wrote to 24e000 %02x at %04x %04x (Trap %02x)\n",offset,cpu_get_pc(space->cpu),data,state->slyspy_state); } /******************************************************************************/ -static int share[0xff]; -static int hippodrm_msb,hippodrm_lsb; READ8_HANDLER( hippodrm_prot_r ) { + dec0_state *state = space->machine->driver_data(); //logerror("6280 PC %06x - Read %06x\n",cpu_getpc(),offset+0x1d0000); - if (hippodrm_lsb==0x45) return 0x4e; - if (hippodrm_lsb==0x92) return 0x15; + if (state->hippodrm_lsb==0x45) return 0x4e; + if (state->hippodrm_lsb==0x92) return 0x15; return 0; } WRITE8_HANDLER( hippodrm_prot_w ) { + dec0_state *state = space->machine->driver_data(); switch (offset) { - case 4: hippodrm_msb=data; break; - case 5: hippodrm_lsb=data; break; + case 4: state->hippodrm_msb=data; break; + case 5: state->hippodrm_lsb=data; break; } //logerror("6280 PC %06x - Wrote %06x to %04x\n",cpu_getpc(),data,offset+0x1d0000); } READ8_HANDLER( hippodrm_shared_r ) { - return share[offset]; + dec0_state *state = space->machine->driver_data(); + return state->share[offset]; } WRITE8_HANDLER( hippodrm_shared_w ) { - share[offset]=data; + dec0_state *state = space->machine->driver_data(); + state->share[offset]=data; } static READ16_HANDLER( hippodrm_68000_share_r ) { + dec0_state *state = space->machine->driver_data(); if (offset==0) cpu_yield(space->cpu); /* A wee helper */ - return share[offset]&0xff; + return state->share[offset]&0xff; } static WRITE16_HANDLER( hippodrm_68000_share_w ) { - share[offset]=data&0xff; + dec0_state *state = space->machine->driver_data(); + state->share[offset]=data&0xff; } /******************************************************************************/ @@ -326,23 +338,23 @@ static WRITE16_HANDLER( hippodrm_68000_share_w ) values are not known to change after bootup. */ -static UINT8 i8751_ports[4]; READ8_HANDLER(dec0_mcu_port_r ) { - int latchEnable=i8751_ports[2]>>4; + dec0_state *state = space->machine->driver_data(); + int latchEnable=state->i8751_ports[2]>>4; // P0 connected to 4 latches if (offset==0) { if ((latchEnable&1)==0) - return i8751_command>>8; + return state->i8751_command>>8; else if ((latchEnable&2)==0) - return i8751_command&0xff; + return state->i8751_command&0xff; else if ((latchEnable&4)==0) - return i8751_return>>8; + return state->i8751_return>>8; else if ((latchEnable&8)==0) - return i8751_return&0xff; + return state->i8751_return&0xff; } return 0xff; @@ -350,7 +362,8 @@ READ8_HANDLER(dec0_mcu_port_r ) WRITE8_HANDLER(dec0_mcu_port_w ) { - i8751_ports[offset]=data; + dec0_state *state = space->machine->driver_data(); + state->i8751_ports[offset]=data; if (offset==2) { @@ -359,58 +372,60 @@ WRITE8_HANDLER(dec0_mcu_port_w ) if ((data&0x8)==0) cputag_set_input_line(space->machine, "mcu", MCS51_INT1_LINE, CLEAR_LINE); if ((data&0x40)==0) - i8751_return=(i8751_return&0xff00)|(i8751_ports[0]); + state->i8751_return=(state->i8751_return&0xff00)|(state->i8751_ports[0]); if ((data&0x80)==0) - i8751_return=(i8751_return&0xff)|(i8751_ports[0]<<8); + state->i8751_return=(state->i8751_return&0xff)|(state->i8751_ports[0]<<8); } } static void baddudes_i8751_write(running_machine *machine, int data) { - i8751_return=0; + dec0_state *state = machine->driver_data(); + state->i8751_return=0; switch (data&0xffff) { - case 0x714: i8751_return=0x700; break; - case 0x73b: i8751_return=0x701; break; - case 0x72c: i8751_return=0x702; break; - case 0x73f: i8751_return=0x703; break; - case 0x755: i8751_return=0x704; break; - case 0x722: i8751_return=0x705; break; - case 0x72b: i8751_return=0x706; break; - case 0x724: i8751_return=0x707; break; - case 0x728: i8751_return=0x708; break; - case 0x735: i8751_return=0x709; break; - case 0x71d: i8751_return=0x70a; break; - case 0x721: i8751_return=0x70b; break; - case 0x73e: i8751_return=0x70c; break; - case 0x761: i8751_return=0x70d; break; - case 0x753: i8751_return=0x70e; break; - case 0x75b: i8751_return=0x70f; break; + case 0x714: state->i8751_return=0x700; break; + case 0x73b: state->i8751_return=0x701; break; + case 0x72c: state->i8751_return=0x702; break; + case 0x73f: state->i8751_return=0x703; break; + case 0x755: state->i8751_return=0x704; break; + case 0x722: state->i8751_return=0x705; break; + case 0x72b: state->i8751_return=0x706; break; + case 0x724: state->i8751_return=0x707; break; + case 0x728: state->i8751_return=0x708; break; + case 0x735: state->i8751_return=0x709; break; + case 0x71d: state->i8751_return=0x70a; break; + case 0x721: state->i8751_return=0x70b; break; + case 0x73e: state->i8751_return=0x70c; break; + case 0x761: state->i8751_return=0x70d; break; + case 0x753: state->i8751_return=0x70e; break; + case 0x75b: state->i8751_return=0x70f; break; } - if (!i8751_return) logerror("%s: warning - write unknown command %02x to 8571\n",machine->describe_context(),data); + if (!state->i8751_return) logerror("%s: warning - write unknown command %02x to 8571\n",machine->describe_context(),data); cputag_set_input_line(machine, "maincpu", 5, HOLD_LINE); } static void birdtry_i8751_write(running_machine *machine, int data) { + dec0_state *state = machine->driver_data(); static int pwr, hgt; - i8751_return=0; + state->i8751_return=0; switch(data&0xffff) { /*"Sprite control"*/ - case 0x22a: i8751_return = 0x200; break; + case 0x22a: state->i8751_return = 0x200; break; /* Gives an O.B. otherwise (it must be > 0xb0 )*/ - case 0x3c7: i8751_return = 0x7ff; break; + case 0x3c7: state->i8751_return = 0x7ff; break; /*Enables shot checks*/ - case 0x33c: i8751_return = 0x200; break; + case 0x33c: state->i8751_return = 0x200; break; /*Used on the title screen only(???)*/ - case 0x31e: i8751_return = 0x200; break; + case 0x31e: state->i8751_return = 0x200; break; /* 0x100-0x10d values are for club power meters(1W=0x100<<-->>PT=0x10d). * * Returned value to i8751 doesn't matter,but send the result to 0x481. * @@ -429,7 +444,7 @@ static void birdtry_i8751_write(running_machine *machine, int data) case 0x10b: pwr = 0x5c; break; /*PW*/ case 0x10c: pwr = 0x60; break; /*SW*/ case 0x10d: pwr = 0x80; break; /*PT*/ - case 0x481: i8751_return = pwr; break; /*Power meter*/ + case 0x481: state->i8751_return = pwr; break; /*Power meter*/ /* 0x200-0x20f values are for shot height(STRONG=0x200<<-->>WEAK=0x20f). * * Returned value to i8751 doesn't matter,but send the result to 0x534. * @@ -450,14 +465,14 @@ static void birdtry_i8751_write(running_machine *machine, int data) case 0x20d: hgt = 0x280; break; /*|*/ case 0x20e: hgt = 0x240; break; /*|*/ case 0x20f: hgt = 0x200; break; /*L*/ - case 0x534: i8751_return = hgt; break; /*Shot height*/ + case 0x534: state->i8751_return = hgt; break; /*Shot height*/ /*At the ending screen(???)*/ - //case 0x3b4: i8751_return = 0; break; + //case 0x3b4: state->i8751_return = 0; break; /*These are activated after a shot (???)*/ - case 0x6ca: i8751_return = 0xff; break; - case 0x7ff: i8751_return = 0x200; break; + case 0x6ca: state->i8751_return = 0xff; break; + case 0x7ff: state->i8751_return = 0x200; break; default: logerror("%s: warning - write unknown command %02x to 8571\n",machine->describe_context(),data); } cputag_set_input_line(machine, "maincpu", 5, HOLD_LINE); @@ -465,19 +480,21 @@ static void birdtry_i8751_write(running_machine *machine, int data) void dec0_i8751_write(running_machine *machine, int data) { - i8751_command=data; + dec0_state *state = machine->driver_data(); + state->i8751_command=data; /* Writes to this address cause an IRQ to the i8751 microcontroller */ - if (GAME == 1) cputag_set_input_line(machine, "mcu", MCS51_INT1_LINE, ASSERT_LINE); - if (GAME == 2) baddudes_i8751_write(machine, data); - if (GAME == 3) birdtry_i8751_write(machine, data); + if (state->GAME == 1) cputag_set_input_line(machine, "mcu", MCS51_INT1_LINE, ASSERT_LINE); + if (state->GAME == 2) baddudes_i8751_write(machine, data); + if (state->GAME == 3) birdtry_i8751_write(machine, data); //logerror("%s: warning - write %02x to i8751\n",machine->describe_context(),data); } -void dec0_i8751_reset(void) +void dec0_i8751_reset(running_machine *machine) { - i8751_return=i8751_command=0; + dec0_state *state = machine->driver_data(); + state->i8751_return=state->i8751_command=0; } /******************************************************************************/ @@ -491,16 +508,18 @@ static WRITE16_HANDLER( sprite_mirror_w ) static READ16_HANDLER( robocop_68000_share_r ) { + dec0_state *state = space->machine->driver_data(); //logerror("%08x: Share read %04x\n",cpu_get_pc(space->cpu),offset); - return robocop_shared_ram[offset]; + return state->robocop_shared_ram[offset]; } static WRITE16_HANDLER( robocop_68000_share_w ) { + dec0_state *state = space->machine->driver_data(); // logerror("%08x: Share write %04x %04x\n",cpu_get_pc(space->cpu),offset,data); - robocop_shared_ram[offset]=data&0xff; + state->robocop_shared_ram[offset]=data&0xff; if (offset == 0x7ff) /* A control address - not standard ram */ cputag_set_input_line(space->machine, "sub", 0, HOLD_LINE); @@ -552,20 +571,23 @@ DRIVER_INIT( robocop ) DRIVER_INIT( baddudes ) { - GAME = 2; + dec0_state *state = machine->driver_data(); + state->GAME = 2; } DRIVER_INIT( hbarrel ) { - GAME = 1; + dec0_state *state = machine->driver_data(); + state->GAME = 1; } DRIVER_INIT( birdtry ) { + dec0_state *state = machine->driver_data(); UINT8 *src, tmp; int i, j, k; - GAME=3; + state->GAME=3; src = machine->region("gfx4")->base(); diff --git a/src/mame/machine/megadriv.c b/src/mame/machine/megadriv.c index b43ac25eeb9..6ec5b5b90f0 100644 --- a/src/mame/machine/megadriv.c +++ b/src/mame/machine/megadriv.c @@ -9290,7 +9290,7 @@ MACHINE_CONFIG_START( megadpal, driver_device ) MACHINE_CONFIG_END -static int _32x_fifo_available_callback(UINT32 src, UINT32 dst, UINT32 data, int size) +static int _32x_fifo_available_callback(device_t *device, UINT32 src, UINT32 dst, UINT32 data, int size) { if (src==0x4012) { diff --git a/src/mame/mame.mak b/src/mame/mame.mak index dc089b984f1..1cbffda4c7e 100644 --- a/src/mame/mame.mak +++ b/src/mame/mame.mak @@ -381,9 +381,9 @@ $(MAMEOBJ)/amiga.a: \ $(MAMEOBJ)/aristocr.a: \ $(DRIVERS)/86lions.o \ - $(DRIVERS)/caswin.o \ $(DRIVERS)/aristmk4.o \ $(DRIVERS)/aristmk5.o \ + $(DRIVERS)/caswin.o \ $(MACHINE)/archimds.o \ $(VIDEO)/archimds.o \ @@ -514,10 +514,10 @@ $(MAMEOBJ)/capcom.a: \ $(DRIVERS)/cps2.o \ $(DRIVERS)/cps3.o $(AUDIO)/cps3.o \ $(DRIVERS)/egghunt.o \ + $(DRIVERS)/exedexes.o $(VIDEO)/exedexes.o \ $(DRIVERS)/fcrash.o \ $(DRIVERS)/gng.o $(VIDEO)/gng.o \ $(DRIVERS)/gunsmoke.o $(VIDEO)/gunsmoke.o \ - $(DRIVERS)/exedexes.o $(VIDEO)/exedexes.o \ $(DRIVERS)/higemaru.o $(VIDEO)/higemaru.o \ $(DRIVERS)/lastduel.o $(VIDEO)/lastduel.o \ $(DRIVERS)/lwings.o $(VIDEO)/lwings.o \ @@ -526,8 +526,8 @@ $(MAMEOBJ)/capcom.a: \ $(DRIVERS)/sidearms.o $(VIDEO)/sidearms.o \ $(DRIVERS)/sonson.o $(VIDEO)/sonson.o \ $(DRIVERS)/srumbler.o $(VIDEO)/srumbler.o \ - $(DRIVERS)/vulgus.o $(VIDEO)/vulgus.o \ $(DRIVERS)/tigeroad.o $(VIDEO)/tigeroad.o \ + $(DRIVERS)/vulgus.o $(VIDEO)/vulgus.o \ $(DRIVERS)/zn.o $(MACHINE)/znsec.o \ $(DRIVERS)/taitogn.o \ $(MACHINE)/cps2crpt.o \ @@ -560,10 +560,9 @@ $(MAMEOBJ)/dataeast.a: \ $(DRIVERS)/boogwing.o $(VIDEO)/boogwing.o \ $(DRIVERS)/brkthru.o $(VIDEO)/brkthru.o \ $(DRIVERS)/btime.o $(MACHINE)/btime.o $(VIDEO)/btime.o \ - $(DRIVERS)/chanbara.o \ $(DRIVERS)/bwing.o $(VIDEO)/bwing.o \ - $(DRIVERS)/deshoros.o \ $(DRIVERS)/cbuster.o $(VIDEO)/cbuster.o \ + $(DRIVERS)/chanbara.o \ $(DRIVERS)/cninja.o $(VIDEO)/cninja.o \ $(DRIVERS)/cntsteer.o \ $(DRIVERS)/compgolf.o $(VIDEO)/compgolf.o \ @@ -577,6 +576,7 @@ $(MAMEOBJ)/dataeast.a: \ $(DRIVERS)/deco156.o $(MACHINE)/deco156.o \ $(DRIVERS)/deco32.o $(VIDEO)/deco32.o \ $(DRIVERS)/decocass.o $(MACHINE)/decocass.o $(VIDEO)/decocass.o \ + $(DRIVERS)/deshoros.o \ $(DRIVERS)/dietgo.o $(VIDEO)/dietgo.o \ $(DRIVERS)/exprraid.o $(VIDEO)/exprraid.o \ $(DRIVERS)/firetrap.o $(VIDEO)/firetrap.o \ diff --git a/src/mame/video/battlera.c b/src/mame/video/battlera.c index 5445e109c5a..01542414d24 100644 --- a/src/mame/video/battlera.c +++ b/src/mame/video/battlera.c @@ -12,39 +12,29 @@ #include "cpu/h6280/h6280.h" #include "includes/battlera.h" -static int HuC6270_registers[20]; -static int VDC_register,vram_ptr; -static UINT8 *HuC6270_vram,*vram_dirty; -static bitmap_t *tile_bitmap,*front_bitmap; -static UINT32 tile_dirtyseq; - -static int current_scanline,inc_value; -static int irq_enable,rcr_enable,sb_enable,bb_enable,bldwolf_vblank; - -static UINT8 blank_tile[32]; - /******************************************************************************/ VIDEO_START( battlera ) { - HuC6270_vram=auto_alloc_array(machine, UINT8, 0x20000); - vram_dirty=auto_alloc_array(machine, UINT8, 0x1000); + battlera_state *state = machine->driver_data(); + state->HuC6270_vram=auto_alloc_array(machine, UINT8, 0x20000); + state->vram_dirty=auto_alloc_array(machine, UINT8, 0x1000); - memset(HuC6270_vram,0,0x20000); - memset(vram_dirty,1,0x1000); + memset(state->HuC6270_vram,0,0x20000); + memset(state->vram_dirty,1,0x1000); - tile_bitmap=auto_bitmap_alloc(machine,512,512,machine->primary_screen->format()); - front_bitmap=auto_bitmap_alloc(machine,512,512,machine->primary_screen->format()); + state->tile_bitmap=auto_bitmap_alloc(machine,512,512,machine->primary_screen->format()); + state->front_bitmap=auto_bitmap_alloc(machine,512,512,machine->primary_screen->format()); - vram_ptr=0; - inc_value=1; - current_scanline=0; - irq_enable=rcr_enable=sb_enable=bb_enable=0; + state->vram_ptr=0; + state->inc_value=1; + state->current_scanline=0; + state->irq_enable=state->rcr_enable=state->sb_enable=state->bb_enable=0; - gfx_element_set_source(machine->gfx[0], HuC6270_vram); - gfx_element_set_source(machine->gfx[1], HuC6270_vram); - gfx_element_set_source(machine->gfx[2], blank_tile); + gfx_element_set_source(machine->gfx[0], state->HuC6270_vram); + gfx_element_set_source(machine->gfx[1], state->HuC6270_vram); + gfx_element_set_source(machine->gfx[2], state->blank_tile); } /******************************************************************************/ @@ -64,34 +54,38 @@ WRITE8_HANDLER( battlera_palette_w ) READ8_HANDLER( HuC6270_debug_r ) { - return HuC6270_vram[offset]; + battlera_state *state = space->machine->driver_data(); + return state->HuC6270_vram[offset]; } WRITE8_HANDLER( HuC6270_debug_w ) { - HuC6270_vram[offset]=data; + battlera_state *state = space->machine->driver_data(); + state->HuC6270_vram[offset]=data; } READ8_HANDLER( HuC6270_register_r ) { + battlera_state *state = space->machine->driver_data(); int rr; - if ((current_scanline+56)==HuC6270_registers[6]) rr=1; else rr=0; + if ((state->current_scanline+56)==state->HuC6270_registers[6]) rr=1; else rr=0; return 0 /* CR flag */ | (0 << 1) /* OR flag */ | (rr << 2) /* RR flag */ | (0 << 3) /* DS flag */ | (0 << 4) /* DV flag */ - | (bldwolf_vblank << 5) /* VD flag (1 when vblank else 0) */ + | (state->bldwolf_vblank << 5) /* VD flag (1 when vblank else 0) */ | (0 << 6) /* BSY flag (1 when dma active, else 0) */ | (0 << 7); /* Always zero */ } WRITE8_HANDLER( HuC6270_register_w ) { + battlera_state *state = space->machine->driver_data(); switch (offset) { case 0: /* Select data region */ - VDC_register=data; + state->VDC_register=data; break; case 1: /* Unused */ break; @@ -103,15 +97,16 @@ WRITE8_HANDLER( HuC6270_register_w ) #ifdef UNUSED_FUNCTION READ8_HANDLER( HuC6270_data_r ) { + battlera_state *state = space->machine->driver_data(); int result; switch (offset) { case 0: /* LSB */ - return HuC6270_vram[(HuC6270_registers[1]<<1)|1]; + return state->HuC6270_vram[(state->HuC6270_registers[1]<<1)|1]; case 1:/* MSB */ - result=HuC6270_vram[(HuC6270_registers[1]<<1)|0]; - HuC6270_registers[1]=(HuC6270_registers[1]+inc_value)&0xffff; + result=state->HuC6270_vram[(state->HuC6270_registers[1]<<1)|0]; + state->HuC6270_registers[1]=(state->HuC6270_registers[1]+state->inc_value)&0xffff; return result; } @@ -121,25 +116,26 @@ READ8_HANDLER( HuC6270_data_r ) WRITE8_HANDLER( HuC6270_data_w ) { + battlera_state *state = space->machine->driver_data(); switch (offset) { case 0: /* LSB */ - switch (VDC_register) { + switch (state->VDC_register) { case 0: /* MAWR */ - HuC6270_registers[0]=(HuC6270_registers[0]&0xff00) | (data); + state->HuC6270_registers[0]=(state->HuC6270_registers[0]&0xff00) | (data); return; case 1: /* MARR */ - HuC6270_registers[0]=(HuC6270_registers[1]&0xff00) | (data); + state->HuC6270_registers[0]=(state->HuC6270_registers[1]&0xff00) | (data); return; case 2: /* VRAM */ - if (HuC6270_vram[(HuC6270_registers[0]<<1)|1]!=data) { - HuC6270_vram[(HuC6270_registers[0]<<1)|1]=data; - gfx_element_mark_dirty(space->machine->gfx[0], HuC6270_registers[0]>>4); - gfx_element_mark_dirty(space->machine->gfx[1], HuC6270_registers[0]>>6); + if (state->HuC6270_vram[(state->HuC6270_registers[0]<<1)|1]!=data) { + state->HuC6270_vram[(state->HuC6270_registers[0]<<1)|1]=data; + gfx_element_mark_dirty(space->machine->gfx[0], state->HuC6270_registers[0]>>4); + gfx_element_mark_dirty(space->machine->gfx[1], state->HuC6270_registers[0]>>6); } - if (HuC6270_registers[0]<0x1000) vram_dirty[HuC6270_registers[0]]=1; + if (state->HuC6270_registers[0]<0x1000) state->vram_dirty[state->HuC6270_registers[0]]=1; return; case 3: break; /* Unused */ @@ -147,23 +143,23 @@ WRITE8_HANDLER( HuC6270_data_w ) case 5: /* CR - Control register */ /* Bits 0,1 unknown */ - rcr_enable=data&0x4; /* Raster interrupt enable */ - irq_enable=data&0x8; /* VBL interrupt enable */ + state->rcr_enable=data&0x4; /* Raster interrupt enable */ + state->irq_enable=data&0x8; /* VBL interrupt enable */ /* Bits 4,5 unknown (EX) */ - sb_enable=data&0x40; /* Sprites enable */ - bb_enable=data&0x80; /* Background enable */ + state->sb_enable=data&0x40; /* Sprites enable */ + state->bb_enable=data&0x80; /* Background enable */ return; case 6: /* RCR - Raster counter register */ - HuC6270_registers[6]=(HuC6270_registers[6]&0xff00) | (data); + state->HuC6270_registers[6]=(state->HuC6270_registers[6]&0xff00) | (data); return; case 7: /* BXR - X scroll */ - HuC6270_registers[7]=(HuC6270_registers[7]&0xff00) | (data); + state->HuC6270_registers[7]=(state->HuC6270_registers[7]&0xff00) | (data); return; case 8: /* BYR - Y scroll */ - HuC6270_registers[8]=(HuC6270_registers[8]&0xff00) | (data); + state->HuC6270_registers[8]=(state->HuC6270_registers[8]&0xff00) | (data); return; case 15: /* DMA */ @@ -174,7 +170,7 @@ WRITE8_HANDLER( HuC6270_data_w ) break; case 19: /* SATB */ - HuC6270_registers[19]=(HuC6270_registers[19]&0xff00) | (data); + state->HuC6270_registers[19]=(state->HuC6270_registers[19]&0xff00) | (data); return; } @@ -183,49 +179,49 @@ WRITE8_HANDLER( HuC6270_data_w ) /*********************************************/ case 1: /* MSB (Autoincrement on this write) */ - switch (VDC_register) { + switch (state->VDC_register) { case 0: /* MAWR - Memory Address Write Register */ - HuC6270_registers[0]=(HuC6270_registers[0]&0xff) | (data<<8); + state->HuC6270_registers[0]=(state->HuC6270_registers[0]&0xff) | (data<<8); return; case 1: /* MARR */ - HuC6270_registers[1]=(HuC6270_registers[1]&0xff) | (data<<8); + state->HuC6270_registers[1]=(state->HuC6270_registers[1]&0xff) | (data<<8); return; case 2: /* VWR - VRAM */ - if (HuC6270_vram[(HuC6270_registers[0]<<1)|0]!=data) { - HuC6270_vram[(HuC6270_registers[0]<<1)|0]=data; - gfx_element_mark_dirty(space->machine->gfx[0], HuC6270_registers[0]>>4); - gfx_element_mark_dirty(space->machine->gfx[1], HuC6270_registers[0]>>6); - if (HuC6270_registers[0]<0x1000) vram_dirty[HuC6270_registers[0]]=1; + if (state->HuC6270_vram[(state->HuC6270_registers[0]<<1)|0]!=data) { + state->HuC6270_vram[(state->HuC6270_registers[0]<<1)|0]=data; + gfx_element_mark_dirty(space->machine->gfx[0], state->HuC6270_registers[0]>>4); + gfx_element_mark_dirty(space->machine->gfx[1], state->HuC6270_registers[0]>>6); + if (state->HuC6270_registers[0]<0x1000) state->vram_dirty[state->HuC6270_registers[0]]=1; } - HuC6270_registers[0]+=inc_value; - HuC6270_registers[0]=HuC6270_registers[0]&0xffff; + state->HuC6270_registers[0]+=state->inc_value; + state->HuC6270_registers[0]=state->HuC6270_registers[0]&0xffff; return; case 5: /* CR */ /* IW - Auto-increment values */ switch ((data>>3)&3) { - case 0: inc_value=1; break; - case 1: inc_value=32;break; - case 2: inc_value=64; break; - case 3: inc_value=128; break; + case 0: state->inc_value=1; break; + case 1: state->inc_value=32;break; + case 2: state->inc_value=64; break; + case 3: state->inc_value=128; break; } /* DR, TE unknown */ return; case 6: /* RCR - Raster counter register */ - HuC6270_registers[6]=(HuC6270_registers[6]&0xff) | (data<<8); + state->HuC6270_registers[6]=(state->HuC6270_registers[6]&0xff) | (data<<8); return; case 7: /* BXR - X scroll */ - HuC6270_registers[7]=(HuC6270_registers[7]&0xff) | (data<<8); + state->HuC6270_registers[7]=(state->HuC6270_registers[7]&0xff) | (data<<8); return; case 8: /* BYR - Y scroll */ - HuC6270_registers[8]=(HuC6270_registers[8]&0xff) | (data<<8); + state->HuC6270_registers[8]=(state->HuC6270_registers[8]&0xff) | (data<<8); return; case 15: /* DMA */ @@ -236,41 +232,42 @@ WRITE8_HANDLER( HuC6270_data_w ) break; case 19: /* SATB - Sprites */ - HuC6270_registers[19]=(HuC6270_registers[19]&0xff) | (data<<8); + state->HuC6270_registers[19]=(state->HuC6270_registers[19]&0xff) | (data<<8); return; } break; } - logerror("%04x: unknown write to VDC_register %02x (%02x) at %02x\n",cpu_get_pc(space->cpu),VDC_register,data,offset); + logerror("%04x: unknown write to state->VDC_register %02x (%02x) at %02x\n",cpu_get_pc(space->cpu),state->VDC_register,data,offset); } /******************************************************************************/ static void draw_sprites(running_machine *machine, bitmap_t *bitmap,const rectangle *clip,int pri) { + battlera_state *state = machine->driver_data(); int offs,my,mx,code,code2,fx,fy,cgy=0,cgx,colour,i,yinc; /* Draw sprites, starting at SATB, draw in _reverse_ order */ - for (offs=(HuC6270_registers[19]<<1)+0x200-8; offs>=(HuC6270_registers[19]<<1); offs-=8) + for (offs=(state->HuC6270_registers[19]<<1)+0x200-8; offs>=(state->HuC6270_registers[19]<<1); offs-=8) { - if ((HuC6270_vram[offs+7]&0x80) && !pri) continue; - if (!(HuC6270_vram[offs+7]&0x80) && pri) continue; + if ((state->HuC6270_vram[offs+7]&0x80) && !pri) continue; + if (!(state->HuC6270_vram[offs+7]&0x80) && pri) continue; - code=HuC6270_vram[offs+5] + (HuC6270_vram[offs+4]<<8); + code=state->HuC6270_vram[offs+5] + (state->HuC6270_vram[offs+4]<<8); code=code>>1; - my=HuC6270_vram[offs+1] + (HuC6270_vram[offs+0]<<8); - mx=HuC6270_vram[offs+3] + (HuC6270_vram[offs+2]<<8); + my=state->HuC6270_vram[offs+1] + (state->HuC6270_vram[offs+0]<<8); + mx=state->HuC6270_vram[offs+3] + (state->HuC6270_vram[offs+2]<<8); mx-=32; my-=57; - fx=HuC6270_vram[offs+6]&0x8; - fy=HuC6270_vram[offs+6]&0x80; - cgx=HuC6270_vram[offs+6]&1; - colour=HuC6270_vram[offs+7]&0xf; + fx=state->HuC6270_vram[offs+6]&0x8; + fy=state->HuC6270_vram[offs+6]&0x80; + cgx=state->HuC6270_vram[offs+6]&1; + colour=state->HuC6270_vram[offs+7]&0xf; - switch ((HuC6270_vram[offs+6]>>4)&3) { + switch ((state->HuC6270_vram[offs+6]>>4)&3) { case 0: cgy=1; break; case 1: cgy=2; break; case 2: cgy=0; break; /* Illegal */ @@ -312,13 +309,14 @@ static void draw_sprites(running_machine *machine, bitmap_t *bitmap,const rectan VIDEO_UPDATE( battlera ) { + battlera_state *state = screen->machine->driver_data(); int offs,code,scrollx,scrolly,mx,my; /* if any tiles changed, redraw the VRAM */ - if (screen->machine->gfx[0]->dirtyseq != tile_dirtyseq) + if (screen->machine->gfx[0]->dirtyseq != state->tile_dirtyseq) { - tile_dirtyseq = screen->machine->gfx[0]->dirtyseq; - memset(vram_dirty, 1, 0x1000); + state->tile_dirtyseq = screen->machine->gfx[0]->dirtyseq; + memset(state->vram_dirty, 1, 0x1000); } mx=-1; @@ -327,45 +325,45 @@ VIDEO_UPDATE( battlera ) { mx++; if (mx==64) {mx=0; my++;} - code=HuC6270_vram[offs+1] + ((HuC6270_vram[offs] & 0x0f) << 8); + code=state->HuC6270_vram[offs+1] + ((state->HuC6270_vram[offs] & 0x0f) << 8); /* If this tile was changed OR tilemap was changed, redraw */ - if (vram_dirty[offs/2]) { - vram_dirty[offs/2]=0; - drawgfx_opaque(tile_bitmap,0,screen->machine->gfx[0], + if (state->vram_dirty[offs/2]) { + state->vram_dirty[offs/2]=0; + drawgfx_opaque(state->tile_bitmap,0,screen->machine->gfx[0], code, - HuC6270_vram[offs] >> 4, + state->HuC6270_vram[offs] >> 4, 0,0, 8*mx,8*my); - drawgfx_opaque(front_bitmap,0,screen->machine->gfx[2], + drawgfx_opaque(state->front_bitmap,0,screen->machine->gfx[2], 0, 0, /* fill the spot with pen 256 */ 0,0, 8*mx,8*my); - drawgfx_transmask(front_bitmap,0,screen->machine->gfx[0], + drawgfx_transmask(state->front_bitmap,0,screen->machine->gfx[0], code, - HuC6270_vram[offs] >> 4, + state->HuC6270_vram[offs] >> 4, 0,0, 8*mx,8*my,0x1); } } /* Render bitmap */ - scrollx=-HuC6270_registers[7]; - scrolly=-HuC6270_registers[8]+cliprect->min_y-1; + scrollx=-state->HuC6270_registers[7]; + scrolly=-state->HuC6270_registers[8]+cliprect->min_y-1; - copyscrollbitmap(bitmap,tile_bitmap,1,&scrollx,1,&scrolly,cliprect); + copyscrollbitmap(bitmap,state->tile_bitmap,1,&scrollx,1,&scrolly,cliprect); /* Todo: Background enable (not used anyway) */ /* Render low priority sprites, if enabled */ - if (sb_enable) draw_sprites(screen->machine,bitmap,cliprect,0); + if (state->sb_enable) draw_sprites(screen->machine,bitmap,cliprect,0); /* Render background over sprites */ - copyscrollbitmap_trans(bitmap,front_bitmap,1,&scrollx,1,&scrolly,cliprect,256); + copyscrollbitmap_trans(bitmap,state->front_bitmap,1,&scrollx,1,&scrolly,cliprect,256); /* Render high priority sprites, if enabled */ - if (sb_enable) draw_sprites(screen->machine,bitmap,cliprect,1); + if (state->sb_enable) draw_sprites(screen->machine,bitmap,cliprect,1); return 0; } @@ -374,24 +372,25 @@ VIDEO_UPDATE( battlera ) INTERRUPT_GEN( battlera_interrupt ) { - current_scanline=255-cpu_getiloops(device); /* 8 lines clipped at top */ + battlera_state *state = device->machine->driver_data(); + state->current_scanline=255-cpu_getiloops(device); /* 8 lines clipped at top */ /* If raster interrupt occurs, refresh screen _up_ to this point */ - if (rcr_enable && (current_scanline+56)==HuC6270_registers[6]) { - device->machine->primary_screen->update_partial(current_scanline); + if (state->rcr_enable && (state->current_scanline+56)==state->HuC6270_registers[6]) { + device->machine->primary_screen->update_partial(state->current_scanline); cpu_set_input_line(device, 0, HOLD_LINE); /* RCR interrupt */ } /* Start of vblank */ - else if (current_scanline==240) { - bldwolf_vblank=1; + else if (state->current_scanline==240) { + state->bldwolf_vblank=1; device->machine->primary_screen->update_partial(240); - if (irq_enable) + if (state->irq_enable) cpu_set_input_line(device, 0, HOLD_LINE); /* VBL */ } /* End of vblank */ - if (current_scanline==254) { - bldwolf_vblank=0; + if (state->current_scanline==254) { + state->bldwolf_vblank=0; } } diff --git a/src/mame/video/bfm_dm01.c b/src/mame/video/bfm_dm01.c index 9f39ea0b2ef..d725b58e80d 100644 --- a/src/mame/video/bfm_dm01.c +++ b/src/mame/video/bfm_dm01.c @@ -38,8 +38,8 @@ Standard dm01 memorymap #include "bfm_dm01.h" // local prototypes /////////////////////////////////////////////////////// -extern void Scorpion2_SetSwitchState(int strobe, int data, int state); -extern int Scorpion2_GetSwitchState(int strobe, int data); +extern void Scorpion2_SetSwitchState(running_machine *machine, int strobe, int data, int state); +extern int Scorpion2_GetSwitchState(running_machine *machine, int strobe, int data); // local vars ///////////////////////////////////////////////////////////// @@ -110,7 +110,7 @@ static WRITE8_HANDLER( control_w ) if ( data & 8 ) busy = 0; else busy = 1; - Scorpion2_SetSwitchState(FEEDBACK_STROBE,FEEDBACK_DATA, busy?0:1); + Scorpion2_SetSwitchState(space->machine, FEEDBACK_STROBE,FEEDBACK_DATA, busy?0:1); } } @@ -247,12 +247,12 @@ int BFM_dm01_busy(void) return data_avail; } -void BFM_dm01_reset(void) +void BFM_dm01_reset(running_machine *machine) { busy = 0; control = 0; xcounter = 0; data_avail = 0; - Scorpion2_SetSwitchState(FEEDBACK_STROBE,FEEDBACK_DATA, busy?0:1); + Scorpion2_SetSwitchState(machine, FEEDBACK_STROBE,FEEDBACK_DATA, busy?0:1); } diff --git a/src/mame/video/bfm_dm01.h b/src/mame/video/bfm_dm01.h index 3718410be2c..cc6fa10d9a3 100644 --- a/src/mame/video/bfm_dm01.h +++ b/src/mame/video/bfm_dm01.h @@ -10,7 +10,7 @@ ADDRESS_MAP_EXTERN( bfm_dm01_memmap,8 ); INTERRUPT_GEN( bfm_dm01_vbl ); -void BFM_dm01_reset(void); +void BFM_dm01_reset(running_machine *machine); void BFM_dm01_writedata(running_machine *machine,UINT8 data); diff --git a/src/mame/video/cchasm.c b/src/mame/video/cchasm.c index 0498fe48e1c..7763c118379 100644 --- a/src/mame/video/cchasm.c +++ b/src/mame/video/cchasm.c @@ -17,9 +17,7 @@ #define POSX 6 #define LENGTH 7 -UINT16 *cchasm_ram; -static int xcenter, ycenter; static TIMER_CALLBACK( cchasm_refresh_end ) { @@ -28,6 +26,7 @@ static TIMER_CALLBACK( cchasm_refresh_end ) static void cchasm_refresh (running_machine *machine) { + cchasm_state *state = machine->driver_data(); int pc = 0; int done = 0; @@ -42,7 +41,7 @@ static void cchasm_refresh (running_machine *machine) while (!done) { - data = cchasm_ram[pc]; + data = state->ram[pc]; opcode = data >> 12; data &= 0xfff; if ((opcode > COLOR) && (data & 0x800)) @@ -67,14 +66,14 @@ static void cchasm_refresh (running_machine *machine) break; case POSY: move = 1; - currenty = ycenter + (data << 16); + currenty = state->ycenter + (data << 16); break; case SCALEX: scalex = data << 5; break; case POSX: move = 1; - currentx = xcenter - (data << 16); + currentx = state->xcenter - (data << 16); break; case LENGTH: if (move) @@ -122,10 +121,11 @@ WRITE16_HANDLER( cchasm_refresh_control_w ) VIDEO_START( cchasm ) { + cchasm_state *state = machine->driver_data(); const rectangle &visarea = machine->primary_screen->visible_area(); - xcenter=((visarea.max_x + visarea.min_x)/2) << 16; - ycenter=((visarea.max_y + visarea.min_y)/2) << 16; + state->xcenter=((visarea.max_x + visarea.min_x)/2) << 16; + state->ycenter=((visarea.max_y + visarea.min_y)/2) << 16; VIDEO_START_CALL(vector); } diff --git a/src/mame/video/cinemat.c b/src/mame/video/cinemat.c index 4b4749805f8..96dfe07be71 100644 --- a/src/mame/video/cinemat.c +++ b/src/mame/video/cinemat.c @@ -27,19 +27,6 @@ enum -/************************************* - * - * Local variables - * - *************************************/ - -static int color_mode; -static rgb_t vector_color; -static INT16 lastx, lasty; -static UINT8 last_control; - - - /************************************* * * Vector rendering @@ -48,6 +35,7 @@ static UINT8 last_control; void cinemat_vector_callback(device_t *device, INT16 sx, INT16 sy, INT16 ex, INT16 ey, UINT8 shift) { + cinemat_state *state = device->machine->driver_data(); const rectangle &visarea = device->machine->primary_screen->visible_area(); int intensity = 0xff; @@ -62,15 +50,15 @@ void cinemat_vector_callback(device_t *device, INT16 sx, INT16 sy, INT16 ex, INT intensity = 0x1ff * shift / 8; /* move to the starting position if we're not there already */ - if (sx != lastx || sy != lasty) + if (sx != state->lastx || sy != state->lasty) vector_add_point(device->machine, sx << 16, sy << 16, 0, 0); /* draw the vector */ - vector_add_point(device->machine, ex << 16, ey << 16, vector_color, intensity); + vector_add_point(device->machine, ex << 16, ey << 16, state->vector_color, intensity); /* remember the last point */ - lastx = ex; - lasty = ey; + state->lastx = ex; + state->lasty = ey; } @@ -83,43 +71,44 @@ void cinemat_vector_callback(device_t *device, INT16 sx, INT16 sy, INT16 ex, INT WRITE8_HANDLER(cinemat_vector_control_w) { + cinemat_state *state = space->machine->driver_data(); int r, g, b, i; cpu_device *cpu = space->machine->device("maincpu"); - switch (color_mode) + switch (state->color_mode) { case COLOR_BILEVEL: /* color is either bright or dim, selected by the value sent to the port */ - vector_color = (data & 1) ? MAKE_RGB(0x80,0x80,0x80) : MAKE_RGB(0xff,0xff,0xff); + state->vector_color = (data & 1) ? MAKE_RGB(0x80,0x80,0x80) : MAKE_RGB(0xff,0xff,0xff); break; case COLOR_16LEVEL: /* on the rising edge of the data value, latch bits 0-3 of the */ /* X register as the intensity */ - if (data != last_control && data) + if (data != state->last_control && data) { int xval = cpu->state(CCPU_X) & 0x0f; i = (xval + 1) * 255 / 16; - vector_color = MAKE_RGB(i,i,i); + state->vector_color = MAKE_RGB(i,i,i); } break; case COLOR_64LEVEL: /* on the rising edge of the data value, latch bits 2-7 of the */ /* X register as the intensity */ - if (data != last_control && data) + if (data != state->last_control && data) { int xval = cpu->state(CCPU_X); xval = (~xval >> 2) & 0x3f; i = (xval + 1) * 255 / 64; - vector_color = MAKE_RGB(i,i,i); + state->vector_color = MAKE_RGB(i,i,i); } break; case COLOR_RGB: /* on the rising edge of the data value, latch the X register */ /* as 4-4-4 BGR values */ - if (data != last_control && data) + if (data != state->last_control && data) { int xval = cpu->state(CCPU_X); r = (~xval >> 0) & 0x0f; @@ -128,27 +117,25 @@ WRITE8_HANDLER(cinemat_vector_control_w) g = g * 255 / 15; b = (~xval >> 8) & 0x0f; b = b * 255 / 15; - vector_color = MAKE_RGB(r,g,b); + state->vector_color = MAKE_RGB(r,g,b); } break; case COLOR_QB3: { - static int lastx, lasty; - /* on the falling edge of the data value, remember the original X,Y values */ /* they will be restored on the rising edge; this is to simulate the fact */ /* that the Rockola color hardware did not overwrite the beam X,Y position */ /* on an IV instruction if data == 0 here */ - if (data != last_control && !data) + if (data != state->last_control && !data) { - lastx = cpu->state(CCPU_X); - lasty = cpu->state(CCPU_Y); + state->qb3_lastx = cpu->state(CCPU_X); + state->qb3_lasty = cpu->state(CCPU_Y); } /* on the rising edge of the data value, latch the Y register */ /* as 2-3-3 BGR values */ - if (data != last_control && data) + if (data != state->last_control && data) { int yval = cpu->state(CCPU_Y); r = (~yval >> 0) & 0x07; @@ -157,18 +144,18 @@ WRITE8_HANDLER(cinemat_vector_control_w) g = g * 255 / 7; b = (~yval >> 6) & 0x03; b = b * 255 / 3; - vector_color = MAKE_RGB(r,g,b); + state->vector_color = MAKE_RGB(r,g,b); /* restore the original X,Y values */ - cpu->set_state(CCPU_X, lastx); - cpu->set_state(CCPU_Y, lasty); + cpu->set_state(CCPU_X, state->qb3_lastx); + cpu->set_state(CCPU_Y, state->qb3_lasty); } } break; } /* remember the last value */ - last_control = data; + state->last_control = data; } @@ -181,35 +168,40 @@ WRITE8_HANDLER(cinemat_vector_control_w) VIDEO_START( cinemat_bilevel ) { - color_mode = COLOR_BILEVEL; + cinemat_state *state = machine->driver_data(); + state->color_mode = COLOR_BILEVEL; VIDEO_START_CALL(vector); } VIDEO_START( cinemat_16level ) { - color_mode = COLOR_16LEVEL; + cinemat_state *state = machine->driver_data(); + state->color_mode = COLOR_16LEVEL; VIDEO_START_CALL(vector); } VIDEO_START( cinemat_64level ) { - color_mode = COLOR_64LEVEL; + cinemat_state *state = machine->driver_data(); + state->color_mode = COLOR_64LEVEL; VIDEO_START_CALL(vector); } VIDEO_START( cinemat_color ) { - color_mode = COLOR_RGB; + cinemat_state *state = machine->driver_data(); + state->color_mode = COLOR_RGB; VIDEO_START_CALL(vector); } VIDEO_START( cinemat_qb3color ) { - color_mode = COLOR_QB3; + cinemat_state *state = machine->driver_data(); + state->color_mode = COLOR_QB3; VIDEO_START_CALL(vector); } diff --git a/src/mame/video/darkseal.c b/src/mame/video/darkseal.c index c26a398244a..1603e0e09f8 100644 --- a/src/mame/video/darkseal.c +++ b/src/mame/video/darkseal.c @@ -88,14 +88,8 @@ Sprites - Data East custom chip 52 #include "emu.h" #include "includes/darkseal.h" -UINT16 *darkseal_pf12_row,*darkseal_pf34_row; -UINT16 *darkseal_pf1_data,*darkseal_pf2_data,*darkseal_pf3_data; -static UINT16 darkseal_control_0[8]; -static UINT16 darkseal_control_1[8]; -static tilemap_t *pf1_tilemap,*pf2_tilemap,*pf3_tilemap; -static int flipscreen; /***************************************************************************/ @@ -121,12 +115,22 @@ INLINE void get_bg_tile_info(running_machine *machine,tile_data *tileinfo,int ti 0); } -static TILE_GET_INFO( get_bg_tile_info2 ) { get_bg_tile_info(machine,tileinfo,tile_index,1,darkseal_pf2_data); } -static TILE_GET_INFO( get_bg_tile_info3 ) { get_bg_tile_info(machine,tileinfo,tile_index,2,darkseal_pf3_data); } +static TILE_GET_INFO( get_bg_tile_info2 ) +{ + darkseal_state *state = machine->driver_data(); + get_bg_tile_info(machine,tileinfo,tile_index,1,state->pf2_data); +} + +static TILE_GET_INFO( get_bg_tile_info3 ) +{ + darkseal_state *state = machine->driver_data(); + get_bg_tile_info(machine,tileinfo,tile_index,2,state->pf3_data); +} static TILE_GET_INFO( get_fg_tile_info ) { - int tile=darkseal_pf1_data[tile_index]; + darkseal_state *state = machine->driver_data(); + int tile=state->pf1_data[tile_index]; int color=tile >> 12; tile=tile&0xfff; @@ -166,6 +170,7 @@ WRITE16_HANDLER( darkseal_palette_24bit_b_w ) static void draw_sprites(running_machine* machine, bitmap_t *bitmap, const rectangle *cliprect) { + darkseal_state *state = machine->driver_data(); UINT16 *buffered_spriteram16 = machine->generic.buffered_spriteram.u16; int offs; @@ -206,7 +211,7 @@ static void draw_sprites(running_machine* machine, bitmap_t *bitmap, const recta inc = 1; } - if (flipscreen) + if (state->flipscreen) { y=240-y; x=240-x; @@ -233,20 +238,23 @@ static void draw_sprites(running_machine* machine, bitmap_t *bitmap, const recta WRITE16_HANDLER( darkseal_pf1_data_w ) { - COMBINE_DATA(&darkseal_pf1_data[offset]); - tilemap_mark_tile_dirty(pf1_tilemap,offset); + darkseal_state *state = space->machine->driver_data(); + COMBINE_DATA(&state->pf1_data[offset]); + tilemap_mark_tile_dirty(state->pf1_tilemap,offset); } WRITE16_HANDLER( darkseal_pf2_data_w ) { - COMBINE_DATA(&darkseal_pf2_data[offset]); - tilemap_mark_tile_dirty(pf2_tilemap,offset); + darkseal_state *state = space->machine->driver_data(); + COMBINE_DATA(&state->pf2_data[offset]); + tilemap_mark_tile_dirty(state->pf2_tilemap,offset); } WRITE16_HANDLER( darkseal_pf3_data_w ) { - COMBINE_DATA(&darkseal_pf3_data[offset]); - tilemap_mark_tile_dirty(pf3_tilemap,offset); + darkseal_state *state = space->machine->driver_data(); + COMBINE_DATA(&state->pf3_data[offset]); + tilemap_mark_tile_dirty(state->pf3_tilemap,offset); } WRITE16_HANDLER( darkseal_pf3b_data_w ) /* Mirror */ @@ -256,56 +264,60 @@ WRITE16_HANDLER( darkseal_pf3b_data_w ) /* Mirror */ WRITE16_HANDLER( darkseal_control_0_w ) { - COMBINE_DATA(&darkseal_control_0[offset]); + darkseal_state *state = space->machine->driver_data(); + COMBINE_DATA(&state->control_0[offset]); } WRITE16_HANDLER( darkseal_control_1_w ) { - COMBINE_DATA(&darkseal_control_1[offset]); + darkseal_state *state = space->machine->driver_data(); + COMBINE_DATA(&state->control_1[offset]); } /******************************************************************************/ VIDEO_START( darkseal ) { - pf1_tilemap = tilemap_create(machine, get_fg_tile_info, tilemap_scan_rows, 8, 8,64,64); - pf2_tilemap = tilemap_create(machine, get_bg_tile_info2,darkseal_scan, 16,16,64,64); - pf3_tilemap = tilemap_create(machine, get_bg_tile_info3,darkseal_scan, 16,16,64,64); + darkseal_state *state = machine->driver_data(); + state->pf1_tilemap = tilemap_create(machine, get_fg_tile_info, tilemap_scan_rows, 8, 8,64,64); + state->pf2_tilemap = tilemap_create(machine, get_bg_tile_info2,darkseal_scan, 16,16,64,64); + state->pf3_tilemap = tilemap_create(machine, get_bg_tile_info3,darkseal_scan, 16,16,64,64); - tilemap_set_transparent_pen(pf1_tilemap,0); - tilemap_set_transparent_pen(pf2_tilemap,0); + tilemap_set_transparent_pen(state->pf1_tilemap,0); + tilemap_set_transparent_pen(state->pf2_tilemap,0); } /******************************************************************************/ VIDEO_UPDATE( darkseal ) { - flipscreen=!(darkseal_control_0[0]&0x80); - tilemap_set_flip_all(screen->machine,flipscreen ? (TILEMAP_FLIPY | TILEMAP_FLIPX) : 0); + darkseal_state *state = screen->machine->driver_data(); + state->flipscreen=!(state->control_0[0]&0x80); + tilemap_set_flip_all(screen->machine,state->flipscreen ? (TILEMAP_FLIPY | TILEMAP_FLIPX) : 0); /* Update scroll registers */ - tilemap_set_scrollx( pf1_tilemap,0, darkseal_control_1[3] ); - tilemap_set_scrolly( pf1_tilemap,0, darkseal_control_1[4] ); - tilemap_set_scrollx( pf2_tilemap,0, darkseal_control_1[1]); - tilemap_set_scrolly( pf2_tilemap,0, darkseal_control_1[2] ); + tilemap_set_scrollx( state->pf1_tilemap,0, state->control_1[3] ); + tilemap_set_scrolly( state->pf1_tilemap,0, state->control_1[4] ); + tilemap_set_scrollx( state->pf2_tilemap,0, state->control_1[1]); + tilemap_set_scrolly( state->pf2_tilemap,0, state->control_1[2] ); - if (darkseal_control_0[6]&0x4000) { /* Rowscroll enable */ - int offs,scrollx=darkseal_control_0[3]; + if (state->control_0[6]&0x4000) { /* Rowscroll enable */ + int offs,scrollx=state->control_0[3]; - tilemap_set_scroll_rows(pf3_tilemap,512); + tilemap_set_scroll_rows(state->pf3_tilemap,512); for (offs = 0;offs < 512;offs++) - tilemap_set_scrollx( pf3_tilemap,offs, scrollx + darkseal_pf34_row[offs+0x40] ); + tilemap_set_scrollx( state->pf3_tilemap,offs, scrollx + state->pf34_row[offs+0x40] ); } else { - tilemap_set_scroll_rows(pf3_tilemap,1); - tilemap_set_scrollx( pf3_tilemap,0, darkseal_control_0[3] ); + tilemap_set_scroll_rows(state->pf3_tilemap,1); + tilemap_set_scrollx( state->pf3_tilemap,0, state->control_0[3] ); } - tilemap_set_scrolly( pf3_tilemap,0, darkseal_control_0[4] ); + tilemap_set_scrolly( state->pf3_tilemap,0, state->control_0[4] ); - tilemap_draw(bitmap,cliprect,pf3_tilemap,0,0); - tilemap_draw(bitmap,cliprect,pf2_tilemap,0,0); + tilemap_draw(bitmap,cliprect,state->pf3_tilemap,0,0); + tilemap_draw(bitmap,cliprect,state->pf2_tilemap,0,0); draw_sprites(screen->machine,bitmap,cliprect); - tilemap_draw(bitmap,cliprect,pf1_tilemap,0,0); + tilemap_draw(bitmap,cliprect,state->pf1_tilemap,0,0); return 0; } diff --git a/src/mame/video/dec0.c b/src/mame/video/dec0.c index f5100a77b98..41101aea8de 100644 --- a/src/mame/video/dec0.c +++ b/src/mame/video/dec0.c @@ -97,27 +97,14 @@ Todo: #include "emu.h" #include "includes/dec0.h" -static tilemap_t *pf1_tilemap_0,*pf1_tilemap_1,*pf1_tilemap_2; -static tilemap_t *pf2_tilemap_0,*pf2_tilemap_1,*pf2_tilemap_2; -static tilemap_t *pf3_tilemap_0,*pf3_tilemap_1,*pf3_tilemap_2; -UINT16 *dec0_pf1_data,*dec0_pf2_data,*dec0_pf3_data; -UINT16 *dec0_pf1_rowscroll,*dec0_pf2_rowscroll,*dec0_pf3_rowscroll; -UINT16 *dec0_pf1_colscroll,*dec0_pf2_colscroll,*dec0_pf3_colscroll; -static UINT16 dec0_pf1_control_0[4]; -static UINT16 dec0_pf1_control_1[4]; -static UINT16 dec0_pf2_control_0[4]; -static UINT16 dec0_pf2_control_1[4]; -static UINT16 dec0_pf3_control_0[4]; -static UINT16 dec0_pf3_control_1[4]; -static UINT16 *dec0_spriteram; -static UINT16 dec0_pri; /******************************************************************************/ WRITE16_HANDLER( dec0_update_sprites_w ) { - memcpy(dec0_spriteram,space->machine->generic.spriteram.u16,0x800); + dec0_state *state = space->machine->driver_data(); + memcpy(state->spriteram,space->machine->generic.spriteram.u16,0x800); } /******************************************************************************/ @@ -149,16 +136,17 @@ WRITE16_HANDLER( dec0_paletteram_b_w ) static void draw_sprites(running_machine* machine, bitmap_t *bitmap,const rectangle *cliprect,int pri_mask,int pri_val) { + dec0_state *state = machine->driver_data(); int offs; for (offs = 0;offs < 0x400;offs += 4) { int x,y,sprite,colour,multi,fx,fy,inc,flash,mult; - y = dec0_spriteram[offs]; + y = state->spriteram[offs]; if ((y&0x8000) == 0) continue; - x = dec0_spriteram[offs+2]; + x = state->spriteram[offs+2]; colour = x >> 12; if ((colour & pri_mask) != pri_val) continue; @@ -170,7 +158,7 @@ static void draw_sprites(running_machine* machine, bitmap_t *bitmap,const rectan multi = (1 << ((y & 0x1800) >> 11)) - 1; /* 1x, 2x, 4x, 8x height */ /* multi = 0 1 3 7 */ - sprite = dec0_spriteram[offs+1] & 0x0fff; + sprite = state->spriteram[offs+1] & 0x0fff; x = x & 0x01ff; y = y & 0x01ff; @@ -299,48 +287,51 @@ static void custom_tilemap_draw(running_machine *machine, static void dec0_pf1_draw(running_machine *machine,bitmap_t *bitmap,const rectangle *cliprect,int flags) { - switch (dec0_pf1_control_0[3]&0x3) { + dec0_state *state = machine->driver_data(); + switch (state->pf1_control_0[3]&0x3) { case 0: /* 4x1 */ - custom_tilemap_draw(machine,bitmap,cliprect,pf1_tilemap_0,dec0_pf1_rowscroll,dec0_pf1_colscroll,dec0_pf1_control_0,dec0_pf1_control_1,flags); + custom_tilemap_draw(machine,bitmap,cliprect,state->pf1_tilemap_0,state->pf1_rowscroll,state->pf1_colscroll,state->pf1_control_0,state->pf1_control_1,flags); break; case 1: /* 2x2 */ default: - custom_tilemap_draw(machine,bitmap,cliprect,pf1_tilemap_1,dec0_pf1_rowscroll,dec0_pf1_colscroll,dec0_pf1_control_0,dec0_pf1_control_1,flags); + custom_tilemap_draw(machine,bitmap,cliprect,state->pf1_tilemap_1,state->pf1_rowscroll,state->pf1_colscroll,state->pf1_control_0,state->pf1_control_1,flags); break; case 2: /* 1x4 */ - custom_tilemap_draw(machine,bitmap,cliprect,pf1_tilemap_2,dec0_pf1_rowscroll,dec0_pf1_colscroll,dec0_pf1_control_0,dec0_pf1_control_1,flags); + custom_tilemap_draw(machine,bitmap,cliprect,state->pf1_tilemap_2,state->pf1_rowscroll,state->pf1_colscroll,state->pf1_control_0,state->pf1_control_1,flags); break; }; } static void dec0_pf2_draw(running_machine *machine,bitmap_t *bitmap,const rectangle *cliprect,int flags) { - switch (dec0_pf2_control_0[3]&0x3) { + dec0_state *state = machine->driver_data(); + switch (state->pf2_control_0[3]&0x3) { case 0: /* 4x1 */ - custom_tilemap_draw(machine,bitmap,cliprect,pf2_tilemap_0,dec0_pf2_rowscroll,dec0_pf2_colscroll,dec0_pf2_control_0,dec0_pf2_control_1,flags); + custom_tilemap_draw(machine,bitmap,cliprect,state->pf2_tilemap_0,state->pf2_rowscroll,state->pf2_colscroll,state->pf2_control_0,state->pf2_control_1,flags); break; case 1: /* 2x2 */ default: - custom_tilemap_draw(machine,bitmap,cliprect,pf2_tilemap_1,dec0_pf2_rowscroll,dec0_pf2_colscroll,dec0_pf2_control_0,dec0_pf2_control_1,flags); + custom_tilemap_draw(machine,bitmap,cliprect,state->pf2_tilemap_1,state->pf2_rowscroll,state->pf2_colscroll,state->pf2_control_0,state->pf2_control_1,flags); break; case 2: /* 1x4 */ - custom_tilemap_draw(machine,bitmap,cliprect,pf2_tilemap_2,dec0_pf2_rowscroll,dec0_pf2_colscroll,dec0_pf2_control_0,dec0_pf2_control_1,flags); + custom_tilemap_draw(machine,bitmap,cliprect,state->pf2_tilemap_2,state->pf2_rowscroll,state->pf2_colscroll,state->pf2_control_0,state->pf2_control_1,flags); break; }; } static void dec0_pf3_draw(running_machine *machine,bitmap_t *bitmap,const rectangle *cliprect,int flags) { - switch (dec0_pf3_control_0[3]&0x3) { + dec0_state *state = machine->driver_data(); + switch (state->pf3_control_0[3]&0x3) { case 0: /* 4x1 */ - custom_tilemap_draw(machine,bitmap,cliprect,pf3_tilemap_0,dec0_pf3_rowscroll,dec0_pf3_colscroll,dec0_pf3_control_0,dec0_pf3_control_1,flags); + custom_tilemap_draw(machine,bitmap,cliprect,state->pf3_tilemap_0,state->pf3_rowscroll,state->pf3_colscroll,state->pf3_control_0,state->pf3_control_1,flags); break; case 1: /* 2x2 */ default: - custom_tilemap_draw(machine,bitmap,cliprect,pf3_tilemap_1,dec0_pf3_rowscroll,dec0_pf3_colscroll,dec0_pf3_control_0,dec0_pf3_control_1,flags); + custom_tilemap_draw(machine,bitmap,cliprect,state->pf3_tilemap_1,state->pf3_rowscroll,state->pf3_colscroll,state->pf3_control_0,state->pf3_control_1,flags); break; case 2: /* 1x4 */ - custom_tilemap_draw(machine,bitmap,cliprect,pf3_tilemap_2,dec0_pf3_rowscroll,dec0_pf3_colscroll,dec0_pf3_control_0,dec0_pf3_control_1,flags); + custom_tilemap_draw(machine,bitmap,cliprect,state->pf3_tilemap_2,state->pf3_rowscroll,state->pf3_colscroll,state->pf3_control_0,state->pf3_control_1,flags); break; }; } @@ -349,7 +340,8 @@ static void dec0_pf3_draw(running_machine *machine,bitmap_t *bitmap,const rectan VIDEO_UPDATE( hbarrel ) { - flip_screen_set(screen->machine, dec0_pf1_control_0[0]&0x80); + dec0_state *state = screen->machine->driver_data(); + flip_screen_set(screen->machine, state->pf1_control_0[0]&0x80); dec0_pf3_draw(screen->machine,bitmap,cliprect,TILEMAP_DRAW_OPAQUE); draw_sprites(screen->machine,bitmap,cliprect,0x08,0x08); @@ -366,20 +358,21 @@ VIDEO_UPDATE( hbarrel ) VIDEO_UPDATE( baddudes ) { - flip_screen_set(screen->machine, dec0_pf1_control_0[0]&0x80); + dec0_state *state = screen->machine->driver_data(); + flip_screen_set(screen->machine, state->pf1_control_0[0]&0x80); /* WARNING: inverted wrt Midnight Resistance */ - if ((dec0_pri & 0x01) == 0) + if ((state->pri & 0x01) == 0) { dec0_pf2_draw(screen->machine,bitmap,cliprect,TILEMAP_DRAW_OPAQUE); dec0_pf3_draw(screen->machine,bitmap,cliprect,0); - if (dec0_pri & 2) + if (state->pri & 2) dec0_pf2_draw(screen->machine,bitmap,cliprect,TILEMAP_DRAW_LAYER0); /* Foreground pens only */ draw_sprites(screen->machine,bitmap,cliprect,0x00,0x00); - if (dec0_pri & 4) + if (state->pri & 4) dec0_pf3_draw(screen->machine,bitmap,cliprect,TILEMAP_DRAW_LAYER0); /* Foreground pens only */ } else @@ -387,12 +380,12 @@ VIDEO_UPDATE( baddudes ) dec0_pf3_draw(screen->machine,bitmap,cliprect,TILEMAP_DRAW_OPAQUE); dec0_pf2_draw(screen->machine,bitmap,cliprect,0); - if (dec0_pri & 2) + if (state->pri & 2) dec0_pf3_draw(screen->machine,bitmap,cliprect,TILEMAP_DRAW_LAYER0); /* Foreground pens only */ draw_sprites(screen->machine,bitmap,cliprect,0x00,0x00); - if (dec0_pri & 4) + if (state->pri & 4) dec0_pf2_draw(screen->machine,bitmap,cliprect,TILEMAP_DRAW_LAYER0); /* Foreground pens only */ } @@ -404,16 +397,17 @@ VIDEO_UPDATE( baddudes ) VIDEO_UPDATE( robocop ) { + dec0_state *state = screen->machine->driver_data(); int trans; - flip_screen_set(screen->machine, dec0_pf1_control_0[0]&0x80); + flip_screen_set(screen->machine, state->pf1_control_0[0]&0x80); - if (dec0_pri & 0x04) + if (state->pri & 0x04) trans = 0x08; else trans = 0x00; - if (dec0_pri & 0x01) + if (state->pri & 0x01) { /* WARNING: inverted wrt Midnight Resistance */ /* Robocop uses it only for the title screen, so this might be just */ @@ -421,7 +415,7 @@ VIDEO_UPDATE( robocop ) /* something (they are 0x80 in midres, 0x00 here) */ dec0_pf2_draw(screen->machine,bitmap,cliprect,TILEMAP_DRAW_LAYER1|TILEMAP_DRAW_OPAQUE); - if (dec0_pri & 0x02) + if (state->pri & 0x02) draw_sprites(screen->machine,bitmap,cliprect,0x08,trans); dec0_pf3_draw(screen->machine,bitmap,cliprect,0); @@ -430,13 +424,13 @@ VIDEO_UPDATE( robocop ) { dec0_pf3_draw(screen->machine,bitmap,cliprect,TILEMAP_DRAW_OPAQUE); - if (dec0_pri & 0x02) + if (state->pri & 0x02) draw_sprites(screen->machine,bitmap,cliprect,0x08,trans); dec0_pf2_draw(screen->machine,bitmap,cliprect,0); } - if (dec0_pri & 0x02) + if (state->pri & 0x02) draw_sprites(screen->machine,bitmap,cliprect,0x08,trans ^ 0x08); else draw_sprites(screen->machine,bitmap,cliprect,0x00,0x00); @@ -449,7 +443,8 @@ VIDEO_UPDATE( robocop ) VIDEO_UPDATE( birdtry ) { - flip_screen_set(screen->machine, dec0_pf1_control_0[0]&0x80); + dec0_state *state = screen->machine->driver_data(); + flip_screen_set(screen->machine, state->pf1_control_0[0]&0x80); /* This game doesn't have the extra playfield chip on the game board, but the palette does show through. */ @@ -464,9 +459,10 @@ VIDEO_UPDATE( birdtry ) VIDEO_UPDATE( hippodrm ) { - flip_screen_set(screen->machine, dec0_pf1_control_0[0]&0x80); + dec0_state *state = screen->machine->driver_data(); + flip_screen_set(screen->machine, state->pf1_control_0[0]&0x80); - if (dec0_pri & 0x01) + if (state->pri & 0x01) { dec0_pf2_draw(screen->machine,bitmap,cliprect,TILEMAP_DRAW_OPAQUE); dec0_pf3_draw(screen->machine,bitmap,cliprect,0); @@ -486,7 +482,8 @@ VIDEO_UPDATE( hippodrm ) VIDEO_UPDATE( slyspy ) { - flip_screen_set(screen->machine, dec0_pf1_control_0[0]&0x80); + dec0_state *state = screen->machine->driver_data(); + flip_screen_set(screen->machine, state->pf1_control_0[0]&0x80); dec0_pf3_draw(screen->machine,bitmap,cliprect,TILEMAP_DRAW_OPAQUE); dec0_pf2_draw(screen->machine,bitmap,cliprect,0); @@ -494,7 +491,7 @@ VIDEO_UPDATE( slyspy ) draw_sprites(screen->machine,bitmap,cliprect,0x00,0x00); /* Redraw top 8 pens of top 8 palettes over sprites */ - if (dec0_pri&0x80) + if (state->pri&0x80) dec0_pf2_draw(screen->machine,bitmap,cliprect,TILEMAP_DRAW_LAYER0); dec0_pf1_draw(screen->machine,bitmap,cliprect,0); @@ -505,19 +502,20 @@ VIDEO_UPDATE( slyspy ) VIDEO_UPDATE( midres ) { + dec0_state *state = screen->machine->driver_data(); int trans; - flip_screen_set(screen->machine, dec0_pf1_control_0[0]&0x80); + flip_screen_set(screen->machine, state->pf1_control_0[0]&0x80); - if (dec0_pri & 0x04) + if (state->pri & 0x04) trans = 0x00; else trans = 0x08; - if (dec0_pri & 0x01) + if (state->pri & 0x01) { dec0_pf2_draw(screen->machine,bitmap,cliprect,TILEMAP_DRAW_OPAQUE); - if (dec0_pri & 0x02) + if (state->pri & 0x02) draw_sprites(screen->machine,bitmap,cliprect,0x08,trans); dec0_pf3_draw(screen->machine,bitmap,cliprect,0); @@ -526,13 +524,13 @@ VIDEO_UPDATE( midres ) { dec0_pf3_draw(screen->machine,bitmap,cliprect,TILEMAP_DRAW_OPAQUE); - if (dec0_pri & 0x02) + if (state->pri & 0x02) draw_sprites(screen->machine,bitmap,cliprect,0x08,trans); dec0_pf2_draw(screen->machine,bitmap,cliprect,0); } - if (dec0_pri & 0x02) + if (state->pri & 0x02) draw_sprites(screen->machine,bitmap,cliprect,0x08,trans ^ 0x08); else draw_sprites(screen->machine,bitmap,cliprect,0x00,0x00); @@ -545,73 +543,83 @@ VIDEO_UPDATE( midres ) WRITE16_HANDLER( dec0_pf1_control_0_w ) { - COMBINE_DATA(&dec0_pf1_control_0[offset]); + dec0_state *state = space->machine->driver_data(); + COMBINE_DATA(&state->pf1_control_0[offset]); } WRITE16_HANDLER( dec0_pf1_control_1_w ) { - COMBINE_DATA(&dec0_pf1_control_1[offset]); + dec0_state *state = space->machine->driver_data(); + COMBINE_DATA(&state->pf1_control_1[offset]); } WRITE16_HANDLER( dec0_pf1_data_w ) { - COMBINE_DATA(&dec0_pf1_data[offset]); - tilemap_mark_tile_dirty(pf1_tilemap_0,offset); - tilemap_mark_tile_dirty(pf1_tilemap_1,offset); - tilemap_mark_tile_dirty(pf1_tilemap_2,offset); + dec0_state *state = space->machine->driver_data(); + COMBINE_DATA(&state->pf1_data[offset]); + tilemap_mark_tile_dirty(state->pf1_tilemap_0,offset); + tilemap_mark_tile_dirty(state->pf1_tilemap_1,offset); + tilemap_mark_tile_dirty(state->pf1_tilemap_2,offset); } WRITE16_HANDLER( dec0_pf2_control_0_w ) { - COMBINE_DATA(&dec0_pf2_control_0[offset]); + dec0_state *state = space->machine->driver_data(); + COMBINE_DATA(&state->pf2_control_0[offset]); } WRITE16_HANDLER( dec0_pf2_control_1_w ) { - COMBINE_DATA(&dec0_pf2_control_1[offset]); + dec0_state *state = space->machine->driver_data(); + COMBINE_DATA(&state->pf2_control_1[offset]); } WRITE16_HANDLER( dec0_pf2_data_w ) { - COMBINE_DATA(&dec0_pf2_data[offset]); - tilemap_mark_tile_dirty(pf2_tilemap_0,offset); - tilemap_mark_tile_dirty(pf2_tilemap_1,offset); - tilemap_mark_tile_dirty(pf2_tilemap_2,offset); + dec0_state *state = space->machine->driver_data(); + COMBINE_DATA(&state->pf2_data[offset]); + tilemap_mark_tile_dirty(state->pf2_tilemap_0,offset); + tilemap_mark_tile_dirty(state->pf2_tilemap_1,offset); + tilemap_mark_tile_dirty(state->pf2_tilemap_2,offset); } WRITE16_HANDLER( dec0_pf3_control_0_w ) { - COMBINE_DATA(&dec0_pf3_control_0[offset]); + dec0_state *state = space->machine->driver_data(); + COMBINE_DATA(&state->pf3_control_0[offset]); } WRITE16_HANDLER( dec0_pf3_control_1_w ) { - COMBINE_DATA(&dec0_pf3_control_1[offset]); + dec0_state *state = space->machine->driver_data(); + COMBINE_DATA(&state->pf3_control_1[offset]); } WRITE16_HANDLER( dec0_pf3_data_w ) { - COMBINE_DATA(&dec0_pf3_data[offset]); - tilemap_mark_tile_dirty(pf3_tilemap_0,offset); - tilemap_mark_tile_dirty(pf3_tilemap_1,offset); - tilemap_mark_tile_dirty(pf3_tilemap_2,offset); + dec0_state *state = space->machine->driver_data(); + COMBINE_DATA(&state->pf3_data[offset]); + tilemap_mark_tile_dirty(state->pf3_tilemap_0,offset); + tilemap_mark_tile_dirty(state->pf3_tilemap_1,offset); + tilemap_mark_tile_dirty(state->pf3_tilemap_2,offset); } WRITE16_HANDLER( dec0_priority_w ) { - COMBINE_DATA(&dec0_pri); + dec0_state *state = space->machine->driver_data(); + COMBINE_DATA(&state->pri); } WRITE8_HANDLER( dec0_pf3_control_8bit_w ) { - static int buffer[0x20]; + dec0_state *state = space->machine->driver_data(); UINT16 myword; - buffer[offset]=data; + state->buffer[offset]=data; /* Rearrange little endian bytes from H6280 into big endian words for 68k */ offset&=0xffe; - myword=buffer[offset] + (buffer[offset+1]<<8); + myword=state->buffer[offset] + (state->buffer[offset+1]<<8); if (offset<0x10) dec0_pf3_control_0_w(space,offset/2,myword,0xffff); else dec0_pf3_control_1_w(space,(offset-0x10)/2,myword,0xffff); @@ -619,27 +627,29 @@ WRITE8_HANDLER( dec0_pf3_control_8bit_w ) WRITE8_HANDLER( dec0_pf3_data_8bit_w ) { + dec0_state *state = space->machine->driver_data(); if (offset&1) { /* MSB has changed */ - UINT16 lsb=dec0_pf3_data[offset>>1]; + UINT16 lsb=state->pf3_data[offset>>1]; UINT16 newword=(lsb&0xff) | (data<<8); - dec0_pf3_data[offset>>1]=newword; + state->pf3_data[offset>>1]=newword; } else { /* LSB has changed */ - UINT16 msb=dec0_pf3_data[offset>>1]; + UINT16 msb=state->pf3_data[offset>>1]; UINT16 newword=(msb&0xff00) | data; - dec0_pf3_data[offset>>1]=newword; + state->pf3_data[offset>>1]=newword; } - tilemap_mark_tile_dirty(pf3_tilemap_0,offset>>1); - tilemap_mark_tile_dirty(pf3_tilemap_1,offset>>1); - tilemap_mark_tile_dirty(pf3_tilemap_2,offset>>1); + tilemap_mark_tile_dirty(state->pf3_tilemap_0,offset>>1); + tilemap_mark_tile_dirty(state->pf3_tilemap_1,offset>>1); + tilemap_mark_tile_dirty(state->pf3_tilemap_2,offset>>1); } READ8_HANDLER( dec0_pf3_data_8bit_r ) { + dec0_state *state = space->machine->driver_data(); if (offset&1) /* MSB */ - return dec0_pf3_data[offset>>1]>>8; + return state->pf3_data[offset>>1]>>8; - return dec0_pf3_data[offset>>1]&0xff; + return state->pf3_data[offset>>1]&0xff; } /******************************************************************************/ @@ -676,13 +686,15 @@ static TILEMAP_MAPPER( tile_shape2_8x8_scan ) static TILE_GET_INFO( get_pf1_tile_info ) { - int tile=dec0_pf1_data[tile_index]; + dec0_state *state = machine->driver_data(); + int tile=state->pf1_data[tile_index]; SET_TILE_INFO(0,tile&0xfff,tile>>12,0); } static TILE_GET_INFO( get_pf2_tile_info ) { - int tile=dec0_pf2_data[tile_index]; + dec0_state *state = machine->driver_data(); + int tile=state->pf2_data[tile_index]; int pri=((tile>>12)>7); SET_TILE_INFO(1,tile&0xfff,tile>>12,0); tileinfo->group = pri; @@ -690,7 +702,8 @@ static TILE_GET_INFO( get_pf2_tile_info ) static TILE_GET_INFO( get_pf3_tile_info ) { - int tile=dec0_pf3_data[tile_index]; + dec0_state *state = machine->driver_data(); + int tile=state->pf3_data[tile_index]; int pri=((tile>>12)>7); SET_TILE_INFO(2,tile&0xfff,tile>>12,0); tileinfo->group = pri; @@ -698,23 +711,25 @@ static TILE_GET_INFO( get_pf3_tile_info ) VIDEO_START( dec0_nodma ) { - pf1_tilemap_0 = tilemap_create(machine, get_pf1_tile_info,tile_shape0_8x8_scan, 8, 8,128, 32); - pf1_tilemap_1 = tilemap_create(machine, get_pf1_tile_info,tile_shape1_8x8_scan, 8, 8, 64, 64); - pf1_tilemap_2 = tilemap_create(machine, get_pf1_tile_info,tile_shape2_8x8_scan, 8, 8, 32,128); - pf2_tilemap_0 = tilemap_create(machine, get_pf2_tile_info,tile_shape0_scan, 16,16, 64, 16); - pf2_tilemap_1 = tilemap_create(machine, get_pf2_tile_info,tile_shape1_scan, 16,16, 32, 32); - pf2_tilemap_2 = tilemap_create(machine, get_pf2_tile_info,tile_shape2_scan, 16,16, 16, 64); - pf3_tilemap_0 = tilemap_create(machine, get_pf3_tile_info,tile_shape0_scan, 16,16, 64, 16); - pf3_tilemap_1 = tilemap_create(machine, get_pf3_tile_info,tile_shape1_scan, 16,16, 32, 32); - pf3_tilemap_2 = tilemap_create(machine, get_pf3_tile_info,tile_shape2_scan, 16,16, 16, 64); + dec0_state *state = machine->driver_data(); + state->pf1_tilemap_0 = tilemap_create(machine, get_pf1_tile_info,tile_shape0_8x8_scan, 8, 8,128, 32); + state->pf1_tilemap_1 = tilemap_create(machine, get_pf1_tile_info,tile_shape1_8x8_scan, 8, 8, 64, 64); + state->pf1_tilemap_2 = tilemap_create(machine, get_pf1_tile_info,tile_shape2_8x8_scan, 8, 8, 32,128); + state->pf2_tilemap_0 = tilemap_create(machine, get_pf2_tile_info,tile_shape0_scan, 16,16, 64, 16); + state->pf2_tilemap_1 = tilemap_create(machine, get_pf2_tile_info,tile_shape1_scan, 16,16, 32, 32); + state->pf2_tilemap_2 = tilemap_create(machine, get_pf2_tile_info,tile_shape2_scan, 16,16, 16, 64); + state->pf3_tilemap_0 = tilemap_create(machine, get_pf3_tile_info,tile_shape0_scan, 16,16, 64, 16); + state->pf3_tilemap_1 = tilemap_create(machine, get_pf3_tile_info,tile_shape1_scan, 16,16, 32, 32); + state->pf3_tilemap_2 = tilemap_create(machine, get_pf3_tile_info,tile_shape2_scan, 16,16, 16, 64); - dec0_spriteram=machine->generic.spriteram.u16; + state->spriteram=machine->generic.spriteram.u16; } VIDEO_START( dec0 ) { + dec0_state *state = machine->driver_data(); VIDEO_START_CALL(dec0_nodma); - dec0_spriteram=auto_alloc_array(machine, UINT16, 0x800/2); + state->spriteram=auto_alloc_array(machine, UINT16, 0x800/2); } /******************************************************************************/ diff --git a/src/mame/video/deco32.c b/src/mame/video/deco32.c index a9cdf3ab545..5fb31e3e9d7 100644 --- a/src/mame/video/deco32.c +++ b/src/mame/video/deco32.c @@ -1,26 +1,6 @@ #include "emu.h" #include "includes/deco32.h" -UINT32 *deco32_pf1_data,*deco32_pf2_data,*deco32_pf3_data,*deco32_pf4_data; -UINT32 *deco32_pf12_control,*deco32_pf34_control; -UINT32 *deco32_pf1_rowscroll,*deco32_pf2_rowscroll,*deco32_pf3_rowscroll,*deco32_pf4_rowscroll; -UINT32 *dragngun_sprite_layout_0_ram, *dragngun_sprite_layout_1_ram; -UINT32 *dragngun_sprite_lookup_0_ram, *dragngun_sprite_lookup_1_ram; -UINT32 *deco32_ace_ram; - -static UINT8 *dirty_palette; -static tilemap_t *pf1_tilemap,*pf1a_tilemap,*pf2_tilemap,*pf3_tilemap,*pf4_tilemap; -static int deco32_pf1_bank,deco32_pf2_bank,deco32_pf3_bank,deco32_pf4_bank; -static int deco32_pf1_flip,deco32_pf2_flip,deco32_pf3_flip,deco32_pf4_flip; -static int deco32_pf2_colourbank,deco32_pf4_colourbank,deco32_pri; - -static bitmap_t *sprite0_mix_bitmap, *sprite1_mix_bitmap, *tilemap_alpha_bitmap; - -static UINT32 dragngun_sprite_ctrl; -static int deco32_ace_ram_dirty, has_ace_ram; - -int deco32_raster_display_position; -UINT16 *deco32_raster_display_list; /****************************************************************************** @@ -28,12 +8,11 @@ UINT16 *deco32_raster_display_list; ******************************************************************************/ -static bitmap_t *sprite_priority_bitmap; -static void deco16_clear_sprite_priority_bitmap(void) +static void deco16_clear_sprite_priority_bitmap(deco32_state *state) { - if (sprite_priority_bitmap) - bitmap_fill(sprite_priority_bitmap,NULL,0); + if (state->sprite_priority_bitmap) + bitmap_fill(state->sprite_priority_bitmap,NULL,0); } /* A special pdrawgfx z-buffered sprite renderer that is needed to properly draw multiple sprite sources with alpha */ @@ -42,6 +21,7 @@ static void deco16_pdrawgfx( UINT32 code,UINT32 color,int flipx,int flipy,int sx,int sy, int transparent_color,UINT32 pri_mask,UINT32 sprite_mask,UINT8 write_pri,UINT8 alpha) { + deco32_state *state = gfx->machine->driver_data(); int ox,oy,cx,cy; int x_index,y_index,x,y; bitmap_t *priority_bitmap = gfx->machine->priority_bitmap; @@ -69,7 +49,7 @@ static void deco16_pdrawgfx( const UINT8 *source = code_base + (y_index * gfx->line_modulo); UINT32 *destb = BITMAP_ADDR32(dest, sy, 0); UINT8 *pri = BITMAP_ADDR8(priority_bitmap, sy, 0); - UINT8 *spri = BITMAP_ADDR8(sprite_priority_bitmap, sy, 0); + UINT8 *spri = BITMAP_ADDR8(state->sprite_priority_bitmap, sy, 0); if (sy >= 0 && sy < 248) { @@ -105,40 +85,46 @@ static void deco16_pdrawgfx( WRITE32_HANDLER( deco32_pf1_data_w ) { - COMBINE_DATA(&deco32_pf1_data[offset]); - tilemap_mark_tile_dirty(pf1_tilemap,offset); - if (pf1a_tilemap && offset<0x400) - tilemap_mark_tile_dirty(pf1a_tilemap,offset); + deco32_state *state = space->machine->driver_data(); + COMBINE_DATA(&state->pf1_data[offset]); + tilemap_mark_tile_dirty(state->pf1_tilemap,offset); + if (state->pf1a_tilemap && offset<0x400) + tilemap_mark_tile_dirty(state->pf1a_tilemap,offset); } WRITE32_HANDLER( deco32_pf2_data_w ) { - COMBINE_DATA(&deco32_pf2_data[offset]); - tilemap_mark_tile_dirty(pf2_tilemap,offset); + deco32_state *state = space->machine->driver_data(); + COMBINE_DATA(&state->pf2_data[offset]); + tilemap_mark_tile_dirty(state->pf2_tilemap,offset); } WRITE32_HANDLER( deco32_pf3_data_w ) { - COMBINE_DATA(&deco32_pf3_data[offset]); - tilemap_mark_tile_dirty(pf3_tilemap,offset); + deco32_state *state = space->machine->driver_data(); + COMBINE_DATA(&state->pf3_data[offset]); + tilemap_mark_tile_dirty(state->pf3_tilemap,offset); } WRITE32_HANDLER( deco32_pf4_data_w ) { - COMBINE_DATA(&deco32_pf4_data[offset]); - tilemap_mark_tile_dirty(pf4_tilemap,offset); + deco32_state *state = space->machine->driver_data(); + COMBINE_DATA(&state->pf4_data[offset]); + tilemap_mark_tile_dirty(state->pf4_tilemap,offset); } /******************************************************************************/ WRITE32_HANDLER( deco32_pri_w ) { - deco32_pri=data; + deco32_state *state = space->machine->driver_data(); + state->pri=data; } WRITE32_HANDLER( dragngun_sprite_control_w ) { - dragngun_sprite_ctrl=data; + deco32_state *state = space->machine->driver_data(); + state->dragngun_sprite_ctrl=data; } WRITE32_HANDLER( dragngun_spriteram_dma_w ) @@ -150,6 +136,7 @@ WRITE32_HANDLER( dragngun_spriteram_dma_w ) WRITE32_HANDLER( deco32_ace_ram_w ) { + deco32_state *state = space->machine->driver_data(); /* Some notes pieced together from Tattoo Assassins info: Bytes 0 to 0x58 - object alpha control? @@ -181,24 +168,25 @@ WRITE32_HANDLER( deco32_ace_ram_w ) 'fadetype' - 1100 for multiplicative fade, 1000 for additive */ - if (offset>=(0x80/4) && (data!=deco32_ace_ram[offset])) - deco32_ace_ram_dirty=1; + if (offset>=(0x80/4) && (data!=state->ace_ram[offset])) + state->ace_ram_dirty=1; - COMBINE_DATA(&deco32_ace_ram[offset]); + COMBINE_DATA(&state->ace_ram[offset]); } static void updateAceRam(running_machine* machine) { + deco32_state *state = machine->driver_data(); int r,g,b,i; - UINT8 fadeptr=deco32_ace_ram[0x20]; - UINT8 fadeptg=deco32_ace_ram[0x21]; - UINT8 fadeptb=deco32_ace_ram[0x22]; - UINT8 fadepsr=deco32_ace_ram[0x23]; - UINT8 fadepsg=deco32_ace_ram[0x24]; - UINT8 fadepsb=deco32_ace_ram[0x25]; -// UINT8 mode=deco32_ace_ram[0x26]; + UINT8 fadeptr=state->ace_ram[0x20]; + UINT8 fadeptg=state->ace_ram[0x21]; + UINT8 fadeptb=state->ace_ram[0x22]; + UINT8 fadepsr=state->ace_ram[0x23]; + UINT8 fadepsg=state->ace_ram[0x24]; + UINT8 fadepsb=state->ace_ram[0x25]; +// UINT8 mode=state->ace_ram[0x26]; - deco32_ace_ram_dirty=0; + state->ace_ram_dirty=0; for (i=0; i<2048; i++) { @@ -239,22 +227,24 @@ WRITE32_HANDLER( deco32_nonbuffered_palette_w ) WRITE32_HANDLER( deco32_buffered_palette_w ) { + deco32_state *state = space->machine->driver_data(); COMBINE_DATA(&space->machine->generic.paletteram.u32[offset]); - dirty_palette[offset]=1; + state->dirty_palette[offset]=1; } WRITE32_HANDLER( deco32_palette_dma_w ) { + deco32_state *state = space->machine->driver_data(); const int m=space->machine->total_colors(); int r,g,b,i; for (i=0; idirty_palette[i]) { + state->dirty_palette[i]=0; - if (has_ace_ram) + if (state->has_ace_ram) { - deco32_ace_ram_dirty=1; + state->ace_ram_dirty=1; } else { @@ -753,6 +743,7 @@ INLINE void dragngun_drawgfxzoom( static void dragngun_draw_sprites(running_machine* machine, bitmap_t *bitmap, const rectangle *cliprect, const UINT32 *spritedata) { + deco32_state *state = machine->driver_data(); const UINT32 *layout_ram; const UINT32 *lookup_ram; int offs; @@ -803,7 +794,7 @@ static void dragngun_draw_sprites(running_machine* machine, bitmap_t *bitmap, co */ /* Sprite global disable bit */ - if (dragngun_sprite_ctrl&0x40000000) + if (state->dragngun_sprite_ctrl&0x40000000) return; for (offs = 0;offs < 0x800;offs += 8) @@ -818,9 +809,9 @@ static void dragngun_draw_sprites(running_machine* machine, bitmap_t *bitmap, co continue; if (spritedata[offs+0]&0x400) - layout_ram = dragngun_sprite_layout_1_ram + ((spritedata[offs+0]&0x1ff)*4); //CHECK! + layout_ram = state->dragngun_sprite_layout_1_ram + ((spritedata[offs+0]&0x1ff)*4); //CHECK! else - layout_ram = dragngun_sprite_layout_0_ram + ((spritedata[offs+0]&0x1ff)*4); //1ff in drag gun code?? + layout_ram = state->dragngun_sprite_layout_0_ram + ((spritedata[offs+0]&0x1ff)*4); //1ff in drag gun code?? h = (layout_ram[1]>>0)&0xf; w = (layout_ram[1]>>4)&0xf; if (!h || !w) @@ -847,9 +838,9 @@ static void dragngun_draw_sprites(running_machine* machine, bitmap_t *bitmap, co // if (spritedata[offs+0]&0x400) if (layout_ram[0]&0x2000) - lookup_ram = dragngun_sprite_lookup_1_ram + (layout_ram[0]&0x1fff); + lookup_ram = state->dragngun_sprite_lookup_1_ram + (layout_ram[0]&0x1fff); else - lookup_ram = dragngun_sprite_lookup_0_ram + (layout_ram[0]&0x1fff); + lookup_ram = state->dragngun_sprite_lookup_0_ram + (layout_ram[0]&0x1fff); zoomx=scalex * 0x10000 / (w*16); zoomy=scaley * 0x10000 / (h*16); @@ -873,10 +864,10 @@ static void dragngun_draw_sprites(running_machine* machine, bitmap_t *bitmap, co /* High bits of the sprite reference into the sprite control bits for banking */ switch (sprite&0x3000) { default: - case 0x0000: sprite=(sprite&0xfff) | ((dragngun_sprite_ctrl&0x000f)<<12); break; - case 0x1000: sprite=(sprite&0xfff) | ((dragngun_sprite_ctrl&0x00f0)<< 8); break; - case 0x2000: sprite=(sprite&0xfff) | ((dragngun_sprite_ctrl&0x0f00)<< 4); break; - case 0x3000: sprite=(sprite&0xfff) | ((dragngun_sprite_ctrl&0xf000)<< 0); break; + case 0x0000: sprite=(sprite&0xfff) | ((state->dragngun_sprite_ctrl&0x000f)<<12); break; + case 0x1000: sprite=(sprite&0xfff) | ((state->dragngun_sprite_ctrl&0x00f0)<< 8); break; + case 0x2000: sprite=(sprite&0xfff) | ((state->dragngun_sprite_ctrl&0x0f00)<< 4); break; + case 0x3000: sprite=(sprite&0xfff) | ((state->dragngun_sprite_ctrl&0xf000)<< 0); break; } /* Because of the unusual interleaved rom layout, we have to mangle the bank bits @@ -936,224 +927,237 @@ static UINT32 deco16_scan_rows(UINT32 col,UINT32 row,UINT32 num_cols,UINT32 num_ static TILE_GET_INFO( get_pf1_tile_info ) { - int tile=deco32_pf1_data[tile_index]; - SET_TILE_INFO(0,(tile&0xfff)|deco32_pf1_bank,(tile>>12)&0xf,0); + deco32_state *state = machine->driver_data(); + int tile=state->pf1_data[tile_index]; + SET_TILE_INFO(0,(tile&0xfff)|state->pf1_bank,(tile>>12)&0xf,0); } static TILE_GET_INFO( get_pf1a_tile_info ) { + deco32_state *state = machine->driver_data(); - int tile=deco32_pf1_data[tile_index]; - SET_TILE_INFO(1,(tile&0xfff)|deco32_pf1_bank,(tile>>12)&0xf,0); + int tile=state->pf1_data[tile_index]; + SET_TILE_INFO(1,(tile&0xfff)|state->pf1_bank,(tile>>12)&0xf,0); } static TILE_GET_INFO( get_pf2_tile_info ) { - UINT32 tile=deco32_pf2_data[tile_index]; + deco32_state *state = machine->driver_data(); + UINT32 tile=state->pf2_data[tile_index]; UINT8 colour=(tile>>12)&0xf; UINT8 flags=0; if (tile&0x8000) { - if ((deco32_pf12_control[6]>>8)&0x01) { + if ((state->pf12_control[6]>>8)&0x01) { flags|=TILE_FLIPX; colour&=0x7; } - if ((deco32_pf12_control[6]>>8)&0x02) { + if ((state->pf12_control[6]>>8)&0x02) { flags|=TILE_FLIPY; colour&=0x7; } } - SET_TILE_INFO(1,(tile&0xfff)|deco32_pf2_bank,colour+deco32_pf2_colourbank,flags); + SET_TILE_INFO(1,(tile&0xfff)|state->pf2_bank,colour+state->pf2_colourbank,flags); } static TILE_GET_INFO( get_pf3_tile_info ) { - UINT32 tile=deco32_pf3_data[tile_index]; + deco32_state *state = machine->driver_data(); + UINT32 tile=state->pf3_data[tile_index]; UINT8 colour=(tile>>12)&0xf; UINT8 flags=0; if (tile&0x8000) { - if ((deco32_pf34_control[6]>>0)&0x01) { + if ((state->pf34_control[6]>>0)&0x01) { flags|=TILE_FLIPX; colour&=0x7; } - if ((deco32_pf34_control[6]>>0)&0x02) { + if ((state->pf34_control[6]>>0)&0x02) { flags|=TILE_FLIPY; colour&=0x7; } } - SET_TILE_INFO(2,(tile&0xfff)|deco32_pf3_bank,colour,flags); + SET_TILE_INFO(2,(tile&0xfff)|state->pf3_bank,colour,flags); } static TILE_GET_INFO( get_pf4_tile_info ) { - UINT32 tile=deco32_pf4_data[tile_index]; + deco32_state *state = machine->driver_data(); + UINT32 tile=state->pf4_data[tile_index]; UINT8 colour=(tile>>12)&0xf; UINT8 flags=0; if (tile&0x8000) { - if ((deco32_pf34_control[6]>>8)&0x01) { + if ((state->pf34_control[6]>>8)&0x01) { flags|=TILE_FLIPX; colour&=0x7; } - if ((deco32_pf34_control[6]>>8)&0x02) { + if ((state->pf34_control[6]>>8)&0x02) { flags|=TILE_FLIPY; colour&=0x7; } } - SET_TILE_INFO(2,(tile&0xfff)|deco32_pf4_bank,colour+deco32_pf4_colourbank,flags); + SET_TILE_INFO(2,(tile&0xfff)|state->pf4_bank,colour+state->pf4_colourbank,flags); } /* Captain America tilemap chip 2 has different banking and colour from normal */ static TILE_GET_INFO( get_ca_pf3_tile_info ) { - int tile=deco32_pf3_data[tile_index]; - SET_TILE_INFO(2,(tile&0x3fff)+deco32_pf3_bank,(tile >> 14)&3,0); + deco32_state *state = machine->driver_data(); + int tile=state->pf3_data[tile_index]; + SET_TILE_INFO(2,(tile&0x3fff)+state->pf3_bank,(tile >> 14)&3,0); } static TILE_GET_INFO( get_ll_pf3_tile_info ) { - UINT32 tile=deco32_pf3_data[tile_index]; + deco32_state *state = machine->driver_data(); + UINT32 tile=state->pf3_data[tile_index]; UINT8 flags=0; if (tile&0x8000) { - if ((deco32_pf34_control[6]>>0)&0x01) + if ((state->pf34_control[6]>>0)&0x01) flags|=TILE_FLIPX; - if ((deco32_pf34_control[6]>>0)&0x02) + if ((state->pf34_control[6]>>0)&0x02) flags|=TILE_FLIPY; } - SET_TILE_INFO(2,(tile&0x0fff)|deco32_pf3_bank,(tile >> 12)&3,flags); + SET_TILE_INFO(2,(tile&0x0fff)|state->pf3_bank,(tile >> 12)&3,flags); } static TILE_GET_INFO( get_ll_pf4_tile_info ) { - UINT32 tile=deco32_pf4_data[tile_index]; + deco32_state *state = machine->driver_data(); + UINT32 tile=state->pf4_data[tile_index]; UINT8 flags=0; if (tile&0x8000) { - if ((deco32_pf34_control[6]>>8)&0x01) + if ((state->pf34_control[6]>>8)&0x01) flags|=TILE_FLIPX; - if ((deco32_pf34_control[6]>>8)&0x02) + if ((state->pf34_control[6]>>8)&0x02) flags|=TILE_FLIPY; } - SET_TILE_INFO(2,(tile&0x0fff)|deco32_pf4_bank,(tile >> 12)&3,flags); + SET_TILE_INFO(2,(tile&0x0fff)|state->pf4_bank,(tile >> 12)&3,flags); } VIDEO_START( captaven ) { - pf1_tilemap = tilemap_create(machine, get_pf1_tile_info, tilemap_scan_rows, 8, 8,64,32); - pf1a_tilemap =tilemap_create(machine, get_pf1a_tile_info, deco16_scan_rows,16,16,64,32); - pf2_tilemap = tilemap_create(machine, get_pf2_tile_info, deco16_scan_rows,16,16,64,32); - pf3_tilemap = tilemap_create(machine, get_ca_pf3_tile_info, tilemap_scan_rows,16,16,32,32); + deco32_state *state = machine->driver_data(); + state->pf1_tilemap = tilemap_create(machine, get_pf1_tile_info, tilemap_scan_rows, 8, 8,64,32); + state->pf1a_tilemap =tilemap_create(machine, get_pf1a_tile_info, deco16_scan_rows,16,16,64,32); + state->pf2_tilemap = tilemap_create(machine, get_pf2_tile_info, deco16_scan_rows,16,16,64,32); + state->pf3_tilemap = tilemap_create(machine, get_ca_pf3_tile_info, tilemap_scan_rows,16,16,32,32); - tilemap_set_transparent_pen(pf1_tilemap,0); - tilemap_set_transparent_pen(pf1a_tilemap,0); - tilemap_set_transparent_pen(pf2_tilemap,0); - tilemap_set_transparent_pen(pf3_tilemap,0); + tilemap_set_transparent_pen(state->pf1_tilemap,0); + tilemap_set_transparent_pen(state->pf1a_tilemap,0); + tilemap_set_transparent_pen(state->pf2_tilemap,0); + tilemap_set_transparent_pen(state->pf3_tilemap,0); - deco32_pf2_colourbank=16; - deco32_pf4_colourbank=0; - has_ace_ram=0; + state->pf2_colourbank=16; + state->pf4_colourbank=0; + state->has_ace_ram=0; } VIDEO_START( fghthist ) { - pf1_tilemap = tilemap_create(machine, get_pf1_tile_info, tilemap_scan_rows, 8, 8,64,32); - pf2_tilemap = tilemap_create(machine, get_pf2_tile_info, deco16_scan_rows, 16,16,64,32); - pf3_tilemap = tilemap_create(machine, get_pf3_tile_info, deco16_scan_rows, 16,16,64,32); - pf4_tilemap = tilemap_create(machine, get_pf4_tile_info, deco16_scan_rows, 16,16,64,32); - pf1a_tilemap =0; - dirty_palette = auto_alloc_array(machine, UINT8, 4096); + deco32_state *state = machine->driver_data(); + state->pf1_tilemap = tilemap_create(machine, get_pf1_tile_info, tilemap_scan_rows, 8, 8,64,32); + state->pf2_tilemap = tilemap_create(machine, get_pf2_tile_info, deco16_scan_rows, 16,16,64,32); + state->pf3_tilemap = tilemap_create(machine, get_pf3_tile_info, deco16_scan_rows, 16,16,64,32); + state->pf4_tilemap = tilemap_create(machine, get_pf4_tile_info, deco16_scan_rows, 16,16,64,32); + state->pf1a_tilemap =0; + state->dirty_palette = auto_alloc_array(machine, UINT8, 4096); /* Allow sprite bitmap */ int width = machine->primary_screen->width(); int height = machine->primary_screen->height(); - sprite_priority_bitmap = auto_bitmap_alloc(machine, width, height, BITMAP_FORMAT_INDEXED16 ); + state->sprite_priority_bitmap = auto_bitmap_alloc(machine, width, height, BITMAP_FORMAT_INDEXED16 ); - tilemap_set_transparent_pen(pf1_tilemap,0); - tilemap_set_transparent_pen(pf2_tilemap,0); - tilemap_set_transparent_pen(pf3_tilemap,0); + tilemap_set_transparent_pen(state->pf1_tilemap,0); + tilemap_set_transparent_pen(state->pf2_tilemap,0); + tilemap_set_transparent_pen(state->pf3_tilemap,0); - deco32_pf2_colourbank=deco32_pf4_colourbank=0; - has_ace_ram=0; + state->pf2_colourbank=state->pf4_colourbank=0; + state->has_ace_ram=0; } VIDEO_START( dragngun ) { - pf1_tilemap = tilemap_create(machine, get_pf1_tile_info, tilemap_scan_rows, 8, 8,64,32); - pf2_tilemap = tilemap_create(machine, get_pf2_tile_info, deco16_scan_rows,16,16,64,32); - pf3_tilemap = tilemap_create(machine, get_ll_pf3_tile_info, deco16_scan_rows,16,16,64,32); - pf4_tilemap = tilemap_create(machine, get_ll_pf4_tile_info, deco16_scan_rows, 16,16,64,32); - pf1a_tilemap =tilemap_create(machine, get_pf1a_tile_info, deco16_scan_rows,16,16,64,32); - dirty_palette = auto_alloc_array(machine, UINT8, 4096); - deco32_raster_display_list = auto_alloc_array(machine, UINT16, 10 * 256 / 2); + deco32_state *state = machine->driver_data(); + state->pf1_tilemap = tilemap_create(machine, get_pf1_tile_info, tilemap_scan_rows, 8, 8,64,32); + state->pf2_tilemap = tilemap_create(machine, get_pf2_tile_info, deco16_scan_rows,16,16,64,32); + state->pf3_tilemap = tilemap_create(machine, get_ll_pf3_tile_info, deco16_scan_rows,16,16,64,32); + state->pf4_tilemap = tilemap_create(machine, get_ll_pf4_tile_info, deco16_scan_rows, 16,16,64,32); + state->pf1a_tilemap =tilemap_create(machine, get_pf1a_tile_info, deco16_scan_rows,16,16,64,32); + state->dirty_palette = auto_alloc_array(machine, UINT8, 4096); + state->raster_display_list = auto_alloc_array(machine, UINT16, 10 * 256 / 2); - tilemap_set_transparent_pen(pf1_tilemap,0); - tilemap_set_transparent_pen(pf2_tilemap,0); - tilemap_set_transparent_pen(pf3_tilemap,0); - tilemap_set_transparent_pen(pf1a_tilemap,0); - memset(dirty_palette,0,4096); + tilemap_set_transparent_pen(state->pf1_tilemap,0); + tilemap_set_transparent_pen(state->pf2_tilemap,0); + tilemap_set_transparent_pen(state->pf3_tilemap,0); + tilemap_set_transparent_pen(state->pf1a_tilemap,0); + memset(state->dirty_palette,0,4096); - deco32_pf2_colourbank=deco32_pf4_colourbank=0; + state->pf2_colourbank=state->pf4_colourbank=0; - state_save_register_global(machine, dragngun_sprite_ctrl); - has_ace_ram=0; + state_save_register_global(machine, state->dragngun_sprite_ctrl); + state->has_ace_ram=0; } VIDEO_START( lockload ) { - pf1_tilemap = tilemap_create(machine, get_pf1_tile_info, tilemap_scan_rows, 8, 8,64,32); - pf2_tilemap = tilemap_create(machine, get_pf2_tile_info, deco16_scan_rows,16,16,64,32); - pf3_tilemap = tilemap_create(machine, get_ll_pf3_tile_info, deco16_scan_rows,16,16,32,32); - pf4_tilemap = tilemap_create(machine, get_ll_pf4_tile_info, deco16_scan_rows, 16,16,32,32); - pf1a_tilemap =tilemap_create(machine, get_pf1a_tile_info, deco16_scan_rows,16,16,64,32); - dirty_palette = auto_alloc_array(machine, UINT8, 4096); - deco32_raster_display_list = auto_alloc_array(machine, UINT16, 10 * 256 / 2); - memset(deco32_raster_display_list, 0, 10 * 256); + deco32_state *state = machine->driver_data(); + state->pf1_tilemap = tilemap_create(machine, get_pf1_tile_info, tilemap_scan_rows, 8, 8,64,32); + state->pf2_tilemap = tilemap_create(machine, get_pf2_tile_info, deco16_scan_rows,16,16,64,32); + state->pf3_tilemap = tilemap_create(machine, get_ll_pf3_tile_info, deco16_scan_rows,16,16,32,32); + state->pf4_tilemap = tilemap_create(machine, get_ll_pf4_tile_info, deco16_scan_rows, 16,16,32,32); + state->pf1a_tilemap =tilemap_create(machine, get_pf1a_tile_info, deco16_scan_rows,16,16,64,32); + state->dirty_palette = auto_alloc_array(machine, UINT8, 4096); + state->raster_display_list = auto_alloc_array(machine, UINT16, 10 * 256 / 2); + memset(state->raster_display_list, 0, 10 * 256); - tilemap_set_transparent_pen(pf1_tilemap,0); - tilemap_set_transparent_pen(pf2_tilemap,0); - tilemap_set_transparent_pen(pf3_tilemap,0); - tilemap_set_transparent_pen(pf1a_tilemap,0); - memset(dirty_palette,0,4096); + tilemap_set_transparent_pen(state->pf1_tilemap,0); + tilemap_set_transparent_pen(state->pf2_tilemap,0); + tilemap_set_transparent_pen(state->pf3_tilemap,0); + tilemap_set_transparent_pen(state->pf1a_tilemap,0); + memset(state->dirty_palette,0,4096); - deco32_pf2_colourbank=deco32_pf4_colourbank=0; + state->pf2_colourbank=state->pf4_colourbank=0; - state_save_register_global(machine, dragngun_sprite_ctrl); - has_ace_ram=0; + state_save_register_global(machine, state->dragngun_sprite_ctrl); + state->has_ace_ram=0; } VIDEO_START( nslasher ) { + deco32_state *state = machine->driver_data(); int width, height; - pf1_tilemap = tilemap_create(machine, get_pf1_tile_info, tilemap_scan_rows, 8, 8,64,32); - pf2_tilemap = tilemap_create(machine, get_pf2_tile_info, deco16_scan_rows,16,16,64,32); - pf3_tilemap = tilemap_create(machine, get_pf3_tile_info, deco16_scan_rows,16,16,64,32); - pf4_tilemap = tilemap_create(machine, get_pf4_tile_info, deco16_scan_rows, 16,16,64,32); - pf1a_tilemap =0; - dirty_palette = auto_alloc_array(machine, UINT8, 4096); + state->pf1_tilemap = tilemap_create(machine, get_pf1_tile_info, tilemap_scan_rows, 8, 8,64,32); + state->pf2_tilemap = tilemap_create(machine, get_pf2_tile_info, deco16_scan_rows,16,16,64,32); + state->pf3_tilemap = tilemap_create(machine, get_pf3_tile_info, deco16_scan_rows,16,16,64,32); + state->pf4_tilemap = tilemap_create(machine, get_pf4_tile_info, deco16_scan_rows, 16,16,64,32); + state->pf1a_tilemap =0; + state->dirty_palette = auto_alloc_array(machine, UINT8, 4096); width = machine->primary_screen->width(); height = machine->primary_screen->height(); - sprite0_mix_bitmap=auto_bitmap_alloc(machine, width, height, BITMAP_FORMAT_INDEXED16 ); - sprite1_mix_bitmap=auto_bitmap_alloc(machine, width, height, BITMAP_FORMAT_INDEXED16 ); - tilemap_alpha_bitmap=auto_bitmap_alloc(machine, width, height, BITMAP_FORMAT_INDEXED16 ); + state->sprite0_mix_bitmap=auto_bitmap_alloc(machine, width, height, BITMAP_FORMAT_INDEXED16 ); + state->sprite1_mix_bitmap=auto_bitmap_alloc(machine, width, height, BITMAP_FORMAT_INDEXED16 ); + state->tilemap_alpha_bitmap=auto_bitmap_alloc(machine, width, height, BITMAP_FORMAT_INDEXED16 ); - tilemap_set_transparent_pen(pf1_tilemap,0); - tilemap_set_transparent_pen(pf2_tilemap,0); - tilemap_set_transparent_pen(pf3_tilemap,0); - memset(dirty_palette,0,4096); + tilemap_set_transparent_pen(state->pf1_tilemap,0); + tilemap_set_transparent_pen(state->pf2_tilemap,0); + tilemap_set_transparent_pen(state->pf3_tilemap,0); + memset(state->dirty_palette,0,4096); - deco32_pf2_colourbank=16; - deco32_pf4_colourbank=16; - state_save_register_global(machine, deco32_pri); - has_ace_ram=1; + state->pf2_colourbank=16; + state->pf4_colourbank=16; + state_save_register_global(machine, state->pri); + state->has_ace_ram=1; } /******************************************************************************/ @@ -1165,22 +1169,24 @@ VIDEO_EOF( captaven ) VIDEO_EOF( dragngun ) { - deco32_raster_display_position=0; + deco32_state *state = machine->driver_data(); + state->raster_display_position=0; } #if 0 static void print_debug_info(bitmap_t *bitmap) { + deco32_state *state = machine->driver_data(); int j; char buf[64*5]; char *bufptr = buf; - bufptr += sprintf(bufptr,"%04X %04X %04X %04X\n",deco32_pf12_control[0]&0xffff,deco32_pf12_control[1]&0xffff,deco32_pf12_control[2]&0xffff,deco32_pf12_control[3]&0xffff); - bufptr += sprintf(bufptr,"%04X %04X %04X %04X\n",deco32_pf12_control[4]&0xffff,deco32_pf12_control[5]&0xffff,deco32_pf12_control[6]&0xffff,deco32_pf12_control[7]&0xffff); + bufptr += sprintf(bufptr,"%04X %04X %04X %04X\n",state->pf12_control[0]&0xffff,state->pf12_control[1]&0xffff,state->pf12_control[2]&0xffff,state->pf12_control[3]&0xffff); + bufptr += sprintf(bufptr,"%04X %04X %04X %04X\n",state->pf12_control[4]&0xffff,state->pf12_control[5]&0xffff,state->pf12_control[6]&0xffff,state->pf12_control[7]&0xffff); - bufptr += sprintf(bufptr,"%04X %04X %04X %04X\n",deco32_pf34_control[0]&0xffff,deco32_pf34_control[1]&0xffff,deco32_pf34_control[2]&0xffff,deco32_pf34_control[3]&0xffff); - bufptr += sprintf(bufptr,"%04X %04X %04X %04X\n",deco32_pf34_control[4]&0xffff,deco32_pf34_control[5]&0xffff,deco32_pf34_control[6]&0xffff,deco32_pf34_control[7]&0xffff); - bufptr += sprintf(bufptr,"%04X\n",deco32_pri); + bufptr += sprintf(bufptr,"%04X %04X %04X %04X\n",state->pf34_control[0]&0xffff,state->pf34_control[1]&0xffff,state->pf34_control[2]&0xffff,state->pf34_control[3]&0xffff); + bufptr += sprintf(bufptr,"%04X %04X %04X %04X\n",state->pf34_control[4]&0xffff,state->pf34_control[5]&0xffff,state->pf34_control[6]&0xffff,state->pf34_control[7]&0xffff); + bufptr += sprintf(bufptr,"%04X\n",state->pri); ui_draw_text(buf,60,40); } @@ -1232,14 +1238,15 @@ static void deco32_setup_scroll(tilemap_t *pf_tilemap, UINT16 height, UINT8 cont static void combined_tilemap_draw(running_machine* machine, bitmap_t *bitmap, const rectangle *cliprect) { - const bitmap_t *bitmap0 = tilemap_get_pixmap(pf3_tilemap); - const bitmap_t *bitmap1 = tilemap_get_pixmap(pf4_tilemap); + deco32_state *state = machine->driver_data(); + const bitmap_t *bitmap0 = tilemap_get_pixmap(state->pf3_tilemap); + const bitmap_t *bitmap1 = tilemap_get_pixmap(state->pf4_tilemap); int x,y,p; const UINT16 width_mask=0x3ff; const UINT16 height_mask=0x1ff; - const UINT16 y_src=deco32_pf34_control[2]; -// const UINT32 *rows=deco32_pf3_rowscroll; + const UINT16 y_src=state->pf34_control[2]; +// const UINT32 *rows=state->pf3_rowscroll; const UINT16 *bitmap0_y; const UINT16 *bitmap1_y; @@ -1255,7 +1262,7 @@ static void combined_tilemap_draw(running_machine* machine, bitmap_t *bitmap, co bitmap2_y=BITMAP_ADDR32(bitmap, y, 0); /* Todo: Should add row enable, and col scroll, but never used as far as I can see */ - x_src=(deco32_pf34_control[1] + deco32_pf3_rowscroll[py])&width_mask; + x_src=(state->pf34_control[1] + state->pf3_rowscroll[py])&width_mask; for (x=0; x<320; x++) { @@ -1275,58 +1282,58 @@ static void combined_tilemap_draw(running_machine* machine, bitmap_t *bitmap, co VIDEO_UPDATE( captaven ) { + deco32_state *state = screen->machine->driver_data(); int pf1_enable,pf2_enable,pf3_enable; - static int last_pf3_bank; - flip_screen_set(screen->machine, deco32_pf12_control[0]&0x80); + flip_screen_set(screen->machine, state->pf12_control[0]&0x80); tilemap_set_flip_all(screen->machine,flip_screen_get(screen->machine) ? (TILEMAP_FLIPY | TILEMAP_FLIPX) : 0); - deco32_setup_scroll(pf1_tilemap, 256,(deco32_pf12_control[5]>>0)&0xff,(deco32_pf12_control[6]>>0)&0xff,deco32_pf12_control[2],deco32_pf12_control[1],deco32_pf1_rowscroll,deco32_pf1_rowscroll+0x200); - deco32_setup_scroll(pf1a_tilemap,512,(deco32_pf12_control[5]>>0)&0xff,(deco32_pf12_control[6]>>0)&0xff,deco32_pf12_control[2],deco32_pf12_control[1],deco32_pf1_rowscroll,deco32_pf1_rowscroll+0x200); - deco32_setup_scroll(pf2_tilemap, 512,(deco32_pf12_control[5]>>8)&0xff,(deco32_pf12_control[6]>>8)&0xff,deco32_pf12_control[4],deco32_pf12_control[3],deco32_pf2_rowscroll,deco32_pf2_rowscroll+0x200); - deco32_setup_scroll(pf3_tilemap, 512,(deco32_pf34_control[5]>>0)&0xff,(deco32_pf34_control[6]>>0)&0xff,deco32_pf34_control[4],deco32_pf34_control[3],deco32_pf3_rowscroll,deco32_pf3_rowscroll+0x200); + deco32_setup_scroll(state->pf1_tilemap, 256,(state->pf12_control[5]>>0)&0xff,(state->pf12_control[6]>>0)&0xff,state->pf12_control[2],state->pf12_control[1],state->pf1_rowscroll,state->pf1_rowscroll+0x200); + deco32_setup_scroll(state->pf1a_tilemap,512,(state->pf12_control[5]>>0)&0xff,(state->pf12_control[6]>>0)&0xff,state->pf12_control[2],state->pf12_control[1],state->pf1_rowscroll,state->pf1_rowscroll+0x200); + deco32_setup_scroll(state->pf2_tilemap, 512,(state->pf12_control[5]>>8)&0xff,(state->pf12_control[6]>>8)&0xff,state->pf12_control[4],state->pf12_control[3],state->pf2_rowscroll,state->pf2_rowscroll+0x200); + deco32_setup_scroll(state->pf3_tilemap, 512,(state->pf34_control[5]>>0)&0xff,(state->pf34_control[6]>>0)&0xff,state->pf34_control[4],state->pf34_control[3],state->pf3_rowscroll,state->pf3_rowscroll+0x200); /* PF1 & PF2 only have enough roms for 1 bank */ - deco32_pf1_bank=0;//(deco32_pf12_control[7]>> 4)&0xf; - deco32_pf2_bank=0;//(deco32_pf12_control[7]>>12)&0xf; - deco32_pf3_bank=(deco32_pf34_control[7]>> 4)&0xf; + state->pf1_bank=0;//(state->pf12_control[7]>> 4)&0xf; + state->pf2_bank=0;//(state->pf12_control[7]>>12)&0xf; + state->pf3_bank=(state->pf34_control[7]>> 4)&0xf; - if (deco32_pf34_control[7]&0x0020) deco32_pf3_bank=0x4000; else deco32_pf3_bank=0; - if (deco32_pf3_bank!=last_pf3_bank) tilemap_mark_all_tiles_dirty(pf3_tilemap); - last_pf3_bank=deco32_pf3_bank; + if (state->pf34_control[7]&0x0020) state->pf3_bank=0x4000; else state->pf3_bank=0; + if (state->pf3_bank!=state->last_pf3_bank) tilemap_mark_all_tiles_dirty(state->pf3_tilemap); + state->last_pf3_bank=state->pf3_bank; - pf1_enable=deco32_pf12_control[5]&0x0080; - pf2_enable=deco32_pf12_control[5]&0x8000; - pf3_enable=deco32_pf34_control[5]&0x0080; + pf1_enable=state->pf12_control[5]&0x0080; + pf2_enable=state->pf12_control[5]&0x8000; + pf3_enable=state->pf34_control[5]&0x0080; - tilemap_set_enable(pf1_tilemap,pf1_enable); - tilemap_set_enable(pf1a_tilemap,pf1_enable); - tilemap_set_enable(pf2_tilemap,pf2_enable); - tilemap_set_enable(pf3_tilemap,pf3_enable); + tilemap_set_enable(state->pf1_tilemap,pf1_enable); + tilemap_set_enable(state->pf1a_tilemap,pf1_enable); + tilemap_set_enable(state->pf2_tilemap,pf2_enable); + tilemap_set_enable(state->pf3_tilemap,pf3_enable); bitmap_fill(screen->machine->priority_bitmap,cliprect,0); - if ((deco32_pri&1)==0) { + if ((state->pri&1)==0) { if (pf3_enable) - tilemap_draw(bitmap,cliprect,pf3_tilemap,TILEMAP_DRAW_OPAQUE,1); + tilemap_draw(bitmap,cliprect,state->pf3_tilemap,TILEMAP_DRAW_OPAQUE,1); else bitmap_fill(bitmap,cliprect,get_black_pen(screen->machine)); - tilemap_draw(bitmap,cliprect,pf2_tilemap,0,2); + tilemap_draw(bitmap,cliprect,state->pf2_tilemap,0,2); } else { if (pf2_enable) { - tilemap_draw(bitmap,cliprect,pf2_tilemap,0,1); + tilemap_draw(bitmap,cliprect,state->pf2_tilemap,0,1); } else bitmap_fill(bitmap,cliprect,get_black_pen(screen->machine)); - tilemap_draw(bitmap,cliprect,pf3_tilemap,0,2); + tilemap_draw(bitmap,cliprect,state->pf3_tilemap,0,2); } /* PF1 can be in 8x8 mode or 16x16 mode */ - if (deco32_pf12_control[6]&0x80) - tilemap_draw(bitmap,cliprect,pf1_tilemap,0,4); + if (state->pf12_control[6]&0x80) + tilemap_draw(bitmap,cliprect,state->pf1_tilemap,0,4); else - tilemap_draw(bitmap,cliprect,pf1a_tilemap,0,4); + tilemap_draw(bitmap,cliprect,state->pf1a_tilemap,0,4); captaven_draw_sprites(screen->machine,bitmap,cliprect,screen->machine->generic.buffered_spriteram.u32,3); @@ -1335,141 +1342,143 @@ VIDEO_UPDATE( captaven ) VIDEO_UPDATE( dragngun ) { + deco32_state *state = screen->machine->driver_data(); /* Tilemap graphics banking */ - if ((((deco32_pf12_control[7]>> 4)&0x7)<<12)!=deco32_pf1_bank || deco32_pf1_flip!=((deco32_pf12_control[6]>>0)&0x3)) { - tilemap_mark_all_tiles_dirty(pf1_tilemap); - tilemap_mark_all_tiles_dirty(pf1a_tilemap); + if ((((state->pf12_control[7]>> 4)&0x7)<<12)!=state->pf1_bank || state->pf1_flip!=((state->pf12_control[6]>>0)&0x3)) { + tilemap_mark_all_tiles_dirty(state->pf1_tilemap); + tilemap_mark_all_tiles_dirty(state->pf1a_tilemap); } - if ((((deco32_pf12_control[7]>>12)&0x7)<<12)!=deco32_pf2_bank || deco32_pf2_flip!=((deco32_pf12_control[6]>>8)&0x3)) - tilemap_mark_all_tiles_dirty(pf2_tilemap); - if ((((deco32_pf34_control[7]>> 5)&0x7)<<12)!=deco32_pf3_bank || deco32_pf3_flip!=((deco32_pf34_control[6]>>0)&0x3)) - tilemap_mark_all_tiles_dirty(pf3_tilemap); - if ((((deco32_pf34_control[7]>>13)&0x7)<<12)!=deco32_pf4_bank || deco32_pf4_flip!=((deco32_pf34_control[6]>>8)&0x3)) - tilemap_mark_all_tiles_dirty(pf4_tilemap); - deco32_pf1_bank=((deco32_pf12_control[7]>> 5)&0x7)<<12; - deco32_pf2_bank=((deco32_pf12_control[7]>>12)&0x7)<<12; - deco32_pf3_bank=((deco32_pf34_control[7]>> 5)&0x7)<<12; - deco32_pf4_bank=((deco32_pf34_control[7]>>13)&0x7)<<12; + if ((((state->pf12_control[7]>>12)&0x7)<<12)!=state->pf2_bank || state->pf2_flip!=((state->pf12_control[6]>>8)&0x3)) + tilemap_mark_all_tiles_dirty(state->pf2_tilemap); + if ((((state->pf34_control[7]>> 5)&0x7)<<12)!=state->pf3_bank || state->pf3_flip!=((state->pf34_control[6]>>0)&0x3)) + tilemap_mark_all_tiles_dirty(state->pf3_tilemap); + if ((((state->pf34_control[7]>>13)&0x7)<<12)!=state->pf4_bank || state->pf4_flip!=((state->pf34_control[6]>>8)&0x3)) + tilemap_mark_all_tiles_dirty(state->pf4_tilemap); + state->pf1_bank=((state->pf12_control[7]>> 5)&0x7)<<12; + state->pf2_bank=((state->pf12_control[7]>>12)&0x7)<<12; + state->pf3_bank=((state->pf34_control[7]>> 5)&0x7)<<12; + state->pf4_bank=((state->pf34_control[7]>>13)&0x7)<<12; - deco32_pf1_flip=(deco32_pf12_control[6]>>0)&0x3; - deco32_pf2_flip=(deco32_pf12_control[6]>>8)&0x3; - deco32_pf3_flip=(deco32_pf34_control[6]>>0)&0x3; - deco32_pf4_flip=(deco32_pf34_control[6]>>8)&0x3; + state->pf1_flip=(state->pf12_control[6]>>0)&0x3; + state->pf2_flip=(state->pf12_control[6]>>8)&0x3; + state->pf3_flip=(state->pf34_control[6]>>0)&0x3; + state->pf4_flip=(state->pf34_control[6]>>8)&0x3; - deco32_setup_scroll(pf1_tilemap, 256,(deco32_pf12_control[5]>>0)&0xff,(deco32_pf12_control[6]>>0)&0xff,deco32_pf12_control[2],deco32_pf12_control[1],deco32_pf1_rowscroll,deco32_pf1_rowscroll+0x200); - deco32_setup_scroll(pf1a_tilemap,512,(deco32_pf12_control[5]>>0)&0xff,(deco32_pf12_control[6]>>0)&0xff,deco32_pf12_control[2],deco32_pf12_control[1],deco32_pf1_rowscroll,deco32_pf1_rowscroll+0x200); - deco32_setup_scroll(pf2_tilemap, 512,(deco32_pf12_control[5]>>8)&0xff,(deco32_pf12_control[6]>>8)&0xff,deco32_pf12_control[4],deco32_pf12_control[3],deco32_pf2_rowscroll,deco32_pf2_rowscroll+0x200); - deco32_setup_scroll(pf3_tilemap, 512,(deco32_pf34_control[5]>>0)&0xff,(deco32_pf34_control[6]>>0)&0xff,deco32_pf34_control[2],deco32_pf34_control[1],deco32_pf3_rowscroll,deco32_pf3_rowscroll+0x200); - deco32_setup_scroll(pf4_tilemap, 512,(deco32_pf34_control[5]>>8)&0xff,(deco32_pf34_control[6]>>8)&0xff,deco32_pf34_control[4],deco32_pf34_control[3],deco32_pf4_rowscroll,deco32_pf4_rowscroll+0x200); + deco32_setup_scroll(state->pf1_tilemap, 256,(state->pf12_control[5]>>0)&0xff,(state->pf12_control[6]>>0)&0xff,state->pf12_control[2],state->pf12_control[1],state->pf1_rowscroll,state->pf1_rowscroll+0x200); + deco32_setup_scroll(state->pf1a_tilemap,512,(state->pf12_control[5]>>0)&0xff,(state->pf12_control[6]>>0)&0xff,state->pf12_control[2],state->pf12_control[1],state->pf1_rowscroll,state->pf1_rowscroll+0x200); + deco32_setup_scroll(state->pf2_tilemap, 512,(state->pf12_control[5]>>8)&0xff,(state->pf12_control[6]>>8)&0xff,state->pf12_control[4],state->pf12_control[3],state->pf2_rowscroll,state->pf2_rowscroll+0x200); + deco32_setup_scroll(state->pf3_tilemap, 512,(state->pf34_control[5]>>0)&0xff,(state->pf34_control[6]>>0)&0xff,state->pf34_control[2],state->pf34_control[1],state->pf3_rowscroll,state->pf3_rowscroll+0x200); + deco32_setup_scroll(state->pf4_tilemap, 512,(state->pf34_control[5]>>8)&0xff,(state->pf34_control[6]>>8)&0xff,state->pf34_control[4],state->pf34_control[3],state->pf4_rowscroll,state->pf4_rowscroll+0x200); - tilemap_set_enable(pf1_tilemap, deco32_pf12_control[5]&0x0080); - tilemap_set_enable(pf1a_tilemap,deco32_pf12_control[5]&0x0080); - tilemap_set_enable(pf2_tilemap, deco32_pf12_control[5]&0x8000); - tilemap_set_enable(pf3_tilemap, deco32_pf34_control[5]&0x0080); - tilemap_set_enable(pf4_tilemap, deco32_pf34_control[5]&0x8000); + tilemap_set_enable(state->pf1_tilemap, state->pf12_control[5]&0x0080); + tilemap_set_enable(state->pf1a_tilemap,state->pf12_control[5]&0x0080); + tilemap_set_enable(state->pf2_tilemap, state->pf12_control[5]&0x8000); + tilemap_set_enable(state->pf3_tilemap, state->pf34_control[5]&0x0080); + tilemap_set_enable(state->pf4_tilemap, state->pf34_control[5]&0x8000); - if ((deco32_pf34_control[5]&0x8000)==0) + if ((state->pf34_control[5]&0x8000)==0) bitmap_fill(bitmap,cliprect,get_black_pen(screen->machine)); - tilemap_draw(bitmap,cliprect,pf4_tilemap,0,0); - tilemap_draw(bitmap,cliprect,pf3_tilemap,0,0); + tilemap_draw(bitmap,cliprect,state->pf4_tilemap,0,0); + tilemap_draw(bitmap,cliprect,state->pf3_tilemap,0,0); /* Raster update */ - if (deco32_raster_display_position) { + if (state->raster_display_position) { int ptr=0,start,end=0; rectangle clip; - int overflow=deco32_raster_display_position; + int overflow=state->raster_display_position; clip.min_x = cliprect->min_x; clip.max_x = cliprect->max_x; /* Finish list up to end of visible display */ - deco32_raster_display_list[overflow++]=255; - deco32_raster_display_list[overflow++]=deco32_pf12_control[1]; - deco32_raster_display_list[overflow++]=deco32_pf12_control[2]; - deco32_raster_display_list[overflow++]=deco32_pf12_control[3]; - deco32_raster_display_list[overflow++]=deco32_pf12_control[4]; + state->raster_display_list[overflow++]=255; + state->raster_display_list[overflow++]=state->pf12_control[1]; + state->raster_display_list[overflow++]=state->pf12_control[2]; + state->raster_display_list[overflow++]=state->pf12_control[3]; + state->raster_display_list[overflow++]=state->pf12_control[4]; while (ptrraster_display_list[ptr++]; + state->pf12_control[1]=state->raster_display_list[ptr++]; + state->pf12_control[2]=state->raster_display_list[ptr++]; + state->pf12_control[3]=state->raster_display_list[ptr++]; + state->pf12_control[4]=state->raster_display_list[ptr++]; clip.min_y = start; clip.max_y = end; - deco32_setup_scroll(pf2_tilemap, 512,(deco32_pf12_control[5]>>8)&0xff,(deco32_pf12_control[6]>>8)&0xff,deco32_pf12_control[4],deco32_pf12_control[3],deco32_pf2_rowscroll,deco32_pf2_rowscroll+0x200); - tilemap_draw(bitmap,&clip,pf2_tilemap,0,0); + deco32_setup_scroll(state->pf2_tilemap, 512,(state->pf12_control[5]>>8)&0xff,(state->pf12_control[6]>>8)&0xff,state->pf12_control[4],state->pf12_control[3],state->pf2_rowscroll,state->pf2_rowscroll+0x200); + tilemap_draw(bitmap,&clip,state->pf2_tilemap,0,0); } } else { - tilemap_draw(bitmap,cliprect,pf2_tilemap,0,0); + tilemap_draw(bitmap,cliprect,state->pf2_tilemap,0,0); } dragngun_draw_sprites(screen->machine,bitmap,cliprect,screen->machine->generic.buffered_spriteram.u32); /* PF1 can be in 8x8 mode or 16x16 mode */ - if (deco32_pf12_control[6]&0x80) - tilemap_draw(bitmap,cliprect,pf1_tilemap,0,0); + if (state->pf12_control[6]&0x80) + tilemap_draw(bitmap,cliprect,state->pf1_tilemap,0,0); else - tilemap_draw(bitmap,cliprect,pf1a_tilemap,0,0); + tilemap_draw(bitmap,cliprect,state->pf1a_tilemap,0,0); return 0; } VIDEO_UPDATE( fghthist ) { + deco32_state *state = screen->machine->driver_data(); /* Dirty tilemaps if any globals change */ - if (deco32_pf1_flip!=((deco32_pf12_control[6]>>0)&0x3)) - tilemap_mark_all_tiles_dirty(pf1_tilemap); - if (deco32_pf2_flip!=((deco32_pf12_control[6]>>8)&0x3)) - tilemap_mark_all_tiles_dirty(pf2_tilemap); + if (state->pf1_flip!=((state->pf12_control[6]>>0)&0x3)) + tilemap_mark_all_tiles_dirty(state->pf1_tilemap); + if (state->pf2_flip!=((state->pf12_control[6]>>8)&0x3)) + tilemap_mark_all_tiles_dirty(state->pf2_tilemap); - if ((((deco32_pf12_control[7]>>13)&0x7)<<12)!=deco32_pf2_bank || deco32_pf2_flip!=((deco32_pf12_control[6]>>8)&0x3)) - tilemap_mark_all_tiles_dirty(pf2_tilemap); - if ((((deco32_pf34_control[7]>> 5)&0x7)<<12)!=deco32_pf3_bank || deco32_pf3_flip!=((deco32_pf34_control[6]>>0)&0x3)) - tilemap_mark_all_tiles_dirty(pf3_tilemap); - if ((((deco32_pf34_control[7]>>13)&0x7)<<12)!=deco32_pf4_bank || deco32_pf4_flip!=((deco32_pf34_control[6]>>8)&0x3)) - tilemap_mark_all_tiles_dirty(pf4_tilemap); + if ((((state->pf12_control[7]>>13)&0x7)<<12)!=state->pf2_bank || state->pf2_flip!=((state->pf12_control[6]>>8)&0x3)) + tilemap_mark_all_tiles_dirty(state->pf2_tilemap); + if ((((state->pf34_control[7]>> 5)&0x7)<<12)!=state->pf3_bank || state->pf3_flip!=((state->pf34_control[6]>>0)&0x3)) + tilemap_mark_all_tiles_dirty(state->pf3_tilemap); + if ((((state->pf34_control[7]>>13)&0x7)<<12)!=state->pf4_bank || state->pf4_flip!=((state->pf34_control[6]>>8)&0x3)) + tilemap_mark_all_tiles_dirty(state->pf4_tilemap); - deco32_pf2_bank=((deco32_pf12_control[7]>>12)&0x3)<<12; - deco32_pf3_bank=((deco32_pf34_control[7]>> 5)&0x3)<<12; //WRONG WRONG WRONG check masks - deco32_pf4_bank=((deco32_pf34_control[7]>>12)&0x3)<<12; - deco32_pf1_flip=(deco32_pf12_control[6]>>0)&0x3; - deco32_pf2_flip=(deco32_pf12_control[6]>>8)&0x3; - deco32_pf3_flip=(deco32_pf34_control[6]>>0)&0x3; - deco32_pf4_flip=(deco32_pf34_control[6]>>8)&0x3; + state->pf2_bank=((state->pf12_control[7]>>12)&0x3)<<12; + state->pf3_bank=((state->pf34_control[7]>> 5)&0x3)<<12; //WRONG WRONG WRONG check masks + state->pf4_bank=((state->pf34_control[7]>>12)&0x3)<<12; + state->pf1_flip=(state->pf12_control[6]>>0)&0x3; + state->pf2_flip=(state->pf12_control[6]>>8)&0x3; + state->pf3_flip=(state->pf34_control[6]>>0)&0x3; + state->pf4_flip=(state->pf34_control[6]>>8)&0x3; /* Enable registers */ - tilemap_set_enable(pf1_tilemap, deco32_pf12_control[5]&0x0080); - tilemap_set_enable(pf2_tilemap, deco32_pf12_control[5]&0x8000); - tilemap_set_enable(pf3_tilemap, deco32_pf34_control[5]&0x0080); - tilemap_set_enable(pf4_tilemap, deco32_pf34_control[5]&0x8000); + tilemap_set_enable(state->pf1_tilemap, state->pf12_control[5]&0x0080); + tilemap_set_enable(state->pf2_tilemap, state->pf12_control[5]&0x8000); + tilemap_set_enable(state->pf3_tilemap, state->pf34_control[5]&0x0080); + tilemap_set_enable(state->pf4_tilemap, state->pf34_control[5]&0x8000); /* Setup scroll registers */ - deco32_setup_scroll(pf1_tilemap, 256,(deco32_pf12_control[5]>>0)&0xff,(deco32_pf12_control[6]>>0)&0xff,deco32_pf12_control[2],deco32_pf12_control[1],deco32_pf1_rowscroll,deco32_pf1_rowscroll+0x200); - deco32_setup_scroll(pf2_tilemap, 512,(deco32_pf12_control[5]>>8)&0xff,(deco32_pf12_control[6]>>8)&0xff,deco32_pf12_control[4],deco32_pf12_control[3],deco32_pf2_rowscroll,deco32_pf2_rowscroll+0x200); - deco32_setup_scroll(pf3_tilemap, 512,(deco32_pf34_control[5]>>0)&0xff,(deco32_pf34_control[6]>>0)&0xff,deco32_pf34_control[2],deco32_pf34_control[1],deco32_pf3_rowscroll,deco32_pf3_rowscroll+0x200); - deco32_setup_scroll(pf4_tilemap, 512,(deco32_pf34_control[5]>>8)&0xff,(deco32_pf34_control[6]>>8)&0xff,deco32_pf34_control[4],deco32_pf34_control[3],deco32_pf4_rowscroll,deco32_pf4_rowscroll+0x200); + deco32_setup_scroll(state->pf1_tilemap, 256,(state->pf12_control[5]>>0)&0xff,(state->pf12_control[6]>>0)&0xff,state->pf12_control[2],state->pf12_control[1],state->pf1_rowscroll,state->pf1_rowscroll+0x200); + deco32_setup_scroll(state->pf2_tilemap, 512,(state->pf12_control[5]>>8)&0xff,(state->pf12_control[6]>>8)&0xff,state->pf12_control[4],state->pf12_control[3],state->pf2_rowscroll,state->pf2_rowscroll+0x200); + deco32_setup_scroll(state->pf3_tilemap, 512,(state->pf34_control[5]>>0)&0xff,(state->pf34_control[6]>>0)&0xff,state->pf34_control[2],state->pf34_control[1],state->pf3_rowscroll,state->pf3_rowscroll+0x200); + deco32_setup_scroll(state->pf4_tilemap, 512,(state->pf34_control[5]>>8)&0xff,(state->pf34_control[6]>>8)&0xff,state->pf34_control[4],state->pf34_control[3],state->pf4_rowscroll,state->pf4_rowscroll+0x200); /* Draw screen */ - deco16_clear_sprite_priority_bitmap(); + deco16_clear_sprite_priority_bitmap(state); bitmap_fill(screen->machine->priority_bitmap,cliprect,0); bitmap_fill(bitmap,cliprect,screen->machine->pens[0x000]); // Palette index not confirmed - tilemap_draw(bitmap,cliprect,pf4_tilemap,0,0); - if(deco32_pri&1) + tilemap_draw(bitmap,cliprect,state->pf4_tilemap,0,0); + if(state->pri&1) { - tilemap_draw(bitmap,cliprect,pf2_tilemap,0,0); - tilemap_draw(bitmap,cliprect,pf3_tilemap,0,2); + tilemap_draw(bitmap,cliprect,state->pf2_tilemap,0,0); + tilemap_draw(bitmap,cliprect,state->pf3_tilemap,0,2); } else { - tilemap_draw(bitmap,cliprect,pf3_tilemap,0,0); - tilemap_draw(bitmap,cliprect,pf2_tilemap,0,2); + tilemap_draw(bitmap,cliprect,state->pf3_tilemap,0,0); + tilemap_draw(bitmap,cliprect,state->pf2_tilemap,0,2); } fghthist_draw_sprites(screen->machine, bitmap, cliprect, screen->machine->generic.buffered_spriteram.u32,3,0, 0xf); - tilemap_draw(bitmap,cliprect,pf1_tilemap,0,0); + tilemap_draw(bitmap,cliprect,state->pf1_tilemap,0,0); return 0; } @@ -1483,20 +1492,21 @@ VIDEO_UPDATE( fghthist ) */ static void mixDualAlphaSprites(bitmap_t *bitmap, const rectangle *cliprect, const gfx_element *gfx0, const gfx_element *gfx1, int mixAlphaTilemap) { + deco32_state *state = gfx0->machine->driver_data(); running_machine *machine = gfx0->machine; const pen_t *pens = machine->pens; const pen_t *pal0 = &pens[gfx0->color_base]; const pen_t *pal1 = &pens[gfx1->color_base]; - const pen_t *pal2 = &pens[machine->gfx[(deco32_pri&1) ? 1 : 2]->color_base]; + const pen_t *pal2 = &pens[machine->gfx[(state->pri&1) ? 1 : 2]->color_base]; int x,y; /* Mix sprites into main bitmap, based on priority & alpha */ for (y=8; y<248; y++) { UINT8* tilemapPri=BITMAP_ADDR8(machine->priority_bitmap, y, 0); - UINT16* sprite0=BITMAP_ADDR16(sprite0_mix_bitmap, y, 0); - UINT16* sprite1=BITMAP_ADDR16(sprite1_mix_bitmap, y, 0); + UINT16* sprite0=BITMAP_ADDR16(state->sprite0_mix_bitmap, y, 0); + UINT16* sprite1=BITMAP_ADDR16(state->sprite1_mix_bitmap, y, 0); UINT32* destLine=BITMAP_ADDR32(bitmap, y, 0); - UINT16* alphaTilemap=BITMAP_ADDR16(tilemap_alpha_bitmap, y, 0); + UINT16* alphaTilemap=BITMAP_ADDR16(state->tilemap_alpha_bitmap, y, 0); for (x=0; x<320; x++) { UINT16 priColAlphaPal0=sprite0[x]; @@ -1550,7 +1560,7 @@ static void mixDualAlphaSprites(bitmap_t *bitmap, const rectangle *cliprect, con */ /* Alpha values are tied to ACE ram... */ - //int alpha=((deco32_ace_ram[0x0 + (((priColAlphaPal1&0xf0)>>4)/2)]) * 8)-1; + //int alpha=((state->ace_ram[0x0 + (((priColAlphaPal1&0xf0)>>4)/2)]) * 8)-1; //if (alpha<0) // alpha=0; @@ -1559,7 +1569,7 @@ static void mixDualAlphaSprites(bitmap_t *bitmap, const rectangle *cliprect, con if (pri1==0 && (((priColAlphaPal0&0xff)==0 || ((pri0&0x3)!=0 && (pri0&0x3)!=1 && (pri0&0x3)!=2)))) { - if ((deco32_pri&1)==0 || ((deco32_pri&1)==1 && tilemapPri[x]<4) || ((deco32_pri&1)==1 && mixAlphaTilemap)) + if ((state->pri&1)==0 || ((state->pri&1)==1 && tilemapPri[x]<4) || ((state->pri&1)==1 && mixAlphaTilemap)) destLine[x]=alpha_blend_r32(destLine[x], pal1[(priColAlphaPal1&0xff) + (gfx1->color_granularity * col1)], 0x80); } else if (pri1==1 && ((priColAlphaPal0&0xff)==0 || ((pri0&0x3)!=0 && (pri0&0x3)!=1 && (pri0&0x3)!=2))) @@ -1598,7 +1608,7 @@ static void mixDualAlphaSprites(bitmap_t *bitmap, const rectangle *cliprect, con && ((priColAlphaPal1&0xff)==0 || (pri1&0x3)==2 || (pri1&0x3)==3 || alpha1)) { /* Alpha values are tied to ACE ram */ - int alpha=((deco32_ace_ram[0x17 + (((p&0xf0)>>4)/2)]) * 8)-1; + int alpha=((state->ace_ram[0x17 + (((p&0xf0)>>4)/2)]) * 8)-1; if (alpha<0) alpha=0; @@ -1612,89 +1622,90 @@ static void mixDualAlphaSprites(bitmap_t *bitmap, const rectangle *cliprect, con VIDEO_UPDATE( nslasher ) { + deco32_state *state = screen->machine->driver_data(); int alphaTilemap=0; /* Dirty tilemaps if any globals change */ - if (deco32_pf1_flip!=((deco32_pf12_control[6]>>0)&0x3)) - tilemap_mark_all_tiles_dirty(pf1_tilemap); - if (deco32_pf2_flip!=((deco32_pf12_control[6]>>8)&0x3)) - tilemap_mark_all_tiles_dirty(pf2_tilemap); - if ((((deco32_pf12_control[7]>>12)&0x7)<<12)!=deco32_pf2_bank || deco32_pf2_flip!=((deco32_pf12_control[6]>>8)&0x3)) - tilemap_mark_all_tiles_dirty(pf2_tilemap); - if ((((deco32_pf34_control[7]>> 4)&0x3)<<12)!=deco32_pf3_bank || deco32_pf3_flip!=((deco32_pf34_control[6]>>0)&0x3)) - tilemap_mark_all_tiles_dirty(pf3_tilemap); - if ((((deco32_pf34_control[7]>>12)&0x3)<<12)!=deco32_pf4_bank || deco32_pf4_flip!=((deco32_pf34_control[6]>>8)&0x3)) - tilemap_mark_all_tiles_dirty(pf4_tilemap); + if (state->pf1_flip!=((state->pf12_control[6]>>0)&0x3)) + tilemap_mark_all_tiles_dirty(state->pf1_tilemap); + if (state->pf2_flip!=((state->pf12_control[6]>>8)&0x3)) + tilemap_mark_all_tiles_dirty(state->pf2_tilemap); + if ((((state->pf12_control[7]>>12)&0x7)<<12)!=state->pf2_bank || state->pf2_flip!=((state->pf12_control[6]>>8)&0x3)) + tilemap_mark_all_tiles_dirty(state->pf2_tilemap); + if ((((state->pf34_control[7]>> 4)&0x3)<<12)!=state->pf3_bank || state->pf3_flip!=((state->pf34_control[6]>>0)&0x3)) + tilemap_mark_all_tiles_dirty(state->pf3_tilemap); + if ((((state->pf34_control[7]>>12)&0x3)<<12)!=state->pf4_bank || state->pf4_flip!=((state->pf34_control[6]>>8)&0x3)) + tilemap_mark_all_tiles_dirty(state->pf4_tilemap); - deco32_pf2_bank=((deco32_pf12_control[7]>>12)&0x3)<<12; - deco32_pf3_bank=((deco32_pf34_control[7]>> 4)&0x3)<<12; - deco32_pf4_bank=((deco32_pf34_control[7]>>12)&0x3)<<12; - deco32_pf1_flip=(deco32_pf12_control[6]>>0)&0x3; - deco32_pf2_flip=(deco32_pf12_control[6]>>8)&0x3; - deco32_pf3_flip=(deco32_pf34_control[6]>>0)&0x3; - deco32_pf4_flip=(deco32_pf34_control[6]>>8)&0x3; + state->pf2_bank=((state->pf12_control[7]>>12)&0x3)<<12; + state->pf3_bank=((state->pf34_control[7]>> 4)&0x3)<<12; + state->pf4_bank=((state->pf34_control[7]>>12)&0x3)<<12; + state->pf1_flip=(state->pf12_control[6]>>0)&0x3; + state->pf2_flip=(state->pf12_control[6]>>8)&0x3; + state->pf3_flip=(state->pf34_control[6]>>0)&0x3; + state->pf4_flip=(state->pf34_control[6]>>8)&0x3; /* Setup scroll registers */ - deco32_setup_scroll(pf1_tilemap, 256,(deco32_pf12_control[5]>>0)&0xff,(deco32_pf12_control[6]>>0)&0xff,deco32_pf12_control[2],deco32_pf12_control[1],deco32_pf1_rowscroll,deco32_pf1_rowscroll+0x200); - deco32_setup_scroll(pf2_tilemap, 512,(deco32_pf12_control[5]>>8)&0xff,(deco32_pf12_control[6]>>8)&0xff,deco32_pf12_control[4],deco32_pf12_control[3],deco32_pf2_rowscroll,deco32_pf2_rowscroll+0x200); - deco32_setup_scroll(pf3_tilemap, 512,(deco32_pf34_control[5]>>0)&0xff,(deco32_pf34_control[6]>>0)&0xff,deco32_pf34_control[2],deco32_pf34_control[1],deco32_pf3_rowscroll,deco32_pf3_rowscroll+0x200); - deco32_setup_scroll(pf4_tilemap, 512,(deco32_pf34_control[5]>>8)&0xff,(deco32_pf34_control[6]>>8)&0xff,deco32_pf34_control[4],deco32_pf34_control[3],deco32_pf4_rowscroll,deco32_pf4_rowscroll+0x200); + deco32_setup_scroll(state->pf1_tilemap, 256,(state->pf12_control[5]>>0)&0xff,(state->pf12_control[6]>>0)&0xff,state->pf12_control[2],state->pf12_control[1],state->pf1_rowscroll,state->pf1_rowscroll+0x200); + deco32_setup_scroll(state->pf2_tilemap, 512,(state->pf12_control[5]>>8)&0xff,(state->pf12_control[6]>>8)&0xff,state->pf12_control[4],state->pf12_control[3],state->pf2_rowscroll,state->pf2_rowscroll+0x200); + deco32_setup_scroll(state->pf3_tilemap, 512,(state->pf34_control[5]>>0)&0xff,(state->pf34_control[6]>>0)&0xff,state->pf34_control[2],state->pf34_control[1],state->pf3_rowscroll,state->pf3_rowscroll+0x200); + deco32_setup_scroll(state->pf4_tilemap, 512,(state->pf34_control[5]>>8)&0xff,(state->pf34_control[6]>>8)&0xff,state->pf34_control[4],state->pf34_control[3],state->pf4_rowscroll,state->pf4_rowscroll+0x200); /* Enable registers */ - tilemap_set_enable(pf1_tilemap, deco32_pf12_control[5]&0x0080); - tilemap_set_enable(pf2_tilemap, deco32_pf12_control[5]&0x8000); - tilemap_set_enable(pf3_tilemap, deco32_pf34_control[5]&0x0080); - tilemap_set_enable(pf4_tilemap, deco32_pf34_control[5]&0x8000); + tilemap_set_enable(state->pf1_tilemap, state->pf12_control[5]&0x0080); + tilemap_set_enable(state->pf2_tilemap, state->pf12_control[5]&0x8000); + tilemap_set_enable(state->pf3_tilemap, state->pf34_control[5]&0x0080); + tilemap_set_enable(state->pf4_tilemap, state->pf34_control[5]&0x8000); /* This is not a conclusive test for deciding if tilemap needs alpha blending */ - if (deco32_ace_ram[0x17]!=0x0 && deco32_pri) + if (state->ace_ram[0x17]!=0x0 && state->pri) alphaTilemap=1; - if (deco32_ace_ram_dirty) + if (state->ace_ram_dirty) updateAceRam(screen->machine); - bitmap_fill(sprite0_mix_bitmap,cliprect,0); - bitmap_fill(sprite1_mix_bitmap,cliprect,0); + bitmap_fill(state->sprite0_mix_bitmap,cliprect,0); + bitmap_fill(state->sprite1_mix_bitmap,cliprect,0); bitmap_fill(screen->machine->priority_bitmap,cliprect,0); - if ((deco32_pf34_control[5]&0x8000)==0) + if ((state->pf34_control[5]&0x8000)==0) bitmap_fill(bitmap,cliprect,screen->machine->pens[0x200]); /* Draw sprites to temporary bitmaps, saving alpha & priority info for later mixing */ - nslasher_draw_sprites(screen->machine,sprite0_mix_bitmap,cliprect,screen->machine->generic.buffered_spriteram.u32,3); - nslasher_draw_sprites(screen->machine,sprite1_mix_bitmap,cliprect,screen->machine->generic.buffered_spriteram2.u32,4); + nslasher_draw_sprites(screen->machine,state->sprite0_mix_bitmap,cliprect,screen->machine->generic.buffered_spriteram.u32,3); + nslasher_draw_sprites(screen->machine,state->sprite1_mix_bitmap,cliprect,screen->machine->generic.buffered_spriteram2.u32,4); /* Render alpha-blended tilemap to seperate buffer for proper mixing */ - bitmap_fill(tilemap_alpha_bitmap,cliprect,0); + bitmap_fill(state->tilemap_alpha_bitmap,cliprect,0); /* Draw playfields & sprites */ - if (deco32_pri&2) + if (state->pri&2) { combined_tilemap_draw(screen->machine,bitmap,cliprect); - tilemap_draw(bitmap,cliprect,pf2_tilemap,0,4); + tilemap_draw(bitmap,cliprect,state->pf2_tilemap,0,4); } else { - tilemap_draw(bitmap,cliprect,pf4_tilemap,0,1); - if (deco32_pri&1) + tilemap_draw(bitmap,cliprect,state->pf4_tilemap,0,1); + if (state->pri&1) { - tilemap_draw(bitmap,cliprect,pf2_tilemap,0,2); + tilemap_draw(bitmap,cliprect,state->pf2_tilemap,0,2); if (alphaTilemap) - tilemap_draw(tilemap_alpha_bitmap,cliprect,pf3_tilemap,0,4); + tilemap_draw(state->tilemap_alpha_bitmap,cliprect,state->pf3_tilemap,0,4); else - tilemap_draw(bitmap,cliprect,pf3_tilemap,0,4); + tilemap_draw(bitmap,cliprect,state->pf3_tilemap,0,4); } else { - tilemap_draw(bitmap,cliprect,pf3_tilemap,0,2); + tilemap_draw(bitmap,cliprect,state->pf3_tilemap,0,2); if (alphaTilemap) - tilemap_draw(tilemap_alpha_bitmap,cliprect,pf2_tilemap,0,4); + tilemap_draw(state->tilemap_alpha_bitmap,cliprect,state->pf2_tilemap,0,4); else - tilemap_draw(bitmap,cliprect,pf2_tilemap,0,4); + tilemap_draw(bitmap,cliprect,state->pf2_tilemap,0,4); } } mixDualAlphaSprites(bitmap, cliprect, screen->machine->gfx[3], screen->machine->gfx[4], alphaTilemap); - tilemap_draw(bitmap,cliprect,pf1_tilemap,0,0); + tilemap_draw(bitmap,cliprect,state->pf1_tilemap,0,0); return 0; } diff --git a/src/mame/video/deco_mlc.c b/src/mame/video/deco_mlc.c index 0cf7bdd28f4..41b2c70fea7 100644 --- a/src/mame/video/deco_mlc.c +++ b/src/mame/video/deco_mlc.c @@ -14,33 +14,33 @@ //extern int mlc_raster_table[9][256]; //extern UINT32 mlc_clipper[32]; //static bitmap_t *temp_bitmap; -static UINT32 colour_mask, *mlc_buffered_spriteram; -UINT32 *mlc_vram, *mlc_clip_ram; /******************************************************************************/ VIDEO_START( mlc ) { + deco_mlc_state *state = machine->driver_data(); if (machine->gfx[0]->color_granularity==16) - colour_mask=0x7f; + state->colour_mask=0x7f; else if (machine->gfx[0]->color_granularity==32) - colour_mask=0x3f; + state->colour_mask=0x3f; else - colour_mask=0x1f; + state->colour_mask=0x1f; // temp_bitmap = auto_bitmap_alloc( machine, 512, 512, BITMAP_FORMAT_RGB32 ); - mlc_buffered_spriteram = auto_alloc_array(machine, UINT32, 0x3000/4); + state->mlc_buffered_spriteram = auto_alloc_array(machine, UINT32, 0x3000/4); } #ifdef UNUSED_FUNCTION static void blitRaster(running_machine *machine, bitmap_t *bitmap, int rasterMode) { + deco_mlc_state *state = machine->driver_data(); int x,y; for (y=0; y<256; y++) //todo { UINT32* src=BITMAP_ADDR32(temp_bitmap, y&0x1ff, 0); UINT32* dst=BITMAP_ADDR32(bitmap, y, 0); - UINT32 xptr=(mlc_raster_table[0][y]<<13); + UINT32 xptr=(state->mlc_raster_table[0][y]<<13); if (input_code_pressed(machine, KEYCODE_X)) xptr=0; @@ -53,9 +53,9 @@ static void blitRaster(running_machine *machine, bitmap_t *bitmap, int rasterMod //if (input_code_pressed(machine, KEYCODE_X)) // xptr+=0x10000; //else if(rasterHackTest[0][y]<0) - xptr+=0x10000 - ((mlc_raster_table[2][y]&0x3ff)<<5); + xptr+=0x10000 - ((state->mlc_raster_table[2][y]&0x3ff)<<5); //else - // xptr+=0x10000 + (mlc_raster_table[0][y]<<5); + // xptr+=0x10000 + (state->mlc_raster_table[0][y]<<5); } } } @@ -227,6 +227,7 @@ static void mlc_drawgfxzoom( static void draw_sprites(running_machine* machine, bitmap_t *bitmap,const rectangle *cliprect) { + deco_mlc_state *state = machine->driver_data(); UINT32 *index_ptr=0; int offs,fx=0,fy=0,x,y,color,colorOffset,sprite,indx,h,w,bx,by,fx1,fy1; int xoffs,yoffs; @@ -245,7 +246,7 @@ static void draw_sprites(running_machine* machine, bitmap_t *bitmap,const rectan // int rasterDirty=0; int clipper=0; rectangle user_clip; - UINT32* mlc_spriteram=mlc_buffered_spriteram; // spriteram32 + UINT32* mlc_spriteram=state->mlc_buffered_spriteram; // spriteram32 for (offs = (0x3000/4)-8; offs>=0; offs-=8) { @@ -312,19 +313,19 @@ static void draw_sprites(running_machine* machine, bitmap_t *bitmap,const rectan however there are space for 8 clipping windows, where is the high bit? (Or is it ~0x400?) */ clipper=((clipper&2)>>1)|((clipper&1)<<1); // Swap low two bits - user_clip.min_y=mlc_clip_ram[(clipper*4)+0]; - user_clip.max_y=mlc_clip_ram[(clipper*4)+1]; - user_clip.min_x=mlc_clip_ram[(clipper*4)+2]; - user_clip.max_x=mlc_clip_ram[(clipper*4)+3]; + user_clip.min_y=state->mlc_clip_ram[(clipper*4)+0]; + user_clip.max_y=state->mlc_clip_ram[(clipper*4)+1]; + user_clip.min_x=state->mlc_clip_ram[(clipper*4)+2]; + user_clip.max_x=state->mlc_clip_ram[(clipper*4)+3]; sect_rect(&user_clip, cliprect); /* Any colours out of range (for the bpp value) trigger 'shadow' mode */ - if (color & (colour_mask+1)) + if (color & (state->colour_mask+1)) alpha=0x80; else alpha=0xff; - color&=colour_mask; + color&=state->colour_mask; /* If this bit is set, combine this block with the next one */ if (mlc_spriteram[offs+1]&0x1000) { @@ -371,7 +372,7 @@ static void draw_sprites(running_machine* machine, bitmap_t *bitmap,const rectan } else { indx&=0x1fff; - index_ptr=mlc_vram + indx*4; + index_ptr=state->mlc_vram + indx*4; h=(index_ptr[0]>>8)&0xf; w=(index_ptr[1]>>8)&0xf; @@ -379,7 +380,7 @@ static void draw_sprites(running_machine* machine, bitmap_t *bitmap,const rectan if (!w) w=16; if (use8bppMode) { - UINT32* index_ptr2=mlc_vram + ((indx2*4)&0x7fff); + UINT32* index_ptr2=state->mlc_vram + ((indx2*4)&0x7fff); sprite2=((index_ptr2[2]&0x3)<<16) | (index_ptr2[3]&0xffff); } @@ -459,7 +460,7 @@ static void draw_sprites(running_machine* machine, bitmap_t *bitmap,const rectan } else { - const UINT32* ptr=mlc_vram + ((sprite)&0x7fff); + const UINT32* ptr=state->mlc_vram + ((sprite)&0x7fff); tile=(*ptr)&0xffff; if (tileFormat) @@ -510,12 +511,13 @@ static void draw_sprites(running_machine* machine, bitmap_t *bitmap,const rectan VIDEO_EOF( mlc ) { + deco_mlc_state *state = machine->driver_data(); /* Spriteram is definitely double buffered, as the vram lookup tables are often updated a frame after spriteram is setup to point to a new lookup table. Without buffering incorrect one frame glitches are seen in several places, especially in Hoops. */ - memcpy(mlc_buffered_spriteram, machine->generic.spriteram.u32, 0x3000); + memcpy(state->mlc_buffered_spriteram, machine->generic.spriteram.u32, 0x3000); } VIDEO_UPDATE( mlc ) diff --git a/src/mame/video/madalien.c b/src/mame/video/madalien.c index ab91718edd3..818b4ab06bc 100644 --- a/src/mame/video/madalien.c +++ b/src/mame/video/madalien.c @@ -14,24 +14,6 @@ #define PIXEL_CLOCK (MADALIEN_MAIN_CLOCK / 2) -UINT8 *madalien_videoram; -UINT8 *madalien_charram; - -UINT8 *madalien_video_flags; -UINT8 *madalien_video_control; /* bit #0 is set during player 2's turn, bit #3 is set during CRTC initialization */ -UINT8 *madalien_scroll; -UINT8 *madalien_edge1_pos; -UINT8 *madalien_edge2_pos; -UINT8 *madalien_headlight_pos; - -static tilemap_t *tilemap_fg; - -static tilemap_t *tilemap_edge1[4]; -static tilemap_t *tilemap_edge2[4]; - -static bitmap_t *headlight_bitmap; - - static PALETTE_INIT( madalien ) { int i; @@ -108,34 +90,39 @@ static TILEMAP_MAPPER( scan_mode3 ) static TILE_GET_INFO( get_tile_info_BG_1 ) { - UINT8 *map = machine->region("user1")->base() + ((*madalien_video_flags & 0x08) << 6); + madalien_state *state = machine->driver_data(); + UINT8 *map = machine->region("user1")->base() + ((*state->video_flags & 0x08) << 6); - SET_TILE_INFO(1, map[tile_index], BIT(*madalien_video_flags, 2) ? 2 : 0, 0); + SET_TILE_INFO(1, map[tile_index], BIT(*state->video_flags, 2) ? 2 : 0, 0); } static TILE_GET_INFO( get_tile_info_BG_2 ) { - UINT8 *map = machine->region("user1")->base() + ((*madalien_video_flags & 0x08) << 6) + 0x80; + madalien_state *state = machine->driver_data(); + UINT8 *map = machine->region("user1")->base() + ((*state->video_flags & 0x08) << 6) + 0x80; - SET_TILE_INFO(1, map[tile_index], BIT(*madalien_video_flags, 2) ? 2 : 0, 0); + SET_TILE_INFO(1, map[tile_index], BIT(*state->video_flags, 2) ? 2 : 0, 0); } static TILE_GET_INFO( get_tile_info_FG ) { - SET_TILE_INFO(0, madalien_videoram[tile_index], 0, 0); + madalien_state *state = machine->driver_data(); + SET_TILE_INFO(0, state->videoram[tile_index], 0, 0); } WRITE8_HANDLER( madalien_videoram_w ) { - madalien_videoram[offset] = data; - tilemap_mark_tile_dirty(tilemap_fg, offset); + madalien_state *state = space->machine->driver_data(); + state->videoram[offset] = data; + tilemap_mark_tile_dirty(state->tilemap_fg, offset); } static VIDEO_START( madalien ) { + madalien_state *state = machine->driver_data(); int i; static const tilemap_mapper_func scan_functions[4] = @@ -148,33 +135,34 @@ static VIDEO_START( madalien ) 16, 16, 32, 32 }; - tilemap_fg = tilemap_create(machine, get_tile_info_FG, tilemap_scan_cols_flip_x, 8, 8, 32, 32); - tilemap_set_transparent_pen(tilemap_fg, 0); - tilemap_set_scrolldx(tilemap_fg, 0, 0x50); - tilemap_set_scrolldy(tilemap_fg, 0, 0x20); + state->tilemap_fg = tilemap_create(machine, get_tile_info_FG, tilemap_scan_cols_flip_x, 8, 8, 32, 32); + tilemap_set_transparent_pen(state->tilemap_fg, 0); + tilemap_set_scrolldx(state->tilemap_fg, 0, 0x50); + tilemap_set_scrolldy(state->tilemap_fg, 0, 0x20); for (i = 0; i < 4; i++) { - tilemap_edge1[i] = tilemap_create(machine, get_tile_info_BG_1, scan_functions[i], 16, 16, tilemap_cols[i], 8); - tilemap_set_scrolldx(tilemap_edge1[i], 0, 0x50); - tilemap_set_scrolldy(tilemap_edge1[i], 0, 0x20); + state->tilemap_edge1[i] = tilemap_create(machine, get_tile_info_BG_1, scan_functions[i], 16, 16, tilemap_cols[i], 8); + tilemap_set_scrolldx(state->tilemap_edge1[i], 0, 0x50); + tilemap_set_scrolldy(state->tilemap_edge1[i], 0, 0x20); - tilemap_edge2[i] = tilemap_create(machine, get_tile_info_BG_2, scan_functions[i], 16, 16, tilemap_cols[i], 8); - tilemap_set_scrolldx(tilemap_edge2[i], 0, 0x50); - tilemap_set_scrolldy(tilemap_edge2[i], 0, machine->primary_screen->height() - 256); + state->tilemap_edge2[i] = tilemap_create(machine, get_tile_info_BG_2, scan_functions[i], 16, 16, tilemap_cols[i], 8); + tilemap_set_scrolldx(state->tilemap_edge2[i], 0, 0x50); + tilemap_set_scrolldy(state->tilemap_edge2[i], 0, machine->primary_screen->height() - 256); } - headlight_bitmap = auto_bitmap_alloc(machine, 128, 128, BITMAP_FORMAT_INDEXED16); + state->headlight_bitmap = auto_bitmap_alloc(machine, 128, 128, BITMAP_FORMAT_INDEXED16); - gfx_element_set_source(machine->gfx[0], madalien_charram); + gfx_element_set_source(machine->gfx[0], state->charram); - drawgfx_opaque(headlight_bitmap, NULL, machine->gfx[2], 0, 0, 0, 0, 0x00, 0x00); - drawgfx_opaque(headlight_bitmap, NULL, machine->gfx[2], 0, 0, 0, 1, 0x00, 0x40); + drawgfx_opaque(state->headlight_bitmap, NULL, machine->gfx[2], 0, 0, 0, 0, 0x00, 0x00); + drawgfx_opaque(state->headlight_bitmap, NULL, machine->gfx[2], 0, 0, 0, 1, 0x00, 0x40); } -static void draw_edges(bitmap_t *bitmap, const rectangle *cliprect, int flip, int scroll_mode) +static void draw_edges(running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect, int flip, int scroll_mode) { + madalien_state *state = machine->driver_data(); rectangle clip_edge1; rectangle clip_edge2; @@ -183,44 +171,45 @@ static void draw_edges(bitmap_t *bitmap, const rectangle *cliprect, int flip, in if (flip) { - clip_edge1.min_y = *madalien_edge1_pos | 0x80; - clip_edge2.max_y = (*madalien_edge2_pos & 0x7f) ^ 0x7f; + clip_edge1.min_y = *state->edge1_pos | 0x80; + clip_edge2.max_y = (*state->edge2_pos & 0x7f) ^ 0x7f; } else { - clip_edge1.max_y = (*madalien_edge1_pos & 0x7f) ^ 0x7f; - clip_edge2.min_y = *madalien_edge2_pos | 0x80; + clip_edge1.max_y = (*state->edge1_pos & 0x7f) ^ 0x7f; + clip_edge2.min_y = *state->edge2_pos | 0x80; } sect_rect(&clip_edge1, cliprect); sect_rect(&clip_edge2, cliprect); - tilemap_mark_all_tiles_dirty(tilemap_edge1[scroll_mode]); - tilemap_mark_all_tiles_dirty(tilemap_edge2[scroll_mode]); + tilemap_mark_all_tiles_dirty(state->tilemap_edge1[scroll_mode]); + tilemap_mark_all_tiles_dirty(state->tilemap_edge2[scroll_mode]); - tilemap_set_flip(tilemap_edge1[scroll_mode], flip ? TILEMAP_FLIPX | TILEMAP_FLIPY : 0); - tilemap_set_scrollx(tilemap_edge1[scroll_mode], 0, -(*madalien_scroll & 0xfc)); - tilemap_set_scrolly(tilemap_edge1[scroll_mode], 0, *madalien_edge1_pos & 0x7f); + tilemap_set_flip(state->tilemap_edge1[scroll_mode], flip ? TILEMAP_FLIPX | TILEMAP_FLIPY : 0); + tilemap_set_scrollx(state->tilemap_edge1[scroll_mode], 0, -(*state->scroll & 0xfc)); + tilemap_set_scrolly(state->tilemap_edge1[scroll_mode], 0, *state->edge1_pos & 0x7f); - tilemap_set_flip(tilemap_edge2[scroll_mode], flip ? TILEMAP_FLIPX : TILEMAP_FLIPY); - tilemap_set_scrollx(tilemap_edge2[scroll_mode], 0, -(*madalien_scroll & 0xfc)); - tilemap_set_scrolly(tilemap_edge2[scroll_mode], 0, *madalien_edge2_pos & 0x7f); + tilemap_set_flip(state->tilemap_edge2[scroll_mode], flip ? TILEMAP_FLIPX : TILEMAP_FLIPY); + tilemap_set_scrollx(state->tilemap_edge2[scroll_mode], 0, -(*state->scroll & 0xfc)); + tilemap_set_scrolly(state->tilemap_edge2[scroll_mode], 0, *state->edge2_pos & 0x7f); - tilemap_draw(bitmap, &clip_edge1, tilemap_edge1[scroll_mode], 0, 0); - tilemap_draw(bitmap, &clip_edge2, tilemap_edge2[scroll_mode], 0, 0); + tilemap_draw(bitmap, &clip_edge1, state->tilemap_edge1[scroll_mode], 0, 0); + tilemap_draw(bitmap, &clip_edge2, state->tilemap_edge2[scroll_mode], 0, 0); } -static void draw_headlight(bitmap_t *bitmap, const rectangle *cliprect, int flip) +static void draw_headlight(running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect, int flip) { - if (BIT(*madalien_video_flags, 0)) + madalien_state *state = machine->driver_data(); + if (BIT(*state->video_flags, 0)) { UINT8 y; for (y = 0; y < 0x80; y++) { UINT8 x; - UINT8 hy = y - *madalien_headlight_pos; + UINT8 hy = y - *state->headlight_pos; if (flip) hy = ~hy; @@ -238,7 +227,7 @@ static void draw_headlight(bitmap_t *bitmap, const rectangle *cliprect, int flip if ((hx < cliprect->min_x) || (hx > cliprect->max_x)) continue; - if (*BITMAP_ADDR16(headlight_bitmap, y, x) != 0) + if (*BITMAP_ADDR16(state->headlight_bitmap, y, x) != 0) *BITMAP_ADDR16(bitmap, hy, hx) |= 8; } } @@ -248,21 +237,24 @@ static void draw_headlight(bitmap_t *bitmap, const rectangle *cliprect, int flip static void draw_foreground(running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect, int flip) { - tilemap_set_flip(tilemap_fg, flip ? TILEMAP_FLIPX | TILEMAP_FLIPY : 0); - tilemap_draw(bitmap, cliprect, tilemap_fg, 0, 0); + madalien_state *state = machine->driver_data(); + tilemap_set_flip(state->tilemap_fg, flip ? TILEMAP_FLIPX | TILEMAP_FLIPY : 0); + tilemap_draw(bitmap, cliprect, state->tilemap_fg, 0, 0); } WRITE8_HANDLER( madalien_charram_w ) { - madalien_charram[offset] = data; + madalien_state *state = space->machine->driver_data(); + state->charram[offset] = data; gfx_element_mark_dirty(space->machine->gfx[0], (offset/8) & 0xff); } static VIDEO_UPDATE( madalien ) { - int flip = BIT(input_port_read(screen->machine, "DSW"), 6) && BIT(*madalien_video_control, 0); + madalien_state *state = screen->machine->driver_data(); + int flip = BIT(input_port_read(screen->machine, "DSW"), 6) && BIT(*state->video_control, 0); // bits #0 and #1 define scrolling mode // @@ -271,18 +263,18 @@ static VIDEO_UPDATE( madalien ) // // mode 2 - transition from B to A // mode 3 - transition from A to B - int scroll_mode = *madalien_scroll & 3; + int scroll_mode = *state->scroll & 3; bitmap_fill(bitmap, cliprect, 0); - draw_edges(bitmap, cliprect, flip, scroll_mode); + draw_edges(screen->machine, bitmap, cliprect, flip, scroll_mode); draw_foreground(screen->machine, bitmap, cliprect, flip); /* highlight section A (outside of tunnels). - * also, bit 1 of the madalien_video_flags register (6A) is + * also, bit 1 of the state->video_flags register (6A) is * combined with the headlight signal through NOR gate 1A, * which is used to light up the tunnel when an alien explodes */ - if (scroll_mode != 1 || *madalien_video_flags & 2) + if (scroll_mode != 1 || *state->video_flags & 2) { int x; int y; @@ -290,10 +282,10 @@ static VIDEO_UPDATE( madalien ) int min_x = 0; int max_x = 0xff; - if (!(*madalien_video_flags & 2)) + if (!(*state->video_flags & 2)) { - if (scroll_mode == 2) min_x = (*madalien_scroll & 0xfc); - else if (scroll_mode == 3) max_x = (*madalien_scroll & 0xfc) - 1; + if (scroll_mode == 2) min_x = (*state->scroll & 0xfc); + else if (scroll_mode == 3) max_x = (*state->scroll & 0xfc) - 1; } if (flip) @@ -309,7 +301,7 @@ static VIDEO_UPDATE( madalien ) *BITMAP_ADDR16(bitmap, y, x) |= 8; } - draw_headlight(bitmap, cliprect, flip); + draw_headlight(screen->machine, bitmap, cliprect, flip); return 0; } diff --git a/src/mame/video/pcktgal.c b/src/mame/video/pcktgal.c index eb5a3ea7ce5..da3d76691b6 100644 --- a/src/mame/video/pcktgal.c +++ b/src/mame/video/pcktgal.c @@ -1,7 +1,6 @@ #include "emu.h" #include "includes/pcktgal.h" -static tilemap_t *bg_tilemap; PALETTE_INIT( pcktgal ) { @@ -36,7 +35,7 @@ WRITE8_HANDLER( pcktgal_videoram_w ) pcktgal_state *state = space->machine->driver_data(); UINT8 *videoram = state->videoram; videoram[offset] = data; - tilemap_mark_tile_dirty(bg_tilemap, offset / 2); + tilemap_mark_tile_dirty(state->bg_tilemap, offset / 2); } WRITE8_HANDLER( pcktgal_flipscreen_w ) @@ -60,7 +59,8 @@ static TILE_GET_INFO( get_bg_tile_info ) VIDEO_START( pcktgal ) { - bg_tilemap = tilemap_create(machine, get_bg_tile_info, tilemap_scan_rows, + pcktgal_state *state = machine->driver_data(); + state->bg_tilemap = tilemap_create(machine, get_bg_tile_info, tilemap_scan_rows, 8, 8, 32, 32); } @@ -99,7 +99,8 @@ static void draw_sprites(running_machine *machine, bitmap_t *bitmap, const recta VIDEO_UPDATE( pcktgal ) { - tilemap_draw(bitmap, cliprect, bg_tilemap, 0, 0); + pcktgal_state *state = screen->machine->driver_data(); + tilemap_draw(bitmap, cliprect, state->bg_tilemap, 0, 0); draw_sprites(screen->machine, bitmap, cliprect); return 0; } diff --git a/src/mame/video/powerins.c b/src/mame/video/powerins.c index cc04fad9c21..8daf0673e6d 100644 --- a/src/mame/video/powerins.c +++ b/src/mame/video/powerins.c @@ -40,16 +40,6 @@ Note: if MAME_DEBUG is defined, pressing Z with: #include "emu.h" #include "includes/powerins.h" -/* Variables that driver has access to: */ -UINT16 *powerins_vram_0, *powerins_vctrl_0; -UINT16 *powerins_vram_1, *powerins_vctrl_1; -//UINT16 *powerins_vregs; - -/* Variables only used here: */ -static tilemap_t *tilemap_0, *tilemap_1; -static int tile_bank; - - /*************************************************************************** @@ -65,12 +55,13 @@ WRITE16_HANDLER( powerins_flipscreen_w ) WRITE16_HANDLER( powerins_tilebank_w ) { + powerins_state *state = space->machine->driver_data(); if (ACCESSING_BITS_0_7) { - if (data != tile_bank) + if (data != state->tile_bank) { - tile_bank = data; // Tiles Bank (VRAM 0) - tilemap_mark_all_tiles_dirty(tilemap_0); + state->tile_bank = data; // Tiles Bank (VRAM 0) + tilemap_mark_all_tiles_dirty(state->tilemap_0); } } } @@ -130,18 +121,20 @@ Offset: static TILE_GET_INFO( get_tile_info_0 ) { - UINT16 code = powerins_vram_0[tile_index]; + powerins_state *state = machine->driver_data(); + UINT16 code = state->vram_0[tile_index]; SET_TILE_INFO( 0, - (code & 0x07ff) + (tile_bank*0x800), + (code & 0x07ff) + (state->tile_bank*0x800), ((code & 0xf000) >> (16-4)) + ((code & 0x0800) >> (11-4)), 0); } WRITE16_HANDLER( powerins_vram_0_w ) { - COMBINE_DATA(&powerins_vram_0[offset]); - tilemap_mark_tile_dirty(tilemap_0, offset); + powerins_state *state = space->machine->driver_data(); + COMBINE_DATA(&state->vram_0[offset]); + tilemap_mark_tile_dirty(state->tilemap_0, offset); } static TILEMAP_MAPPER( powerins_get_memory_offset_0 ) @@ -170,7 +163,8 @@ Offset: static TILE_GET_INFO( get_tile_info_1 ) { - UINT16 code = powerins_vram_1[tile_index]; + powerins_state *state = machine->driver_data(); + UINT16 code = state->vram_1[tile_index]; SET_TILE_INFO( 1, code & 0x0fff, @@ -180,8 +174,9 @@ static TILE_GET_INFO( get_tile_info_1 ) WRITE16_HANDLER( powerins_vram_1_w ) { - COMBINE_DATA(&powerins_vram_1[offset]); - tilemap_mark_tile_dirty(tilemap_1, offset); + powerins_state *state = space->machine->driver_data(); + COMBINE_DATA(&state->vram_1[offset]); + tilemap_mark_tile_dirty(state->tilemap_1, offset); } @@ -198,24 +193,25 @@ WRITE16_HANDLER( powerins_vram_1_w ) VIDEO_START( powerins ) { - tilemap_0 = tilemap_create( machine, get_tile_info_0, + powerins_state *state = machine->driver_data(); + state->tilemap_0 = tilemap_create( machine, get_tile_info_0, powerins_get_memory_offset_0, 16,16, DIM_NX_0, DIM_NY_0 ); - tilemap_1 = tilemap_create( machine, get_tile_info_1, + state->tilemap_1 = tilemap_create( machine, get_tile_info_1, tilemap_scan_cols, 8,8, DIM_NX_1, DIM_NY_1 ); - tilemap_set_scroll_rows(tilemap_0,1); - tilemap_set_scroll_cols(tilemap_0,1); + tilemap_set_scroll_rows(state->tilemap_0,1); + tilemap_set_scroll_cols(state->tilemap_0,1); - tilemap_set_scroll_rows(tilemap_1,1); - tilemap_set_scroll_cols(tilemap_1,1); - tilemap_set_transparent_pen(tilemap_1,15); + tilemap_set_scroll_rows(state->tilemap_1,1); + tilemap_set_scroll_cols(state->tilemap_1,1); + tilemap_set_transparent_pen(state->tilemap_1,15); } @@ -345,16 +341,17 @@ static void draw_sprites(running_machine *machine, bitmap_t *bitmap,const rectan VIDEO_UPDATE( powerins ) { + powerins_state *state = screen->machine->driver_data(); int layers_ctrl = -1; - int scrollx = (powerins_vctrl_0[2/2]&0xff) + (powerins_vctrl_0[0/2]&0xff)*256; - int scrolly = (powerins_vctrl_0[6/2]&0xff) + (powerins_vctrl_0[4/2]&0xff)*256; + int scrollx = (state->vctrl_0[2/2]&0xff) + (state->vctrl_0[0/2]&0xff)*256; + int scrolly = (state->vctrl_0[6/2]&0xff) + (state->vctrl_0[4/2]&0xff)*256; - tilemap_set_scrollx( tilemap_0, 0, scrollx - 0x20); - tilemap_set_scrolly( tilemap_0, 0, scrolly ); + tilemap_set_scrollx( state->tilemap_0, 0, scrollx - 0x20); + tilemap_set_scrolly( state->tilemap_0, 0, scrolly ); - tilemap_set_scrollx( tilemap_1, 0, -0x20); // fixed offset - tilemap_set_scrolly( tilemap_1, 0, 0x00); + tilemap_set_scrollx( state->tilemap_1, 0, -0x20); // fixed offset + tilemap_set_scrolly( state->tilemap_1, 0, 0x00); #ifdef MAME_DEBUG if (input_code_pressed(screen->machine, KEYCODE_Z)) @@ -369,9 +366,9 @@ if (input_code_pressed(screen->machine, KEYCODE_Z)) } #endif - if (layers_ctrl&1) tilemap_draw(bitmap,cliprect, tilemap_0, 0, 0); + if (layers_ctrl&1) tilemap_draw(bitmap,cliprect, state->tilemap_0, 0, 0); else bitmap_fill(bitmap,cliprect,0); if (layers_ctrl&8) draw_sprites(screen->machine,bitmap,cliprect); - if (layers_ctrl&2) tilemap_draw(bitmap,cliprect, tilemap_1, 0, 0); + if (layers_ctrl&2) tilemap_draw(bitmap,cliprect, state->tilemap_1, 0, 0); return 0; } diff --git a/src/mame/video/srumbler.c b/src/mame/video/srumbler.c index 0fc6e212d9c..02662b25b07 100644 --- a/src/mame/video/srumbler.c +++ b/src/mame/video/srumbler.c @@ -9,10 +9,6 @@ #include "emu.h" #include "includes/srumbler.h" -UINT8 *srumbler_backgroundram,*srumbler_foregroundram; -static tilemap_t *bg_tilemap,*fg_tilemap; - - /*************************************************************************** @@ -22,20 +18,22 @@ static tilemap_t *bg_tilemap,*fg_tilemap; static TILE_GET_INFO( get_fg_tile_info ) { - UINT8 attr = srumbler_foregroundram[2*tile_index]; + srumbler_state *state = machine->driver_data(); + UINT8 attr = state->foregroundram[2*tile_index]; SET_TILE_INFO( 0, - srumbler_foregroundram[2*tile_index + 1] + ((attr & 0x03) << 8), + state->foregroundram[2*tile_index + 1] + ((attr & 0x03) << 8), (attr & 0x3c) >> 2, (attr & 0x40) ? TILE_FORCE_LAYER0 : 0); } static TILE_GET_INFO( get_bg_tile_info ) { - UINT8 attr = srumbler_backgroundram[2*tile_index]; + srumbler_state *state = machine->driver_data(); + UINT8 attr = state->backgroundram[2*tile_index]; SET_TILE_INFO( 1, - srumbler_backgroundram[2*tile_index + 1] + ((attr & 0x07) << 8), + state->backgroundram[2*tile_index + 1] + ((attr & 0x07) << 8), (attr & 0xe0) >> 5, ((attr & 0x08) ? TILE_FLIPY : 0)); tileinfo->group = (attr & 0x10) >> 4; @@ -51,13 +49,14 @@ static TILE_GET_INFO( get_bg_tile_info ) VIDEO_START( srumbler ) { - fg_tilemap = tilemap_create(machine, get_fg_tile_info,tilemap_scan_cols,8,8,64,32); - bg_tilemap = tilemap_create(machine, get_bg_tile_info,tilemap_scan_cols, 16,16,64,64); + srumbler_state *state = machine->driver_data(); + state->fg_tilemap = tilemap_create(machine, get_fg_tile_info,tilemap_scan_cols,8,8,64,32); + state->bg_tilemap = tilemap_create(machine, get_bg_tile_info,tilemap_scan_cols, 16,16,64,64); - tilemap_set_transparent_pen(fg_tilemap,3); + tilemap_set_transparent_pen(state->fg_tilemap,3); - tilemap_set_transmask(bg_tilemap,0,0xffff,0x0000); /* split type 0 is totally transparent in front half */ - tilemap_set_transmask(bg_tilemap,1,0x07ff,0xf800); /* split type 1 has pens 0-10 transparent in front half */ + tilemap_set_transmask(state->bg_tilemap,0,0xffff,0x0000); /* split type 0 is totally transparent in front half */ + tilemap_set_transmask(state->bg_tilemap,1,0x07ff,0xf800); /* split type 1 has pens 0-10 transparent in front half */ } @@ -70,14 +69,16 @@ VIDEO_START( srumbler ) WRITE8_HANDLER( srumbler_foreground_w ) { - srumbler_foregroundram[offset] = data; - tilemap_mark_tile_dirty(fg_tilemap,offset/2); + srumbler_state *state = space->machine->driver_data(); + state->foregroundram[offset] = data; + tilemap_mark_tile_dirty(state->fg_tilemap,offset/2); } WRITE8_HANDLER( srumbler_background_w ) { - srumbler_backgroundram[offset] = data; - tilemap_mark_tile_dirty(bg_tilemap,offset/2); + srumbler_state *state = space->machine->driver_data(); + state->backgroundram[offset] = data; + tilemap_mark_tile_dirty(state->bg_tilemap,offset/2); } @@ -96,12 +97,12 @@ WRITE8_HANDLER( srumbler_4009_w ) WRITE8_HANDLER( srumbler_scroll_w ) { - static int scroll[4]; + srumbler_state *state = space->machine->driver_data(); - scroll[offset] = data; + state->scroll[offset] = data; - tilemap_set_scrollx(bg_tilemap,0,scroll[0] | (scroll[1] << 8)); - tilemap_set_scrolly(bg_tilemap,0,scroll[2] | (scroll[3] << 8)); + tilemap_set_scrollx(state->bg_tilemap,0,state->scroll[0] | (state->scroll[1] << 8)); + tilemap_set_scrolly(state->bg_tilemap,0,state->scroll[2] | (state->scroll[3] << 8)); } @@ -161,10 +162,11 @@ static void draw_sprites(running_machine *machine, bitmap_t *bitmap, const recta VIDEO_UPDATE( srumbler ) { - tilemap_draw(bitmap,cliprect,bg_tilemap,TILEMAP_DRAW_LAYER1,0); + srumbler_state *state = screen->machine->driver_data(); + tilemap_draw(bitmap,cliprect,state->bg_tilemap,TILEMAP_DRAW_LAYER1,0); draw_sprites(screen->machine, bitmap,cliprect); - tilemap_draw(bitmap,cliprect,bg_tilemap,TILEMAP_DRAW_LAYER0,0); - tilemap_draw(bitmap,cliprect,fg_tilemap,0,0); + tilemap_draw(bitmap,cliprect,state->bg_tilemap,TILEMAP_DRAW_LAYER0,0); + tilemap_draw(bitmap,cliprect,state->fg_tilemap,0,0); return 0; } diff --git a/src/mame/video/sshangha.c b/src/mame/video/sshangha.c index c0b7f19eea3..12363ed125a 100644 --- a/src/mame/video/sshangha.c +++ b/src/mame/video/sshangha.c @@ -8,18 +8,14 @@ #include "emu.h" #include "includes/sshangha.h" -UINT16 *sshangha_pf2_data,*sshangha_pf1_data; -UINT16 *sshangha_pf1_rowscroll,*sshangha_pf2_rowscroll; -static UINT16 sshangha_control_0[8]; -static tilemap_t *pf1_8x8_tilemap,*pf1_16x16_tilemap,*pf2_tilemap; -static int sshangha_pf1_bank,sshangha_pf2_bank,sshangha_video_control; /******************************************************************************/ -static void sshangha_tilemap_draw(bitmap_t *bitmap, const rectangle *cliprect) +static void sshangha_tilemap_draw(running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect) { - const bitmap_t *bitmap0 = tilemap_get_pixmap(pf1_16x16_tilemap); - const bitmap_t *bitmap1 = tilemap_get_pixmap(pf2_tilemap); + sshangha_state *state = machine->driver_data(); + const bitmap_t *bitmap0 = tilemap_get_pixmap(state->pf1_16x16_tilemap); + const bitmap_t *bitmap1 = tilemap_get_pixmap(state->pf2_tilemap); int x,y,p; for (y=0; y<240; y++) { @@ -34,8 +30,9 @@ static void sshangha_tilemap_draw(bitmap_t *bitmap, const rectangle *cliprect) WRITE16_HANDLER (sshangha_video_w) { + sshangha_state *state = space->machine->driver_data(); /* 0x4: Special video mode, other bits unknown */ - sshangha_video_control=data; + state->video_control=data; // popmessage("%04x",data); } @@ -112,20 +109,23 @@ static void draw_sprites(running_machine *machine, bitmap_t *bitmap, const recta WRITE16_HANDLER( sshangha_pf2_data_w ) { - COMBINE_DATA(&sshangha_pf2_data[offset]); - tilemap_mark_tile_dirty(pf2_tilemap,offset); + sshangha_state *state = space->machine->driver_data(); + COMBINE_DATA(&state->pf2_data[offset]); + tilemap_mark_tile_dirty(state->pf2_tilemap,offset); } WRITE16_HANDLER( sshangha_pf1_data_w ) { - COMBINE_DATA(&sshangha_pf1_data[offset]); - tilemap_mark_tile_dirty(pf1_8x8_tilemap,offset); - tilemap_mark_tile_dirty(pf1_16x16_tilemap,offset); + sshangha_state *state = space->machine->driver_data(); + COMBINE_DATA(&state->pf1_data[offset]); + tilemap_mark_tile_dirty(state->pf1_8x8_tilemap,offset); + tilemap_mark_tile_dirty(state->pf1_16x16_tilemap,offset); } WRITE16_HANDLER( sshangha_control_0_w ) { - COMBINE_DATA(&sshangha_control_0[offset]); + sshangha_state *state = space->machine->driver_data(); + COMBINE_DATA(&state->control_0[offset]); } /******************************************************************************/ @@ -140,102 +140,106 @@ static UINT32 sshangha_scan(UINT32 col,UINT32 row,UINT32 num_cols,UINT32 num_row static TILE_GET_INFO( get_pf2_tile_info ) { - UINT16 tile=sshangha_pf2_data[tile_index]; - SET_TILE_INFO(1,(tile&0xfff)|sshangha_pf2_bank,(tile>>12)|32,0); + sshangha_state *state = machine->driver_data(); + UINT16 tile=state->pf2_data[tile_index]; + SET_TILE_INFO(1,(tile&0xfff)|state->pf2_bank,(tile>>12)|32,0); } static TILE_GET_INFO( get_pf1_16x16_tile_info ) { - UINT16 tile=sshangha_pf1_data[tile_index]; - SET_TILE_INFO(1,(tile&0xfff)|sshangha_pf1_bank,tile>>12,0); + sshangha_state *state = machine->driver_data(); + UINT16 tile=state->pf1_data[tile_index]; + SET_TILE_INFO(1,(tile&0xfff)|state->pf1_bank,tile>>12,0); } static TILE_GET_INFO( get_pf1_8x8_tile_info ) { - UINT16 tile=sshangha_pf1_data[tile_index]; - SET_TILE_INFO(0,(tile&0xfff)|sshangha_pf1_bank,tile>>12,0); + sshangha_state *state = machine->driver_data(); + UINT16 tile=state->pf1_data[tile_index]; + SET_TILE_INFO(0,(tile&0xfff)|state->pf1_bank,tile>>12,0); } VIDEO_START( sshangha ) { - pf1_8x8_tilemap = tilemap_create(machine, get_pf1_8x8_tile_info, tilemap_scan_rows, 8, 8,64,32); - pf1_16x16_tilemap = tilemap_create(machine, get_pf1_16x16_tile_info,tilemap_scan_rows,16,16,32,32); - pf2_tilemap = tilemap_create(machine, get_pf2_tile_info,tilemap_scan_rows, 16,16,32,32); + sshangha_state *state = machine->driver_data(); + state->pf1_8x8_tilemap = tilemap_create(machine, get_pf1_8x8_tile_info, tilemap_scan_rows, 8, 8,64,32); + state->pf1_16x16_tilemap = tilemap_create(machine, get_pf1_16x16_tile_info,tilemap_scan_rows,16,16,32,32); + state->pf2_tilemap = tilemap_create(machine, get_pf2_tile_info,tilemap_scan_rows, 16,16,32,32); - tilemap_set_transparent_pen(pf1_8x8_tilemap,0); - tilemap_set_transparent_pen(pf1_16x16_tilemap,0); + tilemap_set_transparent_pen(state->pf1_8x8_tilemap,0); + tilemap_set_transparent_pen(state->pf1_16x16_tilemap,0); } /******************************************************************************/ VIDEO_UPDATE( sshangha ) { - static int last_pf1_bank,last_pf2_bank; + sshangha_state *state = screen->machine->driver_data(); int offs; - flip_screen_set_no_update(screen->machine, sshangha_control_0[0]&0x80); + flip_screen_set_no_update(screen->machine, state->control_0[0]&0x80); tilemap_set_flip_all(screen->machine,flip_screen_x_get(screen->machine) ? (TILEMAP_FLIPY | TILEMAP_FLIPX) : 0); - tilemap_set_enable( pf2_tilemap, sshangha_control_0[5]&0x8000); - tilemap_set_enable( pf1_8x8_tilemap, sshangha_control_0[5]&0x0080); - tilemap_set_enable( pf1_16x16_tilemap, sshangha_control_0[5]&0x0080); + tilemap_set_enable( state->pf2_tilemap, state->control_0[5]&0x8000); + tilemap_set_enable( state->pf1_8x8_tilemap, state->control_0[5]&0x0080); + tilemap_set_enable( state->pf1_16x16_tilemap, state->control_0[5]&0x0080); - sshangha_pf1_bank=((sshangha_control_0[7]>> 4)&0xf)*0x1000; - sshangha_pf2_bank=((sshangha_control_0[7]>>12)&0xf)*0x1000; + state->pf1_bank=((state->control_0[7]>> 4)&0xf)*0x1000; + state->pf2_bank=((state->control_0[7]>>12)&0xf)*0x1000; - if (sshangha_pf1_bank!=last_pf1_bank) tilemap_mark_all_tiles_dirty(pf1_8x8_tilemap); - if (sshangha_pf1_bank!=last_pf1_bank) tilemap_mark_all_tiles_dirty(pf1_16x16_tilemap); - if (sshangha_pf2_bank!=last_pf2_bank) tilemap_mark_all_tiles_dirty(pf2_tilemap); - last_pf1_bank=sshangha_pf1_bank; - last_pf2_bank=sshangha_pf2_bank; + if (state->pf1_bank!=state->last_pf1_bank) tilemap_mark_all_tiles_dirty(state->pf1_8x8_tilemap); + if (state->pf1_bank!=state->last_pf1_bank) tilemap_mark_all_tiles_dirty(state->pf1_16x16_tilemap); + if (state->pf2_bank!=state->last_pf2_bank) tilemap_mark_all_tiles_dirty(state->pf2_tilemap); + state->last_pf1_bank=state->pf1_bank; + state->last_pf2_bank=state->pf2_bank; /* Rowscroll - todo, this might actually be col scroll, or both row & col combined. Check.. */ - if (sshangha_control_0[6]&0x40) { - tilemap_set_scroll_rows(pf1_8x8_tilemap,256); - tilemap_set_scroll_rows(pf1_16x16_tilemap,256); + if (state->control_0[6]&0x40) { + tilemap_set_scroll_rows(state->pf1_8x8_tilemap,256); + tilemap_set_scroll_rows(state->pf1_16x16_tilemap,256); for (offs=0; offs<256; offs++) { - tilemap_set_scrollx( pf1_8x8_tilemap,0, sshangha_control_0[1] + sshangha_pf1_rowscroll[offs+0x200] ); - tilemap_set_scrollx( pf1_16x16_tilemap,0, sshangha_control_0[1] + sshangha_pf1_rowscroll[offs+0x200] ); + tilemap_set_scrollx( state->pf1_8x8_tilemap,0, state->control_0[1] + state->pf1_rowscroll[offs+0x200] ); + tilemap_set_scrollx( state->pf1_16x16_tilemap,0, state->control_0[1] + state->pf1_rowscroll[offs+0x200] ); } } else { - tilemap_set_scroll_rows(pf1_16x16_tilemap,1); - tilemap_set_scroll_rows(pf1_8x8_tilemap,1); - tilemap_set_scrollx( pf1_8x8_tilemap,0, sshangha_control_0[1] ); - tilemap_set_scrollx( pf1_16x16_tilemap,0, sshangha_control_0[1] ); + tilemap_set_scroll_rows(state->pf1_16x16_tilemap,1); + tilemap_set_scroll_rows(state->pf1_8x8_tilemap,1); + tilemap_set_scrollx( state->pf1_8x8_tilemap,0, state->control_0[1] ); + tilemap_set_scrollx( state->pf1_16x16_tilemap,0, state->control_0[1] ); } - if (sshangha_control_0[6]&0x4000) { - tilemap_set_scroll_rows(pf2_tilemap,256); + if (state->control_0[6]&0x4000) { + tilemap_set_scroll_rows(state->pf2_tilemap,256); for (offs=0; offs<256; offs++) { - tilemap_set_scrollx( pf2_tilemap,0, sshangha_control_0[3] - 3 + sshangha_pf2_rowscroll[offs+0x200] ); + tilemap_set_scrollx( state->pf2_tilemap,0, state->control_0[3] - 3 + state->pf2_rowscroll[offs+0x200] ); } } else { - tilemap_set_scroll_rows(pf2_tilemap,1); - tilemap_set_scrollx( pf2_tilemap,0, sshangha_control_0[3] - 3 ); + tilemap_set_scroll_rows(state->pf2_tilemap,1); + tilemap_set_scrollx( state->pf2_tilemap,0, state->control_0[3] - 3 ); } - tilemap_set_scrolly( pf2_tilemap,0, sshangha_control_0[4] ); - tilemap_set_scrolly( pf1_8x8_tilemap,0, sshangha_control_0[2] ); - tilemap_set_scrolly( pf1_16x16_tilemap,0, sshangha_control_0[2] ); + tilemap_set_scrolly( state->pf2_tilemap,0, state->control_0[4] ); + tilemap_set_scrolly( state->pf1_8x8_tilemap,0, state->control_0[2] ); + tilemap_set_scrolly( state->pf1_16x16_tilemap,0, state->control_0[2] ); - //if ((sshangha_control_0[5]&0x8000)==0) /* <- used on hot-b logo and girl presentation screens */ + //if ((state->control_0[5]&0x8000)==0) /* <- used on hot-b logo and girl presentation screens */ bitmap_fill(bitmap,cliprect,get_black_pen(screen->machine)); /* Super Shanghai has a mode where the two tilemaps are combined to produce a 6bpp tilemap. We can't precompute this as any tiles can be used in any tilemap, so we plot it on the fly */ - if ((sshangha_video_control&4)==0) { - sshangha_tilemap_draw(bitmap, cliprect); + if ((state->video_control&4)==0) { + sshangha_tilemap_draw(screen->machine, bitmap, cliprect); draw_sprites(screen->machine, bitmap, cliprect, screen->machine->generic.spriteram.u16,0x4000,0x4000); } else { - tilemap_draw(bitmap,cliprect,pf2_tilemap,0,0); + tilemap_draw(bitmap,cliprect,state->pf2_tilemap,0,0); draw_sprites(screen->machine, bitmap, cliprect, screen->machine->generic.spriteram.u16,0x4000,0x4000); - if (sshangha_control_0[6]&0x80) - tilemap_draw(bitmap,cliprect,pf1_8x8_tilemap,0,0); + if (state->control_0[6]&0x80) + tilemap_draw(bitmap,cliprect,state->pf1_8x8_tilemap,0,0); else - tilemap_draw(bitmap,cliprect,pf1_16x16_tilemap,0,0); + tilemap_draw(bitmap,cliprect,state->pf1_16x16_tilemap,0,0); } draw_sprites(screen->machine, bitmap, cliprect, screen->machine->generic.spriteram2.u16,0x0000,0x0000); diff --git a/src/mame/video/stadhero.c b/src/mame/video/stadhero.c index 776c420fad8..16467d496d8 100644 --- a/src/mame/video/stadhero.c +++ b/src/mame/video/stadhero.c @@ -12,17 +12,12 @@ #include "emu.h" #include "includes/stadhero.h" -UINT16 *stadhero_pf1_data; -static UINT16 *stadhero_pf2_data; -UINT16 *stadhero_pf2_control_0; -UINT16 *stadhero_pf2_control_1; -static tilemap_t *pf1_tilemap,*pf2_tilemap; -static int flipscreen; /******************************************************************************/ static void draw_sprites(running_machine *machine, bitmap_t *bitmap,const rectangle *cliprect,int pri_mask,int pri_val) { + stadhero_state *state = machine->driver_data(); UINT16 *spriteram16 = machine->generic.spriteram.u16; int offs; @@ -63,7 +58,7 @@ static void draw_sprites(running_machine *machine, bitmap_t *bitmap,const rectan inc = 1; } - if (flipscreen) { + if (state->flipscreen) { y=240-y; x=240-x; if (fx) fx=0; else fx=1; @@ -88,14 +83,15 @@ static void draw_sprites(running_machine *machine, bitmap_t *bitmap,const rectan VIDEO_UPDATE( stadhero ) { - flipscreen=stadhero_pf2_control_0[0]&0x80; - tilemap_set_flip_all(screen->machine,flipscreen ? (TILEMAP_FLIPY | TILEMAP_FLIPX) : 0); - tilemap_set_scrollx( pf2_tilemap,0, stadhero_pf2_control_1[0] ); - tilemap_set_scrolly( pf2_tilemap,0, stadhero_pf2_control_1[1] ); + stadhero_state *state = screen->machine->driver_data(); + state->flipscreen=state->pf2_control_0[0]&0x80; + tilemap_set_flip_all(screen->machine,state->flipscreen ? (TILEMAP_FLIPY | TILEMAP_FLIPX) : 0); + tilemap_set_scrollx( state->pf2_tilemap,0, state->pf2_control_1[0] ); + tilemap_set_scrolly( state->pf2_tilemap,0, state->pf2_control_1[1] ); - tilemap_draw(bitmap,cliprect,pf2_tilemap,0,0); + tilemap_draw(bitmap,cliprect,state->pf2_tilemap,0,0); draw_sprites(screen->machine, bitmap,cliprect,0x00,0x00); - tilemap_draw(bitmap,cliprect,pf1_tilemap,0,0); + tilemap_draw(bitmap,cliprect,state->pf1_tilemap,0,0); return 0; } @@ -103,19 +99,22 @@ VIDEO_UPDATE( stadhero ) WRITE16_HANDLER( stadhero_pf1_data_w ) { - COMBINE_DATA(&stadhero_pf1_data[offset]); - tilemap_mark_tile_dirty(pf1_tilemap,offset); + stadhero_state *state = space->machine->driver_data(); + COMBINE_DATA(&state->pf1_data[offset]); + tilemap_mark_tile_dirty(state->pf1_tilemap,offset); } READ16_HANDLER( stadhero_pf2_data_r ) { - return stadhero_pf2_data[((stadhero_pf2_control_0[2] & 0x01) ? 0x1000 : 0) | offset]; + stadhero_state *state = space->machine->driver_data(); + return state->pf2_data[((state->pf2_control_0[2] & 0x01) ? 0x1000 : 0) | offset]; } WRITE16_HANDLER( stadhero_pf2_data_w ) { - COMBINE_DATA(&stadhero_pf2_data[((stadhero_pf2_control_0[2] & 0x01) ? 0x1000 : 0) | offset]); - tilemap_mark_tile_dirty(pf2_tilemap,offset); + stadhero_state *state = space->machine->driver_data(); + COMBINE_DATA(&state->pf2_data[((state->pf2_control_0[2] & 0x01) ? 0x1000 : 0) | offset]); + tilemap_mark_tile_dirty(state->pf2_tilemap,offset); } @@ -129,9 +128,10 @@ static TILEMAP_MAPPER( stadhero_scan ) static TILE_GET_INFO( get_pf2_tile_info ) { + stadhero_state *state = machine->driver_data(); int tile,color; - tile=stadhero_pf2_data[((stadhero_pf2_control_0[2] & 0x01) ? 0x1000 : 0) | tile_index]; + tile=state->pf2_data[((state->pf2_control_0[2] & 0x01) ? 0x1000 : 0) | tile_index]; color=tile >> 12; tile=tile&0xfff; @@ -144,7 +144,8 @@ static TILE_GET_INFO( get_pf2_tile_info ) static TILE_GET_INFO( get_pf1_tile_info ) { - int tile=stadhero_pf1_data[tile_index]; + stadhero_state *state = machine->driver_data(); + int tile=state->pf1_data[tile_index]; int color=tile >> 12; tile=tile&0xfff; @@ -157,12 +158,13 @@ static TILE_GET_INFO( get_pf1_tile_info ) VIDEO_START( stadhero ) { - pf1_tilemap = tilemap_create(machine, get_pf1_tile_info,tilemap_scan_rows, 8, 8,32,32); - pf2_tilemap = tilemap_create(machine, get_pf2_tile_info,stadhero_scan, 16,16,64,64); + stadhero_state *state = machine->driver_data(); + state->pf1_tilemap = tilemap_create(machine, get_pf1_tile_info,tilemap_scan_rows, 8, 8,32,32); + state->pf2_tilemap = tilemap_create(machine, get_pf2_tile_info,stadhero_scan, 16,16,64,64); - stadhero_pf2_data = auto_alloc_array(machine, UINT16, 0x2000); + state->pf2_data = auto_alloc_array(machine, UINT16, 0x2000); - tilemap_set_transparent_pen(pf1_tilemap,0); + tilemap_set_transparent_pen(state->pf1_tilemap,0); } /******************************************************************************/ diff --git a/src/mame/video/tigeroad.c b/src/mame/video/tigeroad.c index 992ab8c8710..6eb4b6bba50 100644 --- a/src/mame/video/tigeroad.c +++ b/src/mame/video/tigeroad.c @@ -1,19 +1,18 @@ #include "emu.h" #include "includes/tigeroad.h" -static int bgcharbank; -static tilemap_t *bg_tilemap, *fg_tilemap; WRITE16_HANDLER( tigeroad_videoram_w ) { tigeroad_state *state = space->machine->driver_data(); UINT16 *videoram = state->videoram; COMBINE_DATA(&videoram[offset]); - tilemap_mark_tile_dirty(fg_tilemap, offset); + tilemap_mark_tile_dirty(state->fg_tilemap, offset); } WRITE16_HANDLER( tigeroad_videoctrl_w ) { + tigeroad_state *state = space->machine->driver_data(); int bank; if (ACCESSING_BITS_8_15) @@ -32,10 +31,10 @@ WRITE16_HANDLER( tigeroad_videoctrl_w ) bank = (data & 0x04) >> 2; - if (bgcharbank != bank) + if (state->bgcharbank != bank) { - bgcharbank = bank; - tilemap_mark_all_tiles_dirty(bg_tilemap); + state->bgcharbank = bank; + tilemap_mark_all_tiles_dirty(state->bg_tilemap); } /* bits 4-5 are coin lockouts */ @@ -52,6 +51,7 @@ WRITE16_HANDLER( tigeroad_videoctrl_w ) WRITE16_HANDLER( tigeroad_scroll_w ) { + tigeroad_state *state = space->machine->driver_data(); int scroll = 0; COMBINE_DATA(&scroll); @@ -59,10 +59,10 @@ WRITE16_HANDLER( tigeroad_scroll_w ) switch (offset) { case 0: - tilemap_set_scrollx(bg_tilemap, 0, scroll); + tilemap_set_scrollx(state->bg_tilemap, 0, scroll); break; case 1: - tilemap_set_scrolly(bg_tilemap, 0, -scroll - 32 * 8); + tilemap_set_scrolly(state->bg_tilemap, 0, -scroll - 32 * 8); break; } } @@ -113,11 +113,12 @@ static void draw_sprites(running_machine *machine, bitmap_t *bitmap, const recta static TILE_GET_INFO( get_bg_tile_info ) { + tigeroad_state *state = machine->driver_data(); UINT8 *tilerom = machine->region("gfx4")->base(); int data = tilerom[tile_index]; int attr = tilerom[tile_index + 1]; - int code = data + ((attr & 0xc0) << 2) + (bgcharbank << 10); + int code = data + ((attr & 0xc0) << 2) + (state->bgcharbank << 10); int color = attr & 0x0f; int flags = (attr & 0x20) ? TILE_FLIPX : 0; @@ -146,25 +147,27 @@ static TILEMAP_MAPPER( tigeroad_tilemap_scan ) VIDEO_START( tigeroad ) { - bg_tilemap = tilemap_create(machine, get_bg_tile_info, tigeroad_tilemap_scan, + tigeroad_state *state = machine->driver_data(); + state->bg_tilemap = tilemap_create(machine, get_bg_tile_info, tigeroad_tilemap_scan, 32, 32, 128, 128); - fg_tilemap = tilemap_create(machine, get_fg_tile_info, tilemap_scan_rows, + state->fg_tilemap = tilemap_create(machine, get_fg_tile_info, tilemap_scan_rows, 8, 8, 32, 32); - tilemap_set_transmask(bg_tilemap, 0, 0xffff, 0); - tilemap_set_transmask(bg_tilemap, 1, 0x1ff, 0xfe00); + tilemap_set_transmask(state->bg_tilemap, 0, 0xffff, 0); + tilemap_set_transmask(state->bg_tilemap, 1, 0x1ff, 0xfe00); - tilemap_set_transparent_pen(fg_tilemap, 3); + tilemap_set_transparent_pen(state->fg_tilemap, 3); } VIDEO_UPDATE( tigeroad ) { - tilemap_draw(bitmap, cliprect, bg_tilemap, TILEMAP_DRAW_LAYER1, 0); + tigeroad_state *state = screen->machine->driver_data(); + tilemap_draw(bitmap, cliprect, state->bg_tilemap, TILEMAP_DRAW_LAYER1, 0); draw_sprites(screen->machine, bitmap, cliprect, 0); - tilemap_draw(bitmap, cliprect, bg_tilemap, TILEMAP_DRAW_LAYER0, 1); + tilemap_draw(bitmap, cliprect, state->bg_tilemap, TILEMAP_DRAW_LAYER0, 1); //draw_sprites(screen->machine, bitmap, cliprect, 1); draw priority sprites? - tilemap_draw(bitmap, cliprect, fg_tilemap, 0, 2); + tilemap_draw(bitmap, cliprect, state->fg_tilemap, 0, 2); return 0; } diff --git a/src/mame/video/tryout.c b/src/mame/video/tryout.c index 0e4ccf4051f..33f0cccd60e 100644 --- a/src/mame/video/tryout.c +++ b/src/mame/video/tryout.c @@ -8,10 +8,6 @@ #include "emu.h" #include "includes/tryout.h" -static tilemap_t *fg_tilemap, *bg_tilemap; -static UINT8 vram_bank; -static UINT8 *tryout_vram, *tryout_vram_gfx; -UINT8 *tryout_gfx_control; PALETTE_INIT( tryout ) { @@ -57,12 +53,14 @@ static TILE_GET_INFO( get_fg_tile_info ) static TILE_GET_INFO( get_bg_tile_info ) { - SET_TILE_INFO(2, tryout_vram[tile_index] & 0x7f, 2, 0); + tryout_state *state = machine->driver_data(); + SET_TILE_INFO(2, state->vram[tile_index] & 0x7f, 2, 0); } READ8_HANDLER( tryout_vram_r ) { - return tryout_vram[offset]; // debug only + tryout_state *state = space->machine->driver_data(); + return state->vram[offset]; // debug only } WRITE8_HANDLER( tryout_videoram_w ) @@ -70,11 +68,12 @@ WRITE8_HANDLER( tryout_videoram_w ) tryout_state *state = space->machine->driver_data(); UINT8 *videoram = state->videoram; videoram[offset] = data; - tilemap_mark_tile_dirty(fg_tilemap, offset & 0x3ff); + tilemap_mark_tile_dirty(state->fg_tilemap, offset & 0x3ff); } WRITE8_HANDLER( tryout_vram_w ) { + tryout_state *state = space->machine->driver_data(); /* There are eight banks of vram - in bank 0 the first 0x400 bytes is reserved for the tilemap. In banks 2, 4 and 6 the game never writes to the first 0x400 bytes - I suspect it's either @@ -88,14 +87,14 @@ WRITE8_HANDLER( tryout_vram_w ) gfx data and then set high from that point onwards. */ - const UINT8 bank=(vram_bank>>1)&0x7; + const UINT8 bank=(state->vram_bank>>1)&0x7; if ((bank==0 || bank==2 || bank==4 || bank==6) && (offset&0x7ff)<0x400) { int newoff=offset&0x3ff; - tryout_vram[newoff]=data; - tilemap_mark_tile_dirty(bg_tilemap,newoff); + state->vram[newoff]=data; + tilemap_mark_tile_dirty(state->bg_tilemap,newoff); return; } @@ -109,32 +108,32 @@ WRITE8_HANDLER( tryout_vram_w ) */ offset=(offset&0x7ff) | (bank<<11); - tryout_vram[offset]=data; + state->vram[offset]=data; switch (offset&0x1c00) { case 0x0400: - tryout_vram_gfx[(offset&0x3ff) + 0x0000 + ((offset&0x2000)>>1)]=(~data&0xf); - tryout_vram_gfx[(offset&0x3ff) + 0x2000 + ((offset&0x2000)>>1)]=(~data&0xf0)>>4; + state->vram_gfx[(offset&0x3ff) + 0x0000 + ((offset&0x2000)>>1)]=(~data&0xf); + state->vram_gfx[(offset&0x3ff) + 0x2000 + ((offset&0x2000)>>1)]=(~data&0xf0)>>4; break; case 0x0800: - tryout_vram_gfx[(offset&0x3ff) + 0x4000 + ((offset&0x2000)>>1)]=(~data&0xf); - tryout_vram_gfx[(offset&0x3ff) + 0x4400 + ((offset&0x2000)>>1)]=(~data&0xf0)>>4; + state->vram_gfx[(offset&0x3ff) + 0x4000 + ((offset&0x2000)>>1)]=(~data&0xf); + state->vram_gfx[(offset&0x3ff) + 0x4400 + ((offset&0x2000)>>1)]=(~data&0xf0)>>4; break; case 0x0c00: - tryout_vram_gfx[(offset&0x3ff) + 0x0400 + ((offset&0x2000)>>1)]=(~data&0xf); - tryout_vram_gfx[(offset&0x3ff) + 0x2400 + ((offset&0x2000)>>1)]=(~data&0xf0)>>4; + state->vram_gfx[(offset&0x3ff) + 0x0400 + ((offset&0x2000)>>1)]=(~data&0xf); + state->vram_gfx[(offset&0x3ff) + 0x2400 + ((offset&0x2000)>>1)]=(~data&0xf0)>>4; break; case 0x1400: - tryout_vram_gfx[(offset&0x3ff) + 0x0800 + ((offset&0x2000)>>1)]=(~data&0xf); - tryout_vram_gfx[(offset&0x3ff) + 0x2800 + ((offset&0x2000)>>1)]=(~data&0xf0)>>4; + state->vram_gfx[(offset&0x3ff) + 0x0800 + ((offset&0x2000)>>1)]=(~data&0xf); + state->vram_gfx[(offset&0x3ff) + 0x2800 + ((offset&0x2000)>>1)]=(~data&0xf0)>>4; break; case 0x1800: - tryout_vram_gfx[(offset&0x3ff) + 0x4800 + ((offset&0x2000)>>1)]=(~data&0xf); - tryout_vram_gfx[(offset&0x3ff) + 0x4c00 + ((offset&0x2000)>>1)]=(~data&0xf0)>>4; + state->vram_gfx[(offset&0x3ff) + 0x4800 + ((offset&0x2000)>>1)]=(~data&0xf); + state->vram_gfx[(offset&0x3ff) + 0x4c00 + ((offset&0x2000)>>1)]=(~data&0xf0)>>4; break; case 0x1c00: - tryout_vram_gfx[(offset&0x3ff) + 0x0c00 + ((offset&0x2000)>>1)]=(~data&0xf); - tryout_vram_gfx[(offset&0x3ff) + 0x2c00 + ((offset&0x2000)>>1)]=(~data&0xf0)>>4; + state->vram_gfx[(offset&0x3ff) + 0x0c00 + ((offset&0x2000)>>1)]=(~data&0xf); + state->vram_gfx[(offset&0x3ff) + 0x2c00 + ((offset&0x2000)>>1)]=(~data&0xf0)>>4; break; } @@ -143,7 +142,8 @@ WRITE8_HANDLER( tryout_vram_w ) WRITE8_HANDLER( tryout_vram_bankswitch_w ) { - vram_bank = data; + tryout_state *state = space->machine->driver_data(); + state->vram_bank = data; } WRITE8_HANDLER( tryout_flipscreen_w ) @@ -170,15 +170,16 @@ static TILEMAP_MAPPER( get_bg_memory_offset ) VIDEO_START( tryout ) { - fg_tilemap = tilemap_create(machine, get_fg_tile_info,get_fg_memory_offset,8,8,32,32); - bg_tilemap = tilemap_create(machine, get_bg_tile_info,get_bg_memory_offset,16,16,64,16); + tryout_state *state = machine->driver_data(); + state->fg_tilemap = tilemap_create(machine, get_fg_tile_info,get_fg_memory_offset,8,8,32,32); + state->bg_tilemap = tilemap_create(machine, get_bg_tile_info,get_bg_memory_offset,16,16,64,16); - tryout_vram=auto_alloc_array(machine, UINT8, 8 * 0x800); - tryout_vram_gfx=auto_alloc_array(machine, UINT8, 0x6000); + state->vram=auto_alloc_array(machine, UINT8, 8 * 0x800); + state->vram_gfx=auto_alloc_array(machine, UINT8, 0x6000); - gfx_element_set_source(machine->gfx[2], tryout_vram_gfx); + gfx_element_set_source(machine->gfx[2], state->vram_gfx); - tilemap_set_transparent_pen(fg_tilemap,0); + tilemap_set_transparent_pen(state->fg_tilemap,0); } static void draw_sprites(running_machine *machine, bitmap_t *bitmap,const rectangle *cliprect) @@ -233,33 +234,34 @@ static void draw_sprites(running_machine *machine, bitmap_t *bitmap,const rectan VIDEO_UPDATE( tryout ) { + tryout_state *state = screen->machine->driver_data(); int scrollx = 0; if (!flip_screen_get(screen->machine)) - tilemap_set_scrollx(fg_tilemap, 0, 16); /* Assumed hard-wired */ + tilemap_set_scrollx(state->fg_tilemap, 0, 16); /* Assumed hard-wired */ else - tilemap_set_scrollx(fg_tilemap, 0, -8); /* Assumed hard-wired */ + tilemap_set_scrollx(state->fg_tilemap, 0, -8); /* Assumed hard-wired */ - scrollx = tryout_gfx_control[1] + ((tryout_gfx_control[0]&1)<<8) + ((tryout_gfx_control[0]&4)<<7) - ((tryout_gfx_control[0] & 2) ? 0 : 0x100); + scrollx = state->gfx_control[1] + ((state->gfx_control[0]&1)<<8) + ((state->gfx_control[0]&4)<<7) - ((state->gfx_control[0] & 2) ? 0 : 0x100); /* wrap-around */ - if(tryout_gfx_control[1] == 0) { scrollx+=0x100; } + if(state->gfx_control[1] == 0) { scrollx+=0x100; } - tilemap_set_scrollx(bg_tilemap, 0, scrollx+2); /* why +2? hard-wired? */ - tilemap_set_scrolly(bg_tilemap, 0, -tryout_gfx_control[2]); + tilemap_set_scrollx(state->bg_tilemap, 0, scrollx+2); /* why +2? hard-wired? */ + tilemap_set_scrolly(state->bg_tilemap, 0, -state->gfx_control[2]); - if(!(tryout_gfx_control[0] & 0x8)) // screen disable + if(!(state->gfx_control[0] & 0x8)) // screen disable { /* TODO: Color might be different, needs a video from an original pcb. */ bitmap_fill(bitmap, cliprect, screen->machine->pens[0x10]); } else { - tilemap_draw(bitmap,cliprect,bg_tilemap,0,0); - tilemap_draw(bitmap,cliprect,fg_tilemap,0,0); + tilemap_draw(bitmap,cliprect,state->bg_tilemap,0,0); + tilemap_draw(bitmap,cliprect,state->fg_tilemap,0,0); draw_sprites(screen->machine, bitmap,cliprect); } -// popmessage("%02x %02x %02x %02x",tryout_gfx_control[0],tryout_gfx_control[1],tryout_gfx_control[2],scrollx); +// popmessage("%02x %02x %02x %02x",state->gfx_control[0],state->gfx_control[1],state->gfx_control[2],scrollx); return 0; } diff --git a/src/mame/video/vulgus.c b/src/mame/video/vulgus.c index 55b02e85a6d..a7515d4a145 100644 --- a/src/mame/video/vulgus.c +++ b/src/mame/video/vulgus.c @@ -9,12 +9,6 @@ #include "emu.h" #include "includes/vulgus.h" -UINT8 *vulgus_fgvideoram,*vulgus_bgvideoram; -UINT8 *vulgus_scroll_low,*vulgus_scroll_high; - -static int vulgus_palette_bank; -static tilemap_t *fg_tilemap, *bg_tilemap; - /*************************************************************************** @@ -84,10 +78,11 @@ PALETTE_INIT( vulgus ) static TILE_GET_INFO( get_fg_tile_info ) { + vulgus_state *state = machine->driver_data(); int code, color; - code = vulgus_fgvideoram[tile_index]; - color = vulgus_fgvideoram[tile_index + 0x400]; + code = state->fgvideoram[tile_index]; + color = state->fgvideoram[tile_index + 0x400]; SET_TILE_INFO( 0, code + ((color & 0x80) << 1), @@ -98,14 +93,15 @@ static TILE_GET_INFO( get_fg_tile_info ) static TILE_GET_INFO( get_bg_tile_info ) { + vulgus_state *state = machine->driver_data(); int code, color; - code = vulgus_bgvideoram[tile_index]; - color = vulgus_bgvideoram[tile_index + 0x400]; + code = state->bgvideoram[tile_index]; + color = state->bgvideoram[tile_index + 0x400]; SET_TILE_INFO( 1, code + ((color & 0x80) << 1), - (color & 0x1f) + (0x20 * vulgus_palette_bank), + (color & 0x1f) + (0x20 * state->palette_bank), TILE_FLIPYX((color & 0x60) >> 5)); } @@ -118,10 +114,11 @@ static TILE_GET_INFO( get_bg_tile_info ) VIDEO_START( vulgus ) { - fg_tilemap = tilemap_create(machine, get_fg_tile_info,tilemap_scan_rows, 8, 8,32,32); - bg_tilemap = tilemap_create(machine, get_bg_tile_info,tilemap_scan_cols,16,16,32,32); + vulgus_state *state = machine->driver_data(); + state->fg_tilemap = tilemap_create(machine, get_fg_tile_info,tilemap_scan_rows, 8, 8,32,32); + state->bg_tilemap = tilemap_create(machine, get_bg_tile_info,tilemap_scan_cols,16,16,32,32); - colortable_configure_tilemap_groups(machine->colortable, fg_tilemap, machine->gfx[0], 47); + colortable_configure_tilemap_groups(machine->colortable, state->fg_tilemap, machine->gfx[0], 47); } @@ -133,14 +130,16 @@ VIDEO_START( vulgus ) WRITE8_HANDLER( vulgus_fgvideoram_w ) { - vulgus_fgvideoram[offset] = data; - tilemap_mark_tile_dirty(fg_tilemap,offset & 0x3ff); + vulgus_state *state = space->machine->driver_data(); + state->fgvideoram[offset] = data; + tilemap_mark_tile_dirty(state->fg_tilemap,offset & 0x3ff); } WRITE8_HANDLER( vulgus_bgvideoram_w ) { - vulgus_bgvideoram[offset] = data; - tilemap_mark_tile_dirty(bg_tilemap,offset & 0x3ff); + vulgus_state *state = space->machine->driver_data(); + state->bgvideoram[offset] = data; + tilemap_mark_tile_dirty(state->bg_tilemap,offset & 0x3ff); } @@ -157,10 +156,11 @@ WRITE8_HANDLER( vulgus_c804_w ) WRITE8_HANDLER( vulgus_palette_bank_w ) { - if (vulgus_palette_bank != (data & 3)) + vulgus_state *state = space->machine->driver_data(); + if (state->palette_bank != (data & 3)) { - vulgus_palette_bank = data & 3; - tilemap_mark_all_tiles_dirty(bg_tilemap); + state->palette_bank = data & 3; + tilemap_mark_all_tiles_dirty(state->bg_tilemap); } } @@ -218,11 +218,12 @@ static void draw_sprites(running_machine *machine, bitmap_t *bitmap,const rectan VIDEO_UPDATE( vulgus ) { - tilemap_set_scrollx(bg_tilemap, 0, vulgus_scroll_low[1] + 256 * vulgus_scroll_high[1]); - tilemap_set_scrolly(bg_tilemap, 0, vulgus_scroll_low[0] + 256 * vulgus_scroll_high[0]); + vulgus_state *state = screen->machine->driver_data(); + tilemap_set_scrollx(state->bg_tilemap, 0, state->scroll_low[1] + 256 * state->scroll_high[1]); + tilemap_set_scrolly(state->bg_tilemap, 0, state->scroll_low[0] + 256 * state->scroll_high[0]); - tilemap_draw(bitmap,cliprect,bg_tilemap,0,0); + tilemap_draw(bitmap,cliprect,state->bg_tilemap,0,0); draw_sprites(screen->machine, bitmap,cliprect); - tilemap_draw(bitmap,cliprect,fg_tilemap,0,0); + tilemap_draw(bitmap,cliprect,state->fg_tilemap,0,0); return 0; }