105
105
static VIDEO_START( spaceint )
107
astinvad_state *state = machine->driver_data<astinvad_state>();
108
state->colorram = auto_alloc_array(machine, UINT8, state->videoram_size);
107
astinvad_state *state = machine.driver_data<astinvad_state>();
108
state->m_colorram = auto_alloc_array(machine, UINT8, state->m_videoram_size);
110
state_save_register_global(machine, state->color_latch);
111
state_save_register_global_pointer(machine, state->colorram, state->videoram_size);
110
state->save_item(NAME(state->m_color_latch));
111
state->save_pointer(NAME(state->m_colorram), state->m_videoram_size);
115
115
static WRITE8_HANDLER( color_latch_w )
117
astinvad_state *state = space->machine->driver_data<astinvad_state>();
118
state->color_latch = data & 0x0f;
117
astinvad_state *state = space->machine().driver_data<astinvad_state>();
118
state->m_color_latch = data & 0x0f;
122
122
static WRITE8_HANDLER( spaceint_videoram_w )
124
astinvad_state *state = space->machine->driver_data<astinvad_state>();
125
state->videoram[offset] = data;
126
state->colorram[offset] = state->color_latch;
124
astinvad_state *state = space->machine().driver_data<astinvad_state>();
125
state->m_videoram[offset] = data;
126
state->m_colorram[offset] = state->m_color_latch;
154
static VIDEO_UPDATE( astinvad )
154
static SCREEN_UPDATE( astinvad )
156
astinvad_state *state = screen->machine->driver_data<astinvad_state>();
157
const UINT8 *color_prom = screen->machine->region("proms")->base();
158
UINT8 yoffs = state->flip_yoffs & state->screen_flip;
156
astinvad_state *state = screen->machine().driver_data<astinvad_state>();
157
const UINT8 *color_prom = screen->machine().region("proms")->base();
158
UINT8 yoffs = state->m_flip_yoffs & state->m_screen_flip;
161
161
/* render the visible pixels */
162
162
for (y = cliprect->min_y; y <= cliprect->max_y; y++)
163
163
for (x = cliprect->min_x & ~7; x <= cliprect->max_x; x += 8)
165
UINT8 color = color_prom[((y & 0xf8) << 2) | (x >> 3)] >> (state->screen_flip ? 0 : 4);
166
UINT8 data = state->videoram[(((y ^ state->screen_flip) + yoffs) << 5) | ((x ^ state->screen_flip) >> 3)];
167
plot_byte(screen->machine, bitmap, y, x, data, state->screen_red ? 1 : color);
165
UINT8 color = color_prom[((y & 0xf8) << 2) | (x >> 3)] >> (state->m_screen_flip ? 0 : 4);
166
UINT8 data = state->m_videoram[(((y ^ state->m_screen_flip) + yoffs) << 5) | ((x ^ state->m_screen_flip) >> 3)];
167
plot_byte(screen->machine(), bitmap, y, x, data, state->m_screen_red ? 1 : color);
174
static VIDEO_UPDATE( spaceint )
174
static SCREEN_UPDATE( spaceint )
176
astinvad_state *state = screen->machine->driver_data<astinvad_state>();
177
const UINT8 *color_prom = screen->machine->region("proms")->base();
176
astinvad_state *state = screen->machine().driver_data<astinvad_state>();
177
const UINT8 *color_prom = screen->machine().region("proms")->base();
180
for (offs = 0; offs < state->videoram_size; offs++)
180
for (offs = 0; offs < state->m_videoram_size; offs++)
182
UINT8 data = state->videoram[offs];
183
UINT8 color = state->colorram[offs];
182
UINT8 data = state->m_videoram[offs];
183
UINT8 color = state->m_colorram[offs];
186
186
UINT8 x = offs >> 8 << 3;
206
206
static TIMER_CALLBACK( kamikaze_int_off )
208
astinvad_state *state = machine->driver_data<astinvad_state>();
209
cpu_set_input_line(state->maincpu, 0, CLEAR_LINE);
208
astinvad_state *state = machine.driver_data<astinvad_state>();
209
device_set_input_line(state->m_maincpu, 0, CLEAR_LINE);
213
213
static TIMER_CALLBACK( kamizake_int_gen )
215
astinvad_state *state = machine->driver_data<astinvad_state>();
215
astinvad_state *state = machine.driver_data<astinvad_state>();
216
216
/* interrupts are asserted on every state change of the 128V line */
217
cpu_set_input_line(state->maincpu, 0, ASSERT_LINE);
217
device_set_input_line(state->m_maincpu, 0, ASSERT_LINE);
219
timer_adjust_oneshot(state->int_timer, machine->primary_screen->time_until_pos(param), param);
219
state->m_int_timer->adjust(machine.primary_screen->time_until_pos(param), param);
221
221
/* an RC circuit turns the interrupt off after a short amount of time */
222
timer_set(machine, double_to_attotime(300 * 0.1e-6), NULL, 0, kamikaze_int_off);
222
machine.scheduler().timer_set(attotime::from_double(300 * 0.1e-6), FUNC(kamikaze_int_off));
226
226
static MACHINE_START( kamikaze )
228
astinvad_state *state = machine->driver_data<astinvad_state>();
230
state->maincpu = machine->device("maincpu");
231
state->ppi8255_0 = machine->device("ppi8255_0");
232
state->ppi8255_1 = machine->device("ppi8255_1");
233
state->samples = machine->device("samples");
235
state->int_timer = timer_alloc(machine, kamizake_int_gen, NULL);
236
timer_adjust_oneshot(state->int_timer, machine->primary_screen->time_until_pos(128), 128);
238
state_save_register_global(machine, state->screen_flip);
239
state_save_register_global(machine, state->screen_red);
240
state_save_register_global_array(machine, state->sound_state);
228
astinvad_state *state = machine.driver_data<astinvad_state>();
230
state->m_maincpu = machine.device("maincpu");
231
state->m_ppi8255_0 = machine.device("ppi8255_0");
232
state->m_ppi8255_1 = machine.device("ppi8255_1");
233
state->m_samples = machine.device("samples");
235
state->m_int_timer = machine.scheduler().timer_alloc(FUNC(kamizake_int_gen));
236
state->m_int_timer->adjust(machine.primary_screen->time_until_pos(128), 128);
238
state->save_item(NAME(state->m_screen_flip));
239
state->save_item(NAME(state->m_screen_red));
240
state->save_item(NAME(state->m_sound_state));
243
243
static MACHINE_RESET( kamikaze )
245
astinvad_state *state = machine->driver_data<astinvad_state>();
245
astinvad_state *state = machine.driver_data<astinvad_state>();
247
state->screen_flip = 0;
248
state->screen_red = 0;
249
state->sound_state[0] = 0;
250
state->sound_state[1] = 0;
247
state->m_screen_flip = 0;
248
state->m_screen_red = 0;
249
state->m_sound_state[0] = 0;
250
state->m_sound_state[1] = 0;
254
254
static MACHINE_START( spaceint )
256
astinvad_state *state = machine->driver_data<astinvad_state>();
258
state->maincpu = machine->device("maincpu");
259
state->samples = machine->device("samples");
261
state_save_register_global(machine, state->screen_flip);
262
state_save_register_global_array(machine, state->sound_state);
256
astinvad_state *state = machine.driver_data<astinvad_state>();
258
state->m_maincpu = machine.device("maincpu");
259
state->m_samples = machine.device("samples");
261
state->save_item(NAME(state->m_screen_flip));
262
state->save_item(NAME(state->m_sound_state));
265
265
static MACHINE_RESET( spaceint )
267
astinvad_state *state = machine->driver_data<astinvad_state>();
267
astinvad_state *state = machine.driver_data<astinvad_state>();
269
state->screen_flip = 0;
270
state->sound_state[0] = 0;
271
state->sound_state[1] = 0;
272
state->color_latch = 0;
269
state->m_screen_flip = 0;
270
state->m_sound_state[0] = 0;
271
state->m_sound_state[1] = 0;
272
state->m_color_latch = 0;
276
276
static INPUT_CHANGED( spaceint_coin_inserted )
278
astinvad_state *state = field->port->machine->driver_data<astinvad_state>();
278
astinvad_state *state = field->port->machine().driver_data<astinvad_state>();
279
279
/* coin insertion causes an NMI */
280
cpu_set_input_line(state->maincpu, INPUT_LINE_NMI, newval ? ASSERT_LINE : CLEAR_LINE);
280
device_set_input_line(state->m_maincpu, INPUT_LINE_NMI, newval ? ASSERT_LINE : CLEAR_LINE);
324
324
static WRITE8_DEVICE_HANDLER( astinvad_sound1_w )
326
astinvad_state *state = device->machine->driver_data<astinvad_state>();
327
int bits_gone_hi = data & ~state->sound_state[0];
328
state->sound_state[0] = data;
330
if (bits_gone_hi & 0x01) sample_start(state->samples, 0, SND_UFO, 1);
331
if (!(data & 0x01)) sample_stop(state->samples, 0);
332
if (bits_gone_hi & 0x02) sample_start(state->samples, 1, SND_SHOT, 0);
333
if (bits_gone_hi & 0x04) sample_start(state->samples, 2, SND_BASEHIT, 0);
334
if (bits_gone_hi & 0x08) sample_start(state->samples, 3, SND_INVADERHIT, 0);
336
sound_global_enable(device->machine, data & 0x20);
337
state->screen_red = data & 0x04;
326
astinvad_state *state = device->machine().driver_data<astinvad_state>();
327
int bits_gone_hi = data & ~state->m_sound_state[0];
328
state->m_sound_state[0] = data;
330
if (bits_gone_hi & 0x01) sample_start(state->m_samples, 0, SND_UFO, 1);
331
if (!(data & 0x01)) sample_stop(state->m_samples, 0);
332
if (bits_gone_hi & 0x02) sample_start(state->m_samples, 1, SND_SHOT, 0);
333
if (bits_gone_hi & 0x04) sample_start(state->m_samples, 2, SND_BASEHIT, 0);
334
if (bits_gone_hi & 0x08) sample_start(state->m_samples, 3, SND_INVADERHIT, 0);
336
device->machine().sound().system_enable(data & 0x20);
337
state->m_screen_red = data & 0x04;
341
341
static WRITE8_DEVICE_HANDLER( astinvad_sound2_w )
343
astinvad_state *state = device->machine->driver_data<astinvad_state>();
344
int bits_gone_hi = data & ~state->sound_state[1];
345
state->sound_state[1] = data;
347
if (bits_gone_hi & 0x01) sample_start(state->samples, 5, SND_FLEET1, 0);
348
if (bits_gone_hi & 0x02) sample_start(state->samples, 5, SND_FLEET2, 0);
349
if (bits_gone_hi & 0x04) sample_start(state->samples, 5, SND_FLEET3, 0);
350
if (bits_gone_hi & 0x08) sample_start(state->samples, 5, SND_FLEET4, 0);
351
if (bits_gone_hi & 0x10) sample_start(state->samples, 4, SND_UFOHIT, 0);
353
state->screen_flip = (input_port_read(device->machine, "CABINET") & data & 0x20) ? 0xff : 0x00;
343
astinvad_state *state = device->machine().driver_data<astinvad_state>();
344
int bits_gone_hi = data & ~state->m_sound_state[1];
345
state->m_sound_state[1] = data;
347
if (bits_gone_hi & 0x01) sample_start(state->m_samples, 5, SND_FLEET1, 0);
348
if (bits_gone_hi & 0x02) sample_start(state->m_samples, 5, SND_FLEET2, 0);
349
if (bits_gone_hi & 0x04) sample_start(state->m_samples, 5, SND_FLEET3, 0);
350
if (bits_gone_hi & 0x08) sample_start(state->m_samples, 5, SND_FLEET4, 0);
351
if (bits_gone_hi & 0x10) sample_start(state->m_samples, 4, SND_UFOHIT, 0);
353
state->m_screen_flip = (input_port_read(device->machine(), "CABINET") & data & 0x20) ? 0xff : 0x00;
357
357
static WRITE8_HANDLER( spaceint_sound1_w )
359
astinvad_state *state = space->machine->driver_data<astinvad_state>();
360
int bits_gone_hi = data & ~state->sound_state[0];
361
state->sound_state[0] = data;
363
if (bits_gone_hi & 0x01) sample_start(state->samples, 1, SND_SHOT, 0);
364
if (bits_gone_hi & 0x02) sample_start(state->samples, 2, SND_BASEHIT, 0);
365
if (bits_gone_hi & 0x04) sample_start(state->samples, 4, SND_UFOHIT, 0);
366
if (bits_gone_hi & 0x08) sample_start(state->samples, 0, SND_UFO, 1);
367
if (!(data & 0x08)) sample_stop(state->samples, 0);
369
if (bits_gone_hi & 0x10) sample_start(state->samples, 5, SND_FLEET1, 0);
370
if (bits_gone_hi & 0x20) sample_start(state->samples, 5, SND_FLEET2, 0);
371
if (bits_gone_hi & 0x40) sample_start(state->samples, 5, SND_FLEET3, 0);
372
if (bits_gone_hi & 0x80) sample_start(state->samples, 5, SND_FLEET4, 0);
359
astinvad_state *state = space->machine().driver_data<astinvad_state>();
360
int bits_gone_hi = data & ~state->m_sound_state[0];
361
state->m_sound_state[0] = data;
363
if (bits_gone_hi & 0x01) sample_start(state->m_samples, 1, SND_SHOT, 0);
364
if (bits_gone_hi & 0x02) sample_start(state->m_samples, 2, SND_BASEHIT, 0);
365
if (bits_gone_hi & 0x04) sample_start(state->m_samples, 4, SND_UFOHIT, 0);
366
if (bits_gone_hi & 0x08) sample_start(state->m_samples, 0, SND_UFO, 1);
367
if (!(data & 0x08)) sample_stop(state->m_samples, 0);
369
if (bits_gone_hi & 0x10) sample_start(state->m_samples, 5, SND_FLEET1, 0);
370
if (bits_gone_hi & 0x20) sample_start(state->m_samples, 5, SND_FLEET2, 0);
371
if (bits_gone_hi & 0x40) sample_start(state->m_samples, 5, SND_FLEET3, 0);
372
if (bits_gone_hi & 0x80) sample_start(state->m_samples, 5, SND_FLEET4, 0);
376
376
static WRITE8_HANDLER( spaceint_sound2_w )
378
astinvad_state *state = space->machine->driver_data<astinvad_state>();
379
int bits_gone_hi = data & ~state->sound_state[1];
380
state->sound_state[1] = data;
382
sound_global_enable(space->machine, data & 0x02);
384
if (bits_gone_hi & 0x04) sample_start(state->samples, 3, SND_INVADERHIT, 0);
386
state->screen_flip = (input_port_read(space->machine, "CABINET") & data & 0x80) ? 0xff : 0x00;
378
astinvad_state *state = space->machine().driver_data<astinvad_state>();
379
int bits_gone_hi = data & ~state->m_sound_state[1];
380
state->m_sound_state[1] = data;
382
space->machine().sound().system_enable(data & 0x02);
384
if (bits_gone_hi & 0x04) sample_start(state->m_samples, 3, SND_INVADERHIT, 0);
386
state->m_screen_flip = (input_port_read(space->machine(), "CABINET") & data & 0x80) ? 0xff : 0x00;
395
395
*************************************/
397
static ADDRESS_MAP_START( kamikaze_map, ADDRESS_SPACE_PROGRAM, 8 )
397
static ADDRESS_MAP_START( kamikaze_map, AS_PROGRAM, 8 )
398
398
ADDRESS_MAP_GLOBAL_MASK(0x3fff)
399
399
AM_RANGE(0x0000, 0x1bff) AM_ROM
400
400
AM_RANGE(0x1c00, 0x1fff) AM_RAM
401
AM_RANGE(0x2000, 0x3fff) AM_RAM AM_BASE_SIZE_MEMBER(astinvad_state, videoram, videoram_size)
401
AM_RANGE(0x2000, 0x3fff) AM_RAM AM_BASE_SIZE_MEMBER(astinvad_state, m_videoram, m_videoram_size)
405
static ADDRESS_MAP_START( spaceint_map, ADDRESS_SPACE_PROGRAM, 8 )
405
static ADDRESS_MAP_START( spaceint_map, AS_PROGRAM, 8 )
406
406
AM_RANGE(0x0000, 0x1fff) AM_ROM
407
407
AM_RANGE(0x2000, 0x23ff) AM_RAM
408
AM_RANGE(0x4000, 0x5fff) AM_RAM_WRITE(spaceint_videoram_w) AM_BASE_SIZE_MEMBER(astinvad_state, videoram, videoram_size)
408
AM_RANGE(0x4000, 0x5fff) AM_RAM_WRITE(spaceint_videoram_w) AM_BASE_SIZE_MEMBER(astinvad_state, m_videoram, m_videoram_size)
412
static ADDRESS_MAP_START( kamikaze_portmap, ADDRESS_SPACE_IO, 8 )
412
static ADDRESS_MAP_START( kamikaze_portmap, AS_IO, 8 )
413
413
ADDRESS_MAP_GLOBAL_MASK(0xff)
414
414
AM_RANGE(0x00, 0xff) AM_READWRITE(kamikaze_ppi_r, kamikaze_ppi_w)
418
static ADDRESS_MAP_START( spaceint_portmap, ADDRESS_SPACE_IO, 8 )
418
static ADDRESS_MAP_START( spaceint_portmap, AS_IO, 8 )
419
419
ADDRESS_MAP_GLOBAL_MASK(0xff)
420
420
AM_RANGE(0x00, 0x00) AM_READ_PORT("IN0")
421
421
AM_RANGE(0x01, 0x01) AM_READ_PORT("IN1")