Previous 15994 Revisions Next

r14863 Saturday 7th April, 2012 at 07:48:30 UTC by Miodrag Milanović
Sync with MAME r15892 (no whatsnew)
[src/build]makelist.c
[src/emu]audit.h clifront.h config.c diimage.c drivenum.c* drivenum.h* driver.c driver.h emu.h emu.mak emuopts.c gamedrv.h* hashfile.c info.h machine.c machine.h render.c romload.c screen.h uimain.h validity.h
[src/emu/cpu/tms57002]tms57kpr.h
[src/mame/drivers]igs017.c namcos10.c system1.c wldarrow.c

src/build/makelist.c
r14862r14863
251251
252252   // start with a header
253253   printf("#include \"emu.h\"\n\n");
254   printf("#include \"drivenum.h\"\n\n");
254255
255256   // output the list of externs first
256257   for (int index = 0; index < drivcount; index++)
src/mame/drivers/namcos10.c
r14862r14863
269269#include "video/psx.h"
270270#include "includes/psx.h"
271271
272WRITE32_HANDLER( namcos10_bank_w )
273{
274   memory_set_bank( space->machine(), "bank1", data & 0xf );
275}
276
277272class namcos10_state : public psx_state
278273{
279274public:
280275   namcos10_state(const machine_config &mconfig, device_type type, const char *tag)
281276      : psx_state(mconfig, type, tag) { }
277
278   // memm variant interface
279   DECLARE_WRITE32_MEMBER(key_w);
280   DECLARE_READ32_MEMBER(range_r);
281   DECLARE_WRITE32_MEMBER(bank_w);
282
283   // memn variant interface
284   DECLARE_READ32_MEMBER (nand_status_r);
285   DECLARE_WRITE32_MEMBER(nand_address1_w);
286   DECLARE_WRITE32_MEMBER(nand_address2_w);
287   DECLARE_WRITE32_MEMBER(nand_address3_w);
288   DECLARE_WRITE32_MEMBER(nand_address4_w);
289   DECLARE_READ32_MEMBER (nand_data_r);
290   DECLARE_WRITE32_MEMBER(watchdog_w);
291   DECLARE_WRITE32_MEMBER(nand_block_w);
292   DECLARE_READ32_MEMBER (nand_block_r);   
293
294   UINT8 *nand_base;
295   void nand_copy( UINT32 *dst, UINT32 address, int len );
296
297private:
298   UINT16 key;
299   UINT8  cnt;
300   UINT32 bank_base;
301   UINT32 nand_address;
302   UINT32 block[0x1ff];
303
304   UINT16 nand_read( UINT32 address );
305   UINT16 nand_read2( UINT32 address );
282306};
283307
308
284309static ADDRESS_MAP_START( namcos10_map, AS_PROGRAM, 32, namcos10_state )
285310   AM_RANGE(0x00000000, 0x00ffffff) AM_RAM AM_SHARE("share1") /* ram */
286311   AM_RANGE(0x1fc00000, 0x1fffffff) AM_ROM AM_SHARE("share2") AM_REGION("user1", 0) /* bios */
r14862r14863
291316   AM_RANGE(0xfffe0130, 0xfffe0133) AM_WRITENOP
292317ADDRESS_MAP_END
293318
319
320// memm variant interface
321//
322// banked view with dynamic decryption over the flash.  Access to the
323// nand is unknown, but may just be using the memn interface.  Won't
324// know until the decryption is done.
325//
326// bios copies 62000-37ffff from the flash to 80012000 in ram through the
327// decryption in range_r then jumps there (and dies horribly, of course)
328
329WRITE32_MEMBER(namcos10_state::key_w )
330{
331   key = (data >> 15) | (data << 1);
332   cnt = 0;
333}
334
335WRITE32_MEMBER(namcos10_state::bank_w)
336{
337   bank_base = 0x80000*(offset*2 + (ACCESSING_BITS_16_31 ? 1 : 0));
338}
339
340READ32_MEMBER(namcos10_state::range_r)
341{
342   UINT32 data32 = ((const UINT32 *)(machine().region("user1")->base()))[offset+bank_base];
343
344   UINT16 d16;
345   if(ACCESSING_BITS_16_31)
346      d16 = data32 >> 16;
347   else
348      d16 = data32;
349
350   /* This is not entirely correct, but not entirely incorrect either...
351      It's also specific to mrdriller2, it seems.
352   */
353     
354   UINT16 dd16 = d16 ^ key;
355
356   key =
357      ((    BIT(d16,  3) ^ (BIT(cnt, 0) & !BIT(cnt, 2))) << 15) |
358      ((1 ^ BIT(key, 13) ^  BIT(cnt, 0))                 << 14) |
359      ((1 ^ BIT(key, 11) ^  BIT(d16, 5) ^  BIT(d16, 2))  << 13) |
360      ((    BIT(key,  9) ^  BIT(cnt, 3))                 << 12) |
361      ((1 ^ BIT(key,  2))                                << 11) |
362      ((    BIT(key, 10) ^ (BIT(d16, 4) &  BIT(cnt, 1))) << 10) |
363      ((1 ^ BIT(key,  6) ^  BIT(cnt, 4))                 <<  9) |
364      ((1 ^ BIT(d16,  6) ^  BIT(key, 5))                 <<  8) |
365      ((    BIT(key,  1) ^ (BIT(d16, 5) |  BIT(d16, 4))) <<  7) |
366      ((    BIT(key, 15))                                <<  6) |
367      ((1 ^ BIT(key,  4) ^  BIT(cnt, 3) ^  BIT(d16, 2))  <<  5) |
368      ((1 ^ BIT(key,  7) ^  BIT(cnt, 5))                 <<  4) |
369      ((1 ^ BIT(key,  8) ^ (BIT(cnt, 7) |  BIT(d16, 3))) <<  3) |
370      ((    BIT(key, 14) ^ (BIT(cnt, 1) |  BIT(d16, 7))) <<  2) |
371      ((1 ^ BIT(key, 12) ^ (BIT(cnt, 7) &  BIT(d16, 7))) <<  1) |
372      ((                   (BIT(cnt, 0) |  BIT(cnt, 2))) <<  0);
373
374   cnt++;
375
376   if(ACCESSING_BITS_16_31)
377      return dd16 << 16;
378   else
379      return dd16;
380}
381
382static ADDRESS_MAP_START( namcos10_memm_map, AS_PROGRAM, 32, namcos10_state )
383   AM_RANGE(0x1f300000, 0x1f300003) AM_WRITE(key_w)
384   AM_RANGE(0x1f400000, 0x1f5fffff) AM_READ (range_r)
385   AM_RANGE(0x1fb40000, 0x1fb4000f) AM_WRITE(bank_w)
386
387   AM_IMPORT_FROM(namcos10_map)
388ADDRESS_MAP_END
389
390
294391static void memm_driver_init( running_machine &machine )
295392{
296393   psx_driver_init(machine);
297   machine.device("maincpu")->memory().space(AS_PROGRAM)->install_legacy_write_handler( 0x1f300000, 0x1f300003, FUNC(namcos10_bank_w) );
298   machine.device("maincpu")->memory().space(AS_PROGRAM)->install_read_bank( 0x1f400000, 0x1f7fffff, "bank1" );
299   memory_configure_bank( machine, "bank1", 0, 16, machine.region( "user2" )->base(), 4 * 1024 * 1024 );
300394}
301395
302UINT8 *nand_base;
303UINT32 nand_address = 0;
304396
305READ32_HANDLER( nand_status_r )
397// memn variant interface
398//
399// Block access to the nand.  Something strange is going on with the
400// status port.  Interaction with the decryption is unclear at best.
401
402READ32_MEMBER(namcos10_state::nand_status_r )
306403{
307404   return 0;
308405}
309406
310WRITE32_HANDLER( nand_address1_w )
407WRITE32_MEMBER(namcos10_state::nand_address1_w )
311408{
409   logerror("nand_a1_w %08x (%08x)\n", data, cpu_get_pc(&space.device()));
312410   nand_address = ( nand_address & 0x00ffffff ) | ( ( data & 0xff ) << 24 );
313411}
314412
315WRITE32_HANDLER( nand_address2_w )
413WRITE32_MEMBER(namcos10_state::nand_address2_w )
316414{
415   logerror("nand_a2_w %08x (%08x)\n", data, cpu_get_pc(&space.device()));
317416   nand_address = ( nand_address & 0xff00ffff ) | ( ( data & 0xff ) << 16 );
318417}
319418
320WRITE32_HANDLER( nand_address3_w )
419WRITE32_MEMBER(namcos10_state::nand_address3_w )
321420{
421   logerror("nand_a3_w %08x (%08x)\n", data, cpu_get_pc(&space.device()));
322422   nand_address = ( nand_address & 0xffff00ff ) | ( ( data & 0xff ) << 8 );
323423}
324424
325WRITE32_HANDLER( nand_address4_w )
425WRITE32_MEMBER(namcos10_state::nand_address4_w )
326426{
427   logerror("nand_a4_w %08x (%08x)\n", data, cpu_get_pc(&space.device()));
327428   nand_address = ( nand_address & 0xffffff00 ) | ( ( data & 0xff ) << 0 );
328429}
329430
330UINT16 nand_read( UINT32 address )
431UINT16 namcos10_state::nand_read( UINT32 address )
331432{
332433   int index = ( ( address / 512 ) * 528 ) + ( address % 512 );
333434   return nand_base[ index ] | ( nand_base[ index + 1 ] << 8 );
334435}
335436
336UINT16 nand_read2( UINT32 address )
437UINT16 namcos10_state::nand_read2( UINT32 address )
337438{
338439   int index = ( ( address / 512 ) * 528 ) + ( address % 512 );
339440   return nand_base[ index + 1 ] | ( nand_base[ index ] << 8 );
340441}
341442
342READ32_HANDLER( nand_data_r )
443READ32_MEMBER(namcos10_state::nand_data_r )
343444{
344445   UINT32 data = nand_read2( nand_address * 2 );
345446
447   logerror("read %08x = %04x\n", nand_address*2, data);
448
346449/*  printf( "data<-%08x (%08x)\n", data, nand_address ); */
347450   nand_address++;
348451
349452   return data;
350453}
351454
352static void nand_copy( UINT32 *dst, UINT32 address, int len )
455void namcos10_state::nand_copy( UINT32 *dst, UINT32 address, int len )
353456{
354457   while( len > 0 )
355458   {
r14862r14863
359462   }
360463}
361464
362UINT32 block[ 0x1ff ];
363
364WRITE32_HANDLER( nand_block_w )
465WRITE32_MEMBER(namcos10_state::nand_block_w)
365466{
366   COMBINE_DATA( &block[ offset ] );
367/*  printf( "block %d %08x\n", offset, data ); */
467   COMBINE_DATA( &block[offset] );
368468}
369469
370READ32_HANDLER( nand_block_r )
470READ32_MEMBER(namcos10_state::nand_block_r)
371471{
372472   return block[ offset ];
373473}
374474
375WRITE32_HANDLER( watchdog_w )
475WRITE32_MEMBER(namcos10_state::watchdog_w)
376476{
377477}
378478
479static ADDRESS_MAP_START( namcos10_memn_map, AS_PROGRAM, 32, namcos10_state )
480   AM_RANGE(0x1f400000, 0x1f400003) AM_READ (nand_status_r)
481   AM_RANGE(0x1f410000, 0x1f410003) AM_WRITE(nand_address1_w)
482   AM_RANGE(0x1f420000, 0x1f420003) AM_WRITE(nand_address1_w)
483   AM_RANGE(0x1f430000, 0x1f430003) AM_WRITE(nand_address1_w)
484   AM_RANGE(0x1f440000, 0x1f440003) AM_WRITE(nand_address1_w)
485   AM_RANGE(0x1f450000, 0x1f450003) AM_READ (nand_data_r)
486   AM_RANGE(0x1fb60000, 0x1fb60003) AM_READWRITE(nand_block_r, nand_block_w)
487
488   AM_IMPORT_FROM(namcos10_map)
489ADDRESS_MAP_END
490
379491static void memn_driver_init( running_machine &machine )
380492{
493   namcos10_state *state = machine.driver_data<namcos10_state>();
381494   UINT8 *BIOS = (UINT8 *)machine.region( "user1" )->base();
382   nand_base = (UINT8 *)machine.region( "user2" )->base();
495   state->nand_base = (UINT8 *)machine.region( "user2" )->base();
383496
384   nand_copy( (UINT32 *)( BIOS + 0x0000000 ), 0x08000, 0x001c000 );
385   nand_copy( (UINT32 *)( BIOS + 0x0020000 ), 0x24000, 0x03e0000 );
497   state->nand_copy( (UINT32 *)( BIOS + 0x0000000 ), 0x08000, 0x001c000 );
498   state->nand_copy( (UINT32 *)( BIOS + 0x0020000 ), 0x24000, 0x03e0000 );
386499
387   machine.device("maincpu")->memory().space(AS_PROGRAM)->install_legacy_read_handler( 0x1f400000, 0x1f400003, FUNC(nand_status_r) );
388   machine.device("maincpu")->memory().space(AS_PROGRAM)->install_legacy_write_handler( 0x1f410000, 0x1f410003, FUNC(nand_address1_w) );
389   machine.device("maincpu")->memory().space(AS_PROGRAM)->install_legacy_write_handler( 0x1f420000, 0x1f420003, FUNC(nand_address2_w) );
390   machine.device("maincpu")->memory().space(AS_PROGRAM)->install_legacy_write_handler( 0x1f430000, 0x1f430003, FUNC(nand_address3_w) );
391   machine.device("maincpu")->memory().space(AS_PROGRAM)->install_legacy_write_handler( 0x1f440000, 0x1f440003, FUNC(nand_address4_w) );
392   machine.device("maincpu")->memory().space(AS_PROGRAM)->install_legacy_read_handler( 0x1f450000, 0x1f450003, FUNC(nand_data_r) );
393   machine.device("maincpu")->memory().space(AS_PROGRAM)->install_legacy_write_handler( 0x1fb60000, 0x1fb60003, FUNC(watchdog_w) );
394   machine.device("maincpu")->memory().space(AS_PROGRAM)->install_legacy_write_handler( 0xbf500000, 0xbf5007d7, FUNC(nand_block_w) );
395   machine.device("maincpu")->memory().space(AS_PROGRAM)->install_legacy_read_handler( 0xbf500000, 0xbf5007d7, FUNC(nand_block_r) );
396
397500   psx_driver_init(machine);
398501}
399502
400static void decrypt_bios( running_machine &machine, int b15, int b14, int b13, int b12, int b11, int b10, int b9, int b8,
503static void decrypt_bios( running_machine &machine, int start, int end, int b15, int b14, int b13, int b12, int b11, int b10, int b9, int b8,
401504   int b7, int b6, int b5, int b4, int b3, int b2, int b1, int b0 )
402505{
403   UINT16 *BIOS = (UINT16 *)machine.region( "user1" )->base();
404   int len = machine.region( "user1" )->bytes() / 2;
405   int i;
506   UINT16 *BIOS = (UINT16 *)(machine.region( "user1" )->base() + start);
507   int len = (end - start)/2;
406508
407   for( i = 0; i < len; i++ )
509   for( int i = 0; i < len; i++ )
408510   {
409511      BIOS[ i ] = BITSWAP16( BIOS[ i ] ^ 0xaaaa,
410512         b15, b14, b13, b12, b11, b10, b9, b8, b7, b6, b5, b4, b3, b2, b1, b0 );
r14862r14863
414516static DRIVER_INIT( mrdrilr2 )
415517{
416518   memm_driver_init(machine);
417   decrypt_bios( machine, 0xc, 0xd, 0xf, 0xe, 0xb, 0xa, 0x9, 0x8, 0x7, 0x6, 0x4, 0x1, 0x2, 0x5, 0x0, 0x3 );
519   decrypt_bios( machine, 0x000000, 0x041000, 0xc, 0xd, 0xf, 0xe, 0xb, 0xa, 0x9, 0x8, 0x7, 0x6, 0x4, 0x1, 0x2, 0x5, 0x0, 0x3 );
520   decrypt_bios( machine, 0x060000, 0x062000, 0xc, 0xd, 0xf, 0xe, 0xb, 0xa, 0x9, 0x8, 0x7, 0x6, 0x4, 0x1, 0x2, 0x5, 0x0, 0x3 );
418521}
419522
420523static DRIVER_INIT( gjspace )
421524{
422525   memn_driver_init(machine);
423   decrypt_bios( machine, 0x0, 0x2, 0xe, 0xd, 0xf, 0x6, 0xc, 0x7, 0x5, 0x1, 0x9, 0x8, 0xa, 0x3, 0x4, 0xb );
526   decrypt_bios( machine, 0x000000, 0x400000, 0x0, 0x2, 0xe, 0xd, 0xf, 0x6, 0xc, 0x7, 0x5, 0x1, 0x9, 0x8, 0xa, 0x3, 0x4, 0xb );
424527}
425528
426529static DRIVER_INIT( mrdrilrg )
427530{
428531   memn_driver_init(machine);
429   decrypt_bios( machine, 0x6, 0x4, 0x7, 0x5, 0x2, 0x1, 0x0, 0x3, 0xc, 0xd, 0xe, 0xf, 0x8, 0x9, 0xb, 0xa );
532   decrypt_bios( machine, 0x000000, 0x400000, 0x6, 0x4, 0x7, 0x5, 0x2, 0x1, 0x0, 0x3, 0xc, 0xd, 0xe, 0xf, 0x8, 0x9, 0xb, 0xa );
430533}
431534
432535static DRIVER_INIT( knpuzzle )
433536{
434537   memn_driver_init(machine);
435   decrypt_bios( machine, 0x6, 0x7, 0x4, 0x5, 0x2, 0x0, 0x3, 0x1, 0xc, 0xd, 0xe, 0xf, 0x9, 0xb, 0x8, 0xa );
538   decrypt_bios( machine, 0x000000, 0x400000, 0x6, 0x7, 0x4, 0x5, 0x2, 0x0, 0x3, 0x1, 0xc, 0xd, 0xe, 0xf, 0x9, 0xb, 0x8, 0xa );
436539}
437540
438541static DRIVER_INIT( startrgn )
439542{
440543   memn_driver_init(machine);
441   decrypt_bios( machine, 0x6, 0x5, 0x4, 0x7, 0x1, 0x3, 0x0, 0x2, 0xc, 0xd, 0xe, 0xf, 0x8, 0xb, 0xa, 0x9 );
544   decrypt_bios( machine, 0x000000, 0x400000, 0x6, 0x5, 0x4, 0x7, 0x1, 0x3, 0x0, 0x2, 0xc, 0xd, 0xe, 0xf, 0x8, 0xb, 0xa, 0x9 );
442545}
443546
444547static DRIVER_INIT( gamshara )
445548{
446549   memn_driver_init(machine);
447   decrypt_bios( machine, 0x5, 0x4, 0x7, 0x6, 0x0, 0x1, 0x3, 0x2, 0xd, 0xf, 0xc, 0xe, 0x8, 0x9, 0xa, 0xb );
550   decrypt_bios( machine, 0x000000, 0x400000, 0x5, 0x4, 0x7, 0x6, 0x0, 0x1, 0x3, 0x2, 0xd, 0xf, 0xc, 0xe, 0x8, 0x9, 0xa, 0xb );
448551}
449552
450553static DRIVER_INIT( gunbalna )
451554{
452555   memn_driver_init(machine);
453   decrypt_bios( machine, 0x5, 0x4, 0x7, 0x6, 0x0, 0x1, 0x3, 0x2, 0xd, 0xf, 0xc, 0xe, 0x9, 0x8, 0xa, 0xb );
556   decrypt_bios( machine, 0x000000, 0x400000, 0x5, 0x4, 0x7, 0x6, 0x0, 0x1, 0x3, 0x2, 0xd, 0xf, 0xc, 0xe, 0x9, 0x8, 0xa, 0xb );
454557}
455558
456559static DRIVER_INIT( chocovdr )
r14862r14863
459562//  NOTE: none of the possible permutations show the Sony Computer Entertainment string at BIOS[0x84], very likely a bad dump
460563//                                             BAD? 0 or 9                             1 or 8         0 or 9
461564//                         ok!  ok!  ok!  ok!            ok!  ok!  ok!  ok!  ok!  ok!       ok!  ok!
462   decrypt_bios( machine, 0x5, 0x4, 0x6, 0x7, 0x1, 0x0, 0x2, 0x3, 0xc, 0xf, 0xe, 0xd, 0x8, 0xb, 0xa, 0x9 );
565   decrypt_bios( machine, 0x000000, 0x400000, 0x5, 0x4, 0x6, 0x7, 0x1, 0x0, 0x2, 0x3, 0xc, 0xf, 0xe, 0xd, 0x8, 0xb, 0xa, 0x9 );
463566}
464567
465568static DRIVER_INIT( panikuru )
466569{
467570   memn_driver_init(machine);
468   decrypt_bios( machine, 0x6, 0x4, 0x7, 0x5, 0x0, 0x1, 0x2, 0x3, 0xc, 0xf, 0xe, 0xd, 0x9, 0x8, 0xb, 0xa );
571   decrypt_bios( machine, 0x000000, 0x400000, 0x6, 0x4, 0x7, 0x5, 0x0, 0x1, 0x2, 0x3, 0xc, 0xf, 0xe, 0xd, 0x9, 0x8, 0xb, 0xa );
469572}
470573
471574static DRIVER_INIT( nflclsfb )
472575{
473576   memn_driver_init(machine);
474   decrypt_bios( machine, 0x6, 0x5, 0x4, 0x7, 0x1, 0x3, 0x0, 0x2, 0xc, 0xd, 0xe, 0xf, 0x8, 0xb, 0xa, 0x9 );
577   decrypt_bios( machine, 0x000000, 0x400000, 0x6, 0x5, 0x4, 0x7, 0x1, 0x3, 0x0, 0x2, 0xc, 0xd, 0xe, 0xf, 0x8, 0xb, 0xa, 0x9 );
475578}
476579
477580
r14862r14863
479582{
480583}
481584
482static MACHINE_CONFIG_START( namcos10, namcos10_state )
585static MACHINE_CONFIG_START( namcos10_memm, namcos10_state )
483586   /* basic machine hardware */
484587   MCFG_CPU_ADD( "maincpu", CXD8606BQ, XTAL_101_4912MHz )
485   MCFG_CPU_PROGRAM_MAP( namcos10_map )
588   MCFG_CPU_PROGRAM_MAP( namcos10_memm_map )
486589
487590   MCFG_MACHINE_RESET( namcos10 )
488591
r14862r14863
493596   MCFG_SPEAKER_STANDARD_STEREO("lspeaker", "rspeaker")
494597MACHINE_CONFIG_END
495598
599static MACHINE_CONFIG_START( namcos10_memn, namcos10_state )
600   /* basic machine hardware */
601   MCFG_CPU_ADD( "maincpu", CXD8606BQ, XTAL_101_4912MHz )
602   MCFG_CPU_PROGRAM_MAP( namcos10_memn_map )
603
604   MCFG_MACHINE_RESET( namcos10 )
605
606   /* video hardware */
607   MCFG_PSXGPU_ADD( "maincpu", "gpu", CXD8561CQ, 0x200000, XTAL_53_693175MHz )
608
609   /* sound hardware */
610   MCFG_SPEAKER_STANDARD_STEREO("lspeaker", "rspeaker")
611MACHINE_CONFIG_END
612
496613static INPUT_PORTS_START( namcos10 )
497614   /* IN 0 */
498615   PORT_START("SYSTEM")
r14862r14863
665782ROM_END
666783
667784
668GAME( 2000, mrdrilr2,  0,        namcos10, namcos10, mrdrilr2, ROT0, "Namco", "Mr. Driller 2 (Japan, DR21 Ver.A)", GAME_NOT_WORKING | GAME_NO_SOUND ) // PORT_4WAY joysticks
669GAME( 2000, mrdrlr2a,  mrdrilr2, namcos10, namcos10, mrdrilr2, ROT0, "Namco", "Mr. Driller 2 (Japan, DR22 Ver.A)", GAME_NOT_WORKING | GAME_NO_SOUND ) // PORT_4WAY joysticks
670GAME( 2000, ptblank3,  0,        namcos10, namcos10, gunbalna, ROT0, "Namco", "Point Blank 3 (GNN2 Ver.A)", GAME_NOT_WORKING | GAME_NO_SOUND )
671GAME( 2000, gunbalina, ptblank3, namcos10, namcos10, gunbalna, ROT0, "Namco", "Gunbalina (GNN1 Ver.A)", GAME_NOT_WORKING | GAME_NO_SOUND )
672GAME( 2001, gjspace,   0,        namcos10, namcos10, gjspace,  ROT0, "Namco / Metro", "Gekitoride-Jong Space (10011 Ver.A)", GAME_NOT_WORKING | GAME_NO_SOUND )
673GAME( 2001, mrdrilrg,  0,        namcos10, namcos10, mrdrilrg, ROT0, "Namco", "Mr. Driller G (Japan, DRG1 Ver.A)", GAME_NOT_WORKING | GAME_NO_SOUND ) // PORT_4WAY joysticks
674GAME( 2001, knpuzzle,  0,        namcos10, namcos10, knpuzzle, ROT0, "Namco", "Kotoba no Puzzle Mojipittan (Japan, KPM1 Ver.A)", GAME_NOT_WORKING | GAME_NO_SOUND )
675GAME( 2002, chocovdr,  0,        namcos10, namcos10, chocovdr, ROT0, "Namco", "Uchuu Daisakusen: Chocovader Contactee (Japan, CVC1 Ver.A)", GAME_NOT_WORKING | GAME_NO_SOUND )
676GAME( 2002, startrgn,  0,        namcos10, namcos10, startrgn, ROT0, "Namco", "Star Trigon (Japan, STT1 Ver.A)", GAME_NOT_WORKING | GAME_NO_SOUND )
677GAME( 2002, panikuru,  0,        namcos10, namcos10, panikuru, ROT0, "Namco", "Panicuru Panekuru (Japan, PPA1 Ver.A)", GAME_NOT_WORKING | GAME_NO_SOUND )
678GAME( 2003, nflclsfb,  0,        namcos10, namcos10, nflclsfb, ROT0, "Namco", "NFL Classic Football (NCF3 Ver.A.)", GAME_NOT_WORKING | GAME_NO_SOUND )
679GAME( 2003, gamshara,  0,        namcos10, namcos10, gamshara, ROT0, "Mitchell", "Gamshara (10021 Ver.A)", GAME_NOT_WORKING | GAME_NO_SOUND )
785GAME( 2000, mrdrilr2,  0,        namcos10_memm, namcos10, mrdrilr2, ROT0, "Namco", "Mr. Driller 2 (Japan, DR21 Ver.A)", GAME_NOT_WORKING | GAME_NO_SOUND ) // PORT_4WAY joysticks
786GAME( 2000, mrdrlr2a,  mrdrilr2, namcos10_memm, namcos10, mrdrilr2, ROT0, "Namco", "Mr. Driller 2 (Japan, DR22 Ver.A)", GAME_NOT_WORKING | GAME_NO_SOUND ) // PORT_4WAY joysticks
787GAME( 2000, ptblank3,  0,        namcos10_memn, namcos10, gunbalna, ROT0, "Namco", "Point Blank 3 (GNN2 Ver.A)", GAME_NOT_WORKING | GAME_NO_SOUND )
788GAME( 2000, gunbalina, ptblank3, namcos10_memn, namcos10, gunbalna, ROT0, "Namco", "Gunbalina (GNN1 Ver.A)", GAME_NOT_WORKING | GAME_NO_SOUND )
789GAME( 2001, gjspace,   0,        namcos10_memn, namcos10, gjspace,  ROT0, "Namco / Metro", "Gekitoride-Jong Space (10011 Ver.A)", GAME_NOT_WORKING | GAME_NO_SOUND )
790GAME( 2001, mrdrilrg,  0,        namcos10_memn, namcos10, mrdrilrg, ROT0, "Namco", "Mr. Driller G (Japan, DRG1 Ver.A)", GAME_NOT_WORKING | GAME_NO_SOUND ) // PORT_4WAY joysticks
791GAME( 2001, knpuzzle,  0,        namcos10_memn, namcos10, knpuzzle, ROT0, "Namco", "Kotoba no Puzzle Mojipittan (Japan, KPM1 Ver.A)", GAME_NOT_WORKING | GAME_NO_SOUND )
792GAME( 2002, chocovdr,  0,        namcos10_memn, namcos10, chocovdr, ROT0, "Namco", "Uchuu Daisakusen: Chocovader Contactee (Japan, CVC1 Ver.A)", GAME_NOT_WORKING | GAME_NO_SOUND )
793GAME( 2002, startrgn,  0,        namcos10_memn, namcos10, startrgn, ROT0, "Namco", "Star Trigon (Japan, STT1 Ver.A)", GAME_NOT_WORKING | GAME_NO_SOUND )
794GAME( 2002, panikuru,  0,        namcos10_memn, namcos10, panikuru, ROT0, "Namco", "Panicuru Panekuru (Japan, PPA1 Ver.A)", GAME_NOT_WORKING | GAME_NO_SOUND )
795GAME( 2003, nflclsfb,  0,        namcos10_memn, namcos10, nflclsfb, ROT0, "Namco", "NFL Classic Football (NCF3 Ver.A.)", GAME_NOT_WORKING | GAME_NO_SOUND )
796GAME( 2003, gamshara,  0,        namcos10_memn, namcos10, gamshara, ROT0, "Mitchell", "Gamshara (10021 Ver.A)", GAME_NOT_WORKING | GAME_NO_SOUND )
src/mame/drivers/igs017.c
r14862r14863
3434Notes:
3535
3636- iqblocka: keep start or test pressed during boot to enter test mode A or B.
37- mgcs, tjsb: press service + stats during test mode for sound test.
37- lhzb2, mgcs, tjsb: press service + stats during test mode for sound test.
3838- mgdh: press A + B during test mode for sound test (B1+B2+B3 when using a joystick).
3939- mgdh: test mode is accessed by keeping test pressed during boot (as usual), but pressing F2+F3 in MAME
4040  does not actually work. It does work if F2 is pressed in the debug window at boot, and held while closing it.
r14862r14863
5454public:
5555   igs017_state(const machine_config &mconfig, device_type type, const char *tag)
5656      : driver_device(mconfig, type, tag),
57      m_input_addr(-1),
5758      m_maincpu(*this, "maincpu")
5859      { }
5960
r14862r14863
7071   int m_nmi_enable;
7172   int m_irq_enable;
7273   UINT8 m_input_select;
74   int m_input_addr;
7375   UINT8 m_hopper;
7476   UINT16 m_igs_magic[2];
7577   UINT8 m_scramble_data;
78   UINT8 m_prot[2];
7679   int m_irq1_enable;
7780   int m_irq2_enable;
7881   UINT8 *m_spriteram;
r14862r14863
107110   DECLARE_WRITE8_MEMBER(tjsb_paletteram_w);
108111   DECLARE_WRITE8_MEMBER(tjsb_output_w);
109112   DECLARE_READ8_MEMBER(tjsb_input_r);
113   DECLARE_WRITE16_MEMBER(lhzb2a_paletteram_w);
114   DECLARE_READ16_MEMBER(lhzb2a_input_r);
115   DECLARE_WRITE16_MEMBER(lhzb2a_input_addr_w);
116   DECLARE_WRITE16_MEMBER(lhzb2a_input_select_w);
117   DECLARE_WRITE16_MEMBER(lhzb2a_magic_w);
118   DECLARE_READ16_MEMBER(lhzb2a_magic_r);
119   DECLARE_WRITE16_MEMBER(lhzb2_magic_w);
120   DECLARE_READ16_MEMBER(lhzb2_magic_r);
121   DECLARE_WRITE16_MEMBER(slqz2_paletteram_w);
122   DECLARE_WRITE16_MEMBER(slqz2_magic_w);
123   DECLARE_READ16_MEMBER(slqz2_magic_r);
110124};
111125
112126
r14862r14863
119133{
120134   m_video_disable = data & 1;
121135   if (data & (~1))
122      logerror("PC %06X: unknown bits of video_disable written = %02x\n",cpu_get_pc(&space.device()),data);
136      logerror("%s: unknown bits of video_disable written = %02x\n", machine().describe_context(), data);
123137//  popmessage("VIDEO %02X",data);
124138}
125139WRITE16_MEMBER(igs017_state::video_disable_lsb_w)
r14862r14863
198212
199213
200214
201// Eeach 16 bit word in the sprites gfx roms contains three 5 bit pens: x-22222-11111-00000.
215// Eeach 16 bit word in the sprites gfx roms contains three 5 bit pens: x-22222-11111-00000 (little endian!).
202216// This routine expands each word into three bytes.
203217static void expand_sprites(running_machine &machine)
204218{
r14862r14863
338352      if (machine.input().code_pressed(KEYCODE_Y))      w -= 8;
339353
340354      if (machine.input().code_pressed(KEYCODE_RIGHT))   a += 1;
341      if (machine.input().code_pressed(KEYCODE_LEFT))   a -= 1;
355      if (machine.input().code_pressed(KEYCODE_LEFT))      a -= 1;
342356
343      if (machine.input().code_pressed(KEYCODE_DOWN))   a += w;
357      if (machine.input().code_pressed(KEYCODE_DOWN))      a += w;
344358      if (machine.input().code_pressed(KEYCODE_UP))      a -= w;
345359
346      if (machine.input().code_pressed(KEYCODE_PGDN))   a += w * h;
347      if (machine.input().code_pressed(KEYCODE_PGUP))   a -= w * h;
360      if (machine.input().code_pressed(KEYCODE_PGDN))      a += w * h;
361      if (machine.input().code_pressed(KEYCODE_PGUP))      a -= w * h;
348362
349363      if (a < 0)      a = 0;
350364      if (a > state->m_sprites_gfx_size)   a = state->m_sprites_gfx_size;
r14862r14863
356370
357371      draw_sprite(machine, bitmap, cliprect, 0,0, w,h, 0,0, 0, a);
358372
359      popmessage("a: %08X w: %03X p: %02X-%02x-%02x",a,w,state->m_sprites_gfx[a/3*3+0],state->m_sprites_gfx[a/3*3+1],state->m_sprites_gfx[a/3*3+2]);
373      popmessage("a: %08X w: %03X p: %02x-%02x-%02x",a,w,state->m_sprites_gfx[a/3*3+0],state->m_sprites_gfx[a/3*3+1],state->m_sprites_gfx[a/3*3+2]);
360374      state->m_debug_addr = a;
361375      state->m_debug_width = w;
362376      osd_sleep(200000);
r14862r14863
504518   UINT8 *tmp = auto_alloc_array(machine, UINT8, length);
505519   int i, addr;
506520
507   // address lines swap (to do: collapse into one bitswap)
521   // address lines swap
508522   memcpy(tmp, rom, length);
509523   for (i = 0; i < length; i++)
510524   {
511      addr = (i & ~0xff) | BITSWAP8(i,7,6,5,4,1,2,3,0);
525      addr = (i & ~0xff) | BITSWAP8(i,7,6,5,2,1,4,3,0);
512526      rom[i] = tmp[addr];
513527   }
514528
515   memcpy(tmp, rom, length);
516   for (i = 0; i < length; i++)
517   {
518      addr = (i & ~0xff) | BITSWAP8(i,7,6,5,2,4,3,1,0);
519      rom[i] = tmp[addr];
520   }
521
522   memcpy(tmp, rom, length);
523   for (i = 0; i < length; i++)
524   {
525      addr = (i & ~0xff) | BITSWAP8(i,7,6,5,3,4,2,1,0);
526      rom[i] = tmp[addr];
527   }
528
529529   // data lines swap
530530   for (i = 0; i < length; i += 2)
531531   {
532      // x-22222-11111-00000
533      UINT16 data = (rom[i+1] << 8) | rom[i+0];
532      UINT16 data = (rom[i+1] << 8) | rom[i+0];   // x-22222-11111-00000
534533      data = BITSWAP16(data, 15, 14,13,12,11,10, 9,1,7,6,5, 4,3,2,8,0);
534      rom[i+0] = data;
535535      rom[i+1] = data >> 8;
536      rom[i+0] = data;
537536   }
538537}
539538
r14862r14863
708707
709708// starzan
710709
711// decryption is incomplete, data encryption is correct but opcodes are encrypted differently.
710// decryption is incomplete: data decryption is correct but opcodes are encrypted differently.
712711
713712static void starzan_decrypt(UINT8 *ROM, int size, bool isOpcode)
714713{
r14862r14863
881880
882881// lhzb2
883882
883
884static void lhzb2_patch_rom(running_machine &machine)
885{
886   UINT16 *rom = (UINT16 *)machine.region("maincpu")->base();
887
888   // Prot. checks:
889   rom[0x14786/2] = 0x6044;   // 014786: 6744    beq $147cc
890
891   // ROM check:
892   rom[0x0b48a/2] = 0x604e;   // 00B48A: 674E    beq $b4da
893}
894
895static void lhzb2_decrypt_tiles(running_machine &machine)
896{
897   int length = machine.region("tilemaps")->bytes();
898   UINT8 *rom = machine.region("tilemaps")->base();
899   UINT8 *tmp = auto_alloc_array(machine, UINT8, length);
900   int i;
901
902   int addr;
903   memcpy(tmp, rom, length);
904   for (i = 0; i < length; i++)
905   {
906      addr = (i & ~0xffffff) | BITSWAP24(i,23,22,21,20,19,18,17,1,16,15,14,13,12,11,10,9,8,7,6,5,4,3,2,0);
907      rom[i] = tmp[addr];
908   }
909
910   auto_free(machine, tmp);
911}
912
913static void lhzb2_decrypt_sprites(running_machine &machine)
914{
915   int length = machine.region("sprites")->bytes();
916   UINT8 *rom = machine.region("sprites")->base();
917   UINT8 *tmp = auto_alloc_array(machine, UINT8, length);
918   int i, addr;
919
920   // address lines swap
921   memcpy(tmp, rom, length);
922   for (i = 0; i < length; i++)
923   {
924      addr = (i & ~0xffff) | BITSWAP16(i,15,14,13,6,7,10,9,8,11,12,5,4,3,2,1,0);
925      rom[i] = tmp[addr];
926   }
927
928   // data lines swap
929   for (i = 0;i < length;i+=2)
930   {
931      UINT16 data = (rom[i+1] << 8) | rom[i+0];   // x-22222-11111-00000
932      data = BITSWAP16(data, 15, 7,6,5,4,3, 2,1,0,14,13, 12,11,10,9,8);
933      rom[i+0] = data;
934      rom[i+1] = data >> 8;
935   }
936}
937
884938static DRIVER_INIT( lhzb2 )
885939{
886940   int i;
r14862r14863
9661020
9671021      src[i] = x;
9681022   }
1023
1024   lhzb2_decrypt_tiles(machine);
1025   lhzb2_decrypt_sprites(machine);
1026   lhzb2_patch_rom(machine);
9691027}
9701028
9711029
9721030//lhzb2a
9731031
1032static void lhzb2a_patch_rom(running_machine &machine)
1033{
1034   UINT16 *rom = (UINT16 *)machine.region("maincpu")->base();
1035
1036   // Prot. checks:
1037   rom[0x09c52/2] = 0x6026;   // 009C52: 6726    beq $9c7a
1038   rom[0x0c62c/2] = 0x6026;   // 00C62C: 6726    beq $c654
1039   rom[0x0ea10/2] = 0x6030;   // 00EA10: 6730    beq $ea42
1040   rom[0x23472/2] = 0x6026;   // 023472: 6726    beq $2349a
1041   rom[0x6601a/2] = 0x6024;   // 06601A: 6724    beq $66040
1042
1043   // ROM check:
1044   rom[0x32ab6/2] = 0x604e;   // 032AB6: 674E    beq $32b06
1045}
1046
9741047static DRIVER_INIT( lhzb2a )
9751048{
9761049   int i;
r14862r14863
10281101
10291102      src[i] = x;
10301103   }
1104
1105   lhzb2_decrypt_tiles(machine);
1106   lhzb2_decrypt_sprites(machine);
1107   lhzb2a_patch_rom(machine);
10311108}
10321109
10331110
10341111//slqz2
10351112
1113static void slqz2_patch_rom(running_machine &machine)
1114{
1115   UINT16 *rom = (UINT16 *)machine.region("maincpu")->base();
1116
1117   // Prot. checks:
1118   rom[0x1489c/2] = 0x6044;   // 01489C: 6744    beq $148e2
1119
1120   // ROM check:
1121   rom[0x0b77a/2] = 0x604e;   // 00B77A: 674E    beq $b7ca
1122}
1123
1124static void slqz2_decrypt_tiles(running_machine &machine)
1125{
1126   int length = machine.region("tilemaps")->bytes();
1127   UINT8 *rom = machine.region("tilemaps")->base();
1128   UINT8 *tmp = auto_alloc_array(machine, UINT8, length);
1129   int i;
1130
1131   memcpy(tmp,rom,length);
1132   for (i = 0;i < length;i++)
1133   {
1134      int addr = (i & ~0xff) | BITSWAP8(i,7,4,5,6,3,2,1,0);
1135      rom[i] = tmp[addr];
1136   }
1137
1138   auto_free(machine, tmp);
1139}
1140
10361141static DRIVER_INIT( slqz2 )
10371142{
10381143   int i;
r14862r14863
11081213
11091214      src[i] = x;
11101215   }
1216
1217   slqz2_decrypt_tiles(machine);
1218   lhzb2_decrypt_sprites(machine);
1219   slqz2_patch_rom(machine);
11111220}
11121221
11131222/***************************************************************************
11141223                                Memory Maps
11151224***************************************************************************/
11161225
1226
1227// iqblocka
1228
1229
11171230static ADDRESS_MAP_START( iqblocka_map, AS_PROGRAM, 8, igs017_state )
11181231   AM_RANGE( 0x00000, 0x0dfff ) AM_ROM
11191232   AM_RANGE( 0x0e000, 0x0efff ) AM_RAM
r14862r14863
11251238{
11261239   m_nmi_enable = data & 1;
11271240   if (data & (~1))
1128      logerror("PC %06X: nmi_enable = %02x\n",cpu_get_pc(&space.device()),data);
1241      logerror("%s: nmi_enable = %02x\n", machine().describe_context(), data);
11291242}
11301243
11311244WRITE8_MEMBER(igs017_state::irq_enable_w)
11321245{
11331246   m_irq_enable = data & 1;
11341247   if (data & (~1))
1135      logerror("PC %06X: irq_enable = %02x\n",cpu_get_pc(&space.device()),data);
1248      logerror("%s: irq_enable = %02x\n", machine().describe_context(), data);
11361249}
11371250
11381251WRITE8_MEMBER(igs017_state::input_select_w)
r14862r14863
11731286      case 0x34:   return 0x32;
11741287
11751288      default:
1176         logerror("PC %06X: input %02x read\n",cpu_get_pc(&space.device()),m_input_select);
1289         logerror("%s: input %02x read\n", machine().describe_context(), m_input_select);
11771290         return 0xff;
11781291   }
11791292}
r14862r14863
12261339         }
12271340
12281341         if ( m_input_select & ~0xf8 )
1229            logerror("%06x: warning, unknown bits written in input_select = %02x\n", cpu_get_pc(&space.device()), m_input_select);
1342            logerror("%s: warning, unknown bits written in input_select = %02x\n", machine().describe_context(), m_input_select);
12301343         break;
12311344
12321345      case 0x01:
r14862r14863
12401353      // case 0x03: ?
12411354
12421355      default:
1243         logerror("%06x: warning, writing to igs_magic %02x = %02x\n", cpu_get_pc(&space.device()), m_igs_magic[0], data);
1356         logerror("%s: warning, writing to igs_magic %02x = %02x\n", machine().describe_context(), m_igs_magic[0], data);
12441357   }
12451358}
12461359
r14862r14863
12521365         return BITSWAP8(m_scramble_data, 4,5,6,7, 0,1,2,3);
12531366
12541367      default:
1255         logerror("%06x: warning, reading with igs_magic = %02x\n", cpu_get_pc(&space.device()), m_igs_magic[0]);
1368         logerror("%s: warning, reading with igs_magic = %02x\n", machine().describe_context(), m_igs_magic[0]);
12561369         break;
12571370   }
12581371
r14862r14863
12781391      m_irq1_enable = data & 1;
12791392
12801393   if (data != 0 && data != 0xff)
1281      logerror("PC %06X: irq1_enable = %04x\n",cpu_get_pc(&space.device()),data);
1394      logerror("%s: irq1_enable = %04x\n", machine().describe_context(), data);
12821395}
12831396
12841397WRITE16_MEMBER(igs017_state::irq2_enable_w)
r14862r14863
12871400      m_irq2_enable = data & 1;
12881401
12891402   if (data != 0 && data != 0xff)
1290      logerror("PC %06X: irq2_enable = %04x\n",cpu_get_pc(&space.device()),data);
1403      logerror("%s: irq2_enable = %04x\n", machine().describe_context(), data);
12911404}
12921405
12931406WRITE16_MEMBER(igs017_state::mgcs_paletteram_w)
r14862r14863
13221435
13231436// sdmg2
13241437
1438
13251439WRITE16_MEMBER(igs017_state::sdmg2_paletteram_w)
13261440{
13271441   COMBINE_DATA(&m_generic_paletteram_16[offset]);
r14862r14863
13751489         break;
13761490
13771491      default:
1378         logerror("%06x: warning, writing to igs_magic %02x = %02x\n", cpu_get_pc(&space.device()), m_igs_magic[0], data);
1492         logerror("%s: warning, writing to igs_magic %02x = %02x\n", machine().describe_context(), m_igs_magic[0], data);
13791493   }
13801494}
13811495
r14862r14863
13931507         return sdmg2_keys_r(space, 0);
13941508
13951509      default:
1396         logerror("%06x: warning, reading with igs_magic = %02x\n", cpu_get_pc(&space.device()), m_igs_magic[0]);
1510         logerror("%s: warning, reading with igs_magic = %02x\n", machine().describe_context(), m_igs_magic[0]);
13971511         break;
13981512   }
13991513
r14862r14863
14191533
14201534// mgdh, mgdha
14211535
1536
14221537READ8_MEMBER(igs017_state::mgdh_keys_r)
14231538{
14241539   if (~m_input_select & 0x04)   return input_port_read(machine(), "KEY0");
r14862r14863
14501565         }
14511566
14521567         if ( data & ~0xc0 )
1453            logerror("%06x: warning, unknown bits written to igs_magic 00 = %02x\n", cpu_get_pc(&space.device()), data);
1568            logerror("%s: warning, unknown bits written to igs_magic 00 = %02x\n", machine().describe_context(), data);
14541569
14551570         break;
14561571
r14862r14863
14621577         }
14631578
14641579         if ( m_input_select & ~0xfd )
1465            logerror("%06x: warning, unknown bits written in input_select = %02x\n", cpu_get_pc(&space.device()), m_input_select);
1580            logerror("%s: warning, unknown bits written in input_select = %02x\n", machine().describe_context(), m_input_select);
14661581
14671582         break;
14681583
r14862r14863
14871602            04ac10: warning, writing to igs_magic 06 = ff
14881603            04ac20: warning, writing to igs_magic 07 = 3f
14891604*/
1490         logerror("%06x: warning, writing to igs_magic %02x = %02x\n", cpu_get_pc(&space.device()), m_igs_magic[0], data);
1605         logerror("%s: warning, writing to igs_magic %02x = %02x\n", machine().describe_context(), m_igs_magic[0], data);
14911606   }
14921607}
14931608
r14862r14863
15111626      }
15121627
15131628      default:
1514         logerror("%06x: warning, reading with igs_magic = %02x\n", cpu_get_pc(&space.device()), m_igs_magic[0]);
1629         logerror("%s: warning, reading with igs_magic = %02x\n", machine().describe_context(), m_igs_magic[0]);
15151630         break;
15161631   }
15171632
r14862r14863
15381653
15391654// tjsb
15401655
1656
15411657WRITE8_MEMBER(igs017_state::tjsb_paletteram_w)
15421658{
15431659   m_generic_paletteram_8[offset] = data;
15441660   int bgr = (m_generic_paletteram_8[offset/2*2+1] << 8) | m_generic_paletteram_8[offset/2*2+0];
15451661
15461662   // bitswap
1547   bgr = BITSWAP16(bgr, 15, 12,3,6,10,5, 4,2,9,13,8, 7,11,1,0,14);
1663   bgr = BITSWAP16(bgr, 15,12,3,6,10,5,4,2,9,13,8,7,11,1,0,14);
15481664
15491665   palette_set_color_rgb(machine(), offset/2, pal5bit(bgr >> 0), pal5bit(bgr >> 5), pal5bit(bgr >> 10));
15501666}
r14862r14863
15771693            return;
15781694         break;
15791695   }
1580   logerror("%06x: warning, writing to igs_magic %02x = %02x\n", cpu_get_pc(&space.device()), m_input_select, data);
1696   logerror("%s: warning, writing to igs_magic %02x = %02x\n", machine().describe_context(), m_input_select, data);
15811697}
15821698
15831699READ8_MEMBER(igs017_state::tjsb_input_r)
r14862r14863
15941710      }
15951711
15961712      default:
1597         logerror("PC %06X: input %02x read\n",cpu_get_pc(&space.device()),m_input_select);
1713         logerror("%s: input %02x read\n", machine().describe_context(), m_input_select);
15981714         return 0xff;
15991715   }
16001716}
r14862r14863
16321748ADDRESS_MAP_END
16331749
16341750
1751// lhzb2
1752
1753
1754WRITE16_MEMBER(igs017_state::lhzb2_magic_w)
1755{
1756   COMBINE_DATA(&m_igs_magic[offset]);
1757
1758   if (offset == 0)
1759      return;
1760
1761   switch(m_igs_magic[0])
1762   {
1763      case 0x00:
1764         if (ACCESSING_BITS_0_7)
1765         {
1766            m_input_select = data & 0xff;
1767         }
1768
1769         if ( m_input_select & ~0x1f )
1770            logerror("%s: warning, unknown bits written in input_select = %02x\n", machine().describe_context(), m_input_select);
1771         break;
1772
1773      case 0x01:
1774         if (ACCESSING_BITS_0_7)
1775         {
1776            okim6295_device *oki = machine().device<okim6295_device>("oki");
1777            oki->set_bank_base((data & 0x80) ? 0x40000 : 0);
1778
1779            if ( data & 0x7f )
1780               logerror("%s: warning, unknown bits written in oki bank = %04x\n", machine().describe_context(), data);
1781         }
1782         break;
1783
1784      default:
1785         logerror("%s: warning, writing to igs_magic %02x = %02x\n", machine().describe_context(), m_igs_magic[0], data);
1786   }
1787}
1788
1789READ16_MEMBER(igs017_state::lhzb2_magic_r)
1790{
1791   switch(m_igs_magic[0])
1792   {
1793      case 0x01:
1794      {
1795         if (~m_input_select & 0x01)   return input_port_read(machine(), "KEY0");
1796         if (~m_input_select & 0x02)   return input_port_read(machine(), "KEY1");
1797         if (~m_input_select & 0x04)   return input_port_read(machine(), "KEY2");
1798         if (~m_input_select & 0x08)   return input_port_read(machine(), "KEY3");
1799         if (~m_input_select & 0x10)   return input_port_read(machine(), "KEY4");
1800
1801         logerror("%s: warning, reading key with input_select = %02x\n", machine().describe_context(), m_input_select);
1802         return 0xffff;
1803      }
1804
1805      default:
1806         logerror("%s: warning, reading with igs_magic = %02x\n", machine().describe_context(), m_igs_magic[0]);
1807         break;
1808   }
1809
1810   return 0xffff;
1811}
1812
1813static ADDRESS_MAP_START( lhzb2, AS_PROGRAM, 16, igs017_state )
1814   AM_RANGE(0x000000, 0x07ffff) AM_ROM
1815   AM_RANGE(0x500000, 0x503fff) AM_RAM
1816   AM_RANGE(0x910000, 0x910003) AM_WRITE( lhzb2_magic_w )
1817   AM_RANGE(0x910002, 0x910003) AM_READ( lhzb2_magic_r )
1818   AM_RANGE(0xb02000, 0xb02fff) AM_READWRITE( spriteram_lsb_r, spriteram_lsb_w ) AM_BASE( m_spriteram )
1819   AM_RANGE(0xb03000, 0xb037ff) AM_RAM_WRITE( lhzb2a_paletteram_w ) AM_SHARE("paletteram")
1820   AM_RANGE(0xb04020, 0xb04027) AM_DEVREAD8_LEGACY( "ppi8255", ppi8255_r, 0x00ff )
1821   AM_RANGE(0xb04024, 0xb04025) AM_WRITE( video_disable_lsb_w )
1822   AM_RANGE(0xb04028, 0xb04029) AM_WRITE( irq2_enable_w )
1823   AM_RANGE(0xb0402a, 0xb0402b) AM_WRITE( irq1_enable_w )
1824   AM_RANGE(0xb08000, 0xb0bfff) AM_READWRITE( fg_lsb_r, fg_lsb_w ) AM_BASE( m_fg_videoram )
1825   AM_RANGE(0xb0c000, 0xb0ffff) AM_READWRITE( bg_lsb_r, bg_lsb_w ) AM_BASE( m_bg_videoram )
1826   AM_RANGE(0xb10000, 0xb10001) AM_DEVREADWRITE8("oki", okim6295_device, read, write, 0x00ff )
1827ADDRESS_MAP_END
1828
1829
1830// lhzb2a
1831// To do: what devices are on this PCB?
1832
1833
1834WRITE16_MEMBER(igs017_state::lhzb2a_magic_w)
1835{
1836   COMBINE_DATA(&m_igs_magic[offset]);
1837
1838   if (offset == 0)
1839      return;
1840
1841   switch(m_igs_magic[0])
1842   {
1843      // to do: m_prot values
1844      default:
1845         logerror("%s: warning, writing to igs_magic %02x = %02x\n", machine().describe_context(), m_igs_magic[0], data);
1846   }
1847}
1848
1849READ16_MEMBER(igs017_state::lhzb2a_magic_r)
1850{
1851   switch(m_igs_magic[0])
1852   {
1853      case 0x03:
1854      {
1855         UINT8 a = BITSWAP8(m_prot[0], 9,9,1,9,2,5,4,7);   // 9 means 0 value
1856         UINT8 b = BITSWAP8(m_prot[1], 5,2,9,7,9,9,9,9);
1857         return a | b;
1858      }
1859
1860      default:
1861         logerror("%s: warning, reading with igs_magic = %02x\n", machine().describe_context(), m_igs_magic[0]);
1862         break;
1863   }
1864
1865   return 0xffff;
1866}
1867
1868WRITE16_MEMBER(igs017_state::lhzb2a_paletteram_w)
1869{
1870   COMBINE_DATA(&m_generic_paletteram_16[offset]);
1871
1872   int bgr = ((m_generic_paletteram_16[offset/2*2+1] & 0xff) << 8) | (m_generic_paletteram_16[offset/2*2+0] & 0xff);
1873
1874   // bitswap
1875   bgr = BITSWAP16(bgr, 15,9,13,12,11,5,4,8,7,6,0,14,3,2,1,10);
1876
1877   palette_set_color_rgb(machine(), offset/2, pal5bit(bgr >> 0), pal5bit(bgr >> 5), pal5bit(bgr >> 10));
1878}
1879
1880READ16_MEMBER(igs017_state::lhzb2a_input_r)
1881{
1882   switch (offset*2)
1883   {
1884      case 0x00:   // Keys
1885      {
1886         if (~m_input_select & 0x01)   return input_port_read(machine(), "KEY0") << 8;
1887         if (~m_input_select & 0x02)   return input_port_read(machine(), "KEY1") << 8;
1888         if (~m_input_select & 0x04)   return input_port_read(machine(), "KEY2") << 8;
1889         if (~m_input_select & 0x08)   return input_port_read(machine(), "KEY3") << 8;
1890         if (~m_input_select & 0x10)   return input_port_read(machine(), "KEY4") << 8;
1891
1892         logerror("%s: warning, reading key with input_select = %02x\n", machine().describe_context(), m_input_select);
1893         return 0xffff;
1894      }
1895
1896      case 0x02:
1897      {
1898         UINT16 hopper_bit = (m_hopper && ((machine().primary_screen->frame_number()/10)&1)) ? 0x0000 : 0x0002;
1899         return (input_port_read(machine(), "DSW1") << 8) | input_port_read(machine(), "COINS") | hopper_bit;
1900      }
1901
1902      case 0x04:
1903         return input_port_read(machine(), "DSW2");
1904   }
1905
1906   return 0xffff;
1907}
1908
1909WRITE16_MEMBER(igs017_state::lhzb2a_input_addr_w)
1910{
1911   // Unmap previous address ranges
1912   if (m_input_addr != -1)
1913   {
1914      space.unmap_readwrite(m_input_addr * 0x10000 + 0x4000, m_input_addr * 0x10000 + 0x4003);
1915      space.unmap_read     (m_input_addr * 0x10000 + 0x8000, m_input_addr * 0x10000 + 0x8005);
1916      space.unmap_write    (m_input_addr * 0x10000 + 0xc000, m_input_addr * 0x10000 + 0xc001);
1917   }
1918
1919   m_input_addr = data & 0xff;
1920
1921   // Add new memory ranges
1922   space.install_readwrite_handler (m_input_addr * 0x10000 + 0x4000, m_input_addr * 0x10000 + 0x4003, read16_delegate (FUNC(igs017_state::lhzb2a_magic_r),      this), write16_delegate (FUNC(igs017_state::lhzb2a_magic_w),      this));
1923   space.install_read_handler      (m_input_addr * 0x10000 + 0x8000, m_input_addr * 0x10000 + 0x8005, read16_delegate (FUNC(igs017_state::lhzb2a_input_r),      this));
1924   space.install_write_handler     (m_input_addr * 0x10000 + 0xc000, m_input_addr * 0x10000 + 0xc001, write16_delegate(FUNC(igs017_state::lhzb2a_input_addr_w), this));
1925}
1926
1927WRITE16_MEMBER(igs017_state::lhzb2a_input_select_w)
1928{
1929   if (ACCESSING_BITS_0_7)
1930   {
1931      m_input_select      =         data & 0x1f;   // keys
1932      m_hopper         =         data & 0x20;   // hopper motor
1933      coin_counter_w(machine(), 1,   data & 0x40);   // coin out counter
1934      coin_counter_w(machine(), 0,   data & 0x80);   // coin in  counter
1935   }
1936   if (ACCESSING_BITS_8_15)
1937   {
1938      okim6295_device *oki = machine().device<okim6295_device>("oki");
1939      oki->set_bank_base((data & 0x0100) ? 0x40000 : 0);
1940
1941      if ( data & 0x0fe00 )
1942         logerror("%s: warning, unknown bits written in input_select = %04x\n", machine().describe_context(), data);
1943   }
1944}
1945
1946static ADDRESS_MAP_START( lhzb2a, AS_PROGRAM, 16, igs017_state )
1947   AM_RANGE(0x000000, 0x07ffff) AM_ROM
1948   AM_RANGE(0x500000, 0x503fff) AM_RAM
1949//   AM_RANGE(0x910000, 0x910003) protection
1950   AM_RANGE(0xb02000, 0xb02fff) AM_READWRITE( spriteram_lsb_r, spriteram_lsb_w ) AM_BASE( m_spriteram )
1951   AM_RANGE(0xb03000, 0xb037ff) AM_RAM_WRITE( lhzb2a_paletteram_w ) AM_SHARE("paletteram")
1952   AM_RANGE(0xb04024, 0xb04025) AM_WRITE( video_disable_lsb_w )
1953   AM_RANGE(0xb04028, 0xb04029) AM_WRITE( irq2_enable_w )
1954   AM_RANGE(0xb0402a, 0xb0402b) AM_WRITE( irq1_enable_w )
1955   AM_RANGE(0xb08000, 0xb0bfff) AM_READWRITE( fg_lsb_r, fg_lsb_w ) AM_BASE( m_fg_videoram )
1956   AM_RANGE(0xb0c000, 0xb0ffff) AM_READWRITE( bg_lsb_r, bg_lsb_w ) AM_BASE( m_bg_videoram )
1957   AM_RANGE(0xb10000, 0xb10001) AM_DEVREADWRITE8("oki", okim6295_device, read, write, 0x00ff )
1958   AM_RANGE(0xb12000, 0xb12001) AM_WRITE( lhzb2a_input_select_w )
1959//  Inputs dynamically mapped at xx8000, protection at xx4000 (xx = f0 initially). xx written to xxc000
1960ADDRESS_MAP_END
1961
1962
1963// slqz2
1964
1965
1966WRITE16_MEMBER(igs017_state::slqz2_paletteram_w)
1967{
1968   COMBINE_DATA(&m_generic_paletteram_16[offset]);
1969
1970   int bgr = ((m_generic_paletteram_16[offset/2*2+1] & 0xff) << 8) | (m_generic_paletteram_16[offset/2*2+0] & 0xff);
1971
1972   // bitswap
1973   bgr = BITSWAP16(bgr, 15,14,9,4,11,10,12,3,7,6,5,8,13,2,1,0);
1974
1975   palette_set_color_rgb(machine(), offset/2, pal5bit(bgr >> 0), pal5bit(bgr >> 5), pal5bit(bgr >> 10));
1976}
1977
1978WRITE16_MEMBER(igs017_state::slqz2_magic_w)
1979{
1980   COMBINE_DATA(&m_igs_magic[offset]);
1981
1982   if (offset == 0)
1983      return;
1984
1985   switch(m_igs_magic[0])
1986   {
1987      case 0x00:
1988         if (ACCESSING_BITS_0_7)
1989         {
1990            okim6295_device *oki = machine().device<okim6295_device>("oki");
1991            oki->set_bank_base((data & 0x01) ? 0x40000 : 0);
1992
1993//            m_hopper         =         data & 0x20;   // hopper motor
1994//            coin_counter_w(machine(), 1,   data & 0x40);   // coin out counter
1995            coin_counter_w(machine(), 0,   data & 0x80);   // coin in  counter
1996
1997            if ( data & 0x7e )
1998               logerror("%s: warning, unknown bits written in oki bank = %04x\n", machine().describe_context(), data);
1999         }
2000         break;
2001
2002      default:
2003         logerror("%s: warning, writing to igs_magic %02x = %02x\n", machine().describe_context(), m_igs_magic[0], data);
2004   }
2005}
2006
2007READ16_MEMBER(igs017_state::slqz2_magic_r)
2008{
2009   switch(m_igs_magic[0])
2010   {
2011      case 0x00:
2012         return input_port_read(machine(), "PLAYER2");
2013      case 0x01:
2014         return input_port_read(machine(), "PLAYER1");
2015      case 0x02:
2016         return input_port_read(machine(), "BUTTONS");
2017
2018      default:
2019         logerror("%s: warning, reading with igs_magic = %02x\n", machine().describe_context(), m_igs_magic[0]);
2020         break;
2021   }
2022
2023   return 0xffff;
2024}
2025
2026static ADDRESS_MAP_START( slqz2, AS_PROGRAM, 16, igs017_state )
2027   AM_RANGE(0x000000, 0x07ffff) AM_ROM
2028   AM_RANGE(0x100000, 0x103fff) AM_RAM
2029   AM_RANGE(0x602000, 0x602003) AM_WRITE( slqz2_magic_w )
2030   AM_RANGE(0x602002, 0x602003) AM_READ( slqz2_magic_r )
2031   AM_RANGE(0x902000, 0x902fff) AM_READWRITE( spriteram_lsb_r, spriteram_lsb_w ) AM_BASE( m_spriteram )
2032   AM_RANGE(0x903000, 0x9037ff) AM_RAM_WRITE( slqz2_paletteram_w ) AM_SHARE("paletteram")
2033   AM_RANGE(0x904020, 0x904027) AM_DEVREAD8_LEGACY( "ppi8255", ppi8255_r, 0x00ff )
2034   AM_RANGE(0x904024, 0x904025) AM_WRITE( video_disable_lsb_w )
2035   AM_RANGE(0x904028, 0x904029) AM_WRITE( irq2_enable_w )
2036   AM_RANGE(0x90402a, 0x90402b) AM_WRITE( irq1_enable_w )
2037   AM_RANGE(0x908000, 0x90bfff) AM_READWRITE( fg_lsb_r, fg_lsb_w ) AM_BASE( m_fg_videoram )
2038   AM_RANGE(0x90c000, 0x90ffff) AM_READWRITE( bg_lsb_r, bg_lsb_w ) AM_BASE( m_bg_videoram )
2039   AM_RANGE(0x910000, 0x910001) AM_DEVREADWRITE8("oki", okim6295_device, read, write, 0x00ff )
2040ADDRESS_MAP_END
2041
2042
16352043/***************************************************************************
16362044                                Input Ports
16372045***************************************************************************/
r14862r14863
17542162
17552163INPUT_PORTS_END
17562164
2165static INPUT_PORTS_START( lhzb2 )
2166
2167   PORT_START("DSW1")
2168   PORT_DIPNAME( 0x03, 0x03, DEF_STR( Coinage ) )
2169   PORT_DIPSETTING(    0x03, DEF_STR( 1C_1C ) )
2170   PORT_DIPSETTING(    0x02, DEF_STR( 1C_2C ) )
2171   PORT_DIPSETTING(    0x01, DEF_STR( 1C_3C ) )
2172   PORT_DIPSETTING(    0x00, DEF_STR( 1C_5C ) )
2173   PORT_DIPNAME( 0x0c, 0x0c, "Credits Per Note" )
2174   PORT_DIPSETTING(    0x0c, "10" )
2175   PORT_DIPSETTING(    0x08, "20" )
2176   PORT_DIPSETTING(    0x04, "50" )
2177   PORT_DIPSETTING(    0x00, "100" )
2178   PORT_DIPNAME( 0x10, 0x10, "Max Note Credits" )
2179   PORT_DIPSETTING(    0x10, "1000" )
2180   PORT_DIPSETTING(    0x00, "2000" )
2181   PORT_DIPNAME( 0x20, 0x20, "Money Type" )
2182   PORT_DIPSETTING(    0x20, "Coins" )
2183   PORT_DIPSETTING(    0x00, "Notes" )
2184   PORT_DIPNAME( 0x40, 0x40, "Pay Out Type" )
2185   PORT_DIPSETTING(    0x40, "Coins" )
2186   PORT_DIPSETTING(    0x00, "Notes" )
2187   PORT_DIPNAME( 0x80, 0x80, DEF_STR( Demo_Sounds ) )
2188   PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
2189   PORT_DIPSETTING(    0x80, DEF_STR( On ) )
2190
2191   PORT_START("DSW2")
2192   PORT_DIPNAME( 0x03, 0x03, "Min Bet" )
2193   PORT_DIPSETTING(    0x03, "500" )
2194   PORT_DIPSETTING(    0x02, "1000" )
2195   PORT_DIPSETTING(    0x01, "1500" )
2196   PORT_DIPSETTING(    0x00, "2000" )
2197   PORT_DIPNAME( 0x0c, 0x0c, DEF_STR( Unknown ) )
2198   PORT_DIPSETTING(    0x0c, "1" )
2199   PORT_DIPSETTING(    0x08, "2" )
2200   PORT_DIPSETTING(    0x04, "3" )
2201   PORT_DIPSETTING(    0x00, "5" )
2202   PORT_DIPNAME( 0x10, 0x10, "Bonus Round" )
2203   PORT_DIPSETTING(    0x00, DEF_STR( No ) )
2204   PORT_DIPSETTING(    0x10, DEF_STR( Yes ) )
2205   PORT_DIPNAME( 0x20, 0x20, "Number Type" )
2206   PORT_DIPSETTING(    0x20, "Number" )
2207   PORT_DIPSETTING(    0x00, "Dice" )
2208   PORT_DIPNAME( 0x40, 0x40, "Symbols" )
2209   PORT_DIPSETTING(    0x40, DEF_STR( Off ) )
2210   PORT_DIPSETTING(    0x00, DEF_STR( On ) )   // pigs, apples
2211   PORT_DIPNAME( 0x80, 0x80, DEF_STR( Unknown ) )
2212   PORT_DIPSETTING(    0x80, DEF_STR( Off ) )
2213   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
2214
2215   PORT_START("COINS")
2216   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_SPECIAL   )   // hopper switch (unimplemented)
2217   PORT_SERVICE_NO_TOGGLE( 0x02,   IP_ACTIVE_LOW ) // service mode (keep pressed during boot too)
2218   PORT_BIT( 0x04, IP_ACTIVE_LOW,  IPT_SERVICE1  ) PORT_NAME("Statistics")   // press with the above for sound test
2219   PORT_BIT( 0x08, IP_ACTIVE_LOW,  IPT_COIN1     ) PORT_IMPULSE(5)   // coin error otherwise
2220   PORT_BIT( 0x10, IP_ACTIVE_LOW,  IPT_OTHER     ) PORT_NAME("Pay Out") PORT_CODE(KEYCODE_O)
2221   PORT_BIT( 0x20, IP_ACTIVE_LOW,  IPT_SERVICE3  ) // ? (shown in service mode)
2222   PORT_BIT( 0x40, IP_ACTIVE_LOW,  IPT_UNKNOWN   )
2223   PORT_BIT( 0x80, IP_ACTIVE_LOW,  IPT_UNKNOWN   )
2224
2225   PORT_START("KEY0")
2226   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_MAHJONG_A )
2227   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_MAHJONG_E )
2228   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_MAHJONG_I )
2229   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_MAHJONG_M )
2230   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_MAHJONG_KAN )
2231   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_START1 )
2232   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNKNOWN )
2233   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN )
2234
2235   PORT_START("KEY1")
2236   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_MAHJONG_B )
2237   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_MAHJONG_F )
2238   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_MAHJONG_J )
2239   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_MAHJONG_N )
2240   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_MAHJONG_REACH )
2241   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_MAHJONG_BET )
2242   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNKNOWN )
2243   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN )
2244
2245   PORT_START("KEY2")
2246   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_MAHJONG_C )
2247   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_MAHJONG_G )
2248   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_MAHJONG_K )
2249   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_MAHJONG_CHI )
2250   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_MAHJONG_RON )
2251   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_UNKNOWN )
2252   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNKNOWN )
2253   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN )
2254
2255   PORT_START("KEY3")
2256   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_MAHJONG_D )
2257   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_MAHJONG_H )
2258   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_MAHJONG_L )
2259   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_MAHJONG_PON )
2260   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_UNKNOWN )
2261   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_UNKNOWN )
2262   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNKNOWN )
2263   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN )
2264
2265   PORT_START("KEY4")
2266   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_MAHJONG_LAST_CHANCE )
2267   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_MAHJONG_SCORE )
2268   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_MAHJONG_DOUBLE_UP )
2269   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_UNKNOWN )
2270   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_MAHJONG_BIG )
2271   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_MAHJONG_SMALL )
2272   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNKNOWN )
2273   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN )
2274
2275INPUT_PORTS_END
2276
2277static INPUT_PORTS_START( lhzb2a )
2278
2279   PORT_START("DSW1")
2280   PORT_DIPNAME( 0x03, 0x03, DEF_STR( Coinage ) )
2281   PORT_DIPSETTING(    0x03, DEF_STR( 1C_1C ) )
2282   PORT_DIPSETTING(    0x02, DEF_STR( 1C_2C ) )
2283   PORT_DIPSETTING(    0x01, DEF_STR( 1C_3C ) )
2284   PORT_DIPSETTING(    0x00, DEF_STR( 1C_5C ) )
2285   PORT_DIPNAME( 0x0c, 0x0c, "Credits Per Note" )
2286   PORT_DIPSETTING(    0x0c, "10" )
2287   PORT_DIPSETTING(    0x08, "20" )
2288   PORT_DIPSETTING(    0x04, "50" )
2289   PORT_DIPSETTING(    0x00, "100" )
2290   PORT_DIPNAME( 0x10, 0x10, "Max Note Credits" )
2291   PORT_DIPSETTING(    0x10, "1000" )
2292   PORT_DIPSETTING(    0x00, "2000" )
2293   PORT_DIPNAME( 0x20, 0x20, "Money Type" )
2294   PORT_DIPSETTING(    0x20, "Coins" )
2295   PORT_DIPSETTING(    0x00, "Notes" )
2296   PORT_DIPNAME( 0x40, 0x40, "Pay Out Type" )
2297   PORT_DIPSETTING(    0x40, "Coins" )
2298   PORT_DIPSETTING(    0x00, "Notes" )
2299   PORT_DIPNAME( 0x80, 0x80, DEF_STR( Demo_Sounds ) )
2300   PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
2301   PORT_DIPSETTING(    0x80, DEF_STR( On ) )
2302
2303   PORT_START("DSW2")
2304   PORT_DIPNAME( 0x03, 0x03, "Min Bet" )
2305   PORT_DIPSETTING(    0x03, "500" )
2306   PORT_DIPSETTING(    0x02, "1000" )
2307   PORT_DIPSETTING(    0x01, "1500" )
2308   PORT_DIPSETTING(    0x00, "2000" )
2309   PORT_DIPNAME( 0x0c, 0x0c, DEF_STR( Unknown ) )
2310   PORT_DIPSETTING(    0x0c, "1" )
2311   PORT_DIPSETTING(    0x08, "2" )
2312   PORT_DIPSETTING(    0x04, "3" )
2313   PORT_DIPSETTING(    0x00, "5" )
2314   PORT_DIPNAME( 0x10, 0x10, "Bonus Round" )
2315   PORT_DIPSETTING(    0x00, DEF_STR( No ) )
2316   PORT_DIPSETTING(    0x10, DEF_STR( Yes ) )
2317   PORT_DIPNAME( 0x20, 0x20, "Number Type" )
2318   PORT_DIPSETTING(    0x20, "Number" )
2319   PORT_DIPSETTING(    0x00, "Dice" )
2320   PORT_DIPNAME( 0x40, 0x40, "Symbols" )
2321   PORT_DIPSETTING(    0x40, DEF_STR( Off ) )
2322   PORT_DIPSETTING(    0x00, DEF_STR( On ) )   // pigs, apples
2323   PORT_DIPNAME( 0x80, 0x80, DEF_STR( Unknown ) )
2324   PORT_DIPSETTING(    0x80, DEF_STR( Off ) )
2325   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
2326
2327   PORT_START("COINS")
2328   PORT_BIT( 0x01, IP_ACTIVE_LOW,  IPT_SERVICE2  )   // shown in test mode
2329   PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_SPECIAL   )   // hopper switch
2330   PORT_SERVICE_NO_TOGGLE( 0x04,   IP_ACTIVE_LOW )   // keep pressed while booting
2331   PORT_BIT( 0x08, IP_ACTIVE_LOW,  IPT_SERVICE1  ) PORT_NAME("Statistics") // press with the above for sound test
2332   PORT_BIT( 0x10, IP_ACTIVE_LOW,  IPT_COIN1     ) PORT_IMPULSE(2)
2333   PORT_BIT( 0x20, IP_ACTIVE_LOW,  IPT_OTHER     ) PORT_NAME("Pay Out") PORT_CODE(KEYCODE_O)
2334
2335   PORT_START("KEY0")
2336   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_MAHJONG_A )
2337   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_MAHJONG_E )
2338   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_MAHJONG_I )
2339   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_MAHJONG_M )
2340   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_MAHJONG_KAN )
2341   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_START1 )
2342   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNKNOWN )
2343   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN )
2344
2345   PORT_START("KEY1")
2346   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_MAHJONG_B )
2347   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_MAHJONG_F )
2348   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_MAHJONG_J )
2349   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_MAHJONG_N )
2350   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_MAHJONG_REACH )
2351   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_MAHJONG_BET )
2352   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNKNOWN )
2353   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN )
2354
2355   PORT_START("KEY2")
2356   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_MAHJONG_C )
2357   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_MAHJONG_G )
2358   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_MAHJONG_K )
2359   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_MAHJONG_CHI )
2360   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_MAHJONG_RON )
2361   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_UNKNOWN )
2362   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNKNOWN )
2363   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN )
2364
2365   PORT_START("KEY3")
2366   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_MAHJONG_D )
2367   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_MAHJONG_H )
2368   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_MAHJONG_L )
2369   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_MAHJONG_PON )
2370   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_UNKNOWN )
2371   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_UNKNOWN )
2372   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNKNOWN )
2373   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN )
2374
2375   PORT_START("KEY4")
2376   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_MAHJONG_LAST_CHANCE )
2377   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_MAHJONG_SCORE )
2378   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_MAHJONG_DOUBLE_UP )
2379   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_UNKNOWN )
2380   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_MAHJONG_BIG )
2381   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_MAHJONG_SMALL )
2382   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNKNOWN )
2383   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN )
2384
2385INPUT_PORTS_END
2386
17572387static INPUT_PORTS_START( mgcs )
17582388
17592389   // DSWs don't work: they are read through a protection device (IGS029? see code at 1CF16)
r14862r14863
21282758
21292759INPUT_PORTS_END
21302760
2761static INPUT_PORTS_START( slqz2 )
2762
2763   PORT_START("DSW1")
2764   PORT_DIPNAME( 0x03, 0x03, DEF_STR( Coinage ) )
2765   PORT_DIPSETTING(    0x03, DEF_STR( 1C_1C ) )
2766   PORT_DIPSETTING(    0x02, DEF_STR( 1C_2C ) )
2767   PORT_DIPSETTING(    0x01, DEF_STR( 1C_3C ) )
2768   PORT_DIPSETTING(    0x00, DEF_STR( 1C_5C ) )
2769   PORT_DIPNAME( 0x0c, 0x0c, "Credits Per Note" )
2770   PORT_DIPSETTING(    0x0c, "10" )
2771   PORT_DIPSETTING(    0x08, "20" )
2772   PORT_DIPSETTING(    0x04, "50" )
2773   PORT_DIPSETTING(    0x00, "100" )
2774   PORT_DIPNAME( 0x10, 0x10, "Max Note Credits" )
2775   PORT_DIPSETTING(    0x10, "1000" )
2776   PORT_DIPSETTING(    0x00, "2000" )
2777   PORT_DIPNAME( 0x20, 0x20, "Money Type" )
2778   PORT_DIPSETTING(    0x20, "Coins" )
2779   PORT_DIPSETTING(    0x00, "Notes" )
2780   PORT_DIPNAME( 0x40, 0x40, "Pay Out Type" )
2781   PORT_DIPSETTING(    0x40, "Coins" )
2782   PORT_DIPSETTING(    0x00, "Notes" )
2783   PORT_DIPNAME( 0x80, 0x80, DEF_STR( Demo_Sounds ) )
2784   PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
2785   PORT_DIPSETTING(    0x80, DEF_STR( On ) )
2786
2787   PORT_START("DSW2")
2788   PORT_DIPNAME( 0x03, 0x03, "Min Bet" )
2789   PORT_DIPSETTING(    0x03, "500" )
2790   PORT_DIPSETTING(    0x02, "1000" )
2791   PORT_DIPSETTING(    0x01, "1500" )
2792   PORT_DIPSETTING(    0x00, "2000" )
2793   PORT_DIPNAME( 0x0c, 0x0c, DEF_STR( Unknown ) )
2794   PORT_DIPSETTING(    0x0c, "1" )
2795   PORT_DIPSETTING(    0x08, "2" )
2796   PORT_DIPSETTING(    0x04, "3" )
2797   PORT_DIPSETTING(    0x00, "5" )
2798   PORT_DIPNAME( 0x10, 0x10, "Bonus Round" )
2799   PORT_DIPSETTING(    0x00, DEF_STR( No ) )
2800   PORT_DIPSETTING(    0x10, DEF_STR( Yes ) )
2801   PORT_DIPNAME( 0x20, 0x20, "Number Type" )
2802   PORT_DIPSETTING(    0x20, "Number" )
2803   PORT_DIPSETTING(    0x00, "Dice" )
2804   PORT_DIPNAME( 0x40, 0x40, "Symbols" )
2805   PORT_DIPSETTING(    0x40, DEF_STR( Off ) )
2806   PORT_DIPSETTING(    0x00, DEF_STR( On ) )   // pigs, apples
2807   PORT_DIPNAME( 0x80, 0x80, DEF_STR( Unknown ) )
2808   PORT_DIPSETTING(    0x80, DEF_STR( Off ) )
2809   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
2810
2811   PORT_START("COINS")
2812   PORT_BIT( 0x01, IP_ACTIVE_LOW,  IPT_SPECIAL   )   // hopper switch (unimplemented)
2813   PORT_SERVICE_NO_TOGGLE( 0x02,   IP_ACTIVE_LOW ) // service mode (keep pressed during boot too)
2814   PORT_BIT( 0x04, IP_ACTIVE_LOW,  IPT_SERVICE1  ) PORT_NAME("Statistics")   // press with the above for sound test
2815   PORT_BIT( 0x08, IP_ACTIVE_LOW,  IPT_COIN1     ) PORT_IMPULSE(5)   // coin error otherwise
2816   PORT_BIT( 0x10, IP_ACTIVE_LOW,  IPT_OTHER     ) PORT_NAME("Pay Out") PORT_CODE(KEYCODE_O)
2817   PORT_BIT( 0x20, IP_ACTIVE_LOW,  IPT_UNKNOWN   )
2818   PORT_BIT( 0x40, IP_ACTIVE_LOW,  IPT_BUTTON2   )
2819   PORT_BIT( 0x80, IP_ACTIVE_LOW,  IPT_BUTTON3   )
2820
2821   PORT_START("PLAYER1")
2822   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_START1         )   PORT_NAME("Start / Don Den")
2823   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_UP    )
2824   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN  )
2825   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT  )
2826   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT )
2827   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_BUTTON1        ) PORT_NAME( "Help / Big" )
2828   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNKNOWN        )
2829   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN        )
2830
2831   PORT_START("PLAYER2")
2832   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_START2         )   PORT_NAME( "Bet" )
2833   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_UP    ) PORT_PLAYER(2)
2834   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN  ) PORT_PLAYER(2)
2835   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT  ) PORT_PLAYER(2)
2836   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT ) PORT_PLAYER(2)
2837   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_BUTTON1        ) PORT_PLAYER(2)
2838   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_BUTTON2        ) PORT_PLAYER(2)
2839   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_BUTTON3        ) PORT_PLAYER(2)
2840
2841   PORT_START("BUTTONS")
2842   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_OTHER ) PORT_NAME("0") PORT_CODE(KEYCODE_1_PAD)
2843   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_OTHER ) PORT_NAME("0") PORT_CODE(KEYCODE_2_PAD)
2844   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_OTHER ) PORT_NAME("0") PORT_CODE(KEYCODE_3_PAD)
2845   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_OTHER ) PORT_NAME("0") PORT_CODE(KEYCODE_4_PAD)
2846   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_OTHER ) PORT_NAME("0") PORT_CODE(KEYCODE_5_PAD)
2847   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_OTHER ) PORT_NAME("0") PORT_CODE(KEYCODE_6_PAD)
2848   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_OTHER ) PORT_NAME("0") PORT_CODE(KEYCODE_7_PAD)
2849   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_OTHER ) PORT_NAME("0") PORT_CODE(KEYCODE_8_PAD)
2850
2851INPUT_PORTS_END
2852
21312853static INPUT_PORTS_START( tjsb )
21322854
21332855   PORT_START("DSW1")
r14862r14863
24143136
24153137
24163138
3139// lhzb2
3140
3141static const ppi8255_interface lhzb2_ppi8255_intf =
3142{
3143   DEVCB_INPUT_PORT("COINS"),   // Port A read
3144   DEVCB_INPUT_PORT("DSW1"),   // Port B read
3145   DEVCB_INPUT_PORT("DSW2"),   // Port C read
3146
3147   DEVCB_NULL,               // Port A write
3148   DEVCB_NULL,               // Port B write
3149   DEVCB_NULL               // Port C write
3150};
3151
3152static MACHINE_CONFIG_START( lhzb2, igs017_state )
3153   MCFG_CPU_ADD("maincpu", M68000, XTAL_22MHz / 2)
3154   MCFG_CPU_PROGRAM_MAP(lhzb2)
3155   MCFG_TIMER_ADD_SCANLINE("scantimer", mgcs_interrupt, "screen", 0, 1)
3156
3157   MCFG_MACHINE_RESET(mgcs)
3158
3159   MCFG_PPI8255_ADD( "ppi8255", lhzb2_ppi8255_intf )
3160
3161   /* video hardware */
3162   MCFG_SCREEN_ADD("screen", RASTER)
3163   MCFG_SCREEN_REFRESH_RATE(60)
3164   MCFG_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(0))
3165   MCFG_SCREEN_SIZE(512, 256)
3166   MCFG_SCREEN_VISIBLE_AREA(0, 512-1, 0, 240-1)
3167   MCFG_SCREEN_UPDATE_STATIC(igs017)
3168
3169   MCFG_GFXDECODE(igs017_swapped)
3170   MCFG_PALETTE_LENGTH(0x100*2)
3171
3172   MCFG_VIDEO_START(igs017)
3173   MCFG_VIDEO_RESET(igs017)
3174
3175   /* sound hardware */
3176   MCFG_SPEAKER_STANDARD_MONO("mono")
3177   MCFG_OKIM6295_ADD("oki", XTAL_8MHz / 8, OKIM6295_PIN7_HIGH)
3178   MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.5)
3179MACHINE_CONFIG_END
3180
3181
3182
3183// lhzb2a
3184
3185static MACHINE_RESET( lhzb2a )
3186{
3187   igs017_state *state = machine.driver_data<igs017_state>();
3188   MACHINE_RESET_CALL( mgcs );
3189   state->lhzb2a_input_addr_w(*state->m_maincpu->memory().space(AS_PROGRAM), 0, 0xf0);
3190}
3191
3192static MACHINE_CONFIG_START( lhzb2a, igs017_state )
3193   MCFG_CPU_ADD("maincpu", M68000, XTAL_22MHz/2)
3194   MCFG_CPU_PROGRAM_MAP(lhzb2a)
3195   MCFG_TIMER_ADD_SCANLINE("scantimer", mgcs_interrupt, "screen", 0, 1)
3196
3197   MCFG_MACHINE_RESET(lhzb2a)
3198
3199//   MCFG_PPI8255_ADD( "ppi8255", sdmg2_ppi8255_intf )
3200
3201   /* video hardware */
3202   MCFG_SCREEN_ADD("screen", RASTER)
3203   MCFG_SCREEN_REFRESH_RATE(60)   // VSync 60Hz, HSync 15.3kHz
3204   MCFG_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(0))
3205   MCFG_SCREEN_SIZE(512, 256)
3206   MCFG_SCREEN_VISIBLE_AREA(0, 512-1, 0, 256-16-1)
3207   MCFG_SCREEN_UPDATE_STATIC(igs017)
3208
3209   MCFG_GFXDECODE(igs017_swapped)
3210   MCFG_PALETTE_LENGTH(0x100*2)
3211
3212   MCFG_VIDEO_START(igs017)
3213   MCFG_VIDEO_RESET(igs017)
3214
3215   /* sound hardware */
3216   MCFG_SPEAKER_STANDARD_MONO("mono")
3217   MCFG_OKIM6295_ADD("oki", XTAL_22MHz / 22, OKIM6295_PIN7_HIGH)
3218   MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.5)
3219MACHINE_CONFIG_END
3220
3221
3222
3223// slqz2
3224
3225static MACHINE_CONFIG_START( slqz2, igs017_state )
3226   MCFG_CPU_ADD("maincpu", M68000, XTAL_22MHz / 2)
3227   MCFG_CPU_PROGRAM_MAP(slqz2)
3228   MCFG_TIMER_ADD_SCANLINE("scantimer", mgcs_interrupt, "screen", 0, 1)
3229
3230   MCFG_MACHINE_RESET(mgcs)
3231
3232   MCFG_PPI8255_ADD( "ppi8255", lhzb2_ppi8255_intf )
3233
3234   /* video hardware */
3235   MCFG_SCREEN_ADD("screen", RASTER)
3236   MCFG_SCREEN_REFRESH_RATE(60)
3237   MCFG_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(0))
3238   MCFG_SCREEN_SIZE(512, 256)
3239   MCFG_SCREEN_VISIBLE_AREA(0, 512-1, 0, 240-1)
3240   MCFG_SCREEN_UPDATE_STATIC(igs017)
3241
3242   MCFG_GFXDECODE(igs017)
3243   MCFG_PALETTE_LENGTH(0x100*2)
3244
3245   MCFG_VIDEO_START(igs017)
3246   MCFG_VIDEO_RESET(igs017)
3247
3248   /* sound hardware */
3249   MCFG_SPEAKER_STANDARD_MONO("mono")
3250   MCFG_OKIM6295_ADD("oki", XTAL_8MHz / 8, OKIM6295_PIN7_HIGH)
3251   MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.5)
3252MACHINE_CONFIG_END
3253
3254
3255
24173256// sdmg2
24183257
24193258static const ppi8255_interface sdmg2_ppi8255_intf =
r14862r14863
27933632   ROM_LOAD16_WORD_SWAP( "p0900.u25", 0x00000, 0x80000,CRC(43366f51) SHA1(48dd965dceff7de15b43c2140226a8b17a792dbc) )
27943633
27953634   ROM_REGION( 0x280000, "sprites", 0 )
2796   ROM_LOAD( "m0901.u5", 0x000000, 0x200000, CRC(9699db24) SHA1(50fc2f173c20b48d10595f01f1e9545f1b13a61b) )
2797   ROM_LOAD( "m0902.u4", 0x200000, 0x080000, CRC(3298b13b) SHA1(13b21ddeed368b7f4fea1408c8fc511244342faf) )
3635   ROM_LOAD( "m0901.u5", 0x000000, 0x200000, CRC(9699db24) SHA1(50fc2f173c20b48d10595f01f1e9545f1b13a61b) )   // FIXED BITS (xxxxxxxx0xxxxxxx)
3636   ROM_LOAD( "m0902.u4", 0x200000, 0x080000, CRC(3298b13b) SHA1(13b21ddeed368b7f4fea1408c8fc511244342faf) )   // FIXED BITS (xxxxxxxx0xxxxxxx)
27983637
27993638   ROM_REGION( 0x20000, "tilemaps", 0 )
28003639   ROM_LOAD( "text.u6", 0x000000, 0x020000, CRC(cb34cbc0) SHA1(ceedbdda085fd1acc9a575502bdf7cf998f54f05) )
r14862r14863
28533692   ROM_REGION( 0x10000, "igs022", 0 )   // INTERNATIONAL GAMES SYSTEM CO.,LTD
28543693   ROM_LOAD( "m1104.u11",0x0000, 0x10000, CRC(794d0276) SHA1(ac903d2faa3fb315438dc8da22c5337611a8790d) )
28553694
2856   ROM_REGION( 0x200000, "sprites", 0 )   // adddress scrambling
2857   ROM_LOAD16_WORD_SWAP( "m1101.u6", 0x000000, 0x200000, CRC(fed09cd6) SHA1(0658a97983f8ba408126e79889cc58323f2d99ba) )
3695   ROM_REGION( 0x400000, "sprites", 0 )   // adddress scrambling
3696   ROM_LOAD16_WORD_SWAP( "m1101.u6", 0x000000, 0x400000, CRC(0114e9d1) SHA1(5b16170d3cd8b8e1662c949b7234fbdd2ca927f7) )   // FIXED BITS (0xxxxxxxxxxxxxxx)
28583697
2859   ROM_REGION( 0x40000, "tilemaps", 0 )   // adddress scrambling
2860   ROM_LOAD( "m1103.u8", 0x00000, 0x40000, CRC(89d0b81c) SHA1(b8d294a143e5cc9466b544cb70e43a7ce3450ace) )
3698   ROM_REGION( 0x80000, "tilemaps", 0 )   // adddress scrambling
3699   ROM_LOAD( "m1103.u8", 0x00000, 0x80000, CRC(4d3776b4) SHA1(fa9b311b1a6ad56e136b66d090bc62ed5003b2f2) )
28613700
28623701   ROM_REGION( 0x80000, "oki", 0 )
28633702   ROM_LOAD( "s1102.u23", 0x00000, 0x80000, CRC(51ffe245) SHA1(849011b186096add657ab20d49d260ec23363ef3) )
r14862r14863
28693708   ROM_REGION( 0x80000, "maincpu", 0 )
28703709   ROM_LOAD16_WORD_SWAP( "p-4096", 0x00000, 0x80000, CRC(41293f32) SHA1(df4e993f4a458729ade13981e58f32d8116c0082) )
28713710
2872   ROM_REGION( 0x200000, "sprites", 0 )   // adddress scrambling
2873   ROM_LOAD16_WORD_SWAP( "m1101.u6", 0x000000, 0x200000, CRC(fed09cd6) SHA1(0658a97983f8ba408126e79889cc58323f2d99ba) )
3711   ROM_REGION( 0x400000, "sprites", 0 )   // adddress scrambling
3712   ROM_LOAD16_WORD_SWAP( "m1101.u6", 0x000000, 0x400000, CRC(0114e9d1) SHA1(5b16170d3cd8b8e1662c949b7234fbdd2ca927f7) )   // FIXED BITS (0xxxxxxxxxxxxxxx)
28743713
28753714   ROM_REGION( 0x80000, "tilemaps", 0 )   // adddress scrambling
2876   ROM_LOAD( "m1103", 0x000000, 0x080000, CRC(4d3776b4) SHA1(fa9b311b1a6ad56e136b66d090bc62ed5003b2f2) )
3715   ROM_LOAD( "m1103.u8", 0x00000, 0x80000, CRC(4d3776b4) SHA1(fa9b311b1a6ad56e136b66d090bc62ed5003b2f2) )
28773716
28783717   ROM_REGION( 0x80000, "oki", 0 )
28793718   ROM_LOAD( "s1102.u23", 0x00000, 0x80000, CRC(51ffe245) SHA1(849011b186096add657ab20d49d260ec23363ef3) )
r14862r14863
29283767   ROM_REGION( 0x10000, "igs022", 0 )   // INTERNATIONAL GAMES SYSTEM CO.,LTD
29293768   ROM_LOAD( "m1103.u12", 0x00000, 0x10000, CRC(9f3b8d65) SHA1(5ee1ad025474399c2826f21d970e76f25d0fa1fd) )
29303769
2931   ROM_REGION( 0x200000, "sprites", 0 )   // adddress scrambling
2932   ROM_LOAD16_WORD_SWAP( "m1101.u4", 0x000000, 0x200000, CRC(fed09cd6) SHA1(0658a97983f8ba408126e79889cc58323f2d99ba) ) // = m1101.u6 Mahjong Long Hu Zheng Ba 2
3770   ROM_REGION( 0x400000, "sprites", 0 )   // adddress scrambling
3771   ROM_LOAD16_WORD_SWAP( "m1101.u4", 0x000000, 0x400000, CRC(0114e9d1) SHA1(5b16170d3cd8b8e1662c949b7234fbdd2ca927f7) )   // FIXED BITS (0xxxxxxxxxxxxxxx)
29333772
29343773   ROM_REGION( 0x80000, "tilemaps", 0 )   // light adddress scrambling
29353774   ROM_LOAD( "text.u6", 0x00000, 0x80000, CRC(40d21adf) SHA1(18b202d6330ac89026bec2c9c8224b52540dd48d) )
r14862r14863
31323971
31333972GAME( 1996,  iqblocka, iqblock, iqblocka, iqblocka, iqblocka, ROT0, "IGS",              "Shu Zi Le Yuan (V127M)",                      GAME_NOT_WORKING | GAME_UNEMULATED_PROTECTION )
31343973GAME( 1996,  iqblockf, iqblock, iqblocka, iqblocka, iqblockf, ROT0, "IGS",              "Shu Zi Le Yuan (V113FR)",                     GAME_NOT_WORKING | GAME_UNEMULATED_PROTECTION )
3135GAME( 1997,  tjsb,     0,       tjsb,     tjsb,     tjsb,     ROT0, "IGS",              "Mahjong Tian Jiang Shen Bing (V137C)",        GAME_UNEMULATED_PROTECTION )
3136GAME( 1997,  sdmg2,    0,       sdmg2,    sdmg2,    sdmg2,    ROT0, "IGS",              "Mahjong Super Da Man Guan II (China, V754C)", 0 )
31373974GAME( 1997,  mgdh,     0,       mgdha,    mgdh,     mgdh,     ROT0, "IGS",              "Mahjong Man Guan Da Heng (Taiwan, V125T1)",   0 )
31383975GAME( 1997,  mgdha,    mgdh,    mgdha,    mgdh ,    mgdha,    ROT0, "IGS",              "Mahjong Man Guan Da Heng (Taiwan, V123T1)",   0 )
3976GAME( 1997,  sdmg2,    0,       sdmg2,    sdmg2,    sdmg2,    ROT0, "IGS",              "Mahjong Super Da Man Guan II (China, V754C)", 0 )
3977GAME( 1997,  tjsb,     0,       tjsb,     tjsb,     tjsb,     ROT0, "IGS",              "Mahjong Tian Jiang Shen Bing (V137C)",        GAME_UNEMULATED_PROTECTION )
31393978GAME( 1998,  mgcs,     0,       mgcs,     mgcs,     mgcs,     ROT0, "IGS",              "Mahjong Man Guan Cai Shen (V103CS)",          GAME_NOT_WORKING | GAME_UNEMULATED_PROTECTION | GAME_IMPERFECT_SOUND )
3140GAME( 1998,  lhzb2,    0,       sdmg2,    sdmg2,    lhzb2,    ROT0, "IGS",              "Mahjong Long Hu Zheng Ba 2 (set 1)",          GAME_NOT_WORKING | GAME_UNEMULATED_PROTECTION )
3141GAME( 1998,  lhzb2a,   lhzb2,   sdmg2,    sdmg2,    lhzb2a,   ROT0, "IGS",              "Mahjong Long Hu Zheng Ba 2 (set 2)",          GAME_NOT_WORKING | GAME_UNEMULATED_PROTECTION )
3142GAME( 1998,  slqz2,    0,       sdmg2,    sdmg2,    slqz2,    ROT0, "IGS",              "Mahjong Shuang Long Qiang Zhu 2",             GAME_NOT_WORKING | GAME_UNEMULATED_PROTECTION )
3979GAME( 1998,  lhzb2,    0,       lhzb2,    lhzb2,     lhzb2,   ROT0, "IGS",              "Mahjong Long Hu Zheng Ba 2 (set 1)",          GAME_NOT_WORKING | GAME_UNEMULATED_PROTECTION )
3980GAME( 1998,  lhzb2a,   lhzb2,   lhzb2a,   lhzb2a,    lhzb2a,  ROT0, "IGS",              "Mahjong Long Hu Zheng Ba 2 (VS221M)",         GAME_NOT_WORKING | GAME_UNEMULATED_PROTECTION )
3981GAME( 1998,  slqz2,    0,       slqz2,    slqz2,    slqz2,    ROT0, "IGS",              "Mahjong Shuang Long Qiang Zhu 2 (VS203J)",    GAME_NOT_WORKING | GAME_UNEMULATED_PROTECTION )
31433982GAME( 1999?, tarzan,   0,       iqblocka, iqblocka, tarzan,   ROT0, "IGS",              "Tarzan (V109C)",                              GAME_NOT_WORKING )
31443983GAME( 1999?, tarzana,  tarzan,  iqblocka, iqblocka, tarzana,  ROT0, "IGS",              "Tarzan (V107)",                               GAME_NOT_WORKING )
31453984GAME( 2000?, starzan,  0,       iqblocka, iqblocka, starzan,  ROT0, "IGS / G.F. Gioca", "Super Tarzan (Italy, V100I)",                 GAME_NOT_WORKING )
src/mame/drivers/system1.c
r14862r14863
48424842GAME( 1986, wboyo,      wboy,     sys1pio,  wboy,      wboyo,    ROT0,   "Escape (Sega license)", "Wonder Boy (set 1, 315-5135)", GAME_SUPPORTS_SAVE )
48434843GAME( 1986, wboy3,      wboy,     sys1pio,  wboy3,     wboyo,    ROT0,   "Escape (Sega license)", "Wonder Boy (set 3, 315-5135)", GAME_SUPPORTS_SAVE )
48444844GAME( 1986, wboy4,      wboy,     sys1pio,  wboy,      4dwarrio, ROT0,   "Escape (Sega license)", "Wonder Boy (315-5162, 4-D Warriors Conversion)", GAME_SUPPORTS_SAVE )
4845GAME( 1986, wboy5,      wboy,     sys1pio,  wboy3,     wboyo,    ROT0,   "Escape (Sega license)", "Wonder Boy (set 5, bootleg)", GAME_SUPPORTS_SAVE )
48464845GAME( 1986, wboyu,      wboy,     sys1pio,  wboyu,     bank00,   ROT0,   "Escape (Sega license)", "Wonder Boy (prototype?)", GAME_SUPPORTS_SAVE ) // appears to be a very early / unfinished version.
4847GAME( 1986, wboyub,     wboy,     sys1pio,  wboy,      wboyo,    ROT0,   "bootleg", "Wonder Boy (US bootleg)", GAME_SUPPORTS_SAVE | GAME_NOT_WORKING )
4848GAME( 1987, blockgal,   0,        sys1pio,  blockgal,  blockgal, ROT90,  "Sega / Vic Tokai", "Block Gal (MC-8123B, 317-0029)", GAME_SUPPORTS_SAVE)
4846GAME( 1986, wboy5,      wboy,     sys1pio,  wboy3,     wboyo,    ROT0,   "bootleg",         "Wonder Boy (set 5, bootleg)", GAME_SUPPORTS_SAVE )
4847GAME( 1986, wboyub,     wboy,     sys1pio,  wboy,      wboyo,    ROT0,   "bootleg",         "Wonder Boy (US bootleg)", GAME_SUPPORTS_SAVE | GAME_NOT_WORKING )
4848GAME( 1987, blockgal,   0,        sys1pio,  blockgal,  blockgal, ROT90,  "Sega / Vic Tokai","Block Gal (MC-8123B, 317-0029)", GAME_SUPPORTS_SAVE)
48494849
48504850/* PIO-based System 1 with ROM banking */
48514851GAME( 1985, hvymetal,   0,        sys1pio,  hvymetal,  hvymetal, ROT0,   "Sega",            "Heavy Metal (315-5135)", GAME_SUPPORTS_SAVE )
src/mame/drivers/wldarrow.c
r14862r14863
1/*********************************
1/******************************************************
2
23 Wild Arrow - Meyco Games 1982
34
45 Preliminary driver by
r14862r14863
1314
1415XTal: 20.0
1516
16todo:
17 how are the games checking the battery
18 state?
1917
20**********************************/
18To initialize battery RAM, go into testmode (F1 -> F2),
19and then press the Reset Counters button.
2120
21If a game is not turned off properly, eg. exiting MAME
22in mid-game, it may run faulty on the next boot.
23Enable the Night Switch to prevent this.
24
25*******************************************************/
26
2227#include "emu.h"
2328#include "cpu/i8085/i8085.h"
2429#include "sound/dac.h"
r14862r14863
253258   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_BUTTON3 ) PORT_NAME("Stop Reel 1") /* Skill Stop only? */
254259   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_NAME("Spin")
255260   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_NAME("Bet")
256   PORT_DIPNAME( 0x20, 0x20, "2-5" )
257   PORT_DIPSETTING(    0x20, DEF_STR( Off ) )
258   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
259   PORT_DIPNAME( 0x40, 0x40, "2-6" )
260   PORT_DIPSETTING(    0x40, DEF_STR( Off ) )
261   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
261   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_SERVICE2 ) PORT_NAME("Reset Counters")
262   PORT_SERVICE( 0x40, IP_ACTIVE_LOW )
262263   PORT_DIPNAME( 0x80, 0x80, "Night Switch" ) PORT_CODE(KEYCODE_F1) PORT_TOGGLE
263264   PORT_DIPSETTING(    0x80, DEF_STR( Off ) )
264265   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
r14862r14863
333334   PORT_DIPNAME( 0x10, 0x10, "2-4" )
334335   PORT_DIPSETTING(    0x10, DEF_STR( Off ) )
335336   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
336   PORT_DIPNAME( 0x20, 0x20, "2-5" )
337   PORT_DIPSETTING(    0x20, DEF_STR( Off ) )
338   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
339   PORT_DIPNAME( 0x40, 0x40, "2-6" )
340   PORT_DIPSETTING(    0x40, DEF_STR( Off ) )
341   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
337   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_SERVICE2 ) PORT_NAME("Reset Counters")
338   PORT_SERVICE( 0x40, IP_ACTIVE_LOW )
342339   PORT_DIPNAME( 0x80, 0x80, "Night Switch" ) PORT_CODE(KEYCODE_F1) PORT_TOGGLE
343340   PORT_DIPSETTING(    0x80, DEF_STR( Off ) )
344341   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
r14862r14863
358355static MACHINE_CONFIG_START( wldarrow, wldarrow_state )
359356
360357   /* basic machine hardware */
361   MCFG_CPU_ADD("maincpu", I8080, 2000000)
358   MCFG_CPU_ADD("maincpu", I8080, XTAL_20MHz / 10) // divider guessed
362359   MCFG_CPU_PROGRAM_MAP(wldarrow_map)
363360
364361   MCFG_NVRAM_ADD_0FILL("nvram")
r14862r14863
387384 *************************************/
388385
389386ROM_START( wldarrow )
390   ROM_REGION( 0x10000, "maincpu", 0 )
387   ROM_REGION( 0x10000, "maincpu", ROMREGION_INVERT )
391388   ROM_LOAD( "a1-v48.8k", 0x0000, 0x0800, CRC(05dd8056) SHA1(556ca28d090cbf1855618ba40fc631523bdfadd5) )
392389   ROM_LOAD( "a2-v48.7k", 0x0800, 0x0800, CRC(37df3acf) SHA1(a7f7f54af533dd8231bb20c526c053dd99e74863) )
393390   ROM_LOAD( "a3-v48.6k", 0x1000, 0x0800, CRC(1295cee2) SHA1(61b260eb907ee4bbf1460277d09e3205c1f6d8a0) )
r14862r14863
445442*/
446443
447444ROM_START( mdrawpkr )
448   ROM_REGION( 0x10000, "maincpu", 0 )
445   ROM_REGION( 0x10000, "maincpu", ROMREGION_INVERT )
449446   ROM_LOAD( "tms2516.k8", 0x0000, 0x0800, CRC(2e5fc31e) SHA1(5ea01298051bc51250f67305ac8a65b0b94c120f) )
450447   ROM_LOAD( "tms2516.k7", 0x0800, 0x0800, CRC(baaf874e) SHA1(b7bb476ef873102979ad3252d19a26ee3a31d933) )
451448   ROM_LOAD( "tms2516.k6", 0x1000, 0x0800, CRC(a0e13c41) SHA1(17f78f91dae64c39f1a39a0b99a081af1d3bed47) )
r14862r14863
455452ROM_END
456453
457454ROM_START( mdrawpkra )
458   ROM_REGION( 0x10000, "maincpu", 0 )
455   ROM_REGION( 0x10000, "maincpu", ROMREGION_INVERT )
459456   ROM_LOAD( "meyco.k8", 0x0000, 0x0800, CRC(b4f6994d) SHA1(46fb2784b7b333f6755522fd27741a2fc4a4bc99) )
460457   ROM_LOAD( "meyco.k7", 0x0800, 0x0800, CRC(8830365d) SHA1(044bc92880b78fa2a6ed5e133b484ac7d34c455a) )
461458   ROM_LOAD( "meyco.k6", 0x1000, 0x0800, CRC(e1d5d38d) SHA1(523029185e2edc0351fa128d6494a5002cb2d7e7) )
r14862r14863
465462ROM_END
466463
467464ROM_START( unkmeyco )
468   ROM_REGION( 0x10000, "maincpu", 0 )
465   ROM_REGION( 0x10000, "maincpu", ROMREGION_INVERT )
469466   ROM_LOAD( "k8", 0x0000, 0x0800, CRC(c6d8a2f7) SHA1(1fcd3ad72a29f832ffaf37edcb74e84e21909496) )
470467   ROM_LOAD( "k7", 0x0800, 0x0800, CRC(6e30e5ae) SHA1(980096adefce4d4d97607b22f56f3acf246986ed) )
471468   ROM_LOAD( "k6", 0x1000, 0x0800, CRC(7e2cb0e1) SHA1(3ea8f3c051ba730a39404b718d93bcdd762834c3) )
r14862r14863
482479 *
483480 *************************************/
484481
485static DRIVER_INIT( wldarrow )
486{
487   offs_t i;
488   UINT8 *rom = machine.region("maincpu")->base();
489
490   for (i = 0; i < 0x3800; i++)
491      rom[i] ^= 0xff;
492}
493
494
495GAME( 1982, wldarrow,  0,        wldarrow, wldarrow, wldarrow, ROT0, "Meyco Games", "Wild Arrow (Standard V4.8)", GAME_IMPERFECT_SOUND | GAME_SUPPORTS_SAVE )
496GAME( 198?, mdrawpkr,  0,        wldarrow, mdrawpkr, wldarrow, ROT0, "Meyco Games", "Draw Poker Joker's Wild (Standard)", GAME_NOT_WORKING | GAME_SUPPORTS_SAVE )
497GAME( 198?, mdrawpkra, mdrawpkr, wldarrow, mdrawpkr, wldarrow, ROT0, "Meyco Games", "Draw Poker Joker's Wild (02-11)", GAME_NOT_WORKING | GAME_SUPPORTS_SAVE )
498GAME( 198?, unkmeyco,  0,        wldarrow, mdrawpkr, wldarrow, ROT0, "Meyco Games", "unknown Meyco game", GAME_NOT_WORKING | GAME_SUPPORTS_SAVE )
482GAME( 1982, wldarrow,  0,        wldarrow, wldarrow, 0, ROT0, "Meyco Games", "Wild Arrow (Standard V4.8)",                GAME_IMPERFECT_SOUND | GAME_SUPPORTS_SAVE )
483GAME( 1984, mdrawpkr,  0,        wldarrow, mdrawpkr, 0, ROT0, "Meyco Games", "Draw Poker - Joker's Wild (Standard)",      GAME_NOT_WORKING | GAME_SUPPORTS_SAVE ) // year not shown, but it is in mdrawpkra
484GAME( 1984, mdrawpkra, mdrawpkr, wldarrow, mdrawpkr, 0, ROT0, "Meyco Games", "Draw Poker - Joker's Wild (02-11)",         GAME_NOT_WORKING | GAME_SUPPORTS_SAVE )
485GAME( 1983, unkmeyco,  0,        wldarrow, mdrawpkr, 0, ROT0, "Meyco Games", "unknown Meyco poker game (Standard 00-05)", GAME_NOT_WORKING | GAME_SUPPORTS_SAVE )
src/emu/cpu/tms57002/tms57kpr.h
r14862r14863
1#ifndef TMS57KPRIVATE_H
2#define TMS57KPRIVATE_H
3
4CPU_DISASSEMBLE(tms57002);
5
6#ifdef __GNUC__
7#define noinline __attribute__((noinline))
8#else
9#define noinline /* */
10#endif
11
12enum {
13   IN_PLOAD = 0x00000001,
14   IN_CLOAD = 0x00000002,
15   SU_CVAL  = 0x00000004,
16   SU_MASK  = 0x00000018, SU_ST0 = 0x00, SU_ST1 = 0x08, SU_PRG = 0x10,
17   S_IDLE   = 0x00000020,
18   S_READ   = 0x00000040,
19   S_WRITE  = 0x00000080,
20   S_BRANCH = 0x00000100,
21   S_HOST   = 0x00000200
22};
23
24enum {
25   ST0_INCS = 0x000001,
26   ST0_DIRI = 0x000002,
27   ST0_FI   = 0x000004,
28   ST0_SIM  = 0x000008,
29   ST0_PLRI = 0x000020,
30   ST0_PBCI = 0x000040,
31   ST0_DIRO = 0x000080,
32   ST0_FO   = 0x000100,
33   ST0_SOM  = 0x000600,
34   ST0_PLRO = 0x000800,
35   ST0_PBCO = 0x001000,
36   ST0_CNS  = 0x002000,
37   ST0_WORD = 0x004000,
38   ST0_SEL  = 0x008000,
39   ST0_M    = 0x030000, ST0_M_64K = 0x000000, ST0_M_256K = 0x010000, ST0_M_1M = 0x020000,
40   ST0_SRAM = 0x200000,
41
42   ST1_AOV  = 0x000001,
43   ST1_SFAI = 0x000002,
44   ST1_SFAO = 0x000004,
45   ST1_MOVM = 0x000020,
46   ST1_MOV  = 0x000040,
47   ST1_SFMA = 0x000180, ST1_SFMA_SHIFT = 7,
48   ST1_SFMO = 0x001800, ST1_SFMO_SHIFT = 11,
49   ST1_RND  = 0x038000, ST1_RND_SHIFT = 15,
50   ST1_CRM  = 0x0C0000, ST1_CRM_SHIFT = 18, ST1_CRM_32 = 0x000000, ST1_CRM_16H = 0x040000, ST1_CRM_16L = 0x080000,
51   ST1_DBP  = 0x100000,
52   ST1_CAS  = 0x200000,
53
54   ST1_CACHE = ST1_SFAI|ST1_SFAO|ST1_MOVM|ST1_SFMA|ST1_SFMO|ST1_RND|ST1_CRM|ST1_DBP
55};
56
57enum { BR_UB, BR_CB, BR_IDLE };
58
59enum { IBS = 8192, HBS = 4096 };
60
61typedef struct {
62   unsigned short op;
63   short next;
64   unsigned char param;
65} icd;
66
67typedef struct {
68   unsigned int st1;
69   short ipc;
70   short next;
71} hcd;
72
73typedef struct {
74   short hashbase[256];
75   hcd hashnode[HBS];
76   icd inst[IBS];
77   int hused, iused;
78} cd;
79
80typedef struct {
81   int branch;
82   short hnode;
83   short ipc;
84} cstate;
85
86typedef struct {
87   INT64 macc;
88
89   UINT32 cmem[256];
90   UINT32 dmem0[256];
91   UINT32 dmem1[32];
92
93   UINT32 si[4], so[4];
94
95   UINT32 st0, st1, sti;
96   UINT32 aacc, xoa, xba, xwr, xrd, creg;
97
98   UINT8 pc, ca, id, ba0, ba1, rptc, rptc_next, sa;
99
100   UINT32 xm_adr;
101
102   UINT8 host[4], hidx, allow_update;
103
104   cd cache;
105
106   address_space *program, *data;
107   int icount;
108   int unsupported_inst_warning;
109} tms57002_t;
110
111void tms57002_decode_cat1(tms57002_t *s, UINT32 opcode, unsigned short *op, cstate *cs);
112void tms57002_decode_cat2_pre(tms57002_t *s, UINT32 opcode, unsigned short *op, cstate *cs);
113void tms57002_decode_cat3(tms57002_t *s, UINT32 opcode, unsigned short *op, cstate *cs);
114void tms57002_decode_cat2_post(tms57002_t *s, UINT32 opcode, unsigned short *op, cstate *cs);
115
116INLINE int xmode(UINT32 opcode, char type)
117{
118   if(((opcode & 0x400) && (type == 'c')) || (!(opcode & 0x400) && (type == 'd'))) {
119      if(opcode & 0x100)
120         return 0;
121      else if(opcode & 0x80)
122         return 2;
123      else
124         return 1;
125   } else if(opcode & 0x200)
126      return 2;
127
128   return 1;
129}
130
131INLINE int sfao(UINT32 st1)
132{
133   return st1 & ST1_SFAO ? 1 : 0;
134}
135
136INLINE int dbp(UINT32 st1)
137{
138   return st1 & ST1_DBP ? 1 : 0;
139}
140
141INLINE int crm(UINT32 st1)
142{
143   return (st1 & ST1_CRM) >> ST1_CRM_SHIFT;
144}
145
146INLINE int sfai(UINT32 st1)
147{
148   return st1 & ST1_SFAI ? 1 : 0;
149}
150
151INLINE int sfmo(UINT32 st1)
152{
153   return (st1 & ST1_SFMO) >> ST1_SFMO_SHIFT;
154}
155
156INLINE int rnd(UINT32 st1)
157{
158   return (st1 & ST1_RND) >> ST1_RND_SHIFT;
159}
160
161INLINE int movm(UINT32 st1)
162{
163   return st1 & ST1_MOVM ? 1 : 0;
164}
165
166INLINE int sfma(UINT32 st1)
167{
168   return (st1 & ST1_SFMA) >> ST1_SFMA_SHIFT;
169}
170
171#endif
src/emu/emuopts.c
r14862r14863
3939
4040#include "emu.h"
4141#include "emuopts.h"
42#include "drivenum.h"
4243
4344#include <ctype.h>
4445
src/emu/hashfile.c
r14862r14863
1111#include "expat.h"
1212#include "emuopts.h"
1313#include "hash.h"
14#include "drivenum.h"
1415
1516
1617/***************************************************************************
src/emu/gamedrv.h
r0r14863
1/***************************************************************************
2
3    gamedrv.h
4
5    Definitions for game drivers.
6
7****************************************************************************
8
9    Copyright Aaron Giles
10    All rights reserved.
11
12    Redistribution and use in source and binary forms, with or without
13    modification, are permitted provided that the following conditions are
14    met:
15
16        * Redistributions of source code must retain the above copyright
17          notice, this list of conditions and the following disclaimer.
18        * Redistributions in binary form must reproduce the above copyright
19          notice, this list of conditions and the following disclaimer in
20          the documentation and/or other materials provided with the
21          distribution.
22        * Neither the name 'MAME' nor the names of its contributors may be
23          used to endorse or promote products derived from this software
24          without specific prior written permission.
25
26    THIS SOFTWARE IS PROVIDED BY AARON GILES ''AS IS'' AND ANY EXPRESS OR
27    IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
28    WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
29    DISCLAIMED. IN NO EVENT SHALL AARON GILES BE LIABLE FOR ANY DIRECT,
30    INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
31    (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
32    SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
33    HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
34    STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
35    IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
36    POSSIBILITY OF SUCH DAMAGE.
37
38***************************************************************************/
39
40#pragma once
41
42#ifndef __GAMEDRV_H__
43#define __GAMEDRV_H__
44
45
46//**************************************************************************
47//  CONSTANTS
48//**************************************************************************
49
50// maxima
51const int MAX_DRIVER_NAME_CHARS = 8;
52
53// flags for game drivers
54const UINT32 ORIENTATION_MASK              = 0x00000007;
55const UINT32 GAME_NOT_WORKING            = 0x00000008;
56const UINT32 GAME_UNEMULATED_PROTECTION      = 0x00000010;   // game's protection not fully emulated
57const UINT32 GAME_WRONG_COLORS            = 0x00000020;   // colors are totally wrong
58const UINT32 GAME_IMPERFECT_COLORS         = 0x00000040;   // colors are not 100% accurate, but close
59const UINT32 GAME_IMPERFECT_GRAPHICS      = 0x00000080;   // graphics are wrong/incomplete
60const UINT32 GAME_NO_COCKTAIL            = 0x00000100;   // screen flip support is missing
61const UINT32 GAME_NO_SOUND               = 0x00000200;   // sound is missing
62const UINT32 GAME_IMPERFECT_SOUND         = 0x00000400;   // sound is known to be wrong
63const UINT32 GAME_SUPPORTS_SAVE            = 0x00000800;   // game supports save states
64const UINT32 GAME_IS_BIOS_ROOT            = 0x00001000;   // this driver entry is a BIOS root
65const UINT32 GAME_NO_STANDALONE            = 0x00002000;   // this driver cannot stand alone
66const UINT32 GAME_REQUIRES_ARTWORK         = 0x00004000;   // the driver requires external artwork for key elements of the game
67const UINT32 GAME_UNOFFICIAL              = 0x00008000;   // unofficial hardware change
68const UINT32 GAME_NO_SOUND_HW            = 0x00010000;   // sound hardware not available
69const UINT32 GAME_MECHANICAL            = 0x00020000;   // contains mechanical parts (pinball, redemption games,...)
70const UINT32 GAME_TYPE_ARCADE            = 0x00040000;   // arcade machine (coin operated machines)
71const UINT32 GAME_TYPE_CONSOLE            = 0x00080000;   // console system
72const UINT32 GAME_TYPE_COMPUTER            = 0x00100000;   // any kind of computer including home computers, minis, calcs,...
73const UINT32 GAME_TYPE_OTHER            = 0x00200000;   // any other emulated system that doesn't fit above (ex. clock, satelite receiver,...)
74
75// useful combinations of flags
76const UINT32 GAME_IS_SKELETON            = GAME_NO_SOUND | GAME_NOT_WORKING; // mask for skelly games
77const UINT32 GAME_IS_SKELETON_MECHANICAL   = GAME_IS_SKELETON | GAME_MECHANICAL | GAME_REQUIRES_ARTWORK; // mask for skelly mechanical games
78
79
80
81//**************************************************************************
82//  TYPE DEFINITIONS
83//**************************************************************************
84
85// static driver initialization callback
86typedef void (*driver_init_func)(running_machine &machine);
87
88/*
89// wrapper template to allow members
90template<class _DriverClass, void (_DriverClass::*_Function)()>
91void driver_init_wrapper(running_machine &machine)
92{
93   _DriverClass *object = machine.driver_data<_DriverClass>();
94   (object->*_Function)();
95}
96*/
97
98// static POD structure describing each game driver entry
99struct game_driver
100{
101   const char *      source_file;            // set this to __FILE__
102   const char *      parent;                  // if this is a clone, the name of the parent
103   const char *      name;                  // short (8-character) name of the game
104   const char *      description;            // full name of the game
105   const char *      year;                  // year the game was released
106   const char *      manufacturer;            // manufacturer of the game
107   machine_config_constructor machine_config;      // machine driver tokens
108   ioport_constructor   ipt;                  // pointer to constructor for input ports
109   void            (*driver_init)(running_machine &machine); // DRIVER_INIT callback
110   const rom_entry *   rom;                  // pointer to list of ROMs for the game
111   const char *      compatible_with;
112   UINT32            flags;                  // orientation and other flags; see defines below
113   const char *      default_layout;            // default internally defined layout
114};
115
116
117
118//**************************************************************************
119//  MACROS
120//**************************************************************************
121
122// wrappers for the DRIVER_INIT callback
123#define DRIVER_INIT_NAME(name)      driver_init_##name
124#define DRIVER_INIT(name)         void DRIVER_INIT_NAME(name)(running_machine &machine)
125#define DRIVER_INIT_CALL(name)      DRIVER_INIT_NAME(name)(machine)
126
127#define driver_init_0            NULL
128
129// wrappers for declaring and defining game drivers
130#define GAME_NAME(name) driver_##name
131#define GAME_EXTERN(name) extern const game_driver GAME_NAME(name)
132
133// standard GAME() macro
134#define GAME(YEAR,NAME,PARENT,MACHINE,INPUT,INIT,MONITOR,COMPANY,FULLNAME,FLAGS)   \
135   GAMEL(YEAR,NAME,PARENT,MACHINE,INPUT,INIT,MONITOR,COMPANY,FULLNAME,FLAGS,((const char *)0))
136
137// standard macro with additional layout
138#define GAMEL(YEAR,NAME,PARENT,MACHINE,INPUT,INIT,MONITOR,COMPANY,FULLNAME,FLAGS,LAYOUT)   \
139extern const game_driver GAME_NAME(NAME) =   \
140{                                 \
141   __FILE__,                        \
142   #PARENT,                        \
143   #NAME,                           \
144   FULLNAME,                        \
145   #YEAR,                           \
146   COMPANY,                        \
147   MACHINE_CONFIG_NAME(MACHINE),         \
148   INPUT_PORTS_NAME(INPUT),            \
149   DRIVER_INIT_NAME(INIT),               \
150   ROM_NAME(NAME),                     \
151   NULL,                           \
152   (MONITOR)|(FLAGS)|GAME_TYPE_ARCADE,      \
153   &LAYOUT[0]                        \
154};
155
156// standard console definition macro
157#define CONS(YEAR,NAME,PARENT,COMPAT,MACHINE,INPUT,INIT,COMPANY,FULLNAME,FLAGS)   \
158extern const game_driver GAME_NAME(NAME) =   \
159{                                 \
160   __FILE__,                        \
161   #PARENT,                        \
162   #NAME,                           \
163   FULLNAME,                        \
164   #YEAR,                           \
165   COMPANY,                        \
166   MACHINE_CONFIG_NAME(MACHINE),         \
167   INPUT_PORTS_NAME(INPUT),            \
168   DRIVER_INIT_NAME(INIT),               \
169   ROM_NAME(NAME),                     \
170   #COMPAT,                        \
171   ROT0|(FLAGS)|GAME_TYPE_CONSOLE,         \
172   NULL                           \
173};
174
175// standard computer definition macro
176#define COMP(YEAR,NAME,PARENT,COMPAT,MACHINE,INPUT,INIT,COMPANY,FULLNAME,FLAGS)   \
177extern const game_driver GAME_NAME(NAME) =   \
178{                                 \
179   __FILE__,                        \
180   #PARENT,                        \
181   #NAME,                           \
182   FULLNAME,                        \
183   #YEAR,                           \
184   COMPANY,                        \
185   MACHINE_CONFIG_NAME(MACHINE),         \
186   INPUT_PORTS_NAME(INPUT),            \
187   DRIVER_INIT_NAME(INIT),               \
188   ROM_NAME(NAME),                     \
189   #COMPAT,                        \
190   ROT0|(FLAGS)|GAME_TYPE_COMPUTER,      \
191   NULL                           \
192};
193
194// standard system definition macro
195#define SYST(YEAR,NAME,PARENT,COMPAT,MACHINE,INPUT,INIT,COMPANY,FULLNAME,FLAGS)   \
196extern const game_driver GAME_NAME(NAME) =   \
197{                                 \
198   __FILE__,                        \
199   #PARENT,                        \
200   #NAME,                           \
201   FULLNAME,                        \
202   #YEAR,                           \
203   COMPANY,                        \
204   MACHINE_CONFIG_NAME(MACHINE),         \
205   INPUT_PORTS_NAME(INPUT),            \
206   DRIVER_INIT_NAME(INIT),               \
207   ROM_NAME(NAME),                     \
208   #COMPAT,                        \
209   ROT0|(FLAGS)|GAME_TYPE_OTHER,         \
210   NULL                           \
211};
212
213
214
215//**************************************************************************
216//  GLOBAL VARIABLES
217//**************************************************************************
218
219GAME_EXTERN(___empty);
220
221#endif
src/emu/emu.h
r14862r14863
112112
113113// machine and driver configuration
114114#include "mconfig.h"
115#include "driver.h"
115#include "gamedrv.h"
116116
117117// image-related
118118#include "softlist.h"
r14862r14863
123123
124124// the running machine
125125#include "machine.h"
126#include "driver.h"
126127#include "mame.h"
127128
128129// video-related
src/emu/diimage.c
r14862r14863
3939
4040#include "emu.h"
4141#include "emuopts.h"
42#include "drivenum.h"
4243#include "ui.h"
4344#include "zippath.h"
4445#include "uiimage.h"
src/emu/machine.c
r14862r14863
10381038
10391039
10401040//**************************************************************************
1041//  DRIVER DEVICE
1042//**************************************************************************
1043
1044//-------------------------------------------------
1045//  driver_device - constructor
1046//-------------------------------------------------
1047
1048driver_device::driver_device(const machine_config &mconfig, device_type type, const char *tag)
1049   : device_t(mconfig, type, "Driver Device", tag, NULL, 0),
1050     m_system(NULL),
1051     m_palette_init(NULL),
1052     m_generic_paletteram_8(*this, "paletteram"),
1053     m_generic_paletteram2_8(*this, "paletteram2"),
1054     m_generic_paletteram_16(*this, "paletteram"),
1055     m_generic_paletteram2_16(*this, "paletteram2"),
1056     m_generic_paletteram_32(*this, "paletteram"),
1057     m_generic_paletteram2_32(*this, "paletteram2")
1058{
1059   memset(m_callbacks, 0, sizeof(m_callbacks));
1060}
1061
1062
1063//-------------------------------------------------
1064//  driver_device - destructor
1065//-------------------------------------------------
1066
1067driver_device::~driver_device()
1068{
1069}
1070
1071
1072//-------------------------------------------------
1073//  static_set_game - set the game in the device
1074//  configuration
1075//-------------------------------------------------
1076
1077void driver_device::static_set_game(device_t &device, const game_driver &game)
1078{
1079   driver_device &driver = downcast<driver_device &>(device);
1080
1081   // set the system
1082   driver.m_system = &game;
1083
1084   // set the short name to the game's name
1085   driver.m_shortname = game.name;
1086
1087   // set the full name to the game's description
1088   driver.m_name = game.description;
1089
1090   // and set the search path to include all parents
1091   driver.m_searchpath = game.name;
1092   for (int parent = driver_list::clone(game); parent != -1; parent = driver_list::clone(parent))
1093      driver.m_searchpath.cat(";").cat(driver_list::driver(parent).name);
1094}
1095
1096
1097//-------------------------------------------------
1098//  static_set_machine_start - set the legacy
1099//  machine start callback in the device
1100//  configuration
1101//-------------------------------------------------
1102
1103void driver_device::static_set_callback(device_t &device, callback_type type, legacy_callback_func callback)
1104{
1105   downcast<driver_device &>(device).m_callbacks[type] = callback;
1106}
1107
1108
1109//-------------------------------------------------
1110//  static_set_palette_init - set the legacy
1111//  palette init callback in the device
1112//  configuration
1113//-------------------------------------------------
1114
1115void driver_device::static_set_palette_init(device_t &device, palette_init_func callback)
1116{
1117   downcast<driver_device &>(device).m_palette_init = callback;
1118}
1119
1120
1121//-------------------------------------------------
1122//  driver_start - default implementation which
1123//  does nothing
1124//-------------------------------------------------
1125
1126void driver_device::driver_start()
1127{
1128}
1129
1130
1131//-------------------------------------------------
1132//  machine_start - default implementation which
1133//  calls to the legacy machine_start function
1134//-------------------------------------------------
1135
1136void driver_device::machine_start()
1137{
1138   if (m_callbacks[CB_MACHINE_START] != NULL)
1139      (*m_callbacks[CB_MACHINE_START])(machine());
1140}
1141
1142
1143//-------------------------------------------------
1144//  sound_start - default implementation which
1145//  calls to the legacy sound_start function
1146//-------------------------------------------------
1147
1148void driver_device::sound_start()
1149{
1150   if (m_callbacks[CB_SOUND_START] != NULL)
1151      (*m_callbacks[CB_SOUND_START])(machine());
1152}
1153
1154
1155//-------------------------------------------------
1156//  video_start - default implementation which
1157//  calls to the legacy video_start function
1158//-------------------------------------------------
1159
1160void driver_device::video_start()
1161{
1162   if (m_callbacks[CB_VIDEO_START] != NULL)
1163      (*m_callbacks[CB_VIDEO_START])(machine());
1164}
1165
1166
1167//-------------------------------------------------
1168//  driver_reset - default implementation which
1169//  does nothing
1170//-------------------------------------------------
1171
1172void driver_device::driver_reset()
1173{
1174}
1175
1176
1177//-------------------------------------------------
1178//  machine_reset - default implementation which
1179//  calls to the legacy machine_reset function
1180//-------------------------------------------------
1181
1182void driver_device::machine_reset()
1183{
1184   if (m_callbacks[CB_MACHINE_RESET] != NULL)
1185      (*m_callbacks[CB_MACHINE_RESET])(machine());
1186}
1187
1188
1189//-------------------------------------------------
1190//  sound_reset - default implementation which
1191//  calls to the legacy sound_reset function
1192//-------------------------------------------------
1193
1194void driver_device::sound_reset()
1195{
1196   if (m_callbacks[CB_SOUND_RESET] != NULL)
1197      (*m_callbacks[CB_SOUND_RESET])(machine());
1198}
1199
1200
1201//-------------------------------------------------
1202//  video_reset - default implementation which
1203//  calls to the legacy video_reset function
1204//-------------------------------------------------
1205
1206void driver_device::video_reset()
1207{
1208   if (m_callbacks[CB_VIDEO_RESET] != NULL)
1209      (*m_callbacks[CB_VIDEO_RESET])(machine());
1210}
1211
1212
1213//-------------------------------------------------
1214//  device_rom_region - return a pointer to the
1215//  game's ROMs
1216//-------------------------------------------------
1217
1218const rom_entry *driver_device::device_rom_region() const
1219{
1220   return m_system->rom;
1221}
1222
1223
1224//-------------------------------------------------
1225//  device_input_ports - return a pointer to the
1226//  game's input ports
1227//-------------------------------------------------
1228
1229ioport_constructor driver_device::device_input_ports() const
1230{
1231   return m_system->ipt;
1232}
1233
1234
1235//-------------------------------------------------
1236//  device_start - device override which calls
1237//  the various helpers
1238//-------------------------------------------------
1239
1240void driver_device::device_start()
1241{
1242   // reschedule ourselves to be last
1243   device_iterator iter(*this);
1244   for (device_t *test = iter.first(); test != NULL; test = iter.next())
1245      if (test != this && !test->started())
1246         throw device_missing_dependencies();
1247
1248   // call the game-specific init
1249   if (m_system->driver_init != NULL)
1250      (*m_system->driver_init)(machine());
1251
1252   // finish image devices init process
1253   image_postdevice_init(machine());
1254
1255   // call palette_init if present
1256   if (m_palette_init != NULL)
1257      (*m_palette_init)(machine(), machine().region("proms")->base());
1258
1259   // start the various pieces
1260   driver_start();
1261   machine_start();
1262   sound_start();
1263   video_start();
1264}
1265
1266
1267//-------------------------------------------------
1268//  device_reset_after_children - device override
1269//  which calls the various helpers; must happen
1270//  after all child devices are reset
1271//-------------------------------------------------
1272
1273void driver_device::device_reset_after_children()
1274{
1275   // reset each piece
1276   driver_reset();
1277   machine_reset();
1278   sound_reset();
1279   video_reset();
1280}
1281
1282
1283
1284//**************************************************************************
12851041//  SYSTEM TIME
12861042//**************************************************************************
12871043
src/emu/machine.h
r14862r14863
518518
519519
520520
521// ======================> driver_device
522
523// base class for machine driver-specific devices
524class driver_device : public device_t
525{
526public:
527   // construction/destruction
528   driver_device(const machine_config &mconfig, device_type type, const char *tag);
529   virtual ~driver_device();
530
531   // indexes into our generic callbacks
532   enum callback_type
533   {
534      CB_MACHINE_START,
535      CB_MACHINE_RESET,
536      CB_SOUND_START,
537      CB_SOUND_RESET,
538      CB_VIDEO_START,
539      CB_VIDEO_RESET,
540      CB_COUNT
541   };
542
543   // inline configuration helpers
544   static void static_set_game(device_t &device, const game_driver &game);
545   static void static_set_callback(device_t &device, callback_type type, legacy_callback_func callback);
546   static void static_set_palette_init(device_t &device, palette_init_func callback);
547
548   // generic helpers
549
550   // watchdog read/write handlers
551   DECLARE_WRITE8_MEMBER( watchdog_reset_w );
552   DECLARE_READ8_MEMBER( watchdog_reset_r );
553   DECLARE_WRITE16_MEMBER( watchdog_reset16_w );
554   DECLARE_READ16_MEMBER( watchdog_reset16_r );
555   DECLARE_WRITE32_MEMBER( watchdog_reset32_w );
556   DECLARE_READ32_MEMBER( watchdog_reset32_r );
557
558   // sound latch readers
559   DECLARE_READ8_MEMBER( soundlatch_r );
560   DECLARE_READ8_MEMBER( soundlatch2_r );
561   DECLARE_READ8_MEMBER( soundlatch3_r );
562   DECLARE_READ8_MEMBER( soundlatch4_r );
563   DECLARE_READ16_MEMBER( soundlatch_word_r );
564   DECLARE_READ16_MEMBER( soundlatch2_word_r );
565   DECLARE_READ16_MEMBER( soundlatch3_word_r );
566   DECLARE_READ16_MEMBER( soundlatch4_word_r );
567
568   // sound latch writers
569   DECLARE_WRITE8_MEMBER( soundlatch_w );
570   DECLARE_WRITE8_MEMBER( soundlatch2_w );
571   DECLARE_WRITE8_MEMBER( soundlatch3_w );
572   DECLARE_WRITE8_MEMBER( soundlatch4_w );
573   DECLARE_WRITE16_MEMBER( soundlatch_word_w );
574   DECLARE_WRITE16_MEMBER( soundlatch2_word_w );
575   DECLARE_WRITE16_MEMBER( soundlatch3_word_w );
576   DECLARE_WRITE16_MEMBER( soundlatch4_word_w );
577
578   // sound latch clearers
579   DECLARE_WRITE8_MEMBER( soundlatch_clear_w );
580   DECLARE_WRITE8_MEMBER( soundlatch2_clear_w );
581   DECLARE_WRITE8_MEMBER( soundlatch3_clear_w );
582   DECLARE_WRITE8_MEMBER( soundlatch4_clear_w );
583   
584   // general palette helpers
585   void set_color_332(pen_t color, int rshift, int gshift, int bshift, UINT32 data);
586   void set_color_444(pen_t color, int rshift, int gshift, int bshift, UINT32 data);
587   void set_color_555(pen_t color, int rshift, int gshift, int bshift, UINT32 data);
588   void set_color_565(pen_t color, int rshift, int gshift, int bshift, UINT32 data);
589   void set_color_888(pen_t color, int rshift, int gshift, int bshift, UINT32 data);
590   void set_color_4444(pen_t color, int ishift, int rshift, int gshift, int bshift, UINT16 data);
591
592   // 3-3-2 RGB palette write handlers
593   DECLARE_WRITE8_MEMBER( paletteram_BBGGGRRR_w );
594   DECLARE_WRITE8_MEMBER( paletteram_RRRGGGBB_w );
595   DECLARE_WRITE8_MEMBER( paletteram_BBGGRRII_w );
596   DECLARE_WRITE8_MEMBER( paletteram_IIBBGGRR_w );
597
598   // 4-4-4 RGB palette write handlers
599   DECLARE_WRITE8_MEMBER( paletteram_xxxxBBBBGGGGRRRR_le_w );
600   DECLARE_WRITE8_MEMBER( paletteram_xxxxBBBBGGGGRRRR_be_w );
601   DECLARE_WRITE8_MEMBER( paletteram_xxxxBBBBGGGGRRRR_split1_w );   // uses paletteram
602   DECLARE_WRITE8_MEMBER( paletteram_xxxxBBBBGGGGRRRR_split2_w );   // uses paletteram2
603   DECLARE_WRITE16_MEMBER( paletteram16_xxxxBBBBGGGGRRRR_word_w );
604
605   DECLARE_WRITE8_MEMBER( paletteram_xxxxBBBBRRRRGGGG_le_w );
606   DECLARE_WRITE8_MEMBER( paletteram_xxxxBBBBRRRRGGGG_be_w );
607   DECLARE_WRITE8_MEMBER( paletteram_xxxxBBBBRRRRGGGG_split1_w );   // uses paletteram
608   DECLARE_WRITE8_MEMBER( paletteram_xxxxBBBBRRRRGGGG_split2_w );   // uses paletteram2
609   DECLARE_WRITE16_MEMBER( paletteram16_xxxxBBBBRRRRGGGG_word_w );
610
611   DECLARE_WRITE8_MEMBER( paletteram_xxxxRRRRBBBBGGGG_split1_w );   // uses paletteram
612   DECLARE_WRITE8_MEMBER( paletteram_xxxxRRRRBBBBGGGG_split2_w );   // uses paletteram2
613
614   DECLARE_WRITE8_MEMBER( paletteram_xxxxRRRRGGGGBBBB_le_w );
615   DECLARE_WRITE8_MEMBER( paletteram_xxxxRRRRGGGGBBBB_be_w );
616   DECLARE_WRITE8_MEMBER( paletteram_xxxxRRRRGGGGBBBB_split1_w );   // uses paletteram
617   DECLARE_WRITE8_MEMBER( paletteram_xxxxRRRRGGGGBBBB_split2_w );   // uses paletteram2
618   DECLARE_WRITE16_MEMBER( paletteram16_xxxxRRRRGGGGBBBB_word_w );
619
620   DECLARE_WRITE8_MEMBER( paletteram_RRRRGGGGBBBBxxxx_be_w );
621   DECLARE_WRITE8_MEMBER( paletteram_RRRRGGGGBBBBxxxx_split1_w );   // uses paletteram
622   DECLARE_WRITE8_MEMBER( paletteram_RRRRGGGGBBBBxxxx_split2_w );   // uses paletteram2
623   DECLARE_WRITE16_MEMBER( paletteram16_RRRRGGGGBBBBxxxx_word_w );
624
625   // 4-4-4-4 IRGB palette write handlers
626   DECLARE_WRITE16_MEMBER( paletteram16_IIIIRRRRGGGGBBBB_word_w );
627   DECLARE_WRITE16_MEMBER( paletteram16_RRRRGGGGBBBBIIII_word_w );
628
629   // 5-5-5 RGB palette write handlers
630   DECLARE_WRITE8_MEMBER( paletteram_xBBBBBGGGGGRRRRR_le_w );
631   DECLARE_WRITE8_MEMBER( paletteram_xBBBBBGGGGGRRRRR_be_w );
632   DECLARE_WRITE8_MEMBER( paletteram_xBBBBBGGGGGRRRRR_split1_w );   // uses paletteram
633   DECLARE_WRITE8_MEMBER( paletteram_xBBBBBGGGGGRRRRR_split2_w );   // uses paletteram2
634   DECLARE_WRITE16_MEMBER( paletteram16_xBBBBBGGGGGRRRRR_word_w );
635
636   DECLARE_WRITE8_MEMBER( paletteram_xBBBBBRRRRRGGGGG_split1_w );  // uses paletteram
637   DECLARE_WRITE8_MEMBER( paletteram_xBBBBBRRRRRGGGGG_split2_w );  // uses paletteram2
638
639   DECLARE_WRITE8_MEMBER( paletteram_xRRRRRGGGGGBBBBB_le_w );
640   DECLARE_WRITE8_MEMBER( paletteram_xRRRRRGGGGGBBBBB_be_w );
641   DECLARE_WRITE8_MEMBER( paletteram_xRRRRRGGGGGBBBBB_split1_w );
642   DECLARE_WRITE8_MEMBER( paletteram_xRRRRRGGGGGBBBBB_split2_w );
643   DECLARE_WRITE16_MEMBER( paletteram16_xRRRRRGGGGGBBBBB_word_w );
644
645   DECLARE_WRITE16_MEMBER( paletteram16_xGGGGGRRRRRBBBBB_word_w );
646   DECLARE_WRITE16_MEMBER( paletteram16_xGGGGGBBBBBRRRRR_word_w );
647
648   DECLARE_WRITE16_MEMBER( paletteram16_RRRRRGGGGGBBBBBx_word_w );
649   DECLARE_WRITE16_MEMBER( paletteram16_GGGGGRRRRRBBBBBx_word_w );
650   DECLARE_WRITE16_MEMBER( paletteram16_RRRRGGGGBBBBRGBx_word_w );
651
652   // 8-8-8 RGB palette write handlers
653   DECLARE_WRITE16_MEMBER( paletteram16_xrgb_word_be_w );
654   DECLARE_WRITE16_MEMBER( paletteram16_xbgr_word_be_w );
655
656protected:
657   // helpers called at startup
658   virtual void driver_start();
659   virtual void machine_start();
660   virtual void sound_start();
661   virtual void video_start();
662
663   // helpers called at reset
664   virtual void driver_reset();
665   virtual void machine_reset();
666   virtual void sound_reset();
667   virtual void video_reset();
668
669   // device-level overrides
670   virtual const rom_entry *device_rom_region() const;
671   virtual ioport_constructor device_input_ports() const;
672   virtual void device_start();
673   virtual void device_reset_after_children();
674
675   // internal helpers
676   inline UINT16 paletteram16_le(offs_t offset) const { return m_generic_paletteram_8[offset & ~1] | (m_generic_paletteram_8[offset |  1] << 8); }
677   inline UINT16 paletteram16_be(offs_t offset) const { return m_generic_paletteram_8[offset |  1] | (m_generic_paletteram_8[offset & ~1] << 8); }
678   inline UINT16 paletteram16_split(offs_t offset) const { return m_generic_paletteram_8[offset] | (m_generic_paletteram2_8[offset] << 8); }
679   inline UINT32 paletteram32_be(offs_t offset) const { return m_generic_paletteram_16[offset | 1] | (m_generic_paletteram_16[offset & ~1] << 16); }
680
681   // internal state
682   const game_driver *      m_system;               // pointer to the game driver
683
684   legacy_callback_func   m_callbacks[CB_COUNT];      // generic legacy callbacks
685   palette_init_func      m_palette_init;            // one-time palette init callback
686
687public:
688   // generic pointers
689   optional_shared_ptr<UINT8> m_generic_paletteram_8;
690   optional_shared_ptr<UINT8> m_generic_paletteram2_8;
691   optional_shared_ptr<UINT16> m_generic_paletteram_16;
692   optional_shared_ptr<UINT16> m_generic_paletteram2_16;
693   optional_shared_ptr<UINT32> m_generic_paletteram_32;
694   optional_shared_ptr<UINT32> m_generic_paletteram2_32;
695};
696
697
698// this template function creates a stub which constructs a device
699template<class _DriverClass>
700device_t *driver_device_creator(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
701{
702   assert(owner == NULL);
703   assert(clock == 0);
704   return global_alloc_clear(_DriverClass(mconfig, &driver_device_creator<_DriverClass>, tag));
705}
706
707
708
709521//**************************************************************************
710522//  INLINE FUNCTIONS
711523//**************************************************************************
src/emu/render.c
r14862r14863
7272#include "rendlay.h"
7373#include "rendutil.h"
7474#include "config.h"
75#include "drivenum.h"
7576#include "xmlfile.h"
7677
7778
src/emu/clifront.h
r14862r14863
4343#define __CLIFRONT_H__
4444
4545#include "emuopts.h"
46#include "drivenum.h"
4647
4748
4849//**************************************************************************
src/emu/uimain.h
r14862r14863
1515#define __UIMAIN_H__
1616
1717#include "crsshair.h"
18#include "drivenum.h"
1819
1920class ui_menu_main : public ui_menu {
2021public:
src/emu/validity.h
r14862r14863
4343#define __VALIDITY_H__
4444
4545#include "emu.h"
46#include "drivenum.h"
4647
4748
4849//**************************************************************************
src/emu/romload.c
r14862r14863
1111
1212#include "emu.h"
1313#include "emuopts.h"
14#include "drivenum.h"
1415#include "png.h"
1516#include "harddisk.h"
1617#include "config.h"
src/emu/config.c
r14862r14863
1111
1212#include "emu.h"
1313#include "emuopts.h"
14#include "drivenum.h"
1415#include "config.h"
1516#include "xmlfile.h"
1617
src/emu/info.h
r14862r14863
4242#ifndef __INFO_H__
4343#define __INFO_H__
4444
45#include "drivenum.h"
4546
47
4648//**************************************************************************
4749//  FUNCTION PROTOTYPES
4850//**************************************************************************
src/emu/audit.h
r14862r14863
4242#ifndef __AUDIT_H__
4343#define __AUDIT_H__
4444
45#include "drivenum.h"
4546#include "hash.h"
4647
4748
src/emu/emu.mak
r14862r14863
7171   $(EMUOBJ)/distate.o \
7272   $(EMUOBJ)/drawgfx.o \
7373   $(EMUOBJ)/driver.o \
74   $(EMUOBJ)/drivenum.o \
7475   $(EMUOBJ)/emualloc.o \
7576   $(EMUOBJ)/emucore.o \
7677   $(EMUOBJ)/emuopts.o \
src/emu/screen.h
r14862r14863
6161};
6262
6363
64// screen_update callback flags
65const UINT32 UPDATE_HAS_NOT_CHANGED = 0x0001;   // the video has not changed
6466
67
68
6569//**************************************************************************
6670//  TYPE DEFINITIONS
6771//**************************************************************************
src/emu/drivenum.c
r0r14863
1/***************************************************************************
2
3    drivenum.c
4
5    Driver enumeration helpers.
6
7****************************************************************************
8
9    Copyright Aaron Giles
10    All rights reserved.
11
12    Redistribution and use in source and binary forms, with or without
13    modification, are permitted provided that the following conditions are
14    met:
15
16        * Redistributions of source code must retain the above copyright
17          notice, this list of conditions and the following disclaimer.
18        * Redistributions in binary form must reproduce the above copyright
19          notice, this list of conditions and the following disclaimer in
20          the documentation and/or other materials provided with the
21          distribution.
22        * Neither the name 'MAME' nor the names of its contributors may be
23          used to endorse or promote products derived from this software
24          without specific prior written permission.
25
26    THIS SOFTWARE IS PROVIDED BY AARON GILES ''AS IS'' AND ANY EXPRESS OR
27    IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
28    WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
29    DISCLAIMED. IN NO EVENT SHALL AARON GILES BE LIABLE FOR ANY DIRECT,
30    INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
31    (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
32    SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
33    HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
34    STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
35    IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
36    POSSIBILITY OF SUCH DAMAGE.
37
38***************************************************************************/
39
40#include "emu.h"
41#include "drivenum.h"
42#include <ctype.h>
43
44
45
46//**************************************************************************
47//  DRIVER LIST
48//**************************************************************************
49
50//-------------------------------------------------
51//  driver_list - constructor
52//-------------------------------------------------
53
54driver_list::driver_list()
55{
56}
57
58
59//-------------------------------------------------
60//  find - find a driver by name
61//-------------------------------------------------
62
63int driver_list::find(const char *name)
64{
65   // if no name, bail
66   if (name == NULL)
67      return -1;
68
69   // create a dummy item for comparison purposes
70   game_driver driver;
71   driver.name = name;
72   game_driver *driverptr = &driver;
73
74   // binary search to find it
75   const game_driver **result = reinterpret_cast<const game_driver **>(bsearch(&driverptr, s_drivers_sorted, s_driver_count, sizeof(*s_drivers_sorted), driver_sort_callback));
76   return (result == NULL) ? -1 : result - s_drivers_sorted;
77}
78
79
80//-------------------------------------------------
81//  matches - true if we match, taking into
82//  account wildcards in the wildstring
83//-------------------------------------------------
84
85bool driver_list::matches(const char *wildstring, const char *string)
86{
87   // can only match internal drivers if the wildstring starts with an underscore
88   if (string[0] == '_' && (wildstring == NULL || wildstring[0] != '_'))
89      return false;
90
91   // match everything else normally
92   return (wildstring == NULL || mame_strwildcmp(wildstring, string) == 0);
93}
94
95
96//-------------------------------------------------
97//  driver_sort_callback - compare two items in
98//  an array of game_driver pointers
99//-------------------------------------------------
100
101int driver_list::driver_sort_callback(const void *elem1, const void *elem2)
102{
103   const game_driver * const *item1 = reinterpret_cast<const game_driver * const *>(elem1);
104   const game_driver * const *item2 = reinterpret_cast<const game_driver * const *>(elem2);
105   return mame_stricmp((*item1)->name, (*item2)->name);
106}
107
108
109//-------------------------------------------------
110//  penalty_compare - compare two strings for
111//  closeness and assign a score.
112//-------------------------------------------------
113
114int driver_list::penalty_compare(const char *source, const char *target)
115{
116   int gaps = 1;
117   bool last = true;
118
119   // scan the strings
120   for ( ; *source && *target; target++)
121   {
122      // do a case insensitive match
123      bool match = (tolower((UINT8)*source) == tolower((UINT8)*target));
124
125      // if we matched, advance the source
126      if (match)
127         source++;
128
129      // if the match state changed, count gaps
130      if (match != last)
131      {
132         last = match;
133         if (!match)
134            gaps++;
135      }
136   }
137
138   // penalty if short string does not completely fit in
139   for ( ; *source; source++)
140      gaps++;
141
142   // if we matched perfectly, gaps == 0
143   if (gaps == 1 && *source == 0 && *target == 0)
144      gaps = 0;
145
146   return gaps;
147}
148
149
150
151//**************************************************************************
152//  DRIVER ENUMERATOR
153//**************************************************************************
154
155//-------------------------------------------------
156//  driver_enumerator - constructor
157//-------------------------------------------------
158
159driver_enumerator::driver_enumerator(emu_options &options)
160   : m_current(-1),
161     m_filtered_count(0),
162     m_options(options),
163     m_included(global_alloc_array(UINT8, s_driver_count)),
164     m_config(global_alloc_array_clear(machine_config *, s_driver_count))
165{
166   include_all();
167}
168
169
170driver_enumerator::driver_enumerator(emu_options &options, const char *string)
171   : m_current(-1),
172     m_filtered_count(0),
173     m_options(options),
174     m_included(global_alloc_array(UINT8, s_driver_count)),
175     m_config(global_alloc_array_clear(machine_config *, s_driver_count))
176{
177   filter(string);
178}
179
180
181driver_enumerator::driver_enumerator(emu_options &options, const game_driver &driver)
182   : m_current(-1),
183     m_filtered_count(0),
184     m_options(options),
185     m_included(global_alloc_array(UINT8, s_driver_count)),
186     m_config(global_alloc_array_clear(machine_config *, s_driver_count))
187{
188   filter(driver);
189}
190
191
192//-------------------------------------------------
193//  ~driver_enumerator - destructor
194//-------------------------------------------------
195
196driver_enumerator::~driver_enumerator()
197{
198   // free any configs
199   for (int index = 0; index < s_driver_count; index++)
200      global_free(m_config[index]);
201
202   // free the arrays
203   global_free(m_included);
204   global_free(m_config);
205}
206
207
208//-------------------------------------------------
209//  config - return a machine_config for the given
210//  driver, allocating on demand if needed
211//-------------------------------------------------
212
213machine_config &driver_enumerator::config(int index, emu_options &options) const
214{
215   assert(index >= 0 && index < s_driver_count);
216
217   // if we don't have it cached, add it
218   if (m_config[index] == NULL)
219   {
220      // if our cache is full, release the head entry
221      if (m_config_cache.count() == CONFIG_CACHE_COUNT)
222      {
223         config_entry *first = m_config_cache.first();
224         m_config[first->index()] = NULL;
225         m_config_cache.remove(*first);
226      }
227
228      // allocate the config and add it to the end of the list
229      machine_config *config = m_config[index] = global_alloc(machine_config(*s_drivers_sorted[index], options));
230      m_config_cache.append(*global_alloc(config_entry(*config, index)));
231   }
232   return *m_config[index];
233}
234
235
236//-------------------------------------------------
237//  filter - filter the driver list against the
238//  given string
239//-------------------------------------------------
240
241int driver_enumerator::filter(const char *filterstring)
242{
243   // reset the count
244   exclude_all();
245
246   // match name against each driver in the list
247   for (int index = 0; index < s_driver_count; index++)
248      if (matches(filterstring, s_drivers_sorted[index]->name))
249         include(index);
250
251   return m_filtered_count;
252}
253
254
255//-------------------------------------------------
256//  filter - filter the driver list against the
257//  given driver
258//-------------------------------------------------
259
260int driver_enumerator::filter(const game_driver &driver)
261{
262   // reset the count
263   exclude_all();
264
265   // match name against each driver in the list
266   for (int index = 0; index < s_driver_count; index++)
267      if (s_drivers_sorted[index] == &driver)
268         include(index);
269
270   return m_filtered_count;
271}
272
273
274//-------------------------------------------------
275//  include_all - include all non-internal drivers
276//-------------------------------------------------
277
278void driver_enumerator::include_all()
279{
280   memset(m_included, 1, sizeof(m_included[0]) * s_driver_count); m_filtered_count = s_driver_count;
281   int empty = find("___empty");
282   assert(empty != -1);
283   m_included[empty] = 0;
284}
285
286
287//-------------------------------------------------
288//  next - get the next driver matching the given
289//  filter
290//-------------------------------------------------
291
292bool driver_enumerator::next()
293{
294   // always advance one
295   m_current++;
296
297   // if we have a filter, scan forward to the next match
298   while (m_current < s_driver_count)
299   {
300      if (m_included[m_current])
301         break;
302      m_current++;
303   }
304
305   // return true if we end up in range
306   return (m_current >= 0 && m_current < s_driver_count);
307}
308
309
310//-------------------------------------------------
311//  next_excluded - get the next driver that is
312//  not currently included in the list
313//-------------------------------------------------
314
315bool driver_enumerator::next_excluded()
316{
317   // always advance one
318   m_current++;
319
320   // if we have a filter, scan forward to the next match
321   while (m_current < s_driver_count)
322   {
323      if (!m_included[m_current])
324         break;
325      m_current++;
326   }
327
328   // return true if we end up in range
329   return (m_current >= 0 && m_current < s_driver_count);
330}
331
332
333//-------------------------------------------------
334//  driver_sort_callback - compare two items in
335//  an array of game_driver pointers
336//-------------------------------------------------
337
338void driver_enumerator::find_approximate_matches(const char *string, int count, int *results)
339{
340#undef rand
341
342   // if no name, pick random entries
343   if (string == NULL || string[0] == 0)
344   {
345      // seed the RNG first
346      srand(osd_ticks());
347
348      // allocate a temporary list
349      int *templist = global_alloc_array(int, m_filtered_count);
350      int arrayindex = 0;
351      for (int index = 0; index < s_driver_count; index++)
352         if (m_included[index])
353            templist[arrayindex++] = index;
354      assert(arrayindex == m_filtered_count);
355
356      // shuffle
357      for (int shufnum = 0; shufnum < 4 * s_driver_count; shufnum++)
358      {
359         int item1 = rand() % m_filtered_count;
360         int item2 = rand() % m_filtered_count;
361         int temp = templist[item1];
362         templist[item1] = templist[item2];
363         templist[item2] = temp;
364      }
365
366      // copy out the first few entries
367      for (int matchnum = 0; matchnum < count; matchnum++)
368         results[matchnum] = templist[matchnum % m_filtered_count];
369
370      global_free(templist);
371      return;
372   }
373
374   // allocate memory to track the penalty value
375   int *penalty = global_alloc_array(int, count);
376
377   // initialize everyone's states
378   for (int matchnum = 0; matchnum < count; matchnum++)
379   {
380      penalty[matchnum] = 9999;
381      results[matchnum] = -1;
382   }
383
384   // scan the entire drivers array
385   for (int index = 0; index < s_driver_count; index++)
386      if (m_included[index])
387      {
388         // skip things that can't run
389         if ((s_drivers_sorted[index]->flags & GAME_NO_STANDALONE) != 0)
390            continue;
391
392         // pick the best match between driver name and description
393         int curpenalty = penalty_compare(string, s_drivers_sorted[index]->description);
394         int tmp = penalty_compare(string, s_drivers_sorted[index]->name);
395         curpenalty = MIN(curpenalty, tmp);
396
397         // insert into the sorted table of matches
398         for (int matchnum = count - 1; matchnum >= 0; matchnum--)
399         {
400            // stop if we're worse than the current entry
401            if (curpenalty >= penalty[matchnum])
402               break;
403
404            // as long as this isn't the last entry, bump this one down
405            if (matchnum < count - 1)
406            {
407               penalty[matchnum + 1] = penalty[matchnum];
408               results[matchnum + 1] = results[matchnum];
409            }
410            results[matchnum] = index;
411            penalty[matchnum] = curpenalty;
412         }
413      }
414
415   // free our temp memory
416   global_free(penalty);
417}
418
419
420driver_enumerator::config_entry::config_entry(machine_config &config, int index)
421   : m_next(NULL),
422     m_config(&config),
423     m_index(index)
424{
425}
426
427
428driver_enumerator::config_entry::~config_entry()
429{
430   global_free(m_config);
431}
src/emu/driver.c
r14862r14863
22
33    driver.c
44
5    Driver enumeration helpers.
5    Core driver device base class.
66
77****************************************************************************
88
r14862r14863
3838***************************************************************************/
3939
4040#include "emu.h"
41#include <ctype.h>
41#include "drivenum.h"
4242
4343
44
4544//**************************************************************************
46//  DRIVER LIST
45//  DRIVER DEVICE
4746//**************************************************************************
4847
4948//-------------------------------------------------
50//  driver_list - constructor
49//  driver_device - constructor
5150//-------------------------------------------------
5251
53driver_list::driver_list()
52driver_device::driver_device(const machine_config &mconfig, device_type type, const char *tag)
53   : device_t(mconfig, type, "Driver Device", tag, NULL, 0),
54     m_system(NULL),
55     m_palette_init(NULL),
56     m_generic_paletteram_8(*this, "paletteram"),
57     m_generic_paletteram2_8(*this, "paletteram2"),
58     m_generic_paletteram_16(*this, "paletteram"),
59     m_generic_paletteram2_16(*this, "paletteram2"),
60     m_generic_paletteram_32(*this, "paletteram"),
61     m_generic_paletteram2_32(*this, "paletteram2")
5462{
63   memset(m_callbacks, 0, sizeof(m_callbacks));
5564}
5665
5766
5867//-------------------------------------------------
59//  find - find a driver by name
68//  driver_device - destructor
6069//-------------------------------------------------
6170
62int driver_list::find(const char *name)
71driver_device::~driver_device()
6372{
64   // if no name, bail
65   if (name == NULL)
66      return -1;
67
68   // create a dummy item for comparison purposes
69   game_driver driver;
70   driver.name = name;
71   game_driver *driverptr = &driver;
72
73   // binary search to find it
74   const game_driver **result = reinterpret_cast<const game_driver **>(bsearch(&driverptr, s_drivers_sorted, s_driver_count, sizeof(*s_drivers_sorted), driver_sort_callback));
75   return (result == NULL) ? -1 : result - s_drivers_sorted;
7673}
7774
7875
7976//-------------------------------------------------
80//  matches - true if we match, taking into
81//  account wildcards in the wildstring
77//  static_set_game - set the game in the device
78//  configuration
8279//-------------------------------------------------
8380
84bool driver_list::matches(const char *wildstring, const char *string)
81void driver_device::static_set_game(device_t &device, const game_driver &game)
8582{
86   // can only match internal drivers if the wildstring starts with an underscore
87   if (string[0] == '_' && (wildstring == NULL || wildstring[0] != '_'))
88      return false;
83   driver_device &driver = downcast<driver_device &>(device);
8984
90   // match everything else normally
91   return (wildstring == NULL || mame_strwildcmp(wildstring, string) == 0);
85   // set the system
86   driver.m_system = &game;
87
88   // set the short name to the game's name
89   driver.m_shortname = game.name;
90
91   // set the full name to the game's description
92   driver.m_name = game.description;
93
94   // and set the search path to include all parents
95   driver.m_searchpath = game.name;
96   for (int parent = driver_list::clone(game); parent != -1; parent = driver_list::clone(parent))
97      driver.m_searchpath.cat(";").cat(driver_list::driver(parent).name);
9298}
9399
94100
95101//-------------------------------------------------
96//  driver_sort_callback - compare two items in
97//  an array of game_driver pointers
102//  static_set_machine_start - set the legacy
103//  machine start callback in the device
104//  configuration
98105//-------------------------------------------------
99106
100int driver_list::driver_sort_callback(const void *elem1, const void *elem2)
107void driver_device::static_set_callback(device_t &device, callback_type type, legacy_callback_func callback)
101108{
102   const game_driver * const *item1 = reinterpret_cast<const game_driver * const *>(elem1);
103   const game_driver * const *item2 = reinterpret_cast<const game_driver * const *>(elem2);
104   return mame_stricmp((*item1)->name, (*item2)->name);
109   downcast<driver_device &>(device).m_callbacks[type] = callback;
105110}
106111
107112
108113//-------------------------------------------------
109//  penalty_compare - compare two strings for
110//  closeness and assign a score.
114//  static_set_palette_init - set the legacy
115//  palette init callback in the device
116//  configuration
111117//-------------------------------------------------
112118
113int driver_list::penalty_compare(const char *source, const char *target)
119void driver_device::static_set_palette_init(device_t &device, palette_init_func callback)
114120{
115   int gaps = 1;
116   bool last = true;
117
118   // scan the strings
119   for ( ; *source && *target; target++)
120   {
121      // do a case insensitive match
122      bool match = (tolower((UINT8)*source) == tolower((UINT8)*target));
123
124      // if we matched, advance the source
125      if (match)
126         source++;
127
128      // if the match state changed, count gaps
129      if (match != last)
130      {
131         last = match;
132         if (!match)
133            gaps++;
134      }
135   }
136
137   // penalty if short string does not completely fit in
138   for ( ; *source; source++)
139      gaps++;
140
141   // if we matched perfectly, gaps == 0
142   if (gaps == 1 && *source == 0 && *target == 0)
143      gaps = 0;
144
145   return gaps;
121   downcast<driver_device &>(device).m_palette_init = callback;
146122}
147123
148124
149
150//**************************************************************************
151//  DRIVER ENUMERATOR
152//**************************************************************************
153
154125//-------------------------------------------------
155//  driver_enumerator - constructor
126//  driver_start - default implementation which
127//  does nothing
156128//-------------------------------------------------
157129
158driver_enumerator::driver_enumerator(emu_options &options)
159   : m_current(-1),
160     m_filtered_count(0),
161     m_options(options),
162     m_included(global_alloc_array(UINT8, s_driver_count)),
163     m_config(global_alloc_array_clear(machine_config *, s_driver_count))
130void driver_device::driver_start()
164131{
165   include_all();
166132}
167133
168134
169driver_enumerator::driver_enumerator(emu_options &options, const char *string)
170   : m_current(-1),
171     m_filtered_count(0),
172     m_options(options),
173     m_included(global_alloc_array(UINT8, s_driver_count)),
174     m_config(global_alloc_array_clear(machine_config *, s_driver_count))
135//-------------------------------------------------
136//  machine_start - default implementation which
137//  calls to the legacy machine_start function
138//-------------------------------------------------
139
140void driver_device::machine_start()
175141{
176   filter(string);
142   if (m_callbacks[CB_MACHINE_START] != NULL)
143      (*m_callbacks[CB_MACHINE_START])(machine());
177144}
178145
179146
180driver_enumerator::driver_enumerator(emu_options &options, const game_driver &driver)
181   : m_current(-1),
182     m_filtered_count(0),
183     m_options(options),
184     m_included(global_alloc_array(UINT8, s_driver_count)),
185     m_config(global_alloc_array_clear(machine_config *, s_driver_count))
147//-------------------------------------------------
148//  sound_start - default implementation which
149//  calls to the legacy sound_start function
150//-------------------------------------------------
151
152void driver_device::sound_start()
186153{
187   filter(driver);
154   if (m_callbacks[CB_SOUND_START] != NULL)
155      (*m_callbacks[CB_SOUND_START])(machine());
188156}
189157
190158
191159//-------------------------------------------------
192//  ~driver_enumerator - destructor
160//  video_start - default implementation which
161//  calls to the legacy video_start function
193162//-------------------------------------------------
194163
195driver_enumerator::~driver_enumerator()
164void driver_device::video_start()
196165{
197   // free any configs
198   for (int index = 0; index < s_driver_count; index++)
199      global_free(m_config[index]);
200
201   // free the arrays
202   global_free(m_included);
203   global_free(m_config);
166   if (m_callbacks[CB_VIDEO_START] != NULL)
167      (*m_callbacks[CB_VIDEO_START])(machine());
204168}
205169
206170
207171//-------------------------------------------------
208//  config - return a machine_config for the given
209//  driver, allocating on demand if needed
172//  driver_reset - default implementation which
173//  does nothing
210174//-------------------------------------------------
211175
212machine_config &driver_enumerator::config(int index, emu_options &options) const
176void driver_device::driver_reset()
213177{
214   assert(index >= 0 && index < s_driver_count);
215
216   // if we don't have it cached, add it
217   if (m_config[index] == NULL)
218   {
219      // if our cache is full, release the head entry
220      if (m_config_cache.count() == CONFIG_CACHE_COUNT)
221      {
222         config_entry *first = m_config_cache.first();
223         m_config[first->index()] = NULL;
224         m_config_cache.remove(*first);
225      }
226
227      // allocate the config and add it to the end of the list
228      machine_config *config = m_config[index] = global_alloc(machine_config(*s_drivers_sorted[index], options));
229      m_config_cache.append(*global_alloc(config_entry(*config, index)));
230   }
231   return *m_config[index];
232178}
233179
234180
235181//-------------------------------------------------
236//  filter - filter the driver list against the
237//  given string
182//  machine_reset - default implementation which
183//  calls to the legacy machine_reset function
238184//-------------------------------------------------
239185
240int driver_enumerator::filter(const char *filterstring)
186void driver_device::machine_reset()
241187{
242   // reset the count
243   exclude_all();
244
245   // match name against each driver in the list
246   for (int index = 0; index < s_driver_count; index++)
247      if (matches(filterstring, s_drivers_sorted[index]->name))
248         include(index);
249
250   return m_filtered_count;
188   if (m_callbacks[CB_MACHINE_RESET] != NULL)
189      (*m_callbacks[CB_MACHINE_RESET])(machine());
251190}
252191
253192
254193//-------------------------------------------------
255//  filter - filter the driver list against the
256//  given driver
194//  sound_reset - default implementation which
195//  calls to the legacy sound_reset function
257196//-------------------------------------------------
258197
259int driver_enumerator::filter(const game_driver &driver)
198void driver_device::sound_reset()
260199{
261   // reset the count
262   exclude_all();
263
264   // match name against each driver in the list
265   for (int index = 0; index < s_driver_count; index++)
266      if (s_drivers_sorted[index] == &driver)
267         include(index);
268
269   return m_filtered_count;
200   if (m_callbacks[CB_SOUND_RESET] != NULL)
201      (*m_callbacks[CB_SOUND_RESET])(machine());
270202}
271203
272204
273205//-------------------------------------------------
274//  include_all - include all non-internal drivers
206//  video_reset - default implementation which
207//  calls to the legacy video_reset function
275208//-------------------------------------------------
276209
277void driver_enumerator::include_all()
210void driver_device::video_reset()
278211{
279   memset(m_included, 1, sizeof(m_included[0]) * s_driver_count); m_filtered_count = s_driver_count;
280   int empty = find("___empty");
281   assert(empty != -1);
282   m_included[empty] = 0;
212   if (m_callbacks[CB_VIDEO_RESET] != NULL)
213      (*m_callbacks[CB_VIDEO_RESET])(machine());
283214}
284215
285216
286217//-------------------------------------------------
287//  next - get the next driver matching the given
288//  filter
218//  device_rom_region - return a pointer to the
219//  game's ROMs
289220//-------------------------------------------------
290221
291bool driver_enumerator::next()
222const rom_entry *driver_device::device_rom_region() const
292223{
293   // always advance one
294   m_current++;
295
296   // if we have a filter, scan forward to the next match
297   while (m_current < s_driver_count)
298   {
299      if (m_included[m_current])
300         break;
301      m_current++;
302   }
303
304   // return true if we end up in range
305   return (m_current >= 0 && m_current < s_driver_count);
224   return m_system->rom;
306225}
307226
308227
309228//-------------------------------------------------
310//  next_excluded - get the next driver that is
311//  not currently included in the list
229//  device_input_ports - return a pointer to the
230//  game's input ports
312231//-------------------------------------------------
313232
314bool driver_enumerator::next_excluded()
233ioport_constructor driver_device::device_input_ports() const
315234{
316   // always advance one
317   m_current++;
318
319   // if we have a filter, scan forward to the next match
320   while (m_current < s_driver_count)
321   {
322      if (!m_included[m_current])
323         break;
324      m_current++;
325   }
326
327   // return true if we end up in range
328   return (m_current >= 0 && m_current < s_driver_count);
235   return m_system->ipt;
329236}
330237
331238
332239//-------------------------------------------------
333//  driver_sort_callback - compare two items in
334//  an array of game_driver pointers
240//  device_start - device override which calls
241//  the various helpers
335242//-------------------------------------------------
336243
337void driver_enumerator::find_approximate_matches(const char *string, int count, int *results)
244void driver_device::device_start()
338245{
339#undef rand
246   // reschedule ourselves to be last
247   device_iterator iter(*this);
248   for (device_t *test = iter.first(); test != NULL; test = iter.next())
249      if (test != this && !test->started())
250         throw device_missing_dependencies();
340251
341   // if no name, pick random entries
342   if (string == NULL || string[0] == 0)
343   {
344      // seed the RNG first
345      srand(osd_ticks());
252   // call the game-specific init
253   if (m_system->driver_init != NULL)
254      (*m_system->driver_init)(machine());
346255
347      // allocate a temporary list
348      int *templist = global_alloc_array(int, m_filtered_count);
349      int arrayindex = 0;
350      for (int index = 0; index < s_driver_count; index++)
351         if (m_included[index])
352            templist[arrayindex++] = index;
353      assert(arrayindex == m_filtered_count);
256   // finish image devices init process
257   image_postdevice_init(machine());
354258
355      // shuffle
356      for (int shufnum = 0; shufnum < 4 * s_driver_count; shufnum++)
357      {
358         int item1 = rand() % m_filtered_count;
359         int item2 = rand() % m_filtered_count;
360         int temp = templist[item1];
361         templist[item1] = templist[item2];
362         templist[item2] = temp;
363      }
259   // call palette_init if present
260   if (m_palette_init != NULL)
261      (*m_palette_init)(machine(), machine().region("proms")->base());
364262
365      // copy out the first few entries
366      for (int matchnum = 0; matchnum < count; matchnum++)
367         results[matchnum] = templist[matchnum % m_filtered_count];
368
369      global_free(templist);
370      return;
371   }
372
373   // allocate memory to track the penalty value
374   int *penalty = global_alloc_array(int, count);
375
376   // initialize everyone's states
377   for (int matchnum = 0; matchnum < count; matchnum++)
378   {
379      penalty[matchnum] = 9999;
380      results[matchnum] = -1;
381   }
382
383   // scan the entire drivers array
384   for (int index = 0; index < s_driver_count; index++)
385      if (m_included[index])
386      {
387         // skip things that can't run
388         if ((s_drivers_sorted[index]->flags & GAME_NO_STANDALONE) != 0)
389            continue;
390
391         // pick the best match between driver name and description
392         int curpenalty = penalty_compare(string, s_drivers_sorted[index]->description);
393         int tmp = penalty_compare(string, s_drivers_sorted[index]->name);
394         curpenalty = MIN(curpenalty, tmp);
395
396         // insert into the sorted table of matches
397         for (int matchnum = count - 1; matchnum >= 0; matchnum--)
398         {
399            // stop if we're worse than the current entry
400            if (curpenalty >= penalty[matchnum])
401               break;
402
403            // as long as this isn't the last entry, bump this one down
404            if (matchnum < count - 1)
405            {
406               penalty[matchnum + 1] = penalty[matchnum];
407               results[matchnum + 1] = results[matchnum];
408            }
409            results[matchnum] = index;
410            penalty[matchnum] = curpenalty;
411         }
412      }
413
414   // free our temp memory
415   global_free(penalty);
263   // start the various pieces
264   driver_start();
265   machine_start();
266   sound_start();
267   video_start();
416268}
417269
418270
419driver_enumerator::config_entry::config_entry(machine_config &config, int index)
420   : m_next(NULL),
421     m_config(&config),
422     m_index(index)
423{
424}
271//-------------------------------------------------
272//  device_reset_after_children - device override
273//  which calls the various helpers; must happen
274//  after all child devices are reset
275//-------------------------------------------------
425276
426
427driver_enumerator::config_entry::~config_entry()
277void driver_device::device_reset_after_children()
428278{
429   global_free(m_config);
279   // reset each piece
280   driver_reset();
281   machine_reset();
282   sound_reset();
283   video_reset();
430284}
src/emu/drivenum.h
r0r14863
1/***************************************************************************
2
3    drivenum.h
4
5    Driver enumeration helpers.
6
7****************************************************************************
8
9    Copyright Aaron Giles
10    All rights reserved.
11
12    Redistribution and use in source and binary forms, with or without
13    modification, are permitted provided that the following conditions are
14    met:
15
16        * Redistributions of source code must retain the above copyright
17          notice, this list of conditions and the following disclaimer.
18        * Redistributions in binary form must reproduce the above copyright
19          notice, this list of conditions and the following disclaimer in
20          the documentation and/or other materials provided with the
21          distribution.
22        * Neither the name 'MAME' nor the names of its contributors may be
23          used to endorse or promote products derived from this software
24          without specific prior written permission.
25
26    THIS SOFTWARE IS PROVIDED BY AARON GILES ''AS IS'' AND ANY EXPRESS OR
27    IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
28    WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
29    DISCLAIMED. IN NO EVENT SHALL AARON GILES BE LIABLE FOR ANY DIRECT,
30    INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
31    (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
32    SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
33    HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
34    STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
35    IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
36    POSSIBILITY OF SUCH DAMAGE.
37
38***************************************************************************/
39
40#pragma once
41
42#ifndef __DRIVENUM_H__
43#define __DRIVENUM_H__
44
45
46//**************************************************************************
47//  TYPE DEFINITIONS
48//**************************************************************************
49
50// ======================> driver_list
51
52// driver_list is a purely static class that wraps the global driver list
53class driver_list
54{
55   DISABLE_COPYING(driver_list);
56
57protected:
58   // construction/destruction
59   driver_list();
60
61public:
62   // getters
63   static int total() { return s_driver_count; }
64
65   // any item by index
66   static const game_driver &driver(int index) { assert(index >= 0 && index < s_driver_count); return *s_drivers_sorted[index]; }
67   static int clone(int index) { return find(driver(index).parent); }
68   static int non_bios_clone(int index) { int result = find(driver(index).parent); return (result != -1 && (driver(result).flags & GAME_IS_BIOS_ROOT) == 0) ? result : -1; }
69   static int compatible_with(int index) { return find(driver(index).compatible_with); }
70
71   // any item by driver
72   static int clone(const game_driver &driver) { int index = find(driver); assert(index != -1); return clone(index); }
73   static int non_bios_clone(const game_driver &driver) { int index = find(driver); assert(index != -1); return non_bios_clone(index); }
74   static int compatible_with(const game_driver &driver) { int index = find(driver); assert(index != -1); return compatible_with(index); }
75
76   // general helpers
77   static int find(const char *name);
78   static int find(const game_driver &driver) { return find(driver.name); }
79
80   // static helpers
81   static bool matches(const char *wildstring, const char *string);
82
83protected:
84   // internal helpers
85   static int driver_sort_callback(const void *elem1, const void *elem2);
86   static int penalty_compare(const char *source, const char *target);
87
88   // internal state
89   static int                     s_driver_count;
90   static const game_driver * const   s_drivers_sorted[];
91};
92
93
94// ======================> driver_enumerator
95
96// driver_enumerator enables efficient iteration through the driver list
97class driver_enumerator : public driver_list
98{
99   DISABLE_COPYING(driver_enumerator);
100
101public:
102   // construction/destruction
103   driver_enumerator(emu_options &options);
104   driver_enumerator(emu_options &options, const char *filter);
105   driver_enumerator(emu_options &options, const game_driver &filter);
106   ~driver_enumerator();
107
108   // getters
109   int count() const { return m_filtered_count; }
110   int current() const { return m_current; }
111   emu_options &options() const { return m_options; }
112
113   // current item
114   const game_driver &driver() const { return driver_list::driver(m_current); }
115   machine_config &config() const { return config(m_current, m_options); }
116   int clone() { return driver_list::clone(m_current); }
117   int non_bios_clone() { return driver_list::non_bios_clone(m_current); }
118   int compatible_with() { return driver_list::compatible_with(m_current); }
119   void include() { include(m_current); }
120   void exclude() { exclude(m_current); }
121
122   // any item by index
123   bool included(int index) const { assert(index >= 0 && index < s_driver_count); return m_included[index]; }
124   bool excluded(int index) const { assert(index >= 0 && index < s_driver_count); return !m_included[index]; }
125   machine_config &config(int index) const { return config(index,m_options); }
126   machine_config &config(int index, emu_options &options) const;
127   void include(int index) { assert(index >= 0 && index < s_driver_count); if (!m_included[index]) { m_included[index] = true; m_filtered_count++; }  }
128   void exclude(int index) { assert(index >= 0 && index < s_driver_count); if (m_included[index]) { m_included[index] = false; m_filtered_count--; } }
129   using driver_list::driver;
130   using driver_list::clone;
131   using driver_list::non_bios_clone;
132   using driver_list::compatible_with;
133
134   // filtering/iterating
135   int filter(const char *string = NULL);
136   int filter(const game_driver &driver);
137   void include_all();
138   void exclude_all() { memset(m_included, 0, sizeof(m_included[0]) * s_driver_count); m_filtered_count = 0; }
139   void reset() { m_current = -1; }
140   bool next();
141   bool next_excluded();
142
143   // general helpers
144   void set_current(int index) { assert(index >= -1 && index <= s_driver_count); m_current = index; }
145   void find_approximate_matches(const char *string, int count, int *results);
146
147private:
148   // entry in the config cache
149   struct config_entry
150   {
151      friend class simple_list<config_entry>;
152
153   public:
154      // construction/destruction
155      config_entry(machine_config &config, int index);
156      ~config_entry();
157
158      // getters
159      config_entry *next() const { return m_next; }
160      int index() const { return m_index; }
161      machine_config *config() const { return m_config; }
162
163   private:
164      // internal state
165      config_entry *      m_next;
166      machine_config *   m_config;
167      int               m_index;
168   };
169
170   static const int CONFIG_CACHE_COUNT = 100;
171
172   // internal state
173   int               m_current;
174   int               m_filtered_count;
175   emu_options &      m_options;
176   UINT8 *            m_included;
177   machine_config **   m_config;
178   mutable simple_list<config_entry> m_config_cache;
179};
180
181#endif
src/emu/driver.h
r14862r14863
22
33    driver.h
44
5    Driver enumeration helpers.
5    Core driver device base class.
66
77****************************************************************************
88
r14862r14863
4747#define __DRIVER_H__
4848
4949
50/***************************************************************************
51    CONSTANTS
52***************************************************************************/
50//**************************************************************************
51//  TYPE DEFINITIONS
52//**************************************************************************
5353
54/* maxima */
55#define MAX_DRIVER_NAME_CHARS   8
5654
55// ======================> driver_device
5756
58
59/* ----- flags for game drivers ----- */
60
61#define ORIENTATION_MASK              0x00000007
62#define GAME_NOT_WORKING            0x00000008
63#define GAME_UNEMULATED_PROTECTION      0x00000010   /* game's protection not fully emulated */
64#define GAME_WRONG_COLORS            0x00000020   /* colors are totally wrong */
65#define GAME_IMPERFECT_COLORS         0x00000040   /* colors are not 100% accurate, but close */
66#define GAME_IMPERFECT_GRAPHICS         0x00000080   /* graphics are wrong/incomplete */
67#define GAME_NO_COCKTAIL            0x00000100   /* screen flip support is missing */
68#define GAME_NO_SOUND               0x00000200   /* sound is missing */
69#define GAME_IMPERFECT_SOUND         0x00000400   /* sound is known to be wrong */
70#define GAME_SUPPORTS_SAVE            0x00000800   /* game supports save states */
71#define GAME_IS_BIOS_ROOT            0x00001000   /* this driver entry is a BIOS root */
72#define GAME_NO_STANDALONE            0x00002000   /* this driver cannot stand alone */
73#define GAME_REQUIRES_ARTWORK         0x00004000   /* the driver requires external artwork for key elements of the game */
74#define GAME_UNOFFICIAL              0x00008000   /* unofficial hardware change */
75#define GAME_NO_SOUND_HW            0x00010000   /* sound hardware not available */
76#define GAME_MECHANICAL               0x00020000   /* contains mechanical parts (pinball, redemption games,...) */
77#define GAME_IS_SKELETON            0x00000208   /* mask for skelly games */
78#define GAME_IS_SKELETON_MECHANICAL      0x00024208   /* mask for skelly mechanical games */
79#define GAME_TYPE_ARCADE            0x00040000   /* arcade machine (coin operated machines) */
80#define GAME_TYPE_CONSOLE            0x00080000   /* console system */
81#define GAME_TYPE_COMPUTER            0x00100000   /* any kind of computer including home computers, minis, calcs,... */
82#define GAME_TYPE_OTHER               0x00200000   /* any other emulated system that doesn't fit above (ex. clock, satelite receiver,...) */
83
84/* ----- flags to return from video_update ----- */
85#define UPDATE_HAS_NOT_CHANGED         0x0001   /* the video has not changed */
86
87
88
89/***************************************************************************
90    TYPE DEFINITIONS
91***************************************************************************/
92
93typedef void   (*driver_init_func)(running_machine &machine);
94
95
96struct game_driver
57// base class for machine driver-specific devices
58class driver_device : public device_t
9759{
98   const char *      source_file;            /* set this to __FILE__ */
99   const char *      parent;                  /* if this is a clone, the name of the parent */
100   const char *      name;                  /* short (8-character) name of the game */
101   const char *      description;            /* full name of the game */
102   const char *      year;                  /* year the game was released */
103   const char *      manufacturer;            /* manufacturer of the game */
104   machine_config_constructor machine_config;      /* machine driver tokens */
105   ioport_constructor   ipt;               /* pointer to array of input port tokens */
106   void            (*driver_init)(running_machine &machine); /* DRIVER_INIT callback */
107   const rom_entry *   rom;                  /* pointer to list of ROMs for the game */
108   const char *      compatible_with;
109   UINT32            flags;                  /* orientation and other flags; see defines below */
110   const char *      default_layout;            /* default internally defined layout */
111};
112
113
114// driver_list is a purely static class that wraps the global driver list
115class driver_list
116{
117   DISABLE_COPYING(driver_list);
118
119protected:
60public:
12061   // construction/destruction
121   driver_list();
62   driver_device(const machine_config &mconfig, device_type type, const char *tag);
63   virtual ~driver_device();
12264
123public:
124   // getters
125   static int total() { return s_driver_count; }
65   // indexes into our generic callbacks
66   enum callback_type
67   {
68      CB_MACHINE_START,
69      CB_MACHINE_RESET,
70      CB_SOUND_START,
71      CB_SOUND_RESET,
72      CB_VIDEO_START,
73      CB_VIDEO_RESET,
74      CB_COUNT
75   };
12676
127   // any item by index
128   static const game_driver &driver(int index) { assert(index >= 0 && index < s_driver_count); return *s_drivers_sorted[index]; }
129   static int clone(int index) { return find(driver(index).parent); }
130   static int non_bios_clone(int index) { int result = find(driver(index).parent); return (result != -1 && (driver(result).flags & GAME_IS_BIOS_ROOT) == 0) ? result : -1; }
131   static int compatible_with(int index) { return find(driver(index).compatible_with); }
77   // inline configuration helpers
78   static void static_set_game(device_t &device, const game_driver &game);
79   static void static_set_callback(device_t &device, callback_type type, legacy_callback_func callback);
80   static void static_set_palette_init(device_t &device, palette_init_func callback);
13281
133   // any item by driver
134   static int clone(const game_driver &driver) { int index = find(driver); assert(index != -1); return clone(index); }
135   static int non_bios_clone(const game_driver &driver) { int index = find(driver); assert(index != -1); return non_bios_clone(index); }
136   static int compatible_with(const game_driver &driver) { int index = find(driver); assert(index != -1); return compatible_with(index); }
82   // generic helpers
13783
138   // general helpers
139   static int find(const char *name);
140   static int find(const game_driver &driver) { return find(driver.name); }
84   // watchdog read/write handlers
85   DECLARE_WRITE8_MEMBER( watchdog_reset_w );
86   DECLARE_READ8_MEMBER( watchdog_reset_r );
87   DECLARE_WRITE16_MEMBER( watchdog_reset16_w );
88   DECLARE_READ16_MEMBER( watchdog_reset16_r );
89   DECLARE_WRITE32_MEMBER( watchdog_reset32_w );
90   DECLARE_READ32_MEMBER( watchdog_reset32_r );
14191
142   // static helpers
143   static bool matches(const char *wildstring, const char *string);
92   // sound latch readers
93   DECLARE_READ8_MEMBER( soundlatch_r );
94   DECLARE_READ8_MEMBER( soundlatch2_r );
95   DECLARE_READ8_MEMBER( soundlatch3_r );
96   DECLARE_READ8_MEMBER( soundlatch4_r );
97   DECLARE_READ16_MEMBER( soundlatch_word_r );
98   DECLARE_READ16_MEMBER( soundlatch2_word_r );
99   DECLARE_READ16_MEMBER( soundlatch3_word_r );
100   DECLARE_READ16_MEMBER( soundlatch4_word_r );
144101
145protected:
146   // internal helpers
147   static int driver_sort_callback(const void *elem1, const void *elem2);
148   static int penalty_compare(const char *source, const char *target);
102   // sound latch writers
103   DECLARE_WRITE8_MEMBER( soundlatch_w );
104   DECLARE_WRITE8_MEMBER( soundlatch2_w );
105   DECLARE_WRITE8_MEMBER( soundlatch3_w );
106   DECLARE_WRITE8_MEMBER( soundlatch4_w );
107   DECLARE_WRITE16_MEMBER( soundlatch_word_w );
108   DECLARE_WRITE16_MEMBER( soundlatch2_word_w );
109   DECLARE_WRITE16_MEMBER( soundlatch3_word_w );
110   DECLARE_WRITE16_MEMBER( soundlatch4_word_w );
149111
150   // internal state
151   static int                     s_driver_count;
152   static const game_driver * const   s_drivers_sorted[];
153};
112   // sound latch clearers
113   DECLARE_WRITE8_MEMBER( soundlatch_clear_w );
114   DECLARE_WRITE8_MEMBER( soundlatch2_clear_w );
115   DECLARE_WRITE8_MEMBER( soundlatch3_clear_w );
116   DECLARE_WRITE8_MEMBER( soundlatch4_clear_w );
117   
118   // general palette helpers
119   void set_color_332(pen_t color, int rshift, int gshift, int bshift, UINT32 data);
120   void set_color_444(pen_t color, int rshift, int gshift, int bshift, UINT32 data);
121   void set_color_555(pen_t color, int rshift, int gshift, int bshift, UINT32 data);
122   void set_color_565(pen_t color, int rshift, int gshift, int bshift, UINT32 data);
123   void set_color_888(pen_t color, int rshift, int gshift, int bshift, UINT32 data);
124   void set_color_4444(pen_t color, int ishift, int rshift, int gshift, int bshift, UINT16 data);
154125
126   // 3-3-2 RGB palette write handlers
127   DECLARE_WRITE8_MEMBER( paletteram_BBGGGRRR_w );
128   DECLARE_WRITE8_MEMBER( paletteram_RRRGGGBB_w );
129   DECLARE_WRITE8_MEMBER( paletteram_BBGGRRII_w );
130   DECLARE_WRITE8_MEMBER( paletteram_IIBBGGRR_w );
155131
156// driver_enumerator enables efficient iteration through the driver list
157class driver_enumerator : public driver_list
158{
159   DISABLE_COPYING(driver_enumerator);
132   // 4-4-4 RGB palette write handlers
133   DECLARE_WRITE8_MEMBER( paletteram_xxxxBBBBGGGGRRRR_le_w );
134   DECLARE_WRITE8_MEMBER( paletteram_xxxxBBBBGGGGRRRR_be_w );
135   DECLARE_WRITE8_MEMBER( paletteram_xxxxBBBBGGGGRRRR_split1_w );   // uses paletteram
136   DECLARE_WRITE8_MEMBER( paletteram_xxxxBBBBGGGGRRRR_split2_w );   // uses paletteram2
137   DECLARE_WRITE16_MEMBER( paletteram16_xxxxBBBBGGGGRRRR_word_w );
160138
161public:
162   // construction/destruction
163   driver_enumerator(emu_options &options);
164   driver_enumerator(emu_options &options, const char *filter);
165   driver_enumerator(emu_options &options, const game_driver &filter);
166   ~driver_enumerator();
139   DECLARE_WRITE8_MEMBER( paletteram_xxxxBBBBRRRRGGGG_le_w );
140   DECLARE_WRITE8_MEMBER( paletteram_xxxxBBBBRRRRGGGG_be_w );
141   DECLARE_WRITE8_MEMBER( paletteram_xxxxBBBBRRRRGGGG_split1_w );   // uses paletteram
142   DECLARE_WRITE8_MEMBER( paletteram_xxxxBBBBRRRRGGGG_split2_w );   // uses paletteram2
143   DECLARE_WRITE16_MEMBER( paletteram16_xxxxBBBBRRRRGGGG_word_w );
167144
168   // getters
169   int count() const { return m_filtered_count; }
170   int current() const { return m_current; }
171   emu_options &options() const { return m_options; }
145   DECLARE_WRITE8_MEMBER( paletteram_xxxxRRRRBBBBGGGG_split1_w );   // uses paletteram
146   DECLARE_WRITE8_MEMBER( paletteram_xxxxRRRRBBBBGGGG_split2_w );   // uses paletteram2
172147
173   // current item
174   const game_driver &driver() const { return driver_list::driver(m_current); }
175   machine_config &config() const { return config(m_current, m_options); }
176   int clone() { return driver_list::clone(m_current); }
177   int non_bios_clone() { return driver_list::non_bios_clone(m_current); }
178   int compatible_with() { return driver_list::compatible_with(m_current); }
179   void include() { include(m_current); }
180   void exclude() { exclude(m_current); }
148   DECLARE_WRITE8_MEMBER( paletteram_xxxxRRRRGGGGBBBB_le_w );
149   DECLARE_WRITE8_MEMBER( paletteram_xxxxRRRRGGGGBBBB_be_w );
150   DECLARE_WRITE8_MEMBER( paletteram_xxxxRRRRGGGGBBBB_split1_w );   // uses paletteram
151   DECLARE_WRITE8_MEMBER( paletteram_xxxxRRRRGGGGBBBB_split2_w );   // uses paletteram2
152   DECLARE_WRITE16_MEMBER( paletteram16_xxxxRRRRGGGGBBBB_word_w );
181153
182   // any item by index
183   bool included(int index) const { assert(index >= 0 && index < s_driver_count); return m_included[index]; }
184   bool excluded(int index) const { assert(index >= 0 && index < s_driver_count); return !m_included[index]; }
185   machine_config &config(int index) const { return config(index,m_options); }
186   machine_config &config(int index, emu_options &options) const;
187   void include(int index) { assert(index >= 0 && index < s_driver_count); if (!m_included[index]) { m_included[index] = true; m_filtered_count++; }  }
188   void exclude(int index) { assert(index >= 0 && index < s_driver_count); if (m_included[index]) { m_included[index] = false; m_filtered_count--; } }
189   using driver_list::driver;
190   using driver_list::clone;
191   using driver_list::non_bios_clone;
192   using driver_list::compatible_with;
154   DECLARE_WRITE8_MEMBER( paletteram_RRRRGGGGBBBBxxxx_be_w );
155   DECLARE_WRITE8_MEMBER( paletteram_RRRRGGGGBBBBxxxx_split1_w );   // uses paletteram
156   DECLARE_WRITE8_MEMBER( paletteram_RRRRGGGGBBBBxxxx_split2_w );   // uses paletteram2
157   DECLARE_WRITE16_MEMBER( paletteram16_RRRRGGGGBBBBxxxx_word_w );
193158
194   // filtering/iterating
195   int filter(const char *string = NULL);
196   int filter(const game_driver &driver);
197   void include_all();
198   void exclude_all() { memset(m_included, 0, sizeof(m_included[0]) * s_driver_count); m_filtered_count = 0; }
199   void reset() { m_current = -1; }
200   bool next();
201   bool next_excluded();
159   // 4-4-4-4 IRGB palette write handlers
160   DECLARE_WRITE16_MEMBER( paletteram16_IIIIRRRRGGGGBBBB_word_w );
161   DECLARE_WRITE16_MEMBER( paletteram16_RRRRGGGGBBBBIIII_word_w );
202162
203   // general helpers
204   void set_current(int index) { assert(index >= -1 && index <= s_driver_count); m_current = index; }
205   void find_approximate_matches(const char *string, int count, int *results);
163   // 5-5-5 RGB palette write handlers
164   DECLARE_WRITE8_MEMBER( paletteram_xBBBBBGGGGGRRRRR_le_w );
165   DECLARE_WRITE8_MEMBER( paletteram_xBBBBBGGGGGRRRRR_be_w );
166   DECLARE_WRITE8_MEMBER( paletteram_xBBBBBGGGGGRRRRR_split1_w );   // uses paletteram
167   DECLARE_WRITE8_MEMBER( paletteram_xBBBBBGGGGGRRRRR_split2_w );   // uses paletteram2
168   DECLARE_WRITE16_MEMBER( paletteram16_xBBBBBGGGGGRRRRR_word_w );
206169
207private:
208   // entry in the config cache
209   struct config_entry
210   {
211      friend class simple_list<config_entry>;
170   DECLARE_WRITE8_MEMBER( paletteram_xBBBBBRRRRRGGGGG_split1_w );  // uses paletteram
171   DECLARE_WRITE8_MEMBER( paletteram_xBBBBBRRRRRGGGGG_split2_w );  // uses paletteram2
212172
213   public:
214      // construction/destruction
215      config_entry(machine_config &config, int index);
216      ~config_entry();
173   DECLARE_WRITE8_MEMBER( paletteram_xRRRRRGGGGGBBBBB_le_w );
174   DECLARE_WRITE8_MEMBER( paletteram_xRRRRRGGGGGBBBBB_be_w );
175   DECLARE_WRITE8_MEMBER( paletteram_xRRRRRGGGGGBBBBB_split1_w );
176   DECLARE_WRITE8_MEMBER( paletteram_xRRRRRGGGGGBBBBB_split2_w );
177   DECLARE_WRITE16_MEMBER( paletteram16_xRRRRRGGGGGBBBBB_word_w );
217178
218      // getters
219      config_entry *next() const { return m_next; }
220      int index() const { return m_index; }
221      machine_config *config() const { return m_config; }
179   DECLARE_WRITE16_MEMBER( paletteram16_xGGGGGRRRRRBBBBB_word_w );
180   DECLARE_WRITE16_MEMBER( paletteram16_xGGGGGBBBBBRRRRR_word_w );
222181
223   private:
224      // internal state
225      config_entry *      m_next;
226      machine_config *   m_config;
227      int               m_index;
228   };
182   DECLARE_WRITE16_MEMBER( paletteram16_RRRRRGGGGGBBBBBx_word_w );
183   DECLARE_WRITE16_MEMBER( paletteram16_GGGGGRRRRRBBBBBx_word_w );
184   DECLARE_WRITE16_MEMBER( paletteram16_RRRRGGGGBBBBRGBx_word_w );
229185
230   static const int CONFIG_CACHE_COUNT = 100;
186   // 8-8-8 RGB palette write handlers
187   DECLARE_WRITE16_MEMBER( paletteram16_xrgb_word_be_w );
188   DECLARE_WRITE16_MEMBER( paletteram16_xbgr_word_be_w );
231189
232   // internal state
233   int               m_current;
234   int               m_filtered_count;
235   emu_options &      m_options;
236   UINT8 *            m_included;
237   machine_config **   m_config;
238   mutable simple_list<config_entry> m_config_cache;
239};
190protected:
191   // helpers called at startup
192   virtual void driver_start();
193   virtual void machine_start();
194   virtual void sound_start();
195   virtual void video_start();
240196
197   // helpers called at reset
198   virtual void driver_reset();
199   virtual void machine_reset();
200   virtual void sound_reset();
201   virtual void video_reset();
241202
203   // device-level overrides
204   virtual const rom_entry *device_rom_region() const;
205   virtual ioport_constructor device_input_ports() const;
206   virtual void device_start();
207   virtual void device_reset_after_children();
242208
243/***************************************************************************
244    MACROS FOR BUILDING GAME DRIVERS
245***************************************************************************/
209   // internal helpers
210   inline UINT16 paletteram16_le(offs_t offset) const { return m_generic_paletteram_8[offset & ~1] | (m_generic_paletteram_8[offset |  1] << 8); }
211   inline UINT16 paletteram16_be(offs_t offset) const { return m_generic_paletteram_8[offset |  1] | (m_generic_paletteram_8[offset & ~1] << 8); }
212   inline UINT16 paletteram16_split(offs_t offset) const { return m_generic_paletteram_8[offset] | (m_generic_paletteram2_8[offset] << 8); }
213   inline UINT32 paletteram32_be(offs_t offset) const { return m_generic_paletteram_16[offset | 1] | (m_generic_paletteram_16[offset & ~1] << 16); }
246214
215   // internal state
216   const game_driver *      m_system;               // pointer to the game driver
247217
248#define DRIVER_INIT_NAME(name)      driver_init_##name
249#define DRIVER_INIT(name)         void DRIVER_INIT_NAME(name)(running_machine &machine)
250#define DRIVER_INIT_CALL(name)      DRIVER_INIT_NAME(name)(machine)
218   legacy_callback_func   m_callbacks[CB_COUNT];      // generic legacy callbacks
219   palette_init_func      m_palette_init;            // one-time palette init callback
251220
252#define driver_init_0            NULL
253
254
255#define GAME_NAME(name) driver_##name
256#define GAME_EXTERN(name) extern const game_driver GAME_NAME(name)
257
258#define GAME(YEAR,NAME,PARENT,MACHINE,INPUT,INIT,MONITOR,COMPANY,FULLNAME,FLAGS)   \
259   GAMEL(YEAR,NAME,PARENT,MACHINE,INPUT,INIT,MONITOR,COMPANY,FULLNAME,FLAGS,((const char *)0))
260
261#define GAMEL(YEAR,NAME,PARENT,MACHINE,INPUT,INIT,MONITOR,COMPANY,FULLNAME,FLAGS,LAYOUT)   \
262extern const game_driver GAME_NAME(NAME) =   \
263{                                 \
264   __FILE__,                        \
265   #PARENT,                        \
266   #NAME,                           \
267   FULLNAME,                        \
268   #YEAR,                           \
269   COMPANY,                        \
270   MACHINE_CONFIG_NAME(MACHINE),         \
271   INPUT_PORTS_NAME(INPUT),            \
272   DRIVER_INIT_NAME(INIT),               \
273   ROM_NAME(NAME),                     \
274   NULL,                           \
275   (MONITOR)|(FLAGS)|GAME_TYPE_ARCADE,      \
276   &LAYOUT[0]                        \
221public:
222   // generic pointers
223   optional_shared_ptr<UINT8> m_generic_paletteram_8;
224   optional_shared_ptr<UINT8> m_generic_paletteram2_8;
225   optional_shared_ptr<UINT16> m_generic_paletteram_16;
226   optional_shared_ptr<UINT16> m_generic_paletteram2_16;
227   optional_shared_ptr<UINT32> m_generic_paletteram_32;
228   optional_shared_ptr<UINT32> m_generic_paletteram2_32;
277229};
278230
279#define CONS(YEAR,NAME,PARENT,COMPAT,MACHINE,INPUT,INIT,COMPANY,FULLNAME,FLAGS)   \
280extern const game_driver GAME_NAME(NAME) =   \
281{                                 \
282   __FILE__,                        \
283   #PARENT,                        \
284   #NAME,                           \
285   FULLNAME,                        \
286   #YEAR,                           \
287   COMPANY,                        \
288   MACHINE_CONFIG_NAME(MACHINE),         \
289   INPUT_PORTS_NAME(INPUT),            \
290   DRIVER_INIT_NAME(INIT),               \
291   ROM_NAME(NAME),                     \
292   #COMPAT,                        \
293   ROT0|(FLAGS)|GAME_TYPE_CONSOLE,         \
294   NULL                           \
295};
296231
297#define COMP(YEAR,NAME,PARENT,COMPAT,MACHINE,INPUT,INIT,COMPANY,FULLNAME,FLAGS)   \
298extern const game_driver GAME_NAME(NAME) =   \
299{                                 \
300   __FILE__,                        \
301   #PARENT,                        \
302   #NAME,                           \
303   FULLNAME,                        \
304   #YEAR,                           \
305   COMPANY,                        \
306   MACHINE_CONFIG_NAME(MACHINE),         \
307   INPUT_PORTS_NAME(INPUT),            \
308   DRIVER_INIT_NAME(INIT),               \
309   ROM_NAME(NAME),                     \
310   #COMPAT,                        \
311   ROT0|(FLAGS)|GAME_TYPE_COMPUTER,      \
312   NULL                           \
313};
232// this template function creates a stub which constructs a device
233template<class _DriverClass>
234device_t *driver_device_creator(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
235{
236   assert(owner == NULL);
237   assert(clock == 0);
238   return global_alloc_clear(_DriverClass(mconfig, &driver_device_creator<_DriverClass>, tag));
239}
314240
315#define SYST(YEAR,NAME,PARENT,COMPAT,MACHINE,INPUT,INIT,COMPANY,FULLNAME,FLAGS)   \
316extern const game_driver GAME_NAME(NAME) =   \
317{                                 \
318   __FILE__,                        \
319   #PARENT,                        \
320   #NAME,                           \
321   FULLNAME,                        \
322   #YEAR,                           \
323   COMPANY,                        \
324   MACHINE_CONFIG_NAME(MACHINE),         \
325   INPUT_PORTS_NAME(INPUT),            \
326   DRIVER_INIT_NAME(INIT),               \
327   ROM_NAME(NAME),                     \
328   #COMPAT,                        \
329   ROT0|(FLAGS)|GAME_TYPE_OTHER,      \
330   NULL                           \
331};
332241
333/***************************************************************************
334    GLOBAL VARIABLES
335***************************************************************************/
336
337GAME_EXTERN(___empty);
338
339
340
341#endif
242#endif   /* __DRIVER_H__ */

Previous 15994 Revisions Next


© 1998-2018 The MESS Team