17
17
#define PIXEL_CLOCK (MASTER_CLOCK / 2)
23
static int steer_FF1[4];
24
static int steer_FF2[4];
29
20
static CUSTOM_INPUT( get_lever )
22
sprint4_state *state = field->port->machine().driver_data<sprint4_state>();
31
23
int n = (FPTR) param;
33
return 4 * gear[n] > da_latch;
25
return 4 * state->m_gear[n] > state->m_da_latch;
37
29
static CUSTOM_INPUT( get_wheel )
31
sprint4_state *state = field->port->machine().driver_data<sprint4_state>();
39
32
int n = (FPTR) param;
41
return 8 * steer_FF1[n] + 8 * steer_FF2[n] > da_latch;
34
return 8 * state->m_steer_FF1[n] + 8 * state->m_steer_FF2[n] > state->m_da_latch;
45
38
static CUSTOM_INPUT( get_collision )
40
sprint4_state *state = field->port->machine().driver_data<sprint4_state>();
47
41
int n = (FPTR) param;
49
return sprint4_collision[n];
43
return state->m_collision[n];
53
47
static TIMER_CALLBACK( nmi_callback )
49
sprint4_state *state = machine.driver_data<sprint4_state>();
55
50
int scanline = param;
56
static UINT8 last_wheel[4];
58
52
/* MAME updates controls only once per frame but the game checks them on every NMI */
79
73
for (i = 0; i < 4; i++)
81
signed char delta = wheel[i] - last_wheel[i];
75
signed char delta = wheel[i] - state->m_last_wheel[i];
79
state->m_steer_FF2[i] = 0;
83
state->m_steer_FF2[i] = 1;
92
steer_FF1[i] = (wheel[i] >> 4) & 1;
94
if (lever[i] & 1) { gear[i] = 1; }
95
if (lever[i] & 2) { gear[i] = 2; }
96
if (lever[i] & 4) { gear[i] = 3; }
97
if (lever[i] & 8) { gear[i] = 4; }
99
last_wheel[i] = wheel[i];
86
state->m_steer_FF1[i] = (wheel[i] >> 4) & 1;
88
if (lever[i] & 1) { state->m_gear[i] = 1; }
89
if (lever[i] & 2) { state->m_gear[i] = 2; }
90
if (lever[i] & 4) { state->m_gear[i] = 3; }
91
if (lever[i] & 8) { state->m_gear[i] = 4; }
93
state->m_last_wheel[i] = wheel[i];
113
107
if (input_port_read(machine, "IN0") & 0x40)
114
108
cputag_set_input_line(machine, "maincpu", INPUT_LINE_NMI, PULSE_LINE);
116
timer_set(machine, machine->primary_screen->time_until_pos(scanline), NULL, scanline, nmi_callback);
110
machine.scheduler().timer_set(machine.primary_screen->time_until_pos(scanline), FUNC(nmi_callback), scanline);
120
114
static MACHINE_RESET( sprint4 )
122
timer_set(machine, machine->primary_screen->time_until_pos(32), NULL, 32, nmi_callback);
124
memset(steer_FF1, 0, sizeof steer_FF1);
125
memset(steer_FF2, 0, sizeof steer_FF2);
116
sprint4_state *state = machine.driver_data<sprint4_state>();
117
machine.scheduler().timer_set(machine.primary_screen->time_until_pos(32), FUNC(nmi_callback), 32);
119
memset(state->m_steer_FF1, 0, sizeof state->m_steer_FF1);
120
memset(state->m_steer_FF2, 0, sizeof state->m_steer_FF2);
122
state->m_gear[0] = 1;
123
state->m_gear[1] = 1;
124
state->m_gear[2] = 1;
125
state->m_gear[3] = 1;
127
state->m_da_latch = 0;
136
131
static READ8_HANDLER( sprint4_wram_r )
138
sprint4_state *state = space->machine->driver_data<sprint4_state>();
139
UINT8 *videoram = state->videoram;
133
sprint4_state *state = space->machine().driver_data<sprint4_state>();
134
UINT8 *videoram = state->m_videoram;
140
135
return videoram[0x380 + offset];
144
139
static READ8_HANDLER( sprint4_analog_r )
146
return (input_port_read(space->machine, "ANALOG") << (~offset & 7)) & 0x80;
141
return (input_port_read(space->machine(), "ANALOG") << (~offset & 7)) & 0x80;
148
143
static READ8_HANDLER( sprint4_coin_r )
150
return (input_port_read(space->machine, "COIN") << (~offset & 7)) & 0x80;
145
return (input_port_read(space->machine(), "COIN") << (~offset & 7)) & 0x80;
152
147
static READ8_HANDLER( sprint4_collision_r )
154
return (input_port_read(space->machine, "COLLISION") << (~offset & 7)) & 0x80;
149
return (input_port_read(space->machine(), "COLLISION") << (~offset & 7)) & 0x80;
158
153
static READ8_HANDLER( sprint4_options_r )
160
return (input_port_read(space->machine, "DIP") >> (2 * (offset & 3))) & 3;
155
return (input_port_read(space->machine(), "DIP") >> (2 * (offset & 3))) & 3;
164
159
static WRITE8_HANDLER( sprint4_wram_w )
166
sprint4_state *state = space->machine->driver_data<sprint4_state>();
167
UINT8 *videoram = state->videoram;
161
sprint4_state *state = space->machine().driver_data<sprint4_state>();
162
UINT8 *videoram = state->m_videoram;
168
163
videoram[0x380 + offset] = data;
172
167
static WRITE8_HANDLER( sprint4_collision_reset_w )
174
sprint4_collision[(offset >> 1) & 3] = 0;
169
sprint4_state *state = space->machine().driver_data<sprint4_state>();
170
state->m_collision[(offset >> 1) & 3] = 0;
178
174
static WRITE8_HANDLER( sprint4_da_latch_w )
180
da_latch = data & 15;
176
sprint4_state *state = space->machine().driver_data<sprint4_state>();
177
state->m_da_latch = data & 15;
184
181
static WRITE8_HANDLER( sprint4_lamp_w )
186
set_led_status(space->machine, (offset >> 1) & 3, offset & 1);
183
set_led_status(space->machine(), (offset >> 1) & 3, offset & 1);
190
187
#ifdef UNUSED_FUNCTION
191
188
static WRITE8_HANDLER( sprint4_lockout_w )
193
coin_lockout_global_w(space->machine, ~offset & 1);
190
coin_lockout_global_w(space->machine(), ~offset & 1);
236
static ADDRESS_MAP_START( sprint4_cpu_map, ADDRESS_SPACE_PROGRAM, 8 )
233
static ADDRESS_MAP_START( sprint4_cpu_map, AS_PROGRAM, 8 )
238
235
ADDRESS_MAP_GLOBAL_MASK(0x3fff)
240
237
AM_RANGE(0x0080, 0x00ff) AM_MIRROR(0x700) AM_READWRITE(sprint4_wram_r, sprint4_wram_w)
241
AM_RANGE(0x0800, 0x0bff) AM_MIRROR(0x400) AM_RAM_WRITE(sprint4_video_ram_w) AM_BASE_MEMBER(sprint4_state, videoram)
238
AM_RANGE(0x0800, 0x0bff) AM_MIRROR(0x400) AM_RAM_WRITE(sprint4_video_ram_w) AM_BASE_MEMBER(sprint4_state, m_videoram)
243
240
AM_RANGE(0x0000, 0x0007) AM_MIRROR(0x718) AM_READ(sprint4_analog_r)
244
241
AM_RANGE(0x0020, 0x0027) AM_MIRROR(0x718) AM_READ(sprint4_coin_r)
411
408
MCFG_SCREEN_ADD("screen", RASTER)
412
409
MCFG_SCREEN_FORMAT(BITMAP_FORMAT_INDEXED16)
413
410
MCFG_SCREEN_RAW_PARAMS(PIXEL_CLOCK, HTOTAL, 0, 256, VTOTAL, 0, 224)
411
MCFG_SCREEN_UPDATE(sprint4)
412
MCFG_SCREEN_EOF(sprint4)
414
414
MCFG_GFXDECODE(sprint4)
415
415
MCFG_PALETTE_LENGTH(10)
417
417
MCFG_PALETTE_INIT(sprint4)
418
418
MCFG_VIDEO_START(sprint4)
419
MCFG_VIDEO_UPDATE(sprint4)
420
MCFG_VIDEO_EOF(sprint4)
422
420
/* sound hardware */
423
421
MCFG_SPEAKER_STANDARD_STEREO("lspeaker", "rspeaker")