summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
-rw-r--r--src/mame/audio/firetrk.c5
-rw-r--r--src/mame/audio/starwars.c36
-rw-r--r--src/mame/drivers/arcadecl.c3
-rw-r--r--src/mame/drivers/atarigt.c77
-rw-r--r--src/mame/drivers/atarisy1.c7
-rw-r--r--src/mame/drivers/atarisy2.c56
-rw-r--r--src/mame/drivers/atarisy4.c153
-rw-r--r--src/mame/drivers/atetris.c60
-rw-r--r--src/mame/drivers/bwidow.c19
-rw-r--r--src/mame/drivers/centiped.c66
-rw-r--r--src/mame/drivers/cloak.c7
-rw-r--r--src/mame/drivers/cmmb.c5
-rw-r--r--src/mame/drivers/cojag.c166
-rw-r--r--src/mame/drivers/eprom.c6
-rw-r--r--src/mame/drivers/firefox.c163
-rw-r--r--src/mame/drivers/firetrk.c129
-rw-r--r--src/mame/drivers/mhavoc.c10
-rw-r--r--src/mame/drivers/missile.c99
-rw-r--r--src/mame/drivers/poolshrk.c17
-rw-r--r--src/mame/drivers/runaway.c16
-rw-r--r--src/mame/drivers/sbrkout.c74
-rw-r--r--src/mame/drivers/shuuz.c8
-rw-r--r--src/mame/drivers/skydiver.c19
-rw-r--r--src/mame/drivers/sprint2.c96
-rw-r--r--src/mame/drivers/sprint4.c59
-rw-r--r--src/mame/drivers/sprint8.c51
-rw-r--r--src/mame/drivers/starshp1.c55
-rw-r--r--src/mame/drivers/starwars.c55
-rw-r--r--src/mame/drivers/subs.c2
-rw-r--r--src/mame/drivers/tank8.c25
-rw-r--r--src/mame/drivers/tempest.c26
-rw-r--r--src/mame/drivers/tomcat.c91
-rw-r--r--src/mame/drivers/ultratnk.c15
-rw-r--r--src/mame/drivers/videopin.c27
-rw-r--r--src/mame/drivers/wolfpack.c10
-rw-r--r--src/mame/includes/arcadecl.h2
-rw-r--r--src/mame/includes/atarigt.h8
-rw-r--r--src/mame/includes/atarisy1.h2
-rw-r--r--src/mame/includes/atarisy2.h10
-rw-r--r--src/mame/includes/atetris.h9
-rw-r--r--src/mame/includes/centiped.h13
-rw-r--r--src/mame/includes/cloak.h11
-rw-r--r--src/mame/includes/eprom.h1
-rw-r--r--src/mame/includes/firetrk.h46
-rw-r--r--src/mame/includes/irobot.h54
-rw-r--r--src/mame/includes/mhavoc.h24
-rw-r--r--src/mame/includes/poolshrk.h17
-rw-r--r--src/mame/includes/runaway.h17
-rw-r--r--src/mame/includes/shuuz.h2
-rw-r--r--src/mame/includes/skydiver.h15
-rw-r--r--src/mame/includes/sprint2.h19
-rw-r--r--src/mame/includes/sprint4.h10
-rw-r--r--src/mame/includes/sprint8.h29
-rw-r--r--src/mame/includes/starshp1.h57
-rw-r--r--src/mame/includes/starwars.h40
-rw-r--r--src/mame/includes/subs.h7
-rw-r--r--src/mame/includes/tank8.h24
-rw-r--r--src/mame/includes/ultratnk.h6
-rw-r--r--src/mame/includes/videopin.h19
-rw-r--r--src/mame/includes/wolfpack.h29
-rw-r--r--src/mame/machine/irobot.c299
-rw-r--r--src/mame/machine/mhavoc.c163
-rw-r--r--src/mame/machine/starwars.c152
-rw-r--r--src/mame/machine/subs.c62
-rw-r--r--src/mame/video/arcadecl.c1
-rw-r--r--src/mame/video/atetris.c14
-rw-r--r--src/mame/video/centiped.c108
-rw-r--r--src/mame/video/cloak.c105
-rw-r--r--src/mame/video/firetrk.c255
-rw-r--r--src/mame/video/irobot.c81
-rw-r--r--src/mame/video/poolshrk.c21
-rw-r--r--src/mame/video/runaway.c67
-rw-r--r--src/mame/video/skydiver.c38
-rw-r--r--src/mame/video/sprint2.c102
-rw-r--r--src/mame/video/sprint4.c23
-rw-r--r--src/mame/video/sprint8.c65
-rw-r--r--src/mame/video/starshp1.c230
-rw-r--r--src/mame/video/subs.c2
-rw-r--r--src/mame/video/tank8.c99
-rw-r--r--src/mame/video/ultratnk.c23
-rw-r--r--src/mame/video/videopin.c31
-rw-r--r--src/mame/video/wolfpack.c151
82 files changed, 2347 insertions, 1929 deletions
diff --git a/src/mame/audio/firetrk.c b/src/mame/audio/firetrk.c
index b68f5411c55..553fc5bfe4e 100644
--- a/src/mame/audio/firetrk.c
+++ b/src/mame/audio/firetrk.c
@@ -11,8 +11,9 @@
WRITE8_DEVICE_HANDLER( firetrk_skid_reset_w )
{
- firetrk_skid[0] = 0;
- firetrk_skid[1] = 0;
+ firetrk_state *state = device->machine->driver_data<firetrk_state>();
+ state->skid[0] = 0;
+ state->skid[1] = 0;
// also SUPERBUG_SKID_EN
discrete_sound_w(device, FIRETRUCK_SKID_EN, 1);
diff --git a/src/mame/audio/starwars.c b/src/mame/audio/starwars.c
index 87160a10d68..b8b83ac24b5 100644
--- a/src/mame/audio/starwars.c
+++ b/src/mame/audio/starwars.c
@@ -13,15 +13,13 @@
#include "includes/starwars.h"
-static UINT8 sound_data; /* data for the sound cpu */
-static UINT8 main_data; /* data for the main cpu */
-static device_t *riot;
SOUND_START( starwars )
{
- riot = machine->device("riot");
+ starwars_state *state = machine->driver_data<starwars_state>();
+ state->riot = machine->device("riot");
}
@@ -85,16 +83,18 @@ const riot6532_interface starwars_riot6532_intf =
static TIMER_CALLBACK( sound_callback )
{
- riot6532_porta_in_set(riot, 0x40, 0x40);
- main_data = param;
+ starwars_state *state = machine->driver_data<starwars_state>();
+ riot6532_porta_in_set(state->riot, 0x40, 0x40);
+ state->main_data = param;
cpuexec_boost_interleave(machine, attotime_zero, ATTOTIME_IN_USEC(100));
}
READ8_HANDLER( starwars_sin_r )
{
- riot6532_porta_in_set(riot, 0x00, 0x80);
- return sound_data;
+ starwars_state *state = space->machine->driver_data<starwars_state>();
+ riot6532_porta_in_set(state->riot, 0x00, 0x80);
+ return state->sound_data;
}
@@ -113,23 +113,26 @@ WRITE8_HANDLER( starwars_sout_w )
READ8_HANDLER( starwars_main_read_r )
{
- riot6532_porta_in_set(riot, 0x00, 0x40);
- return main_data;
+ starwars_state *state = space->machine->driver_data<starwars_state>();
+ riot6532_porta_in_set(state->riot, 0x00, 0x40);
+ return state->main_data;
}
READ8_HANDLER( starwars_main_ready_flag_r )
{
- return riot6532_porta_in_get(riot) & 0xc0; /* only upper two flag bits mapped */
+ starwars_state *state = space->machine->driver_data<starwars_state>();
+ return riot6532_porta_in_get(state->riot) & 0xc0; /* only upper two flag bits mapped */
}
static TIMER_CALLBACK( main_callback )
{
- if (riot6532_porta_in_get(riot) & 0x80)
- logerror("Sound data not read %x\n",sound_data);
+ starwars_state *state = machine->driver_data<starwars_state>();
+ if (riot6532_porta_in_get(state->riot) & 0x80)
+ logerror("Sound data not read %x\n",state->sound_data);
- riot6532_porta_in_set(riot, 0x80, 0x80);
- sound_data = param;
+ riot6532_porta_in_set(state->riot, 0x80, 0x80);
+ state->sound_data = param;
cpuexec_boost_interleave(machine, attotime_zero, ATTOTIME_IN_USEC(100));
}
@@ -141,7 +144,8 @@ WRITE8_HANDLER( starwars_main_wr_w )
WRITE8_HANDLER( starwars_soundrst_w )
{
- riot6532_porta_in_set(riot, 0x00, 0xc0);
+ starwars_state *state = space->machine->driver_data<starwars_state>();
+ riot6532_porta_in_set(state->riot, 0x00, 0xc0);
/* reset sound CPU here */
cputag_set_input_line(space->machine, "audiocpu", INPUT_LINE_RESET, PULSE_LINE);
diff --git a/src/mame/drivers/arcadecl.c b/src/mame/drivers/arcadecl.c
index 894263e8c43..8034ab4553b 100644
--- a/src/mame/drivers/arcadecl.c
+++ b/src/mame/drivers/arcadecl.c
@@ -68,8 +68,9 @@
#include "emu.h"
#include "cpu/m68000/m68000.h"
-#include "includes/arcadecl.h"
#include "sound/okim6295.h"
+#include "includes/rampart.h"
+#include "includes/arcadecl.h"
#define MASTER_CLOCK XTAL_14_31818MHz
diff --git a/src/mame/drivers/atarigt.c b/src/mame/drivers/atarigt.c
index 48a0924ee7a..d5a35b32947 100644
--- a/src/mame/drivers/atarigt.c
+++ b/src/mame/drivers/atarigt.c
@@ -259,29 +259,23 @@ static WRITE32_HANDLER( sound_data_w )
*
*************************************/
-#define ADDRSEQ_COUNT 4
-static offs_t protaddr[ADDRSEQ_COUNT];
-static UINT8 protmode;
-static UINT16 protresult;
-static UINT8 protdata[0x800];
-static UINT8 ignore_writes = 0;
-
-static void tmek_update_mode(offs_t offset)
+static void tmek_update_mode(atarigt_state *state, offs_t offset)
{
int i;
/* pop us into the readseq */
for (i = 0; i < ADDRSEQ_COUNT - 1; i++)
- protaddr[i] = protaddr[i + 1];
- protaddr[ADDRSEQ_COUNT - 1] = offset;
+ state->protaddr[i] = state->protaddr[i + 1];
+ state->protaddr[ADDRSEQ_COUNT - 1] = offset;
}
static void tmek_protection_w(address_space *space, offs_t offset, UINT16 data)
{
+ atarigt_state *state = space->machine->driver_data<atarigt_state>();
/*
T-Mek init:
($387C0) = $0001
@@ -293,22 +287,23 @@ static void tmek_protection_w(address_space *space, offs_t offset, UINT16 data)
if (LOG_PROTECTION) logerror("%06X:Protection W@%06X = %04X\n", cpu_get_previouspc(space->cpu), offset, data);
/* track accesses */
- tmek_update_mode(offset);
+ tmek_update_mode(state, offset);
switch (offset)
{
case 0xdb0000:
- ignore_writes = (data == 0x18);
+ state->ignore_writes = (data == 0x18);
break;
}
}
static void tmek_protection_r(address_space *space, offs_t offset, UINT16 *data)
{
+ atarigt_state *state = space->machine->driver_data<atarigt_state>();
if (LOG_PROTECTION) logerror("%06X:Protection R@%06X\n", cpu_get_previouspc(space->cpu), offset);
/* track accesses */
- tmek_update_mode(offset);
+ tmek_update_mode(state, offset);
/* handle specific reads */
switch (offset)
@@ -316,7 +311,7 @@ static void tmek_protection_r(address_space *space, offs_t offset, UINT16 *data)
/* status register; the code spins on this waiting for the high bit to be set */
case 0xdb8700:
case 0xdb87c0:
-// if (protmode != 0)
+// if (state->protmode != 0)
{
*data = -1;//0x8000;
}
@@ -332,37 +327,37 @@ static void tmek_protection_r(address_space *space, offs_t offset, UINT16 *data)
*
*************************************/
-static void primage_update_mode(offs_t offset)
+static void primage_update_mode(atarigt_state *state, offs_t offset)
{
int i;
/* pop us into the readseq */
for (i = 0; i < ADDRSEQ_COUNT - 1; i++)
- protaddr[i] = protaddr[i + 1];
- protaddr[ADDRSEQ_COUNT - 1] = offset;
+ state->protaddr[i] = state->protaddr[i + 1];
+ state->protaddr[ADDRSEQ_COUNT - 1] = offset;
/* check for particular sequences */
- if (!protmode)
+ if (!state->protmode)
{
/* this is from the code at $20f90 */
- if (protaddr[1] == 0xdcc7c4 && protaddr[2] == 0xdcc7c4 && protaddr[3] == 0xdc4010)
+ if (state->protaddr[1] == 0xdcc7c4 && state->protaddr[2] == 0xdcc7c4 && state->protaddr[3] == 0xdc4010)
{
if (LOG_PROTECTION) logerror("prot:Entering mode 1\n");
- protmode = 1;
+ state->protmode = 1;
}
/* this is from the code at $27592 */
- if (protaddr[0] == 0xdcc7ca && protaddr[1] == 0xdcc7ca && protaddr[2] == 0xdcc7c6 && protaddr[3] == 0xdc4022)
+ if (state->protaddr[0] == 0xdcc7ca && state->protaddr[1] == 0xdcc7ca && state->protaddr[2] == 0xdcc7c6 && state->protaddr[3] == 0xdc4022)
{
if (LOG_PROTECTION) logerror("prot:Entering mode 2\n");
- protmode = 2;
+ state->protmode = 2;
}
/* this is from the code at $3d8dc */
- if (protaddr[0] == 0xdcc7c0 && protaddr[1] == 0xdcc7c0 && protaddr[2] == 0xdc80f2 && protaddr[3] == 0xdc7af2)
+ if (state->protaddr[0] == 0xdcc7c0 && state->protaddr[1] == 0xdcc7c0 && state->protaddr[2] == 0xdc80f2 && state->protaddr[3] == 0xdc7af2)
{
if (LOG_PROTECTION) logerror("prot:Entering mode 3\n");
- protmode = 3;
+ state->protmode = 3;
}
}
}
@@ -371,6 +366,7 @@ static void primage_update_mode(offs_t offset)
static void primrage_protection_w(address_space *space, offs_t offset, UINT16 data)
{
+ atarigt_state *state = space->machine->driver_data<atarigt_state>();
if (LOG_PROTECTION)
{
UINT32 pc = cpu_get_previouspc(space->cpu);
@@ -414,25 +410,25 @@ static void primrage_protection_w(address_space *space, offs_t offset, UINT16 da
/* mask = 0x78fff */
/* track accesses */
- primage_update_mode(offset);
+ primage_update_mode(state, offset);
/* check for certain read sequences */
- if (protmode == 1 && offset >= 0xdc7800 && offset < 0xdc7800 + sizeof(protdata) * 2)
- protdata[(offset - 0xdc7800) / 2] = data;
+ if (state->protmode == 1 && offset >= 0xdc7800 && offset < 0xdc7800 + sizeof(state->protdata) * 2)
+ state->protdata[(offset - 0xdc7800) / 2] = data;
- if (protmode == 2)
+ if (state->protmode == 2)
{
int temp = (offset - 0xdc7800) / 2;
if (LOG_PROTECTION) logerror("prot:mode 2 param = %04X\n", temp);
- protresult = temp * 0x6915 + 0x6915;
+ state->protresult = temp * 0x6915 + 0x6915;
}
- if (protmode == 3)
+ if (state->protmode == 3)
{
if (offset == 0xdc4700)
{
if (LOG_PROTECTION) logerror("prot:Clearing mode 3\n");
- protmode = 0;
+ state->protmode = 0;
}
}
}
@@ -441,8 +437,9 @@ static void primrage_protection_w(address_space *space, offs_t offset, UINT16 da
static void primrage_protection_r(address_space *space, offs_t offset, UINT16 *data)
{
+ atarigt_state *state = space->machine->driver_data<atarigt_state>();
/* track accesses */
- primage_update_mode(offset);
+ primage_update_mode(state, offset);
if (LOG_PROTECTION)
{
@@ -519,7 +516,7 @@ if (LOG_PROTECTION)
{
/* status register; the code spins on this waiting for the high bit to be set */
case 0xdc4700:
-// if (protmode != 0)
+// if (state->protmode != 0)
{
*data = 0x8000;
}
@@ -527,18 +524,18 @@ if (LOG_PROTECTION)
/* some kind of result register */
case 0xdcc7c2:
- if (protmode == 2)
+ if (state->protmode == 2)
{
- *data = protresult;
- protmode = 0;
+ *data = state->protresult;
+ state->protmode = 0;
if (LOG_PROTECTION) logerror("prot:Clearing mode 2\n");
}
break;
case 0xdcc7c4:
- if (protmode == 1)
+ if (state->protmode == 1)
{
- protmode = 0;
+ state->protmode = 0;
if (LOG_PROTECTION) logerror("prot:Clearing mode 1\n");
}
break;
@@ -584,13 +581,13 @@ static WRITE32_HANDLER( colorram_protection_w )
if (ACCESSING_BITS_16_31)
{
- if (!ignore_writes)
+ if (!state->ignore_writes)
atarigt_colorram_w(state, address, data >> 16, mem_mask >> 16);
(*state->protection_w)(space, address, data >> 16);
}
if (ACCESSING_BITS_0_15)
{
- if (!ignore_writes)
+ if (!state->ignore_writes)
atarigt_colorram_w(state, address + 2, data, mem_mask);
(*state->protection_w)(space, address + 2, data);
}
diff --git a/src/mame/drivers/atarisy1.c b/src/mame/drivers/atarisy1.c
index df457167287..97bae4198cf 100644
--- a/src/mame/drivers/atarisy1.c
+++ b/src/mame/drivers/atarisy1.c
@@ -313,7 +313,6 @@ static READ16_HANDLER( trakball_r )
/* Marble Madness trackball type -- rotated 45 degrees! */
if (state->trackball_type == 1)
{
- static UINT8 cur[2][2];
int player = (offset >> 1) & 1;
int which = offset & 1;
@@ -333,11 +332,11 @@ static READ16_HANDLER( trakball_r )
posy = (INT8)input_port_read(space->machine, "IN3");
}
- cur[player][0] = posx + posy;
- cur[player][1] = posx - posy;
+ state->cur[player][0] = posx + posy;
+ state->cur[player][1] = posx - posy;
}
- result = cur[player][which];
+ result = state->cur[player][which];
}
/* Road Blasters steering wheel */
diff --git a/src/mame/drivers/atarisy2.c b/src/mame/drivers/atarisy2.c
index 2d1d9b8b7aa..c6859b6c352 100644
--- a/src/mame/drivers/atarisy2.c
+++ b/src/mame/drivers/atarisy2.c
@@ -441,24 +441,21 @@ static READ8_HANDLER( leta_r )
case 1: /* Fake Joystick */
/* special thanks to MAME Analog+ for the mapping code */
{
- static double last_angle;
- static int rotations;
-
int analogx = input_port_read(space->machine, "FAKE_JOY_X") - 128;
int analogy = input_port_read(space->machine, "FAKE_JOY_Y") - 128;
double angle;
/* if the joystick is centered, leave the rest of this alone */
- angle = last_angle;
+ angle = state->joy_last_angle;
if (analogx < -32 || analogx > 32 || analogy < -32 || analogy > 32)
angle = atan2((double)analogx, (double)analogy) * 360 / (2 * M_PI);
/* detect when we pass the 0 point in either direction */
- if (last_angle < -90 && angle > 90)
- rotations--;
- else if (last_angle > 90 && angle < -90)
- rotations++;
- last_angle = angle;
+ if (state->joy_last_angle < -90 && angle > 90)
+ state->joy_rotations--;
+ else if (state->joy_last_angle > 90 && angle < -90)
+ state->joy_rotations++;
+ state->joy_last_angle = angle;
/* make offset 0 return 0xff when the controller blocks one of two gaps */
/* this is not accurate, as a counter should count up/down 2 counts as it passes through each gap */
@@ -476,15 +473,12 @@ static READ8_HANDLER( leta_r )
else
{
/* take the rotations * 144 plus the current angle */
- return (rotations * 144 + (int)(angle * 144.0 / 360.0)) & 0xff;
+ return (state->joy_rotations * 144 + (int)(angle * 144.0 / 360.0)) & 0xff;
}
}
case 2: /* Fake Spinner */
{
- static UINT32 last_rotate_count;
- static INT32 pos; /* track fake position of spinner */
- static UINT32 center_count;
INT32 diff;
UINT32 temp;
UINT32 rotate_count = input_port_read(space->machine, "FAKE_SPINNER") & 0xffff;
@@ -492,26 +486,26 @@ static READ8_HANDLER( leta_r )
* we use it to generate the LETA0 Center encoder count
*/
- if (rotate_count != last_rotate_count)
+ if (rotate_count != state->spin_last_rotate_count)
{
/* see if count rolled between 0xffff and 0x0000 */
- if ((last_rotate_count > 0xc000) && (rotate_count < 0x03ff))
+ if ((state->spin_last_rotate_count > 0xc000) && (rotate_count < 0x03ff))
{
- temp = 0xffff - last_rotate_count;
+ temp = 0xffff - state->spin_last_rotate_count;
diff = rotate_count + temp + 1;
}
- else if ((rotate_count > 0xc000) && (last_rotate_count < 0x03ff))
+ else if ((rotate_count > 0xc000) && (state->spin_last_rotate_count < 0x03ff))
{
temp = 0xffff - rotate_count;
- diff = last_rotate_count - temp - 1;
+ diff = state->spin_last_rotate_count - temp - 1;
}
else
{
- temp = rotate_count - last_rotate_count;
+ temp = rotate_count - state->spin_last_rotate_count;
diff = temp;
}
- last_rotate_count = rotate_count;
+ state->spin_last_rotate_count = rotate_count;
/* you may not like this, but it is the easiest way to accurately fake the center count */
/* diff is never a big number anyways */
@@ -519,17 +513,17 @@ static READ8_HANDLER( leta_r )
{
for (int i = 0; i > diff; i--)
{
- pos--;
- if (pos < 0)
- pos = 143;
+ state->spin_pos--;
+ if (state->spin_pos < 0)
+ state->spin_pos = 143;
else
- switch (pos)
+ switch (state->spin_pos)
{
case 2:
case 3:
case 141:
case 142:
- center_count--;
+ state->spin_center_count--;
}
}
}
@@ -537,24 +531,24 @@ static READ8_HANDLER( leta_r )
{
for (int i = 0; i < diff; i++)
{
- pos++;
- if (pos > 143)
- pos = 0;
+ state->spin_pos++;
+ if (state->spin_pos > 143)
+ state->spin_pos = 0;
else
- switch (pos)
+ switch (state->spin_pos)
{
case 2:
case 3:
case 141:
case 142:
- center_count++;
+ state->spin_center_count++;
}
}
}
}
if (offset == 0)
- return center_count & 0xff;
+ return state->spin_center_count & 0xff;
else
/* offset == 1 */
return rotate_count & 0xff;
diff --git a/src/mame/drivers/atarisy4.c b/src/mame/drivers/atarisy4.c
index fbed06fea6b..72c6098772b 100644
--- a/src/mame/drivers/atarisy4.c
+++ b/src/mame/drivers/atarisy4.c
@@ -20,6 +20,25 @@
#include "video/poly.h"
+class atarisy4_state : public driver_device
+{
+public:
+ atarisy4_state(running_machine &machine, const driver_device_config_base &config)
+ : driver_device(machine, config) { }
+
+ UINT8 r_color_table[256];
+ UINT8 g_color_table[256];
+ UINT8 b_color_table[256];
+ UINT16 dsp_bank[2];
+ UINT8 csr[2];
+ UINT16 *m68k_ram;
+ UINT16 *shared_ram[2];
+ UINT16 *screen_ram;
+ poly_manager *poly;
+};
+
+
+
/*************************************
*
* State
@@ -76,22 +95,14 @@ struct _gpu_
UINT16 clip_max_y;
} gpu;
-static UINT8 r_color_table[256];
-static UINT8 g_color_table[256];
-static UINT8 b_color_table[256];
-static UINT16 dsp_bank[2];
-static UINT8 csr[2];
-static UINT16 *m68k_ram;
-static UINT16 *shared_ram[2];
-static UINT16 *screen_ram;
-static poly_manager *poly;
typedef struct _poly_extra_data poly_extra_data;
struct _poly_extra_data
{
UINT16 color;
+ UINT16 *screen_ram;
};
@@ -114,7 +125,8 @@ static MACHINE_RESET( airrace );
static VIDEO_START( atarisy4 )
{
- poly = poly_alloc(machine, 1024, sizeof(poly_extra_data), POLYFLAG_NO_WORK_QUEUE);
+ atarisy4_state *state = machine->driver_data<atarisy4_state>();
+ state->poly = poly_alloc(machine, 1024, sizeof(poly_extra_data), POLYFLAG_NO_WORK_QUEUE);
}
static VIDEO_RESET( atarisy4 )
@@ -124,6 +136,7 @@ static VIDEO_RESET( atarisy4 )
static VIDEO_UPDATE( atarisy4 )
{
+ atarisy4_state *state = screen->machine->driver_data<atarisy4_state>();
int y;
UINT32 offset = 0;
@@ -140,7 +153,7 @@ static VIDEO_UPDATE( atarisy4 )
for (y = cliprect->min_y; y <= cliprect->max_y; ++y)
{
- UINT16 *src = &screen_ram[(offset + (4096 * y)) / 2];
+ UINT16 *src = &state->screen_ram[(offset + (4096 * y)) / 2];
UINT32 *dest = BITMAP_ADDR32(bitmap, y, cliprect->min_x);
int x;
@@ -172,7 +185,7 @@ static inline UINT32 xy_to_screen_addr(UINT32 x, UINT32 y)
return (y * 4096) + offset + x;
}
-static void image_mem_to_screen(bool clip)
+static void image_mem_to_screen(atarisy4_state *state, bool clip)
{
INT16 y = gpu.gr[1] - 0x200;
UINT16 h = gpu.gr[3];
@@ -195,14 +208,14 @@ static void image_mem_to_screen(bool clip)
{
if (x >= 0 && x <= 511)
{
- UINT16 pix = screen_ram[xy_to_screen_addr(x,y) >> 1];
+ UINT16 pix = state->screen_ram[xy_to_screen_addr(x,y) >> 1];
if (x & 1)
pix = (pix & (0x00ff)) | gpu.idr << 8;
else
pix = (pix & (0xff00)) | gpu.idr;
- screen_ram[xy_to_screen_addr(x,y) >> 1] = pix;
+ state->screen_ram[xy_to_screen_addr(x,y) >> 1] = pix;
}
++x;
}
@@ -220,23 +233,23 @@ static void draw_scanline(void *dest, INT32 scanline, const poly_extent *extent,
for (x = extent->startx; x < extent->stopx; ++x)
{
UINT32 addr = xy_to_screen_addr(x, scanline);
- UINT16 pix = screen_ram[addr >> 1];
+ UINT16 pix = extra->screen_ram[addr >> 1];
if (x & 1)
pix = (pix & (0x00ff)) | color << 8;
else
pix = (pix & (0xff00)) | color;
- screen_ram[addr >> 1] = pix;
+ extra->screen_ram[addr >> 1] = pix;
}
}
-static void draw_polygon(UINT16 color)
+static void draw_polygon(atarisy4_state *state, UINT16 color)
{
int i;
rectangle clip;
poly_vertex v1, v2, v3;
- poly_extra_data *extra = (poly_extra_data *)poly_get_extra_data(poly);
+ poly_extra_data *extra = (poly_extra_data *)poly_get_extra_data(state->poly);
clip.min_x = 0;
clip.min_y = 0;
@@ -244,6 +257,7 @@ static void draw_polygon(UINT16 color)
clip.max_y = 511;
extra->color = color;
+ extra->screen_ram = state->screen_ram;
v1.x = gpu.points[0].x;
v1.y = gpu.points[0].y;
@@ -257,7 +271,7 @@ static void draw_polygon(UINT16 color)
v3.x = gpu.points[i].x;
v3.y = gpu.points[i].y;
- poly_render_triangle(poly, 0, &clip, draw_scanline, 1, &v1, &v2, &v3);
+ poly_render_triangle(state->poly, 0, &clip, draw_scanline, 1, &v1, &v2, &v3);
v2 = v3;
}
}
@@ -292,6 +306,7 @@ static void draw_polygon(UINT16 color)
*/
void execute_gpu_command(running_machine *machine)
{
+ atarisy4_state *state = machine->driver_data<atarisy4_state>();
switch (gpu.ecr)
{
case 0x04:
@@ -344,18 +359,18 @@ void execute_gpu_command(running_machine *machine)
for (i = 0; i < gpu.gr[3]; ++i)
{
- UINT16 val = screen_ram[offset >> 1];
+ UINT16 val = state->screen_ram[offset >> 1];
val >>= (~offset & 1) << 3;
if (gpu.gr[4] & 0x10)
- r_color_table[table_offs] = val;
+ state->r_color_table[table_offs] = val;
if (gpu.gr[4] & 0x20)
- g_color_table[table_offs] = val;
+ state->g_color_table[table_offs] = val;
if (gpu.gr[4] & 0x40)
- b_color_table[table_offs] = val;
+ state->b_color_table[table_offs] = val;
/* Update */
- palette_set_color(machine, table_offs, MAKE_RGB(r_color_table[table_offs], g_color_table[table_offs], b_color_table[table_offs]));
+ palette_set_color(machine, table_offs, MAKE_RGB(state->r_color_table[table_offs], state->g_color_table[table_offs], state->b_color_table[table_offs]));
++table_offs;
++offset;
@@ -365,12 +380,12 @@ void execute_gpu_command(running_machine *machine)
}
case 0x20:
{
- image_mem_to_screen(false);
+ image_mem_to_screen(state, false);
break;
}
case 0x21:
{
- image_mem_to_screen(true);
+ image_mem_to_screen(state, true);
break;
}
case 0x28:
@@ -405,8 +420,8 @@ void execute_gpu_command(running_machine *machine)
}
case 0x2c:
{
- draw_polygon(gpu.gr[2]);
- poly_wait(poly, "Normal");
+ draw_polygon(state, gpu.gr[2]);
+ poly_wait(state->poly, "Normal");
break;
}
default:
@@ -498,98 +513,110 @@ static INTERRUPT_GEN( vblank_int )
static READ16_HANDLER( m68k_shared_0_r )
{
- if (!BIT(csr[0], 3))
- return (shared_ram[0][offset]);
+ atarisy4_state *state = space->machine->driver_data<atarisy4_state>();
+ if (!BIT(state->csr[0], 3))
+ return (state->shared_ram[0][offset]);
else
return 0xffff;
}
static WRITE16_HANDLER( m68k_shared_0_w )
{
- if (!BIT(csr[0], 3))
- COMBINE_DATA(&shared_ram[0][offset]);
+ atarisy4_state *state = space->machine->driver_data<atarisy4_state>();
+ if (!BIT(state->csr[0], 3))
+ COMBINE_DATA(&state->shared_ram[0][offset]);
}
static READ16_HANDLER( m68k_shared_1_r )
{
- if (!BIT(csr[1], 3))
- return (shared_ram[1][offset]);
+ atarisy4_state *state = space->machine->driver_data<atarisy4_state>();
+ if (!BIT(state->csr[1], 3))
+ return (state->shared_ram[1][offset]);
else
return 0xffff;
}
static WRITE16_HANDLER( m68k_shared_1_w )
{
- if (!BIT(csr[1], 3))
- COMBINE_DATA(&shared_ram[1][offset]);
+ atarisy4_state *state = space->machine->driver_data<atarisy4_state>();
+ if (!BIT(state->csr[1], 3))
+ COMBINE_DATA(&state->shared_ram[1][offset]);
}
static READ16_HANDLER( dsp0_status_r )
{
- return csr[0];
+ atarisy4_state *state = space->machine->driver_data<atarisy4_state>();
+ return state->csr[0];
}
static WRITE16_HANDLER( dsp0_control_w )
{
+ atarisy4_state *state = space->machine->driver_data<atarisy4_state>();
cputag_set_input_line(space->machine, "dsp0", INPUT_LINE_RESET, data & 0x01 ? CLEAR_LINE : ASSERT_LINE);
cputag_set_input_line(space->machine, "dsp0", 0, data & 0x02 ? ASSERT_LINE : CLEAR_LINE);
- csr[0] = data;
+ state->csr[0] = data;
}
static READ16_HANDLER( dsp0_bio_r )
{
- return BIT(csr[0], 2);
+ atarisy4_state *state = space->machine->driver_data<atarisy4_state>();
+ return BIT(state->csr[0], 2);
}
static WRITE16_HANDLER( dsp0_bank_w )
{
+ atarisy4_state *state = space->machine->driver_data<atarisy4_state>();
if (data & 0x4000)
{
/* Set TIDONE bit */
- csr[0] |= 0x10;
+ state->csr[0] |= 0x10;
- if (BIT(csr[0], 5) == 1)
+ if (BIT(state->csr[0], 5) == 1)
fatalerror("68000 interrupt enable was set!");
}
data &= 0x3800;
- memory_set_bankptr(space->machine, "dsp0_bank1", &shared_ram[0][data]);
- dsp_bank[0] = data;
+ memory_set_bankptr(space->machine, "dsp0_bank1", &state->shared_ram[0][data]);
+ state->dsp_bank[0] = data;
}
static READ16_HANDLER( dsp1_status_r )
{
- return csr[1];
+ atarisy4_state *state = space->machine->driver_data<atarisy4_state>();
+ return state->csr[1];
}
static WRITE16_HANDLER( dsp1_control_w )
{
+ atarisy4_state *state = space->machine->driver_data<atarisy4_state>();
cputag_set_input_line(space->machine, "dsp1", INPUT_LINE_RESET, data & 0x01 ? CLEAR_LINE : ASSERT_LINE);
cputag_set_input_line(space->machine, "dsp1", 0, data & 0x02 ? ASSERT_LINE : CLEAR_LINE);
- csr[1] = data;
+ state->csr[1] = data;
}
static READ16_HANDLER( dsp1_bio_r )
{
- return BIT(csr[1], 2);
+ atarisy4_state *state = space->machine->driver_data<atarisy4_state>();
+ return BIT(state->csr[1], 2);
}
static WRITE16_HANDLER( dsp1_bank_w )
{
+ atarisy4_state *state = space->machine->driver_data<atarisy4_state>();
if (data & 0x4000)
{
/* Set TIDONE bit */
- csr[1] |= 0x10;
+ state->csr[1] |= 0x10;
- if (BIT(csr[1], 5) == 1)
+ if (BIT(state->csr[1], 5) == 1)
fatalerror("68000 interrupt enable was set!");
}
data &= 0x3800;
- memory_set_bankptr(space->machine, "dsp1_bank1", &shared_ram[1][data]);
- dsp_bank[1] = data;
+ memory_set_bankptr(space->machine, "dsp1_bank1", &state->shared_ram[1][data]);
+ state->dsp_bank[1] = data;
}
@@ -600,7 +627,7 @@ static WRITE16_HANDLER( dsp1_bank_w )
*************************************/
static ADDRESS_MAP_START( main_map, ADDRESS_SPACE_PROGRAM, 16 )
- AM_RANGE(0x000000, 0x00ffff) AM_RAM AM_BASE(&m68k_ram)
+ AM_RANGE(0x000000, 0x00ffff) AM_RAM AM_BASE_MEMBER(atarisy4_state, m68k_ram)
AM_RANGE(0x010000, 0x01ffff) AM_RAM
AM_RANGE(0x580000, 0x580001) AM_READ_PORT("JOYSTICK")
AM_RANGE(0x588000, 0x588001) AM_READ(analog_r)
@@ -609,7 +636,7 @@ static ADDRESS_MAP_START( main_map, ADDRESS_SPACE_PROGRAM, 16 )
AM_RANGE(0x7c6000, 0x7c6001) AM_READWRITE(dsp1_status_r, dsp1_control_w)
AM_RANGE(0x7f0000, 0x7f4fff) AM_READWRITE(m68k_shared_0_r, m68k_shared_0_w)
AM_RANGE(0x7f6000, 0x7f6001) AM_READWRITE(dsp0_status_r, dsp0_control_w)
- AM_RANGE(0xa00400, 0xbfffff) AM_RAM AM_BASE(&screen_ram)
+ AM_RANGE(0xa00400, 0xbfffff) AM_RAM AM_BASE_MEMBER(atarisy4_state, screen_ram)
AM_RANGE(0xff8000, 0xff8fff) AM_READWRITE(gpu_r, gpu_w)
ADDRESS_MAP_END
@@ -694,7 +721,7 @@ INPUT_PORTS_END
*
*************************************/
-static MACHINE_CONFIG_START( atarisy4, driver_device )
+static MACHINE_CONFIG_START( atarisy4, atarisy4_state )
MCFG_CPU_ADD("maincpu", M68000, 8000000)
MCFG_CPU_PROGRAM_MAP(main_map)
MCFG_CPU_VBLANK_INT("screen", vblank_int)
@@ -934,38 +961,40 @@ next_line:
static DRIVER_INIT( laststar )
{
+ atarisy4_state *state = machine->driver_data<atarisy4_state>();
address_space *main = cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM);
/* Allocate 16kB of shared RAM */
- shared_ram[0] = auto_alloc_array_clear(machine, UINT16, 0x2000);
+ state->shared_ram[0] = auto_alloc_array_clear(machine, UINT16, 0x2000);
/* Populate the 68000 address space with data from the HEX files */
load_hexfile(main, machine->region("code")->base());
load_hexfile(main, machine->region("data")->base());
/* Set up the DSP */
- memory_set_bankptr(machine, "dsp0_bank0", shared_ram[0]);
- memory_set_bankptr(machine, "dsp0_bank1", &shared_ram[0][0x800]);
+ memory_set_bankptr(machine, "dsp0_bank0", state->shared_ram[0]);
+ memory_set_bankptr(machine, "dsp0_bank1", &state->shared_ram[0][0x800]);
load_ldafile(cputag_get_address_space(machine, "dsp0", ADDRESS_SPACE_PROGRAM), machine->region("dsp")->base());
}
static DRIVER_INIT( airrace )
{
+ atarisy4_state *state = machine->driver_data<atarisy4_state>();
/* Allocate two sets of 32kB shared RAM */
- shared_ram[0] = auto_alloc_array_clear(machine, UINT16, 0x4000);
- shared_ram[1] = auto_alloc_array_clear(machine, UINT16, 0x4000);
+ state->shared_ram[0] = auto_alloc_array_clear(machine, UINT16, 0x4000);
+ state->shared_ram[1] = auto_alloc_array_clear(machine, UINT16, 0x4000);
/* Populate RAM with data from the HEX files */
load_hexfile(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), machine->region("code")->base());
/* Set up the first DSP */
- memory_set_bankptr(machine, "dsp0_bank0", shared_ram[0]);
- memory_set_bankptr(machine, "dsp0_bank1", &shared_ram[0][0x800]);
+ memory_set_bankptr(machine, "dsp0_bank0", state->shared_ram[0]);
+ memory_set_bankptr(machine, "dsp0_bank1", &state->shared_ram[0][0x800]);
load_ldafile(cputag_get_address_space(machine, "dsp0", ADDRESS_SPACE_PROGRAM), machine->region("dsp")->base());
/* Set up the second DSP */
- memory_set_bankptr(machine, "dsp1_bank0", shared_ram[1]);
- memory_set_bankptr(machine, "dsp1_bank1", &shared_ram[1][0x800]);
+ memory_set_bankptr(machine, "dsp1_bank0", state->shared_ram[1]);
+ memory_set_bankptr(machine, "dsp1_bank1", &state->shared_ram[1][0x800]);
load_ldafile(cputag_get_address_space(machine, "dsp1", ADDRESS_SPACE_PROGRAM), machine->region("dsp")->base());
}
diff --git a/src/mame/drivers/atetris.c b/src/mame/drivers/atetris.c
index 2beffb47f8f..26ebc86d783 100644
--- a/src/mame/drivers/atetris.c
+++ b/src/mame/drivers/atetris.c
@@ -60,15 +60,6 @@
#define BOOTLEG_CLOCK XTAL_14_7456MHz
-/* Local variables */
-static UINT8 *slapstic_source;
-static UINT8 *slapstic_base;
-static UINT8 current_bank;
-static UINT8 nvram_write_enable;
-static emu_timer *interrupt_timer;
-
-
-
/*************************************
*
* Interrupt generation
@@ -77,6 +68,7 @@ static emu_timer *interrupt_timer;
static TIMER_CALLBACK( interrupt_gen )
{
+ atetris_state *state = machine->driver_data<atetris_state>();
int scanline = param;
/* assert/deassert the interrupt */
@@ -86,7 +78,7 @@ static TIMER_CALLBACK( interrupt_gen )
scanline += 32;
if (scanline >= 256)
scanline -= 256;
- timer_adjust_oneshot(interrupt_timer, machine->primary_screen->time_until_pos(scanline), scanline);
+ timer_adjust_oneshot(state->interrupt_timer, machine->primary_screen->time_until_pos(scanline), scanline);
}
@@ -103,39 +95,45 @@ static WRITE8_HANDLER( irq_ack_w )
*
*************************************/
-static void reset_bank(void)
+static void reset_bank(running_machine *machine)
{
- memcpy(slapstic_base, &slapstic_source[current_bank * 0x4000], 0x4000);
+ atetris_state *state = machine->driver_data<atetris_state>();
+
+ memcpy(state->slapstic_base, &state->slapstic_source[state->current_bank * 0x4000], 0x4000);
}
static STATE_POSTLOAD( atetris_postload )
{
- reset_bank();
+ reset_bank(machine);
}
static MACHINE_START( atetris )
{
+ atetris_state *state = machine->driver_data<atetris_state>();
+
/* Allocate interrupt timer */
- interrupt_timer = timer_alloc(machine, interrupt_gen, NULL);
+ state->interrupt_timer = timer_alloc(machine, interrupt_gen, NULL);
/* Set up save state */
- state_save_register_global(machine, current_bank);
- state_save_register_global(machine, nvram_write_enable);
+ state_save_register_global(machine, state->current_bank);
+ state_save_register_global(machine, state->nvram_write_enable);
state_save_register_postload(machine, atetris_postload, NULL);
}
static MACHINE_RESET( atetris )
{
+ atetris_state *state = machine->driver_data<atetris_state>();
+
/* reset the slapstic */
slapstic_reset();
- current_bank = slapstic_bank() & 1;
- reset_bank();
+ state->current_bank = slapstic_bank() & 1;
+ reset_bank(machine);
/* start interrupts going (32V clocked by 16V) */
- timer_adjust_oneshot(interrupt_timer, machine->primary_screen->time_until_pos(48), 48);
+ timer_adjust_oneshot(state->interrupt_timer, machine->primary_screen->time_until_pos(48), 48);
}
@@ -148,14 +146,15 @@ static MACHINE_RESET( atetris )
static READ8_HANDLER( atetris_slapstic_r )
{
- int result = slapstic_base[0x2000 + offset];
+ atetris_state *state = space->machine->driver_data<atetris_state>();
+ int result = state->slapstic_base[0x2000 + offset];
int new_bank = slapstic_tweak(space, offset) & 1;
/* update for the new bank */
- if (new_bank != current_bank)
+ if (new_bank != state->current_bank)
{
- current_bank = new_bank;
- memcpy(slapstic_base, &slapstic_source[current_bank * 0x4000], 0x4000);
+ state->current_bank = new_bank;
+ memcpy(state->slapstic_base, &state->slapstic_source[state->current_bank * 0x4000], 0x4000);
}
return result;
}
@@ -185,15 +184,18 @@ static WRITE8_HANDLER( coincount_w )
static WRITE8_HANDLER( nvram_w )
{
atetris_state *state = space->machine->driver_data<atetris_state>();
- if (nvram_write_enable)
+
+ if (state->nvram_write_enable)
state->m_nvram[offset] = data;
- nvram_write_enable = 0;
+ state->nvram_write_enable = 0;
}
static WRITE8_HANDLER( nvram_enable_w )
{
- nvram_write_enable = 1;
+ atetris_state *state = space->machine->driver_data<atetris_state>();
+
+ state->nvram_write_enable = 1;
}
@@ -494,10 +496,12 @@ ROM_END
static DRIVER_INIT( atetris )
{
+ atetris_state *state = machine->driver_data<atetris_state>();
UINT8 *rgn = machine->region("maincpu")->base();
+
slapstic_init(machine, 101);
- slapstic_source = &rgn[0x10000];
- slapstic_base = &rgn[0x04000];
+ state->slapstic_source = &rgn[0x10000];
+ state->slapstic_base = &rgn[0x04000];
}
diff --git a/src/mame/drivers/bwidow.c b/src/mame/drivers/bwidow.c
index 123d5ed9831..b352ee3c18b 100644
--- a/src/mame/drivers/bwidow.c
+++ b/src/mame/drivers/bwidow.c
@@ -223,6 +223,17 @@
#include "machine/atari_vg.h"
#include "sound/pokey.h"
+
+class bwidow_state : public driver_device
+{
+public:
+ bwidow_state(running_machine &machine, const driver_device_config_base &config)
+ : driver_device(machine, config) { }
+
+ int lastdata;
+};
+
+
#define MASTER_CLOCK (12096000)
#define CLOCK_3KHZ (MASTER_CLOCK / 4096)
@@ -317,20 +328,20 @@ static CUSTOM_INPUT( clock_r )
static WRITE8_HANDLER( bwidow_misc_w )
{
+ bwidow_state *state = space->machine->driver_data<bwidow_state>();
/*
0x10 = p1 led
0x20 = p2 led
0x01 = coin counter 1
0x02 = coin counter 2
*/
- static int lastdata;
- if (data == lastdata) return;
+ if (data == state->lastdata) return;
set_led_status(space->machine, 0,~data & 0x10);
set_led_status(space->machine, 1,~data & 0x20);
coin_counter_w(space->machine, 0, data & 0x01);
coin_counter_w(space->machine, 1, data & 0x02);
- lastdata = data;
+ state->lastdata = data;
}
/*************************************
@@ -709,7 +720,7 @@ static const pokey_interface pokey_interface_2 =
*
*************************************/
-static MACHINE_CONFIG_START( bwidow, driver_device )
+static MACHINE_CONFIG_START( bwidow, bwidow_state )
/* basic machine hardware */
MCFG_CPU_ADD("maincpu", M6502, MASTER_CLOCK / 8)
diff --git a/src/mame/drivers/centiped.c b/src/mame/drivers/centiped.c
index 792533399f6..a7ee90e4509 100644
--- a/src/mame/drivers/centiped.c
+++ b/src/mame/drivers/centiped.c
@@ -434,13 +434,6 @@ each direction to assign the boundries.
#include "sound/sn76496.h"
#include "sound/pokey.h"
-
-static UINT8 oldpos[4];
-static UINT8 sign[4];
-static UINT8 dsw_select, control_select;
-static UINT8 *rambase;
-
-
/*************************************
*
* Interrupts
@@ -462,26 +455,32 @@ static TIMER_DEVICE_CALLBACK( generate_interrupt )
static MACHINE_START( centiped )
{
- state_save_register_global_array(machine, oldpos);
- state_save_register_global_array(machine, sign);
- state_save_register_global(machine, dsw_select);
+ centiped_state *state = machine->driver_data<centiped_state>();
+
+ state_save_register_global_array(machine, state->oldpos);
+ state_save_register_global_array(machine, state->sign);
+ state_save_register_global(machine, state->dsw_select);
}
static MACHINE_RESET( centiped )
{
+ centiped_state *state = machine->driver_data<centiped_state>();
+
cputag_set_input_line(machine, "maincpu", 0, CLEAR_LINE);
- dsw_select = 0;
- control_select = 0;
+ state->dsw_select = 0;
+ state->control_select = 0;
}
static MACHINE_RESET( magworm )
{
+ centiped_state *state = machine->driver_data<centiped_state>();
+
MACHINE_RESET_CALL(centiped);
/* kludge: clear RAM so that magworm can be reset cleanly */
- memset(rambase, 0, 0x400);
+ memset(state->rambase, 0, 0x400);
}
@@ -518,28 +517,29 @@ static WRITE8_HANDLER( irq_ack_w )
INLINE int read_trackball(running_machine *machine, int idx, int switch_port)
{
+ centiped_state *state = machine->driver_data<centiped_state>();
UINT8 newpos;
static const char *const portnames[] = { "IN0", "IN1", "IN2" };
static const char *const tracknames[] = { "TRACK0_X", "TRACK0_Y", "TRACK1_X", "TRACK1_Y" };
/* adjust idx if we're cocktail flipped */
- if (centiped_flipscreen)
+ if (state->flipscreen)
idx += 2;
/* if we're to read the dipswitches behind the trackball data, do it now */
- if (dsw_select)
- return (input_port_read(machine, portnames[switch_port]) & 0x7f) | sign[idx];
+ if (state->dsw_select)
+ return (input_port_read(machine, portnames[switch_port]) & 0x7f) | state->sign[idx];
/* get the new position and adjust the result */
newpos = input_port_read(machine, tracknames[idx]);
- if (newpos != oldpos[idx])
+ if (newpos != state->oldpos[idx])
{
- sign[idx] = (newpos - oldpos[idx]) & 0x80;
- oldpos[idx] = newpos;
+ state->sign[idx] = (newpos - state->oldpos[idx]) & 0x80;
+ state->oldpos[idx] = newpos;
}
/* blend with the bits from the switch port */
- return (input_port_read(machine, portnames[switch_port]) & 0x70) | (oldpos[idx] & 0x0f) | sign[idx];
+ return (input_port_read(machine, portnames[switch_port]) & 0x70) | (state->oldpos[idx] & 0x0f) | state->sign[idx];
}
@@ -562,6 +562,7 @@ static READ8_HANDLER( milliped_IN1_r )
static READ8_HANDLER( milliped_IN2_r )
{
+ centiped_state *state = space->machine->driver_data<centiped_state>();
UINT8 data = input_port_read(space->machine, "IN2");
/* MSH - 15 Feb, 2007
@@ -571,7 +572,7 @@ static READ8_HANDLER( milliped_IN2_r )
* the inputs, and has the good side effect of disabling
* the actual Joy1 inputs while control_select is no zero.
*/
- if (0 != control_select) {
+ if (0 != state->control_select) {
/* Bottom 4 bits is our joystick inputs */
UINT8 joy2data = input_port_read(space->machine, "IN3") & 0x0f;
data = data & 0xf0; /* Keep the top 4 bits */
@@ -583,27 +584,34 @@ static READ8_HANDLER( milliped_IN2_r )
static WRITE8_HANDLER( input_select_w )
{
- dsw_select = (~data >> 7) & 1;
+ centiped_state *state = space->machine->driver_data<centiped_state>();
+
+ state->dsw_select = (~data >> 7) & 1;
}
/* used P2 controls if 1, P1 controls if 0 */
static WRITE8_HANDLER( control_select_w )
{
- control_select = (data >> 7) & 1;
+ centiped_state *state = space->machine->driver_data<centiped_state>();
+
+ state->control_select = (data >> 7) & 1;
}
static READ8_HANDLER( mazeinv_input_r )
{
+ centiped_state *state = space->machine->driver_data<centiped_state>();
static const char *const sticknames[] = { "STICK0", "STICK1", "STICK2", "STICK3" };
- return input_port_read(space->machine, sticknames[control_select]);
+ return input_port_read(space->machine, sticknames[state->control_select]);
}
static WRITE8_HANDLER( mazeinv_input_select_w )
{
- control_select = offset & 3;
+ centiped_state *state = space->machine->driver_data<centiped_state>();
+
+ state->control_select = offset & 3;
}
static READ8_HANDLER( bullsdrt_data_port_r )
@@ -680,7 +688,7 @@ static READ8_DEVICE_HANDLER( caterplr_AY8910_r )
static ADDRESS_MAP_START( centiped_map, ADDRESS_SPACE_PROGRAM, 8 )
ADDRESS_MAP_GLOBAL_MASK(0x3fff)
- AM_RANGE(0x0000, 0x03ff) AM_RAM AM_BASE(&rambase)
+ AM_RANGE(0x0000, 0x03ff) AM_RAM AM_BASE_MEMBER(centiped_state, rambase)
AM_RANGE(0x0400, 0x07bf) AM_RAM_WRITE(centiped_videoram_w) AM_BASE_MEMBER(centiped_state, videoram)
AM_RANGE(0x07c0, 0x07ff) AM_RAM AM_BASE_GENERIC(spriteram)
AM_RANGE(0x0800, 0x0800) AM_READ_PORT("DSW1") /* DSW1 */
@@ -854,7 +862,7 @@ ADDRESS_MAP_END
static ADDRESS_MAP_START( bullsdrt_port_map, ADDRESS_SPACE_IO, 8 )
AM_RANGE(0x00, 0x00) AM_WRITE(bullsdrt_sprites_bank_w)
- AM_RANGE(0x20, 0x3f) AM_WRITE(bullsdrt_tilesbank_w) AM_BASE(&bullsdrt_tiles_bankram)
+ AM_RANGE(0x20, 0x3f) AM_WRITE(bullsdrt_tilesbank_w) AM_BASE_MEMBER(centiped_state, bullsdrt_tiles_bankram)
AM_RANGE(S2650_DATA_PORT, S2650_DATA_PORT) AM_READ(bullsdrt_data_port_r) AM_DEVWRITE("snsnd", sn76496_w)
ADDRESS_MAP_END
@@ -1992,7 +2000,9 @@ static DRIVER_INIT( magworm )
static DRIVER_INIT( bullsdrt )
{
- dsw_select = 0;
+ centiped_state *state = machine->driver_data<centiped_state>();
+
+ state->dsw_select = 0;
}
diff --git a/src/mame/drivers/cloak.c b/src/mame/drivers/cloak.c
index acfbc09df58..de882ec7ca2 100644
--- a/src/mame/drivers/cloak.c
+++ b/src/mame/drivers/cloak.c
@@ -121,8 +121,6 @@
#include "machine/nvram.h"
#include "includes/cloak.h"
-static int cloak_nvram_enabled;
-
/*************************************
*
* Output ports
@@ -155,7 +153,8 @@ static WRITE8_HANDLER( cloak_irq_reset_1_w )
static WRITE8_HANDLER( cloak_nvram_enable_w )
{
- cloak_nvram_enabled = data & 0x01;
+ cloak_state *state = space->machine->driver_data<cloak_state>();
+ state->nvram_enabled = data & 0x01;
}
@@ -178,7 +177,7 @@ static ADDRESS_MAP_START( master_map, ADDRESS_SPACE_PROGRAM, 8 )
AM_RANGE(0x2600, 0x2600) AM_WRITE(cloak_custom_w)
AM_RANGE(0x2800, 0x29ff) AM_RAM AM_SHARE("nvram")
AM_RANGE(0x2f00, 0x2fff) AM_NOP
- AM_RANGE(0x3000, 0x30ff) AM_RAM AM_BASE_SIZE_GENERIC(spriteram)
+ AM_RANGE(0x3000, 0x30ff) AM_RAM AM_BASE_MEMBER(cloak_state, spriteram)
AM_RANGE(0x3200, 0x327f) AM_WRITE(cloak_paletteram_w)
AM_RANGE(0x3800, 0x3801) AM_WRITE(cloak_coin_counter_w)
AM_RANGE(0x3803, 0x3803) AM_WRITE(cloak_flipscreen_w)
diff --git a/src/mame/drivers/cmmb.c b/src/mame/drivers/cmmb.c
index 979a8ef3bb4..2503ae391eb 100644
--- a/src/mame/drivers/cmmb.c
+++ b/src/mame/drivers/cmmb.c
@@ -49,6 +49,7 @@ public:
: driver_device(machine, config) { }
UINT8 *videoram;
+ UINT8 irq_mask;
};
@@ -123,7 +124,6 @@ static READ8_HANDLER( cmmb_input_r )
return 0xff;
}
-static UINT8 irq_mask;
/*
{
@@ -137,6 +137,7 @@ static UINT8 irq_mask;
static WRITE8_HANDLER( cmmb_output_w )
{
+ cmmb_state *state = space->machine->driver_data<cmmb_state>();
//printf("%02x -> [%02x] W\n",data,offset);
switch(offset)
{
@@ -150,7 +151,7 @@ static WRITE8_HANDLER( cmmb_output_w )
}
break;
case 0x03:
- irq_mask = data & 0x80;
+ state->irq_mask = data & 0x80;
break;
case 0x07:
break;
diff --git a/src/mame/drivers/cojag.c b/src/mame/drivers/cojag.c
index ab633995840..c82dea4944c 100644
--- a/src/mame/drivers/cojag.c
+++ b/src/mame/drivers/cojag.c
@@ -311,6 +311,18 @@ public:
m_nvram(*this, "nvram") { }
required_shared_ptr<UINT32> m_nvram;
+ cpu_device *main_cpu;
+ UINT32 misc_control_data;
+ UINT8 eeprom_enable;
+ UINT32 *rom_base;
+ UINT32 *gpu_jump_address;
+ UINT8 gpu_command_pending;
+ UINT32 gpu_spin_pc;
+ UINT32 *main_speedup;
+ int main_speedup_hits;
+ UINT64 main_speedup_last_cycles;
+ UINT64 main_speedup_max_cycles;
+ UINT32 *main_gpu_wait;
};
@@ -336,12 +348,8 @@ UINT8 cojag_is_r3000;
*
*************************************/
-static cpu_device *main_cpu;
-static UINT32 misc_control_data;
-static UINT8 eeprom_enable;
-static UINT32 *rom_base;
@@ -353,11 +361,12 @@ static UINT32 *rom_base;
static MACHINE_RESET( cojag )
{
+ cojag_state *state = machine->driver_data<cojag_state>();
UINT8 *rom = machine->region("user2")->base();
/* 68020 only: copy the interrupt vectors into RAM */
if (!cojag_is_r3000)
- memcpy(jaguar_shared_ram, rom_base, 0x10);
+ memcpy(jaguar_shared_ram, state->rom_base, 0x10);
/* configure banks for gfx/sound ROMs */
if (rom)
@@ -400,6 +409,7 @@ static MACHINE_RESET( cojag )
static READ32_HANDLER( misc_control_r )
{
+ cojag_state *state = space->machine->driver_data<cojag_state>();
/* D7 = board reset (low)
D6 = audio must & reset (high)
D5 = volume control data (invert on write)
@@ -407,12 +417,13 @@ static READ32_HANDLER( misc_control_r )
D3-D1 = audio bank 2-0
D0 = shared memory select (0=XBUS) */
- return misc_control_data ^ 0x20;
+ return state->misc_control_data ^ 0x20;
}
static WRITE32_HANDLER( misc_control_w )
{
+ cojag_state *state = space->machine->driver_data<cojag_state>();
logerror("%08X:misc_control_w(%02X)\n", cpu_get_previouspc(space->cpu), data);
/* D7 = board reset (low)
@@ -441,7 +452,7 @@ static WRITE32_HANDLER( misc_control_w )
memory_set_bank(space->machine, "bank9", (data >> 1) & 7);
}
- COMBINE_DATA(&misc_control_data);
+ COMBINE_DATA(&state->misc_control_data);
}
@@ -529,15 +540,16 @@ static READ32_HANDLER( eeprom_data_r )
static WRITE32_HANDLER( eeprom_enable_w )
{
- eeprom_enable = 1;
+ cojag_state *state = space->machine->driver_data<cojag_state>();
+ state->eeprom_enable = 1;
}
static WRITE32_HANDLER( eeprom_data_w )
{
-// if (eeprom_enable)
+ cojag_state *state = space->machine->driver_data<cojag_state>();
+// if (state->eeprom_enable)
{
- cojag_state *state = space->machine->driver_data<cojag_state>();
if (cojag_is_r3000)
state->m_nvram[offset] = data & 0x000000ff;
else
@@ -545,7 +557,7 @@ static WRITE32_HANDLER( eeprom_data_w )
}
// else
// logerror("%08X:error writing to disabled EEPROM\n", cpu_get_previouspc(space->cpu));
- eeprom_enable = 0;
+ state->eeprom_enable = 0;
}
@@ -577,38 +589,38 @@ static WRITE32_HANDLER( eeprom_data_w )
run it until we get back to the spin loop.
*/
-static UINT32 *gpu_jump_address;
-static UINT8 gpu_command_pending;
-static UINT32 gpu_spin_pc;
static TIMER_CALLBACK( gpu_sync_timer )
{
+ cojag_state *state = machine->driver_data<cojag_state>();
/* if a command is still pending, and we haven't maxed out our timer, set a new one */
- if (gpu_command_pending && param < 1000)
+ if (state->gpu_command_pending && param < 1000)
timer_set(machine, ATTOTIME_IN_USEC(50), NULL, ++param, gpu_sync_timer);
}
static WRITE32_HANDLER( gpu_jump_w )
{
+ cojag_state *state = space->machine->driver_data<cojag_state>();
/* update the data in memory */
- COMBINE_DATA(gpu_jump_address);
- logerror("%08X:GPU jump address = %08X\n", cpu_get_previouspc(space->cpu), *gpu_jump_address);
+ COMBINE_DATA(state->gpu_jump_address);
+ logerror("%08X:GPU jump address = %08X\n", cpu_get_previouspc(space->cpu), *state->gpu_jump_address);
/* if the GPU is suspended, release it now */
jaguar_gpu_resume(space->machine);
/* start the sync timer going, and note that there is a command pending */
timer_call_after_resynch(space->machine, NULL, 0, gpu_sync_timer);
- gpu_command_pending = 1;
+ state->gpu_command_pending = 1;
}
static READ32_HANDLER( gpu_jump_r )
{
+ cojag_state *state = space->machine->driver_data<cojag_state>();
/* if the current GPU command is just pointing back to the spin loop, and */
/* we're reading it from the spin loop, we can optimize */
- if (*gpu_jump_address == gpu_spin_pc && cpu_get_previouspc(space->cpu) == gpu_spin_pc)
+ if (*state->gpu_jump_address == state->gpu_spin_pc && cpu_get_previouspc(space->cpu) == state->gpu_spin_pc)
{
#if ENABLE_SPEEDUP_HACKS
/* spin if we're allowed */
@@ -616,11 +628,11 @@ static READ32_HANDLER( gpu_jump_r )
#endif
/* no command is pending */
- gpu_command_pending = 0;
+ state->gpu_command_pending = 0;
}
/* return the current value */
- return *gpu_jump_address;
+ return *state->gpu_jump_address;
}
@@ -644,35 +656,32 @@ static READ32_HANDLER( gpu_jump_r )
#if ENABLE_SPEEDUP_HACKS
-static UINT32 *main_speedup;
-static int main_speedup_hits;
-static UINT64 main_speedup_last_cycles;
-static UINT64 main_speedup_max_cycles;
static READ32_HANDLER( cojagr3k_main_speedup_r )
{
- UINT64 curcycles = main_cpu->total_cycles();
+ cojag_state *state = space->machine->driver_data<cojag_state>();
+ UINT64 curcycles = state->main_cpu->total_cycles();
/* if it's been less than main_speedup_max_cycles cycles since the last time */
- if (curcycles - main_speedup_last_cycles < main_speedup_max_cycles)
+ if (curcycles - state->main_speedup_last_cycles < state->main_speedup_max_cycles)
{
/* increment the count; if we hit 5, we can spin until an interrupt comes */
- if (main_speedup_hits++ > 5)
+ if (state->main_speedup_hits++ > 5)
{
cpu_spinuntil_int(space->cpu);
- main_speedup_hits = 0;
+ state->main_speedup_hits = 0;
}
}
/* if it's been more than main_speedup_max_cycles cycles, reset our count */
else
- main_speedup_hits = 0;
+ state->main_speedup_hits = 0;
/* remember the last cycle count */
- main_speedup_last_cycles = curcycles;
+ state->main_speedup_last_cycles = curcycles;
/* return the real value */
- return *main_speedup;
+ return *state->main_speedup;
}
#endif
@@ -696,13 +705,13 @@ static READ32_HANDLER( cojagr3k_main_speedup_r )
#if ENABLE_SPEEDUP_HACKS
-static UINT32 *main_gpu_wait;
static READ32_HANDLER( main_gpu_wait_r )
{
- if (gpu_command_pending)
+ cojag_state *state = space->machine->driver_data<cojag_state>();
+ if (state->gpu_command_pending)
cpu_spinuntil_int(space->cpu);
- return *main_gpu_wait;
+ return *state->main_gpu_wait;
}
#endif
@@ -726,28 +735,29 @@ static READ32_HANDLER( main_gpu_wait_r )
static WRITE32_HANDLER( area51_main_speedup_w )
{
- UINT64 curcycles = main_cpu->total_cycles();
+ cojag_state *state = space->machine->driver_data<cojag_state>();
+ UINT64 curcycles = state->main_cpu->total_cycles();
/* store the data */
- COMBINE_DATA(main_speedup);
+ COMBINE_DATA(state->main_speedup);
/* if it's been less than 400 cycles since the last time */
- if (*main_speedup == 0 && curcycles - main_speedup_last_cycles < 400)
+ if (*state->main_speedup == 0 && curcycles - state->main_speedup_last_cycles < 400)
{
/* increment the count; if we hit 5, we can spin until an interrupt comes */
- if (main_speedup_hits++ > 5)
+ if (state->main_speedup_hits++ > 5)
{
cpu_spinuntil_int(space->cpu);
- main_speedup_hits = 0;
+ state->main_speedup_hits = 0;
}
}
/* if it's been more than 400 cycles, reset our count */
else
- main_speedup_hits = 0;
+ state->main_speedup_hits = 0;
/* remember the last cycle count */
- main_speedup_last_cycles = curcycles;
+ state->main_speedup_last_cycles = curcycles;
}
@@ -760,28 +770,29 @@ static WRITE32_HANDLER( area51_main_speedup_w )
static WRITE32_HANDLER( area51mx_main_speedup_w )
{
- UINT64 curcycles = main_cpu->total_cycles();
+ cojag_state *state = space->machine->driver_data<cojag_state>();
+ UINT64 curcycles = state->main_cpu->total_cycles();
/* store the data */
- COMBINE_DATA(&main_speedup[offset]);
+ COMBINE_DATA(&state->main_speedup[offset]);
/* if it's been less than 450 cycles since the last time */
- if (((main_speedup[0] << 16) | (main_speedup[1] >> 16)) == 0 && curcycles - main_speedup_last_cycles < 450)
+ if (((state->main_speedup[0] << 16) | (state->main_speedup[1] >> 16)) == 0 && curcycles - state->main_speedup_last_cycles < 450)
{
/* increment the count; if we hit 5, we can spin until an interrupt comes */
- if (main_speedup_hits++ > 10)
+ if (state->main_speedup_hits++ > 10)
{
cpu_spinuntil_int(space->cpu);
- main_speedup_hits = 0;
+ state->main_speedup_hits = 0;
}
}
/* if it's been more than 450 cycles, reset our count */
else
- main_speedup_hits = 0;
+ state->main_speedup_hits = 0;
/* remember the last cycle count */
- main_speedup_last_cycles = curcycles;
+ state->main_speedup_last_cycles = curcycles;
}
#endif
@@ -819,13 +830,13 @@ static ADDRESS_MAP_START( r3000_map, ADDRESS_SPACE_PROGRAM, 32 )
AM_RANGE(0x14000004, 0x14000007) AM_WRITE(watchdog_reset32_w)
AM_RANGE(0x16000000, 0x16000003) AM_WRITE(eeprom_enable_w)
AM_RANGE(0x18000000, 0x18001fff) AM_READWRITE(eeprom_data_r, eeprom_data_w) AM_SHARE("nvram")
- AM_RANGE(0x1fc00000, 0x1fdfffff) AM_ROM AM_REGION("user1", 0) AM_BASE(&rom_base)
+ AM_RANGE(0x1fc00000, 0x1fdfffff) AM_ROM AM_REGION("user1", 0) AM_BASE_MEMBER(cojag_state, rom_base)
ADDRESS_MAP_END
static ADDRESS_MAP_START( m68020_map, ADDRESS_SPACE_PROGRAM, 32 )
AM_RANGE(0x000000, 0x7fffff) AM_RAM AM_BASE(&jaguar_shared_ram) AM_SHARE("share1")
- AM_RANGE(0x800000, 0x9fffff) AM_ROM AM_REGION("user1", 0) AM_BASE(&rom_base)
+ AM_RANGE(0x800000, 0x9fffff) AM_ROM AM_REGION("user1", 0) AM_BASE_MEMBER(cojag_state, rom_base)
AM_RANGE(0xa00000, 0xa1ffff) AM_RAM
AM_RANGE(0xa20000, 0xa21fff) AM_READWRITE(eeprom_data_r, eeprom_data_w) AM_SHARE("nvram")
AM_RANGE(0xa30000, 0xa30003) AM_WRITE(watchdog_reset32_w)
@@ -1518,9 +1529,10 @@ ROM_END
static void cojag_common_init(running_machine *machine, UINT16 gpu_jump_offs, UINT16 spin_pc)
{
+ cojag_state *state = machine->driver_data<cojag_state>();
/* copy over the ROM */
- main_cpu = machine->device<cpu_device>("maincpu");
- cojag_is_r3000 = (main_cpu->type() == R3041BE);
+ state->main_cpu = machine->device<cpu_device>("maincpu");
+ cojag_is_r3000 = (state->main_cpu->type() == R3041BE);
/* install synchronization hooks for GPU */
if (cojag_is_r3000)
@@ -1528,8 +1540,8 @@ static void cojag_common_init(running_machine *machine, UINT16 gpu_jump_offs, UI
else
memory_install_write32_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0xf0b000 + gpu_jump_offs, 0xf0b003 + gpu_jump_offs, 0, 0, gpu_jump_w);
memory_install_read32_handler(cputag_get_address_space(machine, "gpu", ADDRESS_SPACE_PROGRAM), 0xf03000 + gpu_jump_offs, 0xf03003 + gpu_jump_offs, 0, 0, gpu_jump_r);
- gpu_jump_address = &jaguar_gpu_ram[gpu_jump_offs/4];
- gpu_spin_pc = 0xf03000 + spin_pc;
+ state->gpu_jump_address = &jaguar_gpu_ram[gpu_jump_offs/4];
+ state->gpu_spin_pc = 0xf03000 + spin_pc;
/* init the sound system and install DSP speedups */
cojag_sound_init(machine);
@@ -1538,92 +1550,99 @@ static void cojag_common_init(running_machine *machine, UINT16 gpu_jump_offs, UI
static DRIVER_INIT( area51a )
{
+ cojag_state *state = machine->driver_data<cojag_state>();
cojag_common_init(machine, 0x5c4, 0x5a0);
#if ENABLE_SPEEDUP_HACKS
/* install speedup for main CPU */
- main_speedup = memory_install_write32_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0xa02030, 0xa02033, 0, 0, area51_main_speedup_w);
+ state->main_speedup = memory_install_write32_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0xa02030, 0xa02033, 0, 0, area51_main_speedup_w);
#endif
}
static DRIVER_INIT( area51 )
{
+ cojag_state *state = machine->driver_data<cojag_state>();
cojag_common_init(machine, 0x0c0, 0x09e);
#if ENABLE_SPEEDUP_HACKS
/* install speedup for main CPU */
- main_speedup_max_cycles = 120;
- main_speedup = memory_install_read32_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0x100062e8, 0x100062eb, 0, 0, cojagr3k_main_speedup_r);
+ state->main_speedup_max_cycles = 120;
+ state->main_speedup = memory_install_read32_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0x100062e8, 0x100062eb, 0, 0, cojagr3k_main_speedup_r);
#endif
}
static DRIVER_INIT( maxforce )
{
+ cojag_state *state = machine->driver_data<cojag_state>();
cojag_common_init(machine, 0x0c0, 0x09e);
/* patch the protection */
- rom_base[0x220/4] = 0x03e00008;
+ state->rom_base[0x220/4] = 0x03e00008;
#if ENABLE_SPEEDUP_HACKS
/* install speedup for main CPU */
- main_speedup_max_cycles = 120;
- main_speedup = memory_install_read32_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0x1000865c, 0x1000865f, 0, 0, cojagr3k_main_speedup_r);
+ state->main_speedup_max_cycles = 120;
+ state->main_speedup = memory_install_read32_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0x1000865c, 0x1000865f, 0, 0, cojagr3k_main_speedup_r);
#endif
}
static DRIVER_INIT( area51mx )
{
+ cojag_state *state = machine->driver_data<cojag_state>();
cojag_common_init(machine, 0x0c0, 0x09e);
/* patch the protection */
- rom_base[0x418/4] = 0x4e754e75;
+ state->rom_base[0x418/4] = 0x4e754e75;
#if ENABLE_SPEEDUP_HACKS
/* install speedup for main CPU */
- main_speedup = memory_install_write32_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0xa19550, 0xa19557, 0, 0, area51mx_main_speedup_w);
+ state->main_speedup = memory_install_write32_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0xa19550, 0xa19557, 0, 0, area51mx_main_speedup_w);
#endif
}
static DRIVER_INIT( a51mxr3k )
{
+ cojag_state *state = machine->driver_data<cojag_state>();
cojag_common_init(machine, 0x0c0, 0x09e);
/* patch the protection */
- rom_base[0x220/4] = 0x03e00008;
+ state->rom_base[0x220/4] = 0x03e00008;
#if ENABLE_SPEEDUP_HACKS
/* install speedup for main CPU */
- main_speedup_max_cycles = 120;
- main_speedup = memory_install_read32_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0x10006f0c, 0x10006f0f, 0, 0, cojagr3k_main_speedup_r);
+ state->main_speedup_max_cycles = 120;
+ state->main_speedup = memory_install_read32_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0x10006f0c, 0x10006f0f, 0, 0, cojagr3k_main_speedup_r);
#endif
}
static DRIVER_INIT( fishfren )
{
+ cojag_state *state = machine->driver_data<cojag_state>();
cojag_common_init(machine, 0x578, 0x554);
#if ENABLE_SPEEDUP_HACKS
/* install speedup for main CPU */
- main_speedup_max_cycles = 200;
- main_speedup = memory_install_read32_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0x10021b60, 0x10021b63, 0, 0, cojagr3k_main_speedup_r);
+ state->main_speedup_max_cycles = 200;
+ state->main_speedup = memory_install_read32_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0x10021b60, 0x10021b63, 0, 0, cojagr3k_main_speedup_r);
#endif
}
static void init_freeze_common(running_machine *machine, offs_t main_speedup_addr)
{
+ cojag_state *state = machine->driver_data<cojag_state>();
cojag_common_init(machine, 0x0bc, 0x09c);
#if ENABLE_SPEEDUP_HACKS
/* install speedup for main CPU */
- main_speedup_max_cycles = 200;
+ state->main_speedup_max_cycles = 200;
if (main_speedup_addr != 0)
- main_speedup = memory_install_read32_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), main_speedup_addr, main_speedup_addr + 3, 0, 0, cojagr3k_main_speedup_r);
- main_gpu_wait = memory_install_read32_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0x0400d900, 0x0400d900 + 3, 0, 0, main_gpu_wait_r);
+ state->main_speedup = memory_install_read32_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), main_speedup_addr, main_speedup_addr + 3, 0, 0, cojagr3k_main_speedup_r);
+ state->main_gpu_wait = memory_install_read32_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0x0400d900, 0x0400d900 + 3, 0, 0, main_gpu_wait_r);
#endif
}
@@ -1637,12 +1656,13 @@ static DRIVER_INIT( freezeat6 ) { init_freeze_common(machine, 0x10019684); }
static DRIVER_INIT( vcircle )
{
+ cojag_state *state = machine->driver_data<cojag_state>();
cojag_common_init(machine, 0x5c0, 0x5a0);
#if ENABLE_SPEEDUP_HACKS
/* install speedup for main CPU */
- main_speedup_max_cycles = 50;
- main_speedup = memory_install_read32_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0x12005b34, 0x12005b37, 0, 0, cojagr3k_main_speedup_r);
+ state->main_speedup_max_cycles = 50;
+ state->main_speedup = memory_install_read32_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0x12005b34, 0x12005b37, 0, 0, cojagr3k_main_speedup_r);
#endif
}
diff --git a/src/mame/drivers/eprom.c b/src/mame/drivers/eprom.c
index 36f7cac3952..27353d68849 100644
--- a/src/mame/drivers/eprom.c
+++ b/src/mame/drivers/eprom.c
@@ -88,11 +88,11 @@ static READ16_HANDLER( special_port1_r )
static READ16_HANDLER( adc_r )
{
- static int last_offset;
+ eprom_state *state = space->machine->driver_data<eprom_state>();
static const char *const adcnames[] = { "ADC0", "ADC1", "ADC2", "ADC3" };
- int result = input_port_read(space->machine, adcnames[last_offset & 3]);
+ int result = input_port_read(space->machine, adcnames[state->last_offset & 3]);
- last_offset = offset;
+ state->last_offset = offset;
return result;
}
diff --git a/src/mame/drivers/firefox.c b/src/mame/drivers/firefox.c
index 15fbce71c11..4deba6ea567 100644
--- a/src/mame/drivers/firefox.c
+++ b/src/mame/drivers/firefox.c
@@ -35,6 +35,30 @@ but requires a special level III player for proper control. Video: CAV. Audio: A
#include "machine/x2212.h"
+class firefox_state : public driver_device
+{
+public:
+ firefox_state(running_machine &machine, const driver_device_config_base &config)
+ : driver_device(machine, config) { }
+
+ device_t *laserdisc;
+ int m_n_disc_lock;
+ int m_n_disc_data;
+ int m_n_disc_read_data;
+ unsigned char *tileram;
+ unsigned char *tile_palette;
+ unsigned char *sprite_palette;
+ x2212_device *nvram_1c;
+ x2212_device *nvram_1d;
+ tilemap_t *bgtiles;
+ int control_num;
+ UINT8 sound_to_main_flag;
+ UINT8 main_to_sound_flag;
+ int sprite_bank;
+};
+
+
+
#define MASTER_XTAL XTAL_14_31818MHz
@@ -57,10 +81,6 @@ fffe=reset e7cc
/* FXXXXX for first field
AXXXXX for second field */
-static device_t *laserdisc;
-static int m_n_disc_lock;
-static int m_n_disc_data;
-static int m_n_disc_read_data;
/* 20 = DISKOPR - Active low
40 = DISKFULL - Active low
@@ -68,12 +88,13 @@ static int m_n_disc_read_data;
*/
static READ8_HANDLER( firefox_disc_status_r )
{
+ firefox_state *state = space->machine->driver_data<firefox_state>();
UINT8 result = 0xff;
result ^= 0x20;
- if (!laserdisc_line_r(laserdisc, LASERDISC_LINE_READY))
+ if (!laserdisc_line_r(state->laserdisc, LASERDISC_LINE_READY))
result ^= 0x40;
- if (laserdisc_line_r(laserdisc, LASERDISC_LINE_DATA_AVAIL))
+ if (laserdisc_line_r(state->laserdisc, LASERDISC_LINE_DATA_AVAIL))
result ^= 0x80;
return result;
@@ -83,19 +104,22 @@ static READ8_HANDLER( firefox_disc_status_r )
/* this reset RDDSK (&DSKRD) */
static READ8_HANDLER( firefox_disc_data_r )
{
- return m_n_disc_read_data;
+ firefox_state *state = space->machine->driver_data<firefox_state>();
+ return state->m_n_disc_read_data;
}
/* DISK READ ENABLE */
/* 4218 - DSKREAD, set RDDSK */
static WRITE8_HANDLER( firefox_disc_read_w )
{
- m_n_disc_read_data = laserdisc_data_r(laserdisc);
+ firefox_state *state = space->machine->driver_data<firefox_state>();
+ state->m_n_disc_read_data = laserdisc_data_r(state->laserdisc);
}
static WRITE8_HANDLER( firefox_disc_lock_w )
{
- m_n_disc_lock = data & 0x80;
+ firefox_state *state = space->machine->driver_data<firefox_state>();
+ state->m_n_disc_lock = data & 0x80;
}
static WRITE8_HANDLER( audio_enable_w )
@@ -105,34 +129,27 @@ static WRITE8_HANDLER( audio_enable_w )
static WRITE8_HANDLER( firefox_disc_reset_w )
{
- laserdisc_line_w(laserdisc, LASERDISC_LINE_RESET, (data & 0x80) ? CLEAR_LINE : ASSERT_LINE);
+ firefox_state *state = space->machine->driver_data<firefox_state>();
+ laserdisc_line_w(state->laserdisc, LASERDISC_LINE_RESET, (data & 0x80) ? CLEAR_LINE : ASSERT_LINE);
}
/* active low on dbb7 */
static WRITE8_HANDLER( firefox_disc_write_w )
{
+ firefox_state *state = space->machine->driver_data<firefox_state>();
if ( ( data & 0x80 ) == 0 )
- laserdisc_data_w(laserdisc, m_n_disc_data);
+ laserdisc_data_w(state->laserdisc, state->m_n_disc_data);
}
/* latch the data */
static WRITE8_HANDLER( firefox_disc_data_w )
{
- m_n_disc_data = data;
+ firefox_state *state = space->machine->driver_data<firefox_state>();
+ state->m_n_disc_data = data;
}
-static unsigned char *tileram;
-static unsigned char *tile_palette;
-static unsigned char *sprite_palette;
-static x2212_device *nvram_1c;
-static x2212_device *nvram_1d;
-static tilemap_t *bgtiles;
-static int control_num;
-static UINT8 sound_to_main_flag;
-static UINT8 main_to_sound_flag;
-static int sprite_bank;
/*************************************
*
@@ -142,27 +159,31 @@ static int sprite_bank;
static TILE_GET_INFO( bgtile_get_info )
{
- SET_TILE_INFO(0, tileram[tile_index], 0, 0);
+ firefox_state *state = machine->driver_data<firefox_state>();
+ SET_TILE_INFO(0, state->tileram[tile_index], 0, 0);
}
static WRITE8_HANDLER( tileram_w )
{
- tileram[offset] = data;
- tilemap_mark_tile_dirty(bgtiles, offset);
+ firefox_state *state = space->machine->driver_data<firefox_state>();
+ state->tileram[offset] = data;
+ tilemap_mark_tile_dirty(state->bgtiles, offset);
}
static VIDEO_START( firefox )
{
- bgtiles = tilemap_create(machine, bgtile_get_info, tilemap_scan_rows, 8,8, 64,64);
- tilemap_set_transparent_pen(bgtiles, 0);
- tilemap_set_scrolldy(bgtiles, machine->primary_screen->visible_area().min_y, 0);
+ firefox_state *state = machine->driver_data<firefox_state>();
+ state->bgtiles = tilemap_create(machine, bgtile_get_info, tilemap_scan_rows, 8,8, 64,64);
+ tilemap_set_transparent_pen(state->bgtiles, 0);
+ tilemap_set_scrolldy(state->bgtiles, machine->primary_screen->visible_area().min_y, 0);
}
static VIDEO_UPDATE( firefox )
{
+ firefox_state *state = screen->machine->driver_data<firefox_state>();
int sprite;
int gfxtop = screen->visible_area().min_y;
@@ -170,7 +191,7 @@ static VIDEO_UPDATE( firefox )
for( sprite = 0; sprite < 32; sprite++ )
{
- UINT8 *sprite_data = screen->machine->generic.spriteram.u8 + ( 0x200 * sprite_bank ) + ( sprite * 16 );
+ UINT8 *sprite_data = screen->machine->generic.spriteram.u8 + ( 0x200 * state->sprite_bank ) + ( sprite * 16 );
int flags = sprite_data[ 0 ];
int y = sprite_data[ 1 ] + ( 256 * ( ( flags >> 0 ) & 1 ) );
int x = sprite_data[ 2 ] + ( 256 * ( ( flags >> 1 ) & 1 ) );
@@ -191,7 +212,7 @@ static VIDEO_UPDATE( firefox )
}
}
- tilemap_draw( bitmap, cliprect, bgtiles, 0, 0 );
+ tilemap_draw( bitmap, cliprect, state->bgtiles, 0, 0 );
return 0;
}
@@ -215,19 +236,22 @@ static void set_rgba( running_machine *machine, int start, int index, unsigned c
static WRITE8_HANDLER( tile_palette_w )
{
- tile_palette[ offset ] = data;
- set_rgba( space->machine, 0, offset & 0xff, tile_palette );
+ firefox_state *state = space->machine->driver_data<firefox_state>();
+ state->tile_palette[ offset ] = data;
+ set_rgba( space->machine, 0, offset & 0xff, state->tile_palette );
}
static WRITE8_HANDLER( sprite_palette_w )
{
- sprite_palette[ offset ] = data;
- set_rgba( space->machine, 256, offset & 0xff, sprite_palette );
+ firefox_state *state = space->machine->driver_data<firefox_state>();
+ state->sprite_palette[ offset ] = data;
+ set_rgba( space->machine, 256, offset & 0xff, state->sprite_palette );
}
static WRITE8_HANDLER( firefox_objram_bank_w )
{
- sprite_bank = data & 0x03;
+ firefox_state *state = space->machine->driver_data<firefox_state>();
+ state->sprite_bank = data & 0x03;
}
@@ -240,43 +264,50 @@ static WRITE8_HANDLER( firefox_objram_bank_w )
static CUSTOM_INPUT( mainflag_r )
{
- return main_to_sound_flag;
+ firefox_state *state = field->port->machine->driver_data<firefox_state>();
+ return state->main_to_sound_flag;
}
static CUSTOM_INPUT( soundflag_r )
{
- return sound_to_main_flag;
+ firefox_state *state = field->port->machine->driver_data<firefox_state>();
+ return state->sound_to_main_flag;
}
static READ8_HANDLER( sound_to_main_r )
{
- sound_to_main_flag = 0;
+ firefox_state *state = space->machine->driver_data<firefox_state>();
+ state->sound_to_main_flag = 0;
return soundlatch2_r(space, 0);
}
static WRITE8_HANDLER( main_to_sound_w )
{
- main_to_sound_flag = 1;
+ firefox_state *state = space->machine->driver_data<firefox_state>();
+ state->main_to_sound_flag = 1;
soundlatch_w(space, 0, data);
cputag_set_input_line(space->machine, "audiocpu", INPUT_LINE_NMI, PULSE_LINE);
}
static WRITE8_HANDLER( sound_reset_w )
{
+ firefox_state *state = space->machine->driver_data<firefox_state>();
cputag_set_input_line(space->machine, "audiocpu", INPUT_LINE_RESET, (data & 0x80) ? ASSERT_LINE : CLEAR_LINE);
if ((data & 0x80) != 0)
- sound_to_main_flag = main_to_sound_flag = 0;
+ state->sound_to_main_flag = state->main_to_sound_flag = 0;
}
static READ8_HANDLER( main_to_sound_r )
{
- main_to_sound_flag = 0;
+ firefox_state *state = space->machine->driver_data<firefox_state>();
+ state->main_to_sound_flag = 0;
return soundlatch_r(space, 0);
}
static WRITE8_HANDLER( sound_to_main_w )
{
- sound_to_main_flag = 1;
+ firefox_state *state = space->machine->driver_data<firefox_state>();
+ state->sound_to_main_flag = 1;
soundlatch2_w(space, 0, data);
}
@@ -290,6 +321,7 @@ static WRITE8_HANDLER( sound_to_main_w )
static READ8_DEVICE_HANDLER( riot_porta_r )
{
+ firefox_state *state = device->machine->driver_data<firefox_state>();
/* bit 7 = MAINFLAG */
/* bit 6 = SOUNDFLAG */
/* bit 5 = PA5 */
@@ -299,7 +331,7 @@ static READ8_DEVICE_HANDLER( riot_porta_r )
/* bit 1 = TMS /read */
/* bit 0 = TMS /write */
- return (main_to_sound_flag << 7) | (sound_to_main_flag << 6) | 0x10 | (tms5220_readyq_r(device) << 2);
+ return (state->main_to_sound_flag << 7) | (state->sound_to_main_flag << 6) | 0x10 | (tms5220_readyq_r(device) << 2);
}
static WRITE8_DEVICE_HANDLER( riot_porta_w )
@@ -328,7 +360,8 @@ static WRITE_LINE_DEVICE_HANDLER( riot_irq )
static READ8_HANDLER( adc_r )
{
- if( control_num == 0 )
+ firefox_state *state = space->machine->driver_data<firefox_state>();
+ if( state->control_num == 0 )
{
return input_port_read( space->machine, "PITCH" );
}
@@ -338,7 +371,8 @@ static READ8_HANDLER( adc_r )
static WRITE8_HANDLER( adc_select_w )
{
- control_num = offset;
+ firefox_state *state = space->machine->driver_data<firefox_state>();
+ state->control_num = offset;
}
@@ -351,25 +385,29 @@ static WRITE8_HANDLER( adc_select_w )
static WRITE8_HANDLER( nvram_w )
{
- nvram_1c->write(*space, offset, data >> 4);
- nvram_1d->write(*space, offset, data & 0xf);
+ firefox_state *state = space->machine->driver_data<firefox_state>();
+ state->nvram_1c->write(*space, offset, data >> 4);
+ state->nvram_1d->write(*space, offset, data & 0xf);
}
static READ8_HANDLER( nvram_r )
{
- return (nvram_1c->read(*space, offset) << 4) | (nvram_1d->read(*space, offset) & 0x0f);
+ firefox_state *state = space->machine->driver_data<firefox_state>();
+ return (state->nvram_1c->read(*space, offset) << 4) | (state->nvram_1d->read(*space, offset) & 0x0f);
}
static WRITE8_HANDLER( novram_recall_w )
{
- nvram_1c->recall(data & 0x80);
- nvram_1d->recall(data & 0x80);
+ firefox_state *state = space->machine->driver_data<firefox_state>();
+ state->nvram_1c->recall(data & 0x80);
+ state->nvram_1d->recall(data & 0x80);
}
static WRITE8_HANDLER( novram_store_w )
{
- nvram_1c->store(data & 0x80);
- nvram_1d->store(data & 0x80);
+ firefox_state *state = space->machine->driver_data<firefox_state>();
+ state->nvram_1c->store(data & 0x80);
+ state->nvram_1d->store(data & 0x80);
}
@@ -429,15 +467,16 @@ static void firq_gen(device_t *device, int state)
static MACHINE_START( firefox )
{
+ firefox_state *state = machine->driver_data<firefox_state>();
memory_configure_bank(machine, "bank1", 0, 32, machine->region("maincpu")->base() + 0x10000, 0x1000);
- nvram_1c = machine->device<x2212_device>("nvram_1c");
- nvram_1d = machine->device<x2212_device>("nvram_1d");
+ state->nvram_1c = machine->device<x2212_device>("nvram_1c");
+ state->nvram_1d = machine->device<x2212_device>("nvram_1d");
- laserdisc = machine->device("laserdisc");
- vp931_set_data_ready_callback(laserdisc, firq_gen);
+ state->laserdisc = machine->device("laserdisc");
+ vp931_set_data_ready_callback(state->laserdisc, firq_gen);
- control_num = 0;
- sprite_bank = 0;
+ state->control_num = 0;
+ state->sprite_bank = 0;
}
@@ -449,11 +488,11 @@ static MACHINE_START( firefox )
static ADDRESS_MAP_START( main_map, ADDRESS_SPACE_PROGRAM, 8)
AM_RANGE(0x0000, 0x0fff) AM_RAM
- AM_RANGE(0x1000, 0x1fff) AM_RAM_WRITE(tileram_w) AM_BASE(&tileram)
+ AM_RANGE(0x1000, 0x1fff) AM_RAM_WRITE(tileram_w) AM_BASE_MEMBER(firefox_state, tileram)
AM_RANGE(0x2000, 0x27ff) AM_RAM AM_BASE_GENERIC(spriteram)
- AM_RANGE(0x2800, 0x2aff) AM_RAM_WRITE(sprite_palette_w) AM_BASE(&sprite_palette)
+ AM_RANGE(0x2800, 0x2aff) AM_RAM_WRITE(sprite_palette_w) AM_BASE_MEMBER(firefox_state, sprite_palette)
AM_RANGE(0x2b00, 0x2b00) AM_MIRROR(0x04ff) AM_WRITE(firefox_objram_bank_w)
- AM_RANGE(0x2c00, 0x2eff) AM_RAM_WRITE(tile_palette_w) AM_BASE(&tile_palette)
+ AM_RANGE(0x2c00, 0x2eff) AM_RAM_WRITE(tile_palette_w) AM_BASE_MEMBER(firefox_state, tile_palette)
AM_RANGE(0x3000, 0x3fff) AM_ROMBANK("bank1")
AM_RANGE(0x4000, 0x40ff) AM_READWRITE(nvram_r, nvram_w) /* NOVRAM */
AM_RANGE(0x4100, 0x4100) AM_MIRROR(0x00f8) AM_READ_PORT("rdin0") /* RDIN0 */
@@ -641,7 +680,7 @@ static const riot6532_interface riot_intf =
};
-static MACHINE_CONFIG_START( firefox, driver_device )
+static MACHINE_CONFIG_START( firefox, firefox_state )
/* basic machine hardware */
MCFG_CPU_ADD("maincpu", M6809E, MASTER_XTAL/2)
diff --git a/src/mame/drivers/firetrk.c b/src/mame/drivers/firetrk.c
index 404e41ee495..7c27dbaa64a 100644
--- a/src/mame/drivers/firetrk.c
+++ b/src/mame/drivers/firetrk.c
@@ -12,16 +12,12 @@ Atari Fire Truck + Super Bug + Monte Carlo driver
#define MASTER_CLOCK (XTAL_12_096MHz)
-static UINT8 in_service_mode;
-static UINT32 dial[2];
-static UINT8 steer_dir[2];
-static UINT8 steer_flag[2];
-static UINT8 gear;
static void set_service_mode(running_machine *machine, int enable)
{
- in_service_mode = enable;
+ firetrk_state *state = machine->driver_data<firetrk_state>();
+ state->in_service_mode = enable;
/* watchdog is disabled during service mode */
watchdog_enable(machine, !enable);
@@ -46,18 +42,20 @@ static INPUT_CHANGED( firetrk_horn_changed )
static INPUT_CHANGED( gear_changed )
{
+ firetrk_state *state = field->port->machine->driver_data<firetrk_state>();
if (newval)
- gear = (FPTR)param;
+ state->gear = (FPTR)param;
}
static INTERRUPT_GEN( firetrk_interrupt )
{
+ firetrk_state *state = device->machine->driver_data<firetrk_state>();
/* Super Bug - ASR - when is this used and what is an ASR? */
-// discrete_sound_w(machine->device("discrete"), SUPERBUG_ASR_EN, 0);
+// discrete_sound_w(device->machine->device("discrete"), SUPERBUG_ASR_EN, 0);
/* NMI interrupts are disabled during service mode in firetrk and montecar */
- if (!in_service_mode)
+ if (!state->in_service_mode)
cpu_set_input_line(device, INPUT_LINE_NMI, PULSE_LINE);
}
@@ -80,6 +78,7 @@ static TIMER_CALLBACK( periodic_callback )
static WRITE8_HANDLER( firetrk_output_w )
{
+ firetrk_state *state = space->machine->driver_data<firetrk_state>();
device_t *discrete = space->machine->device("discrete");
/* BIT0 => START1 LAMP */
@@ -89,7 +88,7 @@ static WRITE8_HANDLER( firetrk_output_w )
set_led_status(space->machine, 1, !(data & 0x02));
/* BIT2 => FLASH */
- firetrk_flash = data & 0x04;
+ state->flash = data & 0x04;
/* BIT3 => TRACK LAMP */
set_led_status(space->machine, 3, !(data & 0x08));
@@ -111,6 +110,7 @@ static WRITE8_HANDLER( firetrk_output_w )
static WRITE8_HANDLER( superbug_output_w )
{
+ firetrk_state *state = space->machine->driver_data<firetrk_state>();
device_t *discrete = space->machine->device("discrete");
/* BIT0 => START LAMP */
@@ -122,7 +122,7 @@ static WRITE8_HANDLER( superbug_output_w )
coin_lockout_w(space->machine, 1, !(offset & 0x02));
/* BIT2 => FLASH */
- firetrk_flash = offset & 0x04;
+ state->flash = offset & 0x04;
/* BIT3 => TRACK LAMP */
set_led_status(space->machine, 1, offset & 0x08);
@@ -158,9 +158,10 @@ static WRITE8_HANDLER( montecar_output_1_w )
static WRITE8_HANDLER( montecar_output_2_w )
{
+ firetrk_state *state = space->machine->driver_data<firetrk_state>();
device_t *discrete = space->machine->device("discrete");
- firetrk_flash = data & 0x80;
+ state->flash = data & 0x80;
discrete_sound_w(discrete, MONTECAR_BEEPER_EN, data & 0x10);
discrete_sound_w(discrete, MONTECAR_DRONE_LOUD_DATA, data & 0x0f);
@@ -201,25 +202,28 @@ static READ8_HANDLER( montecar_dip_r )
static CUSTOM_INPUT( steer_dir_r )
{
- return steer_dir[(FPTR)param];
+ firetrk_state *state = field->port->machine->driver_data<firetrk_state>();
+ return state->steer_dir[(FPTR)param];
}
static CUSTOM_INPUT( steer_flag_r )
{
- return steer_flag[(FPTR)param];
+ firetrk_state *state = field->port->machine->driver_data<firetrk_state>();
+ return state->steer_flag[(FPTR)param];
}
static CUSTOM_INPUT( skid_r )
{
+ firetrk_state *state = field->port->machine->driver_data<firetrk_state>();
UINT32 ret;
int which = (FPTR)param;
if (which != 2)
- ret = firetrk_skid[which];
+ ret = state->skid[which];
else
- ret = firetrk_skid[0] | firetrk_skid[1];
+ ret = state->skid[0] | state->skid[1];
return ret;
}
@@ -227,13 +231,14 @@ static CUSTOM_INPUT( skid_r )
static CUSTOM_INPUT( crash_r )
{
+ firetrk_state *state = field->port->machine->driver_data<firetrk_state>();
UINT32 ret;
int which = (FPTR)param;
if (which != 2)
- ret = firetrk_crash[which];
+ ret = state->crash[which];
else
- ret = firetrk_crash[0] | firetrk_crash[1];
+ ret = state->crash[0] | state->crash[1];
return ret;
}
@@ -241,26 +246,28 @@ static CUSTOM_INPUT( crash_r )
static CUSTOM_INPUT( gear_r )
{
- return (gear == (FPTR)param) ? 1 : 0;
+ firetrk_state *state = field->port->machine->driver_data<firetrk_state>();
+ return (state->gear == (FPTR)param) ? 1 : 0;
}
static READ8_HANDLER( firetrk_input_r )
{
+ firetrk_state *state = space->machine->driver_data<firetrk_state>();
int i;
/* update steering wheels */
for (i = 0; i < 2; i++)
{
UINT32 new_dial = input_port_read_safe(space->machine, (i ? "STEER_2" : "STEER_1"), 0);
- INT32 delta = new_dial - dial[i];
+ INT32 delta = new_dial - state->dial[i];
if (delta != 0)
{
- steer_flag[i] = 0;
- steer_dir[i] = (delta < 0) ? 1 : 0;
+ state->steer_flag[i] = 0;
+ state->steer_dir[i] = (delta < 0) ? 1 : 0;
- dial[i] = dial[i] + delta;
+ state->dial[i] = state->dial[i] + delta;
}
}
@@ -272,13 +279,14 @@ static READ8_HANDLER( firetrk_input_r )
static READ8_HANDLER( montecar_input_r )
{
+ firetrk_state *state = space->machine->driver_data<firetrk_state>();
UINT8 ret = firetrk_input_r(space, offset);
- if (firetrk_crash[0])
+ if (state->crash[0])
ret |= 0x02;
/* can this be right, bit 0 again ???? */
- if (firetrk_crash[1])
+ if (state->crash[1])
ret |= 0x01;
return ret;
@@ -287,56 +295,61 @@ static READ8_HANDLER( montecar_input_r )
static WRITE8_HANDLER( blink_on_w )
{
- *firetrk_blink = TRUE;
+ firetrk_state *state = space->machine->driver_data<firetrk_state>();
+ *state->blink = TRUE;
}
static WRITE8_HANDLER( montecar_car_reset_w )
{
- firetrk_crash[0] = 0;
- firetrk_skid[0] = 0;
+ firetrk_state *state = space->machine->driver_data<firetrk_state>();
+ state->crash[0] = 0;
+ state->skid[0] = 0;
}
static WRITE8_HANDLER( montecar_drone_reset_w )
{
- firetrk_crash[1] = 0;
- firetrk_skid[1] = 0;
+ firetrk_state *state = space->machine->driver_data<firetrk_state>();
+ state->crash[1] = 0;
+ state->skid[1] = 0;
}
static WRITE8_HANDLER( steer_reset_w )
{
- steer_flag[0] = 1;
- steer_flag[1] = 1;
+ firetrk_state *state = space->machine->driver_data<firetrk_state>();
+ state->steer_flag[0] = 1;
+ state->steer_flag[1] = 1;
}
static WRITE8_HANDLER( crash_reset_w )
{
- firetrk_crash[0] = 0;
- firetrk_crash[1] = 0;
+ firetrk_state *state = space->machine->driver_data<firetrk_state>();
+ state->crash[0] = 0;
+ state->crash[1] = 0;
}
static ADDRESS_MAP_START( firetrk_map, ADDRESS_SPACE_PROGRAM, 8 )
ADDRESS_MAP_GLOBAL_MASK(0x3fff)
- AM_RANGE(0x0000, 0x00ff) AM_MIRROR(0x0700) AM_RAM AM_BASE(&firetrk_alpha_num_ram)
- AM_RANGE(0x0800, 0x08ff) AM_MIRROR(0x0700) AM_RAM AM_BASE(&firetrk_playfield_ram)
- AM_RANGE(0x1000, 0x1000) AM_MIRROR(0x001f) AM_WRITEONLY AM_BASE(&firetrk_scroll_y)
- AM_RANGE(0x1020, 0x1020) AM_MIRROR(0x001f) AM_WRITEONLY AM_BASE(&firetrk_scroll_x)
+ AM_RANGE(0x0000, 0x00ff) AM_MIRROR(0x0700) AM_RAM AM_BASE_MEMBER(firetrk_state, alpha_num_ram)
+ AM_RANGE(0x0800, 0x08ff) AM_MIRROR(0x0700) AM_RAM AM_BASE_MEMBER(firetrk_state, playfield_ram)
+ AM_RANGE(0x1000, 0x1000) AM_MIRROR(0x001f) AM_WRITEONLY AM_BASE_MEMBER(firetrk_state, scroll_y)
+ AM_RANGE(0x1020, 0x1020) AM_MIRROR(0x001f) AM_WRITEONLY AM_BASE_MEMBER(firetrk_state, scroll_x)
AM_RANGE(0x1040, 0x1040) AM_MIRROR(0x001f) AM_WRITE(crash_reset_w)
AM_RANGE(0x1060, 0x1060) AM_MIRROR(0x001f) AM_DEVWRITE("discrete", firetrk_skid_reset_w)
- AM_RANGE(0x1080, 0x1080) AM_MIRROR(0x001f) AM_WRITEONLY AM_BASE(&firetrk_car_rot)
+ AM_RANGE(0x1080, 0x1080) AM_MIRROR(0x001f) AM_WRITEONLY AM_BASE_MEMBER(firetrk_state, car_rot)
AM_RANGE(0x10a0, 0x10a0) AM_MIRROR(0x001f) AM_WRITE(steer_reset_w)
AM_RANGE(0x10c0, 0x10c0) AM_MIRROR(0x001f) AM_WRITE(watchdog_reset_w)
- AM_RANGE(0x10e0, 0x10e0) AM_MIRROR(0x001f) AM_WRITE(blink_on_w) AM_BASE(&firetrk_blink)
+ AM_RANGE(0x10e0, 0x10e0) AM_MIRROR(0x001f) AM_WRITE(blink_on_w) AM_BASE_MEMBER(firetrk_state, blink)
AM_RANGE(0x1400, 0x1400) AM_MIRROR(0x001f) AM_DEVWRITE("discrete", firetrk_motor_snd_w)
AM_RANGE(0x1420, 0x1420) AM_MIRROR(0x001f) AM_DEVWRITE("discrete", firetrk_crash_snd_w)
AM_RANGE(0x1440, 0x1440) AM_MIRROR(0x001f) AM_DEVWRITE("discrete", firetrk_skid_snd_w)
- AM_RANGE(0x1460, 0x1460) AM_MIRROR(0x001f) AM_WRITEONLY AM_BASE(&firetrk_drone_x)
- AM_RANGE(0x1480, 0x1480) AM_MIRROR(0x001f) AM_WRITEONLY AM_BASE(&firetrk_drone_y)
- AM_RANGE(0x14a0, 0x14a0) AM_MIRROR(0x001f) AM_WRITEONLY AM_BASE(&firetrk_drone_rot)
+ AM_RANGE(0x1460, 0x1460) AM_MIRROR(0x001f) AM_WRITEONLY AM_BASE_MEMBER(firetrk_state, drone_x)
+ AM_RANGE(0x1480, 0x1480) AM_MIRROR(0x001f) AM_WRITEONLY AM_BASE_MEMBER(firetrk_state, drone_y)
+ AM_RANGE(0x14a0, 0x14a0) AM_MIRROR(0x001f) AM_WRITEONLY AM_BASE_MEMBER(firetrk_state, drone_rot)
AM_RANGE(0x14c0, 0x14c0) AM_MIRROR(0x001f) AM_WRITE(firetrk_output_w)
AM_RANGE(0x14e0, 0x14e0) AM_MIRROR(0x001f) AM_DEVWRITE("discrete", firetrk_xtndply_w)
AM_RANGE(0x1800, 0x1807) AM_MIRROR(0x03f8) AM_READ(firetrk_input_r) AM_WRITENOP
@@ -348,14 +361,14 @@ ADDRESS_MAP_END
static ADDRESS_MAP_START( superbug_map, ADDRESS_SPACE_PROGRAM, 8 )
ADDRESS_MAP_GLOBAL_MASK(0x1fff)
AM_RANGE(0x0000, 0x00ff) AM_RAM
- AM_RANGE(0x0100, 0x0100) AM_MIRROR(0x001f) AM_WRITEONLY AM_BASE(&firetrk_scroll_y)
- AM_RANGE(0x0120, 0x0120) AM_MIRROR(0x001f) AM_WRITEONLY AM_BASE(&firetrk_scroll_x)
+ AM_RANGE(0x0100, 0x0100) AM_MIRROR(0x001f) AM_WRITEONLY AM_BASE_MEMBER(firetrk_state, scroll_y)
+ AM_RANGE(0x0120, 0x0120) AM_MIRROR(0x001f) AM_WRITEONLY AM_BASE_MEMBER(firetrk_state, scroll_x)
AM_RANGE(0x0140, 0x0140) AM_MIRROR(0x001f) AM_WRITE(crash_reset_w)
AM_RANGE(0x0160, 0x0160) AM_MIRROR(0x001f) AM_DEVWRITE("discrete", firetrk_skid_reset_w)
- AM_RANGE(0x0180, 0x0180) AM_MIRROR(0x001f) AM_WRITEONLY AM_BASE(&firetrk_car_rot)
+ AM_RANGE(0x0180, 0x0180) AM_MIRROR(0x001f) AM_WRITEONLY AM_BASE_MEMBER(firetrk_state, car_rot)
AM_RANGE(0x01a0, 0x01a0) AM_MIRROR(0x001f) AM_WRITE(steer_reset_w)
AM_RANGE(0x01c0, 0x01c0) AM_MIRROR(0x001f) AM_WRITE(watchdog_reset_w)
- AM_RANGE(0x01e0, 0x01e0) AM_MIRROR(0x001f) AM_WRITE(blink_on_w) AM_BASE(&firetrk_blink)
+ AM_RANGE(0x01e0, 0x01e0) AM_MIRROR(0x001f) AM_WRITE(blink_on_w) AM_BASE_MEMBER(firetrk_state, blink)
AM_RANGE(0x0200, 0x0207) AM_MIRROR(0x0018) AM_READ(firetrk_input_r)
AM_RANGE(0x0220, 0x0220) AM_MIRROR(0x001f) AM_DEVWRITE("discrete", superbug_asr_w)
AM_RANGE(0x0240, 0x0243) AM_MIRROR(0x001c) AM_READ(firetrk_dip_r)
@@ -363,30 +376,30 @@ static ADDRESS_MAP_START( superbug_map, ADDRESS_SPACE_PROGRAM, 8 )
AM_RANGE(0x0280, 0x0280) AM_MIRROR(0x001f) AM_DEVWRITE("discrete", superbug_motor_snd_w)
AM_RANGE(0x02a0, 0x02a0) AM_MIRROR(0x001f) AM_DEVWRITE("discrete", firetrk_crash_snd_w)
AM_RANGE(0x02c0, 0x02c0) AM_MIRROR(0x001f) AM_DEVWRITE("discrete", firetrk_skid_snd_w)
- AM_RANGE(0x0400, 0x041f) AM_RAM AM_BASE(&firetrk_alpha_num_ram)
- AM_RANGE(0x0500, 0x05ff) AM_RAM AM_BASE(&firetrk_playfield_ram)
+ AM_RANGE(0x0400, 0x041f) AM_RAM AM_BASE_MEMBER(firetrk_state, alpha_num_ram)
+ AM_RANGE(0x0500, 0x05ff) AM_RAM AM_BASE_MEMBER(firetrk_state, playfield_ram)
AM_RANGE(0x0800, 0x1fff) AM_ROM
ADDRESS_MAP_END
static ADDRESS_MAP_START( montecar_map, ADDRESS_SPACE_PROGRAM, 8 )
ADDRESS_MAP_GLOBAL_MASK(0x3fff)
- AM_RANGE(0x0000, 0x00ff) AM_MIRROR(0x0700) AM_RAM AM_BASE(&firetrk_alpha_num_ram)
- AM_RANGE(0x0800, 0x08ff) AM_MIRROR(0x0700) AM_RAM AM_BASE(&firetrk_playfield_ram)
- AM_RANGE(0x1000, 0x1000) AM_MIRROR(0x001f) AM_WRITEONLY AM_BASE(&firetrk_scroll_y)
- AM_RANGE(0x1020, 0x1020) AM_MIRROR(0x001f) AM_WRITEONLY AM_BASE(&firetrk_scroll_x)
+ AM_RANGE(0x0000, 0x00ff) AM_MIRROR(0x0700) AM_RAM AM_BASE_MEMBER(firetrk_state, alpha_num_ram)
+ AM_RANGE(0x0800, 0x08ff) AM_MIRROR(0x0700) AM_RAM AM_BASE_MEMBER(firetrk_state, playfield_ram)
+ AM_RANGE(0x1000, 0x1000) AM_MIRROR(0x001f) AM_WRITEONLY AM_BASE_MEMBER(firetrk_state, scroll_y)
+ AM_RANGE(0x1020, 0x1020) AM_MIRROR(0x001f) AM_WRITEONLY AM_BASE_MEMBER(firetrk_state, scroll_x)
AM_RANGE(0x1040, 0x1040) AM_MIRROR(0x001f) AM_WRITE(montecar_drone_reset_w)
AM_RANGE(0x1060, 0x1060) AM_MIRROR(0x001f) AM_WRITE(montecar_car_reset_w)
- AM_RANGE(0x1080, 0x1080) AM_MIRROR(0x001f) AM_WRITEONLY AM_BASE(&firetrk_car_rot)
+ AM_RANGE(0x1080, 0x1080) AM_MIRROR(0x001f) AM_WRITEONLY AM_BASE_MEMBER(firetrk_state, car_rot)
AM_RANGE(0x10a0, 0x10a0) AM_MIRROR(0x001f) AM_WRITE(steer_reset_w)
AM_RANGE(0x10c0, 0x10c0) AM_MIRROR(0x001f) AM_WRITE(watchdog_reset_w)
AM_RANGE(0x10e0, 0x10e0) AM_MIRROR(0x001f) AM_DEVWRITE("discrete", montecar_skid_reset_w)
AM_RANGE(0x1400, 0x1400) AM_MIRROR(0x001f) AM_DEVWRITE("discrete", firetrk_motor_snd_w)
AM_RANGE(0x1420, 0x1420) AM_MIRROR(0x001f) AM_DEVWRITE("discrete", firetrk_crash_snd_w)
AM_RANGE(0x1440, 0x1440) AM_MIRROR(0x001f) AM_DEVWRITE("discrete", firetrk_skid_snd_w)
- AM_RANGE(0x1460, 0x1460) AM_MIRROR(0x001f) AM_WRITEONLY AM_BASE(&firetrk_drone_x)
- AM_RANGE(0x1480, 0x1480) AM_MIRROR(0x001f) AM_WRITEONLY AM_BASE(&firetrk_drone_y)
- AM_RANGE(0x14a0, 0x14a0) AM_MIRROR(0x001f) AM_WRITEONLY AM_BASE(&firetrk_drone_rot)
+ AM_RANGE(0x1460, 0x1460) AM_MIRROR(0x001f) AM_WRITEONLY AM_BASE_MEMBER(firetrk_state, drone_x)
+ AM_RANGE(0x1480, 0x1480) AM_MIRROR(0x001f) AM_WRITEONLY AM_BASE_MEMBER(firetrk_state, drone_y)
+ AM_RANGE(0x14a0, 0x14a0) AM_MIRROR(0x001f) AM_WRITEONLY AM_BASE_MEMBER(firetrk_state, drone_rot)
AM_RANGE(0x14c0, 0x14c0) AM_MIRROR(0x001f) AM_WRITE(montecar_output_1_w)
AM_RANGE(0x14e0, 0x14e0) AM_MIRROR(0x001f) AM_WRITE(montecar_output_2_w)
AM_RANGE(0x1800, 0x1807) AM_MIRROR(0x03f8) AM_READ(montecar_input_r) AM_WRITENOP
@@ -876,7 +889,7 @@ static GFXDECODE_START( montecar )
GFXDECODE_END
-static MACHINE_CONFIG_START( firetrk, driver_device )
+static MACHINE_CONFIG_START( firetrk, firetrk_state )
/* basic machine hardware */
MCFG_CPU_ADD("maincpu", M6800, MASTER_CLOCK/12) /* 750Khz during service mode */
diff --git a/src/mame/drivers/mhavoc.c b/src/mame/drivers/mhavoc.c
index 490b2353138..e35b3173f5b 100644
--- a/src/mame/drivers/mhavoc.c
+++ b/src/mame/drivers/mhavoc.c
@@ -233,9 +233,9 @@ static WRITE8_HANDLER( dual_pokey_w )
static ADDRESS_MAP_START( alpha_map, ADDRESS_SPACE_PROGRAM, 8 )
AM_RANGE(0x0000, 0x01ff) AM_RAM
- AM_RANGE(0x0200, 0x07ff) AM_RAMBANK("bank1") AM_BASE(&mhavoc_zram0)
+ AM_RANGE(0x0200, 0x07ff) AM_RAMBANK("bank1") AM_BASE_MEMBER(mhavoc_state, zram0)
AM_RANGE(0x0800, 0x09ff) AM_RAM
- AM_RANGE(0x0a00, 0x0fff) AM_RAMBANK("bank1") AM_BASE(&mhavoc_zram1)
+ AM_RANGE(0x0a00, 0x0fff) AM_RAMBANK("bank1") AM_BASE_MEMBER(mhavoc_state, zram1)
AM_RANGE(0x1000, 0x1000) AM_READ(mhavoc_gamma_r) /* Gamma Read Port */
AM_RANGE(0x1200, 0x1200) AM_READ_PORT("IN0") AM_WRITENOP /* Alpha Input Port 0 */
AM_RANGE(0x1400, 0x141f) AM_RAM AM_BASE(&avgdvg_colorram) /* ColorRAM */
@@ -287,9 +287,9 @@ ADDRESS_MAP_END
static ADDRESS_MAP_START( alphaone_map, ADDRESS_SPACE_PROGRAM, 8 )
AM_RANGE(0x0000, 0x01ff) AM_RAM
- AM_RANGE(0x0200, 0x07ff) AM_RAMBANK("bank1") AM_BASE(&mhavoc_zram0)
+ AM_RANGE(0x0200, 0x07ff) AM_RAMBANK("bank1") AM_BASE_MEMBER(mhavoc_state, zram0)
AM_RANGE(0x0800, 0x09ff) AM_RAM
- AM_RANGE(0x0a00, 0x0fff) AM_RAMBANK("bank1") AM_BASE(&mhavoc_zram1)
+ AM_RANGE(0x0a00, 0x0fff) AM_RAMBANK("bank1") AM_BASE_MEMBER(mhavoc_state, zram1)
AM_RANGE(0x1020, 0x103f) AM_READWRITE(dual_pokey_r, dual_pokey_w)
AM_RANGE(0x1040, 0x1040) AM_READ_PORT("IN0") AM_WRITENOP /* Alpha Input Port 0 */
AM_RANGE(0x1060, 0x1060) AM_READ_PORT("IN1") /* Gamma Input Port */
@@ -472,7 +472,7 @@ static const pokey_interface pokey_config =
*
*************************************/
-static MACHINE_CONFIG_START( mhavoc, driver_device )
+static MACHINE_CONFIG_START( mhavoc, mhavoc_state )
/* basic machine hardware */
MCFG_CPU_ADD("alpha", M6502, MHAVOC_CLOCK_2_5M) /* 2.5 MHz */
diff --git a/src/mame/drivers/missile.c b/src/mame/drivers/missile.c
index 5aea41e5d71..c432acc877b 100644
--- a/src/mame/drivers/missile.c
+++ b/src/mame/drivers/missile.c
@@ -359,6 +359,14 @@ public:
: driver_device(machine, config) { }
UINT8 *videoram;
+ const UINT8 *writeprom;
+ emu_timer *irq_timer;
+ emu_timer *cpu_timer;
+ UINT8 irq_state;
+ UINT8 ctrld;
+ UINT8 flipscreen;
+ UINT8 madsel_delay;
+ UINT16 madsel_lastpc;
};
@@ -380,16 +388,8 @@ public:
*
*************************************/
-static const UINT8 *writeprom;
-static emu_timer *irq_timer;
-static emu_timer *cpu_timer;
-static UINT8 irq_state;
-static UINT8 ctrld;
-static UINT8 flipscreen;
-static UINT8 madsel_delay;
-static UINT16 madsel_lastpc;
@@ -399,47 +399,49 @@ static UINT16 madsel_lastpc;
*
*************************************/
-INLINE int scanline_to_v(int scanline)
+INLINE int scanline_to_v(missile_state *state, int scanline)
{
/* since the vertical sync counter counts backwards when flipped,
this function returns the current effective V value, given
that vpos() only counts forward */
- return flipscreen ? (256 - scanline) : scanline;
+ return state->flipscreen ? (256 - scanline) : scanline;
}
-INLINE int v_to_scanline(int v)
+INLINE int v_to_scanline(missile_state *state, int v)
{
/* same as a above, but the opposite transformation */
- return flipscreen ? (256 - v) : v;
+ return state->flipscreen ? (256 - v) : v;
}
INLINE void schedule_next_irq(running_machine *machine, int curv)
{
+ missile_state *state = machine->driver_data<missile_state>();
/* IRQ = /32V, clocked by /16V ^ flip */
/* When not flipped, clocks on 0, 64, 128, 192 */
/* When flipped, clocks on 16, 80, 144, 208 */
- if (flipscreen)
+ if (state->flipscreen)
curv = ((curv - 32) & 0xff) | 0x10;
else
curv = ((curv + 32) & 0xff) & ~0x10;
/* next one at the start of this scanline */
- timer_adjust_oneshot(irq_timer, machine->primary_screen->time_until_pos(v_to_scanline(curv), 0), curv);
+ timer_adjust_oneshot(state->irq_timer, machine->primary_screen->time_until_pos(v_to_scanline(state, curv), 0), curv);
}
static TIMER_CALLBACK( clock_irq )
{
+ missile_state *state = machine->driver_data<missile_state>();
int curv = param;
/* assert the IRQ if not already asserted */
- irq_state = (~curv >> 5) & 1;
- cputag_set_input_line(machine, "maincpu", 0, irq_state ? ASSERT_LINE : CLEAR_LINE);
+ state->irq_state = (~curv >> 5) & 1;
+ cputag_set_input_line(machine, "maincpu", 0, state->irq_state ? ASSERT_LINE : CLEAR_LINE);
/* force an update while we're here */
- machine->primary_screen->update_partial(v_to_scanline(curv));
+ machine->primary_screen->update_partial(v_to_scanline(state, curv));
/* find the next edge */
schedule_next_irq(machine, curv);
@@ -448,7 +450,8 @@ static TIMER_CALLBACK( clock_irq )
static CUSTOM_INPUT( get_vblank )
{
- int v = scanline_to_v(field->port->machine->primary_screen->vpos());
+ missile_state *state = field->port->machine->driver_data<missile_state>();
+ int v = scanline_to_v(state, field->port->machine->primary_screen->vpos());
return v < 24;
}
@@ -462,6 +465,7 @@ static CUSTOM_INPUT( get_vblank )
static TIMER_CALLBACK( adjust_cpu_speed )
{
+ missile_state *state = machine->driver_data<missile_state>();
int curv = param;
/* starting at scanline 224, the CPU runs at half speed */
@@ -472,7 +476,7 @@ static TIMER_CALLBACK( adjust_cpu_speed )
/* scanline for the next run */
curv ^= 224;
- timer_adjust_oneshot(cpu_timer, machine->primary_screen->time_until_pos(v_to_scanline(curv), 0), curv);
+ timer_adjust_oneshot(state->cpu_timer, machine->primary_screen->time_until_pos(v_to_scanline(state, curv), 0), curv);
}
@@ -504,36 +508,38 @@ DIRECT_UPDATE_HANDLER( missile_direct_handler )
static MACHINE_START( missile )
{
+ missile_state *state = machine->driver_data<missile_state>();
/* initialize globals */
- writeprom = machine->region("proms")->base();
- flipscreen = 0;
+ state->writeprom = machine->region("proms")->base();
+ state->flipscreen = 0;
/* set up an opcode base handler since we use mapped handlers for RAM */
address_space *space = machine->device<m6502_device>("maincpu")->space(AS_PROGRAM);
space->set_direct_update_handler(direct_update_delegate_create_static(missile_direct_handler, *machine));
/* create a timer to speed/slow the CPU */
- cpu_timer = timer_alloc(machine, adjust_cpu_speed, NULL);
- timer_adjust_oneshot(cpu_timer, machine->primary_screen->time_until_pos(v_to_scanline(0), 0), 0);
+ state->cpu_timer = timer_alloc(machine, adjust_cpu_speed, NULL);
+ timer_adjust_oneshot(state->cpu_timer, machine->primary_screen->time_until_pos(v_to_scanline(state, 0), 0), 0);
/* create a timer for IRQs and set up the first callback */
- irq_timer = timer_alloc(machine, clock_irq, NULL);
- irq_state = 0;
+ state->irq_timer = timer_alloc(machine, clock_irq, NULL);
+ state->irq_state = 0;
schedule_next_irq(machine, -32);
/* setup for save states */
- state_save_register_global(machine, irq_state);
- state_save_register_global(machine, ctrld);
- state_save_register_global(machine, flipscreen);
- state_save_register_global(machine, madsel_delay);
- state_save_register_global(machine, madsel_lastpc);
+ state_save_register_global(machine, state->irq_state);
+ state_save_register_global(machine, state->ctrld);
+ state_save_register_global(machine, state->flipscreen);
+ state_save_register_global(machine, state->madsel_delay);
+ state_save_register_global(machine, state->madsel_lastpc);
}
static MACHINE_RESET( missile )
{
+ missile_state *state = machine->driver_data<missile_state>();
cputag_set_input_line(machine, "maincpu", 0, CLEAR_LINE);
- irq_state = 0;
+ state->irq_state = 0;
}
@@ -546,25 +552,26 @@ static MACHINE_RESET( missile )
INLINE int get_madsel(address_space *space)
{
+ missile_state *state = space->machine->driver_data<missile_state>();
UINT16 pc = cpu_get_previouspc(space->cpu);
/* if we're at a different instruction than last time, reset our delay counter */
- if (pc != madsel_lastpc)
- madsel_delay = 0;
+ if (pc != state->madsel_lastpc)
+ state->madsel_delay = 0;
/* MADSEL signal disables standard address decoding and routes
writes to video RAM; it is enabled if the IRQ signal is clear
and the low 5 bits of the fetched opcode are 0x01 */
- if (!irq_state && (space->direct().read_decrypted_byte(pc) & 0x1f) == 0x01)
+ if (!state->irq_state && (space->direct().read_decrypted_byte(pc) & 0x1f) == 0x01)
{
/* the MADSEL signal goes high 5 cycles after the opcode is identified;
this effectively skips the indirect memory read. Since this is difficult
to do in MAME, we just ignore the first two positive hits on MADSEL
and only return TRUE on the third or later */
- madsel_lastpc = pc;
- return (++madsel_delay >= 4);
+ state->madsel_lastpc = pc;
+ return (++state->madsel_delay >= 4);
}
- madsel_delay = 0;
+ state->madsel_delay = 0;
return 0;
}
@@ -595,7 +602,7 @@ static void write_vram(address_space *space, offs_t address, UINT8 data)
/* this should only be called if MADSEL == 1 */
vramaddr = address >> 2;
vramdata = data_lookup[data >> 6];
- vrammask = writeprom[(address & 7) | 0x10];
+ vrammask = state->writeprom[(address & 7) | 0x10];
videoram[vramaddr] = (videoram[vramaddr] & vrammask) | (vramdata & ~vrammask);
/* 3-bit VRAM writes use an extra clock to write the 3rd bit elsewhere */
@@ -604,7 +611,7 @@ static void write_vram(address_space *space, offs_t address, UINT8 data)
{
vramaddr = get_bit3_addr(address);
vramdata = -((data >> 5) & 1);
- vrammask = writeprom[(address & 7) | 0x18];
+ vrammask = state->writeprom[(address & 7) | 0x18];
videoram[vramaddr] = (videoram[vramaddr] & vrammask) | (vramdata & ~vrammask);
/* account for the extra clock cycle */
@@ -668,7 +675,7 @@ static VIDEO_UPDATE( missile )
{
UINT16 *dst = (UINT16 *)bitmap->base + y * bitmap->rowpixels;
- int effy = flipscreen ? ((256+24 - y) & 0xff) : y;
+ int effy = state->flipscreen ? ((256+24 - y) & 0xff) : y;
UINT8 *src = &videoram[effy * 64];
UINT8 *src3 = NULL;
@@ -725,13 +732,13 @@ static WRITE8_HANDLER( missile_w )
/* OUT0 */
else if (offset < 0x4900)
{
- flipscreen = ~data & 0x40;
+ state->flipscreen = ~data & 0x40;
coin_counter_w(space->machine, 0, data & 0x20);
coin_counter_w(space->machine, 1, data & 0x10);
coin_counter_w(space->machine, 2, data & 0x08);
set_led_status(space->machine, 1, ~data & 0x04);
set_led_status(space->machine, 0, ~data & 0x02);
- ctrld = data & 1;
+ state->ctrld = data & 1;
}
/* color RAM */
@@ -745,10 +752,10 @@ static WRITE8_HANDLER( missile_w )
/* interrupt ack */
else if (offset >= 0x4d00 && offset < 0x4e00)
{
- if (irq_state)
+ if (state->irq_state)
{
cputag_set_input_line(space->machine, "maincpu", 0, CLEAR_LINE);
- irq_state = 0;
+ state->irq_state = 0;
}
}
@@ -786,9 +793,9 @@ static READ8_HANDLER( missile_r )
/* IN0 */
else if (offset < 0x4900)
{
- if (ctrld) /* trackball */
+ if (state->ctrld) /* trackball */
{
- if (!flipscreen)
+ if (!state->flipscreen)
result = ((input_port_read(space->machine, "TRACK0_Y") << 4) & 0xf0) | (input_port_read(space->machine, "TRACK0_X") & 0x0f);
else
result = ((input_port_read(space->machine, "TRACK1_Y") << 4) & 0xf0) | (input_port_read(space->machine, "TRACK1_X") & 0x0f);
diff --git a/src/mame/drivers/poolshrk.c b/src/mame/drivers/poolshrk.c
index bf2fde74887..d2e6d048310 100644
--- a/src/mame/drivers/poolshrk.c
+++ b/src/mame/drivers/poolshrk.c
@@ -10,7 +10,6 @@ Atari Poolshark Driver
#include "sound/discrete.h"
-static int poolshrk_da_latch;
static DRIVER_INIT( poolshrk )
@@ -48,7 +47,8 @@ static DRIVER_INIT( poolshrk )
static WRITE8_HANDLER( poolshrk_da_latch_w )
{
- poolshrk_da_latch = data & 15;
+ poolshrk_state *state = space->machine->driver_data<poolshrk_state>();
+ state->da_latch = data & 15;
}
@@ -72,14 +72,15 @@ static WRITE8_HANDLER( poolshrk_watchdog_w )
static READ8_HANDLER( poolshrk_input_r )
{
+ poolshrk_state *state = space->machine->driver_data<poolshrk_state>();
static const char *const portnames[] = { "IN0", "IN1", "IN2", "IN3" };
UINT8 val = input_port_read(space->machine, portnames[offset & 3]);
int x = input_port_read(space->machine, (offset & 1) ? "AN1" : "AN0");
int y = input_port_read(space->machine, (offset & 1) ? "AN3" : "AN2");
- if (x >= poolshrk_da_latch) val |= 8;
- if (y >= poolshrk_da_latch) val |= 4;
+ if (x >= state->da_latch) val |= 8;
+ if (y >= state->da_latch) val |= 4;
if ((offset & 3) == 3)
{
@@ -101,9 +102,9 @@ static READ8_HANDLER( poolshrk_irq_reset_r )
static ADDRESS_MAP_START( poolshrk_cpu_map, ADDRESS_SPACE_PROGRAM, 8 )
ADDRESS_MAP_GLOBAL_MASK(0x7fff)
AM_RANGE(0x0000, 0x00ff) AM_MIRROR(0x2300) AM_RAM
- AM_RANGE(0x0400, 0x07ff) AM_MIRROR(0x2000) AM_WRITEONLY AM_BASE(&poolshrk_playfield_ram)
- AM_RANGE(0x0800, 0x080f) AM_MIRROR(0x23f0) AM_WRITEONLY AM_BASE(&poolshrk_hpos_ram)
- AM_RANGE(0x0c00, 0x0c0f) AM_MIRROR(0x23f0) AM_WRITEONLY AM_BASE(&poolshrk_vpos_ram)
+ AM_RANGE(0x0400, 0x07ff) AM_MIRROR(0x2000) AM_WRITEONLY AM_BASE_MEMBER(poolshrk_state, playfield_ram)
+ AM_RANGE(0x0800, 0x080f) AM_MIRROR(0x23f0) AM_WRITEONLY AM_BASE_MEMBER(poolshrk_state, hpos_ram)
+ AM_RANGE(0x0c00, 0x0c0f) AM_MIRROR(0x23f0) AM_WRITEONLY AM_BASE_MEMBER(poolshrk_state, vpos_ram)
AM_RANGE(0x1000, 0x13ff) AM_MIRROR(0x2000) AM_READWRITE(poolshrk_input_r, poolshrk_watchdog_w)
AM_RANGE(0x1400, 0x17ff) AM_MIRROR(0x2000) AM_DEVWRITE("discrete", poolshrk_scratch_sound_w)
AM_RANGE(0x1800, 0x1bff) AM_MIRROR(0x2000) AM_DEVWRITE("discrete", poolshrk_score_sound_w)
@@ -212,7 +213,7 @@ static PALETTE_INIT( poolshrk )
}
-static MACHINE_CONFIG_START( poolshrk, driver_device )
+static MACHINE_CONFIG_START( poolshrk, poolshrk_state )
/* basic machine hardware */
MCFG_CPU_ADD("maincpu", M6800, 11055000 / 8) /* ? */
diff --git a/src/mame/drivers/runaway.c b/src/mame/drivers/runaway.c
index 6a2b111f033..92c26ff591d 100644
--- a/src/mame/drivers/runaway.c
+++ b/src/mame/drivers/runaway.c
@@ -16,10 +16,10 @@
#include "sound/pokey.h"
#include "includes/runaway.h"
-static emu_timer *interrupt_timer;
static TIMER_CALLBACK( interrupt_callback )
{
+ runaway_state *state = machine->driver_data<runaway_state>();
/* assume Centipede-style interrupt timing */
int scanline = param;
@@ -30,17 +30,19 @@ static TIMER_CALLBACK( interrupt_callback )
if (scanline >= 263)
scanline = 16;
- timer_adjust_oneshot(interrupt_timer, machine->primary_screen->time_until_pos(scanline), scanline);
+ timer_adjust_oneshot(state->interrupt_timer, machine->primary_screen->time_until_pos(scanline), scanline);
}
static MACHINE_START( runaway )
{
- interrupt_timer = timer_alloc(machine, interrupt_callback, NULL);
+ runaway_state *state = machine->driver_data<runaway_state>();
+ state->interrupt_timer = timer_alloc(machine, interrupt_callback, NULL);
}
static MACHINE_RESET( runaway )
{
- timer_adjust_oneshot(interrupt_timer, machine->primary_screen->time_until_pos(16), 16);
+ runaway_state *state = machine->driver_data<runaway_state>();
+ timer_adjust_oneshot(state->interrupt_timer, machine->primary_screen->time_until_pos(16), 16);
}
@@ -81,8 +83,8 @@ static WRITE8_HANDLER( runaway_irq_ack_w )
static ADDRESS_MAP_START( runaway_map, ADDRESS_SPACE_PROGRAM, 8 )
AM_RANGE(0x0000, 0x03ff) AM_RAM
- AM_RANGE(0x0400, 0x07bf) AM_RAM_WRITE(runaway_video_ram_w) AM_BASE(&runaway_video_ram)
- AM_RANGE(0x07c0, 0x07ff) AM_RAM AM_BASE(&runaway_sprite_ram)
+ AM_RANGE(0x0400, 0x07bf) AM_RAM_WRITE(runaway_video_ram_w) AM_BASE_MEMBER(runaway_state, video_ram)
+ AM_RANGE(0x07c0, 0x07ff) AM_RAM AM_BASE_MEMBER(runaway_state, sprite_ram)
AM_RANGE(0x1000, 0x1000) AM_WRITE(runaway_irq_ack_w)
AM_RANGE(0x1400, 0x143f) AM_DEVWRITE("earom", atari_vg_earom_w)
AM_RANGE(0x1800, 0x1800) AM_DEVWRITE("earom", atari_vg_earom_ctrl_w)
@@ -345,7 +347,7 @@ static const pokey_interface pokey_interface_2 =
};
-static MACHINE_CONFIG_START( runaway, driver_device )
+static MACHINE_CONFIG_START( runaway, runaway_state )
/* basic machine hardware */
MCFG_CPU_ADD("maincpu", M6502, 12096000 / 8) /* ? */
diff --git a/src/mame/drivers/sbrkout.c b/src/mame/drivers/sbrkout.c
index 0c94c1644a2..3d0be888f41 100644
--- a/src/mame/drivers/sbrkout.c
+++ b/src/mame/drivers/sbrkout.c
@@ -44,6 +44,12 @@ public:
: driver_device(machine, config) { }
UINT8 *videoram;
+ emu_timer *scanline_timer;
+ emu_timer *pot_timer;
+ tilemap_t *bg_tilemap;
+ UINT8 sync2_value;
+ UINT8 pot_mask[2];
+ UINT8 pot_trigger[2];
};
@@ -62,23 +68,6 @@ public:
/*************************************
*
- * Globals
- *
- *************************************/
-
-static emu_timer *scanline_timer;
-static emu_timer *pot_timer;
-
-static tilemap_t *bg_tilemap;
-
-static UINT8 sync2_value;
-static UINT8 pot_mask[2];
-static UINT8 pot_trigger[2];
-
-
-
-/*************************************
- *
* Prototypes
*
*************************************/
@@ -99,18 +88,19 @@ static MACHINE_START( sbrkout )
sbrkout_state *state = machine->driver_data<sbrkout_state>();
UINT8 *videoram = state->videoram;
memory_set_bankptr(machine, "bank1", &videoram[0x380]);
- scanline_timer = timer_alloc(machine, scanline_callback, NULL);
- pot_timer = timer_alloc(machine, pot_trigger_callback, NULL);
+ state->scanline_timer = timer_alloc(machine, scanline_callback, NULL);
+ state->pot_timer = timer_alloc(machine, pot_trigger_callback, NULL);
- state_save_register_global(machine, sync2_value);
- state_save_register_global_array(machine, pot_mask);
- state_save_register_global_array(machine, pot_trigger);
+ state_save_register_global(machine, state->sync2_value);
+ state_save_register_global_array(machine, state->pot_mask);
+ state_save_register_global_array(machine, state->pot_trigger);
}
static MACHINE_RESET( sbrkout )
{
- timer_adjust_oneshot(scanline_timer, machine->primary_screen->time_until_pos(0), 0);
+ sbrkout_state *state = machine->driver_data<sbrkout_state>();
+ timer_adjust_oneshot(state->scanline_timer, machine->primary_screen->time_until_pos(0), 0);
}
@@ -141,14 +131,14 @@ static TIMER_CALLBACK( scanline_callback )
if (scanline == machine->primary_screen->visible_area().max_y + 1)
{
UINT8 potvalue = input_port_read(machine, "PADDLE");
- timer_adjust_oneshot(pot_timer, machine->primary_screen->time_until_pos(56 + (potvalue / 2), (potvalue % 2) * 128), 0);
+ timer_adjust_oneshot(state->pot_timer, machine->primary_screen->time_until_pos(56 + (potvalue / 2), (potvalue % 2) * 128), 0);
}
/* call us back in 4 scanlines */
scanline += 4;
if (scanline >= machine->primary_screen->height())
scanline = 0;
- timer_adjust_oneshot(scanline_timer, machine->primary_screen->time_until_pos(scanline), scanline);
+ timer_adjust_oneshot(state->scanline_timer, machine->primary_screen->time_until_pos(scanline), scanline);
}
@@ -167,6 +157,7 @@ static WRITE8_HANDLER( irq_ack_w )
static READ8_HANDLER( switches_r )
{
+ sbrkout_state *state = space->machine->driver_data<sbrkout_state>();
UINT8 result = 0xff;
/* DIP switches are selected by ADR0+ADR1 if ADR3 == 0 */
@@ -183,9 +174,9 @@ static READ8_HANDLER( switches_r )
if ((offset & 0x17) == 0x00)
result &= (input_port_read(space->machine, "SELECT") << 7) | 0x7f;
if ((offset & 0x17) == 0x04)
- result &= ((pot_trigger[0] & ~pot_mask[0]) << 7) | 0x7f;
+ result &= ((state->pot_trigger[0] & ~state->pot_mask[0]) << 7) | 0x7f;
if ((offset & 0x17) == 0x05)
- result &= ((pot_trigger[1] & ~pot_mask[1]) << 7) | 0x7f;
+ result &= ((state->pot_trigger[1] & ~state->pot_mask[1]) << 7) | 0x7f;
if ((offset & 0x17) == 0x06)
result &= input_port_read(space->machine, "SERVE");
if ((offset & 0x17) == 0x07)
@@ -197,7 +188,8 @@ static READ8_HANDLER( switches_r )
static void update_nmi_state(running_machine *machine)
{
- if ((pot_trigger[0] & ~pot_mask[0]) | (pot_trigger[1] & ~pot_mask[1]))
+ sbrkout_state *state = machine->driver_data<sbrkout_state>();
+ if ((state->pot_trigger[0] & ~state->pot_mask[0]) | (state->pot_trigger[1] & ~state->pot_mask[1]))
cputag_set_input_line(machine, "maincpu", INPUT_LINE_NMI, ASSERT_LINE);
else
cputag_set_input_line(machine, "maincpu", INPUT_LINE_NMI, CLEAR_LINE);
@@ -206,23 +198,26 @@ static void update_nmi_state(running_machine *machine)
static TIMER_CALLBACK( pot_trigger_callback )
{
- pot_trigger[param] = 1;
+ sbrkout_state *state = machine->driver_data<sbrkout_state>();
+ state->pot_trigger[param] = 1;
update_nmi_state(machine);
}
static WRITE8_HANDLER( pot_mask1_w )
{
- pot_mask[0] = ~offset & 1;
- pot_trigger[0] = 0;
+ sbrkout_state *state = space->machine->driver_data<sbrkout_state>();
+ state->pot_mask[0] = ~offset & 1;
+ state->pot_trigger[0] = 0;
update_nmi_state(space->machine);
}
static WRITE8_HANDLER( pot_mask2_w )
{
- pot_mask[1] = ~offset & 1;
- pot_trigger[1] = 0;
+ sbrkout_state *state = space->machine->driver_data<sbrkout_state>();
+ state->pot_mask[1] = ~offset & 1;
+ state->pot_trigger[1] = 0;
update_nmi_state(space->machine);
}
@@ -273,15 +268,17 @@ static WRITE8_HANDLER( coincount_w )
static READ8_HANDLER( sync_r )
{
+ sbrkout_state *state = space->machine->driver_data<sbrkout_state>();
int hpos = space->machine->primary_screen->hpos();
- sync2_value = (hpos >= 128 && hpos <= space->machine->primary_screen->visible_area().max_x);
+ state->sync2_value = (hpos >= 128 && hpos <= space->machine->primary_screen->visible_area().max_x);
return space->machine->primary_screen->vpos();
}
static READ8_HANDLER( sync2_r )
{
- return (sync2_value << 7) | 0x7f;
+ sbrkout_state *state = space->machine->driver_data<sbrkout_state>();
+ return (state->sync2_value << 7) | 0x7f;
}
@@ -303,7 +300,8 @@ static TILE_GET_INFO( get_bg_tile_info )
static VIDEO_START( sbrkout )
{
- bg_tilemap = tilemap_create(machine, get_bg_tile_info, tilemap_scan_rows, 8, 8, 32, 32);
+ sbrkout_state *state = machine->driver_data<sbrkout_state>();
+ state->bg_tilemap = tilemap_create(machine, get_bg_tile_info, tilemap_scan_rows, 8, 8, 32, 32);
}
@@ -312,7 +310,7 @@ static WRITE8_HANDLER( sbrkout_videoram_w )
sbrkout_state *state = space->machine->driver_data<sbrkout_state>();
UINT8 *videoram = state->videoram;
videoram[offset] = data;
- tilemap_mark_tile_dirty(bg_tilemap, offset);
+ tilemap_mark_tile_dirty(state->bg_tilemap, offset);
}
@@ -329,7 +327,7 @@ static VIDEO_UPDATE( sbrkout )
UINT8 *videoram = state->videoram;
int ball;
- tilemap_draw(bitmap, cliprect, bg_tilemap, 0, 0);
+ tilemap_draw(bitmap, cliprect, state->bg_tilemap, 0, 0);
for (ball = 2; ball >= 0; ball--)
{
diff --git a/src/mame/drivers/shuuz.c b/src/mame/drivers/shuuz.c
index 6d920f81093..2fb57ae012e 100644
--- a/src/mame/drivers/shuuz.c
+++ b/src/mame/drivers/shuuz.c
@@ -93,8 +93,8 @@ static WRITE16_HANDLER( latch_w )
static READ16_HANDLER( leta_r )
{
+ shuuz_state *state = space->machine->driver_data<shuuz_state>();
/* trackball -- rotated 45 degrees? */
- static int cur[2];
int which = offset & 1;
/* when reading the even ports, do a real analog port update */
@@ -103,12 +103,12 @@ static READ16_HANDLER( leta_r )
int dx = (INT8)input_port_read(space->machine, "TRACKX");
int dy = (INT8)input_port_read(space->machine, "TRACKY");
- cur[0] = dx + dy;
- cur[1] = dx - dy;
+ state->cur[0] = dx + dy;
+ state->cur[1] = dx - dy;
}
/* clip the result to -0x3f to +0x3f to remove directional ambiguities */
- return cur[which];
+ return state->cur[which];
}
diff --git a/src/mame/drivers/skydiver.c b/src/mame/drivers/skydiver.c
index 834591ba2c4..108c7e38d22 100644
--- a/src/mame/drivers/skydiver.c
+++ b/src/mame/drivers/skydiver.c
@@ -94,7 +94,6 @@
#define MASTER_CLOCK (XTAL_12_096MHz)
-static int skydiver_nmion;
@@ -141,22 +140,24 @@ static PALETTE_INIT( skydiver )
static WRITE8_HANDLER( skydiver_nmion_w )
{
- skydiver_nmion = offset;
+ skydiver_state *state = space->machine->driver_data<skydiver_state>();
+ state->nmion = offset;
}
static INTERRUPT_GEN( skydiver_interrupt )
{
+ skydiver_state *state = device->machine->driver_data<skydiver_state>();
device_t *discrete = device->machine->device("discrete");
/* Convert range data to divide value and write to sound */
- discrete_sound_w(discrete, SKYDIVER_RANGE_DATA, (0x01 << (~skydiver_videoram[0x394] & 0x07)) & 0xff); // Range 0-2
+ discrete_sound_w(discrete, SKYDIVER_RANGE_DATA, (0x01 << (~state->videoram[0x394] & 0x07)) & 0xff); // Range 0-2
- discrete_sound_w(discrete, SKYDIVER_RANGE3_EN, skydiver_videoram[0x394] & 0x08); // Range 3 - note disable
- discrete_sound_w(discrete, SKYDIVER_NOTE_DATA, ~skydiver_videoram[0x395] & 0xff); // Note - freq
- discrete_sound_w(discrete, SKYDIVER_NOISE_DATA, skydiver_videoram[0x396] & 0x0f); // NAM - Noise Amplitude
+ discrete_sound_w(discrete, SKYDIVER_RANGE3_EN, state->videoram[0x394] & 0x08); // Range 3 - note disable
+ discrete_sound_w(discrete, SKYDIVER_NOTE_DATA, ~state->videoram[0x395] & 0xff); // Note - freq
+ discrete_sound_w(discrete, SKYDIVER_NOISE_DATA, state->videoram[0x396] & 0x0f); // NAM - Noise Amplitude
- if (skydiver_nmion)
+ if (state->nmion)
cpu_set_input_line(device, INPUT_LINE_NMI, PULSE_LINE);
}
@@ -190,7 +191,7 @@ static ADDRESS_MAP_START( skydiver_map, ADDRESS_SPACE_PROGRAM, 8 )
ADDRESS_MAP_GLOBAL_MASK(0x7fff)
AM_RANGE(0x0000, 0x007f) AM_MIRROR(0x4300) AM_READWRITE(skydiver_wram_r, skydiver_wram_w)
AM_RANGE(0x0080, 0x00ff) AM_MIRROR(0x4000) AM_RAM /* RAM B1 */
- AM_RANGE(0x0400, 0x07ff) AM_MIRROR(0x4000) AM_RAM_WRITE(skydiver_videoram_w) AM_BASE(&skydiver_videoram) /* RAMs K1,M1,P1,J1,N1,K/L1,L1,H/J1 */
+ AM_RANGE(0x0400, 0x07ff) AM_MIRROR(0x4000) AM_RAM_WRITE(skydiver_videoram_w) AM_BASE_MEMBER(skydiver_state, videoram) /* RAMs K1,M1,P1,J1,N1,K/L1,L1,H/J1 */
AM_RANGE(0x0800, 0x0801) AM_MIRROR(0x47f0) AM_WRITE(skydiver_lamp_s_w)
AM_RANGE(0x0802, 0x0803) AM_MIRROR(0x47f0) AM_WRITE(skydiver_lamp_k_w)
AM_RANGE(0x0804, 0x0805) AM_MIRROR(0x47f0) AM_WRITE(skydiver_start_lamp_1_w)
@@ -371,7 +372,7 @@ GFXDECODE_END
*
*************************************/
-static MACHINE_CONFIG_START( skydiver, driver_device )
+static MACHINE_CONFIG_START( skydiver, skydiver_state )
/* basic machine hardware */
MCFG_CPU_ADD("maincpu", M6800,MASTER_CLOCK/16) /* ???? */
diff --git a/src/mame/drivers/sprint2.c b/src/mame/drivers/sprint2.c
index d730e14b73f..32184c976c3 100644
--- a/src/mame/drivers/sprint2.c
+++ b/src/mame/drivers/sprint2.c
@@ -22,34 +22,34 @@
#include "includes/sprint2.h"
#include "sound/discrete.h"
-#define GAME_IS_SPRINT1 (game == 1)
-#define GAME_IS_SPRINT2 (game == 2)
-#define GAME_IS_DOMINOS (game == 3)
+#define GAME_IS_SPRINT1 (state->game == 1)
+#define GAME_IS_SPRINT2 (state->game == 2)
+#define GAME_IS_DOMINOS (state->game == 3)
-static int attract;
-static int steering[2];
-static int gear[2];
-static int game;
static DRIVER_INIT( sprint1 )
{
- game = 1;
+ sprint2_state *state = machine->driver_data<sprint2_state>();
+ state->game = 1;
}
static DRIVER_INIT( sprint2 )
{
- game = 2;
+ sprint2_state *state = machine->driver_data<sprint2_state>();
+ state->game = 2;
}
static DRIVER_INIT( dominos )
{
- game = 3;
+ sprint2_state *state = machine->driver_data<sprint2_state>();
+ state->game = 3;
}
static int service_mode(running_machine *machine)
{
+ sprint2_state *state = machine->driver_data<sprint2_state>();
UINT8 v = input_port_read(machine, "INB");
if (GAME_IS_SPRINT1)
@@ -71,10 +71,10 @@ static int service_mode(running_machine *machine)
static INTERRUPT_GEN( sprint2 )
{
+ sprint2_state *state = device->machine->driver_data<sprint2_state>();
device_t *discrete = device->machine->device("discrete");
- static UINT8 dial[2];
- /* handle steering wheels */
+ /* handle state->steering wheels */
if (GAME_IS_SPRINT1 || GAME_IS_SPRINT2)
{
@@ -82,32 +82,32 @@ static INTERRUPT_GEN( sprint2 )
for (i = 0; i < 2; i++)
{
- signed char delta = input_port_read(device->machine, i ? "DIAL_P2" : "DIAL_P1") - dial[i];
+ signed char delta = input_port_read(device->machine, i ? "DIAL_P2" : "DIAL_P1") - state->dial[i];
if (delta < 0)
{
- steering[i] = 0x00;
+ state->steering[i] = 0x00;
}
if (delta > 0)
{
- steering[i] = 0x40;
+ state->steering[i] = 0x40;
}
- dial[i] += delta;
+ state->dial[i] += delta;
switch (input_port_read(device->machine, i ? "GEAR_P2" : "GEAR_P1") & 15)
{
- case 1: gear[i] = 1; break;
- case 2: gear[i] = 2; break;
- case 4: gear[i] = 3; break;
- case 8: gear[i] = 4; break;
+ case 1: state->gear[i] = 1; break;
+ case 2: state->gear[i] = 2; break;
+ case 4: state->gear[i] = 3; break;
+ case 8: state->gear[i] = 4; break;
}
}
}
- discrete_sound_w(discrete, SPRINT2_MOTORSND1_DATA, sprint2_video_ram[0x394] & 15); // also DOMINOS_FREQ_DATA
- discrete_sound_w(discrete, SPRINT2_MOTORSND2_DATA, sprint2_video_ram[0x395] & 15);
- discrete_sound_w(discrete, SPRINT2_CRASHSND_DATA, sprint2_video_ram[0x396] & 15); // also DOMINOS_AMP_DATA
+ discrete_sound_w(discrete, SPRINT2_MOTORSND1_DATA, state->video_ram[0x394] & 15); // also DOMINOS_FREQ_DATA
+ discrete_sound_w(discrete, SPRINT2_MOTORSND2_DATA, state->video_ram[0x395] & 15);
+ discrete_sound_w(discrete, SPRINT2_CRASHSND_DATA, state->video_ram[0x396] & 15); // also DOMINOS_AMP_DATA
/* interrupts and watchdog are disabled during service mode */
@@ -120,7 +120,8 @@ static INTERRUPT_GEN( sprint2 )
static READ8_HANDLER( sprint2_wram_r )
{
- return sprint2_video_ram[0x380 + offset % 0x80];
+ sprint2_state *state = space->machine->driver_data<sprint2_state>();
+ return state->video_ram[0x380 + offset % 0x80];
}
@@ -132,16 +133,17 @@ static READ8_HANDLER( sprint2_dip_r )
static READ8_HANDLER( sprint2_input_A_r )
{
+ sprint2_state *state = space->machine->driver_data<sprint2_state>();
UINT8 val = input_port_read(space->machine, "INA");
if (GAME_IS_SPRINT2)
{
- if (gear[0] == 1) val &= ~0x01;
- if (gear[1] == 1) val &= ~0x02;
- if (gear[0] == 2) val &= ~0x04;
- if (gear[1] == 2) val &= ~0x08;
- if (gear[0] == 3) val &= ~0x10;
- if (gear[1] == 3) val &= ~0x20;
+ if (state->gear[0] == 1) val &= ~0x01;
+ if (state->gear[1] == 1) val &= ~0x02;
+ if (state->gear[0] == 2) val &= ~0x04;
+ if (state->gear[1] == 2) val &= ~0x08;
+ if (state->gear[0] == 3) val &= ~0x10;
+ if (state->gear[1] == 3) val &= ~0x20;
}
return (val << (offset ^ 7)) & 0x80;
@@ -150,13 +152,14 @@ static READ8_HANDLER( sprint2_input_A_r )
static READ8_HANDLER( sprint2_input_B_r )
{
+ sprint2_state *state = space->machine->driver_data<sprint2_state>();
UINT8 val = input_port_read(space->machine, "INB");
if (GAME_IS_SPRINT1)
{
- if (gear[0] == 1) val &= ~0x01;
- if (gear[0] == 2) val &= ~0x02;
- if (gear[0] == 3) val &= ~0x04;
+ if (state->gear[0] == 1) val &= ~0x01;
+ if (state->gear[0] == 2) val &= ~0x02;
+ if (state->gear[0] == 3) val &= ~0x04;
}
return (val << (offset ^ 7)) & 0x80;
@@ -165,9 +168,10 @@ static READ8_HANDLER( sprint2_input_B_r )
static READ8_HANDLER( sprint2_sync_r )
{
+ sprint2_state *state = space->machine->driver_data<sprint2_state>();
UINT8 val = 0;
- if (attract != 0)
+ if (state->attract != 0)
val |= 0x10;
if (space->machine->primary_screen->vpos() == 261)
@@ -185,36 +189,42 @@ static READ8_HANDLER( sprint2_sync_r )
static READ8_HANDLER( sprint2_steering1_r )
{
- return steering[0];
+ sprint2_state *state = space->machine->driver_data<sprint2_state>();
+ return state->steering[0];
}
static READ8_HANDLER( sprint2_steering2_r )
{
- return steering[1];
+ sprint2_state *state = space->machine->driver_data<sprint2_state>();
+ return state->steering[1];
}
static WRITE8_HANDLER( sprint2_steering_reset1_w )
{
- steering[0] |= 0x80;
+ sprint2_state *state = space->machine->driver_data<sprint2_state>();
+ state->steering[0] |= 0x80;
}
static WRITE8_HANDLER( sprint2_steering_reset2_w )
{
- steering[1] |= 0x80;
+ sprint2_state *state = space->machine->driver_data<sprint2_state>();
+ state->steering[1] |= 0x80;
}
static WRITE8_HANDLER( sprint2_wram_w )
{
- sprint2_video_ram[0x380 + offset % 0x80] = data;
+ sprint2_state *state = space->machine->driver_data<sprint2_state>();
+ state->video_ram[0x380 + offset % 0x80] = data;
}
static WRITE8_DEVICE_HANDLER( sprint2_attract_w )
{
- attract = offset & 1;
+ sprint2_state *state = device->machine->driver_data<sprint2_state>();
+ state->attract = offset & 1;
// also DOMINOS_ATTRACT_EN
- discrete_sound_w(device, SPRINT2_ATTRACT_EN, attract);
+ discrete_sound_w(device, SPRINT2_ATTRACT_EN, state->attract);
}
@@ -248,7 +258,7 @@ static WRITE8_HANDLER( sprint2_lamp2_w )
static ADDRESS_MAP_START( sprint2_map, ADDRESS_SPACE_PROGRAM, 8 )
AM_RANGE(0x0000, 0x03ff) AM_READWRITE(sprint2_wram_r,sprint2_wram_w)
- AM_RANGE(0x0400, 0x07ff) AM_RAM_WRITE(sprint2_video_ram_w) AM_BASE(&sprint2_video_ram)
+ AM_RANGE(0x0400, 0x07ff) AM_RAM_WRITE(sprint2_video_ram_w) AM_BASE_MEMBER(sprint2_state, video_ram)
AM_RANGE(0x0818, 0x081f) AM_READ(sprint2_input_A_r)
AM_RANGE(0x0828, 0x082f) AM_READ(sprint2_input_B_r)
AM_RANGE(0x0830, 0x0837) AM_READ(sprint2_dip_r)
@@ -492,7 +502,7 @@ static GFXDECODE_START( sprint2 )
GFXDECODE_END
-static MACHINE_CONFIG_START( sprint2, driver_device )
+static MACHINE_CONFIG_START( sprint2, sprint2_state )
/* basic machine hardware */
MCFG_CPU_ADD("maincpu", M6502, 12096000 / 16)
diff --git a/src/mame/drivers/sprint4.c b/src/mame/drivers/sprint4.c
index af3c9d1aaa6..ed850873489 100644
--- a/src/mame/drivers/sprint4.c
+++ b/src/mame/drivers/sprint4.c
@@ -17,43 +17,37 @@ Atari Sprint 4 driver
#define PIXEL_CLOCK (MASTER_CLOCK / 2)
-
-static int da_latch;
-
-static int steer_FF1[4];
-static int steer_FF2[4];
-
-static int gear[4];
-
-
static CUSTOM_INPUT( get_lever )
{
+ sprint4_state *state = field->port->machine->driver_data<sprint4_state>();
int n = (FPTR) param;
- return 4 * gear[n] > da_latch;
+ return 4 * state->gear[n] > state->da_latch;
}
static CUSTOM_INPUT( get_wheel )
{
+ sprint4_state *state = field->port->machine->driver_data<sprint4_state>();
int n = (FPTR) param;
- return 8 * steer_FF1[n] + 8 * steer_FF2[n] > da_latch;
+ return 8 * state->steer_FF1[n] + 8 * state->steer_FF2[n] > state->da_latch;
}
static CUSTOM_INPUT( get_collision )
{
+ sprint4_state *state = field->port->machine->driver_data<sprint4_state>();
int n = (FPTR) param;
- return sprint4_collision[n];
+ return state->collision[n];
}
static TIMER_CALLBACK( nmi_callback )
{
+ sprint4_state *state = machine->driver_data<sprint4_state>();
int scanline = param;
- static UINT8 last_wheel[4];
/* MAME updates controls only once per frame but the game checks them on every NMI */
@@ -78,25 +72,25 @@ static TIMER_CALLBACK( nmi_callback )
for (i = 0; i < 4; i++)
{
- signed char delta = wheel[i] - last_wheel[i];
+ signed char delta = wheel[i] - state->last_wheel[i];
if (delta < 0)
{
- steer_FF2[i] = 0;
+ state->steer_FF2[i] = 0;
}
if (delta > 0)
{
- steer_FF2[i] = 1;
+ state->steer_FF2[i] = 1;
}
- steer_FF1[i] = (wheel[i] >> 4) & 1;
+ state->steer_FF1[i] = (wheel[i] >> 4) & 1;
- if (lever[i] & 1) { gear[i] = 1; }
- if (lever[i] & 2) { gear[i] = 2; }
- if (lever[i] & 4) { gear[i] = 3; }
- if (lever[i] & 8) { gear[i] = 4; }
+ if (lever[i] & 1) { state->gear[i] = 1; }
+ if (lever[i] & 2) { state->gear[i] = 2; }
+ if (lever[i] & 4) { state->gear[i] = 3; }
+ if (lever[i] & 8) { state->gear[i] = 4; }
- last_wheel[i] = wheel[i];
+ state->last_wheel[i] = wheel[i];
}
scanline += 64;
@@ -119,17 +113,18 @@ static TIMER_CALLBACK( nmi_callback )
static MACHINE_RESET( sprint4 )
{
+ sprint4_state *state = machine->driver_data<sprint4_state>();
timer_set(machine, machine->primary_screen->time_until_pos(32), NULL, 32, nmi_callback);
- memset(steer_FF1, 0, sizeof steer_FF1);
- memset(steer_FF2, 0, sizeof steer_FF2);
+ memset(state->steer_FF1, 0, sizeof state->steer_FF1);
+ memset(state->steer_FF2, 0, sizeof state->steer_FF2);
- gear[0] = 1;
- gear[1] = 1;
- gear[2] = 1;
- gear[3] = 1;
+ state->gear[0] = 1;
+ state->gear[1] = 1;
+ state->gear[2] = 1;
+ state->gear[3] = 1;
- da_latch = 0;
+ state->da_latch = 0;
}
@@ -171,13 +166,15 @@ static WRITE8_HANDLER( sprint4_wram_w )
static WRITE8_HANDLER( sprint4_collision_reset_w )
{
- sprint4_collision[(offset >> 1) & 3] = 0;
+ sprint4_state *state = space->machine->driver_data<sprint4_state>();
+ state->collision[(offset >> 1) & 3] = 0;
}
static WRITE8_HANDLER( sprint4_da_latch_w )
{
- da_latch = data & 15;
+ sprint4_state *state = space->machine->driver_data<sprint4_state>();
+ state->da_latch = data & 15;
}
diff --git a/src/mame/drivers/sprint8.c b/src/mame/drivers/sprint8.c
index c04d745e564..afc8838d806 100644
--- a/src/mame/drivers/sprint8.c
+++ b/src/mame/drivers/sprint8.c
@@ -8,27 +8,24 @@ Atari Sprint 8 driver
#include "cpu/m6800/m6800.h"
#include "includes/sprint8.h"
-static int steer_dir[8];
-static int steer_flag[8];
-static int collision_reset;
-static int collision_index;
void sprint8_set_collision(running_machine *machine, int n)
{
- if (collision_reset == 0)
+ sprint8_state *state = machine->driver_data<sprint8_state>();
+ if (state->collision_reset == 0)
{
cputag_set_input_line(machine, "maincpu", 0, ASSERT_LINE);
- collision_index = n;
+ state->collision_index = n;
}
}
static TIMER_DEVICE_CALLBACK( input_callback )
{
- static UINT8 dial[8];
+ sprint8_state *state = timer.machine->driver_data<sprint8_state>();
static const char *const dialnames[] = { "DIAL1", "DIAL2", "DIAL3", "DIAL4", "DIAL5", "DIAL6", "DIAL7", "DIAL8" };
int i;
@@ -37,47 +34,50 @@ static TIMER_DEVICE_CALLBACK( input_callback )
{
UINT8 val = input_port_read(timer.machine, dialnames[i]) >> 4;
- signed char delta = (val - dial[i]) & 15;
+ signed char delta = (val - state->dial[i]) & 15;
if (delta & 8)
delta |= 0xf0; /* extend sign to 8 bits */
- steer_flag[i] = (delta != 0);
+ state->steer_flag[i] = (delta != 0);
if (delta > 0)
- steer_dir[i] = 0;
+ state->steer_dir[i] = 0;
if (delta < 0)
- steer_dir[i] = 1;
+ state->steer_dir[i] = 1;
- dial[i] = val;
+ state->dial[i] = val;
}
}
static MACHINE_RESET( sprint8 )
{
- collision_reset = 0;
- collision_index = 0;
+ sprint8_state *state = machine->driver_data<sprint8_state>();
+ state->collision_reset = 0;
+ state->collision_index = 0;
}
static READ8_HANDLER( sprint8_collision_r )
{
- return collision_index;
+ sprint8_state *state = space->machine->driver_data<sprint8_state>();
+ return state->collision_index;
}
static READ8_HANDLER( sprint8_input_r )
{
+ sprint8_state *state = space->machine->driver_data<sprint8_state>();
static const char *const portnames[] = { "P1", "P2", "P3", "P4", "P5", "P6", "P7", "P8" };
UINT8 val = input_port_read(space->machine, portnames[offset]);
- if (steer_dir[offset])
+ if (state->steer_dir[offset])
{
val |= 0x02;
}
- if (steer_flag[offset])
+ if (state->steer_flag[offset])
{
val |= 0x04;
}
@@ -94,31 +94,32 @@ static WRITE8_HANDLER( sprint8_lockout_w )
static WRITE8_HANDLER( sprint8_int_reset_w )
{
- collision_reset = !(data & 1);
+ sprint8_state *state = space->machine->driver_data<sprint8_state>();
+ state->collision_reset = !(data & 1);
- if (collision_reset)
+ if (state->collision_reset)
cputag_set_input_line(space->machine, "maincpu", 0, CLEAR_LINE);
}
static ADDRESS_MAP_START( sprint8_map, ADDRESS_SPACE_PROGRAM, 8 )
AM_RANGE(0x0000, 0x00ff) AM_RAM
- AM_RANGE(0x1800, 0x1bff) AM_RAM_WRITE(sprint8_video_ram_w) AM_BASE(&sprint8_video_ram)
+ AM_RANGE(0x1800, 0x1bff) AM_RAM_WRITE(sprint8_video_ram_w) AM_BASE_MEMBER(sprint8_state, video_ram)
AM_RANGE(0x1c00, 0x1c00) AM_READ(sprint8_collision_r)
AM_RANGE(0x1c01, 0x1c08) AM_READ(sprint8_input_r)
AM_RANGE(0x1c09, 0x1c09) AM_READ_PORT("IN0")
AM_RANGE(0x1c0a, 0x1c0a) AM_READ_PORT("IN1")
AM_RANGE(0x1c0f, 0x1c0f) AM_READ_PORT("VBLANK")
- AM_RANGE(0x1c00, 0x1c0f) AM_WRITEONLY AM_BASE(&sprint8_pos_h_ram)
- AM_RANGE(0x1c10, 0x1c1f) AM_WRITEONLY AM_BASE(&sprint8_pos_v_ram)
- AM_RANGE(0x1c20, 0x1c2f) AM_WRITEONLY AM_BASE(&sprint8_pos_d_ram)
+ AM_RANGE(0x1c00, 0x1c0f) AM_WRITEONLY AM_BASE_MEMBER(sprint8_state, pos_h_ram)
+ AM_RANGE(0x1c10, 0x1c1f) AM_WRITEONLY AM_BASE_MEMBER(sprint8_state, pos_v_ram)
+ AM_RANGE(0x1c20, 0x1c2f) AM_WRITEONLY AM_BASE_MEMBER(sprint8_state, pos_d_ram)
AM_RANGE(0x1c30, 0x1c37) AM_WRITE(sprint8_lockout_w)
AM_RANGE(0x1d00, 0x1d00) AM_WRITE(sprint8_int_reset_w)
AM_RANGE(0x1d01, 0x1d01) AM_DEVWRITE("discrete", sprint8_crash_w)
AM_RANGE(0x1d02, 0x1d02) AM_DEVWRITE("discrete", sprint8_screech_w)
AM_RANGE(0x1d03, 0x1d03) AM_WRITENOP
AM_RANGE(0x1d04, 0x1d04) AM_WRITENOP
- AM_RANGE(0x1d05, 0x1d05) AM_WRITEONLY AM_BASE(&sprint8_team)
+ AM_RANGE(0x1d05, 0x1d05) AM_WRITEONLY AM_BASE_MEMBER(sprint8_state, team)
AM_RANGE(0x1d06, 0x1d06) AM_DEVWRITE("discrete", sprint8_attract_w)
AM_RANGE(0x1e00, 0x1e07) AM_DEVWRITE("discrete", sprint8_motor_w)
AM_RANGE(0x1f00, 0x1f00) AM_WRITENOP /* probably a watchdog, disabled in service mode */
@@ -452,7 +453,7 @@ static GFXDECODE_START( sprint8 )
GFXDECODE_END
-static MACHINE_CONFIG_START( sprint8, driver_device )
+static MACHINE_CONFIG_START( sprint8, sprint8_state )
/* basic machine hardware */
MCFG_CPU_ADD("maincpu", M6800, 11055000 / 11) /* ? */
diff --git a/src/mame/drivers/starshp1.c b/src/mame/drivers/starshp1.c
index 6e6ca14e481..0ddd16c5096 100644
--- a/src/mame/drivers/starshp1.c
+++ b/src/mame/drivers/starshp1.c
@@ -11,9 +11,7 @@ Atari Starship 1 driver
#include "cpu/m6502/m6502.h"
#include "includes/starshp1.h"
-int starshp1_attract;
-static int starshp1_analog_in_select;
static INTERRUPT_GEN( starshp1_interrupt )
@@ -25,16 +23,17 @@ static INTERRUPT_GEN( starshp1_interrupt )
static WRITE8_DEVICE_HANDLER( starshp1_audio_w )
{
+ starshp1_state *state = device->machine->driver_data<starshp1_state>();
data &= 1;
switch (offset & 7)
{
case 0:
- starshp1_attract = data;
+ state->attract = data;
discrete_sound_w(device, STARSHP1_ATTRACT, data);
break;
case 1:
- starshp1_phasor = data;
+ state->phasor = data;
discrete_sound_w(device, STARSHP1_PHASOR_ON, data);
break;
case 2:
@@ -54,22 +53,24 @@ static WRITE8_DEVICE_HANDLER( starshp1_audio_w )
break;
}
- coin_lockout_w(device->machine, 0, !starshp1_attract);
- coin_lockout_w(device->machine, 1, !starshp1_attract);
+ coin_lockout_w(device->machine, 0, !state->attract);
+ coin_lockout_w(device->machine, 1, !state->attract);
}
static WRITE8_HANDLER( starshp1_collision_reset_w )
{
- starshp1_collision_latch = 0;
+ starshp1_state *state = space->machine->driver_data<starshp1_state>();
+ state->collision_latch = 0;
}
static CUSTOM_INPUT( starshp1_analog_r )
{
+ starshp1_state *state = field->port->machine->driver_data<starshp1_state>();
int val = 0;
- switch (starshp1_analog_in_select)
+ switch (state->analog_in_select)
{
case 0:
val = input_port_read(field->port->machine, "STICKY");
@@ -91,22 +92,25 @@ static CUSTOM_INPUT( starshp1_analog_r )
static CUSTOM_INPUT( collision_latch_r )
{
- return starshp1_collision_latch & 0x0f;
+ starshp1_state *state = field->port->machine->driver_data<starshp1_state>();
+ return state->collision_latch & 0x0f;
}
static WRITE8_HANDLER( starshp1_analog_in_w )
{
- starshp1_analog_in_select = offset & 3;
+ starshp1_state *state = space->machine->driver_data<starshp1_state>();
+ state->analog_in_select = offset & 3;
}
static WRITE8_DEVICE_HANDLER( starshp1_analog_out_w )
{
+ starshp1_state *state = device->machine->driver_data<starshp1_state>();
switch (offset & 7)
{
case 1:
- starshp1_ship_size = data;
+ state->ship_size = data;
break;
case 2:
discrete_sound_w(device, STARSHP1_NOISE_AMPLITUDE, data);
@@ -118,13 +122,13 @@ static WRITE8_DEVICE_HANDLER( starshp1_analog_out_w )
discrete_sound_w(device, STARSHP1_MOTOR_SPEED, data);
break;
case 5:
- starshp1_circle_hpos = data;
+ state->circle_hpos = data;
break;
case 6:
- starshp1_circle_vpos = data;
+ state->circle_vpos = data;
break;
case 7:
- starshp1_circle_size = data;
+ state->circle_size = data;
break;
}
}
@@ -132,30 +136,31 @@ static WRITE8_DEVICE_HANDLER( starshp1_analog_out_w )
static WRITE8_HANDLER( starshp1_misc_w )
{
+ starshp1_state *state = space->machine->driver_data<starshp1_state>();
data &= 1;
switch (offset & 7)
{
case 0:
- starshp1_ship_explode = data;
+ state->ship_explode = data;
break;
case 1:
- starshp1_circle_mod = data;
+ state->circle_mod = data;
break;
case 2:
- starshp1_circle_kill = !data;
+ state->circle_kill = !data;
break;
case 3:
- starshp1_starfield_kill = data;
+ state->starfield_kill = data;
break;
case 4:
- starshp1_inverse = data;
+ state->inverse = data;
break;
case 5:
/* BLACK HOLE, not used */
break;
case 6:
- starshp1_mux = data;
+ state->mux = data;
break;
case 7:
set_led_status(space->machine, 0, !data);
@@ -172,10 +177,10 @@ static ADDRESS_MAP_START( starshp1_map, ADDRESS_SPACE_PROGRAM, 8 )
AM_RANGE(0xc300, 0xc3ff) AM_WRITE(starshp1_sspic_w) /* spaceship picture */
AM_RANGE(0xc400, 0xc400) AM_READ_PORT("COINAGE")
AM_RANGE(0xc400, 0xc4ff) AM_WRITE(starshp1_ssadd_w) /* spaceship address */
- AM_RANGE(0xc800, 0xc9ff) AM_RAM_WRITE(starshp1_playfield_w) AM_BASE(&starshp1_playfield_ram)
- AM_RANGE(0xcc00, 0xcc0f) AM_WRITEONLY AM_BASE(&starshp1_hpos_ram)
- AM_RANGE(0xd000, 0xd00f) AM_WRITEONLY AM_BASE(&starshp1_vpos_ram)
- AM_RANGE(0xd400, 0xd40f) AM_WRITEONLY AM_BASE(&starshp1_obj_ram)
+ AM_RANGE(0xc800, 0xc9ff) AM_RAM_WRITE(starshp1_playfield_w) AM_BASE_MEMBER(starshp1_state, playfield_ram)
+ AM_RANGE(0xcc00, 0xcc0f) AM_WRITEONLY AM_BASE_MEMBER(starshp1_state, hpos_ram)
+ AM_RANGE(0xd000, 0xd00f) AM_WRITEONLY AM_BASE_MEMBER(starshp1_state, vpos_ram)
+ AM_RANGE(0xd400, 0xd40f) AM_WRITEONLY AM_BASE_MEMBER(starshp1_state, obj_ram)
AM_RANGE(0xd800, 0xd800) AM_READ(starshp1_rng_r)
AM_RANGE(0xd800, 0xd80f) AM_WRITE(starshp1_collision_reset_w)
AM_RANGE(0xdc00, 0xdc0f) AM_WRITE(starshp1_misc_w)
@@ -293,7 +298,7 @@ static GFXDECODE_START( starshp1 )
GFXDECODE_END
-static MACHINE_CONFIG_START( starshp1, driver_device )
+static MACHINE_CONFIG_START( starshp1, starshp1_state )
/* basic machine hardware */
diff --git a/src/mame/drivers/starwars.c b/src/mame/drivers/starwars.c
index 7c16854425f..43e4303c94f 100644
--- a/src/mame/drivers/starwars.c
+++ b/src/mame/drivers/starwars.c
@@ -35,15 +35,6 @@
#define MASTER_CLOCK (12096000)
#define CLOCK_3KHZ (MASTER_CLOCK / 4096)
-UINT8 starwars_is_esb;
-
-/* Local variables */
-static UINT8 *slapstic_source;
-static UINT8 *slapstic_base;
-static UINT8 slapstic_current_bank;
-static offs_t slapstic_last_pc;
-static offs_t slapstic_last_address;
-
/*************************************
@@ -54,22 +45,23 @@ static offs_t slapstic_last_address;
static MACHINE_RESET( starwars )
{
+ starwars_state *state = machine->driver_data<starwars_state>();
/* ESB-specific */
- if (starwars_is_esb)
+ if (state->is_esb)
{
address_space *space = cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM);
/* reset the slapstic */
slapstic_reset();
- slapstic_current_bank = slapstic_bank();
- memcpy(slapstic_base, &slapstic_source[slapstic_current_bank * 0x2000], 0x2000);
+ state->slapstic_current_bank = slapstic_bank();
+ memcpy(state->slapstic_base, &state->slapstic_source[state->slapstic_current_bank * 0x2000], 0x2000);
/* reset all the banks */
starwars_out_w(space, 4, 0);
}
/* reset the matrix processor */
- starwars_mproc_reset();
+ starwars_mproc_reset(machine);
}
@@ -95,20 +87,22 @@ static WRITE8_HANDLER( irq_ack_w )
static void esb_slapstic_tweak(address_space *space, offs_t offset)
{
+ starwars_state *state = space->machine->driver_data<starwars_state>();
int new_bank = slapstic_tweak(space, offset);
/* update for the new bank */
- if (new_bank != slapstic_current_bank)
+ if (new_bank != state->slapstic_current_bank)
{
- slapstic_current_bank = new_bank;
- memcpy(slapstic_base, &slapstic_source[slapstic_current_bank * 0x2000], 0x2000);
+ state->slapstic_current_bank = new_bank;
+ memcpy(state->slapstic_base, &state->slapstic_source[state->slapstic_current_bank * 0x2000], 0x2000);
}
}
static READ8_HANDLER( esb_slapstic_r )
{
- int result = slapstic_base[offset];
+ starwars_state *state = space->machine->driver_data<starwars_state>();
+ int result = state->slapstic_base[offset];
esb_slapstic_tweak(space, offset);
return result;
}
@@ -129,6 +123,7 @@ static WRITE8_HANDLER( esb_slapstic_w )
DIRECT_UPDATE_HANDLER( esb_setdirect )
{
+ starwars_state *state = machine->driver_data<starwars_state>();
/* if we are in the slapstic region, process it */
if ((address & 0xe000) == 0x8000)
{
@@ -139,10 +134,10 @@ DIRECT_UPDATE_HANDLER( esb_setdirect )
1. Because we have read/write handlers backing the current address
2. Because the CPU core executed a jump to a new address
*/
- if (pc != slapstic_last_pc || address != slapstic_last_address)
+ if (pc != state->slapstic_last_pc || address != state->slapstic_last_address)
{
- slapstic_last_pc = pc;
- slapstic_last_address = address;
+ state->slapstic_last_pc = pc;
+ state->slapstic_last_address = address;
esb_slapstic_tweak(&direct.space(), address & 0x1fff);
}
return ~0;
@@ -182,7 +177,7 @@ static ADDRESS_MAP_START( main_map, ADDRESS_SPACE_PROGRAM, 8 )
AM_RANGE(0x4701, 0x4701) AM_READ(starwars_div_rel_r)
AM_RANGE(0x4703, 0x4703) AM_READ(starwars_prng_r) /* pseudo random number generator */
AM_RANGE(0x4800, 0x4fff) AM_RAM /* CPU and Math RAM */
- AM_RANGE(0x5000, 0x5fff) AM_RAM AM_BASE(&starwars_mathram) /* CPU and Math RAM */
+ AM_RANGE(0x5000, 0x5fff) AM_RAM AM_BASE_MEMBER(starwars_state, mathram) /* CPU and Math RAM */
AM_RANGE(0x6000, 0x7fff) AM_ROMBANK("bank1") /* banked ROM */
AM_RANGE(0x8000, 0xffff) AM_ROM /* rest of main_rom */
ADDRESS_MAP_END
@@ -321,7 +316,7 @@ INPUT_PORTS_END
*
*************************************/
-static MACHINE_CONFIG_START( starwars, driver_device )
+static MACHINE_CONFIG_START( starwars, starwars_state )
/* basic machine hardware */
MCFG_CPU_ADD("maincpu", M6809, MASTER_CLOCK / 8)
@@ -503,8 +498,9 @@ ROM_END
static DRIVER_INIT( starwars )
{
+ starwars_state *state = machine->driver_data<starwars_state>();
/* prepare the mathbox */
- starwars_is_esb = 0;
+ state->is_esb = 0;
starwars_mproc_init(machine);
/* initialize banking */
@@ -515,12 +511,13 @@ static DRIVER_INIT( starwars )
static DRIVER_INIT( esb )
{
+ starwars_state *state = machine->driver_data<starwars_state>();
UINT8 *rom = machine->region("maincpu")->base();
/* init the slapstic */
slapstic_init(machine, 101);
- slapstic_source = &rom[0x14000];
- slapstic_base = &rom[0x08000];
+ state->slapstic_source = &rom[0x14000];
+ state->slapstic_base = &rom[0x08000];
/* install an opcode base handler */
address_space *space = machine->device<m6809_device>("maincpu")->space(AS_PROGRAM);
@@ -533,7 +530,7 @@ static DRIVER_INIT( esb )
memory_install_read_bank(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0xa000, 0xffff, 0, 0, "bank2");
/* prepare the matrix processor */
- starwars_is_esb = 1;
+ state->is_esb = 1;
starwars_mproc_init(machine);
/* initialize banking */
@@ -543,9 +540,9 @@ static DRIVER_INIT( esb )
memory_set_bank(machine, "bank2", 0);
/* additional globals for state saving */
- state_save_register_global(machine, slapstic_current_bank);
- state_save_register_global(machine, slapstic_last_pc);
- state_save_register_global(machine, slapstic_last_address);
+ state_save_register_global(machine, state->slapstic_current_bank);
+ state_save_register_global(machine, state->slapstic_last_pc);
+ state_save_register_global(machine, state->slapstic_last_address);
}
diff --git a/src/mame/drivers/subs.c b/src/mame/drivers/subs.c
index c70465ae9e7..502733e5e2e 100644
--- a/src/mame/drivers/subs.c
+++ b/src/mame/drivers/subs.c
@@ -63,7 +63,7 @@ static ADDRESS_MAP_START( main_map, ADDRESS_SPACE_PROGRAM, 8 )
AM_RANGE(0x006a, 0x006b) AM_DEVWRITE("discrete", subs_crash_w)
AM_RANGE(0x006c, 0x006d) AM_WRITE(subs_invert1_w)
AM_RANGE(0x006e, 0x006f) AM_WRITE(subs_invert2_w)
- AM_RANGE(0x0090, 0x009f) AM_BASE_GENERIC(spriteram)
+ AM_RANGE(0x0090, 0x009f) AM_BASE_MEMBER(subs_state, spriteram)
AM_RANGE(0x0000, 0x01ff) AM_RAM
AM_RANGE(0x0800, 0x0bff) AM_RAM AM_BASE_MEMBER(subs_state, videoram)
AM_RANGE(0x2000, 0x3fff) AM_ROM
diff --git a/src/mame/drivers/tank8.c b/src/mame/drivers/tank8.c
index 99cc958d071..a6c3476ae35 100644
--- a/src/mame/drivers/tank8.c
+++ b/src/mame/drivers/tank8.c
@@ -9,26 +9,28 @@ Atari Tank 8 driver
#include "includes/tank8.h"
#include "sound/discrete.h"
-static int collision_index;
void tank8_set_collision(running_machine *machine, int index)
{
+ tank8_state *state = machine->driver_data<tank8_state>();
cputag_set_input_line(machine, "maincpu", 0, ASSERT_LINE);
- collision_index = index;
+ state->collision_index = index;
}
static MACHINE_RESET( tank8 )
{
- collision_index = 0;
+ tank8_state *state = machine->driver_data<tank8_state>();
+ state->collision_index = 0;
}
static READ8_HANDLER( tank8_collision_r )
{
- return collision_index;
+ tank8_state *state = space->machine->driver_data<tank8_state>();
+ return state->collision_index;
}
static WRITE8_HANDLER( tank8_lockout_w )
@@ -39,7 +41,8 @@ static WRITE8_HANDLER( tank8_lockout_w )
static WRITE8_HANDLER( tank8_int_reset_w )
{
- collision_index &= ~0x3f;
+ tank8_state *state = space->machine->driver_data<tank8_state>();
+ state->collision_index &= ~0x3f;
cputag_set_input_line(space->machine, "maincpu", 0, CLEAR_LINE);
}
@@ -113,10 +116,10 @@ static ADDRESS_MAP_START( tank8_cpu_map, ADDRESS_SPACE_PROGRAM, 8 )
AM_RANGE(0x1c0b, 0x1c0b) AM_READ_PORT("RC")
AM_RANGE(0x1c0f, 0x1c0f) AM_READ_PORT("VBLANK")
- AM_RANGE(0x1800, 0x1bff) AM_WRITE(tank8_video_ram_w) AM_BASE(&tank8_video_ram)
- AM_RANGE(0x1c00, 0x1c0f) AM_WRITEONLY AM_BASE(&tank8_pos_h_ram)
- AM_RANGE(0x1c10, 0x1c1f) AM_WRITEONLY AM_BASE(&tank8_pos_v_ram)
- AM_RANGE(0x1c20, 0x1c2f) AM_WRITEONLY AM_BASE(&tank8_pos_d_ram)
+ AM_RANGE(0x1800, 0x1bff) AM_WRITE(tank8_video_ram_w) AM_BASE_MEMBER(tank8_state, video_ram)
+ AM_RANGE(0x1c00, 0x1c0f) AM_WRITEONLY AM_BASE_MEMBER(tank8_state, pos_h_ram)
+ AM_RANGE(0x1c10, 0x1c1f) AM_WRITEONLY AM_BASE_MEMBER(tank8_state, pos_v_ram)
+ AM_RANGE(0x1c20, 0x1c2f) AM_WRITEONLY AM_BASE_MEMBER(tank8_state, pos_d_ram)
AM_RANGE(0x1c30, 0x1c37) AM_WRITE(tank8_lockout_w)
AM_RANGE(0x1d00, 0x1d00) AM_WRITE(tank8_int_reset_w)
@@ -124,7 +127,7 @@ static ADDRESS_MAP_START( tank8_cpu_map, ADDRESS_SPACE_PROGRAM, 8 )
AM_RANGE(0x1d02, 0x1d02) AM_DEVWRITE("discrete", tank8_explosion_w)
AM_RANGE(0x1d03, 0x1d03) AM_DEVWRITE("discrete", tank8_bugle_w)
AM_RANGE(0x1d04, 0x1d04) AM_DEVWRITE("discrete", tank8_bug_w)
- AM_RANGE(0x1d05, 0x1d05) AM_WRITEONLY AM_BASE(&tank8_team)
+ AM_RANGE(0x1d05, 0x1d05) AM_WRITEONLY AM_BASE_MEMBER(tank8_state, team)
AM_RANGE(0x1d06, 0x1d06) AM_DEVWRITE("discrete", tank8_attract_w)
AM_RANGE(0x1e00, 0x1e07) AM_DEVWRITE("discrete", tank8_motor_w)
@@ -324,7 +327,7 @@ static GFXDECODE_START( tank8 )
GFXDECODE_END
-static MACHINE_CONFIG_START( tank8, driver_device )
+static MACHINE_CONFIG_START( tank8, tank8_state )
/* basic machine hardware */
MCFG_CPU_ADD("maincpu", M6800, 11055000 / 10) /* ? */
diff --git a/src/mame/drivers/tempest.c b/src/mame/drivers/tempest.c
index 3a49f513b3a..feb16c7df55 100644
--- a/src/mame/drivers/tempest.c
+++ b/src/mame/drivers/tempest.c
@@ -285,6 +285,17 @@ Version 1 for Tempest Analog Vector-Generator PCB Assembly A037383-01 or A037383
#include "machine/atari_vg.h"
#include "sound/pokey.h"
+
+class tempest_state : public driver_device
+{
+public:
+ tempest_state(running_machine &machine, const driver_device_config_base &config)
+ : driver_device(machine, config) { }
+
+ UINT8 player_select;
+};
+
+
#define MASTER_CLOCK (XTAL_12_096MHz)
#define CLOCK_3KHZ (MASTER_CLOCK / 4096)
@@ -294,11 +305,11 @@ Version 1 for Tempest Analog Vector-Generator PCB Assembly A037383-01 or A037383
#define TEMPEST_BUTTONS_P2_TAG ("BUTTONSP2")
-static UINT8 tempest_player_select;
static MACHINE_START( tempest )
{
- state_save_register_global(machine, tempest_player_select);
+ tempest_state *state = machine->driver_data<tempest_state>();
+ state_save_register_global(machine, state->player_select);
}
/*************************************
@@ -321,13 +332,15 @@ static WRITE8_HANDLER( wdclr_w )
static CUSTOM_INPUT( tempest_knob_r )
{
- return input_port_read(field->port->machine, (tempest_player_select == 0) ?
+ tempest_state *state = field->port->machine->driver_data<tempest_state>();
+ return input_port_read(field->port->machine, (state->player_select == 0) ?
TEMPEST_KNOB_P1_TAG : TEMPEST_KNOB_P2_TAG);
}
static CUSTOM_INPUT( tempest_buttons_r )
{
- return input_port_read(field->port->machine, (tempest_player_select == 0) ?
+ tempest_state *state = field->port->machine->driver_data<tempest_state>();
+ return input_port_read(field->port->machine, (state->player_select == 0) ?
TEMPEST_BUTTONS_P1_TAG : TEMPEST_BUTTONS_P2_TAG);
}
@@ -360,10 +373,11 @@ static READ8_DEVICE_HANDLER( input_port_2_bit_r )
static WRITE8_HANDLER( tempest_led_w )
{
+ tempest_state *state = space->machine->driver_data<tempest_state>();
set_led_status(space->machine, 0, ~data & 0x02);
set_led_status(space->machine, 1, ~data & 0x01);
/* FLIP is bit 0x04 */
- tempest_player_select = data & 0x04;
+ state->player_select = data & 0x04;
}
@@ -570,7 +584,7 @@ static const pokey_interface pokey_interface_2 =
*
*************************************/
-static MACHINE_CONFIG_START( tempest, driver_device )
+static MACHINE_CONFIG_START( tempest, tempest_state )
/* basic machine hardware */
MCFG_CPU_ADD("maincpu", M6502, MASTER_CLOCK / 8)
diff --git a/src/mame/drivers/tomcat.c b/src/mame/drivers/tomcat.c
index 9613d7c1a92..3d41b4daf26 100644
--- a/src/mame/drivers/tomcat.c
+++ b/src/mame/drivers/tomcat.c
@@ -36,20 +36,32 @@
#include "sound/tms5220.h"
#include "sound/2151intf.h"
-static int tomcat_control_num;
-static UINT16 *tomcat_shared_ram;
-static UINT8 *tomcat_nvram;
-static int dsp_BIO;
-static int dsp_idle;
+
+class tomcat_state : public driver_device
+{
+public:
+ tomcat_state(running_machine &machine, const driver_device_config_base &config)
+ : driver_device(machine, config) { }
+
+ int control_num;
+ UINT16 *shared_ram;
+ UINT8 *nvram;
+ int dsp_BIO;
+ int dsp_idle;
+};
+
+
static WRITE16_HANDLER(tomcat_adcon_w)
{
- tomcat_control_num = data;
+ tomcat_state *state = space->machine->driver_data<tomcat_state>();
+ state->control_num = data;
}
static READ16_HANDLER(tomcat_adcread_r)
{
- switch( tomcat_control_num )
+ tomcat_state *state = space->machine->driver_data<tomcat_state>();
+ switch( state->control_num )
{
case 0: return input_port_read(space->machine, "STICKY");
case 1: return input_port_read(space->machine, "STICKX");
@@ -149,9 +161,10 @@ static WRITE16_HANDLER(tomcat_mresl_w)
static WRITE16_HANDLER(tomcat_mresh_w)
{
+ tomcat_state *state = space->machine->driver_data<tomcat_state>();
// 320 Reset high (Address Strobe)
// Release reset of TMS320
- dsp_BIO = 0;
+ state->dsp_BIO = 0;
cpu_set_input_line(space->machine->device("dsp"), INPUT_LINE_RESET, CLEAR_LINE);
}
@@ -163,6 +176,7 @@ static WRITE16_HANDLER(tomcat_irqclr_w)
static READ16_HANDLER(tomcat_inputs2_r)
{
+ tomcat_state *state = space->machine->driver_data<tomcat_state>();
/*
* D15 LNKFLAG (Game Link)
* D14 PC3 " "
@@ -173,33 +187,35 @@ static READ16_HANDLER(tomcat_inputs2_r)
* D9 /IDLE* (TMS320 System)
* D8
*/
- return dsp_idle ? 0 : (1 << 9);
+ return state->dsp_idle ? 0 : (1 << 9);
}
static READ16_HANDLER(tomcat_320bio_r)
{
- dsp_BIO = 1;
+ tomcat_state *state = space->machine->driver_data<tomcat_state>();
+ state->dsp_BIO = 1;
space->machine->device<cpu_device>("maincpu")->suspend(SUSPEND_REASON_SPIN, 1);
return 0;
}
static READ16_HANDLER(dsp_BIO_r)
{
+ tomcat_state *state = space->machine->driver_data<tomcat_state>();
if ( cpu_get_pc(space->cpu) == 0x0001 )
{
- if ( dsp_idle == 0 )
+ if ( state->dsp_idle == 0 )
{
- dsp_idle = 1;
- dsp_BIO = 0;
+ state->dsp_idle = 1;
+ state->dsp_BIO = 0;
}
- return !dsp_BIO;
+ return !state->dsp_BIO;
}
else if ( cpu_get_pc(space->cpu) == 0x0003 )
{
- if ( dsp_BIO == 1 )
+ if ( state->dsp_BIO == 1 )
{
- dsp_idle = 0;
- dsp_BIO = 0;
+ state->dsp_idle = 0;
+ state->dsp_BIO = 0;
space->machine->device<cpu_device>("maincpu")->resume(SUSPEND_REASON_SPIN );
return 0;
}
@@ -211,28 +227,32 @@ static READ16_HANDLER(dsp_BIO_r)
}
else
{
- return !dsp_BIO;
+ return !state->dsp_BIO;
}
}
static READ16_HANDLER(tomcat_shared_ram_r)
{
- return tomcat_shared_ram[offset];
+ tomcat_state *state = space->machine->driver_data<tomcat_state>();
+ return state->shared_ram[offset];
}
static WRITE16_HANDLER(tomcat_shared_ram_w)
{
- COMBINE_DATA(&tomcat_shared_ram[offset]);
+ tomcat_state *state = space->machine->driver_data<tomcat_state>();
+ COMBINE_DATA(&state->shared_ram[offset]);
}
static READ8_HANDLER(tomcat_nvram_r)
{
- return tomcat_nvram[offset];
+ tomcat_state *state = space->machine->driver_data<tomcat_state>();
+ return state->nvram[offset];
}
static WRITE8_HANDLER(tomcat_nvram_w)
{
- tomcat_nvram[offset] = data;
+ tomcat_state *state = space->machine->driver_data<tomcat_state>();
+ state->nvram[offset] = data;
}
static ADDRESS_MAP_START( tomcat_map, ADDRESS_SPACE_PROGRAM, 16 )
@@ -266,7 +286,7 @@ static ADDRESS_MAP_START( tomcat_map, ADDRESS_SPACE_PROGRAM, 16 )
ADDRESS_MAP_END
static ADDRESS_MAP_START( dsp_map, ADDRESS_SPACE_PROGRAM, 16 )
- AM_RANGE(0x0000, 0x1fff) AM_RAM AM_BASE(&tomcat_shared_ram)
+ AM_RANGE(0x0000, 0x1fff) AM_RAM AM_BASE_MEMBER(tomcat_state, shared_ram)
ADDRESS_MAP_END
static ADDRESS_MAP_START( dsp_io_map, ADDRESS_SPACE_IO, 16 )
@@ -328,20 +348,21 @@ ROM_END
static MACHINE_START(tomcat)
{
- ((UINT16*)tomcat_shared_ram)[0x0000] = 0xf600;
- ((UINT16*)tomcat_shared_ram)[0x0001] = 0x0000;
- ((UINT16*)tomcat_shared_ram)[0x0002] = 0xf600;
- ((UINT16*)tomcat_shared_ram)[0x0003] = 0x0000;
+ tomcat_state *state = machine->driver_data<tomcat_state>();
+ ((UINT16*)state->shared_ram)[0x0000] = 0xf600;
+ ((UINT16*)state->shared_ram)[0x0001] = 0x0000;
+ ((UINT16*)state->shared_ram)[0x0002] = 0xf600;
+ ((UINT16*)state->shared_ram)[0x0003] = 0x0000;
- tomcat_nvram = auto_alloc_array(machine, UINT8, 0x800);
- machine->device<nvram_device>("nvram")->set_base(tomcat_nvram, 0x800);
+ state->nvram = auto_alloc_array(machine, UINT8, 0x800);
+ machine->device<nvram_device>("nvram")->set_base(state->nvram, 0x800);
- state_save_register_global_pointer(machine, tomcat_nvram, 0x800);
- state_save_register_global(machine, tomcat_control_num);
- state_save_register_global(machine, dsp_BIO);
- state_save_register_global(machine, dsp_idle);
+ state_save_register_global_pointer(machine, state->nvram, 0x800);
+ state_save_register_global(machine, state->control_num);
+ state_save_register_global(machine, state->dsp_BIO);
+ state_save_register_global(machine, state->dsp_idle);
- dsp_BIO = 0;
+ state->dsp_BIO = 0;
}
static const riot6532_interface tomcat_riot6532_intf =
@@ -365,7 +386,7 @@ static const riot6532_interface tomcat_riot6532_intf =
DEVCB_NULL // connected to IRQ line of 6502
};
-static MACHINE_CONFIG_START( tomcat, driver_device )
+static MACHINE_CONFIG_START( tomcat, tomcat_state )
MCFG_CPU_ADD("maincpu", M68010, XTAL_12MHz / 2)
MCFG_CPU_PROGRAM_MAP(tomcat_map)
MCFG_CPU_VBLANK_INT_HACK(irq1_line_assert, 5)
diff --git a/src/mame/drivers/ultratnk.c b/src/mame/drivers/ultratnk.c
index 9f5ff9a4675..f2c6472cc6e 100644
--- a/src/mame/drivers/ultratnk.c
+++ b/src/mame/drivers/ultratnk.c
@@ -17,23 +17,22 @@ Atari Ultra Tank driver
#define PIXEL_CLOCK (MASTER_CLOCK / 2)
-static int da_latch;
-
-
static CUSTOM_INPUT( get_collision )
{
- return ultratnk_collision[(FPTR) param];
+ ultratnk_state *state = field->port->machine->driver_data<ultratnk_state>();
+ return state->collision[(FPTR) param];
}
static CUSTOM_INPUT( get_joystick )
{
+ ultratnk_state *state = field->port->machine->driver_data<ultratnk_state>();
UINT8 joy = input_port_read(field->port->machine, (const char *)param) & 3;
if (joy == 1)
{
- return (da_latch < 8) ? 1 : 0;
+ return (state->da_latch < 8) ? 1 : 0;
}
if (joy == 2)
{
@@ -106,13 +105,15 @@ static WRITE8_HANDLER( ultratnk_wram_w )
static WRITE8_HANDLER( ultratnk_collision_reset_w )
{
- ultratnk_collision[(offset >> 1) & 3] = 0;
+ ultratnk_state *state = space->machine->driver_data<ultratnk_state>();
+ state->collision[(offset >> 1) & 3] = 0;
}
static WRITE8_HANDLER( ultratnk_da_latch_w )
{
- da_latch = data & 15;
+ ultratnk_state *state = space->machine->driver_data<ultratnk_state>();
+ state->da_latch = data & 15;
}
diff --git a/src/mame/drivers/videopin.c b/src/mame/drivers/videopin.c
index 61a6352517d..caa41b3c3a6 100644
--- a/src/mame/drivers/videopin.c
+++ b/src/mame/drivers/videopin.c
@@ -16,11 +16,7 @@
#include "videopin.lh"
#include "sound/discrete.h"
-static attotime time_pushed;
-static attotime time_released;
-static UINT8 prev = 0;
-static UINT8 mask = 0;
static WRITE8_DEVICE_HANDLER(videopin_out1_w);
static WRITE8_DEVICE_HANDLER(videopin_out2_w);
@@ -28,21 +24,22 @@ static WRITE8_DEVICE_HANDLER(videopin_out2_w);
static void update_plunger(running_machine *machine)
{
+ videopin_state *state = machine->driver_data<videopin_state>();
UINT8 val = input_port_read(machine, "IN2");
- if (prev != val)
+ if (state->prev != val)
{
if (val == 0)
{
- time_released = timer_get_time(machine);
+ state->time_released = timer_get_time(machine);
- if (!mask)
+ if (!state->mask)
cputag_set_input_line(machine, "maincpu", INPUT_LINE_NMI, ASSERT_LINE);
}
else
- time_pushed = timer_get_time(machine);
+ state->time_pushed = timer_get_time(machine);
- prev = val;
+ state->prev = val;
}
}
@@ -79,7 +76,8 @@ static MACHINE_RESET( videopin )
static double calc_plunger_pos(running_machine *machine)
{
- return (attotime_to_double(timer_get_time(machine)) - attotime_to_double(time_released)) * (attotime_to_double(time_released) - attotime_to_double(time_pushed) + 0.2);
+ videopin_state *state = machine->driver_data<videopin_state>();
+ return (attotime_to_double(timer_get_time(machine)) - attotime_to_double(state->time_released)) * (attotime_to_double(state->time_released) - attotime_to_double(state->time_pushed) + 0.2);
}
@@ -140,6 +138,7 @@ static WRITE8_HANDLER( videopin_led_w )
static WRITE8_DEVICE_HANDLER( videopin_out1_w )
{
+ videopin_state *state = device->machine->driver_data<videopin_state>();
/* D0 => OCTAVE0 */
/* D1 => OCTACE1 */
/* D2 => OCTAVE2 */
@@ -149,9 +148,9 @@ static WRITE8_DEVICE_HANDLER( videopin_out1_w )
/* D6 => NOT USED */
/* D7 => NOT USED */
- mask = ~data & 0x10;
+ state->mask = ~data & 0x10;
- if (mask)
+ if (state->mask)
cputag_set_input_line(device->machine, "maincpu", INPUT_LINE_NMI, CLEAR_LINE);
coin_lockout_global_w(device->machine, ~data & 0x08);
@@ -196,7 +195,7 @@ static WRITE8_DEVICE_HANDLER( videopin_note_dvsr_w )
static ADDRESS_MAP_START( main_map, ADDRESS_SPACE_PROGRAM, 8 )
AM_RANGE(0x0000, 0x01ff) AM_RAM
- AM_RANGE(0x0200, 0x07ff) AM_RAM_WRITE(videopin_video_ram_w) AM_BASE(&videopin_video_ram)
+ AM_RANGE(0x0200, 0x07ff) AM_RAM_WRITE(videopin_video_ram_w) AM_BASE_MEMBER(videopin_state, video_ram)
AM_RANGE(0x0800, 0x0800) AM_READ(videopin_misc_r) AM_DEVWRITE("discrete", videopin_note_dvsr_w)
AM_RANGE(0x0801, 0x0801) AM_WRITE(videopin_led_w)
AM_RANGE(0x0802, 0x0802) AM_WRITE(watchdog_reset_w)
@@ -321,7 +320,7 @@ GFXDECODE_END
*
*************************************/
-static MACHINE_CONFIG_START( videopin, driver_device )
+static MACHINE_CONFIG_START( videopin, videopin_state )
/* basic machine hardware */
MCFG_CPU_ADD("maincpu", M6502, 12096000 / 16)
diff --git a/src/mame/drivers/wolfpack.c b/src/mame/drivers/wolfpack.c
index 91e6526ff04..686527d224d 100644
--- a/src/mame/drivers/wolfpack.c
+++ b/src/mame/drivers/wolfpack.c
@@ -39,6 +39,7 @@ static CUSTOM_INPUT( wolfpack_dial_r )
static READ8_HANDLER( wolfpack_misc_r )
{
+ wolfpack_state *state = space->machine->driver_data<wolfpack_state>();
device_t *device = space->machine->device("speech");
UINT8 val = 0;
@@ -54,7 +55,7 @@ static READ8_HANDLER( wolfpack_misc_r )
if (!s14001a_bsy_r(device))
val |= 0x01;
- if (!wolfpack_collision)
+ if (!state->collision)
val |= 0x10;
if (space->machine->primary_screen->vpos() >= 240)
@@ -103,14 +104,15 @@ static WRITE8_HANDLER( wolfpack_credit_w )
static WRITE8_HANDLER( wolfpack_coldetres_w )
{
- wolfpack_collision = 0;
+ wolfpack_state *state = space->machine->driver_data<wolfpack_state>();
+ state->collision = 0;
}
static ADDRESS_MAP_START( main_map, ADDRESS_SPACE_PROGRAM, 8 )
AM_RANGE(0x0000, 0x00ff) AM_RAM AM_MIRROR(0x100)
AM_RANGE(0x1000, 0x1000) AM_READ_PORT("INPUTS")
- AM_RANGE(0x1000, 0x10ff) AM_WRITEONLY AM_BASE(&wolfpack_alpha_num_ram)
+ AM_RANGE(0x1000, 0x10ff) AM_WRITEONLY AM_BASE_MEMBER(wolfpack_state, alpha_num_ram)
AM_RANGE(0x2000, 0x2000) AM_READ(wolfpack_misc_r)
AM_RANGE(0x2000, 0x2000) AM_WRITE(wolfpack_high_explo_w)
AM_RANGE(0x2001, 0x2001) AM_WRITE(wolfpack_sonar_ping_w)
@@ -284,7 +286,7 @@ static GFXDECODE_START( wolfpack )
GFXDECODE_END
-static MACHINE_CONFIG_START( wolfpack, driver_device )
+static MACHINE_CONFIG_START( wolfpack, wolfpack_state )
MCFG_SPEAKER_STANDARD_MONO("mono")
/* basic machine hardware */
diff --git a/src/mame/includes/arcadecl.h b/src/mame/includes/arcadecl.h
index 931336bca5f..ff452304e47 100644
--- a/src/mame/includes/arcadecl.h
+++ b/src/mame/includes/arcadecl.h
@@ -4,8 +4,6 @@
*************************************************************************/
-#include "rampart.h"
-
/*----------- defined in video/arcadecl.c -----------*/
diff --git a/src/mame/includes/atarigt.h b/src/mame/includes/atarigt.h
index f8258cca90c..a7ff5bd167e 100644
--- a/src/mame/includes/atarigt.h
+++ b/src/mame/includes/atarigt.h
@@ -11,6 +11,8 @@
#define TRAM_ENTRIES 0x4000
#define MRAM_ENTRIES 0x8000
+#define ADDRSEQ_COUNT 4
+
class atarigt_state : public atarigen_state
{
public:
@@ -36,6 +38,12 @@ public:
void (*protection_w)(address_space *space, offs_t offset, UINT16 data);
void (*protection_r)(address_space *space, offs_t offset, UINT16 *data);
+
+ UINT8 ignore_writes;
+ offs_t protaddr[ADDRSEQ_COUNT];
+ UINT8 protmode;
+ UINT16 protresult;
+ UINT8 protdata[0x800];
};
diff --git a/src/mame/includes/atarisy1.h b/src/mame/includes/atarisy1.h
index 7c9af55c842..a69b99e1874 100644
--- a/src/mame/includes/atarisy1.h
+++ b/src/mame/includes/atarisy1.h
@@ -40,6 +40,8 @@ public:
/* graphics bank tracking */
UINT8 bank_gfx[3][8];
UINT8 bank_color_shift[MAX_GFX_ELEMENTS];
+
+ UINT8 cur[2][2];
};
diff --git a/src/mame/includes/atarisy2.h b/src/mame/includes/atarisy2.h
index 02659298660..5bae025946d 100644
--- a/src/mame/includes/atarisy2.h
+++ b/src/mame/includes/atarisy2.h
@@ -34,6 +34,16 @@ public:
emu_timer * yscroll_reset_timer;
UINT32 playfield_tile_bank[2];
UINT32 videobank;
+
+ // 720 fake joystick
+ double joy_last_angle;
+ int joy_rotations;
+
+ // 720 fake spinner
+ UINT32 spin_last_rotate_count;
+ INT32 spin_pos; /* track fake position of spinner */
+ UINT32 spin_center_count;
+
UINT16 vram[0x8000/2];
};
diff --git a/src/mame/includes/atetris.h b/src/mame/includes/atetris.h
index 1c35f10cdb5..0b5eac7ac6b 100644
--- a/src/mame/includes/atetris.h
+++ b/src/mame/includes/atetris.h
@@ -13,6 +13,12 @@ public:
required_shared_ptr<UINT8> m_nvram;
UINT8 *videoram;
+ UINT8 *slapstic_source;
+ UINT8 *slapstic_base;
+ UINT8 current_bank;
+ UINT8 nvram_write_enable;
+ emu_timer *interrupt_timer;
+ tilemap_t *bg_tilemap;
};
/*----------- defined in video/atetris.c -----------*/
@@ -21,6 +27,3 @@ VIDEO_START( atetris );
VIDEO_UPDATE( atetris );
WRITE8_HANDLER( atetris_videoram_w );
-
-
-
diff --git a/src/mame/includes/centiped.h b/src/mame/includes/centiped.h
index 225f3e3390e..4b797367b0f 100644
--- a/src/mame/includes/centiped.h
+++ b/src/mame/includes/centiped.h
@@ -11,13 +11,21 @@ public:
: driver_device(machine, config) { }
UINT8 *videoram;
+ UINT8 oldpos[4];
+ UINT8 sign[4];
+ UINT8 dsw_select;
+ UINT8 control_select;
+ UINT8 *rambase;
+ UINT8 flipscreen;
+ UINT8 *bullsdrt_tiles_bankram;
+ tilemap_t *bg_tilemap;
+ UINT8 bullsdrt_sprites_bank;
+ UINT8 penmask[64];
};
/*----------- defined in video/centiped.c -----------*/
-extern UINT8 centiped_flipscreen, *bullsdrt_tiles_bankram;
-
PALETTE_INIT( warlords );
VIDEO_START( centiped );
@@ -39,4 +47,3 @@ WRITE8_HANDLER( bullsdrt_tilesbank_w );
WRITE8_HANDLER( bullsdrt_sprites_bank_w );
WRITE8_HANDLER( mazeinv_paletteram_w );
-
diff --git a/src/mame/includes/cloak.h b/src/mame/includes/cloak.h
index 9c9db7ce57a..76e35f76a17 100644
--- a/src/mame/includes/cloak.h
+++ b/src/mame/includes/cloak.h
@@ -11,6 +11,17 @@ public:
: driver_device(machine, config) { }
UINT8 *videoram;
+ UINT8 *spriteram;
+ int nvram_enabled;
+ UINT8 bitmap_videoram_selected;
+ UINT8 bitmap_videoram_address_x;
+ UINT8 bitmap_videoram_address_y;
+ UINT8 *bitmap_videoram1;
+ UINT8 *bitmap_videoram2;
+ UINT8 *current_bitmap_videoram_accessed;
+ UINT8 *current_bitmap_videoram_displayed;
+ UINT16 *palette_ram;
+ tilemap_t *bg_tilemap;
};
diff --git a/src/mame/includes/eprom.h b/src/mame/includes/eprom.h
index 000ddece639..1c9e42d7205 100644
--- a/src/mame/includes/eprom.h
+++ b/src/mame/includes/eprom.h
@@ -15,6 +15,7 @@ public:
int screen_intensity;
int video_disable;
UINT16 * sync_data;
+ int last_offset;
};
diff --git a/src/mame/includes/firetrk.h b/src/mame/includes/firetrk.h
index abae885e098..e38b71b91b0 100644
--- a/src/mame/includes/firetrk.h
+++ b/src/mame/includes/firetrk.h
@@ -30,6 +30,38 @@ Atari Fire Truck + Super Bug + Monte Carlo driver
#define MONTECAR_ATTRACT_INV FIRETRUCK_ATTRACT_EN
+class firetrk_state : public driver_device
+{
+public:
+ firetrk_state(running_machine &machine, const driver_device_config_base &config)
+ : driver_device(machine, config) { }
+
+ UINT8 in_service_mode;
+ UINT32 dial[2];
+ UINT8 steer_dir[2];
+ UINT8 steer_flag[2];
+ UINT8 gear;
+ UINT8 *alpha_num_ram;
+ UINT8 *playfield_ram;
+ UINT8 *scroll_x;
+ UINT8 *scroll_y;
+ UINT8 *car_rot;
+ UINT8 *drone_rot;
+ UINT8 *drone_x;
+ UINT8 *drone_y;
+ UINT8 *blink;
+ UINT8 flash;
+ UINT8 crash[2];
+ UINT8 skid[2];
+ bitmap_t *helper1;
+ bitmap_t *helper2;
+ UINT32 color1_mask;
+ UINT32 color2_mask;
+ tilemap_t *tilemap1;
+ tilemap_t *tilemap2;
+};
+
+
/*----------- defined in audio/firetrk.c -----------*/
WRITE8_DEVICE_HANDLER( firetrk_skid_reset_w );
@@ -57,16 +89,4 @@ VIDEO_UPDATE( firetrk );
VIDEO_UPDATE( superbug );
VIDEO_UPDATE( montecar );
-extern UINT8 *firetrk_alpha_num_ram;
-extern UINT8 *firetrk_playfield_ram;
-extern UINT8 *firetrk_scroll_x;
-extern UINT8 *firetrk_scroll_y;
-extern UINT8 *firetrk_car_rot;
-extern UINT8 *firetrk_drone_rot;
-extern UINT8 *firetrk_drone_x;
-extern UINT8 *firetrk_drone_y;
-extern UINT8 *firetrk_blink;
-extern UINT8 firetrk_flash;
-
-extern UINT8 firetrk_crash[2];
-extern UINT8 firetrk_skid[2];
+
diff --git a/src/mame/includes/irobot.h b/src/mame/includes/irobot.h
index f674fd92d78..fe69de29f0d 100644
--- a/src/mame/includes/irobot.h
+++ b/src/mame/includes/irobot.h
@@ -4,6 +4,23 @@
*************************************************************************/
+#define IR_TIMING 1 /* try to emulate MB and VG running time */
+
+typedef struct irmb_ops
+{
+ const struct irmb_ops *nxtop;
+ UINT32 func;
+ UINT32 diradd;
+ UINT32 latchmask;
+ UINT32 *areg;
+ UINT32 *breg;
+ UINT8 cycles;
+ UINT8 diren;
+ UINT8 flags;
+ UINT8 ramsel;
+} irmb_ops;
+
+
class irobot_state : public driver_device
{
public:
@@ -13,15 +30,40 @@ public:
required_shared_ptr<UINT8> m_nvram;
UINT8 *videoram;
+ UINT8 vg_clear;
+ UINT8 bufsel;
+ UINT8 alphamap;
+ UINT8 *combase;
+ UINT8 irvg_vblank;
+ UINT8 irvg_running;
+ UINT8 irmb_running;
+#if IR_TIMING
+ timer_device *irvg_timer;
+ timer_device *irmb_timer;
+#endif
+ UINT8 *comRAM[2];
+ UINT8 *mbRAM;
+ UINT8 *mbROM;
+ UINT8 control_num;
+ UINT8 statwr;
+ UINT8 out0;
+ UINT8 outx;
+ UINT8 mpage;
+ UINT8 *combase_mb;
+ irmb_ops *mbops;
+ const irmb_ops *irmb_stack[16];
+ UINT32 irmb_regs[16];
+ UINT32 irmb_latch;
+ UINT8 *polybitmap1;
+ UINT8 *polybitmap2;
+ int ir_xmin;
+ int ir_ymin;
+ int ir_xmax;
+ int ir_ymax;
};
/*----------- defined in machine/irobot.c -----------*/
-extern UINT8 irobot_vg_clear;
-extern UINT8 irobot_bufsel;
-extern UINT8 irobot_alphamap;
-extern UINT8 *irobot_combase;
-
DRIVER_INIT( irobot );
MACHINE_RESET( irobot );
@@ -47,4 +89,4 @@ VIDEO_UPDATE( irobot );
WRITE8_HANDLER( irobot_paletteram_w );
void irobot_poly_clear(running_machine *machine);
-void irobot_run_video(void);
+void irobot_run_video(running_machine *machine);
diff --git a/src/mame/includes/mhavoc.h b/src/mame/includes/mhavoc.h
index cb30c52535f..379982c3838 100644
--- a/src/mame/includes/mhavoc.h
+++ b/src/mame/includes/mhavoc.h
@@ -15,6 +15,29 @@
#define MHAVOC_CLOCK_2_4K (MHAVOC_CLOCK_625K/16/16)
+class mhavoc_state : public driver_device
+{
+public:
+ mhavoc_state(running_machine &machine, const driver_device_config_base &config)
+ : driver_device(machine, config) { }
+
+ UINT8 *zram0;
+ UINT8 *zram1;
+ UINT8 alpha_data;
+ UINT8 alpha_rcvd;
+ UINT8 alpha_xmtd;
+ UINT8 gamma_data;
+ UINT8 gamma_rcvd;
+ UINT8 gamma_xmtd;
+ UINT8 player_1;
+ UINT8 alpha_irq_clock;
+ UINT8 alpha_irq_clock_enable;
+ UINT8 gamma_irq_clock;
+ UINT8 has_gamma_cpu;
+ UINT8 speech_write_buffer;
+};
+
+
/*----------- defined in machine/mhavoc.c -----------*/
TIMER_DEVICE_CALLBACK( mhavoc_cpu_irq_clock );
@@ -47,4 +70,3 @@ WRITE8_HANDLER( alphaone_out_0_w );
WRITE8_HANDLER( mhavoc_out_1_w );
-extern UINT8 *mhavoc_zram0, *mhavoc_zram1;
diff --git a/src/mame/includes/poolshrk.h b/src/mame/includes/poolshrk.h
index 33b786dbd69..98777453c1a 100644
--- a/src/mame/includes/poolshrk.h
+++ b/src/mame/includes/poolshrk.h
@@ -8,6 +8,20 @@
/* Discrete Sound Input Nodes */
+class poolshrk_state : public driver_device
+{
+public:
+ poolshrk_state(running_machine &machine, const driver_device_config_base &config)
+ : driver_device(machine, config) { }
+
+ int da_latch;
+ UINT8* playfield_ram;
+ UINT8* hpos_ram;
+ UINT8* vpos_ram;
+ tilemap_t* bg_tilemap;
+};
+
+
/*----------- defined in audio/poolshrk.c -----------*/
WRITE8_DEVICE_HANDLER( poolshrk_scratch_sound_w );
@@ -23,6 +37,3 @@ DISCRETE_SOUND_EXTERN( poolshrk );
VIDEO_START( poolshrk );
VIDEO_UPDATE( poolshrk );
-extern UINT8* poolshrk_playfield_ram;
-extern UINT8* poolshrk_hpos_ram;
-extern UINT8* poolshrk_vpos_ram;
diff --git a/src/mame/includes/runaway.h b/src/mame/includes/runaway.h
index 80b31bfb74f..386625f0f22 100644
--- a/src/mame/includes/runaway.h
+++ b/src/mame/includes/runaway.h
@@ -1,7 +1,18 @@
-/*----------- defined in video/runaway.c -----------*/
+class runaway_state : public driver_device
+{
+public:
+ runaway_state(running_machine &machine, const driver_device_config_base &config)
+ : driver_device(machine, config) { }
+
+ emu_timer *interrupt_timer;
+ UINT8* video_ram;
+ UINT8* sprite_ram;
+ tilemap_t *bg_tilemap;
+ int tile_bank;
+};
-extern UINT8* runaway_video_ram;
-extern UINT8* runaway_sprite_ram;
+
+/*----------- defined in video/runaway.c -----------*/
VIDEO_START( runaway );
VIDEO_START( qwak );
diff --git a/src/mame/includes/shuuz.h b/src/mame/includes/shuuz.h
index 1fc7bf3a30f..fb4c61a878c 100644
--- a/src/mame/includes/shuuz.h
+++ b/src/mame/includes/shuuz.h
@@ -11,6 +11,8 @@ class shuuz_state : public atarigen_state
public:
shuuz_state(running_machine &machine, const driver_device_config_base &config)
: atarigen_state(machine, config) { }
+
+ int cur[2];
};
diff --git a/src/mame/includes/skydiver.h b/src/mame/includes/skydiver.h
index 9213509c1e3..99fcafa843e 100644
--- a/src/mame/includes/skydiver.h
+++ b/src/mame/includes/skydiver.h
@@ -19,6 +19,19 @@
#define SKYDIVER_SOUND_EN NODE_10
+class skydiver_state : public driver_device
+{
+public:
+ skydiver_state(running_machine &machine, const driver_device_config_base &config)
+ : driver_device(machine, config) { }
+
+ int nmion;
+ UINT8 *videoram;
+ tilemap_t *bg_tilemap;
+ int width;
+};
+
+
/*----------- defined in audio/skydiver.c -----------*/
DISCRETE_SOUND_EXTERN( skydiver );
@@ -26,8 +39,6 @@ DISCRETE_SOUND_EXTERN( skydiver );
/*----------- defined in video/skydiver.c -----------*/
-extern UINT8 *skydiver_videoram;
-
MACHINE_RESET( skydiver );
WRITE8_HANDLER( skydiver_videoram_w );
WRITE8_HANDLER( skydiver_wram_w ); /* the signal is WRAM, presumably Work RAM */
diff --git a/src/mame/includes/sprint2.h b/src/mame/includes/sprint2.h
index f1b6e0a9a2e..ef03ab60ac4 100644
--- a/src/mame/includes/sprint2.h
+++ b/src/mame/includes/sprint2.h
@@ -21,6 +21,24 @@
#define DOMINOS_ATTRACT_EN SPRINT2_ATTRACT_EN
+class sprint2_state : public driver_device
+{
+public:
+ sprint2_state(running_machine &machine, const driver_device_config_base &config)
+ : driver_device(machine, config) { }
+
+ int attract;
+ int steering[2];
+ int gear[2];
+ int game;
+ UINT8 dial[2];
+ UINT8* video_ram;
+ tilemap_t* bg_tilemap;
+ bitmap_t* helper;
+ int collision[2];
+};
+
+
/*----------- defined in audio/sprint2.c -----------*/
DISCRETE_SOUND_EXTERN( sprint2 );
@@ -42,4 +60,3 @@ VIDEO_UPDATE( sprint2 );
VIDEO_START( sprint2 );
VIDEO_EOF( sprint2 );
-extern UINT8* sprint2_video_ram;
diff --git a/src/mame/includes/sprint4.h b/src/mame/includes/sprint4.h
index 983e6eada7c..a7a1940c663 100644
--- a/src/mame/includes/sprint4.h
+++ b/src/mame/includes/sprint4.h
@@ -5,13 +5,19 @@ public:
: driver_device(machine, config) { }
UINT8 *videoram;
+ int da_latch;
+ int steer_FF1[4];
+ int steer_FF2[4];
+ int gear[4];
+ UINT8 last_wheel[4];
+ int collision[4];
+ tilemap_t* playfield;
+ bitmap_t* helper;
};
/*----------- defined in video/sprint4.c -----------*/
-extern int sprint4_collision[4];
-
PALETTE_INIT( sprint4 );
VIDEO_EOF( sprint4 );
diff --git a/src/mame/includes/sprint8.h b/src/mame/includes/sprint8.h
index c88bdcadf98..6c62744ea74 100644
--- a/src/mame/includes/sprint8.h
+++ b/src/mame/includes/sprint8.h
@@ -1,5 +1,28 @@
#include "sound/discrete.h"
+class sprint8_state : public driver_device
+{
+public:
+ sprint8_state(running_machine &machine, const driver_device_config_base &config)
+ : driver_device(machine, config) { }
+
+ int steer_dir[8];
+ int steer_flag[8];
+ int collision_reset;
+ int collision_index;
+ UINT8 dial[8];
+ UINT8* video_ram;
+ UINT8* pos_h_ram;
+ UINT8* pos_v_ram;
+ UINT8* pos_d_ram;
+ UINT8* team;
+ tilemap_t* tilemap1;
+ tilemap_t* tilemap2;
+ bitmap_t* helper1;
+ bitmap_t* helper2;
+};
+
+
/*----------- defined in drivers/sprint8.c -----------*/
void sprint8_set_collision(running_machine *machine, int n);
@@ -7,12 +30,6 @@ void sprint8_set_collision(running_machine *machine, int n);
/*----------- defined in video/sprint8.c -----------*/
-extern UINT8* sprint8_video_ram;
-extern UINT8* sprint8_pos_h_ram;
-extern UINT8* sprint8_pos_v_ram;
-extern UINT8* sprint8_pos_d_ram;
-extern UINT8* sprint8_team;
-
PALETTE_INIT( sprint8 );
VIDEO_EOF( sprint8 );
VIDEO_START( sprint8 );
diff --git a/src/mame/includes/starshp1.h b/src/mame/includes/starshp1.h
index df2f87be551..d9e777d091e 100644
--- a/src/mame/includes/starshp1.h
+++ b/src/mame/includes/starshp1.h
@@ -30,36 +30,41 @@
#define STARSHP1_VBSTART (0x0f0)
-/*----------- defined in drivers/starshp1.c -----------*/
-
-extern int starshp1_attract;
+class starshp1_state : public driver_device
+{
+public:
+ starshp1_state(running_machine &machine, const driver_device_config_base &config)
+ : driver_device(machine, config) { }
+
+ int analog_in_select;
+ int attract;
+ UINT8 *playfield_ram;
+ UINT8 *hpos_ram;
+ UINT8 *vpos_ram;
+ UINT8 *obj_ram;
+ int ship_explode;
+ int ship_picture;
+ int ship_hoffset;
+ int ship_voffset;
+ int ship_size;
+ int circle_hpos;
+ int circle_vpos;
+ int circle_size;
+ int circle_mod;
+ int circle_kill;
+ int phasor;
+ int collision_latch;
+ int starfield_kill;
+ int mux;
+ int inverse;
+ UINT16 *LSFR;
+ bitmap_t *helper;
+ tilemap_t *bg_tilemap;
+};
/*----------- defined in video/starshp1.c -----------*/
-extern UINT8 *starshp1_playfield_ram;
-extern UINT8 *starshp1_hpos_ram;
-extern UINT8 *starshp1_vpos_ram;
-extern UINT8 *starshp1_obj_ram;
-
-extern int starshp1_ship_explode;
-extern int starshp1_ship_picture;
-extern int starshp1_ship_hoffset;
-extern int starshp1_ship_voffset;
-extern int starshp1_ship_size;
-
-extern int starshp1_circle_hpos;
-extern int starshp1_circle_vpos;
-extern int starshp1_circle_size;
-extern int starshp1_circle_mod;
-extern int starshp1_circle_kill;
-
-extern int starshp1_phasor;
-extern int starshp1_collision_latch;
-extern int starshp1_starfield_kill;
-extern int starshp1_mux;
-extern int starshp1_inverse;
-
READ8_HANDLER( starshp1_rng_r );
WRITE8_HANDLER( starshp1_sspic_w );
diff --git a/src/mame/includes/starwars.h b/src/mame/includes/starwars.h
index e2e800046dd..85bc429fe84 100644
--- a/src/mame/includes/starwars.h
+++ b/src/mame/includes/starwars.h
@@ -7,15 +7,43 @@
#include "machine/6532riot.h"
-/*----------- defined in drivers/starwars.c -----------*/
-
-extern UINT8 starwars_is_esb;
+class starwars_state : public driver_device
+{
+public:
+ starwars_state(running_machine &machine, const driver_device_config_base &config)
+ : driver_device(machine, config) { }
+
+ UINT8 sound_data;
+ UINT8 main_data;
+ device_t *riot;
+ UINT8 *slapstic_source;
+ UINT8 *slapstic_base;
+ UINT8 slapstic_current_bank;
+ offs_t slapstic_last_pc;
+ offs_t slapstic_last_address;
+ UINT8 is_esb;
+ UINT8 *mathram;
+ UINT8 control_num;
+ int MPA;
+ int BIC;
+ UINT16 dvd_shift;
+ UINT16 quotient_shift;
+ UINT16 divisor;
+ UINT16 dividend;
+ UINT8 *PROM_STR;
+ UINT8 *PROM_MAS;
+ UINT8 *PROM_AM;
+ int math_run;
+ emu_timer *math_timer;
+ INT16 A;
+ INT16 B;
+ INT16 C;
+ INT32 ACC;
+};
/*----------- defined in machine/starwars.c -----------*/
-extern UINT8 *starwars_mathram;
-
WRITE8_HANDLER( starwars_nstore_w );
WRITE8_HANDLER( starwars_out_w );
@@ -25,7 +53,7 @@ READ8_HANDLER( starwars_adc_r );
WRITE8_HANDLER( starwars_adc_select_w );
void starwars_mproc_init(running_machine *machine);
-void starwars_mproc_reset(void);
+void starwars_mproc_reset(running_machine *machine);
READ8_HANDLER( starwars_prng_r );
READ8_HANDLER( starwars_div_reh_r );
diff --git a/src/mame/includes/subs.h b/src/mame/includes/subs.h
index 3b75b5ceb03..548f67a9f56 100644
--- a/src/mame/includes/subs.h
+++ b/src/mame/includes/subs.h
@@ -23,6 +23,13 @@ public:
: driver_device(machine, config) { }
UINT8 *videoram;
+ UINT8 *spriteram;
+ int steering_buf1;
+ int steering_buf2;
+ int steering_val1;
+ int steering_val2;
+ int last_val_1;
+ int last_val_2;
};
diff --git a/src/mame/includes/tank8.h b/src/mame/includes/tank8.h
index ca6ca86c989..13584aa6084 100644
--- a/src/mame/includes/tank8.h
+++ b/src/mame/includes/tank8.h
@@ -23,6 +23,25 @@
#define TANK8_BUGLE_DATA2 NODE_14
+class tank8_state : public driver_device
+{
+public:
+ tank8_state(running_machine &machine, const driver_device_config_base &config)
+ : driver_device(machine, config) { }
+
+ int collision_index;
+ UINT8 *video_ram;
+ UINT8 *pos_h_ram;
+ UINT8 *pos_v_ram;
+ UINT8 *pos_d_ram;
+ UINT8 *team;
+ tilemap_t *tilemap;
+ bitmap_t *helper1;
+ bitmap_t *helper2;
+ bitmap_t *helper3;
+};
+
+
/*----------- defined in audio/tank8.c -----------*/
DISCRETE_SOUND_EXTERN( tank8 );
@@ -42,9 +61,4 @@ VIDEO_UPDATE( tank8 );
WRITE8_HANDLER( tank8_video_ram_w );
-extern UINT8 *tank8_video_ram;
-extern UINT8 *tank8_pos_h_ram;
-extern UINT8 *tank8_pos_v_ram;
-extern UINT8 *tank8_pos_d_ram;
-extern UINT8 *tank8_team;
diff --git a/src/mame/includes/ultratnk.h b/src/mame/includes/ultratnk.h
index 7c0d34a909d..f0502fb1d3c 100644
--- a/src/mame/includes/ultratnk.h
+++ b/src/mame/includes/ultratnk.h
@@ -12,13 +12,15 @@ public:
: driver_device(machine, config) { }
UINT8 *videoram;
+ int da_latch;
+ int collision[4];
+ tilemap_t* playfield;
+ bitmap_t* helper;
};
/*----------- defined in video/ultratnk.c -----------*/
-extern int ultratnk_collision[4];
-
PALETTE_INIT( ultratnk );
VIDEO_START( ultratnk );
VIDEO_UPDATE( ultratnk );
diff --git a/src/mame/includes/videopin.h b/src/mame/includes/videopin.h
index d1b647d213c..2f3d70e2bee 100644
--- a/src/mame/includes/videopin.h
+++ b/src/mame/includes/videopin.h
@@ -15,6 +15,23 @@
#define VIDEOPIN_VOL_DATA NODE_06
+class videopin_state : public driver_device
+{
+public:
+ videopin_state(running_machine &machine, const driver_device_config_base &config)
+ : driver_device(machine, config) { }
+
+ attotime time_pushed;
+ attotime time_released;
+ UINT8 prev;
+ UINT8 mask;
+ UINT8* video_ram;
+ int ball_x;
+ int ball_y;
+ tilemap_t* bg_tilemap;
+};
+
+
/*----------- defined in audio/videopin.c -----------*/
DISCRETE_SOUND_EXTERN( videopin );
@@ -22,8 +39,6 @@ DISCRETE_SOUND_EXTERN( videopin );
/*----------- defined in video/videopin.c -----------*/
-extern UINT8* videopin_video_ram;
-
WRITE8_HANDLER( videopin_video_ram_w );
WRITE8_HANDLER( videopin_ball_w );
diff --git a/src/mame/includes/wolfpack.h b/src/mame/includes/wolfpack.h
index 4d867a0bea9..59d0af6acf7 100644
--- a/src/mame/includes/wolfpack.h
+++ b/src/mame/includes/wolfpack.h
@@ -1,7 +1,30 @@
-/*----------- defined in video/wolfpack.c -----------*/
+class wolfpack_state : public driver_device
+{
+public:
+ wolfpack_state(running_machine &machine, const driver_device_config_base &config)
+ : driver_device(machine, config) { }
+
+ int collision;
+ UINT8* alpha_num_ram;
+ unsigned current_index;
+ UINT8 video_invert;
+ UINT8 ship_reflect;
+ UINT8 pt_pos_select;
+ UINT8 pt_horz;
+ UINT8 pt_pic;
+ UINT8 ship_h;
+ UINT8 torpedo_pic;
+ UINT8 ship_size;
+ UINT8 ship_h_precess;
+ UINT8 ship_pic;
+ UINT8 torpedo_h;
+ UINT8 torpedo_v;
+ UINT8* LFSR;
+ bitmap_t* helper;
+};
-extern int wolfpack_collision;
-extern UINT8* wolfpack_alpha_num_ram;
+
+/*----------- defined in video/wolfpack.c -----------*/
PALETTE_INIT( wolfpack );
VIDEO_UPDATE( wolfpack );
diff --git a/src/mame/machine/irobot.c b/src/mame/machine/irobot.c
index 3a8b6da5fde..e1599f8372b 100644
--- a/src/mame/machine/irobot.c
+++ b/src/mame/machine/irobot.c
@@ -21,7 +21,6 @@
* too high.
*/
-#define IR_TIMING 1 /* try to emulate MB and VG running time */
#define DISASSEMBLE_MB_ROM 0 /* generate a disassembly of the mathbox ROMs */
#define IR_CPU_STATE(m) \
@@ -29,27 +28,6 @@
"%s, scanline: %d\n", cpuexec_describe_context(m), (m)->primary_screen->vpos())
-UINT8 irobot_vg_clear;
-static UINT8 irvg_vblank;
-static UINT8 irvg_running;
-static UINT8 irmb_running;
-
-#if IR_TIMING
-static timer_device *irvg_timer;
-static timer_device *irmb_timer;
-#endif
-
-static UINT8 *comRAM[2], *mbRAM, *mbROM;
-static UINT8 irobot_control_num = 0;
-static UINT8 irobot_statwr;
-static UINT8 irobot_out0;
-static UINT8 irobot_outx,irobot_mpage;
-
-static UINT8 *irobot_combase_mb;
-UINT8 *irobot_combase;
-UINT8 irobot_bufsel;
-UINT8 irobot_alphamap;
-
static void irmb_run(running_machine *machine);
@@ -59,17 +37,18 @@ static void irmb_run(running_machine *machine);
READ8_HANDLER( irobot_sharedmem_r )
{
- if (irobot_outx == 3)
- return mbRAM[BYTE_XOR_BE(offset)];
+ irobot_state *state = space->machine->driver_data<irobot_state>();
+ if (state->outx == 3)
+ return state->mbRAM[BYTE_XOR_BE(offset)];
- if (irobot_outx == 2)
- return irobot_combase[BYTE_XOR_BE(offset & 0xFFF)];
+ if (state->outx == 2)
+ return state->combase[BYTE_XOR_BE(offset & 0xFFF)];
- if (irobot_outx == 0)
- return mbROM[((irobot_mpage & 1) << 13) + BYTE_XOR_BE(offset)];
+ if (state->outx == 0)
+ return state->mbROM[((state->mpage & 1) << 13) + BYTE_XOR_BE(offset)];
- if (irobot_outx == 1)
- return mbROM[0x4000 + ((irobot_mpage & 3) << 13) + BYTE_XOR_BE(offset)];
+ if (state->outx == 1)
+ return state->mbROM[0x4000 + ((state->mpage & 3) << 13) + BYTE_XOR_BE(offset)];
return 0xFF;
}
@@ -77,55 +56,59 @@ READ8_HANDLER( irobot_sharedmem_r )
/* Comment out the mbRAM =, comRAM2 = or comRAM1 = and it will start working */
WRITE8_HANDLER( irobot_sharedmem_w )
{
- if (irobot_outx == 3)
- mbRAM[BYTE_XOR_BE(offset)] = data;
+ irobot_state *state = space->machine->driver_data<irobot_state>();
+ if (state->outx == 3)
+ state->mbRAM[BYTE_XOR_BE(offset)] = data;
- if (irobot_outx == 2)
- irobot_combase[BYTE_XOR_BE(offset & 0xFFF)] = data;
+ if (state->outx == 2)
+ state->combase[BYTE_XOR_BE(offset & 0xFFF)] = data;
}
TIMER_DEVICE_CALLBACK( irobot_irvg_done_callback )
{
+ irobot_state *state = timer.machine->driver_data<irobot_state>();
logerror("vg done. ");
- irvg_running = 0;
+ state->irvg_running = 0;
}
WRITE8_HANDLER( irobot_statwr_w )
{
+ irobot_state *state = space->machine->driver_data<irobot_state>();
logerror("write %2x ", data);
IR_CPU_STATE(space->machine);
- irobot_combase = comRAM[data >> 7];
- irobot_combase_mb = comRAM[(data >> 7) ^ 1];
- irobot_bufsel = data & 0x02;
- if (((data & 0x01) == 0x01) && (irobot_vg_clear == 0))
+ state->combase = state->comRAM[data >> 7];
+ state->combase_mb = state->comRAM[(data >> 7) ^ 1];
+ state->bufsel = data & 0x02;
+ if (((data & 0x01) == 0x01) && (state->vg_clear == 0))
irobot_poly_clear(space->machine);
- irobot_vg_clear = data & 0x01;
+ state->vg_clear = data & 0x01;
- if ((data & 0x04) && !(irobot_statwr & 0x04))
+ if ((data & 0x04) && !(state->statwr & 0x04))
{
- irobot_run_video();
+ irobot_run_video(space->machine);
#if IR_TIMING
- if (irvg_running == 0)
+ if (state->irvg_running == 0)
logerror("vg start ");
else
logerror("vg start [busy!] ");
IR_CPU_STATE(space->machine);
- irvg_timer->adjust(ATTOTIME_IN_MSEC(10));
+ state->irvg_timer->adjust(ATTOTIME_IN_MSEC(10));
#endif
- irvg_running=1;
+ state->irvg_running=1;
}
- if ((data & 0x10) && !(irobot_statwr & 0x10))
+ if ((data & 0x10) && !(state->statwr & 0x10))
irmb_run(space->machine);
- irobot_statwr = data;
+ state->statwr = data;
}
WRITE8_HANDLER( irobot_out0_w )
{
+ irobot_state *state = space->machine->driver_data<irobot_state>();
UINT8 *RAM = space->machine->region("maincpu")->base();
- irobot_out0 = data;
+ state->out0 = data;
switch (data & 0x60)
{
case 0:
@@ -138,9 +121,9 @@ WRITE8_HANDLER( irobot_out0_w )
memory_set_bankptr(space->machine, "bank2", &RAM[0x1D000]);
break;
}
- irobot_outx = (data & 0x18) >> 3;
- irobot_mpage = (data & 0x06) >> 1;
- irobot_alphamap = (data & 0x80);
+ state->outx = (data & 0x18) >> 3;
+ state->mpage = (data & 0x06) >> 1;
+ state->alphamap = (data & 0x80);
}
WRITE8_HANDLER( irobot_rom_banksel_w )
@@ -174,10 +157,11 @@ WRITE8_HANDLER( irobot_rom_banksel_w )
static TIMER_CALLBACK( scanline_callback )
{
+ irobot_state *state = machine->driver_data<irobot_state>();
int scanline = param;
- if (scanline == 0) irvg_vblank=0;
- if (scanline == 224) irvg_vblank=1;
+ if (scanline == 0) state->irvg_vblank=0;
+ if (scanline == 224) state->irvg_vblank=1;
logerror("SCANLINE CALLBACK %d\n",scanline);
/* set the IRQ line state based on the 32V line state */
cputag_set_input_line(machine, "maincpu", M6809_IRQ_LINE, (scanline & 32) ? ASSERT_LINE : CLEAR_LINE);
@@ -190,42 +174,45 @@ static TIMER_CALLBACK( scanline_callback )
MACHINE_RESET( irobot )
{
+ irobot_state *state = machine->driver_data<irobot_state>();
UINT8 *MB = machine->region("mathbox")->base();
/* initialize the memory regions */
- mbROM = MB + 0x00000;
- mbRAM = MB + 0x0c000;
- comRAM[0] = MB + 0x0e000;
- comRAM[1] = MB + 0x0f000;
+ state->mbROM = MB + 0x00000;
+ state->mbRAM = MB + 0x0c000;
+ state->comRAM[0] = MB + 0x0e000;
+ state->comRAM[1] = MB + 0x0f000;
- irvg_vblank=0;
- irvg_running = 0;
- irvg_timer = machine->device<timer_device>("irvg_timer");
- irmb_running = 0;
- irmb_timer = machine->device<timer_device>("irmb_timer");
+ state->irvg_vblank=0;
+ state->irvg_running = 0;
+ state->irvg_timer = machine->device<timer_device>("irvg_timer");
+ state->irmb_running = 0;
+ state->irmb_timer = machine->device<timer_device>("irmb_timer");
/* set an initial timer to go off on scanline 0 */
timer_set(machine, machine->primary_screen->time_until_pos(0), NULL, 0, scanline_callback);
irobot_rom_banksel_w(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM),0,0);
irobot_out0_w(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM),0,0);
- irobot_combase = comRAM[0];
- irobot_combase_mb = comRAM[1];
- irobot_outx = 0;
+ state->combase = state->comRAM[0];
+ state->combase_mb = state->comRAM[1];
+ state->outx = 0;
}
WRITE8_HANDLER( irobot_control_w )
{
+ irobot_state *state = space->machine->driver_data<irobot_state>();
- irobot_control_num = offset & 0x03;
+ state->control_num = offset & 0x03;
}
READ8_HANDLER( irobot_control_r )
{
+ irobot_state *state = space->machine->driver_data<irobot_state>();
- if (irobot_control_num == 0)
+ if (state->control_num == 0)
return input_port_read(space->machine, "AN0");
- else if (irobot_control_num == 1)
+ else if (state->control_num == 1)
return input_port_read(space->machine, "AN1");
return 0;
@@ -235,21 +222,22 @@ READ8_HANDLER( irobot_control_r )
them to simulate the mathbox and vector generator running in real time */
READ8_HANDLER( irobot_status_r )
{
+ irobot_state *state = space->machine->driver_data<irobot_state>();
int d=0;
logerror("status read. ");
IR_CPU_STATE(space->machine);
- if (!irmb_running) d |= 0x20;
- if (irvg_running) d |= 0x40;
+ if (!state->irmb_running) d |= 0x20;
+ if (state->irvg_running) d |= 0x40;
- // d = (irmb_running * 0x20) | (irvg_running * 0x40);
- if (irvg_vblank) d = d | 0x80;
+ // d = (state->irmb_running * 0x20) | (state->irvg_running * 0x40);
+ if (state->irvg_vblank) d = d | 0x80;
#if IR_TIMING
/* flags are cleared by callbacks */
#else
- irmb_running=0;
- irvg_running=0;
+ state->irmb_running=0;
+ state->irvg_running=0;
#endif
return d;
}
@@ -306,63 +294,44 @@ READ8_HANDLER( irobot_status_r )
#define FL_DIV 0x40
#define FL_MBRW 0x80
-typedef struct irmb_ops
-{
- const struct irmb_ops *nxtop;
- UINT32 func;
- UINT32 diradd;
- UINT32 latchmask;
- UINT32 *areg;
- UINT32 *breg;
- UINT8 cycles;
- UINT8 diren;
- UINT8 flags;
- UINT8 ramsel;
-} irmb_ops;
-
-static irmb_ops *mbops;
-
-static const irmb_ops *irmb_stack[16];
-static UINT32 irmb_regs[16];
-static UINT32 irmb_latch;
#if DISASSEMBLE_MB_ROM
static void disassemble_instruction(irmb_ops *op);
#endif
-static UINT32 irmb_din(const irmb_ops *curop)
+static UINT32 irmb_din(irobot_state *state, const irmb_ops *curop)
{
UINT32 d = 0;
if (!(curop->flags & FL_MBMEMDEC) && (curop->flags & FL_MBRW))
{
- UINT32 ad = curop->diradd | (irmb_latch & curop->latchmask);
+ UINT32 ad = curop->diradd | (state->irmb_latch & curop->latchmask);
- if (curop->diren || (irmb_latch & 0x6000) == 0)
- d = ((UINT16 *)mbRAM)[ad & 0xfff]; /* MB RAM read */
- else if (irmb_latch & 0x4000)
- d = ((UINT16 *)mbROM)[ad + 0x2000]; /* MB ROM read, CEMATH = 1 */
+ if (curop->diren || (state->irmb_latch & 0x6000) == 0)
+ d = ((UINT16 *)state->mbRAM)[ad & 0xfff]; /* MB RAM read */
+ else if (state->irmb_latch & 0x4000)
+ d = ((UINT16 *)state->mbROM)[ad + 0x2000]; /* MB ROM read, CEMATH = 1 */
else
- d = ((UINT16 *)mbROM)[ad & 0x1fff]; /* MB ROM read, CEMATH = 0 */
+ d = ((UINT16 *)state->mbROM)[ad & 0x1fff]; /* MB ROM read, CEMATH = 0 */
}
return d;
}
-static void irmb_dout(const irmb_ops *curop, UINT32 d)
+static void irmb_dout(irobot_state *state, const irmb_ops *curop, UINT32 d)
{
/* Write to video com ram */
if (curop->ramsel == 3)
- ((UINT16 *)irobot_combase_mb)[irmb_latch & 0x7ff] = d;
+ ((UINT16 *)state->combase_mb)[state->irmb_latch & 0x7ff] = d;
/* Write to mathox ram */
if (!(curop->flags & FL_MBMEMDEC))
{
- UINT32 ad = curop->diradd | (irmb_latch & curop->latchmask);
+ UINT32 ad = curop->diradd | (state->irmb_latch & curop->latchmask);
- if (curop->diren || (irmb_latch & 0x6000) == 0)
- ((UINT16 *)mbRAM)[ad & 0xfff] = d; /* MB RAM write */
+ if (curop->diren || (state->irmb_latch & 0x6000) == 0)
+ ((UINT16 *)state->mbRAM)[ad & 0xfff] = d; /* MB RAM write */
}
}
@@ -370,46 +339,47 @@ static void irmb_dout(const irmb_ops *curop, UINT32 d)
/* Convert microcode roms to a more usable form */
static void load_oproms(running_machine *machine)
{
+ irobot_state *state = machine->driver_data<irobot_state>();
UINT8 *MB = machine->region("proms")->base() + 0x20;
int i;
/* allocate RAM */
- mbops = auto_alloc_array(machine, irmb_ops, 1024);
+ state->mbops = auto_alloc_array(machine, irmb_ops, 1024);
for (i = 0; i < 1024; i++)
{
int nxtadd, func, ramsel, diradd, latchmask, dirmask, time;
- mbops[i].areg = &irmb_regs[MB[0x0000 + i] & 0x0F];
- mbops[i].breg = &irmb_regs[MB[0x0400 + i] & 0x0F];
+ state->mbops[i].areg = &state->irmb_regs[MB[0x0000 + i] & 0x0F];
+ state->mbops[i].breg = &state->irmb_regs[MB[0x0400 + i] & 0x0F];
func = (MB[0x0800 + i] & 0x0F) << 5;
func |= ((MB[0x0C00 +i] & 0x0F) << 1);
func |= (MB[0x1000 + i] & 0x08) >> 3;
time = MB[0x1000 + i] & 0x03;
- mbops[i].flags = (MB[0x1000 + i] & 0x04) >> 2;
+ state->mbops[i].flags = (MB[0x1000 + i] & 0x04) >> 2;
nxtadd = (MB[0x1400 + i] & 0x0C) >> 2;
diradd = MB[0x1400 + i] & 0x03;
nxtadd |= ((MB[0x1800 + i] & 0x0F) << 6);
nxtadd |= ((MB[0x1C00 + i] & 0x0F) << 2);
diradd |= (MB[0x2000 + i] & 0x0F) << 2;
func |= (MB[0x2400 + i] & 0x0E) << 9;
- mbops[i].flags |= (MB[0x2400 + i] & 0x01) << 1;
- mbops[i].flags |= (MB[0x2800 + i] & 0x0F) << 2;
- mbops[i].flags |= ((MB[0x2C00 + i] & 0x01) << 6);
- mbops[i].flags |= (MB[0x2C00 + i] & 0x08) << 4;
+ state->mbops[i].flags |= (MB[0x2400 + i] & 0x01) << 1;
+ state->mbops[i].flags |= (MB[0x2800 + i] & 0x0F) << 2;
+ state->mbops[i].flags |= ((MB[0x2C00 + i] & 0x01) << 6);
+ state->mbops[i].flags |= (MB[0x2C00 + i] & 0x08) << 4;
ramsel = (MB[0x2C00 + i] & 0x06) >> 1;
diradd |= (MB[0x3000 + i] & 0x03) << 6;
- if (mbops[i].flags & FL_shift) func |= 0x200;
+ if (state->mbops[i].flags & FL_shift) func |= 0x200;
- mbops[i].func = func;
- mbops[i].nxtop = &mbops[nxtadd];
+ state->mbops[i].func = func;
+ state->mbops[i].nxtop = &state->mbops[nxtadd];
/* determine the number of 12MHz cycles for this operation */
if (time == 3)
- mbops[i].cycles = 2;
+ state->mbops[i].cycles = 2;
else
- mbops[i].cycles = 3 + time;
+ state->mbops[i].cycles = 3 + time;
/* precompute the hardcoded address bits and the mask to be used on the latch value */
if (ramsel == 0)
@@ -427,13 +397,13 @@ static void load_oproms(running_machine *machine)
else
dirmask |= 0x0003;
- mbops[i].ramsel = ramsel;
- mbops[i].diradd = diradd & dirmask;
- mbops[i].latchmask = latchmask;
- mbops[i].diren = (ramsel == 0);
+ state->mbops[i].ramsel = ramsel;
+ state->mbops[i].diradd = diradd & dirmask;
+ state->mbops[i].latchmask = latchmask;
+ state->mbops[i].diren = (ramsel == 0);
#if DISASSEMBLE_MB_ROM
- disassemble_instruction(&mbops[i]);
+ disassemble_instruction(&state->mbops[i]);
#endif
}
}
@@ -442,20 +412,22 @@ static void load_oproms(running_machine *machine)
/* Init mathbox (only called once) */
DRIVER_INIT( irobot )
{
+ irobot_state *state = machine->driver_data<irobot_state>();
int i;
for (i = 0; i < 16; i++)
{
- irmb_stack[i] = &mbops[0];
- irmb_regs[i] = 0;
+ state->irmb_stack[i] = &state->mbops[0];
+ state->irmb_regs[i] = 0;
}
- irmb_latch=0;
+ state->irmb_latch=0;
load_oproms(machine);
}
TIMER_DEVICE_CALLBACK( irobot_irmb_done_callback )
{
- logerror("mb done. ");
- irmb_running = 0;
+ irobot_state *state = timer.machine->driver_data<irobot_state>();
+ logerror("mb done. ");
+ state->irmb_running = 0;
cputag_set_input_line(timer.machine, "maincpu", M6809_FIRQ_LINE, ASSERT_LINE);
}
@@ -568,15 +540,16 @@ TIMER_DEVICE_CALLBACK( irobot_irmb_done_callback )
#define JUMP3 if (!nflag) curop = curop->nxtop; else curop++;
#define JUMP4 if (nflag) curop = curop->nxtop; else curop++;
#define JUMP5 curop = curop->nxtop;
-#define JUMP6 irmb_stack[SP] = curop + 1; SP = (SP + 1) & 15; curop = curop->nxtop;
-#define JUMP7 SP = (SP - 1) & 15; curop = irmb_stack[SP];
+#define JUMP6 state->irmb_stack[SP] = curop + 1; SP = (SP + 1) & 15; curop = curop->nxtop;
+#define JUMP7 SP = (SP - 1) & 15; curop = state->irmb_stack[SP];
/* Run mathbox */
static void irmb_run(running_machine *machine)
{
- const irmb_ops *prevop = &mbops[0];
- const irmb_ops *curop = &mbops[0];
+ irobot_state *state = machine->driver_data<irobot_state>();
+ const irmb_ops *prevop = &state->mbops[0];
+ const irmb_ops *curop = &state->mbops[0];
UINT32 Q = 0;
UINT32 Y = 0;
@@ -621,65 +594,65 @@ static void irmb_run(running_machine *machine)
case 0x02: ADD(0, Q); break;
case 0x03: ADD(0, *curop->breg); break;
case 0x04: ADD(0, *curop->areg); break;
- case 0x05: tmp = irmb_din(curop); ADD(tmp, *curop->areg); break;
- case 0x06: tmp = irmb_din(curop); ADD(tmp, Q); break;
- case 0x07: tmp = irmb_din(curop); ADD(tmp, 0); break;
+ case 0x05: tmp = irmb_din(state, curop); ADD(tmp, *curop->areg); break;
+ case 0x06: tmp = irmb_din(state, curop); ADD(tmp, Q); break;
+ case 0x07: tmp = irmb_din(state, curop); ADD(tmp, 0); break;
case 0x08: SUBR(*curop->areg, Q); break;
case 0x09: SUBR(*curop->areg, *curop->breg); break;
case 0x0a: SUBR(0, Q); break;
case 0x0b: SUBR(0, *curop->breg); break;
case 0x0c: SUBR(0, *curop->areg); break;
- case 0x0d: tmp = irmb_din(curop); SUBR(tmp, *curop->areg); break;
- case 0x0e: tmp = irmb_din(curop); SUBR(tmp, Q); break;
- case 0x0f: tmp = irmb_din(curop); SUBR(tmp, 0); break;
+ case 0x0d: tmp = irmb_din(state, curop); SUBR(tmp, *curop->areg); break;
+ case 0x0e: tmp = irmb_din(state, curop); SUBR(tmp, Q); break;
+ case 0x0f: tmp = irmb_din(state, curop); SUBR(tmp, 0); break;
case 0x10: SUB(*curop->areg, Q); break;
case 0x11: SUB(*curop->areg, *curop->breg); break;
case 0x12: SUB(0, Q); break;
case 0x13: SUB(0, *curop->breg); break;
case 0x14: SUB(0, *curop->areg); break;
- case 0x15: tmp = irmb_din(curop); SUB(tmp, *curop->areg); break;
- case 0x16: tmp = irmb_din(curop); SUB(tmp, Q); break;
- case 0x17: tmp = irmb_din(curop); SUB(tmp, 0); break;
+ case 0x15: tmp = irmb_din(state, curop); SUB(tmp, *curop->areg); break;
+ case 0x16: tmp = irmb_din(state, curop); SUB(tmp, Q); break;
+ case 0x17: tmp = irmb_din(state, curop); SUB(tmp, 0); break;
case 0x18: OR(*curop->areg, Q); break;
case 0x19: OR(*curop->areg, *curop->breg); break;
case 0x1a: OR(0, Q); break;
case 0x1b: OR(0, *curop->breg); break;
case 0x1c: OR(0, *curop->areg); break;
- case 0x1d: OR(irmb_din(curop), *curop->areg); break;
- case 0x1e: OR(irmb_din(curop), Q); break;
- case 0x1f: OR(irmb_din(curop), 0); break;
+ case 0x1d: OR(irmb_din(state, curop), *curop->areg); break;
+ case 0x1e: OR(irmb_din(state, curop), Q); break;
+ case 0x1f: OR(irmb_din(state, curop), 0); break;
case 0x20: AND(*curop->areg, Q); break;
case 0x21: AND(*curop->areg, *curop->breg); break;
case 0x22: AND(0, Q); break;
case 0x23: AND(0, *curop->breg); break;
case 0x24: AND(0, *curop->areg); break;
- case 0x25: AND(irmb_din(curop), *curop->areg); break;
- case 0x26: AND(irmb_din(curop), Q); break;
- case 0x27: AND(irmb_din(curop), 0); break;
+ case 0x25: AND(irmb_din(state, curop), *curop->areg); break;
+ case 0x26: AND(irmb_din(state, curop), Q); break;
+ case 0x27: AND(irmb_din(state, curop), 0); break;
case 0x28: IAND(*curop->areg, Q); break;
case 0x29: IAND(*curop->areg, *curop->breg); break;
case 0x2a: IAND(0, Q); break;
case 0x2b: IAND(0, *curop->breg); break;
case 0x2c: IAND(0, *curop->areg); break;
- case 0x2d: IAND(irmb_din(curop), *curop->areg); break;
- case 0x2e: IAND(irmb_din(curop), Q); break;
- case 0x2f: IAND(irmb_din(curop), 0); break;
+ case 0x2d: IAND(irmb_din(state, curop), *curop->areg); break;
+ case 0x2e: IAND(irmb_din(state, curop), Q); break;
+ case 0x2f: IAND(irmb_din(state, curop), 0); break;
case 0x30: XOR(*curop->areg, Q); break;
case 0x31: XOR(*curop->areg, *curop->breg); break;
case 0x32: XOR(0, Q); break;
case 0x33: XOR(0, *curop->breg); break;
case 0x34: XOR(0, *curop->areg); break;
- case 0x35: XOR(irmb_din(curop), *curop->areg); break;
- case 0x36: XOR(irmb_din(curop), Q); break;
- case 0x37: XOR(irmb_din(curop), 0); break;
+ case 0x35: XOR(irmb_din(state, curop), *curop->areg); break;
+ case 0x36: XOR(irmb_din(state, curop), Q); break;
+ case 0x37: XOR(irmb_din(state, curop), 0); break;
case 0x38: IXOR(*curop->areg, Q); break;
case 0x39: IXOR(*curop->areg, *curop->breg); break;
case 0x3a: IXOR(0, Q); break;
case 0x3b: IXOR(0, *curop->breg); break;
case 0x3c: IXOR(0, *curop->areg); break;
- case 0x3d: IXOR(irmb_din(curop), *curop->areg); break;
- case 0x3e: IXOR(irmb_din(curop), Q); break;
-default: case 0x3f: IXOR(irmb_din(curop), 0); break;
+ case 0x3d: IXOR(irmb_din(state, curop), *curop->areg); break;
+ case 0x3e: IXOR(irmb_din(state, curop), Q); break;
+default: case 0x3f: IXOR(irmb_din(state, curop), 0); break;
}
/* Evaluate flags */
@@ -830,15 +803,15 @@ default: case 0x3f: IXOR(irmb_din(curop), 0); break;
/* Do write */
if (!(prevop->flags & FL_MBRW))
- irmb_dout(prevop, Y);
+ irmb_dout(state, prevop, Y);
/* ADDEN */
if (!(prevop->flags & FL_ADDEN))
{
if (prevop->flags & FL_MBRW)
- irmb_latch = irmb_din(prevop);
+ state->irmb_latch = irmb_din(state, prevop);
else
- irmb_latch = Y;
+ state->irmb_latch = Y;
}
}
g_profiler.stop();
@@ -847,9 +820,9 @@ default: case 0x3f: IXOR(irmb_din(curop), 0); break;
#if IR_TIMING
- if (irmb_running == 0)
+ if (state->irmb_running == 0)
{
- irmb_timer->adjust(attotime_mul(ATTOTIME_IN_HZ(12000000), icount));
+ state->irmb_timer->adjust(attotime_mul(ATTOTIME_IN_HZ(12000000), icount));
logerror("mb start ");
IR_CPU_STATE(machine);
}
@@ -857,12 +830,12 @@ default: case 0x3f: IXOR(irmb_din(curop), 0); break;
{
logerror("mb start [busy!] ");
IR_CPU_STATE(machine);
- irmb_timer->adjust(attotime_mul(ATTOTIME_IN_NSEC(200), icount));
+ state->irmb_timer->adjust(attotime_mul(ATTOTIME_IN_NSEC(200), icount));
}
#else
cputag_set_input_line(machine, "maincpu", M6809_FIRQ_LINE, ASSERT_LINE);
#endif
- irmb_running=1;
+ state->irmb_running=1;
}
diff --git a/src/mame/machine/mhavoc.c b/src/mame/machine/mhavoc.c
index 83d1bbcfa6c..a296c6bca47 100644
--- a/src/mame/machine/mhavoc.c
+++ b/src/mame/machine/mhavoc.c
@@ -9,25 +9,6 @@
#include "cpu/m6502/m6502.h"
#include "includes/mhavoc.h"
-UINT8 *mhavoc_zram0, *mhavoc_zram1;
-
-static UINT8 alpha_data;
-static UINT8 alpha_rcvd;
-static UINT8 alpha_xmtd;
-
-static UINT8 gamma_data;
-static UINT8 gamma_rcvd;
-static UINT8 gamma_xmtd;
-
-static UINT8 player_1;
-
-static UINT8 alpha_irq_clock;
-static UINT8 alpha_irq_clock_enable;
-static UINT8 gamma_irq_clock;
-
-static UINT8 has_gamma_cpu;
-
-static UINT8 speech_write_buffer;
/*************************************
*
@@ -37,40 +18,43 @@ static UINT8 speech_write_buffer;
TIMER_DEVICE_CALLBACK( mhavoc_cpu_irq_clock )
{
+ mhavoc_state *state = timer.machine->driver_data<mhavoc_state>();
/* clock the LS161 driving the alpha CPU IRQ */
- if (alpha_irq_clock_enable)
+ if (state->alpha_irq_clock_enable)
{
- alpha_irq_clock++;
- if ((alpha_irq_clock & 0x0c) == 0x0c)
+ state->alpha_irq_clock++;
+ if ((state->alpha_irq_clock & 0x0c) == 0x0c)
{
cputag_set_input_line(timer.machine, "alpha", 0, ASSERT_LINE);
- alpha_irq_clock_enable = 0;
+ state->alpha_irq_clock_enable = 0;
}
}
/* clock the LS161 driving the gamma CPU IRQ */
- if (has_gamma_cpu)
+ if (state->has_gamma_cpu)
{
- gamma_irq_clock++;
- cputag_set_input_line(timer.machine, "gamma", 0, (gamma_irq_clock & 0x08) ? ASSERT_LINE : CLEAR_LINE);
+ state->gamma_irq_clock++;
+ cputag_set_input_line(timer.machine, "gamma", 0, (state->gamma_irq_clock & 0x08) ? ASSERT_LINE : CLEAR_LINE);
}
}
WRITE8_HANDLER( mhavoc_alpha_irq_ack_w )
{
+ mhavoc_state *state = space->machine->driver_data<mhavoc_state>();
/* clear the line and reset the clock */
cputag_set_input_line(space->machine, "alpha", 0, CLEAR_LINE);
- alpha_irq_clock = 0;
- alpha_irq_clock_enable = 1;
+ state->alpha_irq_clock = 0;
+ state->alpha_irq_clock_enable = 1;
}
WRITE8_HANDLER( mhavoc_gamma_irq_ack_w )
{
+ mhavoc_state *state = space->machine->driver_data<mhavoc_state>();
/* clear the line and reset the clock */
cputag_set_input_line(space->machine, "gamma", 0, CLEAR_LINE);
- gamma_irq_clock = 0;
+ state->gamma_irq_clock = 0;
}
@@ -83,28 +67,30 @@ WRITE8_HANDLER( mhavoc_gamma_irq_ack_w )
MACHINE_START( mhavoc )
{
- state_save_register_item(machine, "misc", NULL, 0, alpha_data);
- state_save_register_item(machine, "misc", NULL, 0, alpha_rcvd);
- state_save_register_item(machine, "misc", NULL, 0, alpha_xmtd);
- state_save_register_item(machine, "misc", NULL, 0, gamma_data);
- state_save_register_item(machine, "misc", NULL, 0, gamma_rcvd);
- state_save_register_item(machine, "misc", NULL, 0, gamma_xmtd);
- state_save_register_item(machine, "misc", NULL, 0, player_1);
- state_save_register_item(machine, "misc", NULL, 0, alpha_irq_clock);
- state_save_register_item(machine, "misc", NULL, 0, alpha_irq_clock_enable);
- state_save_register_item(machine, "misc", NULL, 0, gamma_irq_clock);
-
- state_save_register_item(machine, "misc", NULL, 0, speech_write_buffer);
+ mhavoc_state *state = machine->driver_data<mhavoc_state>();
+ state_save_register_item(machine, "misc", NULL, 0, state->alpha_data);
+ state_save_register_item(machine, "misc", NULL, 0, state->alpha_rcvd);
+ state_save_register_item(machine, "misc", NULL, 0, state->alpha_xmtd);
+ state_save_register_item(machine, "misc", NULL, 0, state->gamma_data);
+ state_save_register_item(machine, "misc", NULL, 0, state->gamma_rcvd);
+ state_save_register_item(machine, "misc", NULL, 0, state->gamma_xmtd);
+ state_save_register_item(machine, "misc", NULL, 0, state->player_1);
+ state_save_register_item(machine, "misc", NULL, 0, state->alpha_irq_clock);
+ state_save_register_item(machine, "misc", NULL, 0, state->alpha_irq_clock_enable);
+ state_save_register_item(machine, "misc", NULL, 0, state->gamma_irq_clock);
+
+ state_save_register_item(machine, "misc", NULL, 0, state->speech_write_buffer);
}
MACHINE_RESET( mhavoc )
{
+ mhavoc_state *state = machine->driver_data<mhavoc_state>();
address_space *space = cputag_get_address_space(machine, "alpha", ADDRESS_SPACE_PROGRAM);
- has_gamma_cpu = (machine->device("gamma") != NULL);
+ state->has_gamma_cpu = (machine->device("gamma") != NULL);
- memory_configure_bank(machine, "bank1", 0, 1, mhavoc_zram0, 0);
- memory_configure_bank(machine, "bank1", 1, 1, mhavoc_zram1, 0);
+ memory_configure_bank(machine, "bank1", 0, 1, state->zram0, 0);
+ memory_configure_bank(machine, "bank1", 1, 1, state->zram1, 0);
memory_configure_bank(machine, "bank2", 0, 4, machine->region("alpha")->base() + 0x10000, 0x2000);
/* reset RAM/ROM banks to 0 */
@@ -112,22 +98,22 @@ MACHINE_RESET( mhavoc )
mhavoc_rom_banksel_w(space, 0, 0);
/* reset alpha comm status */
- alpha_data = 0;
- alpha_rcvd = 0;
- alpha_xmtd = 0;
+ state->alpha_data = 0;
+ state->alpha_rcvd = 0;
+ state->alpha_xmtd = 0;
/* reset gamma comm status */
- gamma_data = 0;
- gamma_rcvd = 0;
- gamma_xmtd = 0;
+ state->gamma_data = 0;
+ state->gamma_rcvd = 0;
+ state->gamma_xmtd = 0;
/* reset player 1 flag */
- player_1 = 0;
+ state->player_1 = 0;
/* reset IRQ clock states */
- alpha_irq_clock = 0;
- alpha_irq_clock_enable = 1;
- gamma_irq_clock = 0;
+ state->alpha_irq_clock = 0;
+ state->alpha_irq_clock_enable = 1;
+ state->gamma_irq_clock = 0;
}
@@ -140,10 +126,11 @@ MACHINE_RESET( mhavoc )
static TIMER_CALLBACK( delayed_gamma_w )
{
+ mhavoc_state *state = machine->driver_data<mhavoc_state>();
/* mark the data received */
- gamma_rcvd = 0;
- alpha_xmtd = 1;
- alpha_data = param;
+ state->gamma_rcvd = 0;
+ state->alpha_xmtd = 1;
+ state->alpha_data = param;
/* signal with an NMI pulse */
cputag_set_input_line(machine, "gamma", INPUT_LINE_NMI, PULSE_LINE);
@@ -155,17 +142,19 @@ static TIMER_CALLBACK( delayed_gamma_w )
WRITE8_HANDLER( mhavoc_gamma_w )
{
- logerror(" writing to gamma processor: %02x (%d %d)\n", data, gamma_rcvd, alpha_xmtd);
+ mhavoc_state *state = space->machine->driver_data<mhavoc_state>();
+ logerror(" writing to gamma processor: %02x (%d %d)\n", data, state->gamma_rcvd, state->alpha_xmtd);
timer_call_after_resynch(space->machine, NULL, data, delayed_gamma_w);
}
READ8_HANDLER( mhavoc_alpha_r )
{
- logerror("\t\t\t\t\treading from alpha processor: %02x (%d %d)\n", alpha_data, gamma_rcvd, alpha_xmtd);
- gamma_rcvd = 1;
- alpha_xmtd = 0;
- return alpha_data;
+ mhavoc_state *state = space->machine->driver_data<mhavoc_state>();
+ logerror("\t\t\t\t\treading from alpha processor: %02x (%d %d)\n", state->alpha_data, state->gamma_rcvd, state->alpha_xmtd);
+ state->gamma_rcvd = 1;
+ state->alpha_xmtd = 0;
+ return state->alpha_data;
}
@@ -178,19 +167,21 @@ READ8_HANDLER( mhavoc_alpha_r )
WRITE8_HANDLER( mhavoc_alpha_w )
{
- logerror("\t\t\t\t\twriting to alpha processor: %02x %d %d\n", data, alpha_rcvd, gamma_xmtd);
- alpha_rcvd = 0;
- gamma_xmtd = 1;
- gamma_data = data;
+ mhavoc_state *state = space->machine->driver_data<mhavoc_state>();
+ logerror("\t\t\t\t\twriting to alpha processor: %02x %d %d\n", data, state->alpha_rcvd, state->gamma_xmtd);
+ state->alpha_rcvd = 0;
+ state->gamma_xmtd = 1;
+ state->gamma_data = data;
}
READ8_HANDLER( mhavoc_gamma_r )
{
- logerror(" reading from gamma processor: %02x (%d %d)\n", gamma_data, alpha_rcvd, gamma_xmtd);
- alpha_rcvd = 1;
- gamma_xmtd = 0;
- return gamma_data;
+ mhavoc_state *state = space->machine->driver_data<mhavoc_state>();
+ logerror(" reading from gamma processor: %02x (%d %d)\n", state->gamma_data, state->alpha_rcvd, state->gamma_xmtd);
+ state->alpha_rcvd = 1;
+ state->gamma_xmtd = 0;
+ return state->gamma_data;
}
@@ -227,33 +218,38 @@ CUSTOM_INPUT( tms5220_r )
CUSTOM_INPUT( mhavoc_bit67_r )
{
+ mhavoc_state *state = field->port->machine->driver_data<mhavoc_state>();
const char *tag1 = (const char *)param;
const char *tag2 = tag1 + strlen(tag1) + 1;
- return input_port_read(field->port->machine, player_1 ? tag2 : tag1) & 0x03;
+ return input_port_read(field->port->machine, state->player_1 ? tag2 : tag1) & 0x03;
}
CUSTOM_INPUT( gamma_rcvd_r )
{
+ mhavoc_state *state = field->port->machine->driver_data<mhavoc_state>();
/* Gamma rcvd flag */
- return gamma_rcvd;
+ return state->gamma_rcvd;
}
CUSTOM_INPUT( gamma_xmtd_r )
{
+ mhavoc_state *state = field->port->machine->driver_data<mhavoc_state>();
/* Gamma xmtd flag */
- return gamma_xmtd;
+ return state->gamma_xmtd;
}
CUSTOM_INPUT( alpha_rcvd_r )
{
+ mhavoc_state *state = field->port->machine->driver_data<mhavoc_state>();
/* Alpha rcvd flag */
- return (has_gamma_cpu && alpha_rcvd);
+ return (state->has_gamma_cpu && state->alpha_rcvd);
}
CUSTOM_INPUT( alpha_xmtd_r )
{
+ mhavoc_state *state = field->port->machine->driver_data<mhavoc_state>();
/* Alpha xmtd flag */
- return (has_gamma_cpu && alpha_xmtd);
+ return (state->has_gamma_cpu && state->alpha_xmtd);
}
/*************************************
@@ -264,21 +260,22 @@ CUSTOM_INPUT( alpha_xmtd_r )
WRITE8_HANDLER( mhavoc_out_0_w )
{
+ mhavoc_state *state = space->machine->driver_data<mhavoc_state>();
/* Bit 7 = Invert Y -- unemulated */
/* Bit 6 = Invert X -- unemulated */
/* Bit 5 = Player 1 */
- player_1 = (data >> 5) & 1;
+ state->player_1 = (data >> 5) & 1;
/* Bit 3 = Gamma reset */
cputag_set_input_line(space->machine, "gamma", INPUT_LINE_RESET, (data & 0x08) ? CLEAR_LINE : ASSERT_LINE);
if (!(data & 0x08))
{
logerror("\t\t\t\t*** resetting gamma processor. ***\n");
- alpha_rcvd = 0;
- alpha_xmtd = 0;
- gamma_rcvd = 0;
- gamma_xmtd = 0;
+ state->alpha_rcvd = 0;
+ state->alpha_xmtd = 0;
+ state->gamma_rcvd = 0;
+ state->gamma_xmtd = 0;
}
/* Bit 0 = Roller light (Blinks on fatal errors) */
@@ -321,14 +318,16 @@ WRITE8_HANDLER( mhavoc_out_1_w )
static WRITE8_HANDLER( mhavocrv_speech_data_w )
{
- speech_write_buffer = data;
+ mhavoc_state *state = space->machine->driver_data<mhavoc_state>();
+ state->speech_write_buffer = data;
}
static WRITE8_HANDLER( mhavocrv_speech_strobe_w )
{
+ mhavoc_state *state = space->machine->driver_data<mhavoc_state>();
device_t *tms = space->machine->device("tms");
- tms5220_data_w(tms, 0, speech_write_buffer);
+ tms5220_data_w(tms, 0, state->speech_write_buffer);
}
/*************************************
diff --git a/src/mame/machine/starwars.c b/src/mame/machine/starwars.c
index a8affb1766c..d49bda21bcb 100644
--- a/src/mame/machine/starwars.c
+++ b/src/mame/machine/starwars.c
@@ -33,32 +33,12 @@
#define MASTER_CLOCK (12096000)
-UINT8 *starwars_mathram;
-
-/* Local variables */
-static UINT8 control_num = kPitch;
-
-static int MPA; /* PROM address counter */
-static int BIC; /* Block index counter */
-
-static UINT16 dvd_shift, quotient_shift; /* Divider shift registers */
-static UINT16 divisor, dividend; /* Divider latches */
-
-/* Store decoded PROM elements */
-static UINT8 *PROM_STR; /* Storage for instruction strobe only */
-static UINT8 *PROM_MAS; /* Storage for direct address only */
-static UINT8 *PROM_AM; /* Storage for address mode select only */
-
-static int math_run;
-static emu_timer *math_timer;
-
-/* Local function prototypes */
-static void run_mproc(void);
static TIMER_CALLBACK( math_run_clear )
{
- math_run = 0;
+ starwars_state *state = machine->driver_data<starwars_state>();
+ state->math_run = 0;
}
@@ -83,6 +63,7 @@ WRITE8_HANDLER( starwars_nstore_w )
WRITE8_HANDLER( starwars_out_w )
{
+ starwars_state *state = space->machine->driver_data<starwars_state>();
switch (offset & 7)
{
case 0: /* Coin counter 1 */
@@ -103,7 +84,7 @@ WRITE8_HANDLER( starwars_out_w )
case 4: /* bank switch */
memory_set_bank(space->machine, "bank1", (data >> 7) & 1);
- if (starwars_is_esb)
+ if (state->is_esb)
memory_set_bank(space->machine, "bank2", (data >> 7) & 1);
break;
case 5: /* reset PRNG */
@@ -129,8 +110,9 @@ WRITE8_HANDLER( starwars_out_w )
CUSTOM_INPUT( matrix_flag_r )
{
+ starwars_state *state = field->port->machine->driver_data<starwars_state>();
/* set the matrix processor flag */
- return math_run ? 1 : 0;
+ return state->math_run ? 1 : 0;
}
@@ -143,12 +125,13 @@ CUSTOM_INPUT( matrix_flag_r )
READ8_HANDLER( starwars_adc_r )
{
+ starwars_state *state = space->machine->driver_data<starwars_state>();
/* pitch */
- if (control_num == kPitch)
+ if (state->control_num == kPitch)
return input_port_read(space->machine, "STICKY");
/* yaw */
- else if (control_num == kYaw)
+ else if (state->control_num == kYaw)
return input_port_read(space->machine, "STICKX");
/* default to unused thrust */
@@ -159,7 +142,8 @@ READ8_HANDLER( starwars_adc_r )
WRITE8_HANDLER( starwars_adc_select_w )
{
- control_num = offset;
+ starwars_state *state = space->machine->driver_data<starwars_state>();
+ state->control_num = offset;
}
@@ -172,12 +156,13 @@ WRITE8_HANDLER( starwars_adc_select_w )
void starwars_mproc_init(running_machine *machine)
{
+ starwars_state *state = machine->driver_data<starwars_state>();
UINT8 *src = machine->region("user2")->base();
int cnt, val;
- PROM_STR = auto_alloc_array(machine, UINT8, 1024);
- PROM_MAS = auto_alloc_array(machine, UINT8, 1024);
- PROM_AM = auto_alloc_array(machine, UINT8, 1024);
+ state->PROM_STR = auto_alloc_array(machine, UINT8, 1024);
+ state->PROM_MAS = auto_alloc_array(machine, UINT8, 1024);
+ state->PROM_AM = auto_alloc_array(machine, UINT8, 1024);
for (cnt = 0; cnt < 1024; cnt++)
{
@@ -188,12 +173,12 @@ void starwars_mproc_init(running_machine *machine)
val |= (src[0x0000 + cnt] << 12) & 0xf000; /* Set MS nibble */
/* perform pre-decoding */
- PROM_STR[cnt] = (val >> 8) & 0x00ff;
- PROM_MAS[cnt] = val & 0x007f;
- PROM_AM[cnt] = (val >> 7) & 0x0001;
+ state->PROM_STR[cnt] = (val >> 8) & 0x00ff;
+ state->PROM_MAS[cnt] = val & 0x007f;
+ state->PROM_AM[cnt] = (val >> 7) & 0x0001;
}
- math_timer = timer_alloc(machine, math_run_clear, NULL);
+ state->math_timer = timer_alloc(machine, math_run_clear, NULL);
}
@@ -204,10 +189,11 @@ void starwars_mproc_init(running_machine *machine)
*
*************************************/
-void starwars_mproc_reset(void)
+void starwars_mproc_reset(running_machine *machine)
{
- MPA = BIC = 0;
- math_run = 0;
+ starwars_state *state = machine->driver_data<starwars_state>();
+ state->MPA = state->BIC = 0;
+ state->math_run = 0;
}
@@ -218,10 +204,9 @@ void starwars_mproc_reset(void)
*
*************************************/
-void run_mproc(void)
+static void run_mproc(running_machine *machine)
{
- static INT16 A, B, C;
- static INT32 ACC;
+ starwars_state *state = machine->driver_data<starwars_state>();
int RAMWORD = 0;
int MA_byte;
@@ -234,7 +219,7 @@ void run_mproc(void)
logerror("Running Matrix Processor...\n");
mptime = 0;
- math_run = 1;
+ state->math_run = 1;
/* loop until finished */
while (M_STOP > 0)
@@ -244,18 +229,18 @@ void run_mproc(void)
mptime += 5;
/* fetch the current instruction data */
- IP15_8 = PROM_STR[MPA];
- IP7 = PROM_AM[MPA];
- IP6_0 = PROM_MAS[MPA];
+ IP15_8 = state->PROM_STR[state->MPA];
+ IP7 = state->PROM_AM[state->MPA];
+ IP6_0 = state->PROM_MAS[state->MPA];
#if (MATHDEBUG)
- mame_printf_debug("\n(MPA:%x), Strobe: %x, IP7: %d, IP6_0:%x\n",MPA, IP15_8, IP7, IP6_0);
- mame_printf_debug("(BIC: %x), A: %x, B: %x, C: %x, ACC: %x\n",BIC,A,B,C,ACC);
+ mame_printf_debug("\n(state->MPA:%x), Strobe: %x, IP7: %d, IP6_0:%x\n",state->MPA, IP15_8, IP7, IP6_0);
+ mame_printf_debug("(state->BIC: %x), state->A: %x, state->B: %x, state->C: %x, state->ACC: %x\n",state->BIC,state->A,state->B,state->C,state->ACC);
#endif
/* construct the current RAM address */
if (IP7 == 0)
- MA = (IP6_0 & 3) | ((BIC & 0x01ff) << 2); /* MA10-2 set to BIC8-0 */
+ MA = (IP6_0 & 3) | ((state->BIC & 0x01ff) << 2); /* MA10-2 set to BIC8-0 */
else
MA = IP6_0;
@@ -263,7 +248,7 @@ void run_mproc(void)
and apply base address offset */
MA_byte = MA << 1;
- RAMWORD = (starwars_mathram[MA_byte + 1] & 0x00ff) | ((starwars_mathram[MA_byte] & 0x00ff) << 8);
+ RAMWORD = (state->mathram[MA_byte + 1] & 0x00ff) | ((state->mathram[MA_byte] & 0x00ff) << 8);
// logerror("MATH ADDR: %x, CPU ADDR: %x, RAMWORD: %x\n", MA, MA_byte, RAMWORD);
@@ -285,18 +270,18 @@ void run_mproc(void)
/* 0x10 - CLEAR_ACC */
if (IP15_8 & CLEAR_ACC)
{
- ACC = 0;
+ state->ACC = 0;
}
/* 0x01 - LAC (also clears lsb)*/
if (IP15_8 & LAC)
- ACC = (RAMWORD << 16);
+ state->ACC = (RAMWORD << 16);
/* 0x02 - READ_ACC */
if (IP15_8 & READ_ACC)
{
- starwars_mathram[MA_byte+1] = ((ACC >> 16) & 0xff);
- starwars_mathram[MA_byte ] = ((ACC >> 24) & 0xff);
+ state->mathram[MA_byte+1] = ((state->ACC >> 16) & 0xff);
+ state->mathram[MA_byte ] = ((state->ACC >> 24) & 0xff);
}
/* 0x04 - M_HALT */
@@ -305,12 +290,12 @@ void run_mproc(void)
/* 0x08 - INC_BIC */
if (IP15_8 & INC_BIC)
- BIC = (BIC + 1) & 0x1ff; /* Restrict to 9 bits */
+ state->BIC = (state->BIC + 1) & 0x1ff; /* Restrict to 9 bits */
/* 0x20 - LDC*/
if (IP15_8 & LDC)
{
- C = RAMWORD;
+ state->C = RAMWORD;
/* This is a serial subtractor - multiplier (74ls384) -
* accumulator. For the full calculation 33 GMCLK pulses
@@ -341,13 +326,13 @@ void run_mproc(void)
* takes 33 clock pulses to do a full rotation.
*/
- ACC += (((INT32)(A - B) << 1) * C) << 1;
+ state->ACC += (((INT32)(state->A - state->B) << 1) * state->C) << 1;
- /* A and B are sign extended (requred by the ls384). After
+ /* state->A and state->B are sign extended (requred by the ls384). After
* multiplication they just contain the sign.
*/
- A = (A & 0x8000)? 0xffff: 0;
- B = (B & 0x8000)? 0xffff: 0;
+ state->A = (state->A & 0x8000)? 0xffff: 0;
+ state->B = (state->B & 0x8000)? 0xffff: 0;
/* The multiply-add holds the main matrix processor counter
* for 33 cycles
@@ -357,11 +342,11 @@ void run_mproc(void)
/* 0x40 - LDB */
if (IP15_8 & LDB)
- B = RAMWORD;
+ state->B = RAMWORD;
/* 0x80 - LDA */
if (IP15_8 & LDA)
- A = RAMWORD;
+ state->A = RAMWORD;
/*
* Now update the PROM address counter
@@ -369,13 +354,13 @@ void run_mproc(void)
* This means that each of the four pages should wrap around rather than
* leaking from one to another. It may not matter, but I've put it in anyway
*/
- tmp = MPA + 1;
- MPA = (MPA & 0x0300) | (tmp & 0x00ff); /* New MPA value */
+ tmp = state->MPA + 1;
+ state->MPA = (state->MPA & 0x0300) | (tmp & 0x00ff); /* New state->MPA value */
M_STOP--; /* Decrease count */
}
- timer_adjust_oneshot(math_timer, attotime_mul(ATTOTIME_IN_HZ(MASTER_CLOCK), mptime), 1);
+ timer_adjust_oneshot(state->math_timer, attotime_mul(ATTOTIME_IN_HZ(MASTER_CLOCK), mptime), 1);
}
@@ -414,40 +399,43 @@ READ8_HANDLER( starwars_prng_r )
READ8_HANDLER( starwars_div_reh_r )
{
- return (quotient_shift & 0xff00) >> 8;
+ starwars_state *state = space->machine->driver_data<starwars_state>();
+ return (state->quotient_shift & 0xff00) >> 8;
}
READ8_HANDLER( starwars_div_rel_r )
{
- return quotient_shift & 0x00ff;
+ starwars_state *state = space->machine->driver_data<starwars_state>();
+ return state->quotient_shift & 0x00ff;
}
WRITE8_HANDLER( starwars_math_w )
{
+ starwars_state *state = space->machine->driver_data<starwars_state>();
int i;
data &= 0xff; /* ASG 971002 -- make sure we only get bytes here */
switch (offset)
{
case 0: /* mw0 */
- MPA = data << 2; /* Set starting PROM address */
- run_mproc(); /* and run the Matrix Processor */
+ state->MPA = data << 2; /* Set starting PROM address */
+ run_mproc(space->machine); /* and run the Matrix Processor */
break;
case 1: /* mw1 */
- BIC = (BIC & 0x00ff) | ((data & 0x01) << 8);
+ state->BIC = (state->BIC & 0x00ff) | ((data & 0x01) << 8);
break;
case 2: /* mw2 */
- BIC = (BIC & 0x0100) | data;
+ state->BIC = (state->BIC & 0x0100) | data;
break;
case 4: /* dvsrh */
- divisor = (divisor & 0x00ff) | (data << 8);
- dvd_shift = dividend;
- quotient_shift = 0;
+ state->divisor = (state->divisor & 0x00ff) | (data << 8);
+ state->dvd_shift = state->dividend;
+ state->quotient_shift = 0;
break;
case 5: /* dvsrl */
@@ -457,35 +445,35 @@ WRITE8_HANDLER( starwars_math_w )
/* If the Tie fighters look corrupt, he byte order of */
/* the 16 bit writes in the 6809 are backwards */
- divisor = (divisor & 0xff00) | data;
+ state->divisor = (state->divisor & 0xff00) | data;
/*
* Simple restoring division as shown in the
* schematics. The algorithm produces the same "wrong"
- * results as the hardware if divisor < 2*dividend or
- * divisor > 0x8000.
+ * results as the hardware if state->divisor < 2*state->dividend or
+ * state->divisor > 0x8000.
*/
for (i = 1; i < 16; i++)
{
- quotient_shift <<= 1;
- if (((INT32)dvd_shift + (divisor ^ 0xffff) + 1) & 0x10000)
+ state->quotient_shift <<= 1;
+ if (((INT32)state->dvd_shift + (state->divisor ^ 0xffff) + 1) & 0x10000)
{
- quotient_shift |= 1;
- dvd_shift = (dvd_shift + (divisor ^ 0xffff) + 1) << 1;
+ state->quotient_shift |= 1;
+ state->dvd_shift = (state->dvd_shift + (state->divisor ^ 0xffff) + 1) << 1;
}
else
{
- dvd_shift <<= 1;
+ state->dvd_shift <<= 1;
}
}
break;
case 6: /* dvddh */
- dividend = (dividend & 0x00ff) | (data << 8);
+ state->dividend = (state->dividend & 0x00ff) | (data << 8);
break;
case 7: /* dvddl */
- dividend = (dividend & 0xff00) | (data);
+ state->dividend = (state->dividend & 0xff00) | (data);
break;
default:
diff --git a/src/mame/machine/subs.c b/src/mame/machine/subs.c
index 88bcc767c7a..f193ae91ba0 100644
--- a/src/mame/machine/subs.c
+++ b/src/mame/machine/subs.c
@@ -7,20 +7,17 @@
#include "emu.h"
#include "includes/subs.h"
-static int subs_steering_buf1;
-static int subs_steering_buf2;
-static int subs_steering_val1;
-static int subs_steering_val2;
/***************************************************************************
subs_init_machine
***************************************************************************/
MACHINE_RESET( subs )
{
- subs_steering_buf1 = 0;
- subs_steering_buf2 = 0;
- subs_steering_val1 = 0x00;
- subs_steering_val2 = 0x00;
+ subs_state *state = machine->driver_data<subs_state>();
+ state->steering_buf1 = 0;
+ state->steering_buf2 = 0;
+ state->steering_val1 = 0x00;
+ state->steering_val2 = 0x00;
}
/***************************************************************************
@@ -42,60 +39,60 @@ Be sure to keep returning a direction until steer_reset is called.
***************************************************************************/
static int subs_steering_1(running_machine *machine)
{
- static int last_val=0;
+ subs_state *state = machine->driver_data<subs_state>();
int this_val;
int delta;
this_val=input_port_read(machine, "DIAL2");
- delta=this_val-last_val;
- last_val=this_val;
+ delta=this_val-state->last_val_1;
+ state->last_val_1=this_val;
if (delta>128) delta-=256;
else if (delta<-128) delta+=256;
/* Divide by four to make our steering less sensitive */
- subs_steering_buf1+=(delta/4);
+ state->steering_buf1+=(delta/4);
- if (subs_steering_buf1>0)
+ if (state->steering_buf1>0)
{
- subs_steering_buf1--;
- subs_steering_val1=0xC0;
+ state->steering_buf1--;
+ state->steering_val1=0xC0;
}
- else if (subs_steering_buf1<0)
+ else if (state->steering_buf1<0)
{
- subs_steering_buf1++;
- subs_steering_val1=0x80;
+ state->steering_buf1++;
+ state->steering_val1=0x80;
}
- return subs_steering_val1;
+ return state->steering_val1;
}
static int subs_steering_2(running_machine *machine)
{
- static int last_val=0;
+ subs_state *state = machine->driver_data<subs_state>();
int this_val;
int delta;
this_val=input_port_read(machine, "DIAL1");
- delta=this_val-last_val;
- last_val=this_val;
+ delta=this_val-state->last_val_2;
+ state->last_val_2=this_val;
if (delta>128) delta-=256;
else if (delta<-128) delta+=256;
/* Divide by four to make our steering less sensitive */
- subs_steering_buf2+=(delta/4);
+ state->steering_buf2+=(delta/4);
- if (subs_steering_buf2>0)
+ if (state->steering_buf2>0)
{
- subs_steering_buf2--;
- subs_steering_val2=0xC0;
+ state->steering_buf2--;
+ state->steering_val2=0xC0;
}
- else if (subs_steering_buf2<0)
+ else if (state->steering_buf2<0)
{
- subs_steering_buf2++;
- subs_steering_val2=0x80;
+ state->steering_buf2++;
+ state->steering_val2=0x80;
}
- return subs_steering_val2;
+ return state->steering_val2;
}
/***************************************************************************
@@ -103,8 +100,9 @@ subs_steer_reset
***************************************************************************/
WRITE8_HANDLER( subs_steer_reset_w )
{
- subs_steering_val1 = 0x00;
- subs_steering_val2 = 0x00;
+ subs_state *state = space->machine->driver_data<subs_state>();
+ state->steering_val1 = 0x00;
+ state->steering_val2 = 0x00;
}
/***************************************************************************
diff --git a/src/mame/video/arcadecl.c b/src/mame/video/arcadecl.c
index bfa51030d58..0feed3c2a0b 100644
--- a/src/mame/video/arcadecl.c
+++ b/src/mame/video/arcadecl.c
@@ -9,6 +9,7 @@
#include "emu.h"
+#include "includes/rampart.h"
#include "includes/arcadecl.h"
diff --git a/src/mame/video/atetris.c b/src/mame/video/atetris.c
index 285ff7d29f3..46eef9b1fe8 100644
--- a/src/mame/video/atetris.c
+++ b/src/mame/video/atetris.c
@@ -8,9 +8,6 @@
#include "includes/atetris.h"
-static tilemap_t *bg_tilemap;
-
-
/*************************************
*
* Tilemap callback
@@ -39,8 +36,9 @@ WRITE8_HANDLER( atetris_videoram_w )
{
atetris_state *state = space->machine->driver_data<atetris_state>();
UINT8 *videoram = state->videoram;
+
videoram[offset] = data;
- tilemap_mark_tile_dirty(bg_tilemap, offset / 2);
+ tilemap_mark_tile_dirty(state->bg_tilemap, offset / 2);
}
@@ -53,7 +51,9 @@ WRITE8_HANDLER( atetris_videoram_w )
VIDEO_START( atetris )
{
- bg_tilemap = tilemap_create(machine, get_tile_info, tilemap_scan_rows, 8,8, 64,32);
+ atetris_state *state = machine->driver_data<atetris_state>();
+
+ state->bg_tilemap = tilemap_create(machine, get_tile_info, tilemap_scan_rows, 8,8, 64,32);
}
@@ -66,6 +66,8 @@ VIDEO_START( atetris )
VIDEO_UPDATE( atetris )
{
- tilemap_draw(bitmap, cliprect, bg_tilemap, 0,0);
+ atetris_state *state = screen->machine->driver_data<atetris_state>();
+
+ tilemap_draw(bitmap, cliprect, state->bg_tilemap, 0,0);
return 0;
}
diff --git a/src/mame/video/centiped.c b/src/mame/video/centiped.c
index 8fdeecd2620..21339cb525a 100644
--- a/src/mame/video/centiped.c
+++ b/src/mame/video/centiped.c
@@ -8,13 +8,6 @@
#include "includes/centiped.h"
-static tilemap_t *bg_tilemap;
-UINT8 centiped_flipscreen, *bullsdrt_tiles_bankram;
-static UINT8 bullsdrt_sprites_bank;
-static UINT8 penmask[64];
-
-
-
/*************************************
*
* Tilemap callback
@@ -25,6 +18,7 @@ static TILE_GET_INFO( centiped_get_tile_info )
{
centiped_state *state = machine->driver_data<centiped_state>();
UINT8 *videoram = state->videoram;
+
int data = videoram[tile_index];
SET_TILE_INFO(0, (data & 0x3f) + 0x40, 0, TILE_FLIPYX(data >> 6));
}
@@ -35,7 +29,8 @@ static TILE_GET_INFO( warlords_get_tile_info )
centiped_state *state = machine->driver_data<centiped_state>();
UINT8 *videoram = state->videoram;
int data = videoram[tile_index];
- int color = ((tile_index & 0x10) >> 4) | ((tile_index & 0x200) >> 8) | (centiped_flipscreen >> 5);
+ int color = ((tile_index & 0x10) >> 4) | ((tile_index & 0x200) >> 8) | (state->flipscreen >> 5);
+
SET_TILE_INFO(0, data & 0x3f, color, TILE_FLIPYX(data >> 6));
}
@@ -48,7 +43,8 @@ static TILE_GET_INFO( milliped_get_tile_info )
int bank = (data >> 6) & 1;
int color = (data >> 6) & 3;
/* Flip both x and y if flipscreen is non-zero */
- int flip_tiles = (centiped_flipscreen) ? 0x03 : 0;
+ int flip_tiles = (state->flipscreen) ? 0x03 : 0;
+
SET_TILE_INFO(0, (data & 0x3f) + 0x40 + (bank * 0x80), color, TILE_FLIPYX(flip_tiles));
}
@@ -58,7 +54,8 @@ static TILE_GET_INFO( bullsdrt_get_tile_info )
centiped_state *state = machine->driver_data<centiped_state>();
UINT8 *videoram = state->videoram;
int data = videoram[tile_index];
- int bank = bullsdrt_tiles_bankram[tile_index & 0x1f] & 0x0f;
+ int bank = state->bullsdrt_tiles_bankram[tile_index & 0x1f] & 0x0f;
+
SET_TILE_INFO(0, (data & 0x3f) + 0x40 * bank, 0, TILE_FLIPYX(data >> 6));
}
@@ -70,8 +67,9 @@ static TILE_GET_INFO( bullsdrt_get_tile_info )
*
*************************************/
-static void init_penmask(void)
+static void init_penmask(running_machine *machine)
{
+ centiped_state *state = machine->driver_data<centiped_state>();
int i;
for (i = 0; i < 64; i++)
@@ -80,7 +78,7 @@ static void init_penmask(void)
if (((i >> 0) & 3) == 0) mask |= 2;
if (((i >> 2) & 3) == 0) mask |= 4;
if (((i >> 4) & 3) == 0) mask |= 8;
- penmask[i] = mask;
+ state->penmask[i] = mask;
}
}
@@ -94,44 +92,51 @@ static void init_penmask(void)
VIDEO_START( centiped )
{
- bg_tilemap = tilemap_create(machine, centiped_get_tile_info, tilemap_scan_rows, 8,8, 32,32);
+ centiped_state *state = machine->driver_data<centiped_state>();
+ state->bg_tilemap = tilemap_create(machine, centiped_get_tile_info, tilemap_scan_rows, 8,8, 32,32);
- init_penmask();
+ init_penmask(machine);
- centiped_flipscreen = 0;
+ state->flipscreen = 0;
- state_save_register_global(machine, centiped_flipscreen);
- state_save_register_global(machine, bullsdrt_sprites_bank);
+ state_save_register_global(machine, state->flipscreen);
+ state_save_register_global(machine, state->bullsdrt_sprites_bank);
}
VIDEO_START( warlords )
{
- bg_tilemap = tilemap_create(machine, warlords_get_tile_info, tilemap_scan_rows, 8,8, 32,32);
+ centiped_state *state = machine->driver_data<centiped_state>();
+
+ state->bg_tilemap = tilemap_create(machine, warlords_get_tile_info, tilemap_scan_rows, 8,8, 32,32);
- centiped_flipscreen = 0;
+ state->flipscreen = 0;
}
VIDEO_START( milliped )
{
- bg_tilemap = tilemap_create(machine, milliped_get_tile_info, tilemap_scan_rows, 8,8, 32,32);
+ centiped_state *state = machine->driver_data<centiped_state>();
+
+ state->bg_tilemap = tilemap_create(machine, milliped_get_tile_info, tilemap_scan_rows, 8,8, 32,32);
- init_penmask();
+ init_penmask(machine);
- centiped_flipscreen = 0;
+ state->flipscreen = 0;
- state_save_register_global(machine, centiped_flipscreen);
+ state_save_register_global(machine, state->flipscreen);
}
VIDEO_START( bullsdrt )
{
- bg_tilemap = tilemap_create(machine, bullsdrt_get_tile_info, tilemap_scan_rows, 8,8, 32,32);
+ centiped_state *state = machine->driver_data<centiped_state>();
- init_penmask();
+ state->bg_tilemap = tilemap_create(machine, bullsdrt_get_tile_info, tilemap_scan_rows, 8,8, 32,32);
- centiped_flipscreen = 0;
+ init_penmask(machine);
+
+ state->flipscreen = 0;
}
@@ -146,8 +151,9 @@ WRITE8_HANDLER( centiped_videoram_w )
{
centiped_state *state = space->machine->driver_data<centiped_state>();
UINT8 *videoram = state->videoram;
+
videoram[offset] = data;
- tilemap_mark_tile_dirty(bg_tilemap, offset);
+ tilemap_mark_tile_dirty(state->bg_tilemap, offset);
}
@@ -160,7 +166,9 @@ WRITE8_HANDLER( centiped_videoram_w )
WRITE8_HANDLER( centiped_flip_screen_w )
{
- centiped_flipscreen = data >> 7;
+ centiped_state *state = space->machine->driver_data<centiped_state>();
+
+ state->flipscreen = data >> 7;
}
@@ -173,8 +181,10 @@ WRITE8_HANDLER( centiped_flip_screen_w )
WRITE8_HANDLER( bullsdrt_tilesbank_w )
{
- bullsdrt_tiles_bankram[offset] = data;
- tilemap_mark_all_tiles_dirty(bg_tilemap);
+ centiped_state *state = space->machine->driver_data<centiped_state>();
+
+ state->bullsdrt_tiles_bankram[offset] = data;
+ tilemap_mark_all_tiles_dirty(state->bg_tilemap);
}
@@ -187,7 +197,9 @@ WRITE8_HANDLER( bullsdrt_tilesbank_w )
WRITE8_HANDLER( bullsdrt_sprites_bank_w )
{
- bullsdrt_sprites_bank = data;
+ centiped_state *state = space->machine->driver_data<centiped_state>();
+
+ state->bullsdrt_sprites_bank = data;
}
@@ -419,15 +431,16 @@ WRITE8_HANDLER( mazeinv_paletteram_w )
VIDEO_UPDATE( centiped )
{
+ centiped_state *state = screen->machine->driver_data<centiped_state>();
UINT8 *spriteram = screen->machine->generic.spriteram.u8;
rectangle spriteclip = *cliprect;
int offs;
/* draw the background */
- tilemap_draw(bitmap, cliprect, bg_tilemap, 0, 0);
+ tilemap_draw(bitmap, cliprect, state->bg_tilemap, 0, 0);
/* apply the sprite clip */
- if (centiped_flipscreen)
+ if (state->flipscreen)
spriteclip.min_x += 8;
else
spriteclip.max_x -= 8;
@@ -442,7 +455,7 @@ VIDEO_UPDATE( centiped )
int x = spriteram[offs + 0x20];
int y = 240 - spriteram[offs + 0x10];
- drawgfx_transmask(bitmap, &spriteclip, screen->machine->gfx[1], code, color, flipx, flipy, x, y, penmask[color & 0x3f]);
+ drawgfx_transmask(bitmap, &spriteclip, screen->machine->gfx[1], code, color, flipx, flipy, x, y, state->penmask[color & 0x3f]);
}
return 0;
}
@@ -450,20 +463,21 @@ VIDEO_UPDATE( centiped )
VIDEO_UPDATE( warlords )
{
+ centiped_state *state = screen->machine->driver_data<centiped_state>();
UINT8 *spriteram = screen->machine->generic.spriteram.u8;
int upright_mode = input_port_read(screen->machine, "IN0") & 0x80;
int offs;
/* if the cocktail/upright switch flipped, force refresh */
- if (centiped_flipscreen != upright_mode)
+ if (state->flipscreen != upright_mode)
{
- centiped_flipscreen = upright_mode;
- tilemap_set_flip(bg_tilemap, upright_mode ? TILEMAP_FLIPX : 0);
- tilemap_mark_all_tiles_dirty(bg_tilemap);
+ state->flipscreen = upright_mode;
+ tilemap_set_flip(state->bg_tilemap, upright_mode ? TILEMAP_FLIPX : 0);
+ tilemap_mark_all_tiles_dirty(state->bg_tilemap);
}
/* draw the background */
- tilemap_draw(bitmap, cliprect, bg_tilemap, 0, 0);
+ tilemap_draw(bitmap, cliprect, state->bg_tilemap, 0, 0);
/* draw the sprites */
for (offs = 0; offs < 0x10; offs++)
@@ -495,16 +509,17 @@ VIDEO_UPDATE( warlords )
VIDEO_UPDATE( bullsdrt )
{
+ centiped_state *state = screen->machine->driver_data<centiped_state>();
UINT8 *spriteram = screen->machine->generic.spriteram.u8;
rectangle spriteclip = *cliprect;
int offs;
/* draw the background */
- tilemap_draw(bitmap, cliprect, bg_tilemap, 0, 0);
+ tilemap_draw(bitmap, cliprect, state->bg_tilemap, 0, 0);
/* apply the sprite clip */
- if (centiped_flipscreen)
+ if (state->flipscreen)
spriteclip.min_x += 8;
else
spriteclip.max_x -= 8;
@@ -512,7 +527,7 @@ VIDEO_UPDATE( bullsdrt )
/* draw the sprites */
for (offs = 0; offs < 0x10; offs++)
{
- int code = ((spriteram[offs] & 0x3e) >> 1) | ((spriteram[offs] & 0x01) << 6) | (bullsdrt_sprites_bank * 0x20);
+ int code = ((spriteram[offs] & 0x3e) >> 1) | ((spriteram[offs] & 0x01) << 6) | (state->bullsdrt_sprites_bank * 0x20);
int color = spriteram[offs + 0x30];
int flipy = (spriteram[offs] >> 7) & 1;
int x = spriteram[offs + 0x20];
@@ -529,15 +544,16 @@ VIDEO_UPDATE( bullsdrt )
*/
VIDEO_UPDATE( milliped )
{
+ centiped_state *state = screen->machine->driver_data<centiped_state>();
UINT8 *spriteram = screen->machine->generic.spriteram.u8;
rectangle spriteclip = *cliprect;
int offs;
/* draw the background */
- tilemap_draw(bitmap, cliprect, bg_tilemap, 0, 0);
+ tilemap_draw(bitmap, cliprect, state->bg_tilemap, 0, 0);
/* apply the sprite clip */
- if (centiped_flipscreen)
+ if (state->flipscreen)
spriteclip.min_x += 8;
else
spriteclip.max_x -= 8;
@@ -547,7 +563,7 @@ VIDEO_UPDATE( milliped )
{
int code = ((spriteram[offs] & 0x3e) >> 1) | ((spriteram[offs] & 0x01) << 6);
int color = spriteram[offs + 0x30];
- int flipx = centiped_flipscreen;
+ int flipx = state->flipscreen;
int flipy = (spriteram[offs] & 0x80);
int x = spriteram[offs + 0x20];
int y = 240 - spriteram[offs + 0x10];
@@ -555,7 +571,7 @@ VIDEO_UPDATE( milliped )
flipy = !flipy;
}
- drawgfx_transmask(bitmap, &spriteclip, screen->machine->gfx[1], code, color, flipx, flipy, x, y, penmask[color & 0x3f]);
+ drawgfx_transmask(bitmap, &spriteclip, screen->machine->gfx[1], code, color, flipx, flipy, x, y, state->penmask[color & 0x3f]);
}
return 0;
}
diff --git a/src/mame/video/cloak.c b/src/mame/video/cloak.c
index c950043c587..a1ff73f5e2f 100644
--- a/src/mame/video/cloak.c
+++ b/src/mame/video/cloak.c
@@ -11,17 +11,6 @@
#define NUM_PENS (0x40)
-static UINT8 bitmap_videoram_selected;
-static UINT8 bitmap_videoram_address_x;
-static UINT8 bitmap_videoram_address_y;
-static UINT8 *bitmap_videoram1;
-static UINT8 *bitmap_videoram2;
-static UINT8 *current_bitmap_videoram_accessed;
-static UINT8 *current_bitmap_videoram_displayed;
-static UINT16 *palette_ram;
-
-static tilemap_t *bg_tilemap;
-
/***************************************************************************
CLOAK & DAGGER uses RAM to dynamically
@@ -51,12 +40,15 @@ static tilemap_t *bg_tilemap;
WRITE8_HANDLER( cloak_paletteram_w )
{
- palette_ram[offset & 0x3f] = ((offset & 0x40) << 2) | data;
+ cloak_state *state = space->machine->driver_data<cloak_state>();
+ state->palette_ram[offset & 0x3f] = ((offset & 0x40) << 2) | data;
}
static void set_pens(running_machine *machine)
{
+ cloak_state *state = machine->driver_data<cloak_state>();
+ UINT16 *palette_ram = state->palette_ram;
static const int resistances[3] = { 10000, 4700, 2200 };
double weights[3];
int i;
@@ -95,54 +87,59 @@ static void set_pens(running_machine *machine)
}
-static void set_current_bitmap_videoram_pointer(void)
+static void set_current_bitmap_videoram_pointer(cloak_state *state)
{
- current_bitmap_videoram_accessed = bitmap_videoram_selected ? bitmap_videoram1 : bitmap_videoram2;
- current_bitmap_videoram_displayed = bitmap_videoram_selected ? bitmap_videoram2 : bitmap_videoram1;
+ state->current_bitmap_videoram_accessed = state->bitmap_videoram_selected ? state->bitmap_videoram1 : state->bitmap_videoram2;
+ state->current_bitmap_videoram_displayed = state->bitmap_videoram_selected ? state->bitmap_videoram2 : state->bitmap_videoram1;
}
WRITE8_HANDLER( cloak_clearbmp_w )
{
+ cloak_state *state = space->machine->driver_data<cloak_state>();
+
space->machine->primary_screen->update_now();
- bitmap_videoram_selected = data & 0x01;
- set_current_bitmap_videoram_pointer();
+ state->bitmap_videoram_selected = data & 0x01;
+ set_current_bitmap_videoram_pointer(state);
if (data & 0x02) /* clear */
- memset(current_bitmap_videoram_accessed, 0, 256*256);
+ memset(state->current_bitmap_videoram_accessed, 0, 256*256);
}
-static void adjust_xy(int offset)
+static void adjust_xy(cloak_state *state, int offset)
{
switch (offset)
{
- case 0x00: bitmap_videoram_address_x--; bitmap_videoram_address_y++; break;
- case 0x01: bitmap_videoram_address_y--; break;
- case 0x02: bitmap_videoram_address_x--; break;
- case 0x04: bitmap_videoram_address_x++; bitmap_videoram_address_y++; break;
- case 0x05: bitmap_videoram_address_y++; break;
- case 0x06: bitmap_videoram_address_x++; break;
+ case 0x00: state->bitmap_videoram_address_x--; state->bitmap_videoram_address_y++; break;
+ case 0x01: state->bitmap_videoram_address_y--; break;
+ case 0x02: state->bitmap_videoram_address_x--; break;
+ case 0x04: state->bitmap_videoram_address_x++; state->bitmap_videoram_address_y++; break;
+ case 0x05: state->bitmap_videoram_address_y++; break;
+ case 0x06: state->bitmap_videoram_address_x++; break;
}
}
READ8_HANDLER( graph_processor_r )
{
- UINT8 ret = current_bitmap_videoram_displayed[(bitmap_videoram_address_y << 8) | bitmap_videoram_address_x];
+ cloak_state *state = space->machine->driver_data<cloak_state>();
+ UINT8 ret = state->current_bitmap_videoram_displayed[(state->bitmap_videoram_address_y << 8) | state->bitmap_videoram_address_x];
- adjust_xy(offset);
+ adjust_xy(state, offset);
return ret;
}
WRITE8_HANDLER( graph_processor_w )
{
+ cloak_state *state = space->machine->driver_data<cloak_state>();
+
switch (offset)
{
- case 0x03: bitmap_videoram_address_x = data; break;
- case 0x07: bitmap_videoram_address_y = data; break;
+ case 0x03: state->bitmap_videoram_address_x = data; break;
+ case 0x07: state->bitmap_videoram_address_y = data; break;
default:
- current_bitmap_videoram_accessed[(bitmap_videoram_address_y << 8) | bitmap_videoram_address_x] = data & 0x0f;
+ state->current_bitmap_videoram_accessed[(state->bitmap_videoram_address_y << 8) | state->bitmap_videoram_address_x] = data & 0x0f;
- adjust_xy(offset);
+ adjust_xy(state, offset);
break;
}
}
@@ -151,8 +148,9 @@ WRITE8_HANDLER( cloak_videoram_w )
{
cloak_state *state = space->machine->driver_data<cloak_state>();
UINT8 *videoram = state->videoram;
+
videoram[offset] = data;
- tilemap_mark_tile_dirty(bg_tilemap, offset);
+ tilemap_mark_tile_dirty(state->bg_tilemap, offset);
}
WRITE8_HANDLER( cloak_flipscreen_w )
@@ -171,36 +169,41 @@ static TILE_GET_INFO( get_bg_tile_info )
static STATE_POSTLOAD( cloak_postload )
{
- set_current_bitmap_videoram_pointer();
+ cloak_state *state = machine->driver_data<cloak_state>();
+
+ set_current_bitmap_videoram_pointer(state);
}
VIDEO_START( cloak )
{
- bg_tilemap = tilemap_create(machine, get_bg_tile_info, tilemap_scan_rows, 8, 8, 32, 32);
+ cloak_state *state = machine->driver_data<cloak_state>();
+
+ state->bg_tilemap = tilemap_create(machine, get_bg_tile_info, tilemap_scan_rows, 8, 8, 32, 32);
- bitmap_videoram1 = auto_alloc_array(machine, UINT8, 256*256);
- bitmap_videoram2 = auto_alloc_array(machine, UINT8, 256*256);
- palette_ram = auto_alloc_array(machine, UINT16, NUM_PENS);
+ state->bitmap_videoram1 = auto_alloc_array(machine, UINT8, 256*256);
+ state->bitmap_videoram2 = auto_alloc_array(machine, UINT8, 256*256);
+ state->palette_ram = auto_alloc_array(machine, UINT16, NUM_PENS);
- set_current_bitmap_videoram_pointer();
+ set_current_bitmap_videoram_pointer(state);
- state_save_register_global(machine, bitmap_videoram_address_x);
- state_save_register_global(machine, bitmap_videoram_address_y);
- state_save_register_global(machine, bitmap_videoram_selected);
- state_save_register_global_pointer(machine, bitmap_videoram1, 256*256);
- state_save_register_global_pointer(machine, bitmap_videoram2, 256*256);
- state_save_register_global_pointer(machine, palette_ram, NUM_PENS);
+ state_save_register_global(machine, state->bitmap_videoram_address_x);
+ state_save_register_global(machine, state->bitmap_videoram_address_y);
+ state_save_register_global(machine, state->bitmap_videoram_selected);
+ state_save_register_global_pointer(machine, state->bitmap_videoram1, 256*256);
+ state_save_register_global_pointer(machine, state->bitmap_videoram2, 256*256);
+ state_save_register_global_pointer(machine, state->palette_ram, NUM_PENS);
state_save_register_postload(machine, cloak_postload, NULL);
}
-static void draw_bitmap(bitmap_t *bitmap, const rectangle *cliprect)
+static void draw_bitmap(running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect)
{
+ cloak_state *state = machine->driver_data<cloak_state>();
int x, y;
for (y = cliprect->min_y; y <= cliprect->max_y; y++)
for (x = cliprect->min_x; x <= cliprect->max_x; x++)
{
- pen_t pen = current_bitmap_videoram_displayed[(y << 8) | x] & 0x07;
+ pen_t pen = state->current_bitmap_videoram_displayed[(y << 8) | x] & 0x07;
if (pen)
*BITMAP_ADDR16(bitmap, y, (x - 6) & 0xff) = 0x10 | ((x & 0x80) >> 4) | pen;
@@ -209,10 +212,11 @@ static void draw_bitmap(bitmap_t *bitmap, const rectangle *cliprect)
static void draw_sprites(running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect)
{
- UINT8 *spriteram = machine->generic.spriteram.u8;
+ cloak_state *state = machine->driver_data<cloak_state>();
+ UINT8 *spriteram = state->spriteram;
int offs;
- for (offs = (machine->generic.spriteram_size / 4) - 1; offs >= 0; offs--)
+ for (offs = (0x100 / 4) - 1; offs >= 0; offs--)
{
int code = spriteram[offs + 64] & 0x7f;
int flipx = spriteram[offs + 64] & 0x80;
@@ -234,9 +238,10 @@ static void draw_sprites(running_machine *machine, bitmap_t *bitmap, const recta
VIDEO_UPDATE( cloak )
{
+ cloak_state *state = screen->machine->driver_data<cloak_state>();
set_pens(screen->machine);
- tilemap_draw(bitmap, cliprect, bg_tilemap, 0, 0);
- draw_bitmap(bitmap, cliprect);
+ tilemap_draw(bitmap, cliprect, state->bg_tilemap, 0, 0);
+ draw_bitmap(screen->machine, bitmap, cliprect);
draw_sprites(screen->machine, bitmap, cliprect);
return 0;
}
diff --git a/src/mame/video/firetrk.c b/src/mame/video/firetrk.c
index 38b8c52fddc..d63836f5387 100644
--- a/src/mame/video/firetrk.c
+++ b/src/mame/video/firetrk.c
@@ -8,36 +8,19 @@ Atari Fire Truck + Super Bug + Monte Carlo video emulation
#include "includes/firetrk.h"
-UINT8 *firetrk_alpha_num_ram;
-UINT8 *firetrk_playfield_ram;
-UINT8 *firetrk_scroll_x;
-UINT8 *firetrk_scroll_y;
-UINT8 *firetrk_car_rot;
-UINT8 *firetrk_drone_rot;
-UINT8 *firetrk_drone_x;
-UINT8 *firetrk_drone_y;
-UINT8 *firetrk_blink;
-UINT8 firetrk_flash;
-UINT8 firetrk_skid[2];
-UINT8 firetrk_crash[2];
-static bitmap_t *helper1;
-static bitmap_t *helper2;
-static UINT32 color1_mask;
-static UINT32 color2_mask;
static const rectangle playfield_window = { 0x02a, 0x115, 0x000, 0x0ff };
-static tilemap_t *tilemap1; /* for screen display */
-static tilemap_t *tilemap2; /* for collision detection */
PALETTE_INIT( firetrk )
{
+ firetrk_state *state = machine->driver_data<firetrk_state>();
int i;
static const UINT8 colortable_source[] =
@@ -58,16 +41,16 @@ PALETTE_INIT( firetrk )
RGB_WHITE
};
- color1_mask = color2_mask = 0;
+ state->color1_mask = state->color2_mask = 0;
for (i = 0; i < ARRAY_LENGTH(colortable_source); i++)
{
UINT8 color = colortable_source[i];
if (color == 1)
- color1_mask |= 1 << i;
+ state->color1_mask |= 1 << i;
else if (color == 2)
- color2_mask |= 1 << i;
+ state->color2_mask |= 1 << i;
palette_set_color(machine, i, palette_source[color]);
}
@@ -82,6 +65,7 @@ static void prom_to_palette(running_machine *machine, int number, UINT8 val)
PALETTE_INIT( montecar )
{
+ firetrk_state *state = machine->driver_data<firetrk_state>();
int i;
static const UINT8 colortable_source[] =
@@ -117,16 +101,16 @@ PALETTE_INIT( montecar )
*
*/
- color1_mask = color2_mask = 0;
+ state->color1_mask = state->color2_mask = 0;
for (i = 0; i < ARRAY_LENGTH(colortable_source); i++)
{
UINT8 color = colortable_source[i];
if (color == 1)
- color1_mask |= 1 << i;
+ state->color1_mask |= 1 << i;
else if (color == 2)
- color2_mask |= 1 << i;
+ state->color2_mask |= 1 << i;
prom_to_palette(machine, i, color_prom[0x100 + colortable_source[i]]);
}
@@ -138,13 +122,14 @@ PALETTE_INIT( montecar )
static TILE_GET_INFO( firetrk_get_tile_info1 )
{
- int code = firetrk_playfield_ram[tile_index] & 0x3f;
- int color = (firetrk_playfield_ram[tile_index] >> 6) & 0x03;
+ firetrk_state *state = machine->driver_data<firetrk_state>();
+ int code = state->playfield_ram[tile_index] & 0x3f;
+ int color = (state->playfield_ram[tile_index] >> 6) & 0x03;
- if (*firetrk_blink && (code >= 0x04) && (code <= 0x0b))
+ if (*state->blink && (code >= 0x04) && (code <= 0x0b))
color = 0;
- if (firetrk_flash)
+ if (state->flash)
color = color | 0x04;
SET_TILE_INFO(1, code, color, 0);
@@ -153,13 +138,14 @@ static TILE_GET_INFO( firetrk_get_tile_info1 )
static TILE_GET_INFO( superbug_get_tile_info1 )
{
- int code = firetrk_playfield_ram[tile_index] & 0x3f;
- int color = (firetrk_playfield_ram[tile_index] >> 6) & 0x03;
+ firetrk_state *state = machine->driver_data<firetrk_state>();
+ int code = state->playfield_ram[tile_index] & 0x3f;
+ int color = (state->playfield_ram[tile_index] >> 6) & 0x03;
- if (*firetrk_blink && (code >= 0x08) && (code <= 0x0f))
+ if (*state->blink && (code >= 0x08) && (code <= 0x0f))
color = 0;
- if (firetrk_flash)
+ if (state->flash)
color = color | 0x04;
SET_TILE_INFO(1, code, color, 0);
@@ -168,10 +154,11 @@ static TILE_GET_INFO( superbug_get_tile_info1 )
static TILE_GET_INFO( montecar_get_tile_info1 )
{
- int code = firetrk_playfield_ram[tile_index] & 0x3f;
- int color = (firetrk_playfield_ram[tile_index] >> 6) & 0x03;
+ firetrk_state *state = machine->driver_data<firetrk_state>();
+ int code = state->playfield_ram[tile_index] & 0x3f;
+ int color = (state->playfield_ram[tile_index] >> 6) & 0x03;
- if (firetrk_flash)
+ if (state->flash)
color = color | 0x04;
SET_TILE_INFO(1, code, color, 0);
@@ -180,7 +167,8 @@ static TILE_GET_INFO( montecar_get_tile_info1 )
static TILE_GET_INFO( firetrk_get_tile_info2 )
{
- UINT8 code = firetrk_playfield_ram[tile_index] & 0x3f;
+ firetrk_state *state = machine->driver_data<firetrk_state>();
+ UINT8 code = state->playfield_ram[tile_index] & 0x3f;
int color = 0;
/* palette 1 for crash and palette 2 for skid */
@@ -196,7 +184,8 @@ static TILE_GET_INFO( firetrk_get_tile_info2 )
static TILE_GET_INFO( superbug_get_tile_info2 )
{
- UINT8 code = firetrk_playfield_ram[tile_index] & 0x3f;
+ firetrk_state *state = machine->driver_data<firetrk_state>();
+ UINT8 code = state->playfield_ram[tile_index] & 0x3f;
int color = 0;
/* palette 1 for crash and palette 2 for skid */
@@ -212,7 +201,8 @@ static TILE_GET_INFO( superbug_get_tile_info2 )
static TILE_GET_INFO( montecar_get_tile_info2 )
{
- UINT8 code = firetrk_playfield_ram[tile_index];
+ firetrk_state *state = machine->driver_data<firetrk_state>();
+ UINT8 code = state->playfield_ram[tile_index];
int color = 0;
/* palette 1 for crash and palette 2 for skid */
@@ -234,55 +224,59 @@ static TILE_GET_INFO( montecar_get_tile_info2 )
VIDEO_START( firetrk )
{
- helper1 = machine->primary_screen->alloc_compatible_bitmap();
- helper2 = machine->primary_screen->alloc_compatible_bitmap();
+ firetrk_state *state = machine->driver_data<firetrk_state>();
+ state->helper1 = machine->primary_screen->alloc_compatible_bitmap();
+ state->helper2 = machine->primary_screen->alloc_compatible_bitmap();
- tilemap1 = tilemap_create(machine, firetrk_get_tile_info1, tilemap_scan_rows, 16, 16, 16, 16);
- tilemap2 = tilemap_create(machine, firetrk_get_tile_info2, tilemap_scan_rows, 16, 16, 16, 16);
+ state->tilemap1 = tilemap_create(machine, firetrk_get_tile_info1, tilemap_scan_rows, 16, 16, 16, 16);
+ state->tilemap2 = tilemap_create(machine, firetrk_get_tile_info2, tilemap_scan_rows, 16, 16, 16, 16);
}
VIDEO_START( superbug )
{
- helper1 = machine->primary_screen->alloc_compatible_bitmap();
- helper2 = machine->primary_screen->alloc_compatible_bitmap();
+ firetrk_state *state = machine->driver_data<firetrk_state>();
+ state->helper1 = machine->primary_screen->alloc_compatible_bitmap();
+ state->helper2 = machine->primary_screen->alloc_compatible_bitmap();
- tilemap1 = tilemap_create(machine, superbug_get_tile_info1, tilemap_scan_rows, 16, 16, 16, 16);
- tilemap2 = tilemap_create(machine, superbug_get_tile_info2, tilemap_scan_rows, 16, 16, 16, 16);
+ state->tilemap1 = tilemap_create(machine, superbug_get_tile_info1, tilemap_scan_rows, 16, 16, 16, 16);
+ state->tilemap2 = tilemap_create(machine, superbug_get_tile_info2, tilemap_scan_rows, 16, 16, 16, 16);
}
VIDEO_START( montecar )
{
- helper1 = machine->primary_screen->alloc_compatible_bitmap();
- helper2 = machine->primary_screen->alloc_compatible_bitmap();
+ firetrk_state *state = machine->driver_data<firetrk_state>();
+ state->helper1 = machine->primary_screen->alloc_compatible_bitmap();
+ state->helper2 = machine->primary_screen->alloc_compatible_bitmap();
- tilemap1 = tilemap_create(machine, montecar_get_tile_info1, tilemap_scan_rows, 16, 16, 16, 16);
- tilemap2 = tilemap_create(machine, montecar_get_tile_info2, tilemap_scan_rows, 16, 16, 16, 16);
+ state->tilemap1 = tilemap_create(machine, montecar_get_tile_info1, tilemap_scan_rows, 16, 16, 16, 16);
+ state->tilemap2 = tilemap_create(machine, montecar_get_tile_info2, tilemap_scan_rows, 16, 16, 16, 16);
}
-static void firetrk_draw_car(bitmap_t *bitmap, const rectangle *cliprect, gfx_element **gfx, int which, int flash)
+static void firetrk_draw_car(running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect, gfx_element **gfx, int which, int flash)
{
+ firetrk_state *state = machine->driver_data<firetrk_state>();
int gfx_bank, code, color, flip_x, flip_y, x, y;
if (which)
{
gfx_bank = 5;
- code = *firetrk_drone_rot & 0x07;
+ code = *state->drone_rot & 0x07;
color = flash ? 1 : 0;
- flip_x = *firetrk_drone_rot & 0x08;
- flip_y = *firetrk_drone_rot & 0x10;
- x = (flip_x ? *firetrk_drone_x - 63 : 192 - *firetrk_drone_x) + 36;
- y = flip_y ? *firetrk_drone_y - 63 : 192 - *firetrk_drone_y;
+ flip_x = *state->drone_rot & 0x08;
+ flip_y = *state->drone_rot & 0x10;
+ x = (flip_x ? *state->drone_x - 63 : 192 - *state->drone_x) + 36;
+ y = flip_y ? *state->drone_y - 63 : 192 - *state->drone_y;
}
else
{
- gfx_bank = (*firetrk_car_rot & 0x10) ? 4 : 3;
- code = *firetrk_car_rot & 0x03;
+ gfx_bank = (*state->car_rot & 0x10) ? 4 : 3;
+ code = *state->car_rot & 0x03;
color = flash ? 1 : 0;
- flip_x = *firetrk_car_rot & 0x04;
- flip_y = *firetrk_car_rot & 0x08;
+ flip_x = *state->car_rot & 0x04;
+ flip_y = *state->car_rot & 0x08;
x = 144;
y = 104;
}
@@ -291,39 +285,41 @@ static void firetrk_draw_car(bitmap_t *bitmap, const rectangle *cliprect, gfx_el
}
-static void superbug_draw_car(bitmap_t *bitmap, const rectangle *cliprect, gfx_element **gfx, int flash)
+static void superbug_draw_car(running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect, gfx_element **gfx, int flash)
{
- int gfx_bank = (*firetrk_car_rot & 0x10) ? 4 : 3;
- int code = ~*firetrk_car_rot & 0x03;
+ firetrk_state *state = machine->driver_data<firetrk_state>();
+ int gfx_bank = (*state->car_rot & 0x10) ? 4 : 3;
+ int code = ~*state->car_rot & 0x03;
int color = flash ? 1 : 0;
- int flip_x = *firetrk_car_rot & 0x04;
- int flip_y = *firetrk_car_rot & 0x08;
+ int flip_x = *state->car_rot & 0x04;
+ int flip_y = *state->car_rot & 0x08;
drawgfx_transpen(bitmap, cliprect, gfx[gfx_bank], code, color, flip_x, flip_y, 144, 104, 0);
}
-static void montecar_draw_car(bitmap_t *bitmap, const rectangle *cliprect, gfx_element **gfx, int which, int is_collision_detection)
+static void montecar_draw_car(running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect, gfx_element **gfx, int which, int is_collision_detection)
{
+ firetrk_state *state = machine->driver_data<firetrk_state>();
int gfx_bank, code, color, flip_x, flip_y, x, y;
if (which)
{
gfx_bank = 4;
- code = *firetrk_drone_rot & 0x07;
- color = is_collision_detection ? 0 : (((*firetrk_car_rot & 0x80) >> 6) | ((*firetrk_drone_rot & 0x80) >> 7));
- flip_x = *firetrk_drone_rot & 0x10;
- flip_y = *firetrk_drone_rot & 0x08;
- x = (flip_x ? *firetrk_drone_x - 31 : 224 - *firetrk_drone_x) + 34;
- y = flip_y ? *firetrk_drone_y - 31 : 224 - *firetrk_drone_y;
+ code = *state->drone_rot & 0x07;
+ color = is_collision_detection ? 0 : (((*state->car_rot & 0x80) >> 6) | ((*state->drone_rot & 0x80) >> 7));
+ flip_x = *state->drone_rot & 0x10;
+ flip_y = *state->drone_rot & 0x08;
+ x = (flip_x ? *state->drone_x - 31 : 224 - *state->drone_x) + 34;
+ y = flip_y ? *state->drone_y - 31 : 224 - *state->drone_y;
}
else
{
gfx_bank = 3;
- code = *firetrk_car_rot & 0x07;
+ code = *state->car_rot & 0x07;
color = 0;
- flip_x = *firetrk_car_rot & 0x10;
- flip_y = *firetrk_car_rot & 0x08;
+ flip_x = *state->car_rot & 0x10;
+ flip_y = *state->car_rot & 0x08;
x = 144;
y = 104;
}
@@ -342,53 +338,54 @@ static void draw_text(bitmap_t *bitmap, const rectangle *cliprect, gfx_element *
}
-static void check_collision(int which)
+static void check_collision(firetrk_state *state, int which)
{
int y, x;
for (y = playfield_window.min_y; y <= playfield_window.max_y; y++)
for (x = playfield_window.min_x; x <= playfield_window.max_x; x++)
{
- pen_t a = *BITMAP_ADDR16(helper1, y, x);
- pen_t b = *BITMAP_ADDR16(helper2, y, x);
+ pen_t a = *BITMAP_ADDR16(state->helper1, y, x);
+ pen_t b = *BITMAP_ADDR16(state->helper2, y, x);
- if (b != 0xff && (color1_mask >> a) & 1)
- firetrk_crash[which] = 1;
+ if (b != 0xff && (state->color1_mask >> a) & 1)
+ state->crash[which] = 1;
- if (b != 0xff && (color2_mask >> a) & 1)
- firetrk_skid[which] = 1;
+ if (b != 0xff && (state->color2_mask >> a) & 1)
+ state->skid[which] = 1;
}
}
VIDEO_UPDATE( firetrk )
{
+ firetrk_state *state = screen->machine->driver_data<firetrk_state>();
tilemap_mark_all_tiles_dirty_all(screen->machine);
- tilemap_set_scrollx(tilemap1, 0, *firetrk_scroll_x - 37);
- tilemap_set_scrollx(tilemap2, 0, *firetrk_scroll_x - 37);
- tilemap_set_scrolly(tilemap1, 0, *firetrk_scroll_y);
- tilemap_set_scrolly(tilemap2, 0, *firetrk_scroll_y);
+ tilemap_set_scrollx(state->tilemap1, 0, *state->scroll_x - 37);
+ tilemap_set_scrollx(state->tilemap2, 0, *state->scroll_x - 37);
+ tilemap_set_scrolly(state->tilemap1, 0, *state->scroll_y);
+ tilemap_set_scrolly(state->tilemap2, 0, *state->scroll_y);
bitmap_fill(bitmap, cliprect, 0);
- tilemap_draw(bitmap, &playfield_window, tilemap1, 0, 0);
- firetrk_draw_car(bitmap, &playfield_window, screen->machine->gfx, 0, firetrk_flash);
- firetrk_draw_car(bitmap, &playfield_window, screen->machine->gfx, 1, firetrk_flash);
- draw_text(bitmap, cliprect, screen->machine->gfx, firetrk_alpha_num_ram + 0x00, 296, 0x10, 0x10);
- draw_text(bitmap, cliprect, screen->machine->gfx, firetrk_alpha_num_ram + 0x10, 8, 0x10, 0x10);
+ tilemap_draw(bitmap, &playfield_window, state->tilemap1, 0, 0);
+ firetrk_draw_car(screen->machine, bitmap, &playfield_window, screen->machine->gfx, 0, state->flash);
+ firetrk_draw_car(screen->machine, bitmap, &playfield_window, screen->machine->gfx, 1, state->flash);
+ draw_text(bitmap, cliprect, screen->machine->gfx, state->alpha_num_ram + 0x00, 296, 0x10, 0x10);
+ draw_text(bitmap, cliprect, screen->machine->gfx, state->alpha_num_ram + 0x10, 8, 0x10, 0x10);
if (cliprect->max_y == screen->visible_area().max_y)
{
- tilemap_draw(helper1, &playfield_window, tilemap2, 0, 0);
+ tilemap_draw(state->helper1, &playfield_window, state->tilemap2, 0, 0);
- bitmap_fill(helper2, &playfield_window, 0xff);
- firetrk_draw_car(helper2, &playfield_window, screen->machine->gfx, 0, FALSE);
- check_collision(0);
+ bitmap_fill(state->helper2, &playfield_window, 0xff);
+ firetrk_draw_car(screen->machine, state->helper2, &playfield_window, screen->machine->gfx, 0, FALSE);
+ check_collision(state, 0);
- bitmap_fill(helper2, &playfield_window, 0xff);
- firetrk_draw_car(helper2, &playfield_window, screen->machine->gfx, 1, FALSE);
- check_collision(1);
+ bitmap_fill(state->helper2, &playfield_window, 0xff);
+ firetrk_draw_car(screen->machine, state->helper2, &playfield_window, screen->machine->gfx, 1, FALSE);
+ check_collision(state, 1);
- *firetrk_blink = FALSE;
+ *state->blink = FALSE;
}
return 0;
@@ -397,27 +394,28 @@ VIDEO_UPDATE( firetrk )
VIDEO_UPDATE( superbug )
{
+ firetrk_state *state = screen->machine->driver_data<firetrk_state>();
tilemap_mark_all_tiles_dirty_all(screen->machine);
- tilemap_set_scrollx(tilemap1, 0, *firetrk_scroll_x - 37);
- tilemap_set_scrollx(tilemap2, 0, *firetrk_scroll_x - 37);
- tilemap_set_scrolly(tilemap1, 0, *firetrk_scroll_y);
- tilemap_set_scrolly(tilemap2, 0, *firetrk_scroll_y);
+ tilemap_set_scrollx(state->tilemap1, 0, *state->scroll_x - 37);
+ tilemap_set_scrollx(state->tilemap2, 0, *state->scroll_x - 37);
+ tilemap_set_scrolly(state->tilemap1, 0, *state->scroll_y);
+ tilemap_set_scrolly(state->tilemap2, 0, *state->scroll_y);
bitmap_fill(bitmap, cliprect, 0);
- tilemap_draw(bitmap, &playfield_window, tilemap1, 0, 0);
- superbug_draw_car(bitmap, &playfield_window, screen->machine->gfx, firetrk_flash);
- draw_text(bitmap, cliprect, screen->machine->gfx, firetrk_alpha_num_ram + 0x00, 296, 0x10, 0x10);
- draw_text(bitmap, cliprect, screen->machine->gfx, firetrk_alpha_num_ram + 0x10, 8, 0x10, 0x10);
+ tilemap_draw(bitmap, &playfield_window, state->tilemap1, 0, 0);
+ superbug_draw_car(screen->machine, bitmap, &playfield_window, screen->machine->gfx, state->flash);
+ draw_text(bitmap, cliprect, screen->machine->gfx, state->alpha_num_ram + 0x00, 296, 0x10, 0x10);
+ draw_text(bitmap, cliprect, screen->machine->gfx, state->alpha_num_ram + 0x10, 8, 0x10, 0x10);
if (cliprect->max_y == screen->visible_area().max_y)
{
- tilemap_draw(helper1, &playfield_window, tilemap2, 0, 0);
+ tilemap_draw(state->helper1, &playfield_window, state->tilemap2, 0, 0);
- bitmap_fill(helper2, &playfield_window, 0xff);
- superbug_draw_car(helper2, &playfield_window, screen->machine->gfx, FALSE);
- check_collision(0);
+ bitmap_fill(state->helper2, &playfield_window, 0xff);
+ superbug_draw_car(screen->machine, state->helper2, &playfield_window, screen->machine->gfx, FALSE);
+ check_collision(state, 0);
- *firetrk_blink = FALSE;
+ *state->blink = FALSE;
}
return 0;
@@ -426,30 +424,31 @@ VIDEO_UPDATE( superbug )
VIDEO_UPDATE( montecar )
{
+ firetrk_state *state = screen->machine->driver_data<firetrk_state>();
tilemap_mark_all_tiles_dirty_all(screen->machine);
- tilemap_set_scrollx(tilemap1, 0, *firetrk_scroll_x - 37);
- tilemap_set_scrollx(tilemap2, 0, *firetrk_scroll_x - 37);
- tilemap_set_scrolly(tilemap1, 0, *firetrk_scroll_y);
- tilemap_set_scrolly(tilemap2, 0, *firetrk_scroll_y);
+ tilemap_set_scrollx(state->tilemap1, 0, *state->scroll_x - 37);
+ tilemap_set_scrollx(state->tilemap2, 0, *state->scroll_x - 37);
+ tilemap_set_scrolly(state->tilemap1, 0, *state->scroll_y);
+ tilemap_set_scrolly(state->tilemap2, 0, *state->scroll_y);
bitmap_fill(bitmap, cliprect, 0x2c);
- tilemap_draw(bitmap, &playfield_window, tilemap1, 0, 0);
- montecar_draw_car(bitmap, &playfield_window, screen->machine->gfx, 0, FALSE);
- montecar_draw_car(bitmap, &playfield_window, screen->machine->gfx, 1, FALSE);
- draw_text(bitmap, cliprect, screen->machine->gfx, firetrk_alpha_num_ram + 0x00, 24, 0x20, 0x08);
- draw_text(bitmap, cliprect, screen->machine->gfx, firetrk_alpha_num_ram + 0x20, 16, 0x20, 0x08);
+ tilemap_draw(bitmap, &playfield_window, state->tilemap1, 0, 0);
+ montecar_draw_car(screen->machine, bitmap, &playfield_window, screen->machine->gfx, 0, FALSE);
+ montecar_draw_car(screen->machine, bitmap, &playfield_window, screen->machine->gfx, 1, FALSE);
+ draw_text(bitmap, cliprect, screen->machine->gfx, state->alpha_num_ram + 0x00, 24, 0x20, 0x08);
+ draw_text(bitmap, cliprect, screen->machine->gfx, state->alpha_num_ram + 0x20, 16, 0x20, 0x08);
if (cliprect->max_y == screen->visible_area().max_y)
{
- tilemap_draw(helper1, &playfield_window, tilemap2, 0, 0);
+ tilemap_draw(state->helper1, &playfield_window, state->tilemap2, 0, 0);
- bitmap_fill(helper2, &playfield_window, 0xff);
- montecar_draw_car(helper2, &playfield_window, screen->machine->gfx, 0, TRUE);
- check_collision(0);
+ bitmap_fill(state->helper2, &playfield_window, 0xff);
+ montecar_draw_car(screen->machine, state->helper2, &playfield_window, screen->machine->gfx, 0, TRUE);
+ check_collision(state, 0);
- bitmap_fill(helper2, &playfield_window, 0xff);
- montecar_draw_car(helper2, &playfield_window, screen->machine->gfx, 1, TRUE);
- check_collision(1);
+ bitmap_fill(state->helper2, &playfield_window, 0xff);
+ montecar_draw_car(screen->machine, state->helper2, &playfield_window, screen->machine->gfx, 1, TRUE);
+ check_collision(state, 1);
}
return 0;
diff --git a/src/mame/video/irobot.c b/src/mame/video/irobot.c
index a7f7bb413fe..5b6ba9447ed 100644
--- a/src/mame/video/irobot.c
+++ b/src/mame/video/irobot.c
@@ -8,10 +8,6 @@
#include "includes/irobot.h"
#define BITMAP_WIDTH 256
-static UINT8 *polybitmap1,*polybitmap2;
-
-static int ir_xmin, ir_ymin, ir_xmax, ir_ymax; /* clipping area */
-
/***************************************************************************
@@ -63,19 +59,19 @@ PALETTE_INIT( irobot )
WRITE8_HANDLER( irobot_paletteram_w )
{
- int r,g,b;
+ int r,g,b;
int bits,intensity;
- UINT32 color;
-
- color = ((data << 1) | (offset & 0x01)) ^ 0x1ff;
- intensity = color & 0x07;
- bits = (color >> 3) & 0x03;
- b = 12 * bits * intensity;
- bits = (color >> 5) & 0x03;
- g = 12 * bits * intensity;
- bits = (color >> 7) & 0x03;
- r = 12 * bits * intensity;
- palette_set_color(space->machine,(offset >> 1) & 0x3F,MAKE_RGB(r,g,b));
+ UINT32 color;
+
+ color = ((data << 1) | (offset & 0x01)) ^ 0x1ff;
+ intensity = color & 0x07;
+ bits = (color >> 3) & 0x03;
+ b = 12 * bits * intensity;
+ bits = (color >> 5) & 0x03;
+ g = 12 * bits * intensity;
+ bits = (color >> 7) & 0x03;
+ r = 12 * bits * intensity;
+ palette_set_color(space->machine,(offset >> 1) & 0x3F,MAKE_RGB(r,g,b));
}
@@ -86,7 +82,8 @@ static void _irobot_poly_clear(running_machine *machine, UINT8 *bitmap_base)
void irobot_poly_clear(running_machine *machine)
{
- UINT8 *bitmap_base = irobot_bufsel ? polybitmap2 : polybitmap1;
+ irobot_state *state = machine->driver_data<irobot_state>();
+ UINT8 *bitmap_base = state->bufsel ? state->polybitmap2 : state->polybitmap1;
_irobot_poly_clear(machine, bitmap_base);
}
@@ -98,19 +95,20 @@ void irobot_poly_clear(running_machine *machine)
***************************************************************************/
VIDEO_START( irobot )
{
+ irobot_state *state = machine->driver_data<irobot_state>();
/* Setup 2 bitmaps for the polygon generator */
int height = machine->primary_screen->height();
- polybitmap1 = auto_alloc_array(machine, UINT8, BITMAP_WIDTH * height);
- polybitmap2 = auto_alloc_array(machine, UINT8, BITMAP_WIDTH * height);
+ state->polybitmap1 = auto_alloc_array(machine, UINT8, BITMAP_WIDTH * height);
+ state->polybitmap2 = auto_alloc_array(machine, UINT8, BITMAP_WIDTH * height);
/* clear the bitmaps so we start with valid palette look-up values for drawing */
- _irobot_poly_clear(machine, polybitmap1);
- _irobot_poly_clear(machine, polybitmap2);
+ _irobot_poly_clear(machine, state->polybitmap1);
+ _irobot_poly_clear(machine, state->polybitmap2);
/* Set clipping */
- ir_xmin = ir_ymin = 0;
- ir_xmax = machine->primary_screen->width();
- ir_ymax = machine->primary_screen->height();
+ state->ir_xmin = state->ir_ymin = 0;
+ state->ir_xmax = machine->primary_screen->width();
+ state->ir_ymax = machine->primary_screen->height();
}
@@ -164,8 +162,9 @@ VIDEO_START( irobot )
modified from a routine written by Andrew Caldwell
*/
-static void draw_line (UINT8 *polybitmap, int x1, int y1, int x2, int y2, int col)
+static void draw_line(running_machine *machine, UINT8 *polybitmap, int x1, int y1, int x2, int y2, int col)
{
+ irobot_state *state = machine->driver_data<irobot_state>();
int dx,dy,sx,sy,cx,cy;
dx = abs(x1-x2);
@@ -179,7 +178,7 @@ static void draw_line (UINT8 *polybitmap, int x1, int y1, int x2, int y2, int co
{
for (;;)
{
- if (x1 >= ir_xmin && x1 < ir_xmax && y1 >= ir_ymin && y1 < ir_ymax)
+ if (x1 >= state->ir_xmin && x1 < state->ir_xmax && y1 >= state->ir_ymin && y1 < state->ir_ymax)
draw_pixel (x1, y1, col);
if (x1 == x2) break;
x1 += sx;
@@ -195,7 +194,7 @@ static void draw_line (UINT8 *polybitmap, int x1, int y1, int x2, int y2, int co
{
for (;;)
{
- if (x1 >= ir_xmin && x1 < ir_xmax && y1 >= ir_ymin && y1 < ir_ymax)
+ if (x1 >= state->ir_xmin && x1 < state->ir_xmax && y1 >= state->ir_ymin && y1 < state->ir_ymax)
draw_pixel (x1, y1, col);
if (y1 == y2) break;
y1 += sy;
@@ -212,10 +211,11 @@ static void draw_line (UINT8 *polybitmap, int x1, int y1, int x2, int y2, int co
#define ROUND_TO_PIXEL(x) ((x >> 7) - 128)
-void irobot_run_video(void)
+void irobot_run_video(running_machine *machine)
{
+ irobot_state *state = machine->driver_data<irobot_state>();
UINT8 *polybitmap;
- UINT16 *combase16 = (UINT16 *)irobot_combase;
+ UINT16 *combase16 = (UINT16 *)state->combase;
int sx,sy,ex,ey,sx2,ey2;
int color;
UINT32 d1;
@@ -223,12 +223,12 @@ void irobot_run_video(void)
int shp;
INT32 word1,word2;
- logerror("Starting Polygon Generator, Clear=%d\n",irobot_vg_clear);
+ logerror("Starting Polygon Generator, Clear=%d\n",state->vg_clear);
- if (irobot_bufsel)
- polybitmap = polybitmap2;
+ if (state->bufsel)
+ polybitmap = state->polybitmap2;
else
- polybitmap = polybitmap1;
+ polybitmap = state->polybitmap1;
lpnt=0;
while (lpnt < 0x7ff)
@@ -249,7 +249,7 @@ void irobot_run_video(void)
color = sy & 0x3f;
sx = ROUND_TO_PIXEL(sx);
sy = ROUND_TO_PIXEL(sy);
- if (sx >= ir_xmin && sx < ir_xmax && sy >= ir_ymin && sy < ir_ymax)
+ if (sx >= state->ir_xmin && sx < state->ir_xmax && sy >= state->ir_ymin && sy < state->ir_ymax)
draw_pixel(sx,sy,color);
spnt+=2;
}//while object
@@ -269,7 +269,7 @@ void irobot_run_video(void)
sx = combase16[spnt+3];
word1 = (INT16)combase16[spnt+2];
ex = sx + word1 * (ey - sy + 1);
- draw_line(polybitmap, ROUND_TO_PIXEL(sx),sy,ROUND_TO_PIXEL(ex),ey,color);
+ draw_line(machine, polybitmap, ROUND_TO_PIXEL(sx),sy,ROUND_TO_PIXEL(ex),ey,color);
spnt+=4;
}//while object
}//if line
@@ -303,15 +303,15 @@ void irobot_run_video(void)
while(1)
{
- if (sy >= ir_ymin && sy < ir_ymax)
+ if (sy >= state->ir_ymin && sy < state->ir_ymax)
{
int x1 = ROUND_TO_PIXEL(sx);
int x2 = ROUND_TO_PIXEL(sx2);
int temp;
if (x1 > x2) temp = x1, x1 = x2, x2 = temp;
- if (x1 < ir_xmin) x1 = ir_xmin;
- if (x2 >= ir_xmax) x2 = ir_xmax - 1;
+ if (x1 < state->ir_xmin) x1 = state->ir_xmin;
+ if (x2 >= state->ir_xmax) x2 = state->ir_xmax - 1;
if (x1 < x2)
fill_hline(x1 + 1, x2, sy, color);
}
@@ -350,7 +350,7 @@ VIDEO_UPDATE( irobot )
{
irobot_state *state = screen->machine->driver_data<irobot_state>();
UINT8 *videoram = state->videoram;
- UINT8 *bitmap_base = irobot_bufsel ? polybitmap1 : polybitmap2;
+ UINT8 *bitmap_base = state->bufsel ? state->polybitmap1 : state->polybitmap2;
int x, y, offs;
/* copy the polygon bitmap */
@@ -362,12 +362,13 @@ VIDEO_UPDATE( irobot )
for (x = 0; x < 32; x++, offs++)
{
int code = videoram[offs] & 0x3f;
- int color = ((videoram[offs] & 0xc0) >> 6) | (irobot_alphamap >> 3);
+ int color = ((videoram[offs] & 0xc0) >> 6) | (state->alphamap >> 3);
drawgfx_transpen(bitmap,cliprect,screen->machine->gfx[0],
code, color,
0,0,
8*x,8*y,0);
}
+
return 0;
}
diff --git a/src/mame/video/poolshrk.c b/src/mame/video/poolshrk.c
index 2d738a66b5b..fe8043b2225 100644
--- a/src/mame/video/poolshrk.c
+++ b/src/mame/video/poolshrk.c
@@ -7,33 +7,32 @@ Atari Poolshark video emulation
#include "emu.h"
#include "includes/poolshrk.h"
-UINT8* poolshrk_playfield_ram;
-UINT8* poolshrk_hpos_ram;
-UINT8* poolshrk_vpos_ram;
-static tilemap_t* bg_tilemap;
static TILE_GET_INFO( get_tile_info )
{
- SET_TILE_INFO(1, poolshrk_playfield_ram[tile_index] & 0x3f, 0, 0);
+ poolshrk_state *state = machine->driver_data<poolshrk_state>();
+ SET_TILE_INFO(1, state->playfield_ram[tile_index] & 0x3f, 0, 0);
}
VIDEO_START( poolshrk )
{
- bg_tilemap = tilemap_create(machine, get_tile_info, tilemap_scan_rows,
+ poolshrk_state *state = machine->driver_data<poolshrk_state>();
+ state->bg_tilemap = tilemap_create(machine, get_tile_info, tilemap_scan_rows,
8, 8, 32, 32);
- tilemap_set_transparent_pen(bg_tilemap, 0);
+ tilemap_set_transparent_pen(state->bg_tilemap, 0);
}
VIDEO_UPDATE( poolshrk )
{
+ poolshrk_state *state = screen->machine->driver_data<poolshrk_state>();
int i;
- tilemap_mark_all_tiles_dirty(bg_tilemap);
+ tilemap_mark_all_tiles_dirty(state->bg_tilemap);
bitmap_fill(bitmap, cliprect, 0);
@@ -41,8 +40,8 @@ VIDEO_UPDATE( poolshrk )
for (i = 0; i < 16; i++)
{
- int hpos = poolshrk_hpos_ram[i];
- int vpos = poolshrk_vpos_ram[i];
+ int hpos = state->hpos_ram[i];
+ int vpos = state->vpos_ram[i];
drawgfx_transpen(bitmap, cliprect, screen->machine->gfx[0], i, (i == 0) ? 0 : 1, 0, 0,
248 - hpos, vpos - 15, 0);
@@ -50,6 +49,6 @@ VIDEO_UPDATE( poolshrk )
/* draw playfield */
- tilemap_draw(bitmap, cliprect, bg_tilemap, 0, 0);
+ tilemap_draw(bitmap, cliprect, state->bg_tilemap, 0, 0);
return 0;
}
diff --git a/src/mame/video/runaway.c b/src/mame/video/runaway.c
index 6adb654cfb5..e2c69ebc13d 100644
--- a/src/mame/video/runaway.c
+++ b/src/mame/video/runaway.c
@@ -8,15 +8,6 @@
#include "includes/runaway.h"
-static tilemap_t *bg_tilemap;
-
-UINT8* runaway_video_ram;
-UINT8* runaway_sprite_ram;
-
-static int tile_bank = 0;
-
-
-
WRITE8_HANDLER( runaway_paletteram_w )
{
int R =
@@ -41,34 +32,38 @@ WRITE8_HANDLER( runaway_paletteram_w )
WRITE8_HANDLER( runaway_video_ram_w )
{
- runaway_video_ram[offset] = data;
- tilemap_mark_tile_dirty(bg_tilemap, offset);
+ runaway_state *state = space->machine->driver_data<runaway_state>();
+ state->video_ram[offset] = data;
+ tilemap_mark_tile_dirty(state->bg_tilemap, offset);
}
WRITE8_HANDLER( runaway_tile_bank_w )
{
- if ((data & 1) != tile_bank)
+ runaway_state *state = space->machine->driver_data<runaway_state>();
+ if ((data & 1) != state->tile_bank)
{
- tilemap_mark_all_tiles_dirty(bg_tilemap);
+ tilemap_mark_all_tiles_dirty(state->bg_tilemap);
}
- tile_bank = data & 1;
+ state->tile_bank = data & 1;
}
static TILE_GET_INFO( runaway_get_tile_info )
{
- UINT8 code = runaway_video_ram[tile_index];
+ runaway_state *state = machine->driver_data<runaway_state>();
+ UINT8 code = state->video_ram[tile_index];
- SET_TILE_INFO(0, ((code & 0x3f) << 1) | ((code & 0x40) >> 6) | (tile_bank << 7), 0, (code & 0x80) ? TILE_FLIPY : 0);
+ SET_TILE_INFO(0, ((code & 0x3f) << 1) | ((code & 0x40) >> 6) | (state->tile_bank << 7), 0, (code & 0x80) ? TILE_FLIPY : 0);
}
static TILE_GET_INFO( qwak_get_tile_info )
{
- UINT8 code = runaway_video_ram[tile_index];
+ runaway_state *state = machine->driver_data<runaway_state>();
+ UINT8 code = state->video_ram[tile_index];
SET_TILE_INFO(0, ((code & 0x7f) << 1) | ((code & 0x80) >> 7), 0, 0);
}
@@ -77,38 +72,41 @@ static TILE_GET_INFO( qwak_get_tile_info )
VIDEO_START( runaway )
{
- bg_tilemap = tilemap_create(machine, runaway_get_tile_info, tilemap_scan_rows, 8, 8, 32, 30);
+ runaway_state *state = machine->driver_data<runaway_state>();
+ state->bg_tilemap = tilemap_create(machine, runaway_get_tile_info, tilemap_scan_rows, 8, 8, 32, 30);
- state_save_register_global(machine, tile_bank);
+ state_save_register_global(machine, state->tile_bank);
}
VIDEO_START( qwak )
{
- bg_tilemap = tilemap_create(machine, qwak_get_tile_info, tilemap_scan_rows, 8, 8, 32, 30);
+ runaway_state *state = machine->driver_data<runaway_state>();
+ state->bg_tilemap = tilemap_create(machine, qwak_get_tile_info, tilemap_scan_rows, 8, 8, 32, 30);
- state_save_register_global(machine, tile_bank);
+ state_save_register_global(machine, state->tile_bank);
}
VIDEO_UPDATE( runaway )
{
+ runaway_state *state = screen->machine->driver_data<runaway_state>();
int i;
- tilemap_draw(bitmap, cliprect, bg_tilemap, 0, 0);
+ tilemap_draw(bitmap, cliprect, state->bg_tilemap, 0, 0);
for (i = 0; i < 16; i++)
{
- unsigned code = runaway_sprite_ram[i] & 0x3f;
+ unsigned code = state->sprite_ram[i] & 0x3f;
- int x = runaway_sprite_ram[i + 0x20];
- int y = runaway_sprite_ram[i + 0x10];
+ int x = state->sprite_ram[i + 0x20];
+ int y = state->sprite_ram[i + 0x10];
- int flipx = runaway_sprite_ram[i] & 0x40;
- int flipy = runaway_sprite_ram[i] & 0x80;
+ int flipx = state->sprite_ram[i] & 0x40;
+ int flipy = state->sprite_ram[i] & 0x80;
- code |= (runaway_sprite_ram[i + 0x30] << 2) & 0x1c0;
+ code |= (state->sprite_ram[i + 0x30] << 2) & 0x1c0;
drawgfx_transpen(bitmap, cliprect, screen->machine->gfx[1],
code,
@@ -128,21 +126,22 @@ VIDEO_UPDATE( runaway )
VIDEO_UPDATE( qwak )
{
+ runaway_state *state = screen->machine->driver_data<runaway_state>();
int i;
- tilemap_draw(bitmap, cliprect, bg_tilemap, 0, 0);
+ tilemap_draw(bitmap, cliprect, state->bg_tilemap, 0, 0);
for (i = 0; i < 16; i++)
{
- unsigned code = runaway_sprite_ram[i] & 0x7f;
+ unsigned code = state->sprite_ram[i] & 0x7f;
- int x = runaway_sprite_ram[i + 0x20];
- int y = runaway_sprite_ram[i + 0x10];
+ int x = state->sprite_ram[i + 0x20];
+ int y = state->sprite_ram[i + 0x10];
int flipx = 0;
- int flipy = runaway_sprite_ram[i] & 0x80;
+ int flipy = state->sprite_ram[i] & 0x80;
- code |= (runaway_sprite_ram[i + 0x30] << 2) & 0x1c0;
+ code |= (state->sprite_ram[i + 0x30] << 2) & 0x1c0;
drawgfx_transpen(bitmap, cliprect, screen->machine->gfx[1],
code,
diff --git a/src/mame/video/skydiver.c b/src/mame/video/skydiver.c
index a853a821b28..5b7c812f89c 100644
--- a/src/mame/video/skydiver.c
+++ b/src/mame/video/skydiver.c
@@ -9,12 +9,6 @@
#include "sound/discrete.h"
-UINT8 *skydiver_videoram;
-
-static tilemap_t *bg_tilemap;
-static int width = 0;
-
-
MACHINE_RESET( skydiver )
{
address_space *space = cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM);
@@ -43,7 +37,8 @@ MACHINE_RESET( skydiver )
static TILE_GET_INFO( get_tile_info )
{
- UINT8 code = skydiver_videoram[tile_index];
+ skydiver_state *state = machine->driver_data<skydiver_state>();
+ UINT8 code = state->videoram[tile_index];
SET_TILE_INFO(0, code & 0x3f, code >> 6, 0);
}
@@ -57,7 +52,8 @@ static TILE_GET_INFO( get_tile_info )
VIDEO_START( skydiver )
{
- bg_tilemap = tilemap_create(machine, get_tile_info,tilemap_scan_rows,8,8,32,32);
+ skydiver_state *state = machine->driver_data<skydiver_state>();
+ state->bg_tilemap = tilemap_create(machine, get_tile_info,tilemap_scan_rows,8,8,32,32);
}
@@ -69,25 +65,29 @@ VIDEO_START( skydiver )
WRITE8_HANDLER( skydiver_videoram_w )
{
- skydiver_videoram[offset] = data;
- tilemap_mark_tile_dirty(bg_tilemap, offset);
+ skydiver_state *state = space->machine->driver_data<skydiver_state>();
+ state->videoram[offset] = data;
+ tilemap_mark_tile_dirty(state->bg_tilemap, offset);
}
READ8_HANDLER( skydiver_wram_r )
{
- return skydiver_videoram[offset | 0x380];
+ skydiver_state *state = space->machine->driver_data<skydiver_state>();
+ return state->videoram[offset | 0x380];
}
WRITE8_HANDLER( skydiver_wram_w )
{
- skydiver_videoram[offset | 0x0380] = data;
+ skydiver_state *state = space->machine->driver_data<skydiver_state>();
+ state->videoram[offset | 0x0380] = data;
}
WRITE8_HANDLER( skydiver_width_w )
{
- width = offset;
+ skydiver_state *state = space->machine->driver_data<skydiver_state>();
+ state->width = offset;
}
@@ -170,6 +170,7 @@ WRITE8_HANDLER( skydiver_2000_201F_w )
static void draw_sprites(running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect)
{
+ skydiver_state *state = machine->driver_data<skydiver_state>();
int pic;
@@ -183,12 +184,12 @@ static void draw_sprites(running_machine *machine, bitmap_t *bitmap, const recta
int color;
int wide;
- sx = 29*8 - skydiver_videoram[pic + 0x0390];
- sy = 30*8 - skydiver_videoram[pic*2 + 0x0398];
- charcode = skydiver_videoram[pic*2 + 0x0399];
+ sx = 29*8 - state->videoram[pic + 0x0390];
+ sy = 30*8 - state->videoram[pic*2 + 0x0398];
+ charcode = state->videoram[pic*2 + 0x0399];
xflip = charcode & 0x10;
yflip = charcode & 0x08;
- wide = (~pic & 0x02) && width;
+ wide = (~pic & 0x02) && state->width;
charcode = (charcode & 0x07) | ((charcode & 0x60) >> 2);
color = pic & 0x01;
@@ -207,7 +208,8 @@ static void draw_sprites(running_machine *machine, bitmap_t *bitmap, const recta
VIDEO_UPDATE( skydiver )
{
- tilemap_draw(bitmap,cliprect,bg_tilemap,0,0);
+ skydiver_state *state = screen->machine->driver_data<skydiver_state>();
+ tilemap_draw(bitmap,cliprect,state->bg_tilemap,0,0);
draw_sprites(screen->machine, bitmap, cliprect);
return 0;
diff --git a/src/mame/video/sprint2.c b/src/mame/video/sprint2.c
index 179918edad9..ab23143b9fe 100644
--- a/src/mame/video/sprint2.c
+++ b/src/mame/video/sprint2.c
@@ -7,13 +7,6 @@
#include "emu.h"
#include "includes/sprint2.h"
-UINT8* sprint2_video_ram;
-
-static tilemap_t* bg_tilemap;
-static bitmap_t* helper;
-
-static int collision[2];
-
PALETTE_INIT( sprint2 )
{
@@ -43,7 +36,8 @@ PALETTE_INIT( sprint2 )
static TILE_GET_INFO( get_tile_info )
{
- UINT8 code = sprint2_video_ram[tile_index];
+ sprint2_state *state = machine->driver_data<sprint2_state>();
+ UINT8 code = state->video_ram[tile_index];
SET_TILE_INFO(0, code & 0x3f, code >> 7, 0);
}
@@ -51,40 +45,46 @@ static TILE_GET_INFO( get_tile_info )
VIDEO_START( sprint2 )
{
- helper = machine->primary_screen->alloc_compatible_bitmap();
+ sprint2_state *state = machine->driver_data<sprint2_state>();
+ state->helper = machine->primary_screen->alloc_compatible_bitmap();
- bg_tilemap = tilemap_create(machine, get_tile_info, tilemap_scan_rows, 16, 8, 32, 32);
+ state->bg_tilemap = tilemap_create(machine, get_tile_info, tilemap_scan_rows, 16, 8, 32, 32);
}
READ8_HANDLER( sprint2_collision1_r )
{
- return collision[0];
+ sprint2_state *state = space->machine->driver_data<sprint2_state>();
+ return state->collision[0];
}
READ8_HANDLER( sprint2_collision2_r )
{
- return collision[1];
+ sprint2_state *state = space->machine->driver_data<sprint2_state>();
+ return state->collision[1];
}
WRITE8_HANDLER( sprint2_collision_reset1_w )
{
- collision[0] = 0;
+ sprint2_state *state = space->machine->driver_data<sprint2_state>();
+ state->collision[0] = 0;
}
WRITE8_HANDLER( sprint2_collision_reset2_w )
{
- collision[1] = 0;
+ sprint2_state *state = space->machine->driver_data<sprint2_state>();
+ state->collision[1] = 0;
}
WRITE8_HANDLER( sprint2_video_ram_w )
{
- sprint2_video_ram[offset] = data;
- tilemap_mark_tile_dirty(bg_tilemap, offset);
+ sprint2_state *state = space->machine->driver_data<sprint2_state>();
+ state->video_ram[offset] = data;
+ tilemap_mark_tile_dirty(state->bg_tilemap, offset);
}
-static UINT8 collision_check(colortable_t *colortable, rectangle* rect)
+static UINT8 collision_check(sprint2_state *state, colortable_t *colortable, rectangle* rect)
{
UINT8 data = 0;
@@ -94,7 +94,7 @@ static UINT8 collision_check(colortable_t *colortable, rectangle* rect)
for (y = rect->min_y; y <= rect->max_y; y++)
for (x = rect->min_x; x <= rect->max_x; x++)
{
- UINT16 a = colortable_entry_get_value(colortable, *BITMAP_ADDR16(helper, y, x));
+ UINT16 a = colortable_entry_get_value(colortable, *BITMAP_ADDR16(state->helper, y, x));
if (a == 0)
data |= 0x40;
@@ -107,36 +107,38 @@ static UINT8 collision_check(colortable_t *colortable, rectangle* rect)
}
-static int get_sprite_code(int n)
+INLINE int get_sprite_code(UINT8 *video_ram, int n)
{
- return sprint2_video_ram[0x398 + 2 * n + 1] >> 3;
+ return video_ram[0x398 + 2 * n + 1] >> 3;
}
-static int get_sprite_x(int n)
+INLINE int get_sprite_x(UINT8 *video_ram, int n)
{
- return 2 * (248 - sprint2_video_ram[0x390 + 1 * n]);
+ return 2 * (248 - video_ram[0x390 + 1 * n]);
}
-static int get_sprite_y(int n)
+INLINE int get_sprite_y(UINT8 *video_ram, int n)
{
- return 1 * (248 - sprint2_video_ram[0x398 + 2 * n]);
+ return 1 * (248 - video_ram[0x398 + 2 * n]);
}
VIDEO_UPDATE( sprint2 )
{
+ sprint2_state *state = screen->machine->driver_data<sprint2_state>();
+ UINT8 *video_ram = state->video_ram;
int i;
- tilemap_draw(bitmap, cliprect, bg_tilemap, 0, 0);
+ tilemap_draw(bitmap, cliprect, state->bg_tilemap, 0, 0);
/* draw the sprites */
for (i = 0; i < 4; i++)
{
drawgfx_transpen(bitmap, cliprect, screen->machine->gfx[1],
- get_sprite_code(i),
+ get_sprite_code(video_ram, i),
i,
0, 0,
- get_sprite_x(i),
- get_sprite_y(i), 0);
+ get_sprite_x(video_ram, i),
+ get_sprite_y(video_ram, i), 0);
}
return 0;
}
@@ -144,6 +146,8 @@ VIDEO_UPDATE( sprint2 )
VIDEO_EOF( sprint2 )
{
+ sprint2_state *state = machine->driver_data<sprint2_state>();
+ UINT8 *video_ram = state->video_ram;
int i;
int j;
const rectangle &visarea = machine->primary_screen->visible_area();
@@ -151,8 +155,8 @@ VIDEO_EOF( sprint2 )
/*
* Collisions are detected for both player cars:
*
- * D7 => collision w/ white playfield
- * D6 => collision w/ black playfield or another car
+ * D7 => state->collision w/ white playfield
+ * D6 => state->collision w/ black playfield or another car
*
*/
@@ -160,10 +164,10 @@ VIDEO_EOF( sprint2 )
{
rectangle rect;
- rect.min_x = get_sprite_x(i);
- rect.min_y = get_sprite_y(i);
- rect.max_x = get_sprite_x(i) + machine->gfx[1]->width - 1;
- rect.max_y = get_sprite_y(i) + machine->gfx[1]->height - 1;
+ rect.min_x = get_sprite_x(video_ram, i);
+ rect.min_y = get_sprite_y(video_ram, i);
+ rect.max_x = get_sprite_x(video_ram, i) + machine->gfx[1]->width - 1;
+ rect.max_y = get_sprite_y(video_ram, i) + machine->gfx[1]->height - 1;
if (rect.min_x < visarea.min_x)
rect.min_x = visarea.min_x;
@@ -176,37 +180,37 @@ VIDEO_EOF( sprint2 )
/* check for sprite-tilemap collisions */
- tilemap_draw(helper, &rect, bg_tilemap, 0, 0);
+ tilemap_draw(state->helper, &rect, state->bg_tilemap, 0, 0);
- drawgfx_transpen(helper, &rect, machine->gfx[1],
- get_sprite_code(i),
+ drawgfx_transpen(state->helper, &rect, machine->gfx[1],
+ get_sprite_code(video_ram, i),
0,
0, 0,
- get_sprite_x(i),
- get_sprite_y(i), 1);
+ get_sprite_x(video_ram, i),
+ get_sprite_y(video_ram, i), 1);
- collision[i] |= collision_check(machine->colortable, &rect);
+ state->collision[i] |= collision_check(state, machine->colortable, &rect);
/* check for sprite-sprite collisions */
for (j = 0; j < 4; j++)
if (j != i)
{
- drawgfx_transpen(helper, &rect, machine->gfx[1],
- get_sprite_code(j),
+ drawgfx_transpen(state->helper, &rect, machine->gfx[1],
+ get_sprite_code(video_ram, j),
1,
0, 0,
- get_sprite_x(j),
- get_sprite_y(j), 0);
+ get_sprite_x(video_ram, j),
+ get_sprite_y(video_ram, j), 0);
}
- drawgfx_transpen(helper, &rect, machine->gfx[1],
- get_sprite_code(i),
+ drawgfx_transpen(state->helper, &rect, machine->gfx[1],
+ get_sprite_code(video_ram, i),
0,
0, 0,
- get_sprite_x(i),
- get_sprite_y(i), 1);
+ get_sprite_x(video_ram, i),
+ get_sprite_y(video_ram, i), 1);
- collision[i] |= collision_check(machine->colortable, &rect);
+ state->collision[i] |= collision_check(state, machine->colortable, &rect);
}
}
diff --git a/src/mame/video/sprint4.c b/src/mame/video/sprint4.c
index 9336bf614ab..85aed50be56 100644
--- a/src/mame/video/sprint4.c
+++ b/src/mame/video/sprint4.c
@@ -8,12 +8,6 @@ Atari Sprint 4 video emulation
#include "audio/sprint4.h"
#include "includes/sprint4.h"
-static tilemap_t* playfield;
-
-static bitmap_t* helper;
-
-int sprint4_collision[4];
-
PALETTE_INIT( sprint4 )
{
@@ -56,9 +50,10 @@ static TILE_GET_INFO( sprint4_tile_info )
VIDEO_START( sprint4 )
{
- helper = machine->primary_screen->alloc_compatible_bitmap();
+ sprint4_state *state = machine->driver_data<sprint4_state>();
+ state->helper = machine->primary_screen->alloc_compatible_bitmap();
- playfield = tilemap_create(machine, sprint4_tile_info, tilemap_scan_rows, 8, 8, 32, 32);
+ state->playfield = tilemap_create(machine, sprint4_tile_info, tilemap_scan_rows, 8, 8, 32, 32);
}
@@ -68,7 +63,7 @@ VIDEO_UPDATE( sprint4 )
UINT8 *videoram = state->videoram;
int i;
- tilemap_draw(bitmap, cliprect, playfield, 0, 0);
+ tilemap_draw(bitmap, cliprect, state->playfield, 0, 0);
for (i = 0; i < 4; i++)
{
@@ -123,12 +118,12 @@ VIDEO_EOF( sprint4 )
sect_rect(&rect, &machine->primary_screen->visible_area());
- tilemap_draw(helper, &rect, playfield, 0, 0);
+ tilemap_draw(state->helper, &rect, state->playfield, 0, 0);
if (i & 1)
bank = 32;
- drawgfx_transpen(helper, &rect, machine->gfx[1],
+ drawgfx_transpen(state->helper, &rect, machine->gfx[1],
(code >> 3) | bank,
4,
0, 0,
@@ -137,8 +132,8 @@ VIDEO_EOF( sprint4 )
for (y = rect.min_y; y <= rect.max_y; y++)
for (x = rect.min_x; x <= rect.max_x; x++)
- if (colortable_entry_get_value(machine->colortable, *BITMAP_ADDR16(helper, y, x)) != 0)
- sprint4_collision[i] = 1;
+ if (colortable_entry_get_value(machine->colortable, *BITMAP_ADDR16(state->helper, y, x)) != 0)
+ state->collision[i] = 1;
}
/* update sound status */
@@ -155,5 +150,5 @@ WRITE8_HANDLER( sprint4_video_ram_w )
sprint4_state *state = space->machine->driver_data<sprint4_state>();
UINT8 *videoram = state->videoram;
videoram[offset] = data;
- tilemap_mark_tile_dirty(playfield, offset);
+ tilemap_mark_tile_dirty(state->playfield, offset);
}
diff --git a/src/mame/video/sprint8.c b/src/mame/video/sprint8.c
index 7a7d9456a02..722964931c6 100644
--- a/src/mame/video/sprint8.c
+++ b/src/mame/video/sprint8.c
@@ -7,18 +7,6 @@ Atari Sprint 8 video emulation
#include "emu.h"
#include "includes/sprint8.h"
-UINT8* sprint8_video_ram;
-UINT8* sprint8_pos_h_ram;
-UINT8* sprint8_pos_v_ram;
-UINT8* sprint8_pos_d_ram;
-UINT8* sprint8_team;
-
-static tilemap_t* tilemap1;
-static tilemap_t* tilemap2;
-
-static bitmap_t* helper1;
-static bitmap_t* helper2;
-
PALETTE_INIT( sprint8 )
{
@@ -40,13 +28,13 @@ PALETTE_INIT( sprint8 )
}
-static void set_pens(colortable_t *colortable)
+static void set_pens(sprint8_state *state, colortable_t *colortable)
{
int i;
for (i = 0; i < 0x10; i += 8)
{
- if (*sprint8_team & 1)
+ if (*state->team & 1)
{
colortable_palette_set_color(colortable, i + 0, MAKE_RGB(0xff, 0x00, 0x00)); /* red */
colortable_palette_set_color(colortable, i + 1, MAKE_RGB(0x00, 0x00, 0xff)); /* blue */
@@ -77,7 +65,8 @@ static void set_pens(colortable_t *colortable)
static TILE_GET_INFO( get_tile_info1 )
{
- UINT8 code = sprint8_video_ram[tile_index];
+ sprint8_state *state = machine->driver_data<sprint8_state>();
+ UINT8 code = state->video_ram[tile_index];
int color = 0;
@@ -102,7 +91,8 @@ static TILE_GET_INFO( get_tile_info1 )
static TILE_GET_INFO( get_tile_info2 )
{
- UINT8 code = sprint8_video_ram[tile_index];
+ sprint8_state *state = machine->driver_data<sprint8_state>();
+ UINT8 code = state->video_ram[tile_index];
int color = 0;
@@ -117,35 +107,38 @@ static TILE_GET_INFO( get_tile_info2 )
WRITE8_HANDLER( sprint8_video_ram_w )
{
- sprint8_video_ram[offset] = data;
- tilemap_mark_tile_dirty(tilemap1, offset);
- tilemap_mark_tile_dirty(tilemap2, offset);
+ sprint8_state *state = space->machine->driver_data<sprint8_state>();
+ state->video_ram[offset] = data;
+ tilemap_mark_tile_dirty(state->tilemap1, offset);
+ tilemap_mark_tile_dirty(state->tilemap2, offset);
}
VIDEO_START( sprint8 )
{
- helper1 = machine->primary_screen->alloc_compatible_bitmap();
- helper2 = machine->primary_screen->alloc_compatible_bitmap();
+ sprint8_state *state = machine->driver_data<sprint8_state>();
+ state->helper1 = machine->primary_screen->alloc_compatible_bitmap();
+ state->helper2 = machine->primary_screen->alloc_compatible_bitmap();
- tilemap1 = tilemap_create(machine, get_tile_info1, tilemap_scan_rows, 16, 8, 32, 32);
- tilemap2 = tilemap_create(machine, get_tile_info2, tilemap_scan_rows, 16, 8, 32, 32);
+ state->tilemap1 = tilemap_create(machine, get_tile_info1, tilemap_scan_rows, 16, 8, 32, 32);
+ state->tilemap2 = tilemap_create(machine, get_tile_info2, tilemap_scan_rows, 16, 8, 32, 32);
- tilemap_set_scrolly(tilemap1, 0, +24);
- tilemap_set_scrolly(tilemap2, 0, +24);
+ tilemap_set_scrolly(state->tilemap1, 0, +24);
+ tilemap_set_scrolly(state->tilemap2, 0, +24);
}
static void draw_sprites(running_machine *machine, bitmap_t* bitmap, const rectangle *cliprect)
{
+ sprint8_state *state = machine->driver_data<sprint8_state>();
int i;
for (i = 0; i < 16; i++)
{
- UINT8 code = sprint8_pos_d_ram[i];
+ UINT8 code = state->pos_d_ram[i];
- int x = sprint8_pos_h_ram[i];
- int y = sprint8_pos_v_ram[i];
+ int x = state->pos_h_ram[i];
+ int y = state->pos_v_ram[i];
if (code & 0x80)
x |= 0x100;
@@ -167,8 +160,9 @@ static TIMER_CALLBACK( sprint8_collision_callback )
VIDEO_UPDATE( sprint8 )
{
- set_pens(screen->machine->colortable);
- tilemap_draw(bitmap, cliprect, tilemap1, 0, 0);
+ sprint8_state *state = screen->machine->driver_data<sprint8_state>();
+ set_pens(state, screen->machine->colortable);
+ tilemap_draw(bitmap, cliprect, state->tilemap1, 0, 0);
draw_sprites(screen->machine, bitmap, cliprect);
return 0;
}
@@ -176,20 +170,21 @@ VIDEO_UPDATE( sprint8 )
VIDEO_EOF( sprint8 )
{
+ sprint8_state *state = machine->driver_data<sprint8_state>();
int x;
int y;
const rectangle &visarea = machine->primary_screen->visible_area();
- tilemap_draw(helper2, &visarea, tilemap2, 0, 0);
+ tilemap_draw(state->helper2, &visarea, state->tilemap2, 0, 0);
- bitmap_fill(helper1, &visarea, 0x20);
+ bitmap_fill(state->helper1, &visarea, 0x20);
- draw_sprites(machine, helper1, &visarea);
+ draw_sprites(machine, state->helper1, &visarea);
for (y = visarea.min_y; y <= visarea.max_y; y++)
{
- const UINT16* p1 = BITMAP_ADDR16(helper1, y, 0);
- const UINT16* p2 = BITMAP_ADDR16(helper2, y, 0);
+ const UINT16* p1 = BITMAP_ADDR16(state->helper1, y, 0);
+ const UINT16* p2 = BITMAP_ADDR16(state->helper2, y, 0);
for (x = visarea.min_x; x <= visarea.max_x; x++)
if (p1[x] != 0x20 && p2[x] == 0x23)
diff --git a/src/mame/video/starshp1.c b/src/mame/video/starshp1.c
index 7174d78c242..05361af95d0 100644
--- a/src/mame/video/starshp1.c
+++ b/src/mame/video/starshp1.c
@@ -7,46 +7,17 @@ Atari Starship 1 video emulation
#include "emu.h"
#include "includes/starshp1.h"
-UINT8 *starshp1_playfield_ram;
-UINT8 *starshp1_hpos_ram;
-UINT8 *starshp1_vpos_ram;
-UINT8 *starshp1_obj_ram;
-int starshp1_ship_explode;
-int starshp1_ship_picture;
-int starshp1_ship_hoffset;
-int starshp1_ship_voffset;
-int starshp1_ship_size;
-
-int starshp1_circle_kill;
-int starshp1_circle_mod;
-int starshp1_circle_hpos;
-int starshp1_circle_vpos;
-int starshp1_circle_size;
-
-int starshp1_starfield_kill;
-int starshp1_phasor;
-int starshp1_collision_latch;
-int starshp1_mux;
-int starshp1_inverse;
-
-static UINT16 *LSFR;
-
-static bitmap_t *helper;
-
-static tilemap_t *bg_tilemap;
-
-
-static void set_pens(colortable_t *colortable)
+static void set_pens(starshp1_state *state, colortable_t *colortable)
{
- colortable_palette_set_color(colortable, starshp1_inverse ? 7 : 0, MAKE_RGB(0x00, 0x00, 0x00));
- colortable_palette_set_color(colortable, starshp1_inverse ? 6 : 1, MAKE_RGB(0x1e, 0x1e, 0x1e));
- colortable_palette_set_color(colortable, starshp1_inverse ? 5 : 2, MAKE_RGB(0x4e, 0x4e, 0x4e));
- colortable_palette_set_color(colortable, starshp1_inverse ? 4 : 3, MAKE_RGB(0x6c, 0x6c, 0x6c));
- colortable_palette_set_color(colortable, starshp1_inverse ? 3 : 4, MAKE_RGB(0x93, 0x93, 0x93));
- colortable_palette_set_color(colortable, starshp1_inverse ? 2 : 5, MAKE_RGB(0xb1, 0xb1, 0xb1));
- colortable_palette_set_color(colortable, starshp1_inverse ? 1 : 6, MAKE_RGB(0xe1, 0xe1, 0xe1));
- colortable_palette_set_color(colortable, starshp1_inverse ? 0 : 7, MAKE_RGB(0xff, 0xff, 0xff));
+ colortable_palette_set_color(colortable, state->inverse ? 7 : 0, MAKE_RGB(0x00, 0x00, 0x00));
+ colortable_palette_set_color(colortable, state->inverse ? 6 : 1, MAKE_RGB(0x1e, 0x1e, 0x1e));
+ colortable_palette_set_color(colortable, state->inverse ? 5 : 2, MAKE_RGB(0x4e, 0x4e, 0x4e));
+ colortable_palette_set_color(colortable, state->inverse ? 4 : 3, MAKE_RGB(0x6c, 0x6c, 0x6c));
+ colortable_palette_set_color(colortable, state->inverse ? 3 : 4, MAKE_RGB(0x93, 0x93, 0x93));
+ colortable_palette_set_color(colortable, state->inverse ? 2 : 5, MAKE_RGB(0xb1, 0xb1, 0xb1));
+ colortable_palette_set_color(colortable, state->inverse ? 1 : 6, MAKE_RGB(0xe1, 0xe1, 0xe1));
+ colortable_palette_set_color(colortable, state->inverse ? 0 : 7, MAKE_RGB(0xff, 0xff, 0xff));
}
@@ -76,7 +47,8 @@ PALETTE_INIT( starshp1 )
static TILE_GET_INFO( get_tile_info )
{
- UINT8 code = starshp1_playfield_ram[tile_index];
+ starshp1_state *state = machine->driver_data<starshp1_state>();
+ UINT8 code = state->playfield_ram[tile_index];
SET_TILE_INFO(0, code & 0x3f, 0, 0);
}
@@ -84,17 +56,18 @@ static TILE_GET_INFO( get_tile_info )
VIDEO_START( starshp1 )
{
+ starshp1_state *state = machine->driver_data<starshp1_state>();
UINT16 val = 0;
int i;
- bg_tilemap = tilemap_create(machine, get_tile_info, tilemap_scan_rows, 16, 8, 32, 32);
+ state->bg_tilemap = tilemap_create(machine, get_tile_info, tilemap_scan_rows, 16, 8, 32, 32);
- tilemap_set_transparent_pen(bg_tilemap, 0);
+ tilemap_set_transparent_pen(state->bg_tilemap, 0);
- tilemap_set_scrollx(bg_tilemap, 0, -8);
+ tilemap_set_scrollx(state->bg_tilemap, 0, -8);
- LSFR = auto_alloc_array(machine, UINT16, 0x10000);
+ state->LSFR = auto_alloc_array(machine, UINT16, 0x10000);
for (i = 0; i < 0x10000; i++)
{
@@ -103,17 +76,18 @@ VIDEO_START( starshp1 )
(val >> 0x7) ^
(val >> 0x1) ^ 1;
- LSFR[i] = val;
+ state->LSFR[i] = val;
val = (val << 1) | (bit & 1);
}
- helper = machine->primary_screen->alloc_compatible_bitmap();
+ state->helper = machine->primary_screen->alloc_compatible_bitmap();
}
READ8_HANDLER( starshp1_rng_r )
{
+ starshp1_state *state = space->machine->driver_data<starshp1_state>();
int width = space->machine->primary_screen->width();
int height = space->machine->primary_screen->height();
int x = space->machine->primary_screen->hpos();
@@ -126,12 +100,13 @@ READ8_HANDLER( starshp1_rng_r )
if (y > height - 1)
y = height - 1;
- return LSFR[x + (UINT16) (512 * y)];
+ return state->LSFR[x + (UINT16) (512 * y)];
}
WRITE8_HANDLER( starshp1_ssadd_w )
{
+ starshp1_state *state = space->machine->driver_data<starshp1_state>();
/*
* The range of sprite position values doesn't suffice to
* move the zoomed spaceship sprite over the top and left
@@ -141,13 +116,14 @@ WRITE8_HANDLER( starshp1_ssadd_w )
* practice they work like offsets in zoomed pixels.
*/
- starshp1_ship_voffset = ((offset & 0xf0) >> 4);
- starshp1_ship_hoffset = ((offset & 0x0f) << 2) | (data & 3);
+ state->ship_voffset = ((offset & 0xf0) >> 4);
+ state->ship_hoffset = ((offset & 0x0f) << 2) | (data & 3);
}
WRITE8_HANDLER( starshp1_sspic_w )
{
+ starshp1_state *state = space->machine->driver_data<starshp1_state>();
/*
* Some mysterious game code at address $2CCE is causing
* erratic images in the target explosion sequence. The
@@ -155,22 +131,23 @@ WRITE8_HANDLER( starshp1_sspic_w )
*/
if (data != 0x87)
- starshp1_ship_picture = data;
+ state->ship_picture = data;
}
WRITE8_HANDLER( starshp1_playfield_w )
{
- if (starshp1_mux != 0)
+ starshp1_state *state = space->machine->driver_data<starshp1_state>();
+ if (state->mux != 0)
{
offset ^= 0x1f;
- starshp1_playfield_ram[offset] = data;
- tilemap_mark_tile_dirty(bg_tilemap, offset);
+ state->playfield_ram[offset] = data;
+ tilemap_mark_tile_dirty(state->bg_tilemap, offset);
}
}
-static void draw_starfield(bitmap_t* bitmap)
+static void draw_starfield(starshp1_state *state, bitmap_t* bitmap)
{
/*
* The LSFR is reset once per frame at the position of
@@ -183,7 +160,7 @@ static void draw_starfield(bitmap_t* bitmap)
for (y = 0; y < bitmap->height; y++)
{
- const UINT16* p = LSFR + (UINT16) (512 * y);
+ const UINT16* p = state->LSFR + (UINT16) (512 * y);
UINT16* pLine = BITMAP_ADDR16(bitmap, y, 0);
@@ -194,65 +171,67 @@ static void draw_starfield(bitmap_t* bitmap)
}
-static int get_sprite_hpos(int i)
+static int get_sprite_hpos(starshp1_state *state, int i)
{
- return 2 * (starshp1_hpos_ram[i] ^ 0xff);
+ return 2 * (state->hpos_ram[i] ^ 0xff);
}
-static int get_sprite_vpos(int i)
+static int get_sprite_vpos(starshp1_state *state, int i)
{
- return 1 * (starshp1_vpos_ram[i] - 0x07);
+ return 1 * (state->vpos_ram[i] - 0x07);
}
static void draw_sprites(running_machine *machine, bitmap_t* bitmap, const rectangle* cliprect)
{
+ starshp1_state *state = machine->driver_data<starshp1_state>();
int i;
for (i = 0; i < 14; i++)
{
- int code = (starshp1_obj_ram[i] & 0xf) ^ 0xf;
+ int code = (state->obj_ram[i] & 0xf) ^ 0xf;
drawgfx_transpen(bitmap, cliprect, machine->gfx[1],
code % 8,
code / 8,
0, 0,
- get_sprite_hpos(i),
- get_sprite_vpos(i), 0);
+ get_sprite_hpos(state, i),
+ get_sprite_vpos(state, i), 0);
}
}
static void draw_spaceship(running_machine *machine, bitmap_t* bitmap, const rectangle* cliprect)
{
- double scaler = -5 * log(1 - starshp1_ship_size / 256.0); /* ? */
+ starshp1_state *state = machine->driver_data<starshp1_state>();
+ double scaler = -5 * log(1 - state->ship_size / 256.0); /* ? */
unsigned xzoom = 2 * 0x10000 * scaler;
unsigned yzoom = 1 * 0x10000 * scaler;
- int x = get_sprite_hpos(14);
- int y = get_sprite_vpos(14);
+ int x = get_sprite_hpos(state, 14);
+ int y = get_sprite_vpos(state, 14);
if (x <= 0)
- x -= (xzoom * starshp1_ship_hoffset) >> 16;
+ x -= (xzoom * state->ship_hoffset) >> 16;
if (y <= 0)
- y -= (yzoom * starshp1_ship_voffset) >> 16;
+ y -= (yzoom * state->ship_voffset) >> 16;
drawgfxzoom_transpen(bitmap, cliprect, machine->gfx[2],
- starshp1_ship_picture & 0x03,
- starshp1_ship_explode,
- starshp1_ship_picture & 0x80, 0,
+ state->ship_picture & 0x03,
+ state->ship_explode,
+ state->ship_picture & 0x80, 0,
x, y,
xzoom, yzoom, 0);
}
-static void draw_phasor(bitmap_t* bitmap)
+static void draw_phasor(starshp1_state *state, bitmap_t* bitmap)
{
int i;
for (i = 128; i < 240; i++)
- if (i >= get_sprite_vpos(13))
+ if (i >= get_sprite_vpos(state, 13))
{
*BITMAP_ADDR16(bitmap, i, 2 * i + 0) = 0x10;
*BITMAP_ADDR16(bitmap, i, 2 * i + 1) = 0x10;
@@ -262,25 +241,26 @@ static void draw_phasor(bitmap_t* bitmap)
}
-static int get_radius(void)
+static int get_radius(starshp1_state *state)
{
- return 6 * sqrt((double)starshp1_circle_size); /* size calibrated by hand */
+ return 6 * sqrt((double)state->circle_size); /* size calibrated by hand */
}
-static int get_circle_hpos(void)
+static int get_circle_hpos(starshp1_state *state)
{
- return 2 * (3 * starshp1_circle_hpos / 2 - 64);
+ return 2 * (3 * state->circle_hpos / 2 - 64);
}
-static int get_circle_vpos(void)
+static int get_circle_vpos(starshp1_state *state)
{
- return 1 * (3 * starshp1_circle_vpos / 2 - 64);
+ return 1 * (3 * state->circle_vpos / 2 - 64);
}
-static void draw_circle_line(bitmap_t *bitmap, int x, int y, int l)
+static void draw_circle_line(running_machine *machine, bitmap_t *bitmap, int x, int y, int l)
{
+ starshp1_state *state = machine->driver_data<starshp1_state>();
if (y >= 0 && y <= bitmap->height - 1)
{
- const UINT16* p = LSFR + (UINT16) (512 * y);
+ const UINT16* p = state->LSFR + (UINT16) (512 * y);
UINT16* pLine = BITMAP_ADDR16(bitmap, y, 0);
@@ -293,7 +273,7 @@ static void draw_circle_line(bitmap_t *bitmap, int x, int y, int l)
h2 = bitmap->width - 1;
for (x = h1; x <= h2; x++)
- if (starshp1_circle_mod)
+ if (state->circle_mod)
{
if (p[x] & 1)
pLine[x] = 0x11;
@@ -304,24 +284,25 @@ static void draw_circle_line(bitmap_t *bitmap, int x, int y, int l)
}
-static void draw_circle(bitmap_t* bitmap)
+static void draw_circle(running_machine *machine, bitmap_t* bitmap)
{
- int cx = get_circle_hpos();
- int cy = get_circle_vpos();
+ starshp1_state *state = machine->driver_data<starshp1_state>();
+ int cx = get_circle_hpos(state);
+ int cy = get_circle_vpos(state);
int x = 0;
- int y = get_radius();
+ int y = get_radius(state);
/* Bresenham's circle algorithm */
- int d = 3 - 2 * get_radius();
+ int d = 3 - 2 * get_radius(state);
while (x <= y)
{
- draw_circle_line(bitmap, cx, cy - x, y);
- draw_circle_line(bitmap, cx, cy + x, y);
- draw_circle_line(bitmap, cx, cy - y, x);
- draw_circle_line(bitmap, cx, cy + y, x);
+ draw_circle_line(machine, bitmap, cx, cy - x, y);
+ draw_circle_line(machine, bitmap, cx, cy + x, y);
+ draw_circle_line(machine, bitmap, cx, cy - y, x);
+ draw_circle_line(machine, bitmap, cx, cy + y, x);
x++;
@@ -333,14 +314,15 @@ static void draw_circle(bitmap_t* bitmap)
}
-static int spaceship_collision(bitmap_t *bitmap, const rectangle *rect)
+static int spaceship_collision(running_machine *machine, bitmap_t *bitmap, const rectangle *rect)
{
+ starshp1_state *state = machine->driver_data<starshp1_state>();
int x;
int y;
for (y = rect->min_y; y <= rect->max_y; y++)
{
- const UINT16* pLine = BITMAP_ADDR16(helper, y, 0);
+ const UINT16* pLine = BITMAP_ADDR16(state->helper, y, 0);
for (x = rect->min_x; x <= rect->max_x; x++)
if (pLine[x] != 0)
@@ -360,12 +342,12 @@ static int point_in_circle(int x, int y, int center_x, int center_y, int r)
}
-static int circle_collision(const rectangle *rect)
+static int circle_collision(starshp1_state *state, const rectangle *rect)
{
- int center_x = get_circle_hpos();
- int center_y = get_circle_vpos();
+ int center_x = get_circle_hpos(state);
+ int center_y = get_circle_vpos(state);
- int r = get_radius();
+ int r = get_radius(state);
return point_in_circle(rect->min_x, rect->min_y, center_x, center_y, r) ||
point_in_circle(rect->min_x, rect->max_y, center_x, center_y, r) ||
@@ -376,28 +358,29 @@ static int circle_collision(const rectangle *rect)
VIDEO_UPDATE( starshp1 )
{
- set_pens(screen->machine->colortable);
+ starshp1_state *state = screen->machine->driver_data<starshp1_state>();
+ set_pens(state, screen->machine->colortable);
bitmap_fill(bitmap, cliprect, 0);
- if (starshp1_starfield_kill == 0)
- draw_starfield(bitmap);
+ if (state->starfield_kill == 0)
+ draw_starfield(state, bitmap);
draw_sprites(screen->machine, bitmap, cliprect);
- if (starshp1_circle_kill == 0 && starshp1_circle_mod != 0)
- draw_circle(bitmap);
+ if (state->circle_kill == 0 && state->circle_mod != 0)
+ draw_circle(screen->machine, bitmap);
- if (starshp1_attract == 0)
+ if (state->attract == 0)
draw_spaceship(screen->machine, bitmap, cliprect);
- if (starshp1_circle_kill == 0 && starshp1_circle_mod == 0)
- draw_circle(bitmap);
+ if (state->circle_kill == 0 && state->circle_mod == 0)
+ draw_circle(screen->machine, bitmap);
- tilemap_draw(bitmap, cliprect, bg_tilemap, 0, 0);
+ tilemap_draw(bitmap, cliprect, state->bg_tilemap, 0, 0);
- if (starshp1_phasor != 0)
- draw_phasor(bitmap);
+ if (state->phasor != 0)
+ draw_phasor(state, bitmap);
return 0;
}
@@ -405,11 +388,12 @@ VIDEO_UPDATE( starshp1 )
VIDEO_EOF( starshp1 )
{
+ starshp1_state *state = machine->driver_data<starshp1_state>();
rectangle rect;
const rectangle &visarea = machine->primary_screen->visible_area();
- rect.min_x = get_sprite_hpos(13);
- rect.min_y = get_sprite_vpos(13);
+ rect.min_x = get_sprite_hpos(state, 13);
+ rect.min_y = get_sprite_vpos(state, 13);
rect.max_x = rect.min_x + machine->gfx[1]->width - 1;
rect.max_y = rect.min_y + machine->gfx[1]->height - 1;
@@ -417,25 +401,25 @@ VIDEO_EOF( starshp1 )
rect.min_x = 0;
if (rect.min_y < 0)
rect.min_y = 0;
- if (rect.max_x > helper->width - 1)
- rect.max_x = helper->width - 1;
- if (rect.max_y > helper->height - 1)
- rect.max_y = helper->height - 1;
+ if (rect.max_x > state->helper->width - 1)
+ rect.max_x = state->helper->width - 1;
+ if (rect.max_y > state->helper->height - 1)
+ rect.max_y = state->helper->height - 1;
- bitmap_fill(helper, &visarea, 0);
+ bitmap_fill(state->helper, &visarea, 0);
- if (starshp1_attract == 0)
- draw_spaceship(machine, helper, &visarea);
+ if (state->attract == 0)
+ draw_spaceship(machine, state->helper, &visarea);
- if (circle_collision(&visarea))
- starshp1_collision_latch |= 1;
+ if (circle_collision(state, &visarea))
+ state->collision_latch |= 1;
- if (circle_collision(&rect))
- starshp1_collision_latch |= 2;
+ if (circle_collision(state, &rect))
+ state->collision_latch |= 2;
- if (spaceship_collision(helper, &rect))
- starshp1_collision_latch |= 4;
+ if (spaceship_collision(machine, state->helper, &rect))
+ state->collision_latch |= 4;
- if (spaceship_collision(helper, &visarea))
- starshp1_collision_latch |= 8;
+ if (spaceship_collision(machine, state->helper, &visarea))
+ state->collision_latch |= 8;
}
diff --git a/src/mame/video/subs.c b/src/mame/video/subs.c
index 5381afef094..06ce9995362 100644
--- a/src/mame/video/subs.c
+++ b/src/mame/video/subs.c
@@ -41,7 +41,7 @@ VIDEO_UPDATE( subs )
{
subs_state *state = screen->machine->driver_data<subs_state>();
UINT8 *videoram = state->videoram;
- UINT8 *spriteram = screen->machine->generic.spriteram.u8;
+ UINT8 *spriteram = state->spriteram;
int offs;
device_t *left_screen = screen->machine->device("lscreen");
diff --git a/src/mame/video/tank8.c b/src/mame/video/tank8.c
index a7f0ef30c72..9d4f16731b6 100644
--- a/src/mame/video/tank8.c
+++ b/src/mame/video/tank8.c
@@ -8,20 +8,6 @@ Atari Tank 8 video emulation
#include "includes/tank8.h"
-UINT8 *tank8_video_ram;
-UINT8 *tank8_pos_h_ram;
-UINT8 *tank8_pos_v_ram;
-UINT8 *tank8_pos_d_ram;
-UINT8 *tank8_team;
-
-static tilemap_t *tank8_tilemap;
-
-static bitmap_t *helper1;
-static bitmap_t *helper2;
-static bitmap_t *helper3;
-
-
-
PALETTE_INIT( tank8 )
{
int i;
@@ -48,9 +34,9 @@ PALETTE_INIT( tank8 )
}
-static void set_pens(colortable_t *colortable)
+static void set_pens(tank8_state *state, colortable_t *colortable)
{
- if (*tank8_team & 0x01)
+ if (*state->team & 0x01)
{
colortable_palette_set_color(colortable, 0, MAKE_RGB(0xff, 0x00, 0x00)); /* red */
colortable_palette_set_color(colortable, 1, MAKE_RGB(0x00, 0x00, 0xff)); /* blue */
@@ -77,15 +63,17 @@ static void set_pens(colortable_t *colortable)
WRITE8_HANDLER( tank8_video_ram_w )
{
- tank8_video_ram[offset] = data;
- tilemap_mark_tile_dirty(tank8_tilemap, offset);
+ tank8_state *state = space->machine->driver_data<tank8_state>();
+ state->video_ram[offset] = data;
+ tilemap_mark_tile_dirty(state->tilemap, offset);
}
static TILE_GET_INFO( tank8_get_tile_info )
{
- UINT8 code = tank8_video_ram[tile_index];
+ tank8_state *state = machine->driver_data<tank8_state>();
+ UINT8 code = state->video_ram[tile_index];
int color = 0;
@@ -115,40 +103,42 @@ static TILE_GET_INFO( tank8_get_tile_info )
VIDEO_START( tank8 )
{
- helper1 = machine->primary_screen->alloc_compatible_bitmap();
- helper2 = machine->primary_screen->alloc_compatible_bitmap();
- helper3 = machine->primary_screen->alloc_compatible_bitmap();
+ tank8_state *state = machine->driver_data<tank8_state>();
+ state->helper1 = machine->primary_screen->alloc_compatible_bitmap();
+ state->helper2 = machine->primary_screen->alloc_compatible_bitmap();
+ state->helper3 = machine->primary_screen->alloc_compatible_bitmap();
- tank8_tilemap = tilemap_create(machine, tank8_get_tile_info, tilemap_scan_rows, 16, 16, 32, 32);
+ state->tilemap = tilemap_create(machine, tank8_get_tile_info, tilemap_scan_rows, 16, 16, 32, 32);
/* VBLANK starts on scanline #256 and ends on scanline #24 */
- tilemap_set_scrolly(tank8_tilemap, 0, 2 * 24);
+ tilemap_set_scrolly(state->tilemap, 0, 2 * 24);
}
-static int get_x_pos(int n)
+static int get_x_pos(tank8_state *state, int n)
{
- return 498 - tank8_pos_h_ram[n] - 2 * (tank8_pos_d_ram[n] & 128); /* ? */
+ return 498 - state->pos_h_ram[n] - 2 * (state->pos_d_ram[n] & 128); /* ? */
}
-static int get_y_pos(int n)
+static int get_y_pos(tank8_state *state, int n)
{
- return 2 * tank8_pos_v_ram[n] - 62;
+ return 2 * state->pos_v_ram[n] - 62;
}
static void draw_sprites(running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect)
{
+ tank8_state *state = machine->driver_data<tank8_state>();
int i;
for (i = 0; i < 8; i++)
{
- UINT8 code = ~tank8_pos_d_ram[i];
+ UINT8 code = ~state->pos_d_ram[i];
- int x = get_x_pos(i);
- int y = get_y_pos(i);
+ int x = get_x_pos(state, i);
+ int y = get_y_pos(state, i);
drawgfx_transpen(bitmap, cliprect, machine->gfx[(code & 0x04) ? 2 : 3],
code & 0x03,
@@ -161,16 +151,17 @@ static void draw_sprites(running_machine *machine, bitmap_t *bitmap, const recta
}
-static void draw_bullets(bitmap_t *bitmap, const rectangle *cliprect)
+static void draw_bullets(running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect)
{
+ tank8_state *state = machine->driver_data<tank8_state>();
int i;
for (i = 0; i < 8; i++)
{
rectangle rect;
- int x = get_x_pos(8 + i);
- int y = get_y_pos(8 + i);
+ int x = get_x_pos(state, 8 + i);
+ int y = get_y_pos(state, 8 + i);
x -= 4; /* ? */
@@ -201,36 +192,38 @@ static TIMER_CALLBACK( tank8_collision_callback )
VIDEO_UPDATE( tank8 )
{
- set_pens(screen->machine->colortable);
- tilemap_draw(bitmap, cliprect, tank8_tilemap, 0, 0);
+ tank8_state *state = screen->machine->driver_data<tank8_state>();
+ set_pens(state, screen->machine->colortable);
+ tilemap_draw(bitmap, cliprect, state->tilemap, 0, 0);
draw_sprites(screen->machine, bitmap, cliprect);
- draw_bullets(bitmap, cliprect);
+ draw_bullets(screen->machine, bitmap, cliprect);
return 0;
}
VIDEO_EOF( tank8 )
{
+ tank8_state *state = machine->driver_data<tank8_state>();
int x;
int y;
const rectangle &visarea = machine->primary_screen->visible_area();
- tilemap_draw(helper1, &visarea, tank8_tilemap, 0, 0);
+ tilemap_draw(state->helper1, &visarea, state->tilemap, 0, 0);
- bitmap_fill(helper2, &visarea, 8);
- bitmap_fill(helper3, &visarea, 8);
+ bitmap_fill(state->helper2, &visarea, 8);
+ bitmap_fill(state->helper3, &visarea, 8);
- draw_sprites(machine, helper2, &visarea);
- draw_bullets(helper3, &visarea);
+ draw_sprites(machine, state->helper2, &visarea);
+ draw_bullets(machine, state->helper3, &visarea);
for (y = visarea.min_y; y <= visarea.max_y; y++)
{
- int state = 0;
+ int _state = 0;
- const UINT16* p1 = BITMAP_ADDR16(helper1, y, 0);
- const UINT16* p2 = BITMAP_ADDR16(helper2, y, 0);
- const UINT16* p3 = BITMAP_ADDR16(helper3, y, 0);
+ const UINT16* p1 = BITMAP_ADDR16(state->helper1, y, 0);
+ const UINT16* p2 = BITMAP_ADDR16(state->helper2, y, 0);
+ const UINT16* p3 = BITMAP_ADDR16(state->helper3, y, 0);
if (y % 2 != machine->primary_screen->frame_number() % 2)
continue; /* video display is interlaced */
@@ -242,25 +235,25 @@ VIDEO_EOF( tank8 )
/* neither wall nor mine */
if ((p1[x] != 0x11) && (p1[x] != 0x13))
{
- state = 0;
+ _state = 0;
continue;
}
/* neither tank nor bullet */
if ((p2[x] == 8) && (p3[x] == 8))
{
- state = 0;
+ _state = 0;
continue;
}
/* bullets cannot hit mines */
if ((p3[x] != 8) && (p1[x] == 0x13))
{
- state = 0;
+ _state = 0;
continue;
}
- if (state)
+ if (_state)
continue;
if (p3[x] != 8)
@@ -284,16 +277,16 @@ VIDEO_EOF( tank8 )
if (p1[x] == 0x11)
index |= 0x20;
- if (y - get_y_pos(sprite_num) >= 8)
+ if (y - get_y_pos(state, sprite_num) >= 8)
index |= 0x40; /* collision on bottom side */
- if (x - get_x_pos(sprite_num) >= 8)
+ if (x - get_x_pos(state, sprite_num) >= 8)
index |= 0x80; /* collision on right side */
}
timer_set(machine, machine->primary_screen->time_until_pos(y, x), NULL, index, tank8_collision_callback);
- state = 1;
+ _state = 1;
}
}
}
diff --git a/src/mame/video/ultratnk.c b/src/mame/video/ultratnk.c
index 2d654171af7..07ba31a3ba0 100644
--- a/src/mame/video/ultratnk.c
+++ b/src/mame/video/ultratnk.c
@@ -8,12 +8,6 @@ Atari Ultra Tank video emulation
#include "includes/ultratnk.h"
#include "audio/sprint4.h"
-static tilemap_t* playfield;
-
-static bitmap_t* helper;
-
-int ultratnk_collision[4];
-
PALETTE_INIT( ultratnk )
{
@@ -54,9 +48,10 @@ static TILE_GET_INFO( ultratnk_tile_info )
VIDEO_START( ultratnk )
{
- helper = machine->primary_screen->alloc_compatible_bitmap();
+ ultratnk_state *state = machine->driver_data<ultratnk_state>();
+ state->helper = machine->primary_screen->alloc_compatible_bitmap();
- playfield = tilemap_create(machine, ultratnk_tile_info, tilemap_scan_rows, 8, 8, 32, 32);
+ state->playfield = tilemap_create(machine, ultratnk_tile_info, tilemap_scan_rows, 8, 8, 32, 32);
}
@@ -66,7 +61,7 @@ VIDEO_UPDATE( ultratnk )
UINT8 *videoram = state->videoram;
int i;
- tilemap_draw(bitmap, cliprect, playfield, 0, 0);
+ tilemap_draw(bitmap, cliprect, state->playfield, 0, 0);
for (i = 0; i < 4; i++)
{
@@ -125,12 +120,12 @@ VIDEO_EOF( ultratnk )
sect_rect(&rect, &machine->primary_screen->visible_area());
- tilemap_draw(helper, &rect, playfield, 0, 0);
+ tilemap_draw(state->helper, &rect, state->playfield, 0, 0);
if (code & 4)
bank = 32;
- drawgfx_transpen(helper, &rect, machine->gfx[1],
+ drawgfx_transpen(state->helper, &rect, machine->gfx[1],
(code >> 3) | bank,
4,
0, 0,
@@ -139,8 +134,8 @@ VIDEO_EOF( ultratnk )
for (y = rect.min_y; y <= rect.max_y; y++)
for (x = rect.min_x; x <= rect.max_x; x++)
- if (colortable_entry_get_value(machine->colortable, *BITMAP_ADDR16(helper, y, x)) != BG)
- ultratnk_collision[i] = 1;
+ if (colortable_entry_get_value(machine->colortable, *BITMAP_ADDR16(state->helper, y, x)) != BG)
+ state->collision[i] = 1;
}
/* update sound status */
@@ -155,5 +150,5 @@ WRITE8_HANDLER( ultratnk_video_ram_w )
ultratnk_state *state = space->machine->driver_data<ultratnk_state>();
UINT8 *videoram = state->videoram;
videoram[offset] = data;
- tilemap_mark_tile_dirty(playfield, offset);
+ tilemap_mark_tile_dirty(state->playfield, offset);
}
diff --git a/src/mame/video/videopin.c b/src/mame/video/videopin.c
index ce704ebba85..80a96492b1c 100644
--- a/src/mame/video/videopin.c
+++ b/src/mame/video/videopin.c
@@ -7,12 +7,8 @@
#include "emu.h"
#include "includes/videopin.h"
-UINT8* videopin_video_ram;
-static int ball_x;
-static int ball_y;
-static tilemap_t* bg_tilemap;
static TILEMAP_MAPPER( get_memory_offset )
@@ -23,7 +19,8 @@ static TILEMAP_MAPPER( get_memory_offset )
static TILE_GET_INFO( get_tile_info )
{
- UINT8 code = videopin_video_ram[tile_index];
+ videopin_state *state = machine->driver_data<videopin_state>();
+ UINT8 code = state->video_ram[tile_index];
SET_TILE_INFO(0, code, 0, (code & 0x40) ? TILE_FLIPY : 0);
}
@@ -31,18 +28,20 @@ static TILE_GET_INFO( get_tile_info )
VIDEO_START( videopin )
{
- bg_tilemap = tilemap_create(machine, get_tile_info, get_memory_offset, 8, 8, 48, 32);
+ videopin_state *state = machine->driver_data<videopin_state>();
+ state->bg_tilemap = tilemap_create(machine, get_tile_info, get_memory_offset, 8, 8, 48, 32);
}
VIDEO_UPDATE( videopin )
{
+ videopin_state *state = screen->machine->driver_data<videopin_state>();
int col;
int row;
- tilemap_set_scrollx(bg_tilemap, 0, -8); /* account for delayed loading of shift reg C6 */
+ tilemap_set_scrollx(state->bg_tilemap, 0, -8); /* account for delayed loading of shift reg C6 */
- tilemap_draw(bitmap, cliprect, bg_tilemap, 0, 0);
+ tilemap_draw(bitmap, cliprect, state->bg_tilemap, 0, 0);
for (row = 0; row < 32; row++)
{
@@ -50,7 +49,7 @@ VIDEO_UPDATE( videopin )
{
UINT32 offset = get_memory_offset(col, row, 48, 32);
- if (videopin_video_ram[offset] & 0x80) /* ball bit found */
+ if (state->video_ram[offset] & 0x80) /* ball bit found */
{
rectangle rect;
@@ -76,8 +75,8 @@ VIDEO_UPDATE( videopin )
if (rect.max_y > cliprect->max_y)
rect.max_y = cliprect->max_y;
- x -= ball_x;
- y -= ball_y;
+ x -= state->ball_x;
+ y -= state->ball_y;
/* ball placement is still 0.5 pixels off but don't tell anyone */
@@ -103,13 +102,15 @@ VIDEO_UPDATE( videopin )
WRITE8_HANDLER( videopin_ball_w )
{
- ball_x = data & 15;
- ball_y = data >> 4;
+ videopin_state *state = space->machine->driver_data<videopin_state>();
+ state->ball_x = data & 15;
+ state->ball_y = data >> 4;
}
WRITE8_HANDLER( videopin_video_ram_w )
{
- videopin_video_ram[offset] = data;
- tilemap_mark_tile_dirty(bg_tilemap, offset);
+ videopin_state *state = space->machine->driver_data<videopin_state>();
+ state->video_ram[offset] = data;
+ tilemap_mark_tile_dirty(state->bg_tilemap, offset);
}
diff --git a/src/mame/video/wolfpack.c b/src/mame/video/wolfpack.c
index 51a14ddb48b..d8e288bc5a8 100644
--- a/src/mame/video/wolfpack.c
+++ b/src/mame/video/wolfpack.c
@@ -7,29 +7,6 @@ Atari Wolf Pack (prototype) video emulation
#include "emu.h"
#include "includes/wolfpack.h"
-int wolfpack_collision;
-
-UINT8* wolfpack_alpha_num_ram;
-
-static unsigned current_index;
-
-static UINT8 wolfpack_video_invert;
-static UINT8 wolfpack_ship_reflect;
-static UINT8 wolfpack_pt_pos_select;
-static UINT8 wolfpack_pt_horz;
-static UINT8 wolfpack_pt_pic;
-static UINT8 wolfpack_ship_h;
-static UINT8 wolfpack_torpedo_pic;
-static UINT8 wolfpack_ship_size;
-static UINT8 wolfpack_ship_h_precess;
-static UINT8 wolfpack_ship_pic;
-static UINT8 wolfpack_torpedo_h;
-static UINT8 wolfpack_torpedo_v;
-
-static UINT8* LFSR;
-
-static bitmap_t* helper;
-
PALETTE_INIT( wolfpack )
{
@@ -70,63 +47,76 @@ PALETTE_INIT( wolfpack )
WRITE8_HANDLER( wolfpack_ship_size_w )
{
- wolfpack_ship_size = data;
+ wolfpack_state *state = space->machine->driver_data<wolfpack_state>();
+ state->ship_size = data;
}
WRITE8_HANDLER( wolfpack_video_invert_w )
{
- wolfpack_video_invert = data & 1;
+ wolfpack_state *state = space->machine->driver_data<wolfpack_state>();
+ state->video_invert = data & 1;
}
WRITE8_HANDLER( wolfpack_ship_reflect_w )
{
- wolfpack_ship_reflect = data & 1;
+ wolfpack_state *state = space->machine->driver_data<wolfpack_state>();
+ state->ship_reflect = data & 1;
}
WRITE8_HANDLER( wolfpack_pt_pos_select_w )
{
- wolfpack_pt_pos_select = data & 1;
+ wolfpack_state *state = space->machine->driver_data<wolfpack_state>();
+ state->pt_pos_select = data & 1;
}
WRITE8_HANDLER( wolfpack_pt_horz_w )
{
- wolfpack_pt_horz = data;
+ wolfpack_state *state = space->machine->driver_data<wolfpack_state>();
+ state->pt_horz = data;
}
WRITE8_HANDLER( wolfpack_pt_pic_w )
{
- wolfpack_pt_pic = data & 0x3f;
+ wolfpack_state *state = space->machine->driver_data<wolfpack_state>();
+ state->pt_pic = data & 0x3f;
}
WRITE8_HANDLER( wolfpack_ship_h_w )
{
- wolfpack_ship_h = data;
+ wolfpack_state *state = space->machine->driver_data<wolfpack_state>();
+ state->ship_h = data;
}
WRITE8_HANDLER( wolfpack_torpedo_pic_w )
{
- wolfpack_torpedo_pic = data;
+ wolfpack_state *state = space->machine->driver_data<wolfpack_state>();
+ state->torpedo_pic = data;
}
WRITE8_HANDLER( wolfpack_ship_h_precess_w )
{
- wolfpack_ship_h_precess = data & 0x3f;
+ wolfpack_state *state = space->machine->driver_data<wolfpack_state>();
+ state->ship_h_precess = data & 0x3f;
}
WRITE8_HANDLER( wolfpack_ship_pic_w )
{
- wolfpack_ship_pic = data & 0x0f;
+ wolfpack_state *state = space->machine->driver_data<wolfpack_state>();
+ state->ship_pic = data & 0x0f;
}
WRITE8_HANDLER( wolfpack_torpedo_h_w )
{
- wolfpack_torpedo_h = data;
+ wolfpack_state *state = space->machine->driver_data<wolfpack_state>();
+ state->torpedo_h = data;
}
WRITE8_HANDLER( wolfpack_torpedo_v_w )
{
- wolfpack_torpedo_v = data;
+ wolfpack_state *state = space->machine->driver_data<wolfpack_state>();
+ state->torpedo_v = data;
}
VIDEO_START( wolfpack )
{
+ wolfpack_state *state = machine->driver_data<wolfpack_state>();
UINT16 val = 0;
int i;
- LFSR = auto_alloc_array(machine, UINT8, 0x8000);
+ state->LFSR = auto_alloc_array(machine, UINT8, 0x8000);
- helper = machine->primary_screen->alloc_compatible_bitmap();
+ state->helper = machine->primary_screen->alloc_compatible_bitmap();
for (i = 0; i < 0x8000; i++)
{
@@ -134,15 +124,16 @@ VIDEO_START( wolfpack )
val = (val << 1) | (bit & 1);
- LFSR[i] = (val & 0xc00) == 0xc00;
+ state->LFSR[i] = (val & 0xc00) == 0xc00;
}
- current_index = 0x80;
+ state->current_index = 0x80;
}
static void draw_ship(running_machine *machine, bitmap_t* bitmap, const rectangle* cliprect)
{
+ wolfpack_state *state = machine->driver_data<wolfpack_state>();
static const UINT32 scaler[] =
{
0x00000, 0x00500, 0x00a00, 0x01000,
@@ -163,21 +154,22 @@ static void draw_ship(running_machine *machine, bitmap_t* bitmap, const rectangl
0x2c000, 0x2fa00, 0x33500, 0x37000
};
- int chop = (scaler[wolfpack_ship_size >> 2] * wolfpack_ship_h_precess) >> 16;
+ int chop = (scaler[state->ship_size >> 2] * state->ship_h_precess) >> 16;
drawgfxzoom_transpen(bitmap, cliprect,
machine->gfx[1],
- wolfpack_ship_pic,
+ state->ship_pic,
0,
- wolfpack_ship_reflect, 0,
- 2 * (wolfpack_ship_h - chop),
+ state->ship_reflect, 0,
+ 2 * (state->ship_h - chop),
128,
- 2 * scaler[wolfpack_ship_size >> 2], scaler[wolfpack_ship_size >> 2], 0);
+ 2 * scaler[state->ship_size >> 2], scaler[state->ship_size >> 2], 0);
}
static void draw_torpedo(running_machine *machine, bitmap_t* bitmap, const rectangle* cliprect)
{
+ wolfpack_state *state = machine->driver_data<wolfpack_state>();
int count = 0;
int x;
@@ -185,13 +177,13 @@ static void draw_torpedo(running_machine *machine, bitmap_t* bitmap, const recta
drawgfx_transpen(bitmap, cliprect,
machine->gfx[3],
- wolfpack_torpedo_pic,
+ state->torpedo_pic,
0,
0, 0,
- 2 * (244 - wolfpack_torpedo_h),
- 224 - wolfpack_torpedo_v, 0);
+ 2 * (244 - state->torpedo_h),
+ 224 - state->torpedo_v, 0);
- for (y = 16; y < 224 - wolfpack_torpedo_v; y++)
+ for (y = 16; y < 224 - state->torpedo_v; y++)
{
int x1;
int x2;
@@ -199,11 +191,11 @@ static void draw_torpedo(running_machine *machine, bitmap_t* bitmap, const recta
if (y % 16 == 1)
count = (count - 1) & 7;
- x1 = 248 - wolfpack_torpedo_h - count;
- x2 = 248 - wolfpack_torpedo_h + count;
+ x1 = 248 - state->torpedo_h - count;
+ x2 = 248 - state->torpedo_h + count;
for (x = 2 * x1; x < 2 * x2; x++)
- if (LFSR[(current_index + 0x300 * y + x) % 0x8000])
+ if (state->LFSR[(state->current_index + 0x300 * y + x) % 0x8000])
*BITMAP_ADDR16(bitmap, y, x) = 1;
}
}
@@ -211,29 +203,30 @@ static void draw_torpedo(running_machine *machine, bitmap_t* bitmap, const recta
static void draw_pt(running_machine *machine, bitmap_t* bitmap, const rectangle* cliprect)
{
+ wolfpack_state *state = machine->driver_data<wolfpack_state>();
rectangle rect = *cliprect;
- if (!(wolfpack_pt_pic & 0x20))
+ if (!(state->pt_pic & 0x20))
rect.min_x = 256;
- if (!(wolfpack_pt_pic & 0x10))
+ if (!(state->pt_pic & 0x10))
rect.max_x = 255;
drawgfx_transpen(bitmap, &rect,
machine->gfx[2],
- wolfpack_pt_pic,
+ state->pt_pic,
0,
0, 0,
- 2 * wolfpack_pt_horz,
- wolfpack_pt_pos_select ? 0x70 : 0xA0, 0);
+ 2 * state->pt_horz,
+ state->pt_pos_select ? 0x70 : 0xA0, 0);
drawgfx_transpen(bitmap, &rect,
machine->gfx[2],
- wolfpack_pt_pic,
+ state->pt_pic,
0,
0, 0,
- 2 * wolfpack_pt_horz - 512,
- wolfpack_pt_pos_select ? 0x70 : 0xA0, 0);
+ 2 * state->pt_horz - 512,
+ state->pt_pos_select ? 0x70 : 0xA0, 0);
}
@@ -259,31 +252,32 @@ static void draw_water(colortable_t *colortable, bitmap_t* bitmap, const rectang
VIDEO_UPDATE( wolfpack )
{
+ wolfpack_state *state = screen->machine->driver_data<wolfpack_state>();
int i;
int j;
UINT8 color = 0x48;
- if (wolfpack_ship_size & 0x10) color += 0x13;
- if (wolfpack_ship_size & 0x20) color += 0x22;
- if (wolfpack_ship_size & 0x40) color += 0x3a;
- if (wolfpack_ship_size & 0x80) color += 0x48;
+ if (state->ship_size & 0x10) color += 0x13;
+ if (state->ship_size & 0x20) color += 0x22;
+ if (state->ship_size & 0x40) color += 0x3a;
+ if (state->ship_size & 0x80) color += 0x48;
colortable_palette_set_color(screen->machine->colortable, 3, MAKE_RGB(color,color,color));
colortable_palette_set_color(screen->machine->colortable, 7, MAKE_RGB(color < 0xb8 ? color + 0x48 : 0xff,
color < 0xb8 ? color + 0x48 : 0xff,
color < 0xb8 ? color + 0x48 : 0xff));
- bitmap_fill(bitmap, cliprect, wolfpack_video_invert);
+ bitmap_fill(bitmap, cliprect, state->video_invert);
for (i = 0; i < 8; i++)
for (j = 0; j < 32; j++)
{
- int code = wolfpack_alpha_num_ram[32 * i + j];
+ int code = state->alpha_num_ram[32 * i + j];
drawgfx_opaque(bitmap, cliprect,
screen->machine->gfx[0],
code,
- wolfpack_video_invert,
+ state->video_invert,
0, 0,
16 * j,
192 + 8 * i);
@@ -299,6 +293,7 @@ VIDEO_UPDATE( wolfpack )
VIDEO_EOF( wolfpack )
{
+ wolfpack_state *state = machine->driver_data<wolfpack_state>();
rectangle rect;
int x;
@@ -306,29 +301,29 @@ VIDEO_EOF( wolfpack )
rect.min_x = 0;
rect.min_y = 0;
- rect.max_x = helper->width - 1;
- rect.max_y = helper->height - 1;
+ rect.max_x = state->helper->width - 1;
+ rect.max_y = state->helper->height - 1;
- bitmap_fill(helper, &rect, 0);
+ bitmap_fill(state->helper, &rect, 0);
- draw_ship(machine, helper, &rect);
+ draw_ship(machine, state->helper, &rect);
- for (y = 128; y < 224 - wolfpack_torpedo_v; y++)
+ for (y = 128; y < 224 - state->torpedo_v; y++)
{
- int x1 = 248 - wolfpack_torpedo_h - 1;
- int x2 = 248 - wolfpack_torpedo_h + 1;
+ int x1 = 248 - state->torpedo_h - 1;
+ int x2 = 248 - state->torpedo_h + 1;
for (x = 2 * x1; x < 2 * x2; x++)
{
- if (x < 0 || x >= helper->width)
+ if (x < 0 || x >= state->helper->width)
continue;
- if (y < 0 || y >= helper->height)
+ if (y < 0 || y >= state->helper->height)
continue;
- if (*BITMAP_ADDR16(helper, y, x))
- wolfpack_collision = 1;
+ if (*BITMAP_ADDR16(state->helper, y, x))
+ state->collision = 1;
}
}
- current_index += 0x300 * 262;
+ state->current_index += 0x300 * 262;
}