38
38
UINT8 m_reset_latch;
39
39
required_device<simutrek_special_device> m_laserdisc;
41
DECLARE_WRITE16_MEMBER(palette_w);
42
DECLARE_READ16_MEMBER(line_r);
43
DECLARE_WRITE16_MEMBER(laserdisc_w);
44
DECLARE_READ16_MEMBER(laserdisc_r);
45
DECLARE_WRITE16_MEMBER(ldaud_w);
46
DECLARE_WRITE16_MEMBER(control_w);
47
DECLARE_WRITE16_MEMBER(reset_w);
48
DECLARE_WRITE16_MEMBER(io_w);
49
DECLARE_READ16_MEMBER(io_r);
50
DECLARE_READ16_MEMBER(chop_r);
51
DECLARE_READ16_MEMBER(read_rotram);
52
DECLARE_WRITE16_MEMBER(write_rotram);
53
DECLARE_READ16_MEMBER(read_sndram);
54
DECLARE_WRITE16_MEMBER(write_sndram);
90
static WRITE16_HANDLER( palette_w )
104
WRITE16_MEMBER(cubeqst_state::palette_w)
92
space->machine().primary_screen->update_now();
93
COMBINE_DATA(&space->machine().generic.paletteram.u16[offset]);
106
machine().primary_screen->update_now();
107
COMBINE_DATA(&m_generic_paletteram_16[offset]);
96
110
/* TODO: This is a simplified version of what actually happens */
156
170
/* Draw the span, testing for depth */
157
pen = state->m_colormap[screen.machine().generic.paletteram.u16[color]];
171
pen = state->m_colormap[state->m_generic_paletteram_16[color]];
158
172
for (x = h1; x <= h2; ++x)
160
174
if (!(state->m_depth_buffer[x] < depth))
173
static READ16_HANDLER( line_r )
187
READ16_MEMBER(cubeqst_state::line_r)
175
189
/* I think this is unusued */
176
return space->machine().primary_screen->vpos();
190
return machine().primary_screen->vpos();
179
193
static INTERRUPT_GEN( vblank )
195
209
*************************************/
197
static WRITE16_HANDLER( laserdisc_w )
211
WRITE16_MEMBER(cubeqst_state::laserdisc_w)
199
cubeqst_state *state = space->machine().driver_data<cubeqst_state>();
200
state->m_laserdisc->data_w(data & 0xff);
213
m_laserdisc->data_w(data & 0xff);
204
217
D0: Command acknowledge
205
218
D1: Seek status (0 = searching, 1 = ready)
207
static READ16_HANDLER( laserdisc_r )
220
READ16_MEMBER(cubeqst_state::laserdisc_r)
209
cubeqst_state *state = space->machine().driver_data<cubeqst_state>();
210
int ldp_command_flag = (state->m_laserdisc->ready_r() == ASSERT_LINE) ? 0 : 1;
211
int ldp_seek_status = (state->m_laserdisc->status_r() == ASSERT_LINE) ? 1 : 0;
222
int ldp_command_flag = (m_laserdisc->ready_r() == ASSERT_LINE) ? 0 : 1;
223
int ldp_seek_status = (m_laserdisc->status_r() == ASSERT_LINE) ? 1 : 0;
213
225
return (ldp_seek_status << 1) | ldp_command_flag;
217
229
/* LDP audio squelch control */
218
static WRITE16_HANDLER( ldaud_w )
230
WRITE16_MEMBER(cubeqst_state::ldaud_w)
220
cubeqst_state *state = space->machine().driver_data<cubeqst_state>();
221
state->m_laserdisc->set_external_audio_squelch(data & 1 ? ASSERT_LINE : CLEAR_LINE);
232
m_laserdisc->set_external_audio_squelch(data & 1 ? ASSERT_LINE : CLEAR_LINE);
232
243
Note: Can only be written during VBLANK (as with palette RAM)
234
static WRITE16_HANDLER( control_w )
245
WRITE16_MEMBER(cubeqst_state::control_w)
236
cubeqst_state *state = space->machine().driver_data<cubeqst_state>();
237
state->m_laserdisc->video_enable(data & 1);
247
m_laserdisc->video_enable(data & 1);
271
static WRITE16_HANDLER( reset_w )
281
WRITE16_MEMBER(cubeqst_state::reset_w)
273
cubeqst_state *state = space->machine().driver_data<cubeqst_state>();
274
cputag_set_input_line(space->machine(), "rotate_cpu", INPUT_LINE_RESET, data & 1 ? CLEAR_LINE : ASSERT_LINE);
275
cputag_set_input_line(space->machine(), "line_cpu", INPUT_LINE_RESET, data & 1 ? CLEAR_LINE : ASSERT_LINE);
276
cputag_set_input_line(space->machine(), "sound_cpu", INPUT_LINE_RESET, data & 2 ? CLEAR_LINE : ASSERT_LINE);
283
cputag_set_input_line(machine(), "rotate_cpu", INPUT_LINE_RESET, data & 1 ? CLEAR_LINE : ASSERT_LINE);
284
cputag_set_input_line(machine(), "line_cpu", INPUT_LINE_RESET, data & 1 ? CLEAR_LINE : ASSERT_LINE);
285
cputag_set_input_line(machine(), "sound_cpu", INPUT_LINE_RESET, data & 2 ? CLEAR_LINE : ASSERT_LINE);
278
287
/* Swap stack and pointer RAM banks on rising edge of display reset */
279
if (!BIT(state->m_reset_latch, 0) && BIT(data, 0))
280
swap_linecpu_banks(space->machine());
288
if (!BIT(m_reset_latch, 0) && BIT(data, 0))
289
swap_linecpu_banks(machine());
282
291
if (!BIT(data, 2))
283
state->m_laserdisc->reset();
292
m_laserdisc->reset();
285
state->m_reset_latch = data & 0xff;
294
m_reset_latch = data & 0xff;
309
317
/* TODO: On rising edge of Q7, status LED latch is written */
310
if ( !BIT(state->m_io_latch, 7) && BIT(data, 7) )
318
if ( !BIT(m_io_latch, 7) && BIT(data, 7) )
313
321
0: Battery failure
319
state->m_io_latch = data;
322
static READ16_HANDLER( io_r )
330
READ16_MEMBER(cubeqst_state::io_r)
324
cubeqst_state *state = space->machine().driver_data<cubeqst_state>();
325
UINT16 port_data = input_port_read(space->machine(), "IO");
332
UINT16 port_data = ioport("IO")->read();
328
335
Certain bits depend on Q7 of the IO latch:
333
340
10: Spare / Trackball V data
336
if ( !BIT(state->m_io_latch, 7) )
343
if ( !BIT(m_io_latch, 7) )
337
344
return port_data;
339
346
/* Return zeroes for the trackball signals for now */
343
350
/* Trackball ('CHOP') */
344
static READ16_HANDLER( chop_r )
351
READ16_MEMBER(cubeqst_state::chop_r)
346
return (input_port_read(space->machine(), "TRACK_X") << 8) | input_port_read(space->machine(), "TRACK_Y");
353
return (ioport("TRACK_X")->read() << 8) | ioport("TRACK_Y")->read();
383
390
*************************************/
385
static READ16_HANDLER( read_rotram )
387
return cubeqcpu_rotram_r(space->machine().device("rotate_cpu"), offset, mem_mask);
390
static WRITE16_HANDLER( write_rotram )
392
cubeqcpu_rotram_w(space->machine().device("rotate_cpu"), offset, data, mem_mask);
395
static READ16_HANDLER( read_sndram )
397
return cubeqcpu_sndram_r(space->machine().device("sound_cpu"), offset, mem_mask);
400
static WRITE16_HANDLER( write_sndram )
402
cubeqcpu_sndram_w(space->machine().device("sound_cpu"), offset, data, mem_mask);
405
static ADDRESS_MAP_START( m68k_program_map, AS_PROGRAM, 16 )
392
READ16_MEMBER(cubeqst_state::read_rotram)
394
return cubeqcpu_rotram_r(machine().device("rotate_cpu"), offset, mem_mask);
397
WRITE16_MEMBER(cubeqst_state::write_rotram)
399
cubeqcpu_rotram_w(machine().device("rotate_cpu"), offset, data, mem_mask);
402
READ16_MEMBER(cubeqst_state::read_sndram)
404
return cubeqcpu_sndram_r(machine().device("sound_cpu"), offset, mem_mask);
407
WRITE16_MEMBER(cubeqst_state::write_sndram)
409
cubeqcpu_sndram_w(machine().device("sound_cpu"), offset, data, mem_mask);
412
static ADDRESS_MAP_START( m68k_program_map, AS_PROGRAM, 16, cubeqst_state )
406
413
ADDRESS_MAP_GLOBAL_MASK(0x03ffff)
407
414
AM_RANGE(0x000000, 0x01ffff) AM_ROM
408
415
AM_RANGE(0x020000, 0x027fff) AM_READWRITE(read_rotram, write_rotram)
411
418
AM_RANGE(0x038002, 0x038003) AM_READWRITE(chop_r, ldaud_w)
412
419
AM_RANGE(0x038008, 0x038009) AM_READWRITE(line_r, reset_w)
413
420
AM_RANGE(0x03800e, 0x03800f) AM_READWRITE(laserdisc_r, laserdisc_w)
414
AM_RANGE(0x03c800, 0x03c9ff) AM_RAM_WRITE(palette_w) AM_BASE_GENERIC(paletteram)
421
AM_RANGE(0x03c800, 0x03c9ff) AM_RAM_WRITE(palette_w) AM_SHARE("paletteram")
415
422
AM_RANGE(0x03cc00, 0x03cc01) AM_WRITE(control_w)
416
423
AM_RANGE(0x03e000, 0x03efff) AM_RAM AM_SHARE("nvram")
417
424
AM_RANGE(0x03f000, 0x03ffff) AM_RAM
421
428
/* For the bit-sliced CPUs */
422
static ADDRESS_MAP_START( rotate_map, AS_PROGRAM, 64 )
429
static ADDRESS_MAP_START( rotate_map, AS_PROGRAM, 64, cubeqst_state )
423
430
AM_RANGE(0x000, 0x1ff) AM_ROM
426
static ADDRESS_MAP_START( line_sound_map, AS_PROGRAM, 64 )
433
static ADDRESS_MAP_START( line_sound_map, AS_PROGRAM, 64, cubeqst_state )
427
434
AM_RANGE(0x000, 0x0ff) AM_ROM
528
535
MCFG_LASERDISC_SIMUTREK_ADD("laserdisc")
529
536
MCFG_LASERDISC_OVERLAY_STATIC(CUBEQST_HBLANK, CUBEQST_VCOUNT, cubeqst)
530
537
MCFG_LASERDISC_OVERLAY_CLIP(0, 320-1, 0, 256-8)
531
MCFG_LASERDISC_OVERLAY_POSITION(0.002, -0.018)
532
MCFG_LASERDISC_OVERLAY_SCALE(1.0, 1.030)
538
MCFG_LASERDISC_OVERLAY_POSITION(0.002f, -0.018f)
539
MCFG_LASERDISC_OVERLAY_SCALE(1.0f, 1.030f)
534
541
MCFG_LASERDISC_SCREEN_ADD_NTSC("screen", "laserdisc")