From cbfecc9d6bd63f16c2f219ad51b50dc2e69a23e4 Mon Sep 17 00:00:00 2001 From: Fabio Priuli Date: Sat, 9 Jan 2010 08:36:34 +0000 Subject: [PATCH] Added driver data struct + save states to darius.c & othunder.c Added driver data struct to ninjaw.c, slapshot.c, warriorb.c, wgp.c There is still some TC0100SCN issue when reloading, which corrupts tilemap2, hence no save states in the latter drivers atm --- .gitattributes | 6 + src/mame/drivers/darius.c | 429 ++++++++++++++++++++--------------- src/mame/drivers/ninjaw.c | 172 ++++++++------ src/mame/drivers/othunder.c | 172 ++++++++------ src/mame/drivers/slapshot.c | 118 +++++----- src/mame/drivers/warriorb.c | 152 ++++++++----- src/mame/drivers/wgp.c | 126 +++++----- src/mame/includes/darius.h | 69 ++++++ src/mame/includes/ninjaw.h | 40 ++++ src/mame/includes/othunder.h | 53 +++++ src/mame/includes/slapshot.h | 54 +++++ src/mame/includes/warriorb.h | 36 +++ src/mame/includes/wgp.h | 52 +++++ src/mame/video/darius.c | 105 ++++----- src/mame/video/ninjaw.c | 81 +++---- src/mame/video/othunder.c | 76 +++---- src/mame/video/slapshot.c | 323 ++++++++++++-------------- src/mame/video/taitoic.c | 7 + src/mame/video/warriorb.c | 42 ++-- src/mame/video/wgp.c | 345 ++++++++++++++-------------- 20 files changed, 1439 insertions(+), 1019 deletions(-) create mode 100644 src/mame/includes/darius.h create mode 100644 src/mame/includes/ninjaw.h create mode 100644 src/mame/includes/othunder.h create mode 100644 src/mame/includes/slapshot.h create mode 100644 src/mame/includes/warriorb.h create mode 100644 src/mame/includes/wgp.h diff --git a/.gitattributes b/.gitattributes index d5267abbea9..b24333c549f 100644 --- a/.gitattributes +++ b/.gitattributes @@ -2438,6 +2438,7 @@ src/mame/includes/crshrace.h svneol=native#text/plain src/mame/includes/cubocd32.h svneol=native#text/plain src/mame/includes/cvs.h svneol=native#text/plain src/mame/includes/cyberbal.h svneol=native#text/plain +src/mame/includes/darius.h svneol=native#text/plain src/mame/includes/dbz.h svneol=native#text/plain src/mame/includes/dc.h svneol=native#text/plain src/mame/includes/dcheese.h svneol=native#text/plain @@ -2645,6 +2646,7 @@ src/mame/includes/nemesis.h svneol=native#text/plain src/mame/includes/neogeo.h svneol=native#text/plain src/mame/includes/news.h svneol=native#text/plain src/mame/includes/ninjakd2.h svneol=native#text/plain +src/mame/includes/ninjaw.h svneol=native#text/plain src/mame/includes/nitedrvr.h svneol=native#text/plain src/mame/includes/niyanpai.h svneol=native#text/plain src/mame/includes/nmk16.h svneol=native#text/plain @@ -2655,6 +2657,7 @@ src/mame/includes/offtwall.h svneol=native#text/plain src/mame/includes/oneshot.h svneol=native#text/plain src/mame/includes/opwolf.h svneol=native#text/plain src/mame/includes/orbit.h svneol=native#text/plain +src/mame/includes/othunder.h svneol=native#text/plain src/mame/includes/overdriv.h svneol=native#text/plain src/mame/includes/pacman.h svneol=native#text/plain src/mame/includes/pandoras.h svneol=native#text/plain @@ -2704,6 +2707,7 @@ src/mame/includes/skullxbo.h svneol=native#text/plain src/mame/includes/skydiver.h svneol=native#text/plain src/mame/includes/skyraid.h svneol=native#text/plain src/mame/includes/slapfght.h svneol=native#text/plain +src/mame/includes/slapshot.h svneol=native#text/plain src/mame/includes/slapstic.h svneol=native#text/plain src/mame/includes/snes.h svneol=native#text/plain src/mame/includes/snk.h svneol=native#text/plain @@ -2782,7 +2786,9 @@ src/mame/includes/vindictr.h svneol=native#text/plain src/mame/includes/volfied.h svneol=native#text/plain src/mame/includes/vsnes.h svneol=native#text/plain src/mame/includes/warpwarp.h svneol=native#text/plain +src/mame/includes/warriorb.h svneol=native#text/plain src/mame/includes/wc90.h svneol=native#text/plain +src/mame/includes/wgp.h svneol=native#text/plain src/mame/includes/williams.h svneol=native#text/plain src/mame/includes/wiping.h svneol=native#text/plain src/mame/includes/wrally.h svneol=native#text/plain diff --git a/src/mame/drivers/darius.c b/src/mame/drivers/darius.c index 80eed895ab4..3a38e1c559b 100644 --- a/src/mame/drivers/darius.c +++ b/src/mame/drivers/darius.c @@ -134,46 +134,37 @@ sounds. #include "sound/2203intf.h" #include "sound/msm5205.h" #include "sound/flt_vol.h" +#include "includes/darius.h" #include "darius.lh" -static MACHINE_START( darius ); -static MACHINE_RESET( darius ); - -VIDEO_START( darius ); -VIDEO_UPDATE( darius ); - -static UINT16 cpua_ctrl; -static UINT16 coin_word=0; - -extern UINT16 *darius_fg_ram; -WRITE16_HANDLER( darius_fg_layer_w ); - - static void parse_control( running_machine *machine ) /* assumes Z80 sandwiched between 68Ks */ { /* bit 0 enables cpu B */ /* however this fails when recovering from a save state if cpu B is disabled !! */ - cputag_set_input_line(machine, "cpub", INPUT_LINE_RESET, (cpua_ctrl &0x1) ? CLEAR_LINE : ASSERT_LINE); - + darius_state *state = (darius_state *)machine->driver_data; + cpu_set_input_line(state->cpub, INPUT_LINE_RESET, (state->cpua_ctrl & 0x01) ? CLEAR_LINE : ASSERT_LINE); } static WRITE16_HANDLER( cpua_ctrl_w ) { - if ((data &0xff00) && ((data &0xff) == 0)) - data = data >> 8; /* for Wgp */ - cpua_ctrl = data; + darius_state *state = (darius_state *)space->machine->driver_data; + + if ((data & 0xff00) && ((data & 0xff) == 0)) + data = data >> 8; + + state->cpua_ctrl = data; parse_control(space->machine); - logerror("CPU #0 PC %06x: write %04x to cpu control\n",cpu_get_pc(space->cpu),data); + logerror("CPU #0 PC %06x: write %04x to cpu control\n", cpu_get_pc(space->cpu), data); } static WRITE16_HANDLER( darius_watchdog_w ) { - watchdog_reset_w(space,0,data); + watchdog_reset_w(space, 0, data); } @@ -183,11 +174,12 @@ static WRITE16_HANDLER( darius_watchdog_w ) static READ16_HANDLER( darius_ioc_r ) { - const device_config *tc0140syt = devtag_get_device(space->machine, "tc0140syt"); + darius_state *state = (darius_state *)space->machine->driver_data; + switch (offset) { case 0x01: - return (tc0140syt_comm_r(tc0140syt, 0) & 0xff); /* sound interface read */ + return (tc0140syt_comm_r(state->tc0140syt, 0) & 0xff); /* sound interface read */ case 0x04: return input_port_read(space->machine, "P1"); @@ -199,7 +191,7 @@ static READ16_HANDLER( darius_ioc_r ) return input_port_read(space->machine, "SYSTEM"); case 0x07: - return coin_word; /* bits 3&4 coin lockouts, must return zero */ + return state->coin_word; /* bits 3&4 coin lockouts, must return zero */ case 0x08: return input_port_read(space->machine, "DSW"); @@ -212,17 +204,18 @@ logerror("CPU #0 PC %06x: warning - read unmapped ioc offset %06x\n",cpu_get_pc( static WRITE16_HANDLER( darius_ioc_w ) { - const device_config *tc0140syt = devtag_get_device(space->machine, "tc0140syt"); + darius_state *state = (darius_state *)space->machine->driver_data; + switch (offset) { case 0x00: /* sound interface write */ - tc0140syt_port_w (tc0140syt, 0, data & 0xff); + tc0140syt_port_w(state->tc0140syt, 0, data & 0xff); return; case 0x01: /* sound interface write */ - tc0140syt_comm_w (tc0140syt, 0, data & 0xff); + tc0140syt_comm_w(state->tc0140syt, 0, data & 0xff); return; case 0x28: /* unknown, written by both cpus - always 0? */ @@ -236,7 +229,7 @@ static WRITE16_HANDLER( darius_ioc_w ) coin_lockout_w(space->machine, 1, ~data & 0x04); coin_counter_w(space->machine, 0, data & 0x08); coin_counter_w(space->machine, 1, data & 0x40); - coin_word = data &0xffff; + state->coin_word = data & 0xffff; //popmessage(" address %04x value %04x",offset,data); return; } @@ -260,9 +253,9 @@ static ADDRESS_MAP_START( darius_map, ADDRESS_SPACE_PROGRAM, 16 ) AM_RANGE(0xd40000, 0xd40003) AM_DEVWRITE("pc080sn", pc080sn_xscroll_word_w) AM_RANGE(0xd50000, 0xd50003) AM_DEVWRITE("pc080sn", pc080sn_ctrl_word_w) AM_RANGE(0xd80000, 0xd80fff) AM_RAM_WRITE(paletteram16_xBBBBBGGGGGRRRRR_word_w) AM_BASE_GENERIC(paletteram)/* palette */ - AM_RANGE(0xe00100, 0xe00fff) AM_RAM AM_SHARE("share1") AM_BASE_SIZE_GENERIC(spriteram) + AM_RANGE(0xe00100, 0xe00fff) AM_RAM AM_SHARE("share1") AM_BASE_SIZE_MEMBER(darius_state, spriteram, spriteram_size) AM_RANGE(0xe01000, 0xe02fff) AM_RAM AM_SHARE("share2") - AM_RANGE(0xe08000, 0xe0ffff) AM_RAM_WRITE(darius_fg_layer_w) AM_SHARE("share3") AM_BASE(&darius_fg_ram) + AM_RANGE(0xe08000, 0xe0ffff) AM_RAM_WRITE(darius_fg_layer_w) AM_SHARE("share3") AM_BASE_MEMBER(darius_state, fg_ram) AM_RANGE(0xe10000, 0xe10fff) AM_RAM /* ??? */ ADDRESS_MAP_END @@ -281,34 +274,33 @@ ADDRESS_MAP_END SOUND *****************************************************/ -static INT32 banknum; -static UINT8 adpcm_command = 0; -static UINT8 nmi_enable = 0; - -static void reset_sound_region(running_machine *machine) +static void reset_sound_region( running_machine *machine ) { - memory_set_bankptr(machine, "bank1", memory_region(machine, "audiocpu") + (banknum * 0x8000) + 0x10000 ); - + darius_state *state = (darius_state *)machine->driver_data; + memory_set_bank(machine, "bank1", state->banknum); } static WRITE8_HANDLER( sound_bankswitch_w ) { - banknum = data &0x03; - reset_sound_region(space->machine); -// banknum = data; -// reset_sound_region(); + darius_state *state = (darius_state *)space->machine->driver_data; + + state->banknum = data & 0x03; + reset_sound_region(space->machine); +// banknum = data; +// reset_sound_region(); } static WRITE8_HANDLER( adpcm_command_w ) { - adpcm_command = data; + darius_state *state = (darius_state *)space->machine->driver_data; + state->adpcm_command = data; /* logerror("#ADPCM command write =%2x\n",data); */ } #if 0 static WRITE8_HANDLER( display_value ) { - popmessage("d800=%x",data); + popmessage("d800=%x", data); } #endif @@ -317,47 +309,47 @@ static WRITE8_HANDLER( display_value ) Sound mixer/pan control *****************************************************/ -static UINT32 darius_def_vol[0x10]; - -#define DARIUS_VOL_MAX (3*2 + 2) -#define DARIUS_PAN_MAX (2 + 2 + 1) /* FM 2port + PSG 2port + DA 1port */ -static UINT8 darius_vol[DARIUS_VOL_MAX]; -static UINT8 darius_pan[DARIUS_PAN_MAX]; - static void update_fm0( running_machine *machine ) { - const device_config *lvol = devtag_get_device(machine, "filter0.3l"); - const device_config *rvol = devtag_get_device(machine, "filter0.3r"); - int left, right; - left = ( darius_pan[0] * darius_vol[6])>>8; - right = ((0xff - darius_pan[0]) * darius_vol[6])>>8; - if (lvol != NULL) - flt_volume_set_volume(lvol, left / 100.0); - if (rvol != NULL) - flt_volume_set_volume(rvol, right / 100.0); /* FM #0 */ + darius_state *state = (darius_state *)machine->driver_data; + int left = ( state->pan[0] * state->vol[6]) >> 8; + int right = ((0xff - state->pan[0]) * state->vol[6]) >> 8; + + if (state->filter0_3l != NULL) + flt_volume_set_volume(state->filter0_3l, left / 100.0); + if (state->filter0_3r != NULL) + flt_volume_set_volume(state->filter0_3r, right / 100.0); /* FM #0 */ } static void update_fm1( running_machine *machine ) { - const device_config *lvol = devtag_get_device(machine, "filter1.3l"); - const device_config *rvol = devtag_get_device(machine, "filter1.3r"); - int left, right; - left = ( darius_pan[1] * darius_vol[7])>>8; - right = ((0xff - darius_pan[1]) * darius_vol[7])>>8; - if (lvol != NULL) - flt_volume_set_volume(lvol, left / 100.0); - if (rvol != NULL) - flt_volume_set_volume(rvol, right / 100.0); /* FM #1 */ + darius_state *state = (darius_state *)machine->driver_data; + int left = ( state->pan[1] * state->vol[7]) >> 8; + int right = ((0xff - state->pan[1]) * state->vol[7]) >> 8; + + if (state->filter1_3l != NULL) + flt_volume_set_volume(state->filter1_3l, left / 100.0); + if (state->filter1_3r != NULL) + flt_volume_set_volume(state->filter1_3r, right / 100.0); /* FM #1 */ } static void update_psg0( running_machine *machine, int port ) { - static const char *const fltname[3][2] = { { "filter0.0l", "filter0.0r" }, { "filter0.1l", "filter0.1r" }, { "filter0.2l", "filter0.2r" } }; - const device_config *lvol = devtag_get_device(machine, fltname[port][0]); - const device_config *rvol = devtag_get_device(machine, fltname[port][1]); + darius_state *state = (darius_state *)machine->driver_data; + const device_config *lvol = NULL, *rvol = NULL; int left, right; - left = ( darius_pan[2] * darius_vol[port])>>8; - right = ((0xff - darius_pan[2]) * darius_vol[port])>>8; + + switch (port) + { + case 0: lvol = state->filter0_0l; rvol = state->filter0_0r; break; + case 1: lvol = state->filter0_1l; rvol = state->filter0_1r; break; + case 2: lvol = state->filter0_2l; rvol = state->filter0_2r; break; + default: break; + } + + left = ( state->pan[2] * state->vol[port]) >> 8; + right = ((0xff - state->pan[2]) * state->vol[port]) >> 8; + if (lvol != NULL) flt_volume_set_volume(lvol, left / 100.0); if (rvol != NULL) @@ -366,12 +358,21 @@ static void update_psg0( running_machine *machine, int port ) static void update_psg1( running_machine *machine, int port ) { - static const char *const fltname[3][2] = { { "filter0.0l", "filter0.0r" }, { "filter0.1l", "filter0.1r" }, { "filter0.2l", "filter0.2r" } }; - const device_config *lvol = devtag_get_device(machine, fltname[port][0]); - const device_config *rvol = devtag_get_device(machine, fltname[port][1]); + darius_state *state = (darius_state *)machine->driver_data; + const device_config *lvol = NULL, *rvol = NULL; int left, right; - left = ( darius_pan[3] * darius_vol[port + 3])>>8; - right = ((0xff - darius_pan[3]) * darius_vol[port + 3])>>8; + + switch (port) + { + case 0: lvol = state->filter1_0l; rvol = state->filter1_0r; break; + case 1: lvol = state->filter1_1l; rvol = state->filter1_1r; break; + case 2: lvol = state->filter1_2l; rvol = state->filter1_2r; break; + default: break; + } + + left = ( state->pan[3] * state->vol[port + 3]) >> 8; + right = ((0xff - state->pan[3]) * state->vol[port + 3]) >> 8; + if (lvol != NULL) flt_volume_set_volume(lvol, left / 100.0); if (rvol != NULL) @@ -380,48 +381,52 @@ static void update_psg1( running_machine *machine, int port ) static void update_da( running_machine *machine ) { - const device_config *lvol = devtag_get_device(machine, "msm5205.l"); - const device_config *rvol = devtag_get_device(machine, "msm5205.r"); - int left, right; - left = darius_def_vol[(darius_pan[4]>>4)&0x0f]; - right = darius_def_vol[(darius_pan[4]>>0)&0x0f]; - if (lvol != NULL) - flt_volume_set_volume(lvol, left / 100.0); - if (rvol != NULL) - flt_volume_set_volume(rvol, right / 100.0); /* FM #1 */ + darius_state *state = (darius_state *)machine->driver_data; + int left = state->def_vol[(state->pan[4] >> 4) & 0x0f]; + int right = state->def_vol[(state->pan[4] >> 0) & 0x0f]; + + if (state->msm5205_l != NULL) + flt_volume_set_volume(state->msm5205_l, left / 100.0); + if (state->msm5205_r != NULL) + flt_volume_set_volume(state->msm5205_r, right / 100.0); } static WRITE8_HANDLER( darius_fm0_pan ) { - darius_pan[0] = data&0xff; /* data 0x00:right 0xff:left */ + darius_state *state = (darius_state *)space->machine->driver_data; + state->pan[0] = data & 0xff; /* data 0x00:right 0xff:left */ update_fm0(space->machine); } static WRITE8_HANDLER( darius_fm1_pan ) { - darius_pan[1] = data&0xff; + darius_state *state = (darius_state *)space->machine->driver_data; + state->pan[1] = data & 0xff; update_fm1(space->machine); } static WRITE8_HANDLER( darius_psg0_pan ) { - darius_pan[2] = data&0xff; - update_psg0( space->machine, 0 ); - update_psg0( space->machine, 1 ); - update_psg0( space->machine, 2 ); + darius_state *state = (darius_state *)space->machine->driver_data; + state->pan[2] = data & 0xff; + update_psg0(space->machine, 0); + update_psg0(space->machine, 1); + update_psg0(space->machine, 2); } static WRITE8_HANDLER( darius_psg1_pan ) { - darius_pan[3] = data&0xff; - update_psg1( space->machine, 0 ); - update_psg1( space->machine, 1 ); - update_psg1( space->machine, 2 ); + darius_state *state = (darius_state *)space->machine->driver_data; + state->pan[3] = data & 0xff; + update_psg1(space->machine, 0); + update_psg1(space->machine, 1); + update_psg1(space->machine, 2); } static WRITE8_HANDLER( darius_da_pan ) { - darius_pan[4] = data&0xff; + darius_state *state = (darius_state *)space->machine->driver_data; + state->pan[4] = data & 0xff; update_da(space->machine); } @@ -429,43 +434,55 @@ static WRITE8_HANDLER( darius_da_pan ) static WRITE8_DEVICE_HANDLER( darius_write_portA0 ) { + darius_state *state = (darius_state *)device->machine->driver_data; + // volume control FM #0 PSG #0 A - //popmessage(" pan %02x %02x %02x %02x %02x", darius_pan[0], darius_pan[1], darius_pan[2], darius_pan[3], darius_pan[4] ); + //popmessage(" pan %02x %02x %02x %02x %02x", state->pan[0], state->pan[1], state->pan[2], state->pan[3], state->pan[4] ); //popmessage(" A0 %02x A1 %02x B0 %02x B1 %02x", port[0], port[1], port[2], port[3] ); - darius_vol[0] = darius_def_vol[(data>>4)&0x0f]; - darius_vol[6] = darius_def_vol[(data>>0)&0x0f]; + + state->vol[0] = state->def_vol[(data >> 4) & 0x0f]; + state->vol[6] = state->def_vol[(data >> 0) & 0x0f]; update_fm0(device->machine); - update_psg0( device->machine, 0 ); + update_psg0(device->machine, 0); } static WRITE8_DEVICE_HANDLER( darius_write_portA1 ) { + darius_state *state = (darius_state *)device->machine->driver_data; + // volume control FM #1 PSG #1 A - //popmessage(" pan %02x %02x %02x %02x %02x", darius_pan[0], darius_pan[1], darius_pan[2], darius_pan[3], darius_pan[4] ); - darius_vol[3] = darius_def_vol[(data>>4)&0x0f]; - darius_vol[7] = darius_def_vol[(data>>0)&0x0f]; + //popmessage(" pan %02x %02x %02x %02x %02x", state->pan[0], state->pan[1], state->pan[2], state->pan[3], state->pan[4] ); + + state->vol[3] = state->def_vol[(data >> 4) & 0x0f]; + state->vol[7] = state->def_vol[(data >> 0) & 0x0f]; update_fm1(device->machine); - update_psg1( device->machine, 0 ); + update_psg1(device->machine, 0); } static WRITE8_DEVICE_HANDLER( darius_write_portB0 ) { + darius_state *state = (darius_state *)device->machine->driver_data; + // volume control PSG #0 B/C - //popmessage(" pan %02x %02x %02x %02x %02x", darius_pan[0], darius_pan[1], darius_pan[2], darius_pan[3], darius_pan[4] ); - darius_vol[1] = darius_def_vol[(data>>4)&0x0f]; - darius_vol[2] = darius_def_vol[(data>>0)&0x0f]; - update_psg0( device->machine, 1 ); - update_psg0( device->machine, 2 ); + //popmessage(" pan %02x %02x %02x %02x %02x", state->pan[0], state->pan[1], state->pan[2], state->pan[3], state->pan[4] ); + + state->vol[1] = state->def_vol[(data >> 4) & 0x0f]; + state->vol[2] = state->def_vol[(data >> 0) & 0x0f]; + update_psg0(device->machine, 1); + update_psg0(device->machine, 2); } static WRITE8_DEVICE_HANDLER( darius_write_portB1 ) { + darius_state *state = (darius_state *)device->machine->driver_data; + // volume control PSG #1 B/C - //popmessage(" pan %02x %02x %02x %02x %02x", darius_pan[0], darius_pan[1], darius_pan[2], darius_pan[3], darius_pan[4] ); - darius_vol[4] = darius_def_vol[(data>>4)&0x0f]; - darius_vol[5] = darius_def_vol[(data>>0)&0x0f]; - update_psg1( device->machine, 1 ); - update_psg1( device->machine, 2 ); + //popmessage(" pan %02x %02x %02x %02x %02x", state->pan[0], state->pan[1], state->pan[2], state->pan[3], state->pan[4] ); + + state->vol[4] = state->def_vol[(data >> 4) & 0x0f]; + state->vol[5] = state->def_vol[(data >> 0) & 0x0f]; + update_psg1(device->machine, 1); + update_psg1(device->machine, 2); } @@ -496,10 +513,12 @@ static ADDRESS_MAP_START( darius_sound2_map, ADDRESS_SPACE_PROGRAM, 8 ) ADDRESS_MAP_END -static void darius_adpcm_int (const device_config *device) +static void darius_adpcm_int( const device_config *device ) { - if (nmi_enable) - cputag_set_input_line(device->machine, "adpcm", INPUT_LINE_NMI, PULSE_LINE); + darius_state *state = (darius_state *)device->machine->driver_data; + + if (state->nmi_enable) + cpu_set_input_line(state->adpcm, INPUT_LINE_NMI, PULSE_LINE); } static const msm5205_interface msm5205_config = @@ -510,8 +529,10 @@ static const msm5205_interface msm5205_config = static READ8_HANDLER( adpcm_command_read ) { + darius_state *state = (darius_state *)space->machine->driver_data; + /* logerror("read port 0: %02x PC=%4x\n",adpcm_command, cpu_get_pc(space->cpu) ); */ - return adpcm_command; + return state->adpcm_command; } static READ8_HANDLER( readport2 ) @@ -524,22 +545,25 @@ static READ8_HANDLER( readport3 ) return 0; } -static WRITE8_HANDLER ( adpcm_nmi_disable ) +static WRITE8_HANDLER( adpcm_nmi_disable ) { - nmi_enable = 0; + darius_state *state = (darius_state *)space->machine->driver_data; + + state->nmi_enable = 0; /* logerror("write port 0: NMI DISABLE PC=%4x\n", data, cpu_get_pc(space->cpu) ); */ } -static WRITE8_HANDLER ( adpcm_nmi_enable ) +static WRITE8_HANDLER( adpcm_nmi_enable ) { - nmi_enable = 1; + darius_state *state = (darius_state *)space->machine->driver_data; + state->nmi_enable = 1; /* logerror("write port 1: NMI ENABLE PC=%4x\n", cpu_get_pc(space->cpu) ); */ } static WRITE8_DEVICE_HANDLER( adpcm_data_w ) { - msm5205_data_w (device, data ); - msm5205_reset_w(device, !(data & 0x20) ); /* my best guess, but it could be output enable as well */ + msm5205_data_w(device, data); + msm5205_reset_w(device, !(data & 0x20)); /* my best guess, but it could be output enable as well */ } static ADDRESS_MAP_START( darius_sound2_io_map, ADDRESS_SPACE_IO, 8 ) @@ -774,9 +798,10 @@ GFXDECODE_END **************************************************************/ /* handler called by the YM2203 emulator when the internal timers cause an IRQ */ -static void irqhandler(const device_config *device, int irq) /* assumes Z80 sandwiched between 68Ks */ +static void irqhandler( const device_config *device, int irq ) /* assumes Z80 sandwiched between 68Ks */ { - cputag_set_input_line(device->machine, "audiocpu", 0, irq ? ASSERT_LINE : CLEAR_LINE); + darius_state *state = (darius_state *)device->machine->driver_data; + cpu_set_input_line(state->audiocpu, 0, irq ? ASSERT_LINE : CLEAR_LINE); } static const ym2203_interface ym2203_interface_1 = @@ -820,8 +845,96 @@ static const tc0140syt_interface darius_tc0140syt_intf = "maincpu", "audiocpu" }; +static STATE_POSTLOAD( darius_postload ) +{ + parse_control(machine); + reset_sound_region(machine); +} + +static MACHINE_START( darius ) +{ + darius_state *state = (darius_state *)machine->driver_data; + + memory_configure_bank(machine, "bank1", 0, 4, memory_region(machine, "audiocpu") + 0x10000, 0x8000); + memory_configure_bank(machine, "bank1", 4, 1, memory_region(machine, "audiocpu"), 0x8000); + memory_set_bank(machine, "bank1", 4); + + state->maincpu = devtag_get_device(machine, "maincpu"); + state->audiocpu = devtag_get_device(machine, "audiocpu"); + state->cpub = devtag_get_device(machine, "cpub"); + state->adpcm = devtag_get_device(machine, "adpcm"); + state->pc080sn = devtag_get_device(machine, "pc080sn"); + state->tc0140syt = devtag_get_device(machine, "tc0140syt"); + + state->lscreen = devtag_get_device(machine, "lscreen"); + state->mscreen = devtag_get_device(machine, "mscreen"); + state->rscreen = devtag_get_device(machine, "rscreen"); + + state->filter0_0l = devtag_get_device(machine, "filter0.0l"); + state->filter0_0r = devtag_get_device(machine, "filter0.0r"); + state->filter0_1l = devtag_get_device(machine, "filter0.1l"); + state->filter0_1r = devtag_get_device(machine, "filter0.1r"); + state->filter0_2l = devtag_get_device(machine, "filter0.2l"); + state->filter0_2r = devtag_get_device(machine, "filter0.2r"); + state->filter0_3l = devtag_get_device(machine, "filter0.3l"); + state->filter0_3r = devtag_get_device(machine, "filter0.3r"); + + state->filter1_0l = devtag_get_device(machine, "filter1.0l"); + state->filter1_0r = devtag_get_device(machine, "filter1.0r"); + state->filter1_1l = devtag_get_device(machine, "filter1.1l"); + state->filter1_1r = devtag_get_device(machine, "filter1.1r"); + state->filter1_2l = devtag_get_device(machine, "filter1.2l"); + state->filter1_2r = devtag_get_device(machine, "filter1.2r"); + state->filter1_3l = devtag_get_device(machine, "filter1.3l"); + state->filter1_3r = devtag_get_device(machine, "filter1.3r"); + + state->msm5205_l = devtag_get_device(machine, "msm5205.l"); + state->msm5205_r = devtag_get_device(machine, "msm5205.r"); + + state_save_register_global(machine, state->cpua_ctrl); + state_save_register_global(machine, state->coin_word); + + state_save_register_global(machine, state->banknum); + state_save_register_global(machine, state->adpcm_command); + state_save_register_global(machine, state->nmi_enable); + state_save_register_global_array(machine, state->vol); + state_save_register_global_array(machine, state->pan); + state_save_register_postload(machine, darius_postload, NULL); +} + + +static MACHINE_RESET( darius ) +{ + darius_state *state = (darius_state *)machine->driver_data; + int i; + + state->cpua_ctrl = 0xff; + state->banknum = 0; + state->coin_word = 0; + state->adpcm_command = 0; + state->nmi_enable = 0; + + sound_global_enable(machine, 1); /* mixer enabled */ + + for (i = 0; i < DARIUS_VOL_MAX; i++) + state->vol[i] = 0x00; /* min volume */ + + for (i = 0; i < DARIUS_PAN_MAX; i++) + state->pan[i] = 0x80; /* center */ + + for (i = 0; i < 0x10; i++) + { + //logerror( "calc %d = %d\n", i, (int)(100.0f / (float)pow(10.0f, (32.0f - (i * (32.0f / (float)(0xf)))) / 20.0f)) ); + state->def_vol[i] = (int)(100.0f / (float)pow(10.0f, (32.0f - (i * (32.0f / (float)(0xf)))) / 20.0f)); + } +} + + static MACHINE_DRIVER_START( darius ) + /* driver data */ + MDRV_DRIVER_DATA(darius_state) + /* basic machine hardware */ MDRV_CPU_ADD("maincpu", M68000,16000000/2) /* 8 MHz ? */ MDRV_CPU_PROGRAM_MAP(darius_map) @@ -1178,63 +1291,19 @@ ROM_END static DRIVER_INIT( darius ) { -// taitosnd_setz80_soundcpu( 2 ); - -} - - -static STATE_POSTLOAD( darius_postload ) -{ - parse_control(machine); - reset_sound_region(machine); -} - -static MACHINE_START( darius ) -{ - cpua_ctrl = 0xff; - banknum = -1; - adpcm_command = 0; - nmi_enable = 0; - - state_save_register_global(machine, cpua_ctrl); - - // (there are other sound vars that may need saving too) // - state_save_register_global(machine, banknum); - state_save_register_global(machine, adpcm_command); - state_save_register_global(machine, nmi_enable); - state_save_register_postload(machine, darius_postload, NULL); -} - - -static MACHINE_RESET( darius ) -{ - int i; - /**** setup sound bank image ****/ UINT8 *RAM = memory_region(machine, "audiocpu"); + int i; - for( i = 3; i >= 0; i-- ){ - memcpy( RAM + 0x8000*i + 0x10000, RAM, 0x4000 ); - memcpy( RAM + 0x8000*i + 0x14000, RAM + 0x4000*i, 0x4000 ); - } - memory_set_bankptr(machine, "bank1", RAM); - - sound_global_enable( machine, 1 ); /* mixer enabled */ - - for( i = 0; i < DARIUS_VOL_MAX; i++ ){ - darius_vol[i] = 0x00; /* min volume */ - } - for( i = 0; i < DARIUS_PAN_MAX; i++ ){ - darius_pan[i] = 0x80; /* center */ - } - for( i = 0; i < 0x10; i++ ){ - //logerror( "calc %d = %d\n", i, (int)(100.0f / (float)pow(10.0f, (32.0f - (i * (32.0f / (float)(0xf)))) / 20.0f)) ); - darius_def_vol[i] = (int)(100.0f / (float)pow(10.0f, (32.0f - (i * (32.0f / (float)(0xf)))) / 20.0f)); + for (i = 3; i >= 0; i--) + { + memcpy(RAM + 0x8000 * i + 0x10000, RAM, 0x4000); + memcpy(RAM + 0x8000 * i + 0x14000, RAM + 0x4000 * i, 0x4000); } } -GAME( 1986, darius, 0, darius, darius, darius, ROT0, "Taito Corporation Japan", "Darius (World)", 0 ) -GAME( 1986, dariusj, darius, darius, dariusj, darius, ROT0, "Taito Corporation", "Darius (Japan)", 0 ) -GAME( 1986, dariuso, darius, darius, dariusj, darius, ROT0, "Taito Corporation", "Darius (Japan old version)", 0 ) -GAME( 1986, dariuse, darius, darius, dariuse, darius, ROT0, "Taito Corporation", "Darius (Extra) (Japan)", 0 ) +GAME( 1986, darius, 0, darius, darius, darius, ROT0, "Taito Corporation Japan", "Darius (World)", GAME_SUPPORTS_SAVE ) +GAME( 1986, dariusj, darius, darius, dariusj, darius, ROT0, "Taito Corporation", "Darius (Japan)", GAME_SUPPORTS_SAVE ) +GAME( 1986, dariuso, darius, darius, dariusj, darius, ROT0, "Taito Corporation", "Darius (Japan old version)", GAME_SUPPORTS_SAVE ) +GAME( 1986, dariuse, darius, darius, dariuse, darius, ROT0, "Taito Corporation", "Darius (Extra) (Japan)", GAME_SUPPORTS_SAVE ) diff --git a/src/mame/drivers/ninjaw.c b/src/mame/drivers/ninjaw.c index a722da98d97..471b1510354 100644 --- a/src/mame/drivers/ninjaw.c +++ b/src/mame/drivers/ninjaw.c @@ -312,42 +312,38 @@ rumbling on a subwoofer in the cabinet.) #include "driver.h" #include "cpu/z80/z80.h" -#include "includes/taitoipt.h" #include "cpu/m68000/m68000.h" #include "video/taitoic.h" #include "machine/taitoio.h" #include "audio/taitosnd.h" #include "sound/2610intf.h" #include "sound/flt_vol.h" +#include "includes/taitoipt.h" +#include "includes/ninjaw.h" extern const char layout_darius[]; -static MACHINE_START( ninjaw ); -static MACHINE_RESET( ninjaw ); - -VIDEO_START( ninjaw ); -VIDEO_UPDATE( ninjaw ); - -static UINT16 cpua_ctrl; - -static void parse_control(running_machine *machine) /* assumes Z80 sandwiched between 68Ks */ +static void parse_control( running_machine *machine ) /* assumes Z80 sandwiched between 68Ks */ { /* bit 0 enables cpu B */ /* however this fails when recovering from a save state if cpu B is disabled !! */ - cputag_set_input_line(machine, "sub", INPUT_LINE_RESET, (cpua_ctrl &0x1) ? CLEAR_LINE : ASSERT_LINE); + ninjaw_state *state = (ninjaw_state *)machine->driver_data; + cpu_set_input_line(state->subcpu, INPUT_LINE_RESET, (state->cpua_ctrl & 0x1) ? CLEAR_LINE : ASSERT_LINE); } static WRITE16_HANDLER( cpua_ctrl_w ) { + ninjaw_state *state = (ninjaw_state *)space->machine->driver_data; + if ((data &0xff00) && ((data &0xff) == 0)) - data = data >> 8; /* for Wgp */ - cpua_ctrl = data; + data = data >> 8; + state->cpua_ctrl = data; parse_control(space->machine); - logerror("CPU #0 PC %06x: write %04x to cpu control\n",cpu_get_pc(space->cpu),data); + logerror("CPU #0 PC %06x: write %04x to cpu control\n", cpu_get_pc(space->cpu), data); } @@ -355,64 +351,75 @@ static WRITE16_HANDLER( cpua_ctrl_w ) SOUND *****************************************/ -static INT32 banknum; - -static void reset_sound_region(running_machine *machine) +static void reset_sound_region( running_machine *machine ) { - memory_set_bankptr(machine, "bank10", memory_region(machine, "audiocpu") + (banknum * 0x4000) + 0x10000 ); + ninjaw_state *state = (ninjaw_state *)machine->driver_data; + memory_set_bank(machine, "bank10", state->banknum); } static WRITE8_HANDLER( sound_bankswitch_w ) { - banknum = (data - 1) & 7; + ninjaw_state *state = (ninjaw_state *)space->machine->driver_data; + + state->banknum = data & 7; reset_sound_region(space->machine); } static WRITE16_HANDLER( ninjaw_sound_w ) { - const device_config *tc0140syt = devtag_get_device(space->machine, "tc0140syt"); + ninjaw_state *state = (ninjaw_state *)space->machine->driver_data; + if (offset == 0) - tc0140syt_port_w(tc0140syt, 0, data & 0xff); + tc0140syt_port_w(state->tc0140syt, 0, data & 0xff); else if (offset == 1) - tc0140syt_comm_w(tc0140syt, 0, data & 0xff); + tc0140syt_comm_w(state->tc0140syt, 0, data & 0xff); #ifdef MAME_DEBUG if (data & 0xff00) - popmessage("ninjaw_sound_w to high byte: %04x",data); + popmessage("ninjaw_sound_w to high byte: %04x", data); #endif } static READ16_HANDLER( ninjaw_sound_r ) { - const device_config *tc0140syt = devtag_get_device(space->machine, "tc0140syt"); + ninjaw_state *state = (ninjaw_state *)space->machine->driver_data; + if (offset == 1) - return ((tc0140syt_comm_r(tc0140syt, 0) & 0xff)); + return ((tc0140syt_comm_r(state->tc0140syt, 0) & 0xff)); else return 0; } /**** sound pan control ****/ -static int ninjaw_pandata[4]; + static WRITE8_HANDLER( ninjaw_pancontrol ) { - static const char *const fltname[] = { "2610.1.l", "2610.1.r", "2610.2.l", "2610.2.r" }; - offset = offset&3; - ninjaw_pandata[offset] = (float)data * (100.f / 255.0f); - //popmessage(" pan %02x %02x %02x %02x", ninjaw_pandata[0], ninjaw_pandata[1], ninjaw_pandata[2], ninjaw_pandata[3] ); - flt_volume_set_volume(devtag_get_device(space->machine, fltname[offset]), ninjaw_pandata[offset] / 100.0); + ninjaw_state *state = (ninjaw_state *)space->machine->driver_data; + const device_config *flt = NULL; + offset &= 3; + + switch (offset) + { + case 0: flt = state->_2610_1l; break; + case 1: flt = state->_2610_1r; break; + case 2: flt = state->_2610_2l; break; + case 3: flt = state->_2610_2r; break; + } + + state->pandata[offset] = (float)data * (100.f / 255.0f); + //popmessage(" pan %02x %02x %02x %02x", state->pandata[0], state->pandata[1], state->pandata[2], state->pandata[3] ); + flt_volume_set_volume(flt, state->pandata[offset] / 100.0); } WRITE16_HANDLER( tc0100scn_triple_screen_w ) { - const device_config *tc0100scn_1 = devtag_get_device(space->machine, "tc0100scn_1"); - const device_config *tc0100scn_2 = devtag_get_device(space->machine, "tc0100scn_2"); - const device_config *tc0100scn_3 = devtag_get_device(space->machine, "tc0100scn_3"); + ninjaw_state *state = (ninjaw_state *)space->machine->driver_data; - tc0100scn_word_w(tc0100scn_1, offset, data, mem_mask); - tc0100scn_word_w(tc0100scn_2, offset, data, mem_mask); - tc0100scn_word_w(tc0100scn_3, offset, data, mem_mask); + tc0100scn_word_w(state->tc0100scn_1, offset, data, mem_mask); + tc0100scn_word_w(state->tc0100scn_2, offset, data, mem_mask); + tc0100scn_word_w(state->tc0100scn_3, offset, data, mem_mask); } /*********************************************************** @@ -427,7 +434,7 @@ static ADDRESS_MAP_START( ninjaw_master_map, ADDRESS_SPACE_PROGRAM, 16 ) AM_RANGE(0x210000, 0x210001) AM_WRITE(cpua_ctrl_w) AM_RANGE(0x220000, 0x220003) AM_READWRITE(ninjaw_sound_r,ninjaw_sound_w) AM_RANGE(0x240000, 0x24ffff) AM_RAM AM_SHARE("share1") - AM_RANGE(0x260000, 0x263fff) AM_RAM AM_SHARE("share2") AM_BASE_SIZE_GENERIC(spriteram) + AM_RANGE(0x260000, 0x263fff) AM_RAM AM_SHARE("share2") AM_BASE_SIZE_MEMBER(ninjaw_state, spriteram, spriteram_size) AM_RANGE(0x280000, 0x293fff) AM_DEVREAD("tc0100scn_1", tc0100scn_word_r) AM_WRITE(tc0100scn_triple_screen_w) /* tilemaps (1st screen/all screens) */ AM_RANGE(0x2a0000, 0x2a000f) AM_DEVREADWRITE("tc0100scn_1", tc0100scn_ctrl_word_r, tc0100scn_ctrl_word_w) AM_RANGE(0x2c0000, 0x2d3fff) AM_DEVREADWRITE("tc0100scn_2", tc0100scn_word_r, tc0100scn_word_w) /* tilemaps (2nd screen) */ @@ -463,7 +470,7 @@ static ADDRESS_MAP_START( darius2_master_map, ADDRESS_SPACE_PROGRAM, 16 ) AM_RANGE(0x210000, 0x210001) AM_WRITE(cpua_ctrl_w) AM_RANGE(0x220000, 0x220003) AM_READWRITE(ninjaw_sound_r,ninjaw_sound_w) AM_RANGE(0x240000, 0x24ffff) AM_RAM AM_SHARE("share1") - AM_RANGE(0x260000, 0x263fff) AM_RAM AM_SHARE("share2") AM_BASE_SIZE_GENERIC(spriteram) + AM_RANGE(0x260000, 0x263fff) AM_RAM AM_SHARE("share2") AM_BASE_SIZE_MEMBER(ninjaw_state, spriteram, spriteram_size) AM_RANGE(0x280000, 0x293fff) AM_DEVREAD("tc0100scn_1", tc0100scn_word_r) AM_WRITE(tc0100scn_triple_screen_w) /* tilemaps (1st screen/all screens) */ AM_RANGE(0x2a0000, 0x2a000f) AM_DEVREADWRITE("tc0100scn_1", tc0100scn_ctrl_word_r, tc0100scn_ctrl_word_w) AM_RANGE(0x2c0000, 0x2d3fff) AM_DEVREADWRITE("tc0100scn_2", tc0100scn_word_r, tc0100scn_word_w) /* tilemaps (2nd screen) */ @@ -639,9 +646,10 @@ GFXDECODE_END **************************************************************/ /* handler called by the YM2610 emulator when the internal timers cause an IRQ */ -static void irqhandler(const device_config *device, int irq) +static void irqhandler( const device_config *device, int irq ) { - cputag_set_input_line(device->machine, "audiocpu", 0, irq ? ASSERT_LINE : CLEAR_LINE); + ninjaw_state *state = (ninjaw_state *)device->machine->driver_data; + cpu_set_input_line(state->audiocpu, 0, irq ? ASSERT_LINE : CLEAR_LINE); } static const ym2610_interface ym2610_config = @@ -662,9 +670,9 @@ static DEVICE_START( subwoofer ) /* The 150 Hz is a common top frequency played by a generic */ /* subwoofer, the real Arcade Machine may differs */ - mixer_set_lowpass_frequency(0,20); - mixer_set_lowpass_frequency(1,20); - mixer_set_lowpass_frequency(2,20); + mixer_set_lowpass_frequency(0, 20); + mixer_set_lowpass_frequency(1, 20); + mixer_set_lowpass_frequency(2, 20); return 0; } @@ -741,8 +749,58 @@ static const tc0140syt_interface ninjaw_tc0140syt_intf = "maincpu", "audiocpu" }; + +static STATE_POSTLOAD( ninjaw_postload ) +{ + parse_control(machine); + reset_sound_region(machine); +} + +static MACHINE_START( ninjaw ) +{ + ninjaw_state *state = (ninjaw_state *)machine->driver_data; + + memory_configure_bank(machine, "bank10", 0, 8, memory_region(machine, "audiocpu") + 0xc000, 0x4000); + + state->maincpu = devtag_get_device(machine, "maincpu"); + state->audiocpu = devtag_get_device(machine, "audiocpu"); + state->subcpu = devtag_get_device(machine, "sub"); + state->tc0140syt = devtag_get_device(machine, "tc0140syt"); + state->tc0100scn_1 = devtag_get_device(machine, "tc0100scn_1"); + state->tc0100scn_2 = devtag_get_device(machine, "tc0100scn_2"); + state->tc0100scn_3 = devtag_get_device(machine, "tc0100scn_3"); + + state->lscreen = devtag_get_device(machine, "lscreen"); + state->mscreen = devtag_get_device(machine, "mscreen"); + state->rscreen = devtag_get_device(machine, "rscreen"); + + state->_2610_1l = devtag_get_device(machine, "2610.1.l"); + state->_2610_1r = devtag_get_device(machine, "2610.1.r"); + state->_2610_2l = devtag_get_device(machine, "2610.2.l"); + state->_2610_2r = devtag_get_device(machine, "2610.2.r"); + + state_save_register_global(machine, state->cpua_ctrl); + state_save_register_global(machine, state->banknum); + state_save_register_global_array(machine, state->pandata); + state_save_register_postload(machine, ninjaw_postload, NULL); +} + +static MACHINE_RESET( ninjaw ) +{ + ninjaw_state *state = (ninjaw_state *)machine->driver_data; + state->cpua_ctrl = 0xff; + state->banknum = 0; + memset(state->pandata, 0, sizeof(state->pandata)); + + /**** mixer control enable ****/ + sound_global_enable(machine, 1); /* mixer enabled */ +} + static MACHINE_DRIVER_START( ninjaw ) + /* driver data */ + MDRV_DRIVER_DATA(ninjaw_state) + /* basic machine hardware */ MDRV_CPU_ADD("maincpu", M68000,16000000/2) /* 8 MHz ? */ MDRV_CPU_PROGRAM_MAP(ninjaw_master_map) @@ -827,6 +885,9 @@ MACHINE_DRIVER_END static MACHINE_DRIVER_START( darius2 ) + /* driver data */ + MDRV_DRIVER_DATA(ninjaw_state) + /* basic machine hardware */ MDRV_CPU_ADD("maincpu", M68000,16000000/2) /* 8 MHz ? */ MDRV_CPU_PROGRAM_MAP(darius2_master_map) @@ -1068,29 +1129,6 @@ ROM_START( darius2 ) ROM_LOAD( "c07-12.107", 0x00000, 0x80000, CRC(e0b71258) SHA1(0258e308b643d723475824752ebffc4ea29d1ac4) ) ROM_END -static STATE_POSTLOAD( ninjaw_postload ) -{ - parse_control(machine); - reset_sound_region(machine); -} - -static MACHINE_START( ninjaw ) -{ - cpua_ctrl = 0xff; - banknum = -1; - memset(ninjaw_pandata, 0, sizeof(ninjaw_pandata)); - - state_save_register_global(machine, cpua_ctrl); - state_save_register_global(machine, banknum); - state_save_register_postload(machine, ninjaw_postload, NULL); -} - -static MACHINE_RESET( ninjaw ) -{ - /**** mixer control enable ****/ - sound_global_enable( machine, 1 ); /* mixer enabled */ -} - /* Working Games */ diff --git a/src/mame/drivers/othunder.c b/src/mame/drivers/othunder.c index b9a163dba60..3a057bee510 100644 --- a/src/mame/drivers/othunder.c +++ b/src/mame/drivers/othunder.c @@ -232,7 +232,6 @@ TODO: #include "driver.h" #include "cpu/z80/z80.h" -#include "includes/taitoipt.h" #include "cpu/m68000/m68000.h" #include "machine/eeprom.h" #include "video/taitoic.h" @@ -240,39 +239,33 @@ TODO: #include "audio/taitosnd.h" #include "sound/2610intf.h" #include "sound/flt_vol.h" - -VIDEO_START( othunder ); -VIDEO_UPDATE( othunder ); +#include "includes/othunder.h" +#include "includes/taitoipt.h" /*********************************************************** INTERRUPTS ***********************************************************/ -static int vblank_irq, ad_irq; - -static MACHINE_RESET( othunder ) +static void update_irq( running_machine *machine ) { - vblank_irq = 0; - ad_irq = 0; -} - -static void update_irq(running_machine *machine) -{ - cputag_set_input_line(machine, "maincpu", 6, ad_irq ? ASSERT_LINE : CLEAR_LINE); - cputag_set_input_line(machine, "maincpu", 5, vblank_irq ? ASSERT_LINE : CLEAR_LINE); + othunder_state *state = (othunder_state *)machine->driver_data; + cpu_set_input_line(state->maincpu, 6, state->ad_irq ? ASSERT_LINE : CLEAR_LINE); + cpu_set_input_line(state->maincpu, 5, state->vblank_irq ? ASSERT_LINE : CLEAR_LINE); } static WRITE16_HANDLER( irq_ack_w ) { + othunder_state *state = (othunder_state *)space->machine->driver_data; + switch (offset) { case 0: - vblank_irq = 0; + state->vblank_irq = 0; break; case 1: - ad_irq = 0; + state->ad_irq = 0; break; } @@ -281,13 +274,17 @@ static WRITE16_HANDLER( irq_ack_w ) static INTERRUPT_GEN( vblank_interrupt ) { - vblank_irq = 1; + othunder_state *state = (othunder_state *)device->machine->driver_data; + + state->vblank_irq = 1; update_irq(device->machine); } static TIMER_CALLBACK( ad_interrupt ) { - ad_irq = 1; + othunder_state *state = (othunder_state *)machine->driver_data; + + state->ad_irq = 1; update_irq(machine); } @@ -313,7 +310,7 @@ static const eeprom_interface eeprom_intf = static WRITE16_HANDLER( othunder_tc0220ioc_w ) { - const device_config *device; + othunder_state *state = (othunder_state *)space->machine->driver_data; if (ACCESSING_BITS_0_7) { @@ -333,18 +330,16 @@ static WRITE16_HANDLER( othunder_tc0220ioc_w ) set_led_status(space->machine, 0, data & 1); set_led_status(space->machine, 1, data & 2); -if (data & 4) - popmessage("OBPRI SET!"); + if (data & 4) + popmessage("OBPRI SET!"); - device = devtag_get_device(space->machine, "eeprom"); - eeprom_write_bit(device, data & 0x40); - eeprom_set_clock_line(device, (data & 0x20) ? ASSERT_LINE : CLEAR_LINE); - eeprom_set_cs_line(device, (data & 0x10) ? CLEAR_LINE : ASSERT_LINE); + eeprom_write_bit(state->eeprom, data & 0x40); + eeprom_set_clock_line(state->eeprom, (data & 0x20) ? ASSERT_LINE : CLEAR_LINE); + eeprom_set_cs_line(state->eeprom, (data & 0x10) ? CLEAR_LINE : ASSERT_LINE); break; default: - device = devtag_get_device(space->machine, "tc0220ioc"); - tc0220ioc_w(device, offset, data & 0xff); + tc0220ioc_w(state->tc0220ioc, offset, data & 0xff); } } } @@ -356,17 +351,15 @@ if (data & 4) static READ16_HANDLER( othunder_tc0220ioc_r ) { - const device_config *device; + othunder_state *state = (othunder_state *)space->machine->driver_data; switch (offset) { case 0x03: - device = devtag_get_device(space->machine, "eeprom"); - return (eeprom_read_bit(device) & 1) << 7; + return (eeprom_read_bit(state->eeprom) & 1) << 7; default: - device = devtag_get_device(space->machine, "tc0220ioc"); - return tc0220ioc_r(device, offset); + return tc0220ioc_r(state->tc0220ioc, offset); } } @@ -397,46 +390,34 @@ static WRITE16_HANDLER( othunder_lightgun_w ) SOUND *****************************************/ -static INT32 banknum; - -static void reset_sound_region(running_machine *machine) +static void reset_sound_region( running_machine *machine ) { - memory_set_bankptr(machine, "bank10", memory_region(machine, "audiocpu") + (banknum * 0x4000) + 0x10000 ); -} - -static STATE_POSTLOAD( othunder_postload ) -{ - reset_sound_region(machine); -} - -static MACHINE_START( othunder ) -{ - banknum = -1; - state_save_register_global(machine, banknum); - state_save_register_postload(machine, othunder_postload, NULL); + othunder_state *state = (othunder_state *)machine->driver_data; + memory_set_bank(machine, "bank10", state->banknum); } static WRITE8_HANDLER( sound_bankswitch_w ) { - banknum = (data - 1) & 7; + othunder_state *state = (othunder_state *)space->machine->driver_data; + state->banknum = data & 7; reset_sound_region(space->machine); } static WRITE16_HANDLER( othunder_sound_w ) { - const device_config *tc0140syt = devtag_get_device(space->machine, "tc0140syt"); + othunder_state *state = (othunder_state *)space->machine->driver_data; if (offset == 0) - tc0140syt_port_w(tc0140syt, 0, data & 0xff); + tc0140syt_port_w(state->tc0140syt, 0, data & 0xff); else if (offset == 1) - tc0140syt_comm_w(tc0140syt, 0, data & 0xff); + tc0140syt_comm_w(state->tc0140syt, 0, data & 0xff); } static READ16_HANDLER( othunder_sound_r ) { - const device_config *tc0140syt = devtag_get_device(space->machine, "tc0140syt"); + othunder_state *state = (othunder_state *)space->machine->driver_data; if (offset == 1) - return ((tc0140syt_comm_r(tc0140syt, 0) & 0xff)); + return ((tc0140syt_comm_r(state->tc0140syt, 0) & 0xff)); else return 0; } @@ -445,29 +426,29 @@ static WRITE8_HANDLER( othunder_TC0310FAM_w ) { /* there are two TC0310FAM, one for CH1 and one for CH2 from the YM2610. The PSG output is routed to both chips. */ - static int pan[4]; - int voll,volr; + othunder_state *state = (othunder_state *)space->machine->driver_data; + int voll, volr; - pan[offset] = data & 0x1f; + state->pan[offset] = data & 0x1f; /* PSG output (single ANALOG OUT pin on the YM2610, but we have three channels because we are using the AY-3-8910 emulation. */ - volr = (pan[0] + pan[2]) * 100 / (2 * 0x1f); - voll = (pan[1] + pan[3]) * 100 / (2 * 0x1f); - flt_volume_set_volume(devtag_get_device(space->machine, "2610.0l"), voll / 100.0); - flt_volume_set_volume(devtag_get_device(space->machine, "2610.0r"), volr / 100.0); + volr = (state->pan[0] + state->pan[2]) * 100 / (2 * 0x1f); + voll = (state->pan[1] + state->pan[3]) * 100 / (2 * 0x1f); + flt_volume_set_volume(state->_2610_0l, voll / 100.0); + flt_volume_set_volume(state->_2610_0r, volr / 100.0); /* CH1 */ - volr = pan[0] * 100 / 0x1f; - voll = pan[1] * 100 / 0x1f; - flt_volume_set_volume(devtag_get_device(space->machine, "2610.1l"), voll / 100.0); - flt_volume_set_volume(devtag_get_device(space->machine, "2610.1r"), volr / 100.0); + volr = state->pan[0] * 100 / 0x1f; + voll = state->pan[1] * 100 / 0x1f; + flt_volume_set_volume(state->_2610_1l, voll / 100.0); + flt_volume_set_volume(state->_2610_1r, volr / 100.0); /* CH2 */ - volr = pan[2] * 100 / 0x1f; - voll = pan[3] * 100 / 0x1f; - flt_volume_set_volume(devtag_get_device(space->machine, "2610.2l"), voll / 100.0); - flt_volume_set_volume(devtag_get_device(space->machine, "2610.2r"), volr / 100.0); + volr = state->pan[2] * 100 / 0x1f; + voll = state->pan[3] * 100 / 0x1f; + flt_volume_set_volume(state->_2610_2l, voll / 100.0); + flt_volume_set_volume(state->_2610_2r, volr / 100.0); } @@ -485,7 +466,7 @@ static ADDRESS_MAP_START( othunder_map, ADDRESS_SPACE_PROGRAM, 16 ) AM_RANGE(0x200000, 0x20ffff) AM_DEVREADWRITE("tc0100scn", tc0100scn_word_r, tc0100scn_word_w) /* tilemaps */ AM_RANGE(0x220000, 0x22000f) AM_DEVREADWRITE("tc0100scn", tc0100scn_ctrl_word_r, tc0100scn_ctrl_word_w) AM_RANGE(0x300000, 0x300003) AM_READWRITE(othunder_sound_r, othunder_sound_w) - AM_RANGE(0x400000, 0x4005ff) AM_RAM AM_BASE_SIZE_GENERIC(spriteram) + AM_RANGE(0x400000, 0x4005ff) AM_RAM AM_BASE_SIZE_MEMBER(othunder_state, spriteram, spriteram_size) AM_RANGE(0x500000, 0x500007) AM_READWRITE(othunder_lightgun_r, othunder_lightgun_w) AM_RANGE(0x600000, 0x600003) AM_WRITE(irq_ack_w) ADDRESS_MAP_END @@ -650,9 +631,10 @@ GFXDECODE_END **************************************************************/ /* handler called by the YM2610 emulator when the internal timers cause an IRQ */ -static void irqhandler(const device_config *device, int irq) +static void irqhandler( const device_config *device, int irq ) { - cputag_set_input_line(device->machine, "audiocpu", 0, irq ? ASSERT_LINE : CLEAR_LINE); + othunder_state *state = (othunder_state *)device->machine->driver_data; + cpu_set_input_line(state->audiocpu, 0, irq ? ASSERT_LINE : CLEAR_LINE); } static const ym2610_interface ym2610_config = @@ -692,8 +674,52 @@ static const tc0140syt_interface othunder_tc0140syt_intf = "maincpu", "audiocpu" }; +static STATE_POSTLOAD( othunder_postload ) +{ + reset_sound_region(machine); +} + +static MACHINE_START( othunder ) +{ + othunder_state *state = (othunder_state *)machine->driver_data; + + memory_configure_bank(machine, "bank10", 0, 4, memory_region(machine, "audiocpu") + 0xc000, 0x4000); + + state->maincpu = devtag_get_device(machine, "maincpu"); + state->audiocpu = devtag_get_device(machine, "audiocpu"); + state->eeprom = devtag_get_device(machine, "eeprom"); + state->tc0220ioc = devtag_get_device(machine, "tc0220ioc"); + state->tc0100scn = devtag_get_device(machine, "tc0100scn"); + state->tc0110pcr = devtag_get_device(machine, "tc0110pcr"); + state->tc0140syt = devtag_get_device(machine, "tc0140syt"); + state->_2610_0l = devtag_get_device(machine, "2610.0l"); + state->_2610_0r = devtag_get_device(machine, "2610.0r"); + state->_2610_1l = devtag_get_device(machine, "2610.1l"); + state->_2610_1r = devtag_get_device(machine, "2610.1r"); + state->_2610_2l = devtag_get_device(machine, "2610.2l"); + state->_2610_2r = devtag_get_device(machine, "2610.2r"); + + state_save_register_global(machine, state->vblank_irq); + state_save_register_global(machine, state->ad_irq); + state_save_register_global(machine, state->banknum); + state_save_register_global_array(machine, state->pan); + state_save_register_postload(machine, othunder_postload, NULL); +} + +static MACHINE_RESET( othunder ) +{ + othunder_state *state = (othunder_state *)machine->driver_data; + + state->vblank_irq = 0; + state->ad_irq = 0; + state->banknum = 0; +} + static MACHINE_DRIVER_START( othunder ) + /* driver data */ + MDRV_DRIVER_DATA(othunder_state) + /* basic machine hardware */ // MDRV_CPU_ADD("maincpu", M68000, 24000000/2 ) /* 12 MHz */ MDRV_CPU_ADD("maincpu", M68000, 13000000 ) /* fixes garbage graphics on startup */ diff --git a/src/mame/drivers/slapshot.c b/src/mame/drivers/slapshot.c index 7f56198142d..4b404328f8f 100644 --- a/src/mame/drivers/slapshot.c +++ b/src/mame/drivers/slapshot.c @@ -139,16 +139,7 @@ Region byte at offset 0x031: #include "sound/2610intf.h" #include "machine/timekpr.h" #include "machine/taitoio.h" - - -VIDEO_EOF( taito_no_buffer ); -VIDEO_START( slapshot ); -VIDEO_UPDATE( slapshot ); - -static UINT16 *color_ram; - -extern UINT16 *taito_sprite_ext; -extern size_t taito_spriteext_size; +#include "includes/slapshot.h" /****************************************************** @@ -157,21 +148,23 @@ extern size_t taito_spriteext_size; static READ16_HANDLER( color_ram_word_r ) { - return color_ram[offset]; + slapshot_state *state = (slapshot_state *)space->machine->driver_data; + return state->color_ram[offset]; } static WRITE16_HANDLER( color_ram_word_w ) { + slapshot_state *state = (slapshot_state *)space->machine->driver_data; int r,g,b; - COMBINE_DATA(&color_ram[offset]); + COMBINE_DATA(&state->color_ram[offset]); if ((offset % 2) == 1) /* assume words written sequentially */ { - r = (color_ram[offset-1] &0xff); - g = (color_ram[offset] &0xff00) >> 8; - b = (color_ram[offset] &0xff); + r = (state->color_ram[offset- 1 ] & 0xff); + g = (state->color_ram[offset] & 0xff00) >> 8; + b = (state->color_ram[offset] & 0xff); - palette_set_color(space->machine,offset/2,MAKE_RGB(r,g,b)); + palette_set_color(space->machine, offset / 2, MAKE_RGB(r,g,b)); } } @@ -182,7 +175,8 @@ static WRITE16_HANDLER( color_ram_word_w ) static TIMER_CALLBACK( slapshot_interrupt6 ) { - cputag_set_input_line(machine, "maincpu", 6, HOLD_LINE); + slapshot_state *state = (slapshot_state *)machine->driver_data; + cpu_set_input_line(state->maincpu, 6, HOLD_LINE); } @@ -199,7 +193,7 @@ static INTERRUPT_GEN( slapshot_interrupt ) static READ16_HANDLER( slapshot_service_input_r ) { - const device_config *tc0640fio = devtag_get_device(space->machine, "tc0640fio"); + slapshot_state *state = (slapshot_state *)space->machine->driver_data; switch (offset) { case 0x03: @@ -207,7 +201,7 @@ static READ16_HANDLER( slapshot_service_input_r ) (input_port_read(space->machine, "SERVICE") & 0x10)) << 8; /* IN3 + service switch */ default: - return tc0640fio_r(tc0640fio, offset) << 8; + return tc0640fio_r(state->tc0640fio, offset) << 8; } } @@ -220,47 +214,36 @@ static READ16_HANDLER( opwolf3_adc_r ) static WRITE16_HANDLER( opwolf3_adc_req_w ) { + slapshot_state *state = (slapshot_state *)space->machine->driver_data; + /* 4 writes a frame - one for each analogue port */ - cputag_set_input_line(space->machine, "maincpu", 3, HOLD_LINE); + cpu_set_input_line(state->maincpu, 3, HOLD_LINE); } /***************************************************** SOUND *****************************************************/ -static INT32 banknum; - -static void reset_sound_region(running_machine *machine) +static void reset_sound_region( running_machine *machine ) { - memory_set_bankptr(machine, "bank10", memory_region(machine, "audiocpu") + (banknum * 0x4000) + 0x10000 ); + slapshot_state *state = (slapshot_state *)machine->driver_data; + memory_set_bank(machine, "bank10", state->banknum); } -static STATE_POSTLOAD( slapshot_postload ) -{ - reset_sound_region(machine); -} - -static MACHINE_START( slapshot ) -{ - banknum = -1; - state_save_register_global(machine, banknum); - state_save_register_postload(machine, slapshot_postload, NULL); -} - - static WRITE8_HANDLER( sound_bankswitch_w ) { - banknum = (data - 1) & 7; + slapshot_state *state = (slapshot_state *)space->machine->driver_data; + state->banknum = data & 7; reset_sound_region(space->machine); } static WRITE16_HANDLER( slapshot_msb_sound_w ) { - const device_config *tc0140syt = devtag_get_device(space->machine, "tc0140syt"); + slapshot_state *state = (slapshot_state *)space->machine->driver_data; if (offset == 0) - tc0140syt_port_w(tc0140syt, 0, (data >> 8) & 0xff); + tc0140syt_port_w(state->tc0140syt, 0, (data >> 8) & 0xff); else if (offset == 1) - tc0140syt_comm_w(tc0140syt, 0, (data >> 8) & 0xff); + tc0140syt_comm_w(state->tc0140syt, 0, (data >> 8) & 0xff); #ifdef MAME_DEBUG if (data & 0xff) @@ -270,9 +253,9 @@ static WRITE16_HANDLER( slapshot_msb_sound_w ) static READ16_HANDLER( slapshot_msb_sound_r ) { - const device_config *tc0140syt = devtag_get_device(space->machine, "tc0140syt"); + slapshot_state *state = (slapshot_state *)space->machine->driver_data; if (offset == 1) - return ((tc0140syt_comm_r(tc0140syt, 0) & 0xff) << 8); + return ((tc0140syt_comm_r(state->tc0140syt, 0) & 0xff) << 8); else return 0; } @@ -285,11 +268,11 @@ static READ16_HANDLER( slapshot_msb_sound_r ) static ADDRESS_MAP_START( slapshot_map, ADDRESS_SPACE_PROGRAM, 16 ) AM_RANGE(0x000000, 0x0fffff) AM_ROM AM_RANGE(0x500000, 0x50ffff) AM_RAM /* main RAM */ - AM_RANGE(0x600000, 0x60ffff) AM_RAM AM_BASE_SIZE_GENERIC(spriteram) /* sprite ram */ - AM_RANGE(0x700000, 0x701fff) AM_RAM AM_BASE(&taito_sprite_ext) AM_SIZE(&taito_spriteext_size) /* debugging */ + AM_RANGE(0x600000, 0x60ffff) AM_RAM AM_BASE_SIZE_MEMBER(slapshot_state, spriteram, spriteram_size) /* sprite ram */ + AM_RANGE(0x700000, 0x701fff) AM_RAM AM_BASE_SIZE_MEMBER(slapshot_state, spriteext, spriteext_size) /* debugging */ AM_RANGE(0x800000, 0x80ffff) AM_DEVREADWRITE("tc0480scp", tc0480scp_word_r, tc0480scp_word_w) /* tilemaps */ AM_RANGE(0x830000, 0x83002f) AM_DEVREADWRITE("tc0480scp", tc0480scp_ctrl_word_r, tc0480scp_ctrl_word_w) - AM_RANGE(0x900000, 0x907fff) AM_READWRITE(color_ram_word_r, color_ram_word_w) AM_BASE(&color_ram) /* 8bpg palette */ + AM_RANGE(0x900000, 0x907fff) AM_READWRITE(color_ram_word_r, color_ram_word_w) AM_BASE_MEMBER(slapshot_state, color_ram) /* 8bpg palette */ AM_RANGE(0xa00000, 0xa03fff) AM_DEVREADWRITE8("mk48t08", timekeeper_r, timekeeper_w, 0xff00) /* nvram (only low bytes used) */ AM_RANGE(0xb00000, 0xb0001f) AM_DEVWRITE8("tc0360pri", tc0360pri_w, 0xff00) /* priority chip */ AM_RANGE(0xc00000, 0xc0000f) AM_DEVREADWRITE("tc0640fio", tc0640fio_halfword_byteswap_r, tc0640fio_halfword_byteswap_w) @@ -300,11 +283,11 @@ ADDRESS_MAP_END static ADDRESS_MAP_START( opwolf3_map, ADDRESS_SPACE_PROGRAM, 16 ) AM_RANGE(0x000000, 0x1fffff) AM_ROM AM_RANGE(0x500000, 0x50ffff) AM_RAM /* main RAM */ - AM_RANGE(0x600000, 0x60ffff) AM_RAM AM_BASE_SIZE_GENERIC(spriteram) /* sprite ram */ - AM_RANGE(0x700000, 0x701fff) AM_RAM AM_BASE(&taito_sprite_ext) AM_SIZE(&taito_spriteext_size) /* debugging */ + AM_RANGE(0x600000, 0x60ffff) AM_RAM AM_BASE_SIZE_MEMBER(slapshot_state, spriteram, spriteram_size) /* sprite ram */ + AM_RANGE(0x700000, 0x701fff) AM_RAM AM_BASE_SIZE_MEMBER(slapshot_state, spriteext, spriteext_size) /* debugging */ AM_RANGE(0x800000, 0x80ffff) AM_DEVREADWRITE("tc0480scp", tc0480scp_word_r, tc0480scp_word_w) /* tilemaps */ AM_RANGE(0x830000, 0x83002f) AM_DEVREADWRITE("tc0480scp", tc0480scp_ctrl_word_r, tc0480scp_ctrl_word_w) - AM_RANGE(0x900000, 0x907fff) AM_READWRITE(color_ram_word_r, color_ram_word_w) AM_BASE(&color_ram) /* 8bpg palette */ + AM_RANGE(0x900000, 0x907fff) AM_READWRITE(color_ram_word_r, color_ram_word_w) AM_BASE_MEMBER(slapshot_state, color_ram) /* 8bpg palette */ AM_RANGE(0xa00000, 0xa03fff) AM_DEVREADWRITE8("mk48t08", timekeeper_r, timekeeper_w, 0xff00) /* nvram (only low bytes used) */ AM_RANGE(0xb00000, 0xb0001f) AM_DEVWRITE8("tc0360pri", tc0360pri_w, 0xff00) /* priority chip */ AM_RANGE(0xc00000, 0xc0000f) AM_DEVREADWRITE("tc0640fio", tc0640fio_halfword_byteswap_r, tc0640fio_halfword_byteswap_w) @@ -483,9 +466,10 @@ GFXDECODE_END **************************************************************/ /* handler called by the YM2610 emulator when the internal timers cause an IRQ */ -static void irqhandler(const device_config *device, int irq) +static void irqhandler( const device_config *device, int irq ) { - cputag_set_input_line(device->machine, "audiocpu", 0, irq ? ASSERT_LINE : CLEAR_LINE); + slapshot_state *state = (slapshot_state *)device->machine->driver_data; + cpu_set_input_line(state->audiocpu, 0, irq ? ASSERT_LINE : CLEAR_LINE); } static const ym2610_interface ym2610_config = @@ -519,8 +503,35 @@ static const tc0140syt_interface slapshot_tc0140syt_intf = "maincpu", "audiocpu" }; +static STATE_POSTLOAD( slapshot_postload ) +{ + reset_sound_region(machine); +} + +static MACHINE_START( slapshot ) +{ + slapshot_state *state = (slapshot_state *)machine->driver_data; + + memory_configure_bank(machine, "bank10", 0, 4, memory_region(machine, "audiocpu") + 0xc000, 0x4000); + + state->maincpu = devtag_get_device(machine, "maincpu"); + state->audiocpu = devtag_get_device(machine, "audiocpu"); + state->tc0140syt = devtag_get_device(machine, "tc0140syt"); + state->tc0480scp = devtag_get_device(machine, "tc0480scp"); + state->tc0360pri = devtag_get_device(machine, "tc0360pri"); + state->tc0640fio = devtag_get_device(machine, "tc0640fio"); + + state->banknum = 0; + state_save_register_global(machine, state->banknum); + state_save_register_postload(machine, slapshot_postload, NULL); +} + + static MACHINE_DRIVER_START( slapshot ) + /* driver data */ + MDRV_DRIVER_DATA(slapshot_state) + /* basic machine hardware */ MDRV_CPU_ADD("maincpu", M68000, 14346000) /* 28.6860 MHz / 2 ??? */ MDRV_CPU_PROGRAM_MAP(slapshot_map) @@ -570,6 +581,9 @@ MACHINE_DRIVER_END static MACHINE_DRIVER_START( opwolf3 ) + /* driver data */ + MDRV_DRIVER_DATA(slapshot_state) + /* basic machine hardware */ MDRV_CPU_ADD("maincpu", M68000, 14346000) /* 28.6860 MHz / 2 ??? */ MDRV_CPU_PROGRAM_MAP(opwolf3_map) @@ -580,6 +594,8 @@ static MACHINE_DRIVER_START( opwolf3 ) MDRV_QUANTUM_TIME(HZ(600)) + MDRV_MACHINE_START(slapshot) + MDRV_TC0640FIO_ADD("tc0640fio", slapshot_io_intf) /* video hardware */ diff --git a/src/mame/drivers/warriorb.c b/src/mame/drivers/warriorb.c index dcbbdf334a3..79089fb337f 100644 --- a/src/mame/drivers/warriorb.c +++ b/src/mame/drivers/warriorb.c @@ -47,7 +47,7 @@ TC0100SCN has tilemaps twice as wide as usual. The two BG tilemaps take up twice the usual space, $8000 bytes each. The text tilemap takes up the usual space, as its height is halved. -The double palette generator (one for each screen) is probably just a +The double palette generator(one for each screen) is probably just a result of the way the hardware works: they both have the same colors. @@ -145,7 +145,6 @@ Colscroll effects? #include "driver.h" #include "cpu/z80/z80.h" -#include "includes/taitoipt.h" #include "rendlay.h" #include "cpu/m68000/m68000.h" #include "video/taitoic.h" @@ -153,71 +152,79 @@ Colscroll effects? #include "audio/taitosnd.h" #include "sound/2610intf.h" #include "sound/flt_vol.h" +#include "includes/warriorb.h" +#include "includes/taitoipt.h" static MACHINE_START( warriorb ); static MACHINE_RESET( taito_dualscreen ); -VIDEO_START( warriorb ); -VIDEO_UPDATE( warriorb ); /*********************************************************** SOUND ***********************************************************/ -static INT32 banknum; - -static void reset_sound_region(running_machine *machine) +static void reset_sound_region( running_machine *machine ) { - memory_set_bankptr(machine, "bank10", memory_region(machine, "audiocpu") + (banknum * 0x4000) + 0x10000 ); + warriorb_state *state = (warriorb_state *)machine->driver_data; + memory_set_bank(machine, "bank10", state->banknum); } static WRITE8_HANDLER( sound_bankswitch_w ) { - banknum = (data - 1) & 7; + warriorb_state *state = (warriorb_state *)space->machine->driver_data; + + state->banknum = data & 7; reset_sound_region(space->machine); } static WRITE16_HANDLER( warriorb_sound_w ) { - const device_config *tc0140syt = devtag_get_device(space->machine, "tc0140syt"); + warriorb_state *state = (warriorb_state *)space->machine->driver_data; + if (offset == 0) - tc0140syt_port_w (tc0140syt, 0, data & 0xff); + tc0140syt_port_w(state->tc0140syt, 0, data & 0xff); else if (offset == 1) - tc0140syt_comm_w (tc0140syt, 0, data & 0xff); + tc0140syt_comm_w(state->tc0140syt, 0, data & 0xff); } static READ16_HANDLER( warriorb_sound_r ) { - const device_config *tc0140syt = devtag_get_device(space->machine, "tc0140syt"); + warriorb_state *state = (warriorb_state *)space->machine->driver_data; + if (offset == 1) - return ((tc0140syt_comm_r (tc0140syt, 0) & 0xff)); - else return 0; + return ((tc0140syt_comm_r(state->tc0140syt, 0) & 0xff)); + else + return 0; } -static int ninjaw_pandata[4]; /**** sound pan control ****/ - static WRITE8_HANDLER( warriorb_pancontrol ) { - static const char *const fltname[] = { "2610.1.l", "2610.1.r", "2610.2.l", "2610.2.r" }; + warriorb_state *state = (warriorb_state *)space->machine->driver_data; + const device_config *flt = NULL; + offset &= 3; - offset = offset&3; - ninjaw_pandata[offset] = (data<<1) + data; /* original volume*3 */ + switch (offset) + { + case 0: flt = state->_2610_1l; break; + case 1: flt = state->_2610_1r; break; + case 2: flt = state->_2610_2l; break; + case 3: flt = state->_2610_2r; break; + } -// popmessage(" pan %02x %02x %02x %02x", ninjaw_pandata[0], ninjaw_pandata[1], ninjaw_pandata[2], ninjaw_pandata[3] ); - - flt_volume_set_volume(devtag_get_device(space->machine, fltname[offset & 3]), ninjaw_pandata[offset] / 100.0); + state->pandata[offset] = (data << 1) + data; /* original volume*3 */ + //popmessage(" pan %02x %02x %02x %02x", state->pandata[0], state->pandata[1], state->pandata[2], state->pandata[3] ); + flt_volume_set_volume(flt, state->pandata[offset] / 100.0); } WRITE16_HANDLER( tc0100scn_dual_screen_w ) { - const device_config *tc0100scn_1 = devtag_get_device(space->machine, "tc0100scn_1"); - const device_config *tc0100scn_2 = devtag_get_device(space->machine, "tc0100scn_2"); + warriorb_state *state = (warriorb_state *)space->machine->driver_data; - tc0100scn_word_w(tc0100scn_1, offset, data, mem_mask); - tc0100scn_word_w(tc0100scn_2, offset, data, mem_mask); + tc0100scn_word_w(state->tc0100scn_1, offset, data, mem_mask); + tc0100scn_word_w(state->tc0100scn_2, offset, data, mem_mask); } /*********************************************************** @@ -234,7 +241,7 @@ static ADDRESS_MAP_START( darius2d_map, ADDRESS_SPACE_PROGRAM, 16 ) AM_RANGE(0x260000, 0x26000f) AM_DEVREADWRITE("tc0100scn_2", tc0100scn_ctrl_word_r, tc0100scn_ctrl_word_w) AM_RANGE(0x400000, 0x400007) AM_DEVREADWRITE("tc0110pcr_1", tc0110pcr_word_r, tc0110pcr_step1_word_w) /* palette (1st screen) */ AM_RANGE(0x420000, 0x420007) AM_DEVREADWRITE("tc0110pcr_2", tc0110pcr_word_r, tc0110pcr_step1_word_w) /* palette (2nd screen) */ - AM_RANGE(0x600000, 0x6013ff) AM_RAM AM_BASE_SIZE_GENERIC(spriteram) + AM_RANGE(0x600000, 0x6013ff) AM_RAM AM_BASE_SIZE_MEMBER(warriorb_state, spriteram, spriteram_size) AM_RANGE(0x800000, 0x80000f) AM_DEVREADWRITE8("tc0220ioc", tc0220ioc_r, tc0220ioc_w, 0x00ff) // AM_RANGE(0x820000, 0x820001) AM_WRITENOP // ??? AM_RANGE(0x830000, 0x830003) AM_READWRITE(warriorb_sound_r, warriorb_sound_w) @@ -249,7 +256,7 @@ static ADDRESS_MAP_START( warriorb_map, ADDRESS_SPACE_PROGRAM, 16 ) AM_RANGE(0x360000, 0x36000f) AM_DEVREADWRITE("tc0100scn_2", tc0100scn_ctrl_word_r, tc0100scn_ctrl_word_w) AM_RANGE(0x400000, 0x400007) AM_DEVREADWRITE("tc0110pcr_1", tc0110pcr_word_r, tc0110pcr_step1_word_w) /* palette (1st screen) */ AM_RANGE(0x420000, 0x420007) AM_DEVREADWRITE("tc0110pcr_2", tc0110pcr_word_r, tc0110pcr_step1_word_w) /* palette (2nd screen) */ - AM_RANGE(0x600000, 0x6013ff) AM_RAM AM_BASE_SIZE_GENERIC(spriteram) + AM_RANGE(0x600000, 0x6013ff) AM_RAM AM_BASE_SIZE_MEMBER(warriorb_state, spriteram, spriteram_size) AM_RANGE(0x800000, 0x80000f) AM_DEVREADWRITE("tc0510nio", tc0510nio_halfword_r, tc0510nio_halfword_w) // AM_RANGE(0x820000, 0x820001) AM_WRITENOP // ? uses bits 0,2,3 AM_RANGE(0x830000, 0x830003) AM_READWRITE(warriorb_sound_r, warriorb_sound_w) @@ -410,9 +417,10 @@ GFXDECODE_END **************************************************************/ /* handler called by the YM2610 emulator when the internal timers cause an IRQ */ -static void irqhandler(const device_config *device, int irq) +static void irqhandler( const device_config *device, int irq ) { - cputag_set_input_line(device->machine, "audiocpu", 0, irq ? ASSERT_LINE : CLEAR_LINE); + warriorb_state *state = (warriorb_state *)device->machine->driver_data; + cpu_set_input_line(state->audiocpu, 0, irq ? ASSERT_LINE : CLEAR_LINE); } static const ym2610_interface ym2610_config = @@ -422,7 +430,7 @@ static const ym2610_interface ym2610_config = /************************************************************** - SUBWOOFER (SOUND) + SUBWOOFEr(SOUND) **************************************************************/ #if 0 @@ -430,9 +438,9 @@ static DEVICE_START( subwoofer ) { /* Adjust the lowpass filter of the first three YM2610 channels */ - mixer_set_lowpass_frequency(0,20); - mixer_set_lowpass_frequency(1,20); - mixer_set_lowpass_frequency(2,20); + mixer_set_lowpass_frequency(0, 20); + mixer_set_lowpass_frequency(1, 20); + mixer_set_lowpass_frequency(2, 20); } static DEVICE_GET_INFO( subwoofer ) @@ -522,8 +530,52 @@ static const tc0140syt_interface warriorb_tc0140syt_intf = "maincpu", "audiocpu" }; + +static STATE_POSTLOAD( warriorb_postload ) +{ + reset_sound_region(machine); +} + +static MACHINE_START( warriorb ) +{ + warriorb_state *state = (warriorb_state *)machine->driver_data; + + memory_configure_bank(machine, "bank10", 0, 8, memory_region(machine, "audiocpu") + 0xc000, 0x4000); + + state->maincpu = devtag_get_device(machine, "maincpu"); + state->audiocpu = devtag_get_device(machine, "audiocpu"); + state->tc0140syt = devtag_get_device(machine, "tc0140syt"); + state->tc0100scn_1 = devtag_get_device(machine, "tc0100scn_1"); + state->tc0100scn_2 = devtag_get_device(machine, "tc0100scn_2"); + + state->lscreen = devtag_get_device(machine, "lscreen"); + state->rscreen = devtag_get_device(machine, "rscreen"); + + state->_2610_1l = devtag_get_device(machine, "2610.1.l"); + state->_2610_1r = devtag_get_device(machine, "2610.1.r"); + state->_2610_2l = devtag_get_device(machine, "2610.2.l"); + state->_2610_2r = devtag_get_device(machine, "2610.2.r"); + + state_save_register_global(machine, state->banknum); + state_save_register_global_array(machine, state->pandata); + state_save_register_postload(machine, warriorb_postload, NULL); +} + +static MACHINE_RESET( taito_dualscreen ) +{ + warriorb_state *state = (warriorb_state *)machine->driver_data; + + state->banknum = 0; + + /**** mixer control enable ****/ + sound_global_enable(machine, 1); /* mixer enabled */ +} + static MACHINE_DRIVER_START( darius2d ) + /* driver data */ + MDRV_DRIVER_DATA(warriorb_state) + /* basic machine hardware */ MDRV_CPU_ADD("maincpu", M68000, 12000000) /* 12 MHz ??? (Might well be 16!) */ MDRV_CPU_PROGRAM_MAP(darius2d_map) @@ -591,6 +643,9 @@ MACHINE_DRIVER_END static MACHINE_DRIVER_START( warriorb ) + /* driver data */ + MDRV_DRIVER_DATA(warriorb_state) + /* basic machine hardware */ MDRV_CPU_ADD("maincpu", M68000, 16000000) /* 16 MHz ? */ MDRV_CPU_PROGRAM_MAP(warriorb_map) @@ -674,7 +729,7 @@ ROM_START( darius2d ) ROM_CONTINUE( 0x10000, 0x1c000 ) /* banked stuff */ ROM_REGION( 0x100000, "gfx1", 0 ) - ROM_LOAD( "c07-03.12", 0x00000, 0x80000, CRC(189bafce) SHA1(d885e444523489fe24269b90dec58e0d92cfbd6e) ) /* SCR (screen 1) */ + ROM_LOAD( "c07-03.12", 0x00000, 0x80000, CRC(189bafce) SHA1(d885e444523489fe24269b90dec58e0d92cfbd6e) ) /* SCr(screen 1) */ ROM_LOAD( "c07-04.11", 0x80000, 0x80000, CRC(50421e81) SHA1(27ac420602f1dac00dc32903543a518e6f47fb2f) ) ROM_REGION( 0x200000, "gfx2", 0 ) @@ -684,7 +739,7 @@ ROM_START( darius2d ) ROM_LOAD32_BYTE( "c07-07.26", 0x00003, 0x80000, CRC(fd9f9e74) SHA1(e89beb5cac844fe16662465b0c76337692591aae) ) ROM_REGION( 0x100000, "gfx3", 0 ) - ROM_COPY( "gfx1", 0x000000, 0x000000, 0x100000 ) /* SCR (screen 2) */ + ROM_COPY( "gfx1", 0x000000, 0x000000, 0x100000 ) /* SCr(screen 2) */ /* The actual board duplicates the SCR gfx roms for the 2nd TC0100SCN */ // ROM_LOAD( "c07-03.47", 0x00000, 0x80000, CRC(189bafce) SHA1(d885e444523489fe24269b90dec58e0d92cfbd6e) ) @@ -720,7 +775,7 @@ ROM_START( darius2do ) ROM_CONTINUE( 0x10000, 0x1c000 ) /* banked stuff */ ROM_REGION( 0x100000, "gfx1", 0 ) - ROM_LOAD( "c07-03.12", 0x00000, 0x80000, CRC(189bafce) SHA1(d885e444523489fe24269b90dec58e0d92cfbd6e) ) /* SCR (screen 1) */ + ROM_LOAD( "c07-03.12", 0x00000, 0x80000, CRC(189bafce) SHA1(d885e444523489fe24269b90dec58e0d92cfbd6e) ) /* SCr(screen 1) */ ROM_LOAD( "c07-04.11", 0x80000, 0x80000, CRC(50421e81) SHA1(27ac420602f1dac00dc32903543a518e6f47fb2f) ) ROM_REGION( 0x200000, "gfx2", 0 ) @@ -730,7 +785,7 @@ ROM_START( darius2do ) ROM_LOAD32_BYTE( "c07-07.26", 0x00003, 0x80000, CRC(fd9f9e74) SHA1(e89beb5cac844fe16662465b0c76337692591aae) ) ROM_REGION( 0x100000, "gfx3", 0 ) - ROM_COPY( "gfx1", 0x000000, 0x000000, 0x100000 ) /* SCR (screen 2) */ + ROM_COPY( "gfx1", 0x000000, 0x000000, 0x100000 ) /* SCr(screen 2) */ /* The actual board duplicates the SCR gfx roms for the 2nd TC0100SCN */ // ROM_LOAD( "c07-03.47", 0x00000, 0x80000, CRC(189bafce) SHA1(d885e444523489fe24269b90dec58e0d92cfbd6e) ) @@ -790,25 +845,6 @@ ROM_START( warriorb ) // ROM_LOAD( "d24-16.79", 0x00000, 0xa??, NO_DUMP ) ROM_END -static STATE_POSTLOAD( warriorb_postload ) -{ - reset_sound_region(machine); -} - -static MACHINE_START( warriorb ) -{ - state_save_register_global(machine, banknum); - state_save_register_postload(machine, warriorb_postload, NULL); -} - -static MACHINE_RESET( taito_dualscreen ) -{ - banknum = -1; - - /**** mixer control enable ****/ - sound_global_enable( machine, 1 ); /* mixer enabled */ -} - /* Working Games */ diff --git a/src/mame/drivers/wgp.c b/src/mame/drivers/wgp.c index 66559733564..042dfdfd100 100644 --- a/src/mame/drivers/wgp.c +++ b/src/mame/drivers/wgp.c @@ -401,37 +401,18 @@ Stephh's notes (based on the game M68000 code and some tests) : #include "video/taitoic.h" #include "audio/taitosnd.h" #include "sound/2610intf.h" - -VIDEO_START( wgp ); -VIDEO_START( wgp2 ); -VIDEO_UPDATE( wgp ); - -extern UINT16 *wgp_spritemap; -extern size_t wgp_spritemap_size; - -extern UINT16 *wgp_pivram; -READ16_HANDLER ( wgp_pivram_word_r ); -WRITE16_HANDLER( wgp_pivram_word_w ); - -extern UINT16 *wgp_piv_ctrlram; -READ16_HANDLER ( wgp_piv_ctrl_word_r ); -WRITE16_HANDLER( wgp_piv_ctrl_word_w ); - -static UINT16 cpua_ctrl; -static UINT16 port_sel=0; -extern UINT16 wgp_rotate_ctrl[8]; - -static UINT16 *sharedram; -static size_t sharedram_size; +#include "includes/wgp.h" static READ16_HANDLER( sharedram_r ) { - return sharedram[offset]; + wgp_state *state = (wgp_state *)space->machine->driver_data; + return state->sharedram[offset]; } static WRITE16_HANDLER( sharedram_w ) { - COMBINE_DATA(&sharedram[offset]); + wgp_state *state = (wgp_state *)space->machine->driver_data; + COMBINE_DATA(&state->sharedram[offset]); } static void parse_control(running_machine *machine) @@ -439,16 +420,19 @@ static void parse_control(running_machine *machine) /* bit 0 enables cpu B */ /* however this fails when recovering from a save state if cpu B is disabled !! */ - cputag_set_input_line(machine, "sub", INPUT_LINE_RESET, (cpua_ctrl & 0x1) ? CLEAR_LINE : ASSERT_LINE); + wgp_state *state = (wgp_state *)machine->driver_data; + cpu_set_input_line(state->subcpu, INPUT_LINE_RESET, (state->cpua_ctrl & 0x1) ? CLEAR_LINE : ASSERT_LINE); /* bit 1 is "vibration" acc. to test mode */ } static WRITE16_HANDLER( cpua_ctrl_w ) /* assumes Z80 sandwiched between 68Ks */ { + wgp_state *state = (wgp_state *)space->machine->driver_data; + if ((data &0xff00) && ((data &0xff) == 0)) data = data >> 8; /* for Wgp */ - cpua_ctrl = data; + state->cpua_ctrl = data; parse_control(space->machine); @@ -465,20 +449,23 @@ static WRITE16_HANDLER( cpua_ctrl_w ) /* assumes Z80 sandwiched between 68Ks */ #ifdef UNUSED_FUNCTION static TIMER_CALLBACK( wgp_interrupt4 ) { - cputag_set_input_line(machine, "maincpu", 4, HOLD_LINE); + wgp_state *state = (wgp_state *)machine->driver_data; + cpu_set_input_line(state->maincpu, 4, HOLD_LINE); } #endif static TIMER_CALLBACK( wgp_interrupt6 ) { - cputag_set_input_line(machine, "maincpu", 6, HOLD_LINE); + wgp_state *state = (wgp_state *)machine->driver_data; + cpu_set_input_line(state->maincpu, 6, HOLD_LINE); } /* 68000 B */ static TIMER_CALLBACK( wgp_cpub_interrupt6 ) { - cputag_set_input_line(machine, "sub", 6, HOLD_LINE); /* assumes Z80 sandwiched between the 68Ks */ + wgp_state *state = (wgp_state *)machine->driver_data; + cpu_set_input_line(state->subcpu, 6, HOLD_LINE); /* assumes Z80 sandwiched between the 68Ks */ } @@ -523,6 +510,7 @@ static WRITE16_HANDLER( rotate_port_w ) which contains sets of 4 words (used for ports 0-3). NB: port 6 is not written. */ + wgp_state *state = (wgp_state *)space->machine->driver_data; switch (offset) { @@ -530,13 +518,13 @@ static WRITE16_HANDLER( rotate_port_w ) { //logerror("CPU #0 PC %06x: warning - port %04x write %04x\n",cpu_get_pc(space->cpu),port_sel,data); - wgp_rotate_ctrl[port_sel] = data; + state->rotate_ctrl[state->port_sel] = data; return; } case 0x01: { - port_sel = data &0x7; + state->port_sel = data & 0x7; } } } @@ -621,33 +609,35 @@ static WRITE16_HANDLER( wgp_adinput_w ) SOUND **********************************************************/ -static INT32 banknum; - -static void reset_sound_region(running_machine *machine) /* assumes Z80 sandwiched between the 68Ks */ +static void reset_sound_region( running_machine *machine ) /* assumes Z80 sandwiched between the 68Ks */ { - memory_set_bankptr(machine, "bank10", memory_region(machine, "audiocpu") + (banknum * 0x4000) + 0x10000 ); + wgp_state *state = (wgp_state *)machine->driver_data; + memory_set_bank(machine, "bank10", state->banknum); } static WRITE8_HANDLER( sound_bankswitch_w ) { - banknum = (data - 1) & 7; + wgp_state *state = (wgp_state *)space->machine->driver_data; + state->banknum = data & 7; reset_sound_region(space->machine); } static WRITE16_HANDLER( wgp_sound_w ) { - const device_config *tc0140syt = devtag_get_device(space->machine, "tc0140syt"); + wgp_state *state = (wgp_state *)space->machine->driver_data; + if (offset == 0) - tc0140syt_port_w(tc0140syt, 0, data & 0xff); + tc0140syt_port_w(state->tc0140syt, 0, data & 0xff); else if (offset == 1) - tc0140syt_comm_w(tc0140syt, 0, data & 0xff); + tc0140syt_comm_w(state->tc0140syt, 0, data & 0xff); } static READ16_HANDLER( wgp_sound_r ) { - const device_config *tc0140syt = devtag_get_device(space->machine, "tc0140syt"); + wgp_state *state = (wgp_state *)space->machine->driver_data; + if (offset == 1) - return ((tc0140syt_comm_r(tc0140syt, 0) & 0xff)); + return ((tc0140syt_comm_r(state->tc0140syt, 0) & 0xff)); else return 0; } @@ -660,18 +650,18 @@ static READ16_HANDLER( wgp_sound_r ) static ADDRESS_MAP_START( main_map, ADDRESS_SPACE_PROGRAM, 16 ) AM_RANGE(0x000000, 0x0fffff) AM_ROM AM_RANGE(0x100000, 0x10ffff) AM_RAM /* main CPUA ram */ - AM_RANGE(0x140000, 0x143fff) AM_RAM AM_BASE(&sharedram) AM_SIZE(&sharedram_size) + AM_RANGE(0x140000, 0x143fff) AM_RAM AM_BASE_SIZE_MEMBER(wgp_state, sharedram, sharedram_size) AM_RANGE(0x180000, 0x18000f) AM_DEVREADWRITE8("tc0220ioc", tc0220ioc_r, tc0220ioc_w, 0xff00) AM_RANGE(0x1c0000, 0x1c0001) AM_WRITE(cpua_ctrl_w) AM_RANGE(0x200000, 0x20000f) AM_READWRITE(wgp_adinput_r,wgp_adinput_w) AM_RANGE(0x300000, 0x30ffff) AM_DEVREADWRITE("tc0100scn", tc0100scn_word_r, tc0100scn_word_w) /* tilemaps */ AM_RANGE(0x320000, 0x32000f) AM_DEVREADWRITE("tc0100scn", tc0100scn_ctrl_word_r, tc0100scn_ctrl_word_w) - AM_RANGE(0x400000, 0x40bfff) AM_RAM AM_BASE(&wgp_spritemap) AM_SIZE(&wgp_spritemap_size) /* sprite tilemaps */ - AM_RANGE(0x40c000, 0x40dfff) AM_RAM AM_BASE_SIZE_GENERIC(spriteram) /* sprite ram */ + AM_RANGE(0x400000, 0x40bfff) AM_RAM AM_BASE_SIZE_MEMBER(wgp_state, spritemap, spritemap_size) /* sprite tilemaps */ + AM_RANGE(0x40c000, 0x40dfff) AM_RAM AM_BASE_SIZE_MEMBER(wgp_state, spriteram, spriteram_size) /* sprite ram */ AM_RANGE(0x40fff0, 0x40fff1) AM_WRITENOP /* ?? (writes 0x8000 and 0 alternately - Wgp2 just 0) */ AM_RANGE(0x500000, 0x501fff) AM_RAM /* unknown/unused */ - AM_RANGE(0x502000, 0x517fff) AM_READWRITE(wgp_pivram_word_r,wgp_pivram_word_w) AM_BASE(&wgp_pivram) /* piv tilemaps */ - AM_RANGE(0x520000, 0x52001f) AM_READWRITE(wgp_piv_ctrl_word_r,wgp_piv_ctrl_word_w) AM_BASE(&wgp_piv_ctrlram) + AM_RANGE(0x502000, 0x517fff) AM_READWRITE(wgp_pivram_word_r, wgp_pivram_word_w) AM_BASE_MEMBER(wgp_state, pivram) /* piv tilemaps */ + AM_RANGE(0x520000, 0x52001f) AM_READWRITE(wgp_piv_ctrl_word_r, wgp_piv_ctrl_word_w) AM_BASE_MEMBER(wgp_state, piv_ctrlram) AM_RANGE(0x600000, 0x600003) AM_WRITE(rotate_port_w) /* rotation control ? */ AM_RANGE(0x700000, 0x701fff) AM_RAM_WRITE(paletteram16_RRRRGGGGBBBBxxxx_word_w) AM_BASE_GENERIC(paletteram) ADDRESS_MAP_END @@ -913,9 +903,10 @@ GFXDECODE_END **************************************************************/ /* handler called by the YM2610 emulator when the internal timers cause an IRQ */ -static void irqhandler(const device_config *device, int irq) // assumes Z80 sandwiched between 68Ks +static void irqhandler( const device_config *device, int irq ) // assumes Z80 sandwiched between 68Ks { - cputag_set_input_line(device->machine, "audiocpu", 0, irq ? ASSERT_LINE : CLEAR_LINE); + wgp_state *state = (wgp_state *)device->machine->driver_data; + cpu_set_input_line(state->audiocpu, 0, irq ? ASSERT_LINE : CLEAR_LINE); } static const ym2610_interface ym2610_config = @@ -940,15 +931,39 @@ static STATE_POSTLOAD( wgp_postload ) static MACHINE_RESET( wgp ) { - banknum = -1; - cpua_ctrl = 0xff; - port_sel = 0; + wgp_state *state = (wgp_state *)machine->driver_data; + int i; + + state->banknum = 0; + state->cpua_ctrl = 0xff; + state->port_sel = 0; + state->piv_ctrl_reg = 0; + + for (i = 0; i < 3; i++) + { + state->piv_zoom[i] = 0; + state->piv_scrollx[i] = 0; + state->piv_scrolly[i] = 0; + } + + memset(state->rotate_ctrl, 0, 8); } static MACHINE_START( wgp ) { - state_save_register_global(machine, cpua_ctrl); - state_save_register_global(machine, banknum); + wgp_state *state = (wgp_state *)machine->driver_data; + + memory_configure_bank(machine, "bank10", 0, 4, memory_region(machine, "audiocpu") + 0xc000, 0x4000); + + state->maincpu = devtag_get_device(machine, "maincpu"); + state->audiocpu = devtag_get_device(machine, "audiocpu"); + state->subcpu = devtag_get_device(machine, "sub"); + state->tc0140syt = devtag_get_device(machine, "tc0140syt"); + state->tc0100scn = devtag_get_device(machine, "tc0100scn"); + + state_save_register_global(machine, state->cpua_ctrl); + state_save_register_global(machine, state->banknum); + state_save_register_global(machine, state->port_sel); state_save_register_postload(machine, wgp_postload, NULL); } @@ -985,6 +1000,9 @@ static const tc0140syt_interface wgp_tc0140syt_intf = static MACHINE_DRIVER_START( wgp ) + /* driver data */ + MDRV_DRIVER_DATA(wgp_state) + /* basic machine hardware */ MDRV_CPU_ADD("maincpu", M68000, 12000000) /* 12 MHz ??? */ MDRV_CPU_PROGRAM_MAP(main_map) @@ -1259,8 +1277,6 @@ static DRIVER_INIT( wgp ) UINT16 *ROM = (UINT16 *)memory_region(machine, "maincpu"); ROM[0x25dc / 2] = 0x0602; // faulty value is 0x0206 #endif - -// taitosnd_setz80_soundcpu( 2 ); } static DRIVER_INIT( wgp2 ) diff --git a/src/mame/includes/darius.h b/src/mame/includes/darius.h new file mode 100644 index 00000000000..3f3342d4a1e --- /dev/null +++ b/src/mame/includes/darius.h @@ -0,0 +1,69 @@ +/************************************************************************* + + Darius + +*************************************************************************/ + +#define DARIUS_VOL_MAX (3*2 + 2) +#define DARIUS_PAN_MAX (2 + 2 + 1) /* FM 2port + PSG 2port + DA 1port */ + +typedef struct _darius_state darius_state; +struct _darius_state +{ + /* memory pointers */ + UINT16 * spriteram; + UINT16 * fg_ram; + size_t spriteram_size; + + /* video-related */ + tilemap_t *fg_tilemap; + + /* misc */ + UINT16 cpua_ctrl; + UINT16 coin_word; + INT32 banknum; + UINT8 adpcm_command; + UINT8 nmi_enable; + UINT32 def_vol[0x10]; + UINT8 vol[DARIUS_VOL_MAX]; + UINT8 pan[DARIUS_PAN_MAX]; + + /* devices */ + const device_config *maincpu; + const device_config *audiocpu; + const device_config *cpub; + const device_config *adpcm; + const device_config *tc0140syt; + const device_config *pc080sn; + + const device_config *lscreen; + const device_config *mscreen; + const device_config *rscreen; + + const device_config *filter0_0l; + const device_config *filter0_0r; + const device_config *filter0_1l; + const device_config *filter0_1r; + const device_config *filter0_2l; + const device_config *filter0_2r; + const device_config *filter0_3l; + const device_config *filter0_3r; + const device_config *filter1_0l; + const device_config *filter1_0r; + const device_config *filter1_1l; + const device_config *filter1_1r; + const device_config *filter1_2l; + const device_config *filter1_2r; + const device_config *filter1_3l; + const device_config *filter1_3r; + const device_config *msm5205_l; + const device_config *msm5205_r; +}; + + +/*----------- defined in video/darius.c -----------*/ + +WRITE16_HANDLER( darius_fg_layer_w ); + +VIDEO_START( darius ); +VIDEO_UPDATE( darius ); diff --git a/src/mame/includes/ninjaw.h b/src/mame/includes/ninjaw.h new file mode 100644 index 00000000000..51f2efb96d1 --- /dev/null +++ b/src/mame/includes/ninjaw.h @@ -0,0 +1,40 @@ +/************************************************************************* + + Taito Triple Screen Games + +*************************************************************************/ + +typedef struct _ninjaw_state ninjaw_state; +struct _ninjaw_state +{ + /* memory pointers */ + UINT16 * spriteram; + size_t spriteram_size; + + /* misc */ + UINT16 cpua_ctrl; + INT32 banknum; + int pandata[4]; + + /* devices */ + const device_config *maincpu; + const device_config *audiocpu; + const device_config *subcpu; + const device_config *tc0140syt; + const device_config *tc0100scn_1; + const device_config *tc0100scn_2; + const device_config *tc0100scn_3; + const device_config *lscreen; + const device_config *mscreen; + const device_config *rscreen; + const device_config *_2610_1l; + const device_config *_2610_1r; + const device_config *_2610_2l; + const device_config *_2610_2r; +}; + + +/*----------- defined in video/ninjaw.c -----------*/ + +VIDEO_START( ninjaw ); +VIDEO_UPDATE( ninjaw ); diff --git a/src/mame/includes/othunder.h b/src/mame/includes/othunder.h new file mode 100644 index 00000000000..64c8c3cb5a4 --- /dev/null +++ b/src/mame/includes/othunder.h @@ -0,0 +1,53 @@ +/************************************************************************* + + Operation Thunderbolt + +*************************************************************************/ + +struct othunder_tempsprite +{ + int gfx; + int code,color; + int flipx,flipy; + int x,y; + int zoomx,zoomy; + int primask; +}; + + +typedef struct _othunder_state othunder_state; +struct _othunder_state +{ + /* memory pointers */ + UINT16 * spriteram; + size_t spriteram_size; + + /* video-related */ + struct othunder_tempsprite *spritelist; + + /* misc */ + int vblank_irq, ad_irq; + INT32 banknum; + int pan[4]; + + /* devices */ + const device_config *maincpu; + const device_config *audiocpu; + const device_config *eeprom; + const device_config *tc0220ioc; + const device_config *tc0100scn; + const device_config *tc0110pcr; + const device_config *tc0140syt; + const device_config *_2610_0l; + const device_config *_2610_0r; + const device_config *_2610_1l; + const device_config *_2610_1r; + const device_config *_2610_2l; + const device_config *_2610_2r; +}; + + +/*----------- defined in video/othunder.c -----------*/ + +VIDEO_START( othunder ); +VIDEO_UPDATE( othunder ); diff --git a/src/mame/includes/slapshot.h b/src/mame/includes/slapshot.h new file mode 100644 index 00000000000..505273ff99d --- /dev/null +++ b/src/mame/includes/slapshot.h @@ -0,0 +1,54 @@ +/************************************************************************* + + Slapshot / Operation Wolf 3 + +*************************************************************************/ + +struct slapshot_tempsprite +{ + int gfx; + int code,color; + int flipx,flipy; + int x,y; + int zoomx,zoomy; + int primask; +}; + +typedef struct _slapshot_state slapshot_state; +struct _slapshot_state +{ + /* memory pointers */ + UINT16 * color_ram; + UINT16 * spriteram; + UINT16 * spriteext; + UINT16 * spriteram_buffered, *spriteram_delayed; +// UINT16 * paletteram; // currently this uses generic palette handling + size_t spriteext_size; + size_t spriteram_size; + + /* video-related */ + struct slapshot_tempsprite *spritelist; + INT32 sprites_disabled, sprites_active_area, sprites_master_scrollx, sprites_master_scrolly; + int sprites_flipscreen; + int prepare_sprites; + + UINT16 spritebank[8]; + + /* misc */ + INT32 banknum; + + /* devices */ + const device_config *maincpu; + const device_config *audiocpu; + const device_config *tc0140syt; + const device_config *tc0480scp; + const device_config *tc0360pri; + const device_config *tc0640fio; +}; + + +/*----------- defined in video/slapshot.c -----------*/ + +VIDEO_START( slapshot ); +VIDEO_UPDATE( slapshot ); +VIDEO_EOF( taito_no_buffer ); diff --git a/src/mame/includes/warriorb.h b/src/mame/includes/warriorb.h new file mode 100644 index 00000000000..109e62fb182 --- /dev/null +++ b/src/mame/includes/warriorb.h @@ -0,0 +1,36 @@ +/************************************************************************* + + Taito Dual Screen Games + +*************************************************************************/ + +typedef struct _warriorb_state warriorb_state; +struct _warriorb_state +{ + /* memory pointers */ + UINT16 * spriteram; + size_t spriteram_size; + + /* misc */ + INT32 banknum; + int pandata[4]; + + /* devices */ + const device_config *maincpu; + const device_config *audiocpu; + const device_config *tc0140syt; + const device_config *tc0100scn_1; + const device_config *tc0100scn_2; + const device_config *lscreen; + const device_config *rscreen; + const device_config *_2610_1l; + const device_config *_2610_1r; + const device_config *_2610_2l; + const device_config *_2610_2r; +}; + + +/*----------- defined in video/warriorb.c -----------*/ + +VIDEO_START( warriorb ); +VIDEO_UPDATE( warriorb ); diff --git a/src/mame/includes/wgp.h b/src/mame/includes/wgp.h new file mode 100644 index 00000000000..892622bda6c --- /dev/null +++ b/src/mame/includes/wgp.h @@ -0,0 +1,52 @@ +/************************************************************************* + + World Grand Prix + +*************************************************************************/ + +typedef struct _wgp_state wgp_state; +struct _wgp_state +{ + /* memory pointers */ + UINT16 * spritemap; + UINT16 * spriteram; + UINT16 * pivram; + UINT16 * piv_ctrlram; + UINT16 * sharedram; +// UINT16 * paletteram; // currently this uses generic palette handling + size_t sharedram_size; + size_t spritemap_size; + size_t spriteram_size; + + /* video-related */ + tilemap_t *piv_tilemap[3]; + UINT16 piv_ctrl_reg; + UINT16 piv_zoom[3], piv_scrollx[3], piv_scrolly[3]; + UINT16 rotate_ctrl[8]; + int piv_xoffs, piv_yoffs; + + /* misc */ + UINT16 cpua_ctrl; + UINT16 port_sel; + INT32 banknum; + + /* devices */ + const device_config *maincpu; + const device_config *audiocpu; + const device_config *subcpu; + const device_config *tc0100scn; + const device_config *tc0140syt; +}; + + +/*----------- defined in video/wgp.c -----------*/ + +READ16_HANDLER ( wgp_pivram_word_r ); +WRITE16_HANDLER( wgp_pivram_word_w ); + +READ16_HANDLER ( wgp_piv_ctrl_word_r ); +WRITE16_HANDLER( wgp_piv_ctrl_word_w ); + +VIDEO_START( wgp ); +VIDEO_START( wgp2 ); +VIDEO_UPDATE( wgp ); diff --git a/src/mame/video/darius.c b/src/mame/video/darius.c index 0a1569a4398..aef3ca2f0e0 100644 --- a/src/mame/video/darius.c +++ b/src/mame/video/darius.c @@ -1,25 +1,10 @@ #include "driver.h" #include "video/taitoic.h" - - -static tilemap_t *fg_tilemap; -UINT16 *darius_fg_ram; - -struct tempsprite -{ - int gfx; - int code,color; - int flipx,flipy; - int x,y; - int zoomx,zoomy; - int primask; -}; -static struct tempsprite *spritelist; - +#include "includes/darius.h" /***************************************************************************/ -INLINE void actual_get_fg_tile_info(running_machine *machine, tile_data *tileinfo, int tile_index, UINT16 *ram,int gfxnum) +INLINE void actual_get_fg_tile_info( running_machine *machine, tile_data *tileinfo, int tile_index, UINT16 *ram, int gfxnum ) { UINT16 code = (ram[tile_index + 0x2000] & 0x7ff); UINT16 attr = ram[tile_index]; @@ -33,61 +18,62 @@ INLINE void actual_get_fg_tile_info(running_machine *machine, tile_data *tileinf static TILE_GET_INFO( get_fg_tile_info ) { - actual_get_fg_tile_info(machine, tileinfo, tile_index, darius_fg_ram, 2); + darius_state *state = (darius_state *)machine->driver_data; + actual_get_fg_tile_info(machine, tileinfo, tile_index, state->fg_ram, 2); } /***************************************************************************/ VIDEO_START( darius ) { - fg_tilemap = tilemap_create(machine, get_fg_tile_info,tilemap_scan_rows,8,8,128,64); + darius_state *state = (darius_state *)machine->driver_data; - spritelist = auto_alloc_array(machine, struct tempsprite, 0x800); + state->fg_tilemap = tilemap_create(machine, get_fg_tile_info,tilemap_scan_rows,8,8,128,64); - tilemap_set_transparent_pen(fg_tilemap,0); + tilemap_set_transparent_pen(state->fg_tilemap, 0); } /***************************************************************************/ WRITE16_HANDLER( darius_fg_layer_w ) { - COMBINE_DATA(&darius_fg_ram[offset]); + darius_state *state = (darius_state *)space->machine->driver_data; + + COMBINE_DATA(&state->fg_ram[offset]); if (offset < 0x4000) - tilemap_mark_tile_dirty(fg_tilemap,(offset & 0x1fff)); + tilemap_mark_tile_dirty(state->fg_tilemap, (offset & 0x1fff)); } /***************************************************************************/ -static void draw_sprites(running_machine *machine, bitmap_t *bitmap,const rectangle *cliprect,int primask, int x_offs, int y_offs) +static void draw_sprites( running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect, int primask, int x_offs, int y_offs ) { - UINT16 *spriteram16 = machine->generic.spriteram.u16; - int offs,curx,cury; - UINT16 code,data,sx,sy; - UINT8 flipx,flipy,color,priority; + darius_state *state = (darius_state *)machine->driver_data; + UINT16 *spriteram = state->spriteram; + int offs, curx, cury; + UINT16 code, data, sx, sy; + UINT8 flipx, flipy, color, priority; - /* pdrawgfx() needs us to draw sprites front to back, so we have to build a list - while processing sprite ram and then draw them all at the end */ - struct tempsprite *sprite_ptr = spritelist; - - for (offs = machine->generic.spriteram_size/2-4; offs >= 0; offs -= 4) + for (offs = state->spriteram_size / 2 - 4; offs >= 0; offs -= 4) { - code = spriteram16[offs+2] &0x1fff; + code = spriteram[offs + 2] & 0x1fff; if (code) { - data = spriteram16[offs]; - sy = (256-data) & 0x1ff; + data = spriteram[offs]; + sy = (256 - data) & 0x1ff; - data = spriteram16[offs+1]; + data = spriteram[offs + 1]; sx = data & 0x3ff; - data = spriteram16[offs+2]; + data = spriteram[offs + 2]; flipx = ((data & 0x4000) >> 14); flipy = ((data & 0x8000) >> 15); - data = spriteram16[offs+3]; - priority = (data &0x80) >> 7; // 0 = low - if (priority != primask) continue; + data = spriteram[offs + 3]; + priority = (data & 0x80) >> 7; // 0 = low + if (priority != primask) + continue; color = (data & 0x7f); curx = sx - x_offs; @@ -96,18 +82,10 @@ static void draw_sprites(running_machine *machine, bitmap_t *bitmap,const rectan if (curx > 900) curx -= 1024; if (cury > 400) cury -= 512; - sprite_ptr->code = code; - sprite_ptr->color = color; - sprite_ptr->flipx = flipx; - sprite_ptr->flipy = flipy; - sprite_ptr->x = curx; - sprite_ptr->y = cury; - drawgfx_transpen(bitmap,cliprect,machine->gfx[0], - sprite_ptr->code, - sprite_ptr->color, - sprite_ptr->flipx,sprite_ptr->flipy, - sprite_ptr->x,sprite_ptr->y,0); + code, color, + flipx, flipy, + curx, cury, 0); } } } @@ -116,35 +94,32 @@ static void draw_sprites(running_machine *machine, bitmap_t *bitmap,const rectan VIDEO_UPDATE( darius ) { + darius_state *state = (darius_state *)screen->machine->driver_data; int xoffs = 0; - const device_config *left_screen = devtag_get_device(screen->machine, "lscreen"); - const device_config *middle_screen = devtag_get_device(screen->machine, "mscreen"); - const device_config *right_screen = devtag_get_device(screen->machine, "rscreen"); - const device_config *pc080sn = devtag_get_device(screen->machine, "pc080sn"); - if (screen == left_screen) + if (screen == state->lscreen) xoffs = 36 * 8 * 0; - else if (screen == middle_screen) + else if (screen == state->mscreen) xoffs = 36 * 8 * 1; - else if (screen == right_screen) + else if (screen == state->rscreen) xoffs = 36 * 8 * 2; - pc080sn_tilemap_update(pc080sn); + pc080sn_tilemap_update(state->pc080sn); // draw bottom layer(always active) - pc080sn_tilemap_draw_offset(pc080sn, bitmap, cliprect, 0, TILEMAP_DRAW_OPAQUE, 0, -xoffs, 0); + pc080sn_tilemap_draw_offset(state->pc080sn, bitmap, cliprect, 0, TILEMAP_DRAW_OPAQUE, 0, -xoffs, 0); /* Sprites can be under/over the layer below text layer */ draw_sprites(screen->machine, bitmap, cliprect, 0, xoffs, -8); // draw sprites with priority 0 which are under the mid layer // draw middle layer - pc080sn_tilemap_draw_offset(pc080sn, bitmap, cliprect, 1, 0, 0, -xoffs, 0); + pc080sn_tilemap_draw_offset(state->pc080sn, bitmap, cliprect, 1, 0, 0, -xoffs, 0); draw_sprites(screen->machine, bitmap, cliprect, 1, xoffs, -8); // draw sprites with priority 1 which are over the mid layer /* top(text) layer is in fixed position */ - tilemap_set_scrollx(fg_tilemap, 0, 0 + xoffs); - tilemap_set_scrolly(fg_tilemap, 0, -8); - tilemap_draw(bitmap, cliprect, fg_tilemap, 0, 0); + tilemap_set_scrollx(state->fg_tilemap, 0, 0 + xoffs); + tilemap_set_scrolly(state->fg_tilemap, 0, -8); + tilemap_draw(bitmap, cliprect, state->fg_tilemap, 0, 0); return 0; } diff --git a/src/mame/video/ninjaw.c b/src/mame/video/ninjaw.c index 6cdcf427521..5739b7cc41a 100644 --- a/src/mame/video/ninjaw.c +++ b/src/mame/video/ninjaw.c @@ -1,60 +1,45 @@ #include "driver.h" #include "video/taitoic.h" - -struct tempsprite -{ - int gfx; - int code,color; - int flipx,flipy; - int x,y; - int zoomx,zoomy; - int primask; -}; -static struct tempsprite *spritelist; - +#include "includes/ninjaw.h" /**********************************************************/ VIDEO_START( ninjaw ) { - const device_config *tc0100scn = devtag_get_device(machine, "tc0100scn_1"); - - spritelist = auto_alloc_array(machine, struct tempsprite, 0x1000); + ninjaw_state *state = (ninjaw_state *)machine->driver_data; /* Ensure palette from correct TC0110PCR used for each screen */ - tc0100scn_set_colbanks(tc0100scn, 0x0, 0x100, 0x200); + tc0100scn_set_colbanks(state->tc0100scn_1, 0x0, 0x100, 0x200); } /************************************************************ SPRITE DRAW ROUTINE ************************************************************/ -static void draw_sprites(running_machine *machine, bitmap_t *bitmap,const rectangle *cliprect,int primask,int x_offs,int y_offs) +static void draw_sprites( running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect, int primask, int x_offs, int y_offs ) { - UINT16 *spriteram16 = machine->generic.spriteram.u16; + ninjaw_state *state = (ninjaw_state *)machine->driver_data; + UINT16 *spriteram = state->spriteram; int offs, data, tilenum, color, flipx, flipy; int x, y, priority, curx, cury; int code; #ifdef MAME_DEBUG - int unknown=0; + int unknown = 0; #endif - /* pdrawgfx() needs us to draw sprites front to back, so we have to build a list - while processing sprite ram and then draw them all at the end */ - struct tempsprite *sprite_ptr = spritelist; - - for (offs = (machine->generic.spriteram_size/2)-4;offs >=0;offs -= 4) + for (offs = (state->spriteram_size / 2) - 4; offs >= 0; offs -= 4) { - data = spriteram16[offs+2]; + data = spriteram[offs + 2]; tilenum = data & 0x7fff; - if (!tilenum) continue; + if (!tilenum) + continue; - data = spriteram16[offs+0]; + data = spriteram[offs + 0]; x = (data - 32) & 0x3ff; /* aligns sprites on rock outcrops and sewer hole */ - data = spriteram16[offs+1]; + data = spriteram[offs + 1]; y = (data - 0) & 0x1ff; /* @@ -70,12 +55,13 @@ static void draw_sprites(running_machine *machine, bitmap_t *bitmap,const rectan Bit&0x8000 is set on some sprites in later levels of Darius but is again unknown, and there is no obvious visual problem. */ - data = spriteram16[offs+3]; + data = spriteram[offs + 3]; flipx = (data & 0x1); flipy = (data & 0x2) >> 1; priority = (data & 0x4) >> 2; // 1 = low /* data&0x8 - unknown */ - if (priority != primask) continue; + if (priority != primask) + continue; color = (data & 0x7f00) >> 8; /* data&0x8000 - unknown */ @@ -87,25 +73,17 @@ static void draw_sprites(running_machine *machine, bitmap_t *bitmap,const rectan y += y_offs; /* sprite wrap: coords become negative at high values */ - if (x>0x3c0) x -= 0x400; - if (y>0x180) y -= 0x200; + if (x > 0x3c0) x -= 0x400; + if (y > 0x180) y -= 0x200; curx = x; cury = y; code = tilenum; - sprite_ptr->code = code; - sprite_ptr->color = color; - sprite_ptr->flipx = flipx; - sprite_ptr->flipy = flipy; - sprite_ptr->x = curx; - sprite_ptr->y = cury; - drawgfx_transpen(bitmap,cliprect,machine->gfx[0], - sprite_ptr->code, - sprite_ptr->color, - sprite_ptr->flipx,sprite_ptr->flipy, - sprite_ptr->x,sprite_ptr->y,0); + code, color, + flipx, flipy, + curx, cury, 0); } #ifdef MAME_DEBUG @@ -121,28 +99,25 @@ static void draw_sprites(running_machine *machine, bitmap_t *bitmap,const rectan VIDEO_UPDATE( ninjaw ) { + ninjaw_state *state = (ninjaw_state *)screen->machine->driver_data; int xoffs = 0; UINT8 layer[3], nodraw; - - const device_config *left_screen = devtag_get_device(screen->machine, "lscreen"); - const device_config *middle_screen = devtag_get_device(screen->machine, "mscreen"); - const device_config *right_screen = devtag_get_device(screen->machine, "rscreen"); const device_config *tc0100scn = NULL; - if (screen == left_screen) + if (screen == state->lscreen) { xoffs = 36 * 8 * 0; - tc0100scn = devtag_get_device(screen->machine, "tc0100scn_1"); + tc0100scn = state->tc0100scn_1; } - else if (screen == middle_screen) + else if (screen == state->mscreen) { xoffs = 36 * 8 * 1; - tc0100scn = devtag_get_device(screen->machine, "tc0100scn_2"); + tc0100scn = state->tc0100scn_2; } - else if (screen == right_screen) + else if (screen == state->rscreen) { xoffs = 36 * 8 * 2; - tc0100scn = devtag_get_device(screen->machine, "tc0100scn_3"); + tc0100scn = state->tc0100scn_3; } tc0100scn_tilemap_update(tc0100scn); diff --git a/src/mame/video/othunder.c b/src/mame/video/othunder.c index b9f4a44fd4f..c093c1e0c50 100644 --- a/src/mame/video/othunder.c +++ b/src/mame/video/othunder.c @@ -1,27 +1,15 @@ #include "driver.h" #include "video/taitoic.h" +#include "includes/othunder.h" -struct tempsprite -{ - int gfx; - int code,color; - int flipx,flipy; - int x,y; - int zoomx,zoomy; - int primask; -}; -static struct tempsprite *spritelist; - - - -/**********************************************************/ VIDEO_START( othunder ) { /* Up to $800/8 big sprites, requires 0x100 * sizeof(*spritelist) Multiply this by 32 to give room for the number of small sprites, which are what actually get put in the structure. */ - spritelist = auto_alloc_array(machine, struct tempsprite, 0x2000); + othunder_state *state = (othunder_state *)machine->driver_data; + state->spritelist = auto_alloc_array(machine, struct othunder_tempsprite, 0x2000); } @@ -75,42 +63,44 @@ spriteram is being tested, take no notice of that.] ********************************************************/ -static void draw_sprites(running_machine *machine, bitmap_t *bitmap,const rectangle *cliprect,const int *primasks,int y_offs) +static void draw_sprites( running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect, const int *primasks, int y_offs ) { + othunder_state *state = (othunder_state *)machine->driver_data; UINT16 *spritemap = (UINT16 *)memory_region(machine, "user1"); UINT16 tile_mask = (machine->gfx[0]->total_elements) - 1; - UINT16 *spriteram16 = machine->generic.spriteram.u16; + UINT16 *spriteram16 = state->spriteram; int offs, data, tilenum, color, flipx, flipy; int x, y, priority, curx, cury; int sprites_flipscreen = 0; int zoomx, zoomy, zx, zy; - int sprite_chunk,map_offset,code,j,k,px,py; + int sprite_chunk, map_offset, code, j, k, px, py; int bad_chunks; /* pdrawgfx() needs us to draw sprites front to back, so we have to build a list while processing sprite ram and then draw them all at the end */ - struct tempsprite *sprite_ptr = spritelist; + struct othunder_tempsprite *sprite_ptr = state->spritelist; - for (offs = (machine->generic.spriteram_size/2)-4;offs >=0;offs -= 4) + for (offs = (state->spriteram_size / 2) - 4; offs >= 0; offs -= 4) { - data = spriteram16[offs+0]; + data = spriteram16[offs + 0]; zoomy = (data & 0xfe00) >> 9; y = data & 0x1ff; - data = spriteram16[offs+1]; + data = spriteram16[offs + 1]; flipx = (data & 0x4000) >> 14; priority = (data & 0x8000) >> 15; x = data & 0x1ff; - data = spriteram16[offs+2]; + data = spriteram16[offs + 2]; color = (data & 0xff00) >> 8; zoomx = (data & 0x7f); - data = spriteram16[offs+3]; + data = spriteram16[offs + 3]; tilenum = data & 0x1fff; // $80000 spritemap rom maps up to $2000 64x64 sprites flipy = (data & 0x8000) >> 15; - if (!tilenum) continue; + if (!tilenum) + continue; map_offset = tilenum << 5; @@ -120,34 +110,34 @@ static void draw_sprites(running_machine *machine, bitmap_t *bitmap,const rectan y += y_offs; /* treat coords as signed */ - if (x>0x140) x -= 0x200; - if (y>0x140) y -= 0x200; + if (x > 0x140) x -= 0x200; + if (y > 0x140) y -= 0x200; bad_chunks = 0; - for (sprite_chunk=0;sprite_chunk<32;sprite_chunk++) + for (sprite_chunk = 0; sprite_chunk < 32; sprite_chunk++) { k = sprite_chunk % 4; /* 4 chunks per row */ j = sprite_chunk / 4; /* 8 rows */ px = k; py = j; - if (flipx) px = 3-k; /* pick tiles back to front for x and y flips */ - if (flipy) py = 7-j; + if (flipx) px = 3 - k; /* pick tiles back to front for x and y flips */ + if (flipy) py = 7 - j; - code = spritemap[map_offset + px + (py<<2)] &tile_mask; + code = spritemap[map_offset + px + (py << 2)] & tile_mask; - if (code==0xffff) + if (code == 0xffff) { bad_chunks += 1; continue; } - curx = x + ((k*zoomx)/4); - cury = y + ((j*zoomy)/8); + curx = x + ((k * zoomx) / 4); + cury = y + ((j * zoomy) / 8); - zx= x + (((k+1)*zoomx)/4) - curx; - zy= y + (((j+1)*zoomy)/8) - cury; + zx= x + (((k + 1) * zoomx) / 4) - curx; + zy= y + (((j + 1) * zoomy) / 8) - cury; if (sprites_flipscreen) { @@ -191,7 +181,7 @@ logerror("Sprite number %04x had %02x invalid chunks\n",tilenum,bad_chunks); } /* this happens only if primsks != NULL */ - while (sprite_ptr != spritelist) + while (sprite_ptr != state->spritelist) { sprite_ptr--; @@ -212,12 +202,12 @@ logerror("Sprite number %04x had %02x invalid chunks\n",tilenum,bad_chunks); VIDEO_UPDATE( othunder ) { - const device_config *tc0100scn = devtag_get_device(screen->machine, "tc0100scn"); + othunder_state *state = (othunder_state *)screen->machine->driver_data; int layer[3]; - tc0100scn_tilemap_update(tc0100scn); + tc0100scn_tilemap_update(state->tc0100scn); - layer[0] = tc0100scn_bottomlayer(tc0100scn); + layer[0] = tc0100scn_bottomlayer(state->tc0100scn); layer[1] = layer[0] ^ 1; layer[2] = 2; @@ -226,9 +216,9 @@ VIDEO_UPDATE( othunder ) /* Ensure screen blanked even when bottom layer not drawn due to disable bit */ bitmap_fill(bitmap, cliprect, 0); - tc0100scn_tilemap_draw(tc0100scn, bitmap, cliprect, layer[0], TILEMAP_DRAW_OPAQUE, 1); - tc0100scn_tilemap_draw(tc0100scn, bitmap, cliprect, layer[1], 0, 2); - tc0100scn_tilemap_draw(tc0100scn, bitmap, cliprect, layer[2], 0, 4); + tc0100scn_tilemap_draw(state->tc0100scn, bitmap, cliprect, layer[0], TILEMAP_DRAW_OPAQUE, 1); + tc0100scn_tilemap_draw(state->tc0100scn, bitmap, cliprect, layer[1], 0, 2); + tc0100scn_tilemap_draw(state->tc0100scn, bitmap, cliprect, layer[2], 0, 4); /* Sprites can be under/over the layer below text layer */ { diff --git a/src/mame/video/slapshot.c b/src/mame/video/slapshot.c index 4fa0c69f4d4..6f1cd07620e 100644 --- a/src/mame/video/slapshot.c +++ b/src/mame/video/slapshot.c @@ -1,68 +1,40 @@ #include "driver.h" #include "video/taitoic.h" - -struct tempsprite -{ - int gfx; - int code,color; - int flipx,flipy; - int x,y; - int zoomx,zoomy; - int primask; -}; -static struct tempsprite *spritelist; - -static INT32 sprites_disabled,sprites_active_area,sprites_master_scrollx,sprites_master_scrolly; -static int sprites_flipscreen = 0; -static UINT16 *spriteram_buffered,*spriteram_delayed; - -static INT32 taito_sprite_type = 0; -UINT16 *taito_sprite_ext; -size_t taito_spriteext_size; -static UINT16 spritebank[8]; - -static INT32 taito_hide_pixels; - - +#include "includes/slapshot.h" /**********************************************************/ -static VIDEO_START( slapshot_core ) -{ - int i; - - spriteram_delayed = auto_alloc_array(machine, UINT16, machine->generic.spriteram_size/2); - spriteram_buffered = auto_alloc_array(machine, UINT16, machine->generic.spriteram_size/2); - spritelist = auto_alloc_array(machine, struct tempsprite, 0x400); - - for (i = 0; i < 8; i ++) - spritebank[i] = 0x400 * i; - - sprites_disabled = 1; - sprites_active_area = 0; - - state_save_register_global(machine, taito_hide_pixels); - state_save_register_global(machine, taito_sprite_type); - state_save_register_global_array(machine, spritebank); - state_save_register_global(machine, sprites_disabled); - state_save_register_global(machine, sprites_active_area); - state_save_register_global_pointer(machine, spriteram_delayed, machine->generic.spriteram_size/2); - state_save_register_global_pointer(machine, spriteram_buffered, machine->generic.spriteram_size/2); -} - VIDEO_START( slapshot ) { - taito_hide_pixels = 3; - taito_sprite_type = 2; - VIDEO_START_CALL(slapshot_core); -} + slapshot_state *state = (slapshot_state *)machine->driver_data; + int i; + state->spriteram_delayed = auto_alloc_array(machine, UINT16, state->spriteram_size / 2); + state->spriteram_buffered = auto_alloc_array(machine, UINT16, state->spriteram_size / 2); + state->spritelist = auto_alloc_array(machine, struct slapshot_tempsprite, 0x400); + + for (i = 0; i < 8; i ++) + state->spritebank[i] = 0x400 * i; + + state->sprites_disabled = 1; + state->sprites_active_area = 0; + + state_save_register_global_array(machine, state->spritebank); + state_save_register_global(machine, state->sprites_disabled); + state_save_register_global(machine, state->sprites_active_area); + state_save_register_global(machine, state->sprites_master_scrollx); + state_save_register_global(machine, state->sprites_master_scrolly); + state_save_register_global(machine, state->sprites_flipscreen); + state_save_register_global(machine, state->prepare_sprites); + state_save_register_global_pointer(machine, state->spriteram_delayed, state->spriteram_size / 2); + state_save_register_global_pointer(machine, state->spriteram_buffered, state->spriteram_size / 2); +} /************************************************************ SPRITE DRAW ROUTINES ************************************************************/ -static void draw_sprites(running_machine *machine, bitmap_t *bitmap,const rectangle *cliprect,int *primasks,int y_offset) +static void draw_sprites( running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect, int *primasks, int y_offset ) { /* Sprite format: @@ -117,31 +89,32 @@ static void draw_sprites(running_machine *machine, bitmap_t *bitmap,const rectan 000b - 000f : unused */ - int x,y,off,extoffs; - int code,color,spritedata,spritecont,flipx,flipy; - int xcurrent,ycurrent,big_sprite=0; - int y_no=0, x_no=0, xlatch=0, ylatch=0, last_continuation_tile=0; /* for zooms */ - UINT32 zoomword, zoomx, zoomy, zx=0, zy=0, zoomxlatch=0, zoomylatch=0; /* for zooms */ + slapshot_state *state = (slapshot_state *)machine->driver_data; + int x, y, off, extoffs; + int code, color, spritedata, spritecont, flipx, flipy; + int xcurrent, ycurrent, big_sprite = 0; + int y_no = 0, x_no = 0, xlatch = 0, ylatch = 0, last_continuation_tile = 0; /* for zooms */ + UINT32 zoomword, zoomx, zoomy, zx = 0, zy = 0, zoomxlatch = 0, zoomylatch = 0; /* for zooms */ int scroll1x, scroll1y; - int scrollx=0, scrolly=0; - int curx,cury; + int scrollx = 0, scrolly = 0; + int curx, cury; int x_offset; /* pdrawgfx() needs us to draw sprites front to back, so we have to build a list while processing sprite ram and then draw them all at the end */ - struct tempsprite *sprite_ptr = spritelist; + struct slapshot_tempsprite *sprite_ptr = state->spritelist; /* must remember enable status from last frame because driftout fails to reactivate them from a certain point onwards. */ - int disabled = sprites_disabled; + int disabled = state->sprites_disabled; /* must remember master scroll from previous frame because driftout sometimes doesn't set it. */ - int master_scrollx = sprites_master_scrollx; - int master_scrolly = sprites_master_scrolly; + int master_scrollx = state->sprites_master_scrollx; + int master_scrolly = state->sprites_master_scrolly; /* must also remember the sprite bank from previous frame. */ - int area = sprites_active_area; + int area = state->sprites_active_area; scroll1x = 0; scroll1y = 0; @@ -149,55 +122,60 @@ static void draw_sprites(running_machine *machine, bitmap_t *bitmap,const rectan xcurrent = ycurrent = 0; color = 0; - x_offset = taito_hide_pixels; /* Get rid of 0-3 unwanted pixels on edge of screen. */ - if (sprites_flipscreen) x_offset = -x_offset; + x_offset = 3; /* Get rid of 0-3 unwanted pixels on edge of screen. */ + if (state->sprites_flipscreen) x_offset = -x_offset; /* safety check to avoid getting stuck in bank 2 for games using only one bank */ if (area == 0x8000 && - spriteram_buffered[(0x8000+6)/2] == 0 && - spriteram_buffered[(0x8000+10)/2] == 0) + state->spriteram_buffered[(0x8000 + 6) / 2] == 0 && + state->spriteram_buffered[(0x8000 + 10) / 2] == 0) area = 0; - for (off = 0;off < 0x4000;off += 16) + for (off = 0; off < 0x4000; off += 16) { /* sprites_active_area may change during processing */ int offs = off + area; - if (spriteram_buffered[(offs+6)/2] & 0x8000) + if (state->spriteram_buffered[(offs + 6) / 2] & 0x8000) { - disabled = spriteram_buffered[(offs+10)/2] & 0x1000; - sprites_flipscreen = spriteram_buffered[(offs+10)/2] & 0x2000; - x_offset = taito_hide_pixels; /* Get rid of 0-3 unwanted pixels on edge of screen. */ - if (sprites_flipscreen) x_offset = -x_offset; - area = 0x8000 * (spriteram_buffered[(offs+10)/2] & 0x0001); + disabled = state->spriteram_buffered[(offs + 10) / 2] & 0x1000; + state->sprites_flipscreen = state->spriteram_buffered[(offs + 10) / 2] & 0x2000; + x_offset = 3; /* Get rid of 0-3 unwanted pixels on edge of screen. */ + if (state->sprites_flipscreen) x_offset = -x_offset; + area = 0x8000 * (state->spriteram_buffered[(offs + 10) / 2] & 0x0001); continue; } //popmessage("%04x",area); /* check for extra scroll offset */ - if ((spriteram_buffered[(offs+4)/2] & 0xf000) == 0xa000) + if ((state->spriteram_buffered[(offs + 4) / 2] & 0xf000) == 0xa000) { - master_scrollx = spriteram_buffered[(offs+4)/2] & 0xfff; - if (master_scrollx >= 0x800) master_scrollx -= 0x1000; /* signed value */ - master_scrolly = spriteram_buffered[(offs+6)/2] & 0xfff; - if (master_scrolly >= 0x800) master_scrolly -= 0x1000; /* signed value */ + master_scrollx = state->spriteram_buffered[(offs + 4) / 2] & 0xfff; + if (master_scrollx >= 0x800) + master_scrollx -= 0x1000; /* signed value */ + + master_scrolly = state->spriteram_buffered[(offs + 6) / 2] & 0xfff; + if (master_scrolly >= 0x800) + master_scrolly -= 0x1000; /* signed value */ } - if ((spriteram_buffered[(offs+4)/2] & 0xf000) == 0x5000) + if ((state->spriteram_buffered[(offs + 4) / 2] & 0xf000) == 0x5000) { - scroll1x = spriteram_buffered[(offs+4)/2] & 0xfff; - if (scroll1x >= 0x800) scroll1x -= 0x1000; /* signed value */ + scroll1x = state->spriteram_buffered[(offs + 4) / 2] & 0xfff; + if (scroll1x >= 0x800) + scroll1x -= 0x1000; /* signed value */ - scroll1y = spriteram_buffered[(offs+6)/2] & 0xfff; - if (scroll1y >= 0x800) scroll1y -= 0x1000; /* signed value */ + scroll1y = state->spriteram_buffered[(offs + 6) / 2] & 0xfff; + if (scroll1y >= 0x800) + scroll1y -= 0x1000; /* signed value */ } if (disabled) continue; - spritedata = spriteram_buffered[(offs+8)/2]; + spritedata = state->spriteram_buffered[(offs + 8) / 2]; spritecont = (spritedata & 0xff00) >> 8; @@ -205,13 +183,13 @@ static void draw_sprites(running_machine *machine, bitmap_t *bitmap,const rectan { if (big_sprite == 0) /* are we starting a big sprite ? */ { - xlatch = spriteram_buffered[(offs+4)/2] & 0xfff; - ylatch = spriteram_buffered[(offs+6)/2] & 0xfff; + xlatch = state->spriteram_buffered[(offs + 4) / 2] & 0xfff; + ylatch = state->spriteram_buffered[(offs + 6) / 2] & 0xfff; x_no = 0; y_no = 0; - zoomword = spriteram_buffered[(offs+2)/2]; - zoomylatch = (zoomword>>8) & 0xff; - zoomxlatch = (zoomword) & 0xff; + zoomword = state->spriteram_buffered[(offs + 2) / 2]; + zoomylatch = (zoomword >> 8) & 0xff; + zoomxlatch = (zoomword >> 0) & 0xff; big_sprite = 1; /* we have started a new big sprite */ } } @@ -230,7 +208,7 @@ static void draw_sprites(running_machine *machine, bitmap_t *bitmap,const rectan // of anything. if (big_sprite == 0 || (spritecont & 0xf0) == 0) { - x = spriteram_buffered[(offs+4)/2]; + x = state->spriteram_buffered[(offs + 4) / 2]; // DG: some absolute x values deduced here are 1 too high (scenes when you get // home run in Koshien, and may also relate to BG layer woods and stuff as you @@ -253,7 +231,7 @@ static void draw_sprites(running_machine *machine, bitmap_t *bitmap,const rectan scrolly = scroll1y + master_scrolly; } x &= 0xfff; - y = spriteram_buffered[(offs+6)/2] & 0xfff; + y = state->spriteram_buffered[(offs+6)/2] & 0xfff; xcurrent = x; ycurrent = y; @@ -295,65 +273,37 @@ static void draw_sprites(running_machine *machine, bitmap_t *bitmap,const rectan x = xlatch + x_no * (0x100 - zoomx) / 16; y = ylatch + y_no * (0x100 - zoomy) / 16; - zx = xlatch + (x_no+1) * (0x100 - zoomx) / 16 - x; - zy = ylatch + (y_no+1) * (0x100 - zoomy) / 16 - y; + zx = xlatch + (x_no + 1) * (0x100 - zoomx) / 16 - x; + zy = ylatch + (y_no + 1) * (0x100 - zoomy) / 16 - y; } } else { - zoomword = spriteram_buffered[(offs+2)/2]; - zoomy = (zoomword>>8) & 0xff; - zoomx = (zoomword) & 0xff; + zoomword = state->spriteram_buffered[(offs+2)/2]; + zoomy = (zoomword >> 8) & 0xff; + zoomx = (zoomword >> 0) & 0xff; zx = (0x100 - zoomx) / 16; zy = (0x100 - zoomy) / 16; } if (last_continuation_tile) { - big_sprite=0; - last_continuation_tile=0; + big_sprite = 0; + last_continuation_tile = 0; } code = 0; extoffs = offs; if (extoffs >= 0x8000) extoffs -= 0x4000; /* spriteram[0x4000-7fff] has no corresponding extension area */ - if (taito_sprite_type == 0) - { - int bank; - - code = spriteram_buffered[(offs)/2] & 0x1fff; - - bank = (code & 0x1c00) >> 10; - code = spritebank[bank] + (code & 0x3ff); - } - - if (taito_sprite_type == 1) /* Yuyugogo */ { int i; - code = spriteram_buffered[(offs)/2] & 0x3ff; - i = (taito_sprite_ext[(extoffs >> 4)] & 0x3f ) << 10; + code = state->spriteram_buffered[(offs)/2] & 0xff; + i = (state->spriteext[(extoffs >> 4)] & 0xff00 ); code = (i | code); } - if (taito_sprite_type == 2) /* Pulirula, Slapshot */ - { - int i; - - code = spriteram_buffered[(offs)/2] & 0xff; - i = (taito_sprite_ext[(extoffs >> 4)] & 0xff00 ); - code = (i | code); - } - - if (taito_sprite_type == 3) /* Dinorex and a few quizzes */ - { - int i; - - code = spriteram_buffered[(offs)/2] & 0xff; - i = (taito_sprite_ext[(extoffs >> 4)] & 0xff ) << 8; - code = (i | code); - } if (code == 0) continue; @@ -366,7 +316,7 @@ static void draw_sprites(running_machine *machine, bitmap_t *bitmap,const rectan cury = (y + scrolly) & 0xfff; if (cury >= 0x800) cury -= 0x1000; /* treat it as signed */ - if (sprites_flipscreen) + if (state->sprites_flipscreen) { /* -zx/y is there to fix zoomed sprite coords in screenflip. drawgfxzoom does not know to draw from flip-side of sprites when @@ -412,7 +362,7 @@ static void draw_sprites(running_machine *machine, bitmap_t *bitmap,const rectan /* this happens only if primsks != NULL */ - while (sprite_ptr != spritelist) + while (sprite_ptr != state->spritelist) { sprite_ptr--; @@ -426,59 +376,65 @@ static void draw_sprites(running_machine *machine, bitmap_t *bitmap,const rectan } } -static int prepare_sprites; -static void taito_handle_sprite_buffering(running_machine *machine) +static void taito_handle_sprite_buffering( running_machine *machine ) { - if (prepare_sprites) /* no buffering */ + slapshot_state *state = (slapshot_state *)machine->driver_data; + + if (state->prepare_sprites) /* no buffering */ { - memcpy(spriteram_buffered,machine->generic.spriteram.u16,machine->generic.spriteram_size); - prepare_sprites = 0; + memcpy(state->spriteram_buffered, state->spriteram, state->spriteram_size); + state->prepare_sprites = 0; } } -static void taito_update_sprites_active_area(running_machine *machine) +static void taito_update_sprites_active_area( running_machine *machine ) { + slapshot_state *state = (slapshot_state *)machine->driver_data; int off; - /* if the frame was skipped, we'll have to do the buffering now */ taito_handle_sprite_buffering(machine); /* safety check to avoid getting stuck in bank 2 for games using only one bank */ - if (sprites_active_area == 0x8000 && - spriteram_buffered[(0x8000+6)/2] == 0 && - spriteram_buffered[(0x8000+10)/2] == 0) - sprites_active_area = 0; + if (state->sprites_active_area == 0x8000 && + state->spriteram_buffered[(0x8000 + 6) / 2] == 0 && + state->spriteram_buffered[(0x8000 + 10) / 2] == 0) + state->sprites_active_area = 0; - for (off = 0;off < 0x4000;off += 16) + for (off = 0; off < 0x4000; off += 16) { /* sprites_active_area may change during processing */ - int offs = off + sprites_active_area; + int offs = off + state->sprites_active_area; - if (spriteram_buffered[(offs+6)/2] & 0x8000) + if (state->spriteram_buffered[(offs + 6) / 2] & 0x8000) { - sprites_disabled = spriteram_buffered[(offs+10)/2] & 0x1000; - sprites_active_area = 0x8000 * (spriteram_buffered[(offs+10)/2] & 0x0001); + state->sprites_disabled = state->spriteram_buffered[(offs + 10) / 2] & 0x1000; + state->sprites_active_area = 0x8000 * (state->spriteram_buffered[(offs + 10) / 2] & 0x0001); continue; } /* check for extra scroll offset */ - if ((spriteram_buffered[(offs+4)/2] & 0xf000) == 0xa000) + if ((state->spriteram_buffered[(offs+4)/2] & 0xf000) == 0xa000) { - sprites_master_scrollx = spriteram_buffered[(offs+4)/2] & 0xfff; - if (sprites_master_scrollx >= 0x800) sprites_master_scrollx -= 0x1000; /* signed value */ - sprites_master_scrolly = spriteram_buffered[(offs+6)/2] & 0xfff; - if (sprites_master_scrolly >= 0x800) sprites_master_scrolly -= 0x1000; /* signed value */ + state->sprites_master_scrollx = state->spriteram_buffered[(offs + 4) / 2] & 0xfff; + if (state->sprites_master_scrollx >= 0x800) + state->sprites_master_scrollx -= 0x1000; /* signed value */ + + state->sprites_master_scrolly = state->spriteram_buffered[(offs + 6) / 2] & 0xfff; + if (state->sprites_master_scrolly >= 0x800) + state->sprites_master_scrolly -= 0x1000; /* signed value */ } } } VIDEO_EOF( taito_no_buffer ) { + slapshot_state *state = (slapshot_state *)machine->driver_data; + taito_update_sprites_active_area(machine); - prepare_sprites = 1; + state->prepare_sprites = 1; } @@ -500,8 +456,7 @@ a bg layer given priority over some sprites. VIDEO_UPDATE( slapshot ) { - const device_config *tc0480scp = devtag_get_device(screen->machine, "tc0480scp"); - const device_config *tc0360pri = devtag_get_device(screen->machine, "tc0360pri"); + slapshot_state *state = (slapshot_state *)screen->machine->driver_data; UINT8 layer[5]; UINT8 tilepri[5]; UINT8 spritepri[4]; @@ -545,57 +500,57 @@ VIDEO_UPDATE( slapshot ) taito_handle_sprite_buffering(screen->machine); - tc0480scp_tilemap_update(tc0480scp); + tc0480scp_tilemap_update(state->tc0480scp); - priority = tc0480scp_get_bg_priority(tc0480scp); + priority = tc0480scp_get_bg_priority(state->tc0480scp); - layer[0] = (priority &0xf000) >> 12; /* tells us which bg layer is bottom */ - layer[1] = (priority &0x0f00) >> 8; - layer[2] = (priority &0x00f0) >> 4; - layer[3] = (priority &0x000f) >> 0; /* tells us which is top */ + layer[0] = (priority & 0xf000) >> 12; /* tells us which bg layer is bottom */ + layer[1] = (priority & 0x0f00) >> 8; + layer[2] = (priority & 0x00f0) >> 4; + layer[3] = (priority & 0x000f) >> 0; /* tells us which is top */ layer[4] = 4; /* text layer always over bg layers */ - tilepri[0] = tc0360pri_r(tc0360pri, 4) & 0x0f; /* bg0 */ - tilepri[1] = tc0360pri_r(tc0360pri, 4) >> 4; /* bg1 */ - tilepri[2] = tc0360pri_r(tc0360pri, 5) & 0x0f; /* bg2 */ - tilepri[3] = tc0360pri_r(tc0360pri, 5) >> 4; /* bg3 */ + tilepri[0] = tc0360pri_r(state->tc0360pri, 4) & 0x0f; /* bg0 */ + tilepri[1] = tc0360pri_r(state->tc0360pri, 4) >> 4; /* bg1 */ + tilepri[2] = tc0360pri_r(state->tc0360pri, 5) & 0x0f; /* bg2 */ + tilepri[3] = tc0360pri_r(state->tc0360pri, 5) >> 4; /* bg3 */ /* we actually assume text layer is on top of everything anyway, but FWIW... */ - tilepri[layer[4]] = tc0360pri_r(tc0360pri, 7) & 0x0f; /* fg (text layer) */ + tilepri[layer[4]] = tc0360pri_r(state->tc0360pri, 7) & 0x0f; /* fg (text layer) */ - spritepri[0] = tc0360pri_r(tc0360pri, 6) & 0x0f; - spritepri[1] = tc0360pri_r(tc0360pri, 6) >> 4; - spritepri[2] = tc0360pri_r(tc0360pri, 7) & 0x0f; - spritepri[3] = tc0360pri_r(tc0360pri, 7) >> 4; + spritepri[0] = tc0360pri_r(state->tc0360pri, 6) & 0x0f; + spritepri[1] = tc0360pri_r(state->tc0360pri, 6) >> 4; + spritepri[2] = tc0360pri_r(state->tc0360pri, 7) & 0x0f; + spritepri[3] = tc0360pri_r(state->tc0360pri, 7) >> 4; - bitmap_fill(screen->machine->priority_bitmap,cliprect,0); - bitmap_fill(bitmap,cliprect,0); + bitmap_fill(screen->machine->priority_bitmap, cliprect, 0); + bitmap_fill(bitmap, cliprect, 0); #ifdef MAME_DEBUG - if (dislayer[layer[0]]==0) + if (dislayer[layer[0]] == 0) #endif - tc0480scp_tilemap_draw(tc0480scp, bitmap, cliprect, layer[0], 0, 1); + tc0480scp_tilemap_draw(state->tc0480scp, bitmap, cliprect, layer[0], 0, 1); #ifdef MAME_DEBUG - if (dislayer[layer[1]]==0) + if (dislayer[layer[1]] == 0) #endif - tc0480scp_tilemap_draw(tc0480scp, bitmap, cliprect, layer[1], 0, 2); + tc0480scp_tilemap_draw(state->tc0480scp, bitmap, cliprect, layer[1], 0, 2); #ifdef MAME_DEBUG - if (dislayer[layer[2]]==0) + if (dislayer[layer[2]] == 0) #endif - tc0480scp_tilemap_draw(tc0480scp, bitmap, cliprect, layer[2], 0, 4); + tc0480scp_tilemap_draw(state->tc0480scp, bitmap, cliprect, layer[2], 0, 4); #ifdef MAME_DEBUG - if (dislayer[layer[3]]==0) + if (dislayer[layer[3]] == 0) #endif - tc0480scp_tilemap_draw(tc0480scp, bitmap, cliprect, layer[3], 0, 8); + tc0480scp_tilemap_draw(state->tc0480scp, bitmap, cliprect, layer[3], 0, 8); { int primasks[4] = {0,0,0,0}; int i; - for (i = 0;i < 4;i++) + for (i = 0; i < 4; i++) { if (spritepri[i] < tilepri[(layer[0])]) primasks[i] |= 0xaaaa; if (spritepri[i] < tilepri[(layer[1])]) primasks[i] |= 0xcccc; @@ -613,9 +568,9 @@ VIDEO_UPDATE( slapshot ) */ #ifdef MAME_DEBUG - if (dislayer[layer[4]]==0) + if (dislayer[layer[4]] == 0) #endif - tc0480scp_tilemap_draw(tc0480scp, bitmap, cliprect, layer[4], 0, 0); + tc0480scp_tilemap_draw(state->tc0480scp, bitmap, cliprect, layer[4], 0, 0); return 0; } diff --git a/src/mame/video/taitoic.c b/src/mame/video/taitoic.c index 41b06c8408f..91d720d54b1 100644 --- a/src/mame/video/taitoic.c +++ b/src/mame/video/taitoic.c @@ -2154,6 +2154,13 @@ static STATE_POSTLOAD( tc0100scn_postload ) tc0100scn_set_layer_ptrs(tc0100scn); tc0100scn_restore_scroll(tc0100scn); + + tilemap_mark_all_tiles_dirty(tc0100scn->tilemap[0][0]); + tilemap_mark_all_tiles_dirty(tc0100scn->tilemap[1][0]); + tilemap_mark_all_tiles_dirty(tc0100scn->tilemap[2][0]); + tilemap_mark_all_tiles_dirty(tc0100scn->tilemap[0][1]); + tilemap_mark_all_tiles_dirty(tc0100scn->tilemap[1][1]); + tilemap_mark_all_tiles_dirty(tc0100scn->tilemap[2][1]); } READ16_DEVICE_HANDLER( tc0100scn_word_r ) diff --git a/src/mame/video/warriorb.c b/src/mame/video/warriorb.c index 04be5b0feec..2567c13decf 100644 --- a/src/mame/video/warriorb.c +++ b/src/mame/video/warriorb.c @@ -1,14 +1,15 @@ #include "driver.h" #include "video/taitoic.h" +#include "includes/warriorb.h" /**********************************************************/ VIDEO_START( warriorb ) { - const device_config *tc0100scn = devtag_get_device(machine, "tc0100scn_1"); + warriorb_state *state = (warriorb_state *)machine->driver_data; /* Ensure palette from correct TC0110PCR used for each screen */ - tc0100scn_set_colbanks(tc0100scn, 0x0, 0x100, 0x0); + tc0100scn_set_colbanks(state->tc0100scn_1, 0x0, 0x100, 0x0); } @@ -16,27 +17,28 @@ VIDEO_START( warriorb ) SPRITE DRAW ROUTINE ************************************************************/ -static void draw_sprites(running_machine *machine, bitmap_t *bitmap,const rectangle *cliprect,int x_offs,int y_offs) +static void draw_sprites( running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect, int x_offs, int y_offs ) { - UINT16 *spriteram16 = machine->generic.spriteram.u16; + warriorb_state *state = (warriorb_state *)machine->driver_data; + UINT16 *spriteram = state->spriteram; int offs, data, data2, tilenum, color, flipx, flipy; int x, y, priority, pri_mask; #ifdef MAME_DEBUG - int unknown=0; + int unknown = 0; #endif /* pdrawgfx() needs us to draw sprites front to back */ - for (offs = 0;offs < machine->generic.spriteram_size/2;offs += 4) + for (offs = 0; offs < state->spriteram_size / 2; offs += 4) { - data = spriteram16[offs+1]; + data = spriteram[offs + 1]; tilenum = data & 0x7fff; - data = spriteram16[offs+0]; - y = (-(data &0x1ff) - 24) & 0x1ff; /* (inverted y adjusted for vis area) */ + data = spriteram[offs + 0]; + y = (-(data & 0x1ff) - 24) & 0x1ff; /* (inverted y adjusted for vis area) */ flipy = (data & 0x200) >> 9; - data2 = spriteram16[offs+2]; + data2 = spriteram[offs + 2]; /* 8,4 also seen in msbyte */ priority = (data2 & 0x0100) >> 8; // 1 = low @@ -45,9 +47,9 @@ static void draw_sprites(running_machine *machine, bitmap_t *bitmap,const rectan else pri_mask = 0; - color = (data2 & 0x7f); + color = (data2 & 0x7f); - data = spriteram16[offs+3]; + data = spriteram[offs + 3]; x = (data & 0x3ff); flipx = (data & 0x400) >> 10; @@ -60,8 +62,8 @@ static void draw_sprites(running_machine *machine, bitmap_t *bitmap,const rectan y += y_offs; /* sprite wrap: coords become negative at high values */ - if (x>0x3c0) x -= 0x400; - if (y>0x180) y -= 0x200; + if (x > 0x3c0) x -= 0x400; + if (y > 0x180) y -= 0x200; pdrawgfx_transpen(bitmap,cliprect,machine->gfx[0], tilenum, @@ -84,22 +86,20 @@ static void draw_sprites(running_machine *machine, bitmap_t *bitmap,const rectan VIDEO_UPDATE( warriorb ) { + warriorb_state *state = (warriorb_state *)screen->machine->driver_data; int xoffs = 0; UINT8 layer[3], nodraw; - - const device_config *left_screen = devtag_get_device(screen->machine, "lscreen"); - const device_config *right_screen = devtag_get_device(screen->machine, "rscreen"); const device_config *tc0100scn = NULL; - if (screen == left_screen) + if (screen == state->lscreen) { xoffs = 40 * 8 * 0; - tc0100scn = devtag_get_device(screen->machine, "tc0100scn_1"); + tc0100scn = state->tc0100scn_1; } - else if (screen == right_screen) + else if (screen == state->rscreen) { xoffs = 40 * 8 * 1; - tc0100scn = devtag_get_device(screen->machine, "tc0100scn_2"); + tc0100scn = state->tc0100scn_2; } tc0100scn_tilemap_update(tc0100scn); diff --git a/src/mame/video/wgp.c b/src/mame/video/wgp.c index 19f47f56386..f8369fd9650 100644 --- a/src/mame/video/wgp.c +++ b/src/mame/video/wgp.c @@ -1,75 +1,70 @@ #include "driver.h" #include "video/taitoic.h" - -static tilemap_t *wgp_piv_tilemap[3]; - -UINT16 *wgp_spritemap; -size_t wgp_spritemap_size; -UINT16 *wgp_pivram; -UINT16 *wgp_piv_ctrlram; - -static UINT16 wgp_piv_ctrl_reg; -static UINT16 wgp_piv_zoom[3],wgp_piv_scrollx[3],wgp_piv_scrolly[3]; -UINT16 wgp_rotate_ctrl[8]; -static int wgp_piv_xoffs,wgp_piv_yoffs; - +#include "includes/wgp.h" /*******************************************************************/ -INLINE void common_get_piv_tile_info(running_machine *machine,tile_data *tileinfo,int tile_index,int num) +INLINE void common_get_piv_tile_info( running_machine *machine, tile_data *tileinfo, int tile_index, int num ) { - UINT16 tilenum = wgp_pivram[tile_index + num*0x1000]; /* 3 blocks of $2000 */ - UINT16 attr = wgp_pivram[tile_index + num*0x1000 + 0x8000]; /* 3 blocks of $2000 */ + wgp_state *state = (wgp_state *)machine->driver_data; + UINT16 tilenum = state->pivram[tile_index + num * 0x1000]; /* 3 blocks of $2000 */ + UINT16 attr = state->pivram[tile_index + num * 0x1000 + 0x8000]; /* 3 blocks of $2000 */ SET_TILE_INFO( 2, tilenum & 0x3fff, - (attr & 0x3f), /* attr &0x1 ?? */ + (attr & 0x3f), /* attr & 0x1 ?? */ TILE_FLIPYX( (attr & 0xc0) >> 6)); } static TILE_GET_INFO( get_piv0_tile_info ) { - common_get_piv_tile_info(machine,tileinfo,tile_index,0); + common_get_piv_tile_info(machine, tileinfo, tile_index, 0); } static TILE_GET_INFO( get_piv1_tile_info ) { - common_get_piv_tile_info(machine,tileinfo,tile_index,1); + common_get_piv_tile_info(machine, tileinfo, tile_index, 1); } static TILE_GET_INFO( get_piv2_tile_info ) { - common_get_piv_tile_info(machine,tileinfo,tile_index,2); + common_get_piv_tile_info(machine, tileinfo, tile_index, 2); } -static void wgp_core_vh_start(running_machine *machine, int piv_xoffs, int piv_yoffs) +static void wgp_core_vh_start( running_machine *machine, int piv_xoffs, int piv_yoffs ) { - const device_config *tc0100scn = devtag_get_device(machine, "tc0100scn"); + wgp_state *state = (wgp_state *)machine->driver_data; - wgp_piv_tilemap[0] = tilemap_create(machine, get_piv0_tile_info, tilemap_scan_rows, 16, 16, 64, 64); - wgp_piv_tilemap[1] = tilemap_create(machine, get_piv1_tile_info, tilemap_scan_rows, 16, 16, 64, 64); - wgp_piv_tilemap[2] = tilemap_create(machine, get_piv2_tile_info, tilemap_scan_rows, 16, 16, 64, 64); + state->piv_tilemap[0] = tilemap_create(machine, get_piv0_tile_info, tilemap_scan_rows, 16, 16, 64, 64); + state->piv_tilemap[1] = tilemap_create(machine, get_piv1_tile_info, tilemap_scan_rows, 16, 16, 64, 64); + state->piv_tilemap[2] = tilemap_create(machine, get_piv2_tile_info, tilemap_scan_rows, 16, 16, 64, 64); - wgp_piv_xoffs = piv_xoffs; - wgp_piv_yoffs = piv_yoffs; + state->piv_xoffs = piv_xoffs; + state->piv_yoffs = piv_yoffs; - tilemap_set_transparent_pen(wgp_piv_tilemap[0], 0); - tilemap_set_transparent_pen(wgp_piv_tilemap[1], 0); - tilemap_set_transparent_pen(wgp_piv_tilemap[2], 0); + tilemap_set_transparent_pen(state->piv_tilemap[0], 0); + tilemap_set_transparent_pen(state->piv_tilemap[1], 0); + tilemap_set_transparent_pen(state->piv_tilemap[2], 0); /* flipscreen n/a */ - tilemap_set_scrolldx(wgp_piv_tilemap[0], -piv_xoffs, 0); - tilemap_set_scrolldx(wgp_piv_tilemap[1], -piv_xoffs, 0); - tilemap_set_scrolldx(wgp_piv_tilemap[2], -piv_xoffs, 0); - tilemap_set_scrolldy(wgp_piv_tilemap[0], -piv_yoffs, 0); - tilemap_set_scrolldy(wgp_piv_tilemap[1], -piv_yoffs, 0); - tilemap_set_scrolldy(wgp_piv_tilemap[2], -piv_yoffs, 0); + tilemap_set_scrolldx(state->piv_tilemap[0], -piv_xoffs, 0); + tilemap_set_scrolldx(state->piv_tilemap[1], -piv_xoffs, 0); + tilemap_set_scrolldx(state->piv_tilemap[2], -piv_xoffs, 0); + tilemap_set_scrolldy(state->piv_tilemap[0], -piv_yoffs, 0); + tilemap_set_scrolldy(state->piv_tilemap[1], -piv_yoffs, 0); + tilemap_set_scrolldy(state->piv_tilemap[2], -piv_yoffs, 0); /* We don't need tilemap_set_scroll_rows, as the custom draw routine applies rowscroll manually */ - tc0100scn_set_colbanks(tc0100scn, 0x80, 0xc0, 0x40); + tc0100scn_set_colbanks(state->tc0100scn, 0x80, 0xc0, 0x40); + + state_save_register_global(machine, state->piv_ctrl_reg); + state_save_register_global_array(machine, state->rotate_ctrl); + state_save_register_global_array(machine, state->piv_zoom); + state_save_register_global_array(machine, state->piv_scrollx); + state_save_register_global_array(machine, state->piv_scrolly); } VIDEO_START( wgp ) @@ -129,69 +124,74 @@ custom chip capable of four rather than three tilemaps.) READ16_HANDLER( wgp_pivram_word_r ) { - return wgp_pivram[offset]; + wgp_state *state = (wgp_state *)space->machine->driver_data; + return state->pivram[offset]; } WRITE16_HANDLER( wgp_pivram_word_w ) { - COMBINE_DATA(&wgp_pivram[offset]); + wgp_state *state = (wgp_state *)space->machine->driver_data; - if (offset<0x3000) + COMBINE_DATA(&state->pivram[offset]); + + if (offset < 0x3000) { - tilemap_mark_tile_dirty(wgp_piv_tilemap[(offset / 0x1000)], (offset % 0x1000) ); + tilemap_mark_tile_dirty(state->piv_tilemap[(offset / 0x1000)], (offset % 0x1000)); } - else if ((offset >=0x3400) && (offset<0x4000)) + else if ((offset >= 0x3400) && (offset < 0x4000)) { /* do nothing, custom draw routine takes care of raster effects */ } - else if ((offset >=0x8000) && (offset<0xb000)) + else if ((offset >= 0x8000) && (offset < 0xb000)) { - tilemap_mark_tile_dirty(wgp_piv_tilemap[((offset - 0x8000)/ 0x1000)], (offset % 0x1000) ); + tilemap_mark_tile_dirty(state->piv_tilemap[((offset - 0x8000)/ 0x1000)], (offset % 0x1000)); } } READ16_HANDLER( wgp_piv_ctrl_word_r ) { - return wgp_piv_ctrlram[offset]; + wgp_state *state = (wgp_state *)space->machine->driver_data; + return state->piv_ctrlram[offset]; } WRITE16_HANDLER( wgp_piv_ctrl_word_w ) { - UINT16 a,b; + wgp_state *state = (wgp_state *)space->machine->driver_data; + UINT16 a, b; - COMBINE_DATA(&wgp_piv_ctrlram[offset]); - data = wgp_piv_ctrlram[offset]; + COMBINE_DATA(&state->piv_ctrlram[offset]); + data = state->piv_ctrlram[offset]; switch (offset) { case 0x00: a = -data; - b = (a &0xffe0) >> 1; /* kill bit 4 */ - wgp_piv_scrollx[0] = (a &0xf) | b; + b = (a & 0xffe0) >> 1; /* kill bit 4 */ + state->piv_scrollx[0] = (a & 0xf) | b; break; case 0x01: a = -data; - b = (a &0xffe0) >> 1; - wgp_piv_scrollx[1] = (a &0xf) | b; + b = (a & 0xffe0) >> 1; + state->piv_scrollx[1] = (a & 0xf) | b; break; case 0x02: a = -data; - b = (a &0xffe0) >> 1; - wgp_piv_scrollx[2] = (a &0xf) | b; + b = (a & 0xffe0) >> 1; + state->piv_scrollx[2] = (a & 0xf) | b; break; case 0x03: - wgp_piv_scrolly[0] = data; + state->piv_scrolly[0] = data; break; case 0x04: - wgp_piv_scrolly[1] = data; + state->piv_scrolly[1] = data; break; case 0x05: - wgp_piv_scrolly[2] = data; + state->piv_scrolly[2] = data; break; case 0x06: @@ -201,24 +201,24 @@ WRITE16_HANDLER( wgp_piv_ctrl_word_w ) seen on Wgp stages 4,5,7 in which piv 2 used for cloud or scenery wandering up screen */ - wgp_piv_ctrl_reg = data; + state->piv_ctrl_reg = data; break; case 0x08: /* piv 0 y zoom (0x7f = normal, not seen others) */ - wgp_piv_zoom[0] = data; + state->piv_zoom[0] = data; break; case 0x09: /* piv 1 y zoom (0x7f = normal, values 0 & 0xff7f-ffbc in Wgp2) */ - wgp_piv_zoom[1] = data; + state->piv_zoom[1] = data; break; case 0x0a: /* piv 2 y zoom (0x7f = normal, values 0 & 0xff7f-ffbc in Wgp2, 0-0x98 in Wgp round 4/5) */ - wgp_piv_zoom[2] = data; + state->piv_zoom[2] = data; break; } } @@ -284,7 +284,7 @@ Memory Map +0x02 y pos (signed) +0x04 index to tile mapping area [2 msbs always set] - (400000 + (index &0x3fff) << 2) points to relevant part of + (400000 + (index & 0x3fff) << 2) points to relevant part of sprite tile mapping area. Index >0x2fff would be invalid. +0x06 zoom size (pixels) [typical range 0x1-5f, 0x3f = standard] @@ -346,53 +346,53 @@ static const UINT8 ylookup[16] = 2, 2, 3, 3, 2, 2, 3, 3 }; -static void draw_sprites(running_machine *machine, bitmap_t *bitmap,const rectangle *cliprect,int y_offs) +static void draw_sprites( running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect, int y_offs ) { - UINT16 *spriteram16 = machine->generic.spriteram.u16; - int offs,i,j,k; - int x,y,curx,cury; - int zx,zy,zoomx,zoomy,priority=0; - UINT8 small_sprite,col,flipx,flipy; - UINT16 code,bigsprite,map_index; - UINT16 rotate=0; + wgp_state *state = (wgp_state *)machine->driver_data; + UINT16 *spriteram = state->spriteram; + int offs, i, j, k; + int x, y, curx, cury; + int zx, zy, zoomx, zoomy, priority = 0; + UINT8 small_sprite, col, flipx, flipy; + UINT16 code, bigsprite, map_index; + UINT16 rotate = 0; UINT16 tile_mask = (machine->gfx[0]->total_elements) - 1; static const int primasks[2] = {0x0, 0xfffc}; /* fff0 => under rhs of road only */ - for (offs = 0x1ff;offs >= 0;offs--) + for (offs = 0x1ff; offs >= 0; offs--) { - code = (spriteram16[0xe00+offs]); + code = (spriteram[0xe00 + offs]); if (code) /* do we have an active sprite ? */ { - i = (code << 3) &0xfff; /* yes, so we look up its sprite entry */ + i = (code << 3) & 0xfff; /* yes, so we look up its sprite entry */ - x = spriteram16[i]; - y = spriteram16[i + 1]; - bigsprite = spriteram16[i + 2] &0x3fff; + x = spriteram[i]; + y = spriteram[i + 1]; + bigsprite = spriteram[i + 2] & 0x3fff; /* The last five words [i + 3 thru 7] must be zoom/rotation control: for time being we kludge zoom using 1 word. Timing problems are causing many glitches. */ -if ((spriteram16[i + 4]==0xfff6) && (spriteram16[i + 5]==0)) - continue; + if ((spriteram[i + 4] == 0xfff6) && (spriteram[i + 5] == 0)) + continue; -if (((spriteram16[i + 4]!=0xf800) && (spriteram16[i + 4]!=0xfff6)) - || ((spriteram16[i + 5]!=0xf800) && (spriteram16[i + 5]!=0)) - || spriteram16[i + 7]!=0) + if (((spriteram[i + 4] != 0xf800) && (spriteram[i + 4] != 0xfff6)) + || ((spriteram[i + 5] != 0xf800) && (spriteram[i + 5] != 0)) + || spriteram[i + 7] != 0) + rotate = i << 1; - rotate = i << 1; + /***** Begin zoom kludge ******/ - /***** Begin zoom kludge ******/ + zoomx = (spriteram[i + 3] & 0x1ff) + 1; + zoomy = (spriteram[i + 3] & 0x1ff) + 1; - zoomx = (spriteram16[i + 3] &0x1ff) + 1; - zoomy = (spriteram16[i + 3] &0x1ff) + 1; + y -= 4; + // distant sprites were some 16 pixels too far down // + y -= ((0x40 - zoomy)/4); - y -=4; - // distant sprites were some 16 pixels too far down // - y -=((0x40-zoomy)/4); - - /****** end zoom kludge *******/ + /****** end zoom kludge *******/ /* Treat coords as signed */ if (x & 0x8000) x -= 0x10000; @@ -400,34 +400,33 @@ if (((spriteram16[i + 4]!=0xf800) && (spriteram16[i + 4]!=0xfff6)) map_index = bigsprite << 1; /* now we access sprite tilemap */ - /* don't know what selects 2x2 sprites: we use a nasty kludge - which seems to work */ + /* don't know what selects 2x2 sprites: we use a nasty kludge which seems to work */ - i = wgp_spritemap[map_index + 0xa]; - j = wgp_spritemap[map_index + 0xc]; - small_sprite = ((i > 0) & (i <=8) & (j > 0) & (j <=8)); + i = state->spritemap[map_index + 0xa]; + j = state->spritemap[map_index + 0xc]; + small_sprite = ((i > 0) & (i <= 8) & (j > 0) & (j <= 8)); if (small_sprite) { - for (i=0;i<4;i++) + for (i = 0; i < 4; i++) { - code = wgp_spritemap[(map_index + (i << 1))] &tile_mask; - col = wgp_spritemap[(map_index + (i << 1) + 1)] &0xf; + code = state->spritemap[(map_index + (i << 1))] & tile_mask; + col = state->spritemap[(map_index + (i << 1) + 1)] & 0xf; /* not known what controls priority */ - priority = (wgp_spritemap[(map_index + (i << 1) + 1)] &0x70) >> 4; + priority = (state->spritemap[(map_index + (i << 1) + 1)] & 0x70) >> 4; - flipx=0; // no flip xy? - flipy=0; + flipx = 0; // no flip xy? + flipy = 0; k = xlookup[i]; // assumes no xflip j = ylookup[i]; // assumes no yflip - curx = x + ((k*zoomx)/2); - cury = y + ((j*zoomy)/2); + curx = x + ((k * zoomx) / 2); + cury = y + ((j * zoomy) / 2); - zx = x + (((k+1)*zoomx)/2) - curx; - zy = y + (((j+1)*zoomy)/2) - cury; + zx = x + (((k + 1) * zoomx) / 2) - curx; + zy = y + (((j + 1) * zoomy) / 2) - cury; pdrawgfxzoom_transpen(bitmap, cliprect,machine->gfx[0], code, @@ -440,25 +439,25 @@ if (((spriteram16[i + 4]!=0xf800) && (spriteram16[i + 4]!=0xfff6)) } else { - for (i=0;i<16;i++) + for (i = 0; i < 16; i++) { - code = wgp_spritemap[(map_index + (i << 1))] &tile_mask; - col = wgp_spritemap[(map_index + (i << 1) + 1)] &0xf; + code = state->spritemap[(map_index + (i << 1))] & tile_mask; + col = state->spritemap[(map_index + (i << 1) + 1)] & 0xf; /* not known what controls priority */ - priority = (wgp_spritemap[(map_index + (i << 1) + 1)] &0x70) >> 4; + priority = (state->spritemap[(map_index + (i << 1) + 1)] & 0x70) >> 4; - flipx=0; // no flip xy? - flipy=0; + flipx = 0; // no flip xy? + flipy = 0; k = xlookup[i]; // assumes no xflip j = ylookup[i]; // assumes no yflip - curx = x + ((k*zoomx)/4); - cury = y + ((j*zoomy)/4); + curx = x + ((k * zoomx) / 4); + cury = y + ((j * zoomy) / 4); - zx = x + (((k+1)*zoomx)/4) - curx; - zy = y + (((j+1)*zoomy)/4) - cury; + zx = x + (((k + 1) * zoomx) / 4) - curx; + zy = y + (((j + 1) * zoomy) / 4) - cury; pdrawgfxzoom_transpen(bitmap, cliprect,machine->gfx[0], code, @@ -476,7 +475,7 @@ if (((spriteram16[i + 4]!=0xf800) && (spriteram16[i + 4]!=0xfff6)) if (rotate) { char buf[80]; - sprintf(buf,"sprite rotate offs %04x ?",rotate); + sprintf(buf, "sprite rotate offs %04x ?", rotate); popmessage(buf); } #endif @@ -487,25 +486,30 @@ if (((spriteram16[i + 4]!=0xf800) && (spriteram16[i + 4]!=0xfff6)) CUSTOM DRAW *********************************************************/ -INLINE void bryan2_drawscanline( - bitmap_t *bitmap,int x,int y,int length, - const UINT16 *src,int transparent,UINT32 orient,bitmap_t *priority,int pri) +INLINE void bryan2_drawscanline( bitmap_t *bitmap, int x, int y, int length, + const UINT16 *src, int transparent, UINT32 orient, bitmap_t *priority, int pri ) { UINT16 *dsti = BITMAP_ADDR16(bitmap, y, x); UINT8 *dstp = BITMAP_ADDR8(priority, y, x); - if (transparent) { - while (length--) { + if (transparent) + { + while (length--) + { UINT32 spixel = *src++; - if (spixel<0x7fff) { + if (spixel < 0x7fff) + { *dsti = spixel; *dstp = pri; } dsti++; dstp++; } - } else { /* Not transparent case */ - while (length--) { + } + else /* Not transparent case */ + { + while (length--) + { *dsti++ = *src++; *dstp++ = pri; } @@ -514,31 +518,31 @@ INLINE void bryan2_drawscanline( -static void wgp_piv_layer_draw(running_machine *machine,bitmap_t *bitmap,const rectangle *cliprect,int layer,int flags,UINT32 priority) +static void wgp_piv_layer_draw( running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect, int layer, int flags, UINT32 priority ) { - bitmap_t *srcbitmap = tilemap_get_pixmap(wgp_piv_tilemap[layer]); - bitmap_t *flagsbitmap = tilemap_get_flagsmap(wgp_piv_tilemap[layer]); + wgp_state *state = (wgp_state *)machine->driver_data; + bitmap_t *srcbitmap = tilemap_get_pixmap(state->piv_tilemap[layer]); + bitmap_t *flagsbitmap = tilemap_get_flagsmap(state->piv_tilemap[layer]); UINT16 *dst16,*src16; UINT8 *tsrc; - int i,y,y_index,src_y_index,row_index,row_zoom; + int i, y, y_index, src_y_index, row_index, row_zoom; /* I have a fairly strong feeling these should be UINT32's, x_index is falling through from max +ve to max -ve quite a lot in this routine */ - int sx,x_index,x_step,x_max; + int sx, x_index, x_step, x_max; - UINT32 zoomx,zoomy; + UINT32 zoomx, zoomy; UINT16 scanline[512]; - UINT16 row_colbank,row_scroll; + UINT16 row_colbank, row_scroll; int flipscreen = 0; /* n/a */ int machine_flip = 0; /* for ROT 180 ? */ - UINT16 screen_width = cliprect->max_x - - cliprect->min_x + 1; + UINT16 screen_width = cliprect->max_x - cliprect->min_x + 1; UINT16 min_y = cliprect->min_y; UINT16 max_y = cliprect->max_y; - int width_mask=0x3ff; + int width_mask = 0x3ff; zoomx = 0x10000; /* No overall X zoom, unlike TC0480SCP */ @@ -550,15 +554,15 @@ static void wgp_piv_layer_draw(running_machine *machine,bitmap_t *bitmap,const r In WGP2 see: road at big hill (default course) */ /* This calculation may be wrong, the y_index one too */ - zoomy = 0x10000 - (((wgp_piv_ctrlram[0x08 + layer] &0xff) - 0x7f) * 512); + zoomy = 0x10000 - (((state->piv_ctrlram[0x08 + layer] & 0xff) - 0x7f) * 512); if (!flipscreen) { - sx = ((wgp_piv_scrollx[layer]) << 16); - sx += (wgp_piv_xoffs) * zoomx; /* may be imperfect */ + sx = ((state->piv_scrollx[layer]) << 16); + sx += (state->piv_xoffs) * zoomx; /* may be imperfect */ - y_index = (wgp_piv_scrolly[layer] << 16); - y_index += (wgp_piv_yoffs + min_y) * zoomy; /* may be imperfect */ + y_index = (state->piv_scrolly[layer] << 16); + y_index += (state->piv_yoffs + min_y) * zoomy; /* may be imperfect */ } else /* piv tiles flipscreen n/a */ { @@ -566,35 +570,38 @@ static void wgp_piv_layer_draw(running_machine *machine,bitmap_t *bitmap,const r y_index = 0; } - if (!machine_flip) y=min_y; else y=max_y; + if (!machine_flip) + y = min_y; + else + y = max_y; do { int a; - src_y_index = (y_index>>16) &0x3ff; + src_y_index = (y_index >> 16) & 0x3ff; row_index = src_y_index; - row_zoom = wgp_pivram[row_index + layer*0x400 + 0x3400] &0xff; + row_zoom = state->pivram[row_index + layer * 0x400 + 0x3400] & 0xff; - row_colbank = wgp_pivram[row_index + layer*0x400 + 0x3400] >> 8; - a = (row_colbank &0xe0); /* kill bit 4 */ - row_colbank = (((row_colbank &0xf) << 1) | a) << 4; + row_colbank = state->pivram[row_index + layer * 0x400 + 0x3400] >> 8; + a = (row_colbank & 0xe0); /* kill bit 4 */ + row_colbank = (((row_colbank & 0xf) << 1) | a) << 4; - row_scroll = wgp_pivram[row_index + layer*0x1000 + 0x4000]; - a = (row_scroll &0xffe0) >> 1; /* kill bit 4 */ - row_scroll = ((row_scroll &0xf) | a) &width_mask; + row_scroll = state->pivram[row_index + layer * 0x1000 + 0x4000]; + a = (row_scroll & 0xffe0) >> 1; /* kill bit 4 */ + row_scroll = ((row_scroll & 0xf) | a) & width_mask; x_index = sx - (row_scroll << 16); x_step = zoomx; if (row_zoom > 0x7f) /* zoom in: reduce x_step */ { - x_step -= (((row_zoom - 0x7f) << 8) &0xffff); + x_step -= (((row_zoom - 0x7f) << 8) & 0xffff); } else if (row_zoom < 0x7f) /* zoom out: increase x_step */ { - x_step += (((0x7f - row_zoom) << 8) &0xffff); + x_step += (((0x7f - row_zoom) << 8) & 0xffff); } x_max = x_index + screen_width * x_step; @@ -604,30 +611,30 @@ static void wgp_piv_layer_draw(running_machine *machine,bitmap_t *bitmap,const r if (flags & TILEMAP_DRAW_OPAQUE) { - for (i=0; i> 16) &width_mask] + row_colbank; + *dst16++ = src16[(x_index >> 16) & width_mask] + row_colbank; x_index += x_step; } } else { - for (i=0; i> 16) &width_mask]) - *dst16++ = src16[(x_index >> 16) &width_mask] + row_colbank; + if (tsrc[(x_index >> 16) & width_mask]) + *dst16++ = src16[(x_index >> 16) & width_mask] + row_colbank; else *dst16++ = 0x8000; x_index += x_step; } } - bryan2_drawscanline(bitmap,0,y,screen_width,scanline,(flags & TILEMAP_DRAW_OPAQUE)?0:1,ROT0,machine->priority_bitmap,priority); + bryan2_drawscanline(bitmap, 0, y, screen_width, scanline, (flags & TILEMAP_DRAW_OPAQUE) ? 0 : 1, ROT0, machine->priority_bitmap, priority); y_index += zoomy; if (!machine_flip) y++; else y--; } - while ( (!machine_flip && y<=max_y) || (machine_flip && y>=min_y) ); + while ((!machine_flip && y <= max_y) || (machine_flip && y >= min_y)); } @@ -639,7 +646,7 @@ static void wgp_piv_layer_draw(running_machine *machine,bitmap_t *bitmap,const r VIDEO_UPDATE( wgp ) { - const device_config *tc0100scn = devtag_get_device(screen->machine, "tc0100scn"); + wgp_state *state = (wgp_state *)screen->machine->driver_data; int i; UINT8 layer[3]; @@ -673,13 +680,13 @@ VIDEO_UPDATE( wgp ) } #endif - for (i=0;i<3;i++) + for (i = 0; i < 3; i++) { - tilemap_set_scrollx(wgp_piv_tilemap[i], 0, wgp_piv_scrollx[i]); - tilemap_set_scrolly(wgp_piv_tilemap[i], 0, wgp_piv_scrolly[i]); + tilemap_set_scrollx(state->piv_tilemap[i], 0, state->piv_scrollx[i]); + tilemap_set_scrolly(state->piv_tilemap[i], 0, state->piv_scrolly[i]); } - tc0100scn_tilemap_update(tc0100scn); + tc0100scn_tilemap_update(state->tc0100scn); bitmap_fill(bitmap, cliprect, 0); @@ -687,7 +694,7 @@ VIDEO_UPDATE( wgp ) layer[1] = 1; layer[2] = 2; - if (wgp_piv_ctrl_reg == 0x2d) + if (state->piv_ctrl_reg == 0x2d) { layer[1] = 2; layer[2] = 1; @@ -713,23 +720,23 @@ VIDEO_UPDATE( wgp ) draw_sprites(screen->machine, bitmap, cliprect, 16); /* ... then here we should apply rotation from wgp_sate_ctrl[] to the bitmap before we draw the TC0100SCN layers on it */ - layer[0] = tc0100scn_bottomlayer(tc0100scn); + layer[0] = tc0100scn_bottomlayer(state->tc0100scn); layer[1] = layer[0] ^ 1; layer[2] = 2; - tc0100scn_tilemap_draw(tc0100scn, bitmap, cliprect, layer[0], 0, 0); + tc0100scn_tilemap_draw(state->tc0100scn, bitmap, cliprect, layer[0], 0, 0); #ifdef MAME_DEBUG if (dislayer[3] == 0) #endif - tc0100scn_tilemap_draw(tc0100scn, bitmap, cliprect, layer[1], 0, 0); - tc0100scn_tilemap_draw(tc0100scn, bitmap, cliprect, layer[2], 0, 0); + tc0100scn_tilemap_draw(state->tc0100scn, bitmap, cliprect, layer[1], 0, 0); + tc0100scn_tilemap_draw(state->tc0100scn, bitmap, cliprect, layer[2], 0, 0); #if 0 { char buf[80]; - sprintf(buf,"wgp_piv_ctrl_reg: %04x y zoom: %04x %04x %04x",wgp_piv_ctrl_reg, - wgp_piv_zoom[0],wgp_piv_zoom[1],wgp_piv_zoom[2]); + sprintf(buf,"wgp_piv_ctrl_reg: %04x y zoom: %04x %04x %04x",state->piv_ctrl_reg, + state->piv_zoom[0],state->piv_zoom[1],state->piv_zoom[2]); popmessage(buf); } #endif