Previous 15994 Revisions Next

r5522 Saturday 29th August, 2009 at 12:01:55 UTC by Roberto Zandonà
[C64] fixed some carts
[src/mess/machine]c64.c

src/mess/machine/c64.c
r5521r5522
4646#define log_cart 0
4747
4848/* expansion port lines input */
49int c64_pal = 0;
49int c64_pal;
5050UINT8 c64_game = 1, c64_exrom = 1;
5151
5252/* cpu port */
r5521r5522
6868static int c64_cia1_on;
6969static int c64_io_enabled = 0;
7070static int is_sx64;            // temporary workaround until we implement full vc1541 emulation for every c64 set
71static UINT8 c64_cart_loaded = 0;
71static UINT8 c64_cart_n_banks = 0;
7272
7373static UINT8 serial_clock, serial_data, serial_atn;
7474static UINT8 vicirq = 0;
r5521r5522
10281028
10291029/* Hardware Types for C64 carts */
10301030enum {
1031   GENERIC_CRT = 0,   /* 00 - Normal cartridge               */
1031   GENERIC_CRT = 0,      /* 00 - Normal cartridge               */
10321032   ACTION_REPLAY,      /* 01 - Action Replay                  */
1033   KCS_PC,            /* 02 - KCS Power Cartridge               */
1033   KCS_PC,         /* 02 - KCS Power Cartridge               */
10341034   FINAL_CART_III,      /* 03 - Final Cartridge III               */
10351035   SIMONS_BASIC,      /* 04 - Simons Basic                  */
10361036   OCEAN_1,         /* 05 - Ocean type 1 (1)               */
1037   EXPERT,            /* 06 - Expert Cartridge               */
1038   FUN_PLAY,         /* 07 - Fun Play, Power Play            */
1039   SUPER_GAMES,      /* 08 - Super Games                     */
1037   EXPERT,         /* 06 - Expert Cartridge               */
1038   FUN_PLAY,         /* 07 - Fun Play, Power Play               */
1039   SUPER_GAMES,      /* 08 - Super Games                  */
10401040   ATOMIC_POWER,      /* 09 - Atomic Power                  */
10411041   EPYX_FASTLOAD,      /* 10 - Epyx Fastload                  */
10421042   WESTERMANN,         /* 11 - Westermann Learning               */
1043   REX,            /* 12 - Rex Utility                     */
1043   REX,            /* 12 - Rex Utility                  */
10441044   FINAL_CART_I,      /* 13 - Final Cartridge I               */
10451045   MAGIC_FORMEL,      /* 14 - Magic Formel                  */
1046   C64GS,            /* 15 - C64 Game System, System 3         */
1046   C64GS,         /* 15 - C64 Game System, System 3            */
10471047   WARPSPEED,         /* 16 - WarpSpeed                     */
1048   DINAMIC,         /* 17 - Dinamic (2)                     */
1049   ZAXXON,            /* 18 - Zaxxon, Super Zaxxon (SEGA)         */
1050   DOMARK,            /* 19 - Magic Desk, Domark, HES Australia   */
1048   DINAMIC,         /* 17 - Dinamic (2)                  */
1049   ZAXXON,         /* 18 - Zaxxon, Super Zaxxon (SEGA)            */
1050   DOMARK,         /* 19 - Magic Desk, Domark, HES Australia         */
10511051   SUPER_SNAP_5,      /* 20 - Super Snapshot 5               */
10521052   COMAL_80,         /* 21 - Comal-80                     */
10531053   STRUCT_BASIC,      /* 22 - Structured Basic               */
1054   ROSS,            /* 23 - Ross                        */
1054   ROSS,            /* 23 - Ross                     */
10551055   DELA_EP64,         /* 24 - Dela EP64                     */
1056   DELA_EP7X8,         /* 25 - Dela EP7x8                     */
1057   DELA_EP256,         /* 26 - Dela EP256                     */
1056   DELA_EP7X8,         /* 25 - Dela EP7x8                  */
1057   DELA_EP256,         /* 26 - Dela EP256                  */
10581058   REX_EP256,         /* 27 - Rex EP256                     */
10591059   MIKRO_ASSMBLR,      /* 28 - Mikro Assembler                  */
1060   REAL_FC_I,         /* 29 - (3)                           */
1061   ACTION_REPLAY_4,   /* 30 - Action Replay 4                  */
1062   STARDOS,         /* 31 - StarDOS                        */
1060   REAL_FC_I,         /* 29 - (3)                        */
1061   ACTION_REPLAY_4,      /* 30 - Action Replay 4                  */
1062   STARDOS,         /* 31 - StarDOS                     */
10631063   /*
10641064   (1) Ocean type 1 includes Navy Seals, Robocop 2 & 3,  Shadow  of
10651065   the Beast, Toki, Terminator 2 and more. Both 256 and 128 Kb images.
r5521r5522
10821082
10831083static DEVICE_IMAGE_LOAD(c64_cart)
10841084{
1085   int size = image_length(image), test, i = 0;
1085   int size = image_length(image), test, i = 0, n_banks;
10861086   const char *filetype;
1087   int address = 0, lbank_end_addr = 0, hbank_end_addr = 0, new_start = 0;
1087   int address = 0, new_start = 0;
1088   // int lbank_end_addr = 0, hbank_end_addr = 0;
10881089   UINT8 *cart = memory_region(image->machine, "cart");
10891090
10901091   filetype = image_filetype(image);
r5521r5522
11121113      switch (c64_cart_type)
11131114      {
11141115         case GENERIC_CRT:
1116            printf("Currently supported cart type (Type %d)\n", c64_cart_type);
11151117            break;
11161118
11171119         default:
1118            logerror("Currently unsupported cart type (Type %d)\n", c64_cart_type);
1120            printf("Currently unsupported cart type (Type %d)\n", c64_cart_type);
11191121            break;
11201122      }
11211123
r5521r5522
11971199         j += chip_size;
11981200      }
11991201   }
1200
1201   /* We also support .80 files for c64 & .e0/.f0 for max */
1202   else
1202   else /* We also support .80 files for c64 & .e0/.f0 for max */
12031203   {
12041204      /* Assign loading address according to extension */
12051205      if (!mame_stricmp (filetype, "80"))
r5521r5522
12321232         return INIT_FAIL;
12331233   }
12341234
1235   n_banks = i;
1236
12351237   /* If we load a .crt file, use EXROM & GAME from the header! */
12361238   if ((cbm_c64_exrom != -1) && (cbm_c64_game != -1))
12371239   {
r5521r5522
12441246   roml = c64_roml;
12451247   romh = c64_romh;
12461248
1247   memset(roml, 0, 0x4000);
1249   memset(roml, 0, 0x2000);
12481250   memset(romh, 0, 0x2000);
12491251
12501252   /* a bit hacky, until we have fixed the bankswitch part... it will be improved afterwards! */
r5521r5522
12521254   /* now we have bankswitch handlers for some cart types, but we keep loading first 1 or 2 banks here, for carts without bankswitch */
12531255   /* to be sure we only load the first pieces, we check that cart.addr is larger than the previous and that no more than 2 CHIPs are loaded */
12541256   for (i = 0; (i < sizeof(c64_cbm_cart) / sizeof(c64_cbm_cart[0])) && (c64_cbm_cart[i].size != 0); i++)
1257/*
12551258   {
1256      /* load the bank only if the space is free */
1259      // load the bank only if the space is free
12571260      if ((c64_cbm_cart[i].addr < 0xc000) && (c64_cbm_cart[i].addr >= lbank_end_addr + 0x8000) && (i < 2))
12581261      {
12591262         memcpy(roml + c64_cbm_cart[i].addr - 0x8000, cart + c64_cbm_cart[i].start, c64_cbm_cart[i].size);
r5521r5522
12651268         hbank_end_addr += c64_cbm_cart[i].addr - 0xe000 + c64_cbm_cart[i].size;
12661269      }
12671270   }
1271*/
1272   memcpy(roml, cart + 0 * 0x2000, 0x2000);
1273   if (n_banks > 1) memcpy(romh, cart + 1 * 0x2000, 0x2000);
12681274
1269   c64_cart_loaded = 1; // this is needed so that we only set mappers if a cart is present!
1275   c64_cart_n_banks = n_banks; // this is needed so that we only set mappers if a cart is present!
12701276   return INIT_PASS;
12711277}
12721278
r5521r5522
12921298
12931299static WRITE8_HANDLER( ocean1_bank_w )
12941300{
1301   // Type # 5
1302   // working: Ghostbusters, Terminator 2
1303   // not working: Pang, Robocop 2, Toki
1304
12951305   UINT8 bank = data & 0x3f;
12961306   UINT8 *cart = memory_region(space->machine, "cart");
12971307
1298   if (bank < 32)
1308   if (c64_cart_n_banks != 64)                        // all carts except Terminator II
1309   {
1310      if (bank < 16)
1311         memcpy(roml, cart + bank * 0x2000, 0x2000);
1312      else
1313         memcpy(romh, cart + (bank - 16) * 0x2000, 0x2000);
1314   }
1315   else                                   // Terminator II
1316   {
12991317      memcpy(roml, cart + bank * 0x2000, 0x2000);
1300   else
1301      memcpy(romh, cart + (bank - 32) * 0x2000, 0x2000);
1318   }
13021319/*
13031320   if (log_cart)
13041321   {
r5521r5522
13111328
13121329static WRITE8_HANDLER( funplay_bank_w )
13131330{
1331   // Type # 7
1332   // working:
1333   // not working:
1334
13141335   UINT8 bank = data & 0x39, real_bank = 0;
1315   UINT8 *mem = memory_region(space->machine, "maincpu");
13161336   UINT8 *cart = memory_region(space->machine, "cart");
13171337
13181338   /* This should be written after the bankswitch has happened. We log it to see if it is really working */
r5521r5522
13231343      /* bank number is not the value written, but c64_cbm_cart[bank].index IS the value written! */
13241344      real_bank = ((bank & 0x01) << 3) + ((bank & 0x38) >> 3);
13251345
1326      memcpy(mem + c64_cbm_cart[bank].addr, cart + c64_cbm_cart[bank].start, c64_cbm_cart[bank].size);
1346//      memcpy(mem + c64_cbm_cart[bank].addr, cart + c64_cbm_cart[bank].start, c64_cbm_cart[bank].size);
13271347
1348      memcpy(roml, cart + real_bank * 0x2000, 0x2000);
1349
13281350      if (log_cart)
13291351      {
13301352         logerror("bank %d of size %d successfully loaded at %d!\n", bank, c64_cbm_cart[bank].size, c64_cbm_cart[bank].addr);
r5521r5522
13361358
13371359static WRITE8_HANDLER( c64gs_bank_w )
13381360{
1361   // Type # 15
1362   // working:
1363   // not working: The Last Ninja Remix
1364
13391365   UINT8 bank = offset & 0xff;
1340   UINT8 *mem = memory_region(space->machine, "maincpu");
13411366   UINT8 *cart = memory_region(space->machine, "cart");
13421367
13431368   if (bank > 0x3f)
13441369      logerror("Warning: This cart type should have at most 64 banks and the cart looked for bank %d... Something strange is going on!\n", bank);
13451370
1346   memcpy(mem + c64_cbm_cart[bank].addr, cart + c64_cbm_cart[bank].start, c64_cbm_cart[bank].size);
1371//   memcpy(mem + c64_cbm_cart[bank].addr, cart + c64_cbm_cart[bank].start, c64_cbm_cart[bank].size);
13471372
1373   memcpy(roml, cart + bank * 0x2000, 0x2000);
1374
13481375   if (log_cart)
13491376   {
13501377      logerror("bank %d of size %d successfully loaded at %d!\n", bank, c64_cbm_cart[bank].size, c64_cbm_cart[bank].addr);
r5521r5522
13551382
13561383static READ8_HANDLER( dinamic_bank_r )
13571384{
1385   // Type # 17
1386   // working: Satan
1387   // not working:
1388
13581389   UINT8 bank = offset & 0xff;
1359   UINT8 *mem = memory_region(space->machine, "maincpu");
13601390   UINT8 *cart = memory_region(space->machine, "cart");
13611391
13621392   if (bank > 0xf)
13631393      logerror("Warning: This cart type should have 16 banks and the cart looked for bank %d... Something strange is going on!\n", bank);
13641394
1365   memcpy(mem + c64_cbm_cart[bank].addr, cart + c64_cbm_cart[bank].start, c64_cbm_cart[bank].size);
1395   memcpy(roml, cart + bank * 0x2000, 0x2000);
13661396
1397//   memcpy(mem + c64_cbm_cart[bank].addr, cart + c64_cbm_cart[bank].start, c64_cbm_cart[bank].size);
1398
13671399   if (log_cart)
13681400   {
13691401      logerror("bank %d of size %d successfully loaded at %d!\n", bank, c64_cbm_cart[bank].size, c64_cbm_cart[bank].addr);
r5521r5522
13761408
13771409static WRITE8_HANDLER( comal80_bank_w )
13781410{
1411   // Type # 21
1412   // working: Comal 80
1413   // not working:
1414
13791415   UINT8 bank = data & 0x83;
13801416   UINT8 *cart = memory_region(space->machine, "cart");
13811417
r5521r5522
14041440
14051441   switch( c64_mapper )
14061442   {
1407      case FINAL_CART_III:    /* 4 16k banks, loaded at 0x8000, banks chosen by writing to 0xdfff */
1443      case KCS_PC:      /* Type #  2 not working*/
1444         break;
1445      case FINAL_CART_III:    /* Type #  3 - 4 16k banks, loaded at 0x8000, banks chosen by writing to 0xdfff */
14081446         memory_install_write8_handler( space, 0xdfff, 0xdfff, 0, 0, fc3_bank_w );
14091447         break;
1410      case OCEAN_1:           /* up to 64 8k banks, loaded at 0x8000 or 0xa000, banks chosen by writing to 0xde00 */
1448      case SIMONS_BASIC:   /* Type #  4 not working*/
1449         break;
1450      case OCEAN_1:           /* Type #  5 - up to 64 8k banks, loaded at 0x8000 or 0xa000, banks chosen by writing to 0xde00 */
14111451         memory_install_write8_handler( space, 0xde00, 0xde00, 0, 0, ocean1_bank_w );
14121452         break;
1413      case FUN_PLAY:          /* 16 8k banks, loaded at 0x8000, banks chosen by writing to 0xde00 */
1453      case FUN_PLAY:          /* Type #  7 - 16 8k banks, loaded at 0x8000, banks chosen by writing to 0xde00 */
14141454         memory_install_write8_handler( space, 0xde00, 0xde00, 0, 0, funplay_bank_w );
14151455         break;
1416      case C64GS:             /* up to 64 8k banks, loaded at 0x8000, banks chosen by writing to 0xde00+bank# */
1456      case EPYX_FASTLOAD:   /* Type # 10 not working*/
1457         break;
1458      case WESTERMANN:      /* Type # 11 not working*/
1459         break;
1460      case FINAL_CART_I:   /* Type # 13 not working*/
1461         break;
1462      case C64GS:             /* Type # 15 - up to 64 8k banks, loaded at 0x8000, banks chosen by writing to 0xde00 + bank */
14171463         memory_install_write8_handler( space, 0xde00, 0xdeff, 0, 0, c64gs_bank_w );
14181464         break;
1419      case DINAMIC:           /* 16 8k banks, loaded at 0x8000, banks chosen by reading to 0xde00+bank# */
1465      case DINAMIC:           /* Type # 17 - 16 8k banks, loaded at 0x8000, banks chosen by reading to 0xde00 + bank# */
14201466         memory_install_read8_handler( space, 0xde00, 0xdeff, 0, 0, dinamic_bank_r );
14211467         break;
1422      case COMAL_80:          /* 4 16k banks, loaded at 0x8000, banks chosen by writing(?) to 0xde00 */
1468      case COMAL_80:          /* Type # 21 - 4 16k banks, loaded at 0x8000, banks chosen by writing the value 0x80 + bank to 0xde00 */
14231469         memory_install_write8_handler( space, 0xde00, 0xde00, 0, 0, comal80_bank_w );
14241470         break;
1425      case GENERIC_CRT:       /* single bank, no bankswitch, loaded at start with correct size and place */
1471      case GENERIC_CRT:       /* Type #  0 - single bank, no bankswitch, loaded at start with correct size and place */
14261472      default:
14271473         break;
14281474   }
r5521r5522
14311477
14321478MACHINE_RESET( c64 )
14331479{
1434   if(c64_cart_loaded)
1480   if(c64_cart_n_banks)
14351481      setup_c64_custom_mappers(machine);
14361482}
14371483

Previous 15994 Revisions Next


© 1998-2018 The MESS Team