Previous 15994 Revisions Next

r8858 Monday 23rd August, 2010 at 05:52:37 UTC by Fabio Priuli
[C64] cleaned up a bit .crt loading routine and properly implemented loading address from CHIP header (this improves Ocean mapper and allows to remove a Zaxxon mapper hack)
[CBMB] cleaned up cart loading code
[PET] cleaned up cart loading code

+ cleaned up cbm.h inclusion
[src/mess/formats]cbm_snqk.c
[src/mess/includes]cbm.h
[src/mess/machine]c64.c cbmb.c pet.c sym1.c

src/mess/machine/cbmb.c
r8857r8858
99#include "sound/sid6581.h"
1010#include "machine/6525tpi.h"
1111#include "machine/6526cia.h"
12
13#include "includes/cbm.h"
1412#include "machine/ieee488.h"
1513
1614#include "includes/cbmb.h"
r8857r8858
4341static UINT8 *cbmb_chargen;
4442UINT8 *cbmb_videoram;
4543UINT8 *cbmb_colorram;
46static UINT8 *cbmb_memory;
4744
4845/* tpi at 0xfde00
4946 in interrupt mode
r8857r8858
497494
498495***********************************************/
499496
500
501static CBM_ROM cbmb_cbm_cart[0x20]= { {0} };
502
503497static DEVICE_IMAGE_LOAD(cbmb_cart)
504498{
505   int size = image.length(), test;
506   const char *filetype;
499   UINT32 size = image.length();
500   const char *filetype = image.filetype();
501   UINT8 *cbmb_memory = memory_region(image.device().machine, "maincpu");
507502   int address = 0;
508503
509   filetype = image.filetype();
504   /* Assign loading address according to extension */
505   if (!mame_stricmp(filetype, "10"))
506      address = 0x1000;
510507
511   if (!mame_stricmp(filetype, "crt"))
512   {
513   /* We temporarily remove .crt loading. Previous versions directly used
514    the same routines used to load C64 .crt file, but I seriously doubt the
515    formats are compatible. While waiting for confirmation about .crt dumps
516    for CBMB machines, we simply do not load .crt files */
517   }
518   else
519   {
520      /* Assign loading address according to extension */
521      if (!mame_stricmp(filetype, "10"))
522         address = 0x1000;
508   else if (!mame_stricmp(filetype, "20"))
509      address = 0x2000;
523510
524      else if (!mame_stricmp(filetype, "20"))
525         address = 0x2000;
511   else if (!mame_stricmp(filetype, "40"))
512      address = 0x4000;
526513
527      else if (!mame_stricmp(filetype, "40"))
528         address = 0x4000;
514   else if (!mame_stricmp(filetype, "60"))
515      address = 0x6000;
529516
530      else if (!mame_stricmp(filetype, "60"))
531         address = 0x6000;
517   logerror("Loading cart %s at %.4x size:%.4x\n", image.filename(), address, size);
532518
533      logerror("Loading cart %s at %.4x size:%.4x\n", image.filename(), address, size);
519   image.fread(cbmb_memory + 0xf0000 + address, size);
534520
535      /* Does cart contain any data? */
536      cbmb_cbm_cart[0].chip = (UINT8*) image.image_malloc(size);
537      if (!cbmb_cbm_cart[0].chip)
538         return IMAGE_INIT_FAIL;
539
540      /* Store data, address & size */
541      cbmb_cbm_cart[0].addr = address;
542      cbmb_cbm_cart[0].size = size;
543      test = image.fread(cbmb_cbm_cart[0].chip, cbmb_cbm_cart[0].size);
544
545      if (test != cbmb_cbm_cart[0].size)
546         return IMAGE_INIT_FAIL;
547   }
548
549   /* Finally load the cart */
550//  This could be needed with .crt support
551//  for (i = 0; (i < ARRAY_LENGTH(pet_cbm_cart)) && (pet_cbm_cart[i].size != 0); i++)
552//      memcpy(cbmb_memory + cbmb_cbm_cart[i].addr + 0xf0000, cbmb_cbm_cart[i].chip, cbmb_cbm_cart[i].size);
553   memcpy(cbmb_memory + cbmb_cbm_cart[0].addr + 0xf0000, cbmb_cbm_cart[0].chip, cbmb_cbm_cart[0].size);
554
555521   return IMAGE_INIT_PASS;
556522}
557523
558524
559525MACHINE_DRIVER_START(cbmb_cartslot)
560526   MDRV_CARTSLOT_ADD("cart1")
561   MDRV_CARTSLOT_EXTENSION_LIST("crt,10,20,40,60")
527   MDRV_CARTSLOT_EXTENSION_LIST("10,20,40,60")
562528   MDRV_CARTSLOT_NOT_MANDATORY
563529   MDRV_CARTSLOT_LOAD(cbmb_cart)
564530
565531   MDRV_CARTSLOT_ADD("cart2")
566   MDRV_CARTSLOT_EXTENSION_LIST("crt,10,20,40,60")
532   MDRV_CARTSLOT_EXTENSION_LIST("10,20,40,60")
567533   MDRV_CARTSLOT_NOT_MANDATORY
568534   MDRV_CARTSLOT_LOAD(cbmb_cart)
569535MACHINE_DRIVER_END
src/mess/machine/pet.c
r8857r8858
88#include "cpu/m6502/m6502.h"
99#include "cpu/m6809/m6809.h"
1010
11#include "includes/cbm.h"
1211#include "machine/6821pia.h"
1312#include "machine/6522via.h"
1413#include "machine/ieee488.h"
r8857r8858
847846
848847***********************************************/
849848
850
851static CBM_ROM pet_cbm_cart[0x20] = { {0} };
852
853
854849static DEVICE_IMAGE_LOAD(pet_cart)
855850{
856   int size = image.length(), test;
857   const char *filetype;
851   UINT32 size = image.length();
852   const char *filetype = image.filetype();
858853   int address = 0;
859854
860   filetype = image.filetype();
855   /* Assign loading address according to extension */
856   if (!mame_stricmp(filetype, "90"))
857      address = 0x9000;
858   else if (!mame_stricmp(filetype, "a0"))
859      address = 0xa000;
860   else if (!mame_stricmp(filetype, "b0"))
861      address = 0xb000;
861862
862   if (!mame_stricmp(filetype, "crt"))
863   {
864   /* We temporarily remove .crt loading. Previous versions directly used
865    the same routines used to load C64 .crt file, but I seriously doubt the
866    formats are compatible. While waiting for confirmation about .crt dumps
867    for PET machines, we simply do not load .crt files */
868   }
869   else
870   {
871      /* Assign loading address according to extension */
872      if (!mame_stricmp(filetype, "a0"))
873         address = 0xa000;
863   logerror("Loading cart %s at %.4x size:%.4x\n", image.filename(), address, size);
874864
875      else if (!mame_stricmp(filetype, "b0"))
876         address = 0xb000;
865   image.fread(pet_memory + address, size);
877866
878      logerror("Loading cart %s at %.4x size:%.4x\n", image.filename(), address, size);
879
880      /* Does cart contain any data? */
881      pet_cbm_cart[0].chip = (UINT8*) image.image_malloc(size);
882      if (!pet_cbm_cart[0].chip)
883         return IMAGE_INIT_FAIL;
884
885      /* Store data, address & size */
886      pet_cbm_cart[0].addr = address;
887      pet_cbm_cart[0].size = size;
888      test = image.fread(pet_cbm_cart[0].chip, pet_cbm_cart[0].size);
889
890      if (test != pet_cbm_cart[0].size)
891         return IMAGE_INIT_FAIL;
892   }
893
894   /* Finally load the cart */
895//  This could be needed with .crt support
896//  for (i = 0; (i < ARRAY_LENGTH(pet_cbm_cart)) && (pet_cbm_cart[i].size != 0); i++)
897//      memcpy(pet_memory + pet_cbm_cart[i].addr, pet_cbm_cart[i].chip, pet_cbm_cart[i].size);
898   memcpy(pet_memory + pet_cbm_cart[0].addr, pet_cbm_cart[0].chip, pet_cbm_cart[0].size);
899
900867   return IMAGE_INIT_PASS;
901868}
902869
903870MACHINE_DRIVER_START(pet_cartslot)
904871   MDRV_CARTSLOT_ADD("cart1")
905   MDRV_CARTSLOT_EXTENSION_LIST("crt,a0,b0")
872   MDRV_CARTSLOT_EXTENSION_LIST("90,a0,b0")
906873   MDRV_CARTSLOT_NOT_MANDATORY
907874   MDRV_CARTSLOT_LOAD(pet_cart)
908875
909876   MDRV_CARTSLOT_ADD("cart2")
910   MDRV_CARTSLOT_EXTENSION_LIST("crt,a0,b0")
877   MDRV_CARTSLOT_EXTENSION_LIST("90,a0,b0")
911878   MDRV_CARTSLOT_NOT_MANDATORY
912879   MDRV_CARTSLOT_LOAD(pet_cart)
913880MACHINE_DRIVER_END
914881
882// 2010-08, FP: this is used by CBM40 & CBM80, and I actually have only found .prg files for these... does cart dumps exist?
915883MACHINE_DRIVER_START(pet4_cartslot)
916884   MDRV_CARTSLOT_MODIFY("cart1")
917   MDRV_CARTSLOT_EXTENSION_LIST("crt,a0")
885   MDRV_CARTSLOT_EXTENSION_LIST("a0")
918886   MDRV_CARTSLOT_NOT_MANDATORY
919887   MDRV_CARTSLOT_LOAD(pet_cart)
920888
921889   MDRV_CARTSLOT_MODIFY("cart2")
922   MDRV_CARTSLOT_EXTENSION_LIST("crt,a0")
890   MDRV_CARTSLOT_EXTENSION_LIST("a0")
923891   MDRV_CARTSLOT_NOT_MANDATORY
924892   MDRV_CARTSLOT_LOAD(pet_cart)
925893MACHINE_DRIVER_END
src/mess/machine/sym1.c
r8857r8858
99
1010#include "emu.h"
1111#include "includes/sym1.h"
12#include "includes/cbm.h"
1312
1413/* M6502 CPU */
1514#include "cpu/m6502/m6502.h"
src/mess/machine/c64.c
r8857r8858
6464static int c64_cia1_on;
6565static int c64_io_enabled;
6666static int is_sx64;            // temporary workaround until we implement full vc1541 emulation for every c64 set
67static UINT8 c64_cart_n_banks = 0;
6867
6968static UINT8 vicirq;
7069
r8857r8858
939938*/
940939
941940
942#define C64_MAX_ROMBANK 64 //?
943
944static CBM_ROM c64_cbm_cart[C64_MAX_ROMBANK] = { {0} };
945static INT8 cbm_c64_game;
946static INT8 cbm_c64_exrom;
947
948static DEVICE_IMAGE_UNLOAD( c64_cart )
949{
950   int i;
951
952   for (i = 0; i < C64_MAX_ROMBANK; i++)
953   {
954      c64_cbm_cart[i].size = 0;
955      c64_cbm_cart[i].addr = 0;
956      c64_cbm_cart[i].chip = 0;
957   }
958}
959
960
961static DEVICE_START( c64_cart )
962{
963   int index = 0;
964
965   if (strcmp(device->tag(), "cart1") == 0)
966      index = 0;
967
968   if (strcmp(device->tag(), "cart2") == 0)
969      index = 1;
970
971
972   /* In the first slot we can load a .crt file. In this case we want
973        to use game & exrom values from the header, not the default ones. */
974   if (index == 0)
975   {
976      cbm_c64_game = -1;
977      cbm_c64_exrom = -1;
978   }
979}
980
981941/* Hardware Types for C64 carts */
982942enum {
983943   GENERIC_CRT = 0,      /* 00 - Normal cartridge                    */
r8857r8858
987947   SIMONS_BASIC,      /* 04 - Simons Basic                        */
988948   OCEAN_1,         /* 05 - Ocean type 1 (1)                    */
989949   EXPERT,         /* 06 - Expert Cartridge                    */
990   FUN_PLAY,         /* 07 - Fun Play, Power Play                    */
991   SUPER_GAMES,      /* 08 - Super Games                     */
950   FUN_PLAY,         /* 07 - Fun Play, Power Play                */
951   SUPER_GAMES,      /* 08 - Super Games                         */
992952   ATOMIC_POWER,      /* 09 - Atomic Power                        */
993953   EPYX_FASTLOAD,      /* 10 - Epyx Fastload                       */
994954   WESTERMANN,         /* 11 - Westermann Learning                 */
995   REX,            /* 12 - Rex Utility                     */
955   REX,            /* 12 - Rex Utility                         */
996956   FINAL_CART_I,      /* 13 - Final Cartridge I                   */
997957   MAGIC_FORMEL,      /* 14 - Magic Formel                        */
998   C64GS,         /* 15 - C64 Game System, System 3               */
958   C64GS,         /* 15 - C64 Game System, System 3           */
999959   WARPSPEED,         /* 16 - WarpSpeed                           */
1000   DINAMIC,         /* 17 - Dinamic (2)                     */
1001   ZAXXON,         /* 18 - Zaxxon, Super Zaxxon (SEGA)             */
1002   DOMARK,         /* 19 - Magic Desk, Domark, HES Australia           */
960   DINAMIC,         /* 17 - Dinamic (2)                         */
961   ZAXXON,         /* 18 - Zaxxon, Super Zaxxon (SEGA)         */
962   DOMARK,         /* 19 - Magic Desk, Domark, HES Australia   */
1003963   SUPER_SNAP_5,      /* 20 - Super Snapshot 5                    */
1004964   COMAL_80,         /* 21 - Comal-80                            */
1005965   STRUCT_BASIC,      /* 22 - Structured Basic                    */
1006   ROSS,            /* 23 - Ross                            */
966   ROSS,            /* 23 - Ross                                */
1007967   DELA_EP64,         /* 24 - Dela EP64                           */
1008   DELA_EP7X8,         /* 25 - Dela EP7x8                      */
1009   DELA_EP256,         /* 26 - Dela EP256                      */
968   DELA_EP7X8,         /* 25 - Dela EP7x8                          */
969   DELA_EP256,         /* 26 - Dela EP256                          */
1010970   REX_EP256,         /* 27 - Rex EP256                           */
1011971   MIKRO_ASSMBLR,      /* 28 - Mikro Assembler                     */
1012   REAL_FC_I,         /* 29 - (3)                             */
972   REAL_FC_I,         /* 29 - (3)                                 */
1013973   ACTION_REPLAY_4,      /* 30 - Action Replay 4                     */
1014   STARDOS,         /* 31 - StarDOS                         */
974   STARDOS,         /* 31 - StarDOS                             */
1015975   /*
1016976    (1) Ocean type 1 includes Navy Seals, Robocop 2 & 3,  Shadow  of
1017977    the Beast, Toki, Terminator 2 and more. Both 256 and 128 Kb images.
r8857r8858
1030990    *****************************************/
1031991};
1032992
1033static UINT8 c64_mapper = GENERIC_CRT;
993#define C64_MAX_ROMBANK 64 // .crt files contain multiple 'CHIPs', i.e. rom banks (of variable size) with headers. Known carts have at most 64 'CHIPs'.
1034994
1035static int c64_common_cart_load( device_image_interface &image )
995typedef struct {
996   int addr, size, index, start;
997} C64_ROM;
998
999typedef struct _c64_cart_t c64_cart_t;
1000struct _c64_cart_t {
1001   C64_ROM     bank[C64_MAX_ROMBANK];
1002   INT8        game;
1003   INT8        exrom;
1004   UINT8       mapper;
1005   UINT8       n_banks;
1006};
1007
1008static c64_cart_t c64_cart;
1009
1010static DEVICE_IMAGE_UNLOAD( c64_cart )
10361011{
1037   int size = image.length(), test, i = 0, n_banks;
1038   const char *filetype;
1012   int i;
1013
1014   for (i = 0; i < C64_MAX_ROMBANK; i++)
1015   {
1016      c64_cart.bank[i].size = 0;
1017      c64_cart.bank[i].addr = 0;
1018   }
1019}
1020
1021
1022static DEVICE_START( c64_cart )
1023{
1024   /* In the first slot we can load a .crt file. In this case we want
1025        to use game & exrom values from the header, not the default ones. */
1026   c64_cart.game = -1;
1027   c64_cart.exrom = -1;
1028   c64_cart.mapper = GENERIC_CRT;
1029   c64_cart.n_banks = 0;
1030}
1031
1032static int c64_crt_load( device_image_interface &image )
1033{
1034   int size = image.length(), test, i = 0, ii;
1035   int _80_loaded = 0, _90_loaded = 0, a0_loaded = 0, b0_loaded = 0, e0_loaded = 0, f0_loaded = 0;
1036   const char *filetype = image.filetype();
10391037   int address = 0, new_start = 0;
10401038   // int lbank_end_addr = 0, hbank_end_addr = 0;
1041   UINT8 *temp_cart = auto_alloc_array(image.device().machine, UINT8, size);
1039   UINT8 *cart_cpy = memory_region(image.device().machine, "user1");
10421040
1043   filetype = image.filetype();
1044
10451041   /* We support .crt files */
10461042   if (!mame_stricmp(filetype, "crt"))
10471043   {
10481044      int j;
10491045      unsigned short c64_cart_type;
10501046
1051      for (i = 0; (i < ARRAY_LENGTH(c64_cbm_cart)) && (c64_cbm_cart[i].size != 0); i++)
1047      for (i = 0; (i < C64_MAX_ROMBANK) && (c64_cart.bank[i].size != 0); i++)
10521048      ;
10531049
1054      if (i >= ARRAY_LENGTH(c64_cbm_cart))
1055      {
1056         auto_free(image.device().machine, temp_cart);
1050      if (i >= C64_MAX_ROMBANK)
10571051         return IMAGE_INIT_FAIL;
1058      }
10591052     
10601053      /* Start to parse the .crt header */
10611054      /* 0x16-0x17 is Hardware type */
10621055      image.fseek(0x16, SEEK_SET);
10631056      image.fread(&c64_cart_type, 2);
10641057      c64_cart_type = BIG_ENDIANIZE_INT16(c64_cart_type);
1065      c64_mapper = c64_cart_type;
1058      c64_cart.mapper = c64_cart_type;
10661059
10671060      /* If it is unsupported cart type, warn the user */
10681061      switch (c64_cart_type)
10691062      {
1070         case ACTION_REPLAY:   /* Type #  1 */
1071         case KCS_PC:      /* Type #  2 */
1072         case FINAL_CART_III:   /* Type #  3 */
10731063         case SIMONS_BASIC:   /* Type #  4 */
10741064         case OCEAN_1:      /* Type #  5 */
1075         case EXPERT:      /* Type #  6 */
10761065         case FUN_PLAY:      /* Type #  7 */
10771066         case SUPER_GAMES:      /* Type #  8 */
1078         case ATOMIC_POWER:   /* Type #  9 */
10791067         case EPYX_FASTLOAD:   /* Type # 10 */
1080         case WESTERMANN:      /* Type # 11 */
10811068         case REX:         /* Type # 12 */
1082         case FINAL_CART_I:   /* Type # 13 */
1083         case MAGIC_FORMEL:   /* Type # 14 */
10841069         case C64GS:         /* Type # 15 */
10851070         case DINAMIC:      /* Type # 17 */
10861071         case ZAXXON:      /* Type # 18 */
10871072         case DOMARK:      /* Type # 19 */
1088         case SUPER_SNAP_5:   /* Type # 20 */
10891073         case COMAL_80:      /* Type # 21 */
10901074         case GENERIC_CRT:      /* Type #  0 */
10911075            printf("Currently supported cart type (Type %d)\n", c64_cart_type);
10921076            break;
10931077
10941078         default:
1079         case ACTION_REPLAY:   /* Type #  1 */
1080         case KCS_PC:      /* Type #  2 */
1081         case FINAL_CART_III:   /* Type #  3 */
1082         case EXPERT:      /* Type #  6 */
1083         case ATOMIC_POWER:   /* Type #  9 */
1084         case WESTERMANN:      /* Type # 11 */
1085         case FINAL_CART_I:   /* Type # 13 */
1086         case MAGIC_FORMEL:   /* Type # 14 */
1087         case SUPER_SNAP_5:   /* Type # 20 */
10951088            printf("Currently unsupported cart type (Type %d)\n", c64_cart_type);
10961089            break;
10971090      }
10981091
10991092      /* 0x18 is EXROM */
11001093      image.fseek(0x18, SEEK_SET);
1101      image.fread(&cbm_c64_exrom, 1);
1094      image.fread(&c64_cart.exrom, 1);
11021095
11031096      /* 0x19 is GAME */
1104      image.fread(&cbm_c64_game, 1);
1097      image.fread(&c64_cart.game, 1);
11051098
11061099      /* We can pass to the data: it starts from 0x40 */
11071100      image.fseek(0x40, SEEK_SET);
11081101      j = 0x40;
11091102
11101103      logerror("Loading cart %s size:%.4x\n", image.filename(), size);
1111      logerror("Header info: EXROM %d, GAME %d, Cart Type %d \n", cbm_c64_exrom, cbm_c64_game, c64_cart_type);
1104      logerror("Header info: EXROM %d, GAME %d, Cart Type %d \n", c64_cart.exrom, c64_cart.game, c64_cart_type);
11121105
11131106
11141107      /* Data in a .crt image are organized in blocks called 'CHIP':
r8857r8858
11501143            address, chip_data_size);
11511144         logerror("Loading CHIP data at %.4x size:%.4x\n", address, chip_data_size);
11521145
1153         /* Does CHIP contain any data? */
1154         c64_cbm_cart[i].chip = (UINT8*) image.image_malloc(chip_data_size);
1155         if (!c64_cbm_cart[i].chip)
1156         {
1157            auto_free(image.device().machine, temp_cart);
1158            return IMAGE_INIT_FAIL;
1159         }
1160         
11611146         /* Store data, address & size of the CHIP block */
1162         c64_cbm_cart[i].addr = address;
1163         c64_cbm_cart[i].index = chip_bank_index;
1164         c64_cbm_cart[i].size = chip_data_size;
1165         c64_cbm_cart[i].start = new_start;
1147         c64_cart.bank[i].addr = address;
1148         c64_cart.bank[i].index = chip_bank_index;
1149         c64_cart.bank[i].size = chip_data_size;
1150         c64_cart.bank[i].start = new_start;
11661151
1167         test = image.fread(c64_cbm_cart[i].chip, chip_data_size);
1152         test = image.fread(cart_cpy + new_start, c64_cart.bank[i].size);
1153         new_start += c64_cart.bank[i].size;
11681154
1169         memcpy(&temp_cart[new_start], c64_cbm_cart[i].chip, c64_cbm_cart[i].size);
1170         new_start += c64_cbm_cart[i].size;
1171
1172         if (test != chip_data_size)
1173         {
1174            auto_free(image.device().machine, temp_cart);
1155         /* Does CHIP contain any data? */
1156         if (test != c64_cart.bank[i].size)
11751157            return IMAGE_INIT_FAIL;
1176         }
11771158         
11781159         /* Advance to the next CHIP block */
11791160         i++;
r8857r8858
11831164   else /* We also support .80 files for c64 & .e0/.f0 for max */
11841165   {
11851166      /* Assign loading address according to extension */
1186      if (!mame_stricmp (filetype, "80"))
1167      if (!mame_stricmp(filetype, "80"))
11871168         address = 0x8000;
11881169
1189      if (!mame_stricmp (filetype, "e0"))
1170      if (!mame_stricmp(filetype, "e0"))
11901171         address = 0xe000;
11911172
1192      if (!mame_stricmp (filetype, "f0"))
1173      if (!mame_stricmp(filetype, "f0"))
11931174         address = 0xf000;
11941175
11951176      logerror("loading %s rom at %.4x size:%.4x\n", image.filename(), address, size);
11961177
1197      /* Does cart contain any data? */
1198      c64_cbm_cart[0].chip = (UINT8*) image.image_malloc(size);
1199      if (!c64_cbm_cart[0].chip)
1200      {
1201         auto_free(image.device().machine, temp_cart);
1202         return IMAGE_INIT_FAIL;
1203      }
1204     
12051178      /* Store data, address & size */
1206      c64_cbm_cart[0].addr = address;
1207      c64_cbm_cart[0].size = size;
1208      c64_cbm_cart[0].start = new_start;
1179      c64_cart.bank[0].addr = address;
1180      c64_cart.bank[0].size = size;
1181      c64_cart.bank[0].start = new_start;
12091182
1210      test = image.fread(c64_cbm_cart[0].chip, size);
1183      test = image.fread(cart_cpy + new_start, c64_cart.bank[0].size);
1184      new_start += c64_cart.bank[0].size;
12111185
1212      memcpy(&temp_cart[new_start], c64_cbm_cart[0].chip, c64_cbm_cart[0].size);
1213      new_start += c64_cbm_cart[0].size;
1214
1215      if (test != c64_cbm_cart[0].size)
1216      {
1217         auto_free(image.device().machine, temp_cart);
1186      /* Does cart contain any data? */
1187      if (test != c64_cart.bank[0].size)
12181188         return IMAGE_INIT_FAIL;
1219      }
12201189   }
12211190
1222   n_banks = i;
1191   c64_cart.n_banks = i; // this is also needed so that we only set mappers if a cart is present!
12231192
12241193   /* If we load a .crt file, use EXROM & GAME from the header! */
1225   if ((cbm_c64_exrom != -1) && (cbm_c64_game != -1))
1194   if ((c64_cart.exrom != -1) && (c64_cart.game != -1))
12261195   {
1227      c64_exrom = cbm_c64_exrom;
1228      c64_game  = cbm_c64_game;
1196      c64_exrom = c64_cart.exrom;
1197      c64_game  = c64_cart.game;
12291198   }
12301199
12311200   /* Finally load the cart */
r8857r8858
12351204   memset(roml, 0, 0x2000);
12361205   memset(romh, 0, 0x2000);
12371206
1238   switch (c64_mapper)
1207   switch (c64_cart.mapper)
12391208   {
1240   case ZAXXON:
1241      memcpy(romh, temp_cart + 0x1000, 0x2000);
1242      break;
12431209   default:
1244      if (!c64_game && c64_exrom && (n_banks == 1))
1245         memcpy(romh, temp_cart, 0x2000);
1210      if (!c64_game && c64_exrom && (c64_cart.n_banks == 1))
1211      {
1212         memcpy(romh, cart_cpy, 0x2000);
1213      }
12461214      else
12471215      {
1248         memcpy(roml, temp_cart + 0 * 0x2000, 0x2000);
1249         memcpy(romh, temp_cart + 1 * 0x2000, 0x2000);
1216         // we first attempt to load the first 'CHIPs' with address 0x8000-0xb000 and 0xe000-0xf000, otherwise we load the first (or first two) 'CHIPs' of the image
1217         for (ii = 0; ii < c64_cart.n_banks; ii++)
1218         {
1219            if (c64_cart.bank[ii].addr == 0x8000 && !_80_loaded)
1220            {
1221               memcpy(roml, cart_cpy + c64_cart.bank[ii].start, c64_cart.bank[ii].size);
1222               _80_loaded = 1;
1223               if (c64_cart.bank[ii].size > 0x1000)
1224                  _90_loaded = 1;
1225               if (c64_cart.bank[ii].size > 0x2000)
1226                  a0_loaded = 1;
1227               if (c64_cart.bank[ii].size > 0x3000)
1228                  b0_loaded = 1;
1229//               printf("addr 0x8000: 80 %d, 90 %d, a0 %d, b0 %d\n", _80_loaded, _90_loaded, a0_loaded, b0_loaded);
1230            }
1231
1232            if (c64_cart.bank[ii].addr == 0x9000 && !_90_loaded)
1233            {
1234               memcpy(roml + 0x1000, cart_cpy + c64_cart.bank[ii].start, c64_cart.bank[ii].size);
1235               _90_loaded = 1;
1236               if (c64_cart.bank[ii].size > 0x1000)
1237                  a0_loaded = 1;
1238               if (c64_cart.bank[ii].size > 0x2000)
1239                  b0_loaded = 1;
1240//               printf("addr 0x9000: 80 %d, 90 %d, a0 %d, b0 %d\n", _80_loaded, _90_loaded, a0_loaded, b0_loaded);
1241            }
1242
1243            if (c64_cart.bank[ii].addr == 0xa000 && !a0_loaded)
1244            {
1245               memcpy(roml + 0x2000, cart_cpy + c64_cart.bank[ii].start, c64_cart.bank[ii].size);
1246               a0_loaded = 1;
1247               if (c64_cart.bank[ii].size > 0x1000)
1248                  b0_loaded = 1;
1249//               printf("addr 0xa000: 80 %d, 90 %d, a0 %d, b0 %d\n", _80_loaded, _90_loaded, a0_loaded, b0_loaded);
1250            }
1251
1252            if (c64_cart.bank[ii].addr == 0xb000 && !b0_loaded)
1253            {
1254               memcpy(roml + 0x3000, cart_cpy + c64_cart.bank[ii].start, c64_cart.bank[ii].size);
1255               b0_loaded = 1;
1256//               printf("addr 0xb000: 80 %d, 90 %d, a0 %d, b0 %d\n", _80_loaded, _90_loaded, a0_loaded, b0_loaded);
1257            }
1258
1259            if (c64_cart.bank[ii].addr == 0xe000 && !e0_loaded)
1260            {
1261               memcpy(romh, cart_cpy + c64_cart.bank[ii].start, c64_cart.bank[ii].size);
1262               e0_loaded = 1;
1263               if (c64_cart.bank[ii].size > 0x1000)
1264                  f0_loaded = 1;
1265//               printf("addr 0xe000: e0 %d, f0 %d\n", e0_loaded, f0_loaded);
1266            }
1267
1268            if (c64_cart.bank[ii].addr == 0xf000 && !f0_loaded)
1269            {
1270               memcpy(romh + 0x1000, cart_cpy + c64_cart.bank[ii].start, c64_cart.bank[ii].size);
1271               f0_loaded = 1;
1272//               printf("addr 0xe000: e0 %d, f0 %d\n", e0_loaded, f0_loaded);
1273            }
1274         }
12501275      }
12511276   }
12521277
1253   c64_cart_n_banks = n_banks; // this is needed so that we only set mappers if a cart is present!
1254
1255   memcpy(memory_region(image.device().machine, "user1"), temp_cart, size);
1256   auto_free(image.device().machine, temp_cart);
12571278   return IMAGE_INIT_PASS;
12581279}
12591280
12601281static DEVICE_IMAGE_LOAD( c64_cart )
12611282{
1262   return c64_common_cart_load(image);
1283   return c64_crt_load(image);
12631284}
12641285
12651286static DEVICE_IMAGE_LOAD( max_cart )
r8857r8858
12681289
12691290   if (image.software_entry() == NULL)
12701291   {
1271      result = c64_common_cart_load(image);
1272   }
1273   else
1274   {
12751292      UINT32 size;
12761293
12771294      // setup Ultimax mode
r8857r8858
12941311      if (size)
12951312         memcpy(romh, image.get_software_region("romh"), size);
12961313   }
1314   else
1315      result = c64_crt_load(image);
12971316
12981317   return result;
12991318}
r8857r8858
13191338/*
13201339            if (log_cart)
13211340            {
1322                logerror("bank %d of size %d successfully loaded at %d!\n", bank, c64_cbm_cart[bank].size, c64_cbm_cart[bank].addr);
1323                if (c64_cbm_cart[bank].index != bank)
1324                    logerror("Warning: According to the CHIP info this should be bank %d, but we are loading it as bank %d!\n", c64_cbm_cart[bank].index, bank);
1341                logerror("bank %d of size %d successfully loaded at %d!\n", bank, c64_cart.bank[bank].size, c64_cart.bank[bank].addr);
1342                if (c64_cart.bank[bank].index != bank)
1343                    logerror("Warning: According to the CHIP info this should be bank %d, but we are loading it as bank %d!\n", c64_cart.bank[bank].index, bank);
13251344            }
13261345*/
13271346      }
r8857r8858
13341353   // working: Double Dragon, Ghostbusters, Terminator 2
13351354   // not working: Pang, Robocop 2, Toki
13361355
1337   UINT8 bank = data & 0x3f;
1356   UINT8 bank = data & c64_cart.n_banks;
13381357   UINT8 *cart = memory_region(space->machine, "user1");
13391358
1340   if (c64_cart_n_banks != 64)                        // all carts except Terminator II
1359   switch (c64_cart.bank[bank].addr)
13411360   {
1342      if (bank < 16)
1343         memcpy(roml, cart + bank * 0x2000, 0x2000);
1344      else
1345         memcpy(romh, cart + (bank - 16) * 0x2000, 0x2000);
1361   case 0x8000:
1362      memcpy(roml, cart + bank * 0x2000, c64_cart.bank[bank].size);
1363      break;
1364   case 0xa000:
1365      memcpy(roml + 0x2000, cart + bank * 0x2000, c64_cart.bank[bank].size);
1366      break;
1367   case 0xe000:
1368      memcpy(romh, cart + bank * 0x2000, c64_cart.bank[bank].size);
1369      break;
1370   default:
1371      logerror("Unexpected loading address (%x) for bank %x", c64_cart.bank[bank].addr, bank);
1372      break;
13461373   }
1347   else                                 // Terminator II
1348   {
1349      memcpy(roml, cart + bank * 0x2000, 0x2000);
1350   }
13511374/*
13521375    if (log_cart)
13531376    {
1354        logerror("bank %d of size %d successfully loaded at %d!\n", bank, c64_cbm_cart[bank].size, c64_cbm_cart[bank].addr);
1355        if (c64_cbm_cart[bank].index != bank)
1356            logerror("Warning: According to the CHIP info this should be bank %d, but we are loading it as bank %d!\n", c64_cbm_cart[bank].index, bank);
1377        logerror("bank %d of size %d successfully loaded at %d!\n", bank, c64_cart.bank[bank].size, c64_cart.bank[bank].addr);
1378        if (c64_cart.bank[bank].index != bank)
1379            logerror("Warning: According to the CHIP info this should be bank %d, but we are loading it as bank %d!\n", c64_cart.bank[bank].index, bank);
13571380    }
13581381*/
13591382}
r8857r8858
13721395      logerror("Reserved value written\n");
13731396   else
13741397   {
1375      /* bank number is not the value written, but c64_cbm_cart[bank].index IS the value written! */
1398      /* bank number is not the value written, but c64_cart.bank[bank].index IS the value written! */
13761399      real_bank = ((bank & 0x01) << 3) + ((bank & 0x38) >> 3);
13771400
13781401      memcpy(roml, cart + real_bank * 0x2000, 0x2000);
13791402/*
13801403        if (log_cart)
13811404        {
1382            logerror("bank %d of size %d successfully loaded at %d!\n", bank, c64_cbm_cart[bank].size, c64_cbm_cart[bank].addr);
1383            if (c64_cbm_cart[bank].index != bank)
1384                logerror("Warning: According to the CHIP info this should be bank %d, but we are loading it as bank %d!\n", c64_cbm_cart[bank].index, bank);
1405            logerror("bank %d of size %d successfully loaded at %d!\n", bank, c64_cart.bank[bank].size, c64_cart.bank[bank].addr);
1406            if (c64_cart.bank[bank].index != bank)
1407                logerror("Warning: According to the CHIP info this should be bank %d, but we are loading it as bank %d!\n", c64_cart.bank[bank].index, bank);
13851408        }
13861409*/
13871410   }
r8857r8858
14411464/*
14421465    if (log_cart)
14431466    {
1444        logerror("bank %d of size %d successfully loaded at %d!\n", bank, c64_cbm_cart[bank].size, c64_cbm_cart[bank].addr);
1445        if (c64_cbm_cart[bank].index != bank)
1446            logerror("Warning: According to the CHIP info this should be bank %d, but we are loading it as bank %d!\n", c64_cbm_cart[bank].index, bank);
1467        logerror("bank %d of size %d successfully loaded at %d!\n", bank, c64_cart.bank[bank].size, c64_cart.bank[bank].addr);
1468        if (c64_cart.bank[bank].index != bank)
1469            logerror("Warning: According to the CHIP info this should be bank %d, but we are loading it as bank %d!\n", c64_cart.bank[bank].index, bank);
14471470    }
14481471*/
14491472}
r8857r8858
14641487/*
14651488    if (log_cart)
14661489    {
1467        logerror("bank %d of size %d successfully loaded at %d!\n", bank, c64_cbm_cart[bank].size, c64_cbm_cart[bank].addr);
1468        if (c64_cbm_cart[bank].index != bank)
1469            logerror("Warning: According to the CHIP info this should be bank %d, but we are loading it as bank %d!\n", c64_cbm_cart[bank].index, bank);
1490        logerror("bank %d of size %d successfully loaded at %d!\n", bank, c64_cart.bank[bank].size, c64_cart.bank[bank].addr);
1491        if (c64_cart.bank[bank].index != bank)
1492            logerror("Warning: According to the CHIP info this should be bank %d, but we are loading it as bank %d!\n", c64_cart.bank[bank].index, bank);
14701493    }
14711494*/
14721495   return 0;
r8857r8858
15361559/*
15371560        if (log_cart)
15381561        {
1539            logerror("bank %d of size %d successfully loaded at %d!\n", bank, c64_cbm_cart[bank].size, c64_cbm_cart[bank].addr);
1540            if (c64_cbm_cart[bank].index != bank)
1541                logerror("Warning: According to the CHIP info this should be bank %d, but we are loading it as bank %d!\n", c64_cbm_cart[bank].index, bank);
1562            logerror("bank %d of size %d successfully loaded at %d!\n", bank, c64_cart.bank[bank].size, c64_cart.bank[bank].addr);
1563            if (c64_cart.bank[bank].index != bank)
1564                logerror("Warning: According to the CHIP info this should be bank %d, but we are loading it as bank %d!\n", c64_cart.bank[bank].index, bank);
15421565        }
15431566*/
15441567   }
r8857r8858
15481571{
15491572   address_space *space = cputag_get_address_space( machine, "maincpu", ADDRESS_SPACE_PROGRAM );
15501573
1551   switch (c64_mapper)
1574   switch (c64_cart.mapper)
15521575   {
15531576      case ACTION_REPLAY:   /* Type #  1 not working */
15541577         break;
r8857r8858
16081631
16091632MACHINE_RESET( c64 )
16101633{
1611   if (c64_cart_n_banks)
1634   if (c64_cart.n_banks)
16121635      setup_c64_custom_mappers(machine);
16131636}
16141637
src/mess/includes/cbm.h
r8857r8858
2121UINT8 cbm_common_cia0_port_a_r( running_device *device, UINT8 output_b );
2222UINT8 cbm_common_cia0_port_b_r( running_device *device, UINT8 output_a );
2323
24
2524/***********************************************
2625
27    CBM Cartridges
28
29***********************************************/
30
31
32#define CBM_ROM_ADDR_UNKNOWN 0
33#define CBM_ROM_ADDR_LO -1
34#define CBM_ROM_ADDR_HI -2
35
36typedef struct {
37   int addr, size, index, start;
38   UINT8 *chip;
39} CBM_ROM;
40
41
42
43/* prg file format
44 * sfx file format
45 * sda file format
46 * 0 lsb 16bit address
47 * 2 chip data */
48
49/* p00 file format (p00 .. p63, s00 .. s63, ..)
50 * 0x0000 C64File
51 * 0x0007 0
52 * 0x0008 Name in commodore encoding?
53 * 0x0018 0 0
54 * 0x001a lsb 16bit address
55 * 0x001c data */
56
57
58/***********************************************
59
6026    CBM Datasette Tapes
6127
6228***********************************************/
src/mess/formats/cbm_snqk.c
r8857r8858
77#include "emu.h"
88#include "cbm_snqk.h"
99
10/* prg file format
11 * sfx file format
12 * sda file format
13 * 0 lsb 16bit address
14 * 2 chip data */
15
16/* p00 file format (p00 .. p63, s00 .. s63, ..)
17 * 0x0000 C64File
18 * 0x0007 0
19 * 0x0008 Name in commodore encoding?
20 * 0x0018 0 0
21 * 0x001a lsb 16bit address
22 * 0x001c data */
23
24
1025static int general_cbm_loadsnap( device_image_interface &image, const char *file_type, int snapshot_size,
1126                        offs_t offset, void (*cbm_sethiaddress)(running_machine *machine, UINT16 hiaddress) )
1227{

Previous 15994 Revisions Next


© 1998-2018 The MESS Team