summaryrefslogtreecommitdiffstatshomepage
path: root/src/mame/machine/atarifb.c
diff options
context:
space:
mode:
author Fabio Priuli <etabeta78@users.noreply.github.com>2009-11-18 23:24:43 +0000
committer Fabio Priuli <etabeta78@users.noreply.github.com>2009-11-18 23:24:43 +0000
commitdf5e77518308a9d6d215350d48a93e89e1dd027f (patch)
tree1baed09594300570077c45abc3797b2deefec77a /src/mame/machine/atarifb.c
parentb5af35345a7783eb69ea46795d363a78c0c80e06 (diff)
Added driver_data struct and save states to atarifb.c
Diffstat (limited to 'src/mame/machine/atarifb.c')
-rw-r--r--src/mame/machine/atarifb.c207
1 files changed, 102 insertions, 105 deletions
diff --git a/src/mame/machine/atarifb.c b/src/mame/machine/atarifb.c
index f6cf3205775..a073019b34e 100644
--- a/src/mame/machine/atarifb.c
+++ b/src/mame/machine/atarifb.c
@@ -9,72 +9,70 @@
#include "atarifb.h"
#include "sound/discrete.h"
-static int CTRLD;
-static int sign_x_1, sign_y_1;
-static int sign_x_2, sign_y_2;
-static int sign_x_3, sign_y_3;
-static int sign_x_4, sign_y_4;
-
WRITE8_HANDLER( atarifb_out1_w )
{
+ atarifb_state *state = (atarifb_state *)space->machine->driver_data;
const device_config *discrete = devtag_get_device(space->machine, "discrete");
- CTRLD = data;
+ state->CTRLD = data;
- discrete_sound_w(discrete, ATARIFB_WHISTLE_EN, data & 0x01); // Whistle
- discrete_sound_w(discrete, ATARIFB_HIT_EN, data & 0x02); // Hit
+ discrete_sound_w(discrete, ATARIFB_WHISTLE_EN, data & 0x01); // Whistle
+ discrete_sound_w(discrete, ATARIFB_HIT_EN, data & 0x02); // Hit
discrete_sound_w(discrete, ATARIFB_ATTRACT_EN, data & 0x10); // Attract
- discrete_sound_w(discrete, ATARIFB_NOISE_EN, data & 0x04); // Noise Enable / Kicker
+ discrete_sound_w(discrete, ATARIFB_NOISE_EN, data & 0x04); // Noise Enable / Kicker
}
WRITE8_HANDLER( atarifb4_out1_w )
{
+ atarifb_state *state = (atarifb_state *)space->machine->driver_data;
const device_config *discrete = devtag_get_device(space->machine, "discrete");
- CTRLD = data;
+ state->CTRLD = data;
- discrete_sound_w(discrete, ATARIFB_WHISTLE_EN, data & 0x01); // Whistle
- discrete_sound_w(discrete, ATARIFB_HIT_EN, data & 0x02); // Hit
+ discrete_sound_w(discrete, ATARIFB_WHISTLE_EN, data & 0x01); // Whistle
+ discrete_sound_w(discrete, ATARIFB_HIT_EN, data & 0x02); // Hit
discrete_sound_w(discrete, ATARIFB_ATTRACT_EN, data & 0x10); // Attract
- discrete_sound_w(discrete, ATARIFB_NOISE_EN, data & 0x04); // Noise Enable / Kicker
+ discrete_sound_w(discrete, ATARIFB_NOISE_EN, data & 0x04); // Noise Enable / Kicker
- coin_counter_w (1, data & 0x80);
+ coin_counter_w(1, data & 0x80);
}
WRITE8_HANDLER( abaseb_out1_w )
{
+ atarifb_state *state = (atarifb_state *)space->machine->driver_data;
const device_config *discrete = devtag_get_device(space->machine, "discrete");
- CTRLD = data;
+ state->CTRLD = data;
- discrete_sound_w(discrete, ATARIFB_WHISTLE_EN, data & 0x01); // Whistle
- discrete_sound_w(discrete, ATARIFB_HIT_EN, data & 0x02); // Hit
+ discrete_sound_w(discrete, ATARIFB_WHISTLE_EN, data & 0x01); // Whistle
+ discrete_sound_w(discrete, ATARIFB_HIT_EN, data & 0x02); // Hit
discrete_sound_w(discrete, ATARIFB_ATTRACT_EN, data & 0x10); // Attract
- discrete_sound_w(discrete, ATARIFB_NOISE_EN, data & 0x04); // Noise Enable / Kicker
+ discrete_sound_w(discrete, ATARIFB_NOISE_EN, data & 0x04); // Noise Enable / Kicker
if (data & 0x80)
{
/* Invert video */
- palette_set_color(space->machine,1,MAKE_RGB(0x00,0x00,0x00)); /* black */
- palette_set_color(space->machine,0,MAKE_RGB(0xff,0xff,0xff)); /* white */
+ palette_set_color(space->machine, 1, MAKE_RGB(0x00,0x00,0x00)); /* black */
+ palette_set_color(space->machine, 0, MAKE_RGB(0xff,0xff,0xff)); /* white */
}
else
{
/* Regular video */
- palette_set_color(space->machine,0,MAKE_RGB(0x00,0x00,0x00)); /* black */
- palette_set_color(space->machine,1,MAKE_RGB(0xff,0xff,0xff)); /* white */
+ palette_set_color(space->machine, 0, MAKE_RGB(0x00,0x00,0x00)); /* black */
+ palette_set_color(space->machine, 1, MAKE_RGB(0xff,0xff,0xff)); /* white */
}
}
WRITE8_HANDLER( soccer_out1_w )
{
+ atarifb_state *state = (atarifb_state *)space->machine->driver_data;
const device_config *discrete = devtag_get_device(space->machine, "discrete");
- CTRLD = data;
+ state->CTRLD = data;
/* bit 0 = whistle */
/* bit 1 = hit */
@@ -84,13 +82,13 @@ WRITE8_HANDLER( soccer_out1_w )
/* bit 5-6 = trackball CTRL bits */
/* bit 7 = Rule LED */
- discrete_sound_w(discrete, ATARIFB_WHISTLE_EN, data & 0x01); // Whistle
- discrete_sound_w(discrete, ATARIFB_HIT_EN, data & 0x02); // Hit
+ discrete_sound_w(discrete, ATARIFB_WHISTLE_EN, data & 0x01); // Whistle
+ discrete_sound_w(discrete, ATARIFB_HIT_EN, data & 0x02); // Hit
discrete_sound_w(discrete, ATARIFB_ATTRACT_EN, data & 0x10); // Attract
- discrete_sound_w(discrete, ATARIFB_NOISE_EN, data & 0x04); // Noise Enable / Kicker
+ discrete_sound_w(discrete, ATARIFB_NOISE_EN, data & 0x04); // Noise Enable / Kicker
-// set_led_status(0,data & 0x10); // !!!!!!!!!! Is this correct????
- set_led_status(1,data & 0x80);
+// set_led_status(0, data & 0x10); // !!!!!!!!!! Is this correct????
+ set_led_status(1, data & 0x80);
}
@@ -156,134 +154,135 @@ WRITE8_HANDLER( atarifb_out3_w )
READ8_HANDLER( atarifb_in0_r )
{
- if ((CTRLD & 0x20) == 0x00)
+ atarifb_state *state = (atarifb_state *)space->machine->driver_data;
+ if ((state->CTRLD & 0x20) == 0x00)
{
int val;
- val = (sign_y_2 >> 7) |
- (sign_x_2 >> 6) |
- (sign_y_1 >> 5) |
- (sign_x_1 >> 4) |
+ val = (state->sign_y_2 >> 7) |
+ (state->sign_x_2 >> 6) |
+ (state->sign_y_1 >> 5) |
+ (state->sign_x_1 >> 4) |
input_port_read(space->machine, "IN0");
return val;
}
else
{
- static int counter_x,counter_y;
- int new_x,new_y;
+ int new_x, new_y;
/* Read player 1 trackball */
new_x = input_port_read(space->machine, "IN3");
- if (new_x != counter_x)
+ if (new_x != state->counter_x_in0)
{
- sign_x_1 = (new_x - counter_x) & 0x80;
- counter_x = new_x;
+ state->sign_x_1 = (new_x - state->counter_x_in0) & 0x80;
+ state->counter_x_in0 = new_x;
}
new_y = input_port_read(space->machine, "IN2");
- if (new_y != counter_y)
+ if (new_y != state->counter_y_in0)
{
- sign_y_1 = (new_y - counter_y) & 0x80;
- counter_y = new_y;
+ state->sign_y_1 = (new_y - state->counter_y_in0) & 0x80;
+ state->counter_y_in0 = new_y;
}
- return (((counter_y & 0x0f) << 4) | (counter_x & 0x0f));
+ return (((state->counter_y_in0 & 0x0f) << 4) | (state->counter_x_in0 & 0x0f));
}
}
READ8_HANDLER( atarifb_in2_r )
{
- if ((CTRLD & 0x20) == 0x00)
+ atarifb_state *state = (atarifb_state *)space->machine->driver_data;
+
+ if ((state->CTRLD & 0x20) == 0x00)
{
return input_port_read(space->machine, "IN1");
}
else
{
- static int counter_x,counter_y;
- int new_x,new_y;
+ int new_x, new_y;
/* Read player 2 trackball */
new_x = input_port_read(space->machine, "IN5");
- if (new_x != counter_x)
+ if (new_x != state->counter_x_in2)
{
- sign_x_2 = (new_x - counter_x) & 0x80;
- counter_x = new_x;
+ state->sign_x_2 = (new_x - state->counter_x_in2) & 0x80;
+ state->counter_x_in2 = new_x;
}
new_y = input_port_read(space->machine, "IN4");
- if (new_y != counter_y)
+ if (new_y != state->counter_y_in2)
{
- sign_y_2 = (new_y - counter_y) & 0x80;
- counter_y = new_y;
+ state->sign_y_2 = (new_y - state->counter_y_in2) & 0x80;
+ state->counter_y_in2 = new_y;
}
- return (((counter_y & 0x0f) << 4) | (counter_x & 0x0f));
+ return (((state->counter_y_in2 & 0x0f) << 4) | (state->counter_x_in2 & 0x0f));
}
}
READ8_HANDLER( atarifb4_in0_r )
{
+ atarifb_state *state = (atarifb_state *)space->machine->driver_data;
+
/* LD1 and LD2 low, return sign bits */
- if ((CTRLD & 0x60) == 0x00)
+ if ((state->CTRLD & 0x60) == 0x00)
{
int val;
- val = (sign_x_4 >> 7) |
- (sign_y_4 >> 6) |
- (sign_x_2 >> 5) |
- (sign_y_2 >> 4) |
- (sign_x_3 >> 3) |
- (sign_y_3 >> 2) |
- (sign_x_1 >> 1) |
- (sign_y_1 >> 0);
+ val = (state->sign_x_4 >> 7) |
+ (state->sign_y_4 >> 6) |
+ (state->sign_x_2 >> 5) |
+ (state->sign_y_2 >> 4) |
+ (state->sign_x_3 >> 3) |
+ (state->sign_y_3 >> 2) |
+ (state->sign_x_1 >> 1) |
+ (state->sign_y_1 >> 0);
return val;
}
- else if ((CTRLD & 0x60) == 0x60)
+ else if ((state->CTRLD & 0x60) == 0x60)
/* LD1 and LD2 both high, return Team 1 right player (player 1) */
{
- static int counter_x,counter_y;
- int new_x,new_y;
+ int new_x, new_y;
/* Read player 1 trackball */
new_x = input_port_read(space->machine, "IN3");
- if (new_x != counter_x)
+ if (new_x != state->counter_x_in0)
{
- sign_x_1 = (new_x - counter_x) & 0x80;
- counter_x = new_x;
+ state->sign_x_1 = (new_x - state->counter_x_in0) & 0x80;
+ state->counter_x_in0 = new_x;
}
new_y = input_port_read(space->machine, "IN2");
- if (new_y != counter_y)
+ if (new_y != state->counter_y_in0)
{
- sign_y_1 = (new_y - counter_y) & 0x80;
- counter_y = new_y;
+ state->sign_y_1 = (new_y - state->counter_y_in0) & 0x80;
+ state->counter_y_in0 = new_y;
}
- return (((counter_y & 0x0f) << 4) | (counter_x & 0x0f));
+ return (((state->counter_y_in0 & 0x0f) << 4) | (state->counter_x_in0 & 0x0f));
}
- else if ((CTRLD & 0x60) == 0x40)
+ else if ((state->CTRLD & 0x60) == 0x40)
/* LD1 high, LD2 low, return Team 1 left player (player 2) */
{
- static int counter_x,counter_y;
- int new_x,new_y;
+ int new_x, new_y;
/* Read player 2 trackball */
new_x = input_port_read(space->machine, "IN5");
- if (new_x != counter_x)
+ if (new_x != state->counter_x_in0b)
{
- sign_x_2 = (new_x - counter_x) & 0x80;
- counter_x = new_x;
+ state->sign_x_2 = (new_x - state->counter_x_in0b) & 0x80;
+ state->counter_x_in0b = new_x;
}
new_y = input_port_read(space->machine, "IN4");
- if (new_y != counter_y)
+ if (new_y != state->counter_y_in0b)
{
- sign_y_2 = (new_y - counter_y) & 0x80;
- counter_y = new_y;
+ state->sign_y_2 = (new_y - state->counter_y_in0b) & 0x80;
+ state->counter_y_in0b = new_y;
}
- return (((counter_y & 0x0f) << 4) | (counter_x & 0x0f));
+ return (((state->counter_y_in0b & 0x0f) << 4) | (state->counter_x_in0b & 0x0f));
}
else return 0;
@@ -292,58 +291,56 @@ READ8_HANDLER( atarifb4_in0_r )
READ8_HANDLER( atarifb4_in2_r )
{
- if ((CTRLD & 0x40) == 0x00)
+ atarifb_state *state = (atarifb_state *)space->machine->driver_data;
+
+ if ((state->CTRLD & 0x40) == 0x00)
{
return input_port_read(space->machine, "IN1");
}
- else if ((CTRLD & 0x60) == 0x60)
+ else if ((state->CTRLD & 0x60) == 0x60)
/* LD1 and LD2 both high, return Team 2 right player (player 3) */
{
- static int counter_x,counter_y;
- int new_x,new_y;
+ int new_x, new_y;
/* Read player 3 trackball */
new_x = input_port_read(space->machine, "IN7");
- if (new_x != counter_x)
+ if (new_x != state->counter_x_in2)
{
- sign_x_3 = (new_x - counter_x) & 0x80;
- counter_x = new_x;
+ state->sign_x_3 = (new_x - state->counter_x_in2) & 0x80;
+ state->counter_x_in2 = new_x;
}
new_y = input_port_read(space->machine, "IN6");
- if (new_y != counter_y)
+ if (new_y != state->counter_y_in2)
{
- sign_y_3 = (new_y - counter_y) & 0x80;
- counter_y = new_y;
+ state->sign_y_3 = (new_y - state->counter_y_in2) & 0x80;
+ state->counter_y_in2 = new_y;
}
- return (((counter_y & 0x0f) << 4) | (counter_x & 0x0f));
+ return (((state->counter_y_in2 & 0x0f) << 4) | (state->counter_x_in2 & 0x0f));
}
- else if ((CTRLD & 0x60) == 0x40)
+ else if ((state->CTRLD & 0x60) == 0x40)
/* LD1 high, LD2 low, return Team 2 left player (player 4) */
{
- static int counter_x,counter_y;
- int new_x,new_y;
+ int new_x, new_y;
/* Read player 4 trackball */
new_x = input_port_read(space->machine, "IN9");
- if (new_x != counter_x)
+ if (new_x != state->counter_x_in2b)
{
- sign_x_4 = (new_x - counter_x) & 0x80;
- counter_x = new_x;
+ state->sign_x_4 = (new_x - state->counter_x_in2b) & 0x80;
+ state->counter_x_in2b = new_x;
}
new_y = input_port_read(space->machine, "IN8");
- if (new_y != counter_y)
+ if (new_y != state->counter_y_in2b)
{
- sign_y_4 = (new_y - counter_y) & 0x80;
- counter_y = new_y;
+ state->sign_y_4 = (new_y - state->counter_y_in2b) & 0x80;
+ state->counter_y_in2b = new_y;
}
- return (((counter_y & 0x0f) << 4) | (counter_x & 0x0f));
+ return (((state->counter_y_in2b & 0x0f) << 4) | (state->counter_x_in2b & 0x0f));
}
else return 0;
}
-
-