82
82
statriv2_state(const machine_config &mconfig, device_type type, const char *tag)
83
: driver_device(mconfig, type, tag) { }
83
: driver_device(mconfig, type, tag) ,
84
m_videoram(*this, "videoram"),
85
m_question_offset(*this, "question_offset"){ }
87
required_shared_ptr<UINT8> m_videoram;
86
88
tilemap_t *m_tilemap;
87
UINT8 *m_question_offset;
89
required_shared_ptr<UINT8> m_question_offset;
88
90
UINT8 m_question_offset_low;
89
91
UINT8 m_question_offset_mid;
90
92
UINT8 m_question_offset_high;
91
93
UINT8 m_latched_coin;
95
DECLARE_WRITE8_MEMBER(statriv2_videoram_w);
96
DECLARE_READ8_MEMBER(question_data_r);
97
DECLARE_READ8_MEMBER(laserdisc_io_r);
98
DECLARE_WRITE8_MEMBER(laserdisc_io_w);
99
DECLARE_CUSTOM_INPUT_MEMBER(latched_coin_r);
217
223
*************************************/
219
static READ8_HANDLER( question_data_r )
225
READ8_MEMBER(statriv2_state::question_data_r)
221
statriv2_state *state = space->machine().driver_data<statriv2_state>();
222
const UINT8 *qrom = space->machine().region("questions")->base();
223
UINT32 qromsize = space->machine().region("questions")->bytes();
227
const UINT8 *qrom = memregion("questions")->base();
228
UINT32 qromsize = memregion("questions")->bytes();
226
if (state->m_question_offset_high == 0xff)
227
state->m_question_offset[state->m_question_offset_low]++;
231
if (m_question_offset_high == 0xff)
232
m_question_offset[m_question_offset_low]++;
229
address = state->m_question_offset[state->m_question_offset_low];
230
address |= state->m_question_offset[state->m_question_offset_mid] << 8;
231
if (state->m_question_offset_high != 0xff)
232
address |= state->m_question_offset[state->m_question_offset_high] << 16;
234
address = m_question_offset[m_question_offset_low];
235
address |= m_question_offset[m_question_offset_mid] << 8;
236
if (m_question_offset_high != 0xff)
237
address |= m_question_offset[m_question_offset_high] << 16;
234
239
return (address < qromsize) ? qrom[address] : 0xff;
267
271
*************************************/
269
static const ppi8255_interface ppi8255_intf =
273
static I8255A_INTERFACE( ppi8255_intf )
271
/* PPI 8255 group A & B set to Mode 0.
272
Port A, B and lower 4 bits of C set as Input.
273
High 4 bits of C set as Output
275
DEVCB_INPUT_PORT("IN0"), /* Port A read */
276
DEVCB_INPUT_PORT("IN1"), /* Port B read */
277
DEVCB_INPUT_PORT("IN2"), /* Port C read (Lower Nibble as Input) */
278
DEVCB_NULL, /* Port A write */
279
DEVCB_NULL, /* Port B write */
280
DEVCB_HANDLER(ppi_portc_hi_w) /* Port C write (High nibble as Output) */
275
/* PPI 8255 group A & B set to Mode 0.
276
Port A, B and lower 4 bits of C set as Input.
277
High 4 bits of C set as Output */
278
DEVCB_INPUT_PORT("IN0"), /* Port A read */
279
DEVCB_NULL, /* Port A write */
280
DEVCB_INPUT_PORT("IN1"), /* Port B read */
281
DEVCB_NULL, /* Port B write */
282
DEVCB_INPUT_PORT("IN2"), /* Port C read */
283
DEVCB_HANDLER(ppi_portc_hi_w) /* Port C write */
285
287
/*************************************
289
291
*************************************/
291
static ADDRESS_MAP_START( statriv2_map, AS_PROGRAM, 8 )
293
static ADDRESS_MAP_START( statriv2_map, AS_PROGRAM, 8, statriv2_state )
292
294
AM_RANGE(0x0000, 0x3fff) AM_ROM
293
295
AM_RANGE(0x4000, 0x43ff) AM_RAM
294
296
AM_RANGE(0x4800, 0x48ff) AM_RAM AM_SHARE("nvram")
295
AM_RANGE(0xc800, 0xcfff) AM_RAM_WRITE(statriv2_videoram_w) AM_BASE_MEMBER(statriv2_state, m_videoram)
297
AM_RANGE(0xc800, 0xcfff) AM_RAM_WRITE(statriv2_videoram_w) AM_SHARE("videoram")
298
static ADDRESS_MAP_START( statriv2_io_map, AS_IO, 8 )
299
AM_RANGE(0x20, 0x23) AM_DEVREADWRITE("ppi", ppi8255_r, ppi8255_w)
300
AM_RANGE(0x28, 0x2b) AM_READ(question_data_r) AM_WRITEONLY AM_BASE_MEMBER(statriv2_state, m_question_offset)
301
AM_RANGE(0xb0, 0xb1) AM_DEVWRITE("aysnd", ay8910_address_data_w)
302
AM_RANGE(0xb1, 0xb1) AM_DEVREAD("aysnd", ay8910_r)
303
AM_RANGE(0xc0, 0xcf) AM_DEVREADWRITE("tms", tms9927_r, tms9927_w)
300
static ADDRESS_MAP_START( statriv2_io_map, AS_IO, 8, statriv2_state )
301
AM_RANGE(0x20, 0x23) AM_DEVREADWRITE("ppi8255", i8255_device, read, write)
302
AM_RANGE(0x28, 0x2b) AM_READ(question_data_r) AM_WRITEONLY AM_SHARE("question_offset")
303
AM_RANGE(0xb0, 0xb1) AM_DEVWRITE_LEGACY("aysnd", ay8910_address_data_w)
304
AM_RANGE(0xb1, 0xb1) AM_DEVREAD_LEGACY("aysnd", ay8910_r)
305
AM_RANGE(0xc0, 0xcf) AM_DEVREADWRITE_LEGACY("tms", tms9927_r, tms9927_w)
306
308
#ifdef UNUSED_CODE
307
static ADDRESS_MAP_START( statusbj_io, AS_IO, 8 )
309
static ADDRESS_MAP_START( statusbj_io, AS_IO, 8, statriv2_state )
308
310
ADDRESS_MAP_GLOBAL_MASK(0xff)
309
AM_RANGE(0x20, 0x23) AM_DEVREADWRITE("ppi", ppi8255_r, ppi8255_w)
310
AM_RANGE(0xb0, 0xb1) AM_DEVWRITE("aysnd", ay8910_address_data_w)
311
AM_RANGE(0xb1, 0xb1) AM_DEVREAD("aysnd", ay8910_r)
312
AM_RANGE(0xc0, 0xcf) AM_DEVREADWRITE("tms", tms9927_r, tms9927_w)
311
AM_RANGE(0x20, 0x23) AM_DEVREADWRITE("ppi8255", i8255_device, read, write)
312
AM_RANGE(0xb0, 0xb1) AM_DEVWRITE_LEGACY("aysnd", ay8910_address_data_w)
313
AM_RANGE(0xb1, 0xb1) AM_DEVREAD_LEGACY("aysnd", ay8910_r)
314
AM_RANGE(0xc0, 0xcf) AM_DEVREADWRITE_LEGACY("tms", tms9927_r, tms9927_w)
335
337
PORT_START("IN1")
336
338
PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_UNKNOWN )
337
339
PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_UNUSED )
338
PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_SPECIAL ) PORT_CUSTOM(latched_coin_r, "COIN")
340
PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_SPECIAL ) PORT_CUSTOM_MEMBER(DEVICE_SELF, statriv2_state,latched_coin_r, "COIN")
339
341
PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_UNUSED )
340
342
PORT_DIPNAME( 0x30, 0x00, DEF_STR( Coinage ) )
341
343
PORT_DIPSETTING( 0x00, DEF_STR( 1C_1C ) )
368
370
PORT_START("IN1")
369
371
PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_NAME("Stand") PORT_CODE(KEYCODE_4)
370
372
PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_BUTTON3 ) PORT_NAME("Select Game") PORT_CODE(KEYCODE_S)
371
PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_SPECIAL ) PORT_CUSTOM(latched_coin_r, "COIN")
373
PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_SPECIAL ) PORT_CUSTOM_MEMBER(DEVICE_SELF, statriv2_state,latched_coin_r, "COIN")
372
374
PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_UNUSED )
373
375
PORT_DIPNAME( 0x10, 0x10, "DIP switch? 10" )
374
376
PORT_DIPSETTING( 0x00, DEF_STR( Off ) )
443
445
PORT_START("IN1")
444
446
PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_SERVICE1 ) PORT_NAME("Play 1000")
445
447
PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_START2 )
446
PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_SPECIAL ) PORT_CUSTOM(latched_coin_r, "COIN")
448
PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_SPECIAL ) PORT_CUSTOM_MEMBER(DEVICE_SELF, statriv2_state,latched_coin_r, "COIN")
447
449
PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_UNKNOWN )
448
450
PORT_SERVICE( 0x10, IP_ACTIVE_HIGH )
449
451
PORT_DIPNAME( 0x20, 0x20, "Show Correct Answer" )
1112
static READ8_HANDLER( laserdisc_io_r )
1114
READ8_MEMBER(statriv2_state::laserdisc_io_r)
1114
1116
UINT8 result = 0x00;
1115
1117
if (offset == 1)
1117
mame_printf_debug("%s:ld read ($%02X) = %02X\n", space->machine().describe_context(), 0x28 + offset, result);
1119
mame_printf_debug("%s:ld read ($%02X) = %02X\n", machine().describe_context(), 0x28 + offset, result);
1121
static WRITE8_HANDLER( laserdisc_io_w )
1123
WRITE8_MEMBER(statriv2_state::laserdisc_io_w)
1123
mame_printf_debug("%s:ld write ($%02X) = %02X\n", space->machine().describe_context(), 0x28 + offset, data);
1125
mame_printf_debug("%s:ld write ($%02X) = %02X\n", machine().describe_context(), 0x28 + offset, data);
1126
1128
static DRIVER_INIT( laserdisc )
1128
1130
address_space *iospace = machine.device("maincpu")->memory().space(AS_IO);
1129
iospace->install_legacy_readwrite_handler(0x28, 0x2b, FUNC(laserdisc_io_r), FUNC(laserdisc_io_w));
1131
statriv2_state *state = machine.driver_data<statriv2_state>();
1132
iospace->install_readwrite_handler(0x28, 0x2b, read8_delegate(FUNC(statriv2_state::laserdisc_io_r), state), write8_delegate(FUNC(statriv2_state::laserdisc_io_w), state));