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

« back to all changes in this revision

Viewing changes to src/mame/drivers/snesb.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:
2
2
 
3
3
 Arcade games (hacks of console games) running on SNES harware.
4
4
 
5
 
 Driver (based on nss.c ) by Tomasz Slanina  analog[at]op.pl
 
5
 Driver (based on nss.c) by Tomasz Slanina  analog[at]op.pl
6
6
 
7
7
    Supported games:
8
8
    - Killer Instinct
9
9
    - Final Fight 2
10
 
    - Sonic Blast Man 2
11
10
    - Iron (bootleg of Iron Commando)
12
11
    - Ghost Chaser Densei
 
12
    - Sonic Blast Man 2
13
13
    - Gundam Wing: Endless Duel
14
14
 
15
15
    Not dumped:
17
17
 
18
18
TODO:
19
19
 
20
 
 - ffight2b -  dipswitches ($7eadd7 ?)
21
 
 - sblast2b -  dipswicthes
22
 
 - kiinstb -   fix gfx glitches, missing texts
23
 
 
 
20
 - all games : (re)add PORT_DIPLOCATION
 
21
 - kiinstb  : fix gfx glitches, missing texts
 
22
 - ffight2b : fix starting credits (RAM - mainly 0x7eadce where credits are stored - is filled with 0x55, so you are awarded 55 credits on a hard reset)
 
23
 - sblast2b : dipswicthes
 
24
 - denseib  :  fix gfx glitches, missing texts
 
25
 
 
26
***************************************************************************
 
27
 
 
28
  Killer Instinct PCB Info:
 
29
  --------------------------
 
30
 
 
31
    PQFP 100(?)pin chip marked "SP-BE0"
 
32
    PQFP 100(?)pin chip marked "SP-BH0"
 
33
    PQFP 100(?)pin chip marked "SP-AF0"
 
34
    Lattice pLSI 1024-60LJ B604S03
 
35
    6116 SRAM    x2
 
36
    AS7C256 SRAM x8
 
37
    jumper pack (12)
 
38
    dsw8         x2
 
39
    Xtal 24.576 MHz
 
40
    Xtal 21.47727 MHz
 
41
    volume pot
 
42
    27c801       x4
 
43
    two empty eprom sockets
 
44
 
 
45
    It's SNES version of KI with few mods (removed copyright messages,
 
46
    extra code for coin input, etc).
 
47
 
 
48
    256 bytes of RAM (mapped to reserved area) are shared with some
 
49
    device (probably Lattice PLD) used for handle coin inputs and dips
 
50
 
 
51
    Data lines of eproms are bitswapped.
 
52
 
 
53
***************************************************************************
24
54
 
25
55
  Final Fight 2 PCB layout:
26
56
  ------------------------
55
85
 |               |---|              JAMMA                 |---|               |
56
86
 |---------------|   |------------------------------------|   |---------------|
57
87
 
58
 
  Killer Instinct PCB Info:
59
 
  --------------------------
60
 
 
61
 
    PQFP 100(?)pin chip marked "SP-BE0"
62
 
    PQFP 100(?)pin chip marked "SP-BH0"
63
 
    PQFP 100(?)pin chip marked "SP-AF0"
64
 
    Lattice pLSI 1024-60LJ B604S03
65
 
    6116 SRAM    x2
66
 
    AS7C256 SRAM x8
67
 
    jumper pack (12)
68
 
    dsw8         x2
69
 
    Xtal 24.576 MHz
70
 
    Xtal 21.47727 MHz
71
 
    volume pot
72
 
    27c801       x4
73
 
    two empty eprom sockets
74
 
 
75
 
    It's SNES version of KI with few mods (removed copyright messages,
76
 
    extra code for coin input, etc).
77
 
 
78
 
    256 bytes of RAM ( mapped to reserved area) are shared with some
79
 
    device (probably Lattice PLD) used for handle coin inputs and dips
80
 
 
81
 
    Data lines of eproms are bitswapped.
82
 
 
83
88
***************************************************************************
84
89
 
85
90
Iron PCB (same as Final Fight 2?)
131
136
|                 |     || | | | | | | | | | | | | | | | | | | | | | | |     |                 |
132
137
|_________________|     |______________________________________________|     |_________________|
133
138
 
134
 
 
135
139
***************************************************************************/
136
140
 
137
141
 
151
155
                : snes_state(mconfig, type, tag) { }
152
156
 
153
157
        INT8 *m_shared_ram;
154
 
        UINT8 m_ffight2b_coins;
155
 
        INT32 m_oldinput;
156
 
        INT32 m_oldcoin;
157
158
        UINT8 m_cnt;
 
159
        DECLARE_READ8_MEMBER(sharedram_r);
 
160
        DECLARE_WRITE8_MEMBER(sharedram_w);
 
161
        DECLARE_READ8_MEMBER(sb2b_75bd37_r);
 
162
        DECLARE_READ8_MEMBER(sb2b_6a6xxx_r);
 
163
        DECLARE_READ8_MEMBER(sb2b_7xxx_r);
 
164
        DECLARE_READ8_MEMBER(snesb_dsw1_r);
 
165
        DECLARE_READ8_MEMBER(snesb_dsw2_r);
 
166
        DECLARE_READ8_MEMBER(snesb_coin_r);
158
167
};
159
168
 
160
169
 
161
 
 
162
 
static READ8_HANDLER(sharedram_r)
163
 
{
164
 
        snesb_state *state = space->machine().driver_data<snesb_state>();
165
 
        INT32 coincnt;
166
 
        INT32 input = input_port_read(space->machine(), "COIN");
167
 
 
168
 
        if(input&3)
169
 
        {
170
 
                if( ((input&1)==1)&&((state->m_oldinput&1)==0)) {state->m_shared_ram[0]++;}
171
 
 
172
 
                coincnt=state->m_shared_ram[0];
173
 
 
174
 
                if(coincnt>99){coincnt=99;}
175
 
 
176
 
                state->m_shared_ram[0xb]=(coincnt/10)+'0';
177
 
                state->m_shared_ram[0xa]=(coincnt%10)+'0';
178
 
        }
179
 
        state->m_oldinput=input;
180
 
        return state->m_shared_ram[offset];
181
 
}
182
 
 
183
 
static WRITE8_HANDLER(sharedram_w)
184
 
{
185
 
        snesb_state *state = space->machine().driver_data<snesb_state>();
186
 
        state->m_shared_ram[offset]=data;
187
 
}
188
 
 
189
 
static READ8_HANDLER(ffight2b_coin_r)
190
 
{
191
 
        snesb_state *state = space->machine().driver_data<snesb_state>();
192
 
        INT32 input = input_port_read(space->machine(), "COIN");
193
 
 
194
 
        if( ((input&1)==1)&&((state->m_oldcoin&1)==0))
195
 
        {
196
 
                INT32 coin_cnt=(state->m_ffight2b_coins&0xf)+10*(state->m_ffight2b_coins>>4);
197
 
                if(++coin_cnt>99) coin_cnt=99;
198
 
                state->m_ffight2b_coins=(coin_cnt%10)|((coin_cnt/10)<<4);
199
 
        }
200
 
        state->m_oldcoin=input;
201
 
        return state->m_ffight2b_coins;
202
 
}
203
 
 
204
 
/* Sonic blast man 2 turbo */
205
 
 
206
 
static READ8_HANDLER(sb2b_75bd37_r)
207
 
{
208
 
        snesb_state *state = space->machine().driver_data<snesb_state>();
 
170
/* Killer Instinct */
 
171
READ8_MEMBER(snesb_state::sharedram_r)
 
172
{
 
173
        return m_shared_ram[offset];
 
174
}
 
175
 
 
176
WRITE8_MEMBER(snesb_state::sharedram_w)
 
177
{
 
178
        m_shared_ram[offset]=data;
 
179
}
 
180
 
 
181
/* Sonic Blast Man 2 Special Turbo */
 
182
READ8_MEMBER(snesb_state::sb2b_75bd37_r)
 
183
{
209
184
        /* protection check */
210
 
        return ++state->m_cnt;
 
185
        return ++m_cnt;
211
186
}
212
187
 
213
 
static READ8_HANDLER(sb2b_6a6xxx_r)
 
188
READ8_MEMBER(snesb_state::sb2b_6a6xxx_r)
214
189
{
215
190
        /* protection checks */
216
191
        switch(offset)
223
198
                case 0xfb7:     return 0x47;
224
199
        }
225
200
 
226
 
        logerror("Unknown protection read read %x @ %x\n",offset, cpu_get_pc(&space->device()));
 
201
        logerror("Unknown protection read read %x @ %x\n",offset, cpu_get_pc(&space.device()));
227
202
 
228
203
        return 0;
229
204
}
230
205
 
231
 
static READ8_HANDLER(sb2b_770071_r)
232
 
{
233
 
        return input_port_read(space->machine(), "DSW");
234
 
}
235
 
 
236
 
static READ8_HANDLER(sb2b_770079_r)
237
 
{
238
 
        return input_port_read(space->machine(), "COIN");
239
 
}
240
 
 
241
 
static READ8_HANDLER(sb2b_7xxx_r)
 
206
READ8_MEMBER(snesb_state::sb2b_7xxx_r)
242
207
{
243
208
        return snes_ram[0xc07000 + offset];
244
209
}
245
210
 
246
 
/* Iron */
247
 
 
248
 
static READ8_HANDLER(iron_770071_r)
249
 
{
250
 
        return input_port_read(space->machine(), "DSW1");
251
 
}
252
 
 
253
 
static READ8_HANDLER(iron_770073_r)
254
 
{
255
 
        return input_port_read(space->machine(), "DSW2");
256
 
}
257
 
 
258
 
static READ8_HANDLER(iron_770079_r)
259
 
{
260
 
        return input_port_read(space->machine(), "COIN");
261
 
}
262
 
 
263
 
 
264
 
/* Denseib */
265
 
 
266
 
static READ8_HANDLER(denseib_770071_r)
267
 
{
268
 
        return input_port_read(space->machine(), "DSW1");
269
 
}
270
 
 
271
 
static READ8_HANDLER(denseib_770079_r)
272
 
{
273
 
        return input_port_read(space->machine(), "COIN");
274
 
}
275
 
 
276
 
 
277
 
 
278
 
static ADDRESS_MAP_START( snesb_map, AS_PROGRAM, 8)
279
 
        AM_RANGE(0x000000, 0x2fffff) AM_READWRITE(snes_r_bank1, snes_w_bank1)   /* I/O and ROM (repeats for each bank) */
280
 
        AM_RANGE(0x300000, 0x3fffff) AM_READWRITE(snes_r_bank2, snes_w_bank2)   /* I/O and ROM (repeats for each bank) */
281
 
        AM_RANGE(0x400000, 0x5fffff) AM_READ(snes_r_bank3)                                              /* ROM (and reserved in Mode 20) */
282
 
        AM_RANGE(0x600000, 0x6fffff) AM_READWRITE(snes_r_bank4, snes_w_bank4)   /* used by Mode 20 DSP-1 */
283
 
        AM_RANGE(0x700000, 0x7dffff) AM_READWRITE(snes_r_bank5, snes_w_bank5)
 
211
 
 
212
/* Generic read handlers for Dip Switches and coins inputs */
 
213
READ8_MEMBER(snesb_state::snesb_dsw1_r)
 
214
{
 
215
        return ioport("DSW1")->read();
 
216
}
 
217
 
 
218
READ8_MEMBER(snesb_state::snesb_dsw2_r)
 
219
{
 
220
        return ioport("DSW2")->read();
 
221
}
 
222
 
 
223
READ8_MEMBER(snesb_state::snesb_coin_r)
 
224
{
 
225
        return ioport("COIN")->read();
 
226
}
 
227
 
 
228
 
 
229
static ADDRESS_MAP_START( snesb_map, AS_PROGRAM, 8, snesb_state )
 
230
        AM_RANGE(0x000000, 0x2fffff) AM_READWRITE_LEGACY(snes_r_bank1, snes_w_bank1)    /* I/O and ROM (repeats for each bank) */
 
231
        AM_RANGE(0x300000, 0x3fffff) AM_READWRITE_LEGACY(snes_r_bank2, snes_w_bank2)    /* I/O and ROM (repeats for each bank) */
 
232
        AM_RANGE(0x400000, 0x5fffff) AM_READ_LEGACY(snes_r_bank3)                                               /* ROM (and reserved in Mode 20) */
 
233
        AM_RANGE(0x600000, 0x6fffff) AM_READWRITE_LEGACY(snes_r_bank4, snes_w_bank4)    /* used by Mode 20 DSP-1 */
 
234
        AM_RANGE(0x700000, 0x7dffff) AM_READWRITE_LEGACY(snes_r_bank5, snes_w_bank5)
284
235
        AM_RANGE(0x7e0000, 0x7fffff) AM_RAM                                                                             /* 8KB Low RAM, 24KB High RAM, 96KB Expanded RAM */
285
 
        AM_RANGE(0x800000, 0xbfffff) AM_READWRITE(snes_r_bank6, snes_w_bank6)   /* Mirror and ROM */
286
 
        AM_RANGE(0xc00000, 0xffffff) AM_READWRITE(snes_r_bank7, snes_w_bank7)   /* Mirror and ROM */
 
236
        AM_RANGE(0x800000, 0xbfffff) AM_READWRITE_LEGACY(snes_r_bank6, snes_w_bank6)    /* Mirror and ROM */
 
237
        AM_RANGE(0xc00000, 0xffffff) AM_READWRITE_LEGACY(snes_r_bank7, snes_w_bank7)    /* Mirror and ROM */
287
238
ADDRESS_MAP_END
288
239
 
289
240
 
297
248
        spc_ram_w(device, offset + 0x100, data);
298
249
}
299
250
 
300
 
static ADDRESS_MAP_START( spc_mem, AS_PROGRAM, 8 )
301
 
        AM_RANGE(0x0000, 0x00ef) AM_DEVREADWRITE("spc700", spc_ram_r, spc_ram_w)        /* lower 32k ram */
302
 
        AM_RANGE(0x00f0, 0x00ff) AM_DEVREADWRITE("spc700", spc_io_r, spc_io_w)          /* spc io */
303
 
        AM_RANGE(0x0100, 0xffff) AM_DEVWRITE("spc700", spc_ram_100_w)
304
 
        AM_RANGE(0x0100, 0xffbf) AM_DEVREAD("spc700", spc_ram_100_r)
305
 
        AM_RANGE(0xffc0, 0xffff) AM_DEVREAD("spc700", spc_ipl_r)
 
251
static ADDRESS_MAP_START( spc_mem, AS_PROGRAM, 8, snesb_state )
 
252
        AM_RANGE(0x0000, 0x00ef) AM_DEVREADWRITE_LEGACY("spc700", spc_ram_r, spc_ram_w) /* lower 32k ram */
 
253
        AM_RANGE(0x00f0, 0x00ff) AM_DEVREADWRITE_LEGACY("spc700", spc_io_r, spc_io_w)   /* spc io */
 
254
        AM_RANGE(0x0100, 0xffff) AM_DEVWRITE_LEGACY("spc700", spc_ram_100_w)
 
255
        AM_RANGE(0x0100, 0xffbf) AM_DEVREAD_LEGACY("spc700", spc_ram_100_r)
 
256
        AM_RANGE(0xffc0, 0xffff) AM_DEVREAD_LEGACY("spc700", spc_ipl_r)
306
257
ADDRESS_MAP_END
307
258
 
308
259
static INPUT_PORTS_START( snes_common )
400
351
INPUT_PORTS_END
401
352
 
402
353
 
 
354
/* verified from 5A22 code */
403
355
static INPUT_PORTS_START( kinstb )
404
356
        PORT_INCLUDE(snes_common)
405
357
 
406
 
        PORT_START("DSW")
 
358
        PORT_START("DSW1")
 
359
        PORT_DIPNAME( 0x0f, 0x00, DEF_STR( Difficulty ) )
 
360
        PORT_DIPSETTING(    0x00, "0 (Easiest)" )               /* "EASY" (0 star) */
 
361
        PORT_DIPSETTING(    0x01, "1" )                         /* (1 star) */
 
362
        PORT_DIPSETTING(    0x02, "2" )                         /* (2 stars) */
 
363
        PORT_DIPSETTING(    0x03, "3" )                         /* (3 stars) */
 
364
        PORT_DIPSETTING(    0x04, "4" )                         /* (4 stars) */
 
365
        PORT_DIPSETTING(    0x05, "5" )                         /* "HARD" (5 stars) */
 
366
        PORT_DIPSETTING(    0x06, "6" )                         /* undefined */
 
367
        PORT_DIPSETTING(    0x07, "7" )                         /* undefined */
 
368
        PORT_DIPSETTING(    0x08, "8" )                         /* undefined */
 
369
        PORT_DIPSETTING(    0x09, "9" )                         /* undefined */
 
370
        PORT_DIPSETTING(    0x0a, "10" )                        /* undefined */
 
371
        PORT_DIPSETTING(    0x0b, "11" )                        /* undefined */
 
372
        PORT_DIPSETTING(    0x0c, "12" )                        /* undefined */
 
373
        PORT_DIPSETTING(    0x0d, "13" )                        /* undefined */
 
374
        PORT_DIPSETTING(    0x0e, "14" )                        /* undefined */
 
375
        PORT_DIPSETTING(    0x0f, "15 (Hardest)" )              /* undefined */
 
376
        PORT_DIPUNUSED( 0x10, IP_ACTIVE_LOW )
 
377
        PORT_DIPUNUSED( 0x20, IP_ACTIVE_LOW )
 
378
        PORT_DIPUNUSED( 0x40, IP_ACTIVE_LOW )
 
379
        PORT_DIPUNUSED( 0x80, IP_ACTIVE_LOW )
 
380
 
 
381
        PORT_START("DSW2")
 
382
        PORT_DIPNAME( 0x0f, 0x01, DEF_STR( Coinage ) )
 
383
        PORT_DIPSETTING(    0x0f, "15 Coins/1 Credit" )
 
384
        PORT_DIPSETTING(    0x0e, "14 Coins/1 Credit" )
 
385
        PORT_DIPSETTING(    0x0d, "13 Coins/1 Credit" )
 
386
        PORT_DIPSETTING(    0x0c, "12 Coins/1 Credit" )
 
387
        PORT_DIPSETTING(    0x0b, "11 Coins/1 Credit" )
 
388
        PORT_DIPSETTING(    0x0a, "10 Coins/1 Credit" )
 
389
        PORT_DIPSETTING(    0x09, DEF_STR( 9C_1C ) )
 
390
        PORT_DIPSETTING(    0x08, DEF_STR( 8C_1C ) )
 
391
        PORT_DIPSETTING(    0x07, DEF_STR( 7C_1C ) )
 
392
        PORT_DIPSETTING(    0x06, DEF_STR( 6C_1C ) )
 
393
        PORT_DIPSETTING(    0x05, DEF_STR( 5C_1C ) )
 
394
        PORT_DIPSETTING(    0x04, DEF_STR( 4C_1C ) )
 
395
        PORT_DIPSETTING(    0x03, DEF_STR( 3C_1C ) )
 
396
        PORT_DIPSETTING(    0x02, DEF_STR( 2C_1C ) )
 
397
        PORT_DIPSETTING(    0x01, DEF_STR( 1C_1C ) )
 
398
        PORT_DIPSETTING(    0x00, DEF_STR( 1C_2C ) )
 
399
        PORT_DIPUNUSED( 0x10, IP_ACTIVE_LOW )
 
400
        PORT_DIPUNUSED( 0x20, IP_ACTIVE_LOW )
 
401
        PORT_DIPUNUSED( 0x40, IP_ACTIVE_LOW )
 
402
        PORT_DIPUNUSED( 0x80, IP_ACTIVE_LOW )
407
403
 
408
404
        PORT_START("COIN")
409
 
        PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_COIN1 )
410
 
        PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_COIN2 )
411
 
 
 
405
        PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_COIN1 )
 
406
        PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_COIN2 )
412
407
INPUT_PORTS_END
413
408
 
414
 
 
 
409
/* verified from 5A22 code */
415
410
static INPUT_PORTS_START( ffight2b )
416
411
        PORT_INCLUDE(snes_common)
417
412
 
418
 
        PORT_START("DSW")
419
 
        PORT_DIPNAME( 0x01, 0x01, "Player Bonus" ) PORT_DIPLOCATION("SW1:1")
420
 
        PORT_DIPSETTING(    0x01, DEF_STR( No ) )
421
 
        PORT_DIPSETTING(    0x00, DEF_STR( Yes ) )
422
 
        PORT_DIPNAME( 0x06, 0x04, "Game Level" ) PORT_DIPLOCATION("SW1:2,3")
423
 
        PORT_DIPSETTING(    0x00, DEF_STR( Hardest ) )
 
413
        PORT_START("DSW1")
 
414
        PORT_DIPNAME( 0x07, 0x07, DEF_STR( Coinage ) )
 
415
        PORT_DIPSETTING(    0x01, DEF_STR( 4C_1C ) )
 
416
        PORT_DIPSETTING(    0x02, DEF_STR( 3C_1C ) )
 
417
        PORT_DIPSETTING(    0x03, DEF_STR( 2C_1C ) )
 
418
        PORT_DIPSETTING(    0x07, DEF_STR( 1C_1C ) )
 
419
//  PORT_DIPSETTING(    0x00, DEF_STR( 1C_1C ) )            /* duplicate setting */
 
420
        PORT_DIPSETTING(    0x06, DEF_STR( 1C_2C ) )
 
421
        PORT_DIPSETTING(    0x05, DEF_STR( 1C_3C ) )
 
422
        PORT_DIPSETTING(    0x04, DEF_STR( 1C_4C ) )
 
423
        PORT_DIPNAME( 0x18, 0x08, DEF_STR( Lives ) )
 
424
        PORT_DIPSETTING(    0x18, "1" )
 
425
        PORT_DIPSETTING(    0x10, "2" )
 
426
        PORT_DIPSETTING(    0x08, "3" )
 
427
        PORT_DIPSETTING(    0x00, "4" )
 
428
        PORT_DIPNAME( 0x60, 0x60, DEF_STR( Difficulty ) )       /* "GAME LEVEL" */
 
429
        PORT_DIPSETTING(    0x60, DEF_STR( Easy ) )
 
430
        PORT_DIPSETTING(    0x40, DEF_STR( Normal ) )
 
431
        PORT_DIPSETTING(    0x20, DEF_STR( Hard ) )
 
432
        PORT_DIPSETTING(    0x00, DEF_STR( Hardest ) )          /* "EXPERT" */
 
433
        PORT_DIPNAME( 0x80, 0x80, DEF_STR( Bonus_Life ) )
 
434
        PORT_DIPSETTING(    0x00, "100k 300k 200k+" )
 
435
        PORT_DIPSETTING(    0x80, DEF_STR( None ) )
 
436
 
 
437
        PORT_START("DSW2")
 
438
        PORT_DIPUNUSED( 0x01, IP_ACTIVE_LOW )
 
439
        PORT_DIPUNUSED( 0x02, IP_ACTIVE_LOW )
 
440
        PORT_DIPUNUSED( 0x04, IP_ACTIVE_LOW )
 
441
        PORT_DIPUNUSED( 0x08, IP_ACTIVE_LOW )
 
442
        PORT_DIPUNUSED( 0x10, IP_ACTIVE_LOW )
 
443
        PORT_DIPUNUSED( 0x20, IP_ACTIVE_LOW )
 
444
        PORT_DIPUNUSED( 0x40, IP_ACTIVE_LOW )
 
445
        PORT_DIPUNUSED( 0x80, IP_ACTIVE_LOW )
 
446
 
 
447
        PORT_START("COIN")
 
448
        PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_COIN1 )
 
449
        PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_COIN2 )
 
450
INPUT_PORTS_END
 
451
 
 
452
/* verified from 5A22 code */
 
453
static INPUT_PORTS_START( iron )
 
454
        PORT_INCLUDE(snes_common)
 
455
 
 
456
        PORT_START("DSW1")
 
457
        PORT_DIPNAME( 0x07, 0x07, DEF_STR( Coinage ) )
 
458
        PORT_DIPSETTING(    0x01, DEF_STR( 4C_1C ) )
 
459
        PORT_DIPSETTING(    0x02, DEF_STR( 3C_1C ) )
 
460
        PORT_DIPSETTING(    0x03, DEF_STR( 2C_1C ) )
 
461
        PORT_DIPSETTING(    0x07, DEF_STR( 1C_1C ) )
 
462
//  PORT_DIPSETTING(    0x00, DEF_STR( 1C_1C ) )            /* duplicate setting */
 
463
        PORT_DIPSETTING(    0x06, DEF_STR( 1C_2C ) )
 
464
        PORT_DIPSETTING(    0x05, DEF_STR( 1C_3C ) )
 
465
        PORT_DIPSETTING(    0x04, DEF_STR( 1C_4C ) )
 
466
        PORT_DIPUNUSED( 0x10, IP_ACTIVE_LOW )
 
467
        PORT_DIPUNUSED( 0x20, IP_ACTIVE_LOW )
 
468
        PORT_DIPUNUSED( 0x40, IP_ACTIVE_LOW )
 
469
        PORT_DIPUNUSED( 0x80, IP_ACTIVE_LOW )
 
470
 
 
471
        PORT_START("DSW2")
 
472
        PORT_DIPNAME( 0x03, 0x03, DEF_STR( Difficulty ) )       /* "LEVEL" */
 
473
        PORT_DIPSETTING(    0x01, DEF_STR( Easy ) )
 
474
        PORT_DIPSETTING(    0x03, DEF_STR( Normal ) )           /* "MEDIUM" */
424
475
        PORT_DIPSETTING(    0x02, DEF_STR( Hard ) )
 
476
        PORT_DIPSETTING(    0x00, DEF_STR( Hard ) )             /* duplicate setting */
 
477
        PORT_DIPNAME( 0x04, 0x04, "Suffered Damages" )          /* code at 0x(8)082d0 */
425
478
        PORT_DIPSETTING(    0x04, DEF_STR( Normal ) )
426
 
        PORT_DIPSETTING(    0x06, DEF_STR( Easy ) )
427
 
        PORT_DIPNAME( 0x18, 0x08, DEF_STR( Lives ) ) PORT_DIPLOCATION("SW1:4,5")
428
 
        PORT_DIPSETTING(    0x00, "4" )
429
 
        PORT_DIPSETTING(    0x08, "3" )
430
 
        PORT_DIPSETTING(    0x10, "2" )
431
 
        PORT_DIPSETTING(    0x18, "1" )
432
 
        PORT_DIPNAME( 0xe0, 0x00, DEF_STR( Coin_A ) ) PORT_DIPLOCATION("SW1:6,7,8")
433
 
        PORT_DIPSETTING(    0x20, DEF_STR( 4C_1C ) )
434
 
        PORT_DIPSETTING(    0x40, DEF_STR( 3C_1C ) )
435
 
        PORT_DIPSETTING(    0x60, DEF_STR( 2C_1C ) )
436
 
        PORT_DIPSETTING(    0x00, DEF_STR( 1C_1C ) )
437
 
        /*  PORT_DIPSETTING(    0xe0, DEF_STR( 1C_1C ) ) */
438
 
        PORT_DIPSETTING(    0xc0, DEF_STR( 1C_2C ) )
439
 
        PORT_DIPSETTING(    0xa0, DEF_STR( 1C_3C ) )
440
 
        PORT_DIPSETTING(    0x80, DEF_STR( 1C_4C ) )
441
 
 
442
 
        PORT_START("COIN")
443
 
        PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_COIN1 )
444
 
        PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_COIN2 )
445
 
INPUT_PORTS_END
446
 
 
447
 
 
 
479
        PORT_DIPSETTING(    0x00, "More" )
 
480
        PORT_DIPNAME( 0x18, 0x18, DEF_STR( Lives ) )            /* table at 0x(8)3ffda (4 * 1 word) gives 02 03 04 05 (add 1) but extra LSRA before TAY at 0x(8)3ffcf */
 
481
        PORT_DIPSETTING(    0x18, "3" )
 
482
        PORT_DIPSETTING(    0x08, "4" )
 
483
        PORT_DIPSETTING(    0x10, "769 (Bug)" )
 
484
        PORT_DIPSETTING(    0x00, "1025 (Bug)" )
 
485
        PORT_DIPUNUSED( 0x20, IP_ACTIVE_LOW )
 
486
        PORT_DIPUNUSED( 0x40, IP_ACTIVE_LOW )
 
487
        PORT_DIPNAME( 0x80, 0x80, DEF_STR( Demo_Sounds ) )
 
488
        PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
 
489
        PORT_DIPSETTING(    0x80, DEF_STR( On ) )
 
490
 
 
491
        PORT_START("COIN")
 
492
        PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_COIN1 )
 
493
        PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_COIN2 )
 
494
INPUT_PORTS_END
 
495
 
 
496
/* verified from 5A22 code */
 
497
static INPUT_PORTS_START( denseib )
 
498
        PORT_INCLUDE(snes_common)
 
499
 
 
500
        PORT_START("DSW1")
 
501
        PORT_DIPNAME( 0x07, 0x07, DEF_STR( Coinage ) )
 
502
        PORT_DIPSETTING(    0x01, DEF_STR( 4C_1C ) )
 
503
        PORT_DIPSETTING(    0x02, DEF_STR( 3C_1C ) )
 
504
        PORT_DIPSETTING(    0x03, DEF_STR( 2C_1C ) )
 
505
        PORT_DIPSETTING(    0x07, DEF_STR( 1C_1C ) )
 
506
//  PORT_DIPSETTING(    0x00, DEF_STR( 1C_1C ) )            /* duplicate setting */
 
507
        PORT_DIPSETTING(    0x06, DEF_STR( 1C_2C ) )
 
508
        PORT_DIPSETTING(    0x05, DEF_STR( 1C_3C ) )
 
509
        PORT_DIPSETTING(    0x04, DEF_STR( 1C_4C ) )
 
510
        PORT_DIPNAME( 0x18, 0x10, DEF_STR( Difficulty ) )       /* "RANK" */
 
511
        PORT_DIPSETTING(    0x18, DEF_STR( Easy ) )
 
512
        PORT_DIPSETTING(    0x10, DEF_STR( Normal ) )
 
513
        PORT_DIPSETTING(    0x08, DEF_STR( Hard ) )
 
514
//  PORT_DIPSETTING(    0x00, DEF_STR( Hard ) )             /* duplicate setting */
 
515
        PORT_DIPUNUSED( 0x20, IP_ACTIVE_LOW )
 
516
        PORT_DIPUNUSED( 0x40, IP_ACTIVE_LOW )
 
517
        PORT_DIPNAME( 0x80, 0x00, "Mode" )
 
518
        PORT_DIPSETTING(    0x00, DEF_STR( Normal ) )
 
519
        PORT_DIPSETTING(    0x80, "Battle" )
 
520
 
 
521
        PORT_START("DSW2")
 
522
        PORT_DIPNAME( 0x07, 0x07, "Suffered Damages" )          /* code at 0x(8)0f810 */
 
523
        PORT_DIPSETTING(    0x07, DEF_STR( Normal ) )
 
524
        PORT_DIPSETTING(    0x06, "x1.5" )
 
525
        PORT_DIPSETTING(    0x05, "x2.5" )
 
526
        PORT_DIPSETTING(    0x04, "x3.5" )
 
527
        PORT_DIPSETTING(    0x03, "x4.5" )
 
528
        PORT_DIPSETTING(    0x02, "x5.5" )
 
529
        PORT_DIPSETTING(    0x01, "x6.5" )
 
530
        PORT_DIPSETTING(    0x00, "x7.5" )
 
531
        PORT_DIPUNUSED( 0x10, IP_ACTIVE_LOW )
 
532
        PORT_DIPUNUSED( 0x20, IP_ACTIVE_LOW )
 
533
        PORT_DIPUNUSED( 0x40, IP_ACTIVE_LOW )
 
534
        PORT_DIPUNUSED( 0x80, IP_ACTIVE_LOW )
 
535
 
 
536
        PORT_START("COIN")
 
537
        PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_COIN1 )
 
538
        PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_COIN2 )
 
539
INPUT_PORTS_END
 
540
 
 
541
/* verified from 5A22 code */
448
542
static INPUT_PORTS_START( sblast2b )
449
543
        PORT_INCLUDE(snes_common)
450
544
 
451
 
        PORT_START("DSW")
452
 
        PORT_DIPUNKNOWN_DIPLOC( 0x01, 0x01, "SW1:1" )
453
 
        PORT_DIPUNKNOWN_DIPLOC( 0x02, 0x02, "SW1:2" )
454
 
        PORT_DIPUNKNOWN_DIPLOC( 0x04, 0x04, "SW1:3" )
455
 
        PORT_DIPUNKNOWN_DIPLOC( 0x08, 0x08, "SW1:4" )
456
 
        PORT_DIPUNKNOWN_DIPLOC( 0x10, 0x10, "SW1:5" )
457
 
        PORT_DIPUNKNOWN_DIPLOC( 0x20, 0x20, "SW1:6" )
458
 
        PORT_DIPUNKNOWN_DIPLOC( 0x40, 0x40, "SW1:7" )
459
 
        PORT_DIPUNKNOWN_DIPLOC( 0x80, 0x80, "SW1:8" )
460
 
 
461
 
        PORT_START("COIN")
462
 
        PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_COIN1 )
463
 
        PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_COIN2 )
464
 
 
465
 
INPUT_PORTS_END
466
 
 
467
 
 
468
 
static INPUT_PORTS_START( iron )
469
 
        PORT_INCLUDE(snes_common)
470
 
 
471
 
        PORT_START("DSW1")
472
 
        PORT_DIPUNKNOWN_DIPLOC( 0x01, 0x01, "SW1:1" )
473
 
        PORT_DIPUNKNOWN_DIPLOC( 0x02, 0x02, "SW1:2" )
474
 
        PORT_DIPUNKNOWN_DIPLOC( 0x04, 0x04, "SW1:3" )
475
 
        PORT_DIPUNKNOWN_DIPLOC( 0x08, 0x08, "SW1:4" )
476
 
        PORT_DIPUNKNOWN_DIPLOC( 0x10, 0x10, "SW1:5" )
477
 
        PORT_DIPUNKNOWN_DIPLOC( 0x20, 0x20, "SW1:6" )
478
 
        PORT_DIPUNKNOWN_DIPLOC( 0x40, 0x40, "SW1:7" )
479
 
        PORT_DIPUNKNOWN_DIPLOC( 0x80, 0x80, "SW1:8" )
480
 
 
481
 
        PORT_START("DSW2")
482
 
        PORT_DIPUNKNOWN_DIPLOC( 0x01, 0x01, "SW2:1" )
483
 
        PORT_DIPUNKNOWN_DIPLOC( 0x02, 0x02, "SW2:2" )
484
 
        PORT_DIPUNKNOWN_DIPLOC( 0x04, 0x04, "SW2:3" )
485
 
        PORT_DIPUNKNOWN_DIPLOC( 0x08, 0x08, "SW2:4" )
486
 
        PORT_DIPUNKNOWN_DIPLOC( 0x10, 0x10, "SW2:5" )
487
 
        PORT_DIPUNKNOWN_DIPLOC( 0x20, 0x20, "SW2:6" )
488
 
        PORT_DIPUNKNOWN_DIPLOC( 0x40, 0x40, "SW2:7" )
489
 
        PORT_DIPUNKNOWN_DIPLOC( 0x80, 0x80, "SW2:8" )
490
 
 
491
 
        PORT_START("COIN")
492
 
        PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_COIN1 )
493
 
        PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_COIN2 )
494
 
INPUT_PORTS_END
495
 
 
496
 
static INPUT_PORTS_START( denseib )
497
 
        PORT_INCLUDE(snes_common)
498
 
 
499
 
        PORT_START("DSW1")
500
 
        PORT_DIPUNKNOWN_DIPLOC( 0x01, 0x01, "SW1:1" )
501
 
        PORT_DIPUNKNOWN_DIPLOC( 0x02, 0x02, "SW1:2" )
502
 
        PORT_DIPUNKNOWN_DIPLOC( 0x04, 0x04, "SW1:3" )
503
 
        PORT_DIPUNKNOWN_DIPLOC( 0x08, 0x08, "SW1:4" )
504
 
        PORT_DIPUNKNOWN_DIPLOC( 0x10, 0x10, "SW1:5" )
505
 
        PORT_DIPUNKNOWN_DIPLOC( 0x20, 0x20, "SW1:6" )
506
 
        PORT_DIPUNKNOWN_DIPLOC( 0x40, 0x40, "SW1:7" )
507
 
        PORT_DIPUNKNOWN_DIPLOC( 0x80, 0x80, "SW1:8" )
 
545
        PORT_START("DSW1")
 
546
        PORT_DIPNAME( 0x07, 0x07, DEF_STR( Coinage ) )
 
547
        PORT_DIPSETTING(    0x01, DEF_STR( 4C_1C ) )
 
548
        PORT_DIPSETTING(    0x02, DEF_STR( 3C_1C ) )
 
549
        PORT_DIPSETTING(    0x03, DEF_STR( 2C_1C ) )
 
550
        PORT_DIPSETTING(    0x07, DEF_STR( 1C_1C ) )
 
551
//  PORT_DIPSETTING(    0x00, DEF_STR( 1C_1C ) )            /* duplicate setting */
 
552
        PORT_DIPSETTING(    0x06, DEF_STR( 1C_2C ) )
 
553
        PORT_DIPSETTING(    0x05, DEF_STR( 1C_3C ) )
 
554
        PORT_DIPSETTING(    0x04, DEF_STR( 1C_4C ) )
 
555
        PORT_DIPNAME( 0x38, 0x38, DEF_STR( Difficulty ) )       /* "LEVEL" */
 
556
        PORT_DIPSETTING(    0x38, "0 (Easiest)" )               /* "NORMAL" */
 
557
        PORT_DIPSETTING(    0x30, "1" )                         /* "HARD" */
 
558
        PORT_DIPSETTING(    0x28, "2" )                         /* undefined */
 
559
        PORT_DIPSETTING(    0x20, "3" )                         /* undefined */
 
560
        PORT_DIPSETTING(    0x18, "4" )                         /* undefined */
 
561
        PORT_DIPSETTING(    0x10, "5" )                         /* undefined */
 
562
        PORT_DIPSETTING(    0x08, "6" )                         /* undefined */
 
563
        PORT_DIPSETTING(    0x00, "7 (Hardest)" )               /* undefined */
 
564
        PORT_DIPNAME( 0xc0, 0x40, DEF_STR( Lives ) )
 
565
        PORT_DIPSETTING(    0xc0, "1" )
 
566
        PORT_DIPSETTING(    0x80, "2" )
 
567
        PORT_DIPSETTING(    0x40, "3" )
 
568
        PORT_DIPSETTING(    0x00, "4" )
 
569
 
 
570
        PORT_START("DSW2")
 
571
        PORT_DIPNAME( 0x0f, 0x04, "Power" )
 
572
        PORT_DIPSETTING(    0x07, "0" )
 
573
        PORT_DIPSETTING(    0x06, "1" )
 
574
        PORT_DIPSETTING(    0x05, "2" )
 
575
        PORT_DIPSETTING(    0x04, "3" )
 
576
        PORT_DIPSETTING(    0x03, "4" )
 
577
        PORT_DIPSETTING(    0x02, "5" )
 
578
        PORT_DIPSETTING(    0x01, "6" )
 
579
        PORT_DIPSETTING(    0x00, "7" )
 
580
        PORT_DIPUNUSED( 0x10, IP_ACTIVE_LOW )
 
581
        PORT_DIPUNUSED( 0x20, IP_ACTIVE_LOW )
 
582
        PORT_DIPUNUSED( 0x40, IP_ACTIVE_LOW )
 
583
        PORT_DIPUNUSED( 0x80, IP_ACTIVE_LOW )
 
584
 
 
585
        PORT_START("COIN")
 
586
        PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_COIN1 )
 
587
        PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_COIN2 )
 
588
INPUT_PORTS_END
 
589
 
 
590
 
 
591
static INPUT_PORTS_START( endless )
 
592
        PORT_INCLUDE(snes_common)
 
593
 
 
594
        PORT_START("DSW1")
 
595
        PORT_DIPUNKNOWN( 0x01, IP_ACTIVE_LOW )
 
596
        PORT_DIPUNKNOWN( 0x02, IP_ACTIVE_LOW )
 
597
        PORT_DIPUNKNOWN( 0x04, IP_ACTIVE_LOW )
 
598
        PORT_DIPUNKNOWN( 0x08, IP_ACTIVE_LOW )
 
599
        PORT_DIPUNKNOWN( 0x10, IP_ACTIVE_LOW )
 
600
        PORT_DIPUNKNOWN( 0x20, IP_ACTIVE_LOW )
 
601
        PORT_DIPUNKNOWN( 0x40, IP_ACTIVE_LOW )
 
602
        PORT_DIPUNKNOWN( 0x80, IP_ACTIVE_LOW )
 
603
 
 
604
        PORT_START("DSW2")
 
605
        PORT_DIPUNKNOWN( 0x01, IP_ACTIVE_LOW )
 
606
        PORT_DIPUNKNOWN( 0x02, IP_ACTIVE_LOW )
 
607
        PORT_DIPUNKNOWN( 0x04, IP_ACTIVE_LOW )
 
608
        PORT_DIPUNKNOWN( 0x08, IP_ACTIVE_LOW )
 
609
        PORT_DIPUNKNOWN( 0x10, IP_ACTIVE_LOW )
 
610
        PORT_DIPUNKNOWN( 0x20, IP_ACTIVE_LOW )
 
611
        PORT_DIPUNKNOWN( 0x40, IP_ACTIVE_LOW )
 
612
        PORT_DIPUNKNOWN( 0x80, IP_ACTIVE_LOW )
508
613
 
509
614
        PORT_START("COIN")
510
615
        PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_COIN1 )
545
650
{
546
651
        snesb_state *state = machine.driver_data<snesb_state>();
547
652
        INT32 i;
548
 
        UINT8 *rom = machine.region("user3")->base();
 
653
        UINT8 *rom = state->memregion("user3")->base();
549
654
 
550
655
        for (i = 0; i < 0x400000; i++)
551
656
        {
553
658
        }
554
659
 
555
660
        state->m_shared_ram = auto_alloc_array(machine, INT8, 0x100);
556
 
        machine.device("maincpu")->memory().space(AS_PROGRAM)->install_legacy_readwrite_handler(0x781000, 0x7810ff, FUNC(sharedram_r), FUNC(sharedram_w));
 
661
        machine.device("maincpu")->memory().space(AS_PROGRAM)->install_readwrite_handler(0x781000, 0x7810ff, read8_delegate(FUNC(snesb_state::sharedram_r),state), write8_delegate(FUNC(snesb_state::sharedram_w),state));
 
662
 
 
663
        /* extra inputs */
 
664
        machine.device("maincpu")->memory().space(AS_PROGRAM)->install_read_handler(0x770071, 0x770071, read8_delegate(FUNC(snesb_state::snesb_dsw1_r),state));
 
665
        machine.device("maincpu")->memory().space(AS_PROGRAM)->install_read_handler(0x770073, 0x770073, read8_delegate(FUNC(snesb_state::snesb_dsw2_r),state));
 
666
        machine.device("maincpu")->memory().space(AS_PROGRAM)->install_read_handler(0x770079, 0x770079, read8_delegate(FUNC(snesb_state::snesb_coin_r),state));
557
667
 
558
668
        DRIVER_INIT_CALL(snes_hirom);
559
669
}
560
670
 
561
671
static DRIVER_INIT( ffight2b )
562
672
{
563
 
        snesb_state *state = machine.driver_data<snesb_state>();
564
673
        INT32 i;
565
 
        UINT8 *rom = machine.region("user3")->base();
 
674
        UINT8 *rom = machine.root_device().memregion("user3")->base();
566
675
 
567
676
        for(i = 0; i < 0x200000; i++)
568
677
        {
590
699
                }
591
700
        }
592
701
 
593
 
        /*  boot vector */
 
702
        /* boot vector */
594
703
        rom[0x7ffd] = 0x89;
595
704
        rom[0x7ffc] = 0x54;
596
705
 
597
 
        state->m_ffight2b_coins = 0;
598
 
        machine.device("maincpu")->memory().space(AS_PROGRAM)->install_legacy_read_handler(0x7eadce, 0x7eadce, FUNC(ffight2b_coin_r));
599
 
 
600
 
        DRIVER_INIT_CALL(snes);
601
 
}
602
 
 
 
706
        /* extra inputs */
 
707
        snesb_state *state = machine.driver_data<snesb_state>();
 
708
        machine.device("maincpu")->memory().space(AS_PROGRAM)->install_read_handler(0x770071, 0x770071, read8_delegate(FUNC(snesb_state::snesb_dsw1_r),state));
 
709
        machine.device("maincpu")->memory().space(AS_PROGRAM)->install_read_handler(0x770073, 0x770073, read8_delegate(FUNC(snesb_state::snesb_dsw2_r),state));
 
710
        machine.device("maincpu")->memory().space(AS_PROGRAM)->install_read_handler(0x770079, 0x770079, read8_delegate(FUNC(snesb_state::snesb_coin_r),state));
 
711
 
 
712
        DRIVER_INIT_CALL(snes);
 
713
}
 
714
 
 
715
static DRIVER_INIT( iron )
 
716
{
 
717
        INT32 i;
 
718
        UINT8 *rom = machine.root_device().memregion("user3")->base();
 
719
 
 
720
        for (i = 0; i < 0x140000; i++)
 
721
        {
 
722
                if(i < 0x80000)
 
723
                {
 
724
                        rom[i] = BITSWAP8(rom[i]^0xff,2,7,1,6,3,0,5,4);
 
725
                }
 
726
                else
 
727
                {
 
728
                        rom[i] = BITSWAP8(rom[i],6,3,0,5,1,4,7,2);
 
729
                }
 
730
        }
 
731
 
 
732
        /* extra inputs */
 
733
        snesb_state *state = machine.driver_data<snesb_state>();
 
734
        machine.device("maincpu")->memory().space(AS_PROGRAM)->install_read_handler(0x770071, 0x770071, read8_delegate(FUNC(snesb_state::snesb_dsw1_r),state));
 
735
        machine.device("maincpu")->memory().space(AS_PROGRAM)->install_read_handler(0x770073, 0x770073, read8_delegate(FUNC(snesb_state::snesb_dsw2_r),state));
 
736
        machine.device("maincpu")->memory().space(AS_PROGRAM)->install_read_handler(0x770079, 0x770079, read8_delegate(FUNC(snesb_state::snesb_coin_r),state));
 
737
 
 
738
        DRIVER_INIT_CALL(snes);
 
739
}
 
740
 
 
741
static DRIVER_INIT( denseib )
 
742
{
 
743
        UINT8 *rom = machine.root_device().memregion("user3")->base();
 
744
        INT32 i;
 
745
 
 
746
        for (i = 0; i < 0x200000; i++)
 
747
        {
 
748
                rom[i] = rom[i] ^ 0xff;
 
749
                switch (i >> 16)
 
750
                {
 
751
                        case 0x00: rom[i] = BITSWAP8(rom[i],1,7,0,6,3,4,5,2); break;
 
752
                        case 0x01: rom[i] = BITSWAP8(rom[i],3,4,7,2,0,6,5,1); break;
 
753
                        case 0x02: rom[i] = BITSWAP8(rom[i],5,4,2,1,7,0,6,3); break;
 
754
                        case 0x03: rom[i] = BITSWAP8(rom[i],0,1,3,7,2,6,5,4); break;
 
755
 
 
756
                        default:   rom[i] = BITSWAP8(rom[i],4,5,1,0,2,3,7,6); break;
 
757
                }
 
758
        }
 
759
 
 
760
        /* boot vector */
 
761
        rom[0xfffc] = 0x40;
 
762
        rom[0xfffd] = 0xf7;
 
763
 
 
764
        /* extra inputs */
 
765
        snesb_state *state = machine.driver_data<snesb_state>();
 
766
        machine.device("maincpu")->memory().space(AS_PROGRAM)->install_read_handler(0x770071, 0x770071, read8_delegate(FUNC(snesb_state::snesb_dsw1_r),state));
 
767
        machine.device("maincpu")->memory().space(AS_PROGRAM)->install_read_handler(0x770073, 0x770073, read8_delegate(FUNC(snesb_state::snesb_dsw2_r),state));
 
768
        machine.device("maincpu")->memory().space(AS_PROGRAM)->install_read_handler(0x770079, 0x770079, read8_delegate(FUNC(snesb_state::snesb_coin_r),state));
 
769
 
 
770
        DRIVER_INIT_CALL(snes_hirom);
 
771
}
603
772
 
604
773
static const UINT8 data_substitution0[] = {0x88,0x02,0x2a,0x08,0x28,0xaa,0x8a,0x0a,0xa2,0x00,0x80,0xa0,0x22,0xa8,0x82,0x20,};
605
774
static const UINT8 data_substitution1[] = {0x44,0x01,0x51,0x40,0x50,0x55,0x45,0x41,0x15,0x00,0x04,0x14,0x11,0x54,0x05,0x10,};
621
790
static DRIVER_INIT( sblast2b )
622
791
{
623
792
        int i, cipherText, plainText, newAddress;
624
 
        UINT8 *src = machine.region("user7")->base();
625
 
        UINT8 *dst = machine.region("user3")->base();
 
793
        UINT8 *src = machine.root_device().memregion("user7")->base();
 
794
        UINT8 *dst = machine.root_device().memregion("user3")->base();
626
795
 
627
796
        for (i =0; i < 0x80000 * 3; i++)
628
797
        {
654
823
        dst[0xfffd] = 0x7a;
655
824
 
656
825
        /*  protection checks */
657
 
        machine.device("maincpu")->memory().space(AS_PROGRAM)->install_legacy_read_handler(0x75bd37, 0x75bd37, FUNC(sb2b_75bd37_r));
658
 
        machine.device("maincpu")->memory().space(AS_PROGRAM)->install_legacy_read_handler(0x6a6000, 0x6a6fff, FUNC(sb2b_6a6xxx_r));
659
 
 
660
 
        /* extra inputs */
661
 
        machine.device("maincpu")->memory().space(AS_PROGRAM)->install_legacy_read_handler(0x770071, 0x770071, FUNC(sb2b_770071_r));
662
 
        machine.device("maincpu")->memory().space(AS_PROGRAM)->install_legacy_read_handler(0x770079, 0x770079, FUNC(sb2b_770079_r));
 
826
        snesb_state *state = machine.driver_data<snesb_state>();
 
827
        machine.device("maincpu")->memory().space(AS_PROGRAM)->install_read_handler(0x75bd37, 0x75bd37, read8_delegate(FUNC(snesb_state::sb2b_75bd37_r),state));
 
828
        machine.device("maincpu")->memory().space(AS_PROGRAM)->install_read_handler(0x6a6000, 0x6a6fff, read8_delegate(FUNC(snesb_state::sb2b_6a6xxx_r),state));
663
829
 
664
830
        /* handler to read boot code */
665
 
        machine.device("maincpu")->memory().space(AS_PROGRAM)->install_legacy_read_handler(0x007000, 0x007fff, FUNC(sb2b_7xxx_r));
 
831
        machine.device("maincpu")->memory().space(AS_PROGRAM)->install_read_handler(0x007000, 0x007fff, read8_delegate(FUNC(snesb_state::sb2b_7xxx_r),state));
 
832
 
 
833
        /* extra inputs */
 
834
        machine.device("maincpu")->memory().space(AS_PROGRAM)->install_read_handler(0x770071, 0x770071, read8_delegate(FUNC(snesb_state::snesb_dsw1_r),state));
 
835
        machine.device("maincpu")->memory().space(AS_PROGRAM)->install_read_handler(0x770073, 0x770073, read8_delegate(FUNC(snesb_state::snesb_dsw2_r),state));
 
836
        machine.device("maincpu")->memory().space(AS_PROGRAM)->install_read_handler(0x770079, 0x770079, read8_delegate(FUNC(snesb_state::snesb_coin_r),state));
666
837
 
667
838
        DRIVER_INIT_CALL(snes_hirom);
668
839
}
669
840
 
670
 
static DRIVER_INIT( iron )
671
 
{
672
 
        INT32 i;
673
 
        UINT8 *rom = machine.region("user3")->base();
674
 
 
675
 
        for (i = 0; i < 0x140000; i++)
676
 
        {
677
 
                if(i < 0x80000)
678
 
                {
679
 
                        rom[i] = BITSWAP8(rom[i]^0xff,2,7,1,6,3,0,5,4);
680
 
                }
681
 
                else
682
 
                {
683
 
                        rom[i] = BITSWAP8(rom[i],6,3,0,5,1,4,7,2);
684
 
                }
685
 
        }
686
 
 
687
 
        /* extra inputs */
688
 
        machine.device("maincpu")->memory().space(AS_PROGRAM)->install_legacy_read_handler(0x770071, 0x770071, FUNC(iron_770071_r));
689
 
        machine.device("maincpu")->memory().space(AS_PROGRAM)->install_legacy_read_handler(0x770073, 0x770073, FUNC(iron_770073_r));
690
 
        machine.device("maincpu")->memory().space(AS_PROGRAM)->install_legacy_read_handler(0x770079, 0x770079, FUNC(iron_770079_r));
691
 
 
692
 
        DRIVER_INIT_CALL(snes);
693
 
}
694
 
 
695
841
static DRIVER_INIT( endless )
696
842
{
697
843
        INT32 i;
698
 
        UINT8 *rom = machine.region("user3")->base();
 
844
        UINT8 *rom = machine.root_device().memregion("user3")->base();
699
845
 
700
846
        /* there is more to this, 0x800 based block swaps? */
701
847
        for (i = 0; i < 0x200000; i++)
706
852
        DRIVER_INIT_CALL(snes);
707
853
}
708
854
 
709
 
static DRIVER_INIT( denseib )
710
 
{
711
 
        UINT8 *rom = machine.region("user3")->base();
712
 
        INT32 i;
713
 
 
714
 
        for (i = 0; i < 0x200000; i++)
715
 
        {
716
 
                rom[i] = rom[i] ^ 0xff;
717
 
                switch (i >> 16)
718
 
                {
719
 
                        case 0x00: rom[i] = BITSWAP8(rom[i],1,7,0,6,3,4,5,2); break;
720
 
                        case 0x01: rom[i] = BITSWAP8(rom[i],3,4,7,2,0,6,5,1); break;
721
 
                        case 0x02: rom[i] = BITSWAP8(rom[i],5,4,2,1,7,0,6,3); break;
722
 
                        case 0x03: rom[i] = BITSWAP8(rom[i],0,1,3,7,2,6,5,4); break;
723
 
 
724
 
                        default:   rom[i] = BITSWAP8(rom[i],4,5,1,0,2,3,7,6); break;
725
 
                }
726
 
        }
727
 
 
728
 
        /*  boot vector */
729
 
        rom[0xfffc] = 0x40;
730
 
        rom[0xfffd] = 0xf7;
731
 
 
732
 
        /* extra inputs */
733
 
        machine.device("maincpu")->memory().space(AS_PROGRAM)->install_legacy_read_handler(0x770071, 0x770071, FUNC(denseib_770071_r));
734
 
        machine.device("maincpu")->memory().space(AS_PROGRAM)->install_legacy_read_handler(0x770079, 0x770079, FUNC(denseib_770079_r));
735
 
 
736
 
        DRIVER_INIT_CALL(snes_hirom);
737
 
}
738
 
 
739
855
 
740
856
ROM_START( kinstb )
741
857
        ROM_REGION( 0x400000, "user3", 0 )
750
866
        ROM_REGION(0x800,           "user6", ROMREGION_ERASEFF)
751
867
ROM_END
752
868
 
753
 
ROM_START( endless )
754
 
        ROM_REGION( 0x400000, "user3", 0 )
755
 
        ROM_LOAD( "endlessduel.unknownposition1", 0x000000, 0x80000, CRC(e49acd29) SHA1(ac137261fe7a7691738ac812bea9591256eb9038) )
756
 
        ROM_LOAD( "endlessduel.unknownposition2", 0x080000, 0x80000, CRC(ad2052f9) SHA1(d61382e3d93eb0bff45fb534cec0ce5ae3626165) )
757
 
        ROM_LOAD( "endlessduel.unknownposition3", 0x100000, 0x80000, CRC(30d06d7a) SHA1(17c617d94abb10c3bdf9d51013b116f4ef4debe8) )
758
 
        ROM_LOAD( "endlessduel.unknownposition4", 0x180000, 0x80000, CRC(9a9493ad) SHA1(82ee4fce9cc2014cb8404fd43eebb7941cdb9ac1) )
759
 
 
760
 
        ROM_REGION(0x100,           "user5", 0)
761
 
        ROM_LOAD("spc700.rom", 0, 0x40, CRC(44bb3a40) SHA1(97e352553e94242ae823547cd853eecda55c20f0) )
762
 
 
763
 
        ROM_REGION(0x800,           "user6", ROMREGION_ERASEFF)
764
 
ROM_END
765
 
 
766
869
ROM_START( ffight2b )
767
870
        ROM_REGION( 0x400000, "user3", 0 )
768
871
        ROM_LOAD( "ff2_3.u6", 0x000000, 0x008000, CRC(343bf582) SHA1(cc6b7219bb2fe61f0b377b606ad28b0e5a78be0b) )
817
920
        ROM_REGION(0x800,           "user6", ROMREGION_ERASEFF)
818
921
ROM_END
819
922
 
 
923
ROM_START( denseib )
 
924
        ROM_REGION( 0x200000, "user3", ROMREGION_ERASEFF )
 
925
        ROM_LOAD( "dj.u14", 0x000000, 0x0080000, CRC(487ded13) SHA1(624edce30fe2f2d750bcb49c609ceb511b2279b1) )
 
926
        ROM_LOAD( "dj.u15", 0x080000, 0x0080000, CRC(5932a440) SHA1(6048372268a097b08d9f56ad30f083267d798165) )
 
927
        ROM_LOAD( "dj.u16", 0x100000, 0x0080000, CRC(7cb71fd7) SHA1(7673e9dcaabe804e2d637e67eabca1683dad4245) )
 
928
        ROM_LOAD( "dj.u17", 0x180000, 0x0080000, CRC(de29dd89) SHA1(441aefbc7ee64515ee66431ef504e76dc8dc5ca3) )
 
929
 
 
930
        ROM_REGION(0x100,           "user5", 0)
 
931
        ROM_LOAD("spc700.rom", 0, 0x40, CRC(44bb3a40) SHA1(97e352553e94242ae823547cd853eecda55c20f0) )
 
932
 
 
933
        ROM_REGION(0x800,           "user6", ROMREGION_ERASEFF)
 
934
ROM_END
 
935
 
820
936
ROM_START( sblast2b )
821
937
        ROM_REGION( 0x180000, "user3", ROMREGION_ERASEFF )
822
938
 
832
948
 
833
949
ROM_END
834
950
 
835
 
ROM_START( denseib )
836
 
        ROM_REGION( 0x200000, "user3", ROMREGION_ERASEFF )
837
 
        ROM_LOAD( "dj.u14", 0x000000, 0x0080000, CRC(487ded13) SHA1(624edce30fe2f2d750bcb49c609ceb511b2279b1) )
838
 
        ROM_LOAD( "dj.u15", 0x080000, 0x0080000, CRC(5932a440) SHA1(6048372268a097b08d9f56ad30f083267d798165) )
839
 
        ROM_LOAD( "dj.u16", 0x100000, 0x0080000, CRC(7cb71fd7) SHA1(7673e9dcaabe804e2d637e67eabca1683dad4245) )
840
 
        ROM_LOAD( "dj.u17", 0x180000, 0x0080000, CRC(de29dd89) SHA1(441aefbc7ee64515ee66431ef504e76dc8dc5ca3) )
 
951
ROM_START( endless )
 
952
        ROM_REGION( 0x400000, "user3", 0 )
 
953
        ROM_LOAD( "endlessduel.unknownposition1", 0x000000, 0x80000, CRC(e49acd29) SHA1(ac137261fe7a7691738ac812bea9591256eb9038) )
 
954
        ROM_LOAD( "endlessduel.unknownposition2", 0x080000, 0x80000, CRC(ad2052f9) SHA1(d61382e3d93eb0bff45fb534cec0ce5ae3626165) )
 
955
        ROM_LOAD( "endlessduel.unknownposition3", 0x100000, 0x80000, CRC(30d06d7a) SHA1(17c617d94abb10c3bdf9d51013b116f4ef4debe8) )
 
956
        ROM_LOAD( "endlessduel.unknownposition4", 0x180000, 0x80000, CRC(9a9493ad) SHA1(82ee4fce9cc2014cb8404fd43eebb7941cdb9ac1) )
841
957
 
842
958
        ROM_REGION(0x100,           "user5", 0)
843
959
        ROM_LOAD("spc700.rom", 0, 0x40, CRC(44bb3a40) SHA1(97e352553e94242ae823547cd853eecda55c20f0) )
848
964
 
849
965
GAME( 199?, kinstb,       0,     kinstb,             kinstb,    kinstb,       ROT0, "bootleg",  "Killer Instinct (SNES bootleg)",                 GAME_IMPERFECT_SOUND | GAME_IMPERFECT_GRAPHICS )
850
966
GAME( 1996, ffight2b,     0,     kinstb,             ffight2b,  ffight2b,     ROT0, "bootleg",  "Final Fight 2 (SNES bootleg)",                   GAME_IMPERFECT_SOUND | GAME_IMPERFECT_GRAPHICS )
851
 
GAME( 1997, sblast2b,     0,     kinstb,             sblast2b,  sblast2b,     ROT0, "bootleg",  "Sonic Blast Man 2 Special Turbo (SNES bootleg)", GAME_IMPERFECT_SOUND | GAME_IMPERFECT_GRAPHICS)
852
967
GAME( 1996, iron,         0,     kinstb,             iron,      iron,         ROT0, "bootleg",  "Iron (SNES bootleg)",                            GAME_IMPERFECT_SOUND | GAME_IMPERFECT_GRAPHICS )
853
968
GAME( 1996, denseib,      0,     kinstb,             denseib,   denseib,      ROT0, "bootleg",  "Ghost Chaser Densei (SNES bootleg)",             GAME_IMPERFECT_SOUND | GAME_IMPERFECT_GRAPHICS )
854
 
GAME( 1996, endless,      0,     kinstb,             iron,      endless,      ROT0, "bootleg",  "Gundam Wing: Endless Duel (SNES bootleg)",       GAME_NOT_WORKING | GAME_IMPERFECT_SOUND | GAME_IMPERFECT_GRAPHICS )
 
969
GAME( 1997, sblast2b,     0,     kinstb,             sblast2b,  sblast2b,     ROT0, "bootleg",  "Sonic Blast Man 2 Special Turbo (SNES bootleg)", GAME_IMPERFECT_SOUND | GAME_IMPERFECT_GRAPHICS)
 
970
GAME( 1996, endless,      0,     kinstb,             endless,   endless,      ROT0, "bootleg",  "Gundam Wing: Endless Duel (SNES bootleg)",       GAME_NOT_WORKING | GAME_IMPERFECT_SOUND | GAME_IMPERFECT_GRAPHICS )