Previous 15994 Revisions Next

r6138 Monday 19th October, 2009 at 14:23:23 UTC by Robbbert
[GAMECOM] 1. Fixed crash on soft reset
2. Fixed various errors and crashes when loading carts
3. System now recognises 1MB and 2MB carts
[src/mess/drivers]gamecom.c
[src/mess/includes]gamecom.h
[src/mess/machine]gamecom.c

src/mess/includes/gamecom.h
r6137r6138
150150
151151extern MACHINE_RESET( gamecom );
152152extern DEVICE_START( gamecom_cart );
153extern DRIVER_INIT( gamecom );
153154extern DEVICE_IMAGE_LOAD( gamecom_cart );
154155
155156extern WRITE8_HANDLER( gamecom_internal_w );
src/mess/machine/gamecom.c
r6137r6138
5050static UINT8 *cartridge1 = NULL;
5151static UINT8 *cartridge2 = NULL;
5252static UINT8 *cartridge = NULL;
53static UINT8 *dummy_bank = NULL;
5453
5554static emu_timer *gamecom_clock_timer = NULL;
5655static GAMECOM_DMA gamecom_dma;
r6137r6138
7978   /* should possibly go in a DRIVER_INIT piece? */
8079   gamecom_clock_timer = timer_alloc(machine,  gamecom_clock_timer_callback , NULL);
8180
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 );
8881   cartridge = NULL;
8982   /* disable DMA and timer */
9083   gamecom_dma.enabled = 0;
r6137r6138
9790
9891static void gamecom_set_mmu( running_machine *machine, int mmu, UINT8 data )
9992{
100   if ( data < 32 )
93   if ( data < 0x20 )
10194   {
10295      /* select internal ROM bank */
10396      memory_set_bankptr( machine, mmu, memory_region(machine, "user1") + (data << 13) );
r6137r6138
10598   else
10699   {
107100      /* select cartridge bank */
108      if ( cartridge == NULL )
109      {
110         memory_set_bankptr( machine, mmu, dummy_bank );
111      }
112      else
113      {
101      if ( cartridge )
114102         memory_set_bankptr( machine, mmu, cartridge + ( data << 13 ) );
115      }
116103   }
117104}
118105
r6137r6138
256243            case 0x80: cartridge = cartridge2; break;
257244            default:   cartridge = NULL;       break;
258245            }
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] );
264246            return;
265247   case SM8521_SYS:   cpu_set_reg( cputag_get_cpu(space->machine, "maincpu"), SM8500_SYS, data ); return;
266248   case SM8521_CKC:   cpu_set_reg( cputag_get_cpu(space->machine, "maincpu"), SM8500_CKC, data ); return;
r6137r6138
649631   return gamecom_vram[offset];
650632}
651633
652DEVICE_START( gamecom_cart )
634DRIVER_INIT( gamecom )
653635{
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);
655637}
656638
657639DEVICE_IMAGE_LOAD( gamecom_cart )
658640{
659   int filesize;
660   int load_offset = 0;
641   UINT32 filesize;
642   UINT32 load_offset = 0;
643   UINT32 bytes_read;
661644
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
667647   filesize = image_length( image );
668648   switch( filesize )
669649   {
r6137r6138
674654   case 0x1c0000: load_offset = 0x040000; break;  /* 1.8MB */
675655   case 0x200000: load_offset = 0;        break;  /* 2  MB */
676656   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" );
678659      return INIT_FAIL;
679660   }
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 )
681663   {
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" );
683666      return INIT_FAIL;
684667   }
685668   if ( filesize < 0x010000 ) { memcpy( cartridge1 + 0x008000, cartridge1, 0x008000 ); } /* ->64KB */
src/mess/drivers/gamecom.c
r6137r6138
3333   AM_RANGE( 0xE000, 0xFFFF )  AM_RAM                                                 /* Extended I/O, Extended RAM */
3434ADDRESS_MAP_END
3535
36static GFXDECODE_START( gamecom )
37GFXDECODE_END
38
3936static const SM8500_CONFIG gamecom_cpu_config = {
4037   gamecom_handle_dma,
4138   gamecom_update_timers
r6137r6138
109106   MDRV_SCREEN_SIZE( 200, 200 )
110107   MDRV_SCREEN_VISIBLE_AREA( 0, 199, 0, 159 )
111108   MDRV_DEFAULT_LAYOUT(layout_lcd)
112   MDRV_GFXDECODE( gamecom )
113109   MDRV_PALETTE_LENGTH( GAMECOM_PALETTE_LENGTH )
114110   MDRV_PALETTE_INIT( gamecom )
115111
r6137r6138
126122   MDRV_CARTSLOT_ADD("cart")
127123   MDRV_CARTSLOT_EXTENSION_LIST("bin,tgc")
128124   MDRV_CARTSLOT_NOT_MANDATORY
129   MDRV_CARTSLOT_START(gamecom_cart)
130125   MDRV_CARTSLOT_LOAD(gamecom_cart)
131126MACHINE_DRIVER_END
132127
r6137r6138
135130   ROM_LOAD( "internal.bin", 0x1000,  0x1000, CRC(a0cec361) SHA1(03368237e8fed4a8724f3b4a1596cf4b17c96d33) )
136131   ROM_REGION( 0x40000, "user1", 0 )
137132   ROM_LOAD( "external.bin", 0x00000, 0x40000, CRC(e235a589) SHA1(97f782e72d738f4d7b861363266bf46b438d9b50) )
133   ROM_REGION( 0x200000, "user2", ROMREGION_ERASEFF )
138134ROM_END
139135
140136/*    YEAR  NAME     PARENT COMPAT MACHINE  INPUT    INIT CONFIG   COMPANY  FULLNAME */
141CONS( 1997, gamecom, 0,     0,     gamecom, gamecom, 0,   0, "Tiger", "Game.com", GAME_NOT_WORKING )
137CONS( 1997, gamecom, 0,     0,     gamecom, gamecom, gamecom,   0, "Tiger", "Game.com", GAME_NOT_WORKING )
142138
143139

Previous 15994 Revisions Next


© 1998-2018 The MESS Team