src/mess/machine/gamecom.c
| r6137 | r6138 | |
| 50 | 50 | static UINT8 *cartridge1 = NULL; |
| 51 | 51 | static UINT8 *cartridge2 = NULL; |
| 52 | 52 | static UINT8 *cartridge = NULL; |
| 53 | | static UINT8 *dummy_bank = NULL; |
| 54 | 53 | |
| 55 | 54 | static emu_timer *gamecom_clock_timer = NULL; |
| 56 | 55 | static GAMECOM_DMA gamecom_dma; |
| r6137 | r6138 | |
| 79 | 78 | /* should possibly go in a DRIVER_INIT piece? */ |
| 80 | 79 | gamecom_clock_timer = timer_alloc(machine, gamecom_clock_timer_callback , NULL); |
| 81 | 80 | |
| 82 | | /* intialize the empty dummy bank */ |
| 83 | | if ( dummy_bank == NULL ) |
| 84 | | { |
| 85 | | dummy_bank = auto_alloc_array(machine, UINT8, 8 * 1024 ); |
| 86 | | } |
| 87 | | memset( dummy_bank, 0xff, 8 * 1024 ); |
| 88 | 81 | cartridge = NULL; |
| 89 | 82 | /* disable DMA and timer */ |
| 90 | 83 | gamecom_dma.enabled = 0; |
| r6137 | r6138 | |
| 97 | 90 | |
| 98 | 91 | static void gamecom_set_mmu( running_machine *machine, int mmu, UINT8 data ) |
| 99 | 92 | { |
| 100 | | if ( data < 32 ) |
| 93 | if ( data < 0x20 ) |
| 101 | 94 | { |
| 102 | 95 | /* select internal ROM bank */ |
| 103 | 96 | memory_set_bankptr( machine, mmu, memory_region(machine, "user1") + (data << 13) ); |
| r6137 | r6138 | |
| 105 | 98 | else |
| 106 | 99 | { |
| 107 | 100 | /* select cartridge bank */ |
| 108 | | if ( cartridge == NULL ) |
| 109 | | { |
| 110 | | memory_set_bankptr( machine, mmu, dummy_bank ); |
| 111 | | } |
| 112 | | else |
| 113 | | { |
| 101 | if ( cartridge ) |
| 114 | 102 | memory_set_bankptr( machine, mmu, cartridge + ( data << 13 ) ); |
| 115 | | } |
| 116 | 103 | } |
| 117 | 104 | } |
| 118 | 105 | |
| r6137 | r6138 | |
| 256 | 243 | case 0x80: cartridge = cartridge2; break; |
| 257 | 244 | default: cartridge = NULL; break; |
| 258 | 245 | } |
| 259 | | /* update banks to reflect possible change of cartridge slot */ |
| 260 | | gamecom_set_mmu( space->machine, 1, gamecom_internal_registers[SM8521_MMU1] ); |
| 261 | | gamecom_set_mmu( space->machine, 2, gamecom_internal_registers[SM8521_MMU2] ); |
| 262 | | gamecom_set_mmu( space->machine, 3, gamecom_internal_registers[SM8521_MMU3] ); |
| 263 | | gamecom_set_mmu( space->machine, 4, gamecom_internal_registers[SM8521_MMU4] ); |
| 264 | 246 | return; |
| 265 | 247 | case SM8521_SYS: cpu_set_reg( cputag_get_cpu(space->machine, "maincpu"), SM8500_SYS, data ); return; |
| 266 | 248 | case SM8521_CKC: cpu_set_reg( cputag_get_cpu(space->machine, "maincpu"), SM8500_CKC, data ); return; |
| r6137 | r6138 | |
| 649 | 631 | return gamecom_vram[offset]; |
| 650 | 632 | } |
| 651 | 633 | |
| 652 | | DEVICE_START( gamecom_cart ) |
| 634 | DRIVER_INIT( gamecom ) |
| 653 | 635 | { |
| 654 | | internal_ram = devtag_get_info_ptr(device->machine, "maincpu", CPUINFO_PTR_SM8500_INTERNAL_RAM); |
| 636 | internal_ram = devtag_get_info_ptr(machine, "maincpu", CPUINFO_PTR_SM8500_INTERNAL_RAM); |
| 655 | 637 | } |
| 656 | 638 | |
| 657 | 639 | DEVICE_IMAGE_LOAD( gamecom_cart ) |
| 658 | 640 | { |
| 659 | | int filesize; |
| 660 | | int load_offset = 0; |
| 641 | UINT32 filesize; |
| 642 | UINT32 load_offset = 0; |
| 643 | UINT32 bytes_read; |
| 661 | 644 | |
| 662 | | /* allocate memory on first load of a cartridge */ |
| 663 | | if ( cartridge1 == NULL ) |
| 664 | | { |
| 665 | | cartridge1 = auto_alloc_array(image->machine, UINT8, 2048 * 1024 ); |
| 666 | | } |
| 645 | cartridge1 = memory_region(image->machine, "user2"); |
| 646 | |
| 667 | 647 | filesize = image_length( image ); |
| 668 | 648 | switch( filesize ) |
| 669 | 649 | { |
| r6137 | r6138 | |
| 674 | 654 | case 0x1c0000: load_offset = 0x040000; break; /* 1.8MB */ |
| 675 | 655 | case 0x200000: load_offset = 0; break; /* 2 MB */ |
| 676 | 656 | default: /* otherwise */ |
| 677 | | logerror( "Error loading cartridge: Invalid file size.\n" ); |
| 657 | logerror( "Error loading cartridge: Invalid file size 0x%X\n",filesize ); |
| 658 | image_seterror( image, IMAGE_ERROR_UNSPECIFIED, "Unhandled cart size" ); |
| 678 | 659 | return INIT_FAIL; |
| 679 | 660 | } |
| 680 | | if ( image_fread( image, cartridge1 + load_offset, filesize ) != filesize ) |
| 661 | bytes_read = image_fread( image, cartridge1 + load_offset, filesize ); |
| 662 | if (bytes_read != filesize ) |
| 681 | 663 | { |
| 682 | | logerror( "Error loading cartridge: Unable to read from file: %s.\n", image_filename(image) ); |
| 664 | logerror( "Error loading cartridge: Read 0x%X, should have been 0x%X\n",bytes_read,filesize ); |
| 665 | image_seterror( image, IMAGE_ERROR_UNSPECIFIED, "Unable to load all of the cart" ); |
| 683 | 666 | return INIT_FAIL; |
| 684 | 667 | } |
| 685 | 668 | if ( filesize < 0x010000 ) { memcpy( cartridge1 + 0x008000, cartridge1, 0x008000 ); } /* ->64KB */ |
src/mess/drivers/gamecom.c
| r6137 | r6138 | |
| 33 | 33 | AM_RANGE( 0xE000, 0xFFFF ) AM_RAM /* Extended I/O, Extended RAM */ |
| 34 | 34 | ADDRESS_MAP_END |
| 35 | 35 | |
| 36 | | static GFXDECODE_START( gamecom ) |
| 37 | | GFXDECODE_END |
| 38 | | |
| 39 | 36 | static const SM8500_CONFIG gamecom_cpu_config = { |
| 40 | 37 | gamecom_handle_dma, |
| 41 | 38 | gamecom_update_timers |
| r6137 | r6138 | |
| 109 | 106 | MDRV_SCREEN_SIZE( 200, 200 ) |
| 110 | 107 | MDRV_SCREEN_VISIBLE_AREA( 0, 199, 0, 159 ) |
| 111 | 108 | MDRV_DEFAULT_LAYOUT(layout_lcd) |
| 112 | | MDRV_GFXDECODE( gamecom ) |
| 113 | 109 | MDRV_PALETTE_LENGTH( GAMECOM_PALETTE_LENGTH ) |
| 114 | 110 | MDRV_PALETTE_INIT( gamecom ) |
| 115 | 111 | |
| r6137 | r6138 | |
| 126 | 122 | MDRV_CARTSLOT_ADD("cart") |
| 127 | 123 | MDRV_CARTSLOT_EXTENSION_LIST("bin,tgc") |
| 128 | 124 | MDRV_CARTSLOT_NOT_MANDATORY |
| 129 | | MDRV_CARTSLOT_START(gamecom_cart) |
| 130 | 125 | MDRV_CARTSLOT_LOAD(gamecom_cart) |
| 131 | 126 | MACHINE_DRIVER_END |
| 132 | 127 | |
| r6137 | r6138 | |
| 135 | 130 | ROM_LOAD( "internal.bin", 0x1000, 0x1000, CRC(a0cec361) SHA1(03368237e8fed4a8724f3b4a1596cf4b17c96d33) ) |
| 136 | 131 | ROM_REGION( 0x40000, "user1", 0 ) |
| 137 | 132 | ROM_LOAD( "external.bin", 0x00000, 0x40000, CRC(e235a589) SHA1(97f782e72d738f4d7b861363266bf46b438d9b50) ) |
| 133 | ROM_REGION( 0x200000, "user2", ROMREGION_ERASEFF ) |
| 138 | 134 | ROM_END |
| 139 | 135 | |
| 140 | 136 | /* YEAR NAME PARENT COMPAT MACHINE INPUT INIT CONFIG COMPANY FULLNAME */ |
| 141 | | CONS( 1997, gamecom, 0, 0, gamecom, gamecom, 0, 0, "Tiger", "Game.com", GAME_NOT_WORKING ) |
| 137 | CONS( 1997, gamecom, 0, 0, gamecom, gamecom, gamecom, 0, "Tiger", "Game.com", GAME_NOT_WORKING ) |
| 142 | 138 | |
| 143 | 139 | |