111
111
#define CLOCK_XTAL 12000000
113
static READ8_HANDLER( in0_port_r )
113
READ8_MEMBER(naughtyb_state::in0_port_r)
115
naughtyb_state *state = space->machine().driver_data<naughtyb_state>();
116
int in0 = input_port_read(space->machine(), "IN0");
115
int in0 = ioport("IN0")->read();
118
if ( state->m_cocktail )
120
119
// cabinet == cocktail -AND- handling player 2
122
121
in0 = ( in0 & 0x03 ) | // start buttons
123
( input_port_read(space->machine(), "IN0_COCKTAIL") & 0xFC ); // cocktail inputs
122
( ioport("IN0_COCKTAIL")->read() & 0xFC ); // cocktail inputs
129
static READ8_HANDLER( dsw0_port_r )
128
READ8_MEMBER(naughtyb_state::dsw0_port_r)
131
130
// vblank replaces the cabinet dip
133
return ( ( input_port_read(space->machine(), "DSW0") & 0x7F ) | // dsw0
134
( input_port_read(space->machine(), "FAKE") & 0x80 ) ); // vblank
132
return ( ( ioport("DSW0")->read() & 0x7F ) | // dsw0
133
( ioport("FAKE")->read() & 0x80 ) ); // vblank
142
141
Paul Priest: tourniquet@mameworld.net */
145
static READ8_HANDLER( popflame_protection_r ) /* Not used by bootleg/hack */
144
READ8_MEMBER(naughtyb_state::popflame_protection_r)/* Not used by bootleg/hack */
147
naughtyb_state *state = space->machine().driver_data<naughtyb_state>();
148
146
static const int seed00[4] = { 0x78, 0x68, 0x48, 0x38|0x80 };
149
147
static const int seed10[4] = { 0x68, 0x60, 0x68, 0x60|0x80 };
152
seedxx = (state->m_r_index < 0x89) ? 1 : 0;
150
seedxx = (m_r_index < 0x89) ? 1 : 0;
154
state->m_prot_count = (state->m_prot_count + 1) % 4;
155
if(state->m_popflame_prot_seed == 0x10)
156
return seed10[state->m_prot_count] | seedxx;
152
m_prot_count = (m_prot_count + 1) % 4;
153
if(m_popflame_prot_seed == 0x10)
154
return seed10[m_prot_count] | seedxx;
158
return seed00[state->m_prot_count] | seedxx;
156
return seed00[m_prot_count] | seedxx;
161
if ( cpu_get_pc(&space->device()) == (0x26F2 + 0x03) )
159
if ( cpu_get_pc(&space.device()) == (0x26F2 + 0x03) )
163
161
popflame_prot_count = 0;
165
163
} /* Must not carry when rotated left */
167
if ( cpu_get_pc(&space->device()) == (0x26F9 + 0x03) )
165
if ( cpu_get_pc(&space.device()) == (0x26F9 + 0x03) )
168
166
return 0x80; /* Must carry when rotated left */
170
if ( cpu_get_pc(&space->device()) == (0x270F + 0x03) )
168
if ( cpu_get_pc(&space.device()) == (0x270F + 0x03) )
172
170
switch( popflame_prot_count++ )
177
175
case 3: return 0x38; /* x011 1xxx, matches 0x07 at $2693, stored in $400D */
180
logerror("CPU #0 PC %06x: unmapped protection read\n", cpu_get_pc(&space->device()));
178
logerror("CPU #0 PC %06x: unmapped protection read\n", cpu_get_pc(&space.device()));
185
static WRITE8_HANDLER( popflame_protection_w )
183
WRITE8_MEMBER(naughtyb_state::popflame_protection_w)
187
naughtyb_state *state = space->machine().driver_data<naughtyb_state>();
189
186
Alternative protection check is executed at the end of stage 3, it seems some kind of pseudo "EEPROM" device:
190
187
2720: 21 98 B0 ld hl,$B098
235
232
---- --x- puts a bit into the write buffer
236
233
---- ---x reset write index buffer
238
if(data & 1 && ((state->m_popflame_prot_seed & 1) == 0)) //Note: we use the write buffer index
239
state->m_r_index = 0;
240
if(data & 8 && ((state->m_popflame_prot_seed & 8) == 0))
235
if(data & 1 && ((m_popflame_prot_seed & 1) == 0)) //Note: we use the write buffer index
237
if(data & 8 && ((m_popflame_prot_seed & 8) == 0))
243
state->m_popflame_prot_seed = data & 0x10;
240
m_popflame_prot_seed = data & 0x10;
249
static ADDRESS_MAP_START( naughtyb_map, AS_PROGRAM, 8 )
246
static ADDRESS_MAP_START( naughtyb_map, AS_PROGRAM, 8, naughtyb_state )
250
247
AM_RANGE(0x0000, 0x3fff) AM_ROM
251
248
AM_RANGE(0x4000, 0x7fff) AM_RAM
252
AM_RANGE(0x8000, 0x87ff) AM_RAM AM_BASE_MEMBER(naughtyb_state, m_videoram)
253
AM_RANGE(0x8800, 0x8fff) AM_RAM AM_BASE_MEMBER(naughtyb_state, m_videoram2)
249
AM_RANGE(0x8000, 0x87ff) AM_RAM AM_SHARE("videoram")
250
AM_RANGE(0x8800, 0x8fff) AM_RAM AM_SHARE("videoram2")
254
251
AM_RANGE(0x9000, 0x97ff) AM_RAM_WRITE(naughtyb_videoreg_w)
255
AM_RANGE(0x9800, 0x9fff) AM_RAM AM_BASE_MEMBER(naughtyb_state, m_scrollreg)
256
AM_RANGE(0xa000, 0xa7ff) AM_DEVWRITE("cust", pleiads_sound_control_a_w)
257
AM_RANGE(0xa800, 0xafff) AM_DEVWRITE("cust", pleiads_sound_control_b_w)
252
AM_RANGE(0x9800, 0x9fff) AM_RAM AM_SHARE("scrollreg")
253
AM_RANGE(0xa000, 0xa7ff) AM_DEVWRITE_LEGACY("cust", pleiads_sound_control_a_w)
254
AM_RANGE(0xa800, 0xafff) AM_DEVWRITE_LEGACY("cust", pleiads_sound_control_b_w)
258
255
AM_RANGE(0xb000, 0xb7ff) AM_READ(in0_port_r) // IN0
259
256
AM_RANGE(0xb800, 0xbfff) AM_READ(dsw0_port_r) // DSW0
262
static ADDRESS_MAP_START( popflame_map, AS_PROGRAM, 8 )
259
static ADDRESS_MAP_START( popflame_map, AS_PROGRAM, 8, naughtyb_state )
263
260
AM_RANGE(0x0000, 0x3fff) AM_ROM
264
261
AM_RANGE(0x4000, 0x7fff) AM_RAM
265
AM_RANGE(0x8000, 0x87ff) AM_RAM AM_BASE_MEMBER(naughtyb_state, m_videoram)
266
AM_RANGE(0x8800, 0x8fff) AM_RAM AM_BASE_MEMBER(naughtyb_state, m_videoram2)
262
AM_RANGE(0x8000, 0x87ff) AM_RAM AM_SHARE("videoram")
263
AM_RANGE(0x8800, 0x8fff) AM_RAM AM_SHARE("videoram2")
267
264
AM_RANGE(0x9000, 0x97ff) AM_RAM_WRITE(popflame_videoreg_w)
268
AM_RANGE(0x9800, 0x9fff) AM_RAM AM_BASE_MEMBER(naughtyb_state, m_scrollreg)
269
AM_RANGE(0xa000, 0xa7ff) AM_DEVWRITE("cust", pleiads_sound_control_a_w)
270
AM_RANGE(0xa800, 0xafff) AM_DEVWRITE("cust", pleiads_sound_control_b_w)
265
AM_RANGE(0x9800, 0x9fff) AM_RAM AM_SHARE("scrollreg")
266
AM_RANGE(0xa000, 0xa7ff) AM_DEVWRITE_LEGACY("cust", pleiads_sound_control_a_w)
267
AM_RANGE(0xa800, 0xafff) AM_DEVWRITE_LEGACY("cust", pleiads_sound_control_b_w)
271
268
AM_RANGE(0xb000, 0xb7ff) AM_READ(in0_port_r) // IN0
272
269
AM_RANGE(0xb800, 0xbfff) AM_READ(dsw0_port_r) // DSW0
332
329
PORT_DIPSETTING( 0x80, DEF_STR( Cocktail ) )
334
331
PORT_START( "FAKE" )
335
PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_COIN1 ) PORT_CHANGED(coin_inserted, 0)
332
PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_COIN1 ) PORT_CHANGED_MEMBER(DEVICE_SELF, naughtyb_state,coin_inserted, 0)
336
333
// when reading DSW0, bit 7 doesn't read cabinet, but vblank
337
PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_VBLANK )
334
PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_CUSTOM ) PORT_VBLANK("screen")
340
337
static INPUT_PORTS_START( trvmstr )
380
377
PORT_DIPSETTING( 0x80, DEF_STR( Cocktail ) )
382
379
PORT_START( "FAKE" )
383
PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_COIN1 ) PORT_CHANGED(coin_inserted, 0)
380
PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_COIN1 ) PORT_CHANGED_MEMBER(DEVICE_SELF, naughtyb_state,coin_inserted, 0)
384
381
// when reading DSW0, bit 7 doesn't read cabinet, but vblank
385
PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_VBLANK )
382
PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_CUSTOM ) PORT_VBLANK("screen")
747
744
ROM_START( trvmstrb )
748
745
ROM_REGION( 0x10000, "maincpu", 0 )
749
ROM_LOAD( "ic30-3.bin", 0x0000, 0x1000, CRC(d3eb4197) SHA1(5843ffc8ec82ffe9a6519180e54c82b0375cc3dc) )
750
ROM_LOAD( "ic28.bin", 0x1000, 0x1000, CRC(70322d65) SHA1(498102236390f2e15444943e0fff8a53f37db083) )
751
ROM_LOAD( "ic26.bin", 0x2000, 0x1000, CRC(31dfa9cf) SHA1(007c6ef2381ce9e707932c66a451805cec342eeb) )
746
ROM_LOAD( "ic30b.bin", 0x0000, 0x1000, CRC(d3eb4197) SHA1(5843ffc8ec82ffe9a6519180e54c82b0375cc3dc) )
747
ROM_LOAD( "ic28b.bin", 0x1000, 0x1000, CRC(70322d65) SHA1(498102236390f2e15444943e0fff8a53f37db083) )
748
ROM_LOAD( "ic26b.bin", 0x2000, 0x1000, CRC(31dfa9cf) SHA1(007c6ef2381ce9e707932c66a451805cec342eeb) )
753
750
ROM_REGION( 0x2000, "gfx1", 0 )
754
751
ROM_LOAD( "ic44.bin", 0x0000, 0x1000, CRC(dac8cff7) SHA1(21da2b2ceb4a726d03b2e49a2df75ca66b89a197) )
839
836
static DRIVER_INIT( popflame )
841
838
/* install a handler to catch protection checks */
842
machine.device("maincpu")->memory().space(AS_PROGRAM)->install_legacy_read_handler(0x9000, 0x9000, FUNC(popflame_protection_r));
843
machine.device("maincpu")->memory().space(AS_PROGRAM)->install_legacy_read_handler(0x9090, 0x9090, FUNC(popflame_protection_r));
845
machine.device("maincpu")->memory().space(AS_PROGRAM)->install_legacy_write_handler(0xb000, 0xb0ff, FUNC(popflame_protection_w));
849
static READ8_HANDLER( trvmstr_questions_r )
851
naughtyb_state *state = space->machine().driver_data<naughtyb_state>();
852
return space->machine().region("user1")->base()[state->m_question_offset];
855
static WRITE8_HANDLER( trvmstr_questions_w )
857
naughtyb_state *state = space->machine().driver_data<naughtyb_state>();
839
naughtyb_state *state = machine.driver_data<naughtyb_state>();
840
machine.device("maincpu")->memory().space(AS_PROGRAM)->install_read_handler(0x9000, 0x9000, read8_delegate(FUNC(naughtyb_state::popflame_protection_r),state));
841
machine.device("maincpu")->memory().space(AS_PROGRAM)->install_read_handler(0x9090, 0x9090, read8_delegate(FUNC(naughtyb_state::popflame_protection_r),state));
843
machine.device("maincpu")->memory().space(AS_PROGRAM)->install_write_handler(0xb000, 0xb0ff, write8_delegate(FUNC(naughtyb_state::popflame_protection_w),state));
847
READ8_MEMBER(naughtyb_state::trvmstr_questions_r)
849
return memregion("user1")->base()[m_question_offset];
852
WRITE8_MEMBER(naughtyb_state::trvmstr_questions_w)
861
state->m_question_offset = (state->m_question_offset & 0xffff00) | data;
857
m_question_offset = (m_question_offset & 0xffff00) | data;
864
state->m_question_offset = (state->m_question_offset & 0xff00ff) | (data << 8);
860
m_question_offset = (m_question_offset & 0xff00ff) | (data << 8);
867
state->m_question_offset = (state->m_question_offset & 0x00ffff) | (data << 16);
863
m_question_offset = (m_question_offset & 0x00ffff) | (data << 16);