~ubuntu-branches/debian/sid/mame/sid

« back to all changes in this revision

Viewing changes to src/mame/drivers/naughtyb.c

  • Committer: Package Import Robot
  • Author(s): Jordi Mallach, Emmanuel Kasper, Jordi Mallach
  • Date: 2012-06-05 20:02:23 UTC
  • mfrom: (0.3.1) (0.1.4)
  • Revision ID: package-import@ubuntu.com-20120605200223-gnlpogjrg6oqe9md
Tags: 0.146-1
[ Emmanuel Kasper ]
* New upstream release
* Drop patch to fix man pages section and patches to link with flac 
  and jpeg system lib: all this has been pushed upstream by Cesare Falco
* Add DM-Upload-Allowed: yes field.

[ Jordi Mallach ]
* Create a "gnu" TARGETOS stanza that defines NO_AFFINITY_NP.
* Stop setting TARGETOS to "unix" in d/rules. It should be autodetected,
  and set to the appropriate value.
* mame_manpage_section.patch: Change mame's manpage section to 6 (games),
  in the TH declaration.

Show diffs side-by-side

added added

removed removed

Lines of Context:
110
110
 
111
111
#define CLOCK_XTAL 12000000
112
112
 
113
 
static READ8_HANDLER( in0_port_r )
 
113
READ8_MEMBER(naughtyb_state::in0_port_r)
114
114
{
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();
117
116
 
118
 
        if ( state->m_cocktail )
 
117
        if ( m_cocktail )
119
118
        {
120
119
                // cabinet == cocktail -AND- handling player 2
121
120
 
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
124
123
        }
125
124
 
126
125
        return in0;
127
126
}
128
127
 
129
 
static READ8_HANDLER( dsw0_port_r )
 
128
READ8_MEMBER(naughtyb_state::dsw0_port_r)
130
129
{
131
130
        // vblank replaces the cabinet dip
132
131
 
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
135
134
}
136
135
 
137
136
/* Pop Flamer
142
141
   Paul Priest: tourniquet@mameworld.net */
143
142
 
144
143
 
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 */
146
145
{
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 };
150
148
        UINT8 seedxx;
151
149
 
152
 
        seedxx = (state->m_r_index < 0x89) ? 1 : 0;
 
150
        seedxx = (m_r_index < 0x89) ? 1 : 0;
153
151
 
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;
157
155
        else
158
 
                return seed00[state->m_prot_count] | seedxx;
 
156
                return seed00[m_prot_count] | seedxx;
159
157
 
160
158
#if 0
161
 
        if ( cpu_get_pc(&space->device()) == (0x26F2 + 0x03) )
 
159
        if ( cpu_get_pc(&space.device()) == (0x26F2 + 0x03) )
162
160
        {
163
161
                popflame_prot_count = 0;
164
162
                return 0x01;
165
163
        } /* Must not carry when rotated left */
166
164
 
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 */
169
167
 
170
 
        if ( cpu_get_pc(&space->device()) == (0x270F + 0x03) )
 
168
        if ( cpu_get_pc(&space.device()) == (0x270F + 0x03) )
171
169
        {
172
170
                switch( popflame_prot_count++ )
173
171
                {
177
175
                        case 3: return 0x38; /* x011 1xxx, matches 0x07 at $2693, stored in $400D */
178
176
                }
179
177
        }
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()));
181
179
        return 0x00;
182
180
#endif
183
181
}
184
182
 
185
 
static WRITE8_HANDLER( popflame_protection_w )
 
183
WRITE8_MEMBER(naughtyb_state::popflame_protection_w)
186
184
{
187
 
        naughtyb_state *state = space->machine().driver_data<naughtyb_state>();
188
185
        /*
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
237
234
    */
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))
241
 
                state->m_r_index++;
 
235
        if(data & 1 && ((m_popflame_prot_seed & 1) == 0)) //Note: we use the write buffer index
 
236
                m_r_index = 0;
 
237
        if(data & 8 && ((m_popflame_prot_seed & 8) == 0))
 
238
                m_r_index++;
242
239
 
243
 
        state->m_popflame_prot_seed = data & 0x10;
 
240
        m_popflame_prot_seed = data & 0x10;
244
241
 
245
242
}
246
243
 
247
244
 
248
245
 
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
260
257
ADDRESS_MAP_END
261
258
 
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
273
270
ADDRESS_MAP_END
282
279
 
283
280
***************************************************************************/
284
281
 
285
 
static INPUT_CHANGED( coin_inserted )
 
282
INPUT_CHANGED_MEMBER(naughtyb_state::coin_inserted)
286
283
{
287
 
        cputag_set_input_line(field.machine(), "maincpu", INPUT_LINE_NMI, newval ? ASSERT_LINE : CLEAR_LINE);
 
284
        cputag_set_input_line(machine(), "maincpu", INPUT_LINE_NMI, newval ? ASSERT_LINE : CLEAR_LINE);
288
285
}
289
286
 
290
287
static INPUT_PORTS_START( naughtyb )
332
329
        PORT_DIPSETTING(    0x80, DEF_STR( Cocktail ) )
333
330
 
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")
338
335
INPUT_PORTS_END
339
336
 
340
337
static INPUT_PORTS_START( trvmstr )
380
377
        PORT_DIPSETTING(    0x80, DEF_STR( Cocktail ) )
381
378
 
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")
386
383
INPUT_PORTS_END
387
384
 
388
385
 
746
743
 
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) )
752
749
 
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 )
840
837
{
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));
844
 
 
845
 
        machine.device("maincpu")->memory().space(AS_PROGRAM)->install_legacy_write_handler(0xb000, 0xb0ff, FUNC(popflame_protection_w));
846
 
}
847
 
 
848
 
 
849
 
static READ8_HANDLER( trvmstr_questions_r )
850
 
{
851
 
        naughtyb_state *state = space->machine().driver_data<naughtyb_state>();
852
 
        return space->machine().region("user1")->base()[state->m_question_offset];
853
 
}
854
 
 
855
 
static WRITE8_HANDLER( trvmstr_questions_w )
856
 
{
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));
 
842
 
 
843
        machine.device("maincpu")->memory().space(AS_PROGRAM)->install_write_handler(0xb000, 0xb0ff, write8_delegate(FUNC(naughtyb_state::popflame_protection_w),state));
 
844
}
 
845
 
 
846
 
 
847
READ8_MEMBER(naughtyb_state::trvmstr_questions_r)
 
848
{
 
849
        return memregion("user1")->base()[m_question_offset];
 
850
}
 
851
 
 
852
WRITE8_MEMBER(naughtyb_state::trvmstr_questions_w)
 
853
{
858
854
        switch(offset)
859
855
        {
860
856
        case 0:
861
 
                state->m_question_offset = (state->m_question_offset & 0xffff00) | data;
 
857
                m_question_offset = (m_question_offset & 0xffff00) | data;
862
858
                break;
863
859
        case 1:
864
 
                state->m_question_offset = (state->m_question_offset & 0xff00ff) | (data << 8);
 
860
                m_question_offset = (m_question_offset & 0xff00ff) | (data << 8);
865
861
                break;
866
862
        case 2:
867
 
                state->m_question_offset = (state->m_question_offset & 0x00ffff) | (data << 16);
 
863
                m_question_offset = (m_question_offset & 0x00ffff) | (data << 16);
868
864
                break;
869
865
        }
870
866
}
872
868
static DRIVER_INIT( trvmstr )
873
869
{
874
870
        /* install questions' handlers  */
875
 
        machine.device("maincpu")->memory().space(AS_PROGRAM)->install_legacy_readwrite_handler(0xc000, 0xc002, FUNC(trvmstr_questions_r), FUNC(trvmstr_questions_w));
 
871
        naughtyb_state *state = machine.driver_data<naughtyb_state>();
 
872
        machine.device("maincpu")->memory().space(AS_PROGRAM)->install_readwrite_handler(0xc000, 0xc002, read8_delegate(FUNC(naughtyb_state::trvmstr_questions_r),state), write8_delegate(FUNC(naughtyb_state::trvmstr_questions_w),state));
876
873
}
877
874
 
878
875