Previous 15994 Revisions Next

r10298 Saturday 5th February, 2011 at 15:17:08 UTC by Fabio Priuli
[A800] slightly improved header recognition
[src/mess/machine]ataricrt.c

src/mess/machine/ataricrt.c
r10297r10298
224224   switch (type)
225225   {
226226      case A800_4K:
227      case A800_RIGHT_4K:
228      case A800_12K:
227229      case A800_8K:
228      case A800_12K:
229230      case A800_16K:
230      case A800_RIGHT_4K:
231231      case A800_RIGHT_8K:
232232      case OSS_034M:
233233      case OSS_M091:
r10297r10298
247247{
248248   UINT8 header[16];
249249   image.fread(header, 0x10);
250   int hdr_type, cart_type;
250251
251252   // add check of CART format
252253   if (strncmp((const char *)header, "CART", 4))
253254      fatalerror("Invalid header detected!\n");
254255
255   int cart_type = (header[4] << 24) + (header[5] << 16) +  (header[6] << 8) + (header[7] << 0);
256   printf("cart type: %x\n", cart_type);
256   hdr_type = (header[4] << 24) + (header[5] << 16) +  (header[6] << 8) + (header[7] << 0);
257   switch (hdr_type)
258   {
259      case 1:
260         cart_type = A800_8K;
261         break;
262      case 2:
263         cart_type = A800_16K;
264         break;
265      case 3:
266         cart_type = OSS_034M;
267         break;
268      case 8:
269         cart_type = WILLIAMS_64K;
270         break;
271      case 9:
272         cart_type = DIAMOND_64K;
273         break;
274      case 10:
275         cart_type = EXPRESS_64;
276         break;
277      case 11:
278         cart_type = SPARTADOS_X;
279         break;
280      case 12:
281         cart_type = XEGS_32K;
282         break;
283      case 15:
284         cart_type = OSS_M091;
285         break;
286      case 18:
287         cart_type = BBSB;
288         break;
289      case 21:
290         cart_type = A800_RIGHT_8K;
291         break;
292      case 39:
293         cart_type = PHOENIX_8K;
294         break;
295      case 4:
296      case 6:
297      case 7:
298      case 16:
299      case 19:
300      case 20:
301         fatalerror("Cart type \"%d\" means this is an Atari 5200 cart.\n", hdr_type);
302         break;
303      default:
304         mame_printf_info("Cart type \"%d\" is currently unsupported.\n", hdr_type);
305         break;
306   }   
257307   return cart_type;
258308}
259309
r10297r10298
261311{
262312   UINT8 *mem = image.device().machine->region("maincpu")->base();
263313   const char   *pcb_name;
264   int cart_type = 0;
314   int cart_type = A800_UNKNOWN;
265315   UINT32 size;
266316
267317   if (image.software_entry() == NULL)
268318   {
269319      size = image.length();
270      // check if there is an header, if so extract cart_type from it (after a800_get_type, we point at the start of the data)
320
321      // check if there is an header, if so extract cart_type from it, otherwise
322      // try to guess the cart_type from the file size (notice that after the
323      // a800_get_type call, we point at the start of the data)
271324      if ((size % 0x1000) == 0x10)
272325         cart_type = a800_get_type(image);
273      //else check size to decide type (assuming base type of cart only!)
326      else if (size == 0x4000)
327         cart_type = A800_16K;
328      else if (size == 0x2000)
329      {
330         if (strcmp(image.device().tag(),"cart2") == 0)
331            cart_type = A800_RIGHT_8K;
332         else
333            cart_type = A800_8K;
334      }
274335   }
275336   else
276337   {
277338      size = image.get_software_region_length("rom");
278      if ((pcb_name = image.get_feature("cart_type")) == NULL)
279         cart_type = A800_UNKNOWN;
280      else
339      if ((pcb_name = image.get_feature("cart_type")) != NULL)
281340         cart_type = a800_get_pcb_id(pcb_name);
341
282342      switch (cart_type)
283343      {
344         case A800_UNKNOWN:
284345         case A800_4K:
346         case A800_RIGHT_4K:
347         case A800_12K:
285348         case A800_8K:
286         case A800_12K:
287349         case A800_16K:
288         case A800_RIGHT_4K:
289350         case A800_RIGHT_8K:
290351            break;
291352         default:
292353            mame_printf_info("Cart type \"%s\" currently unsupported.\n", pcb_name);
293354            break;
294355      }
295      a800_setup_mappers(image.device().machine, cart_type);
296356   }
297357
358   a800_setup_mappers(image.device().machine, cart_type);
359
298360   /* load an optional (dual) cartridge (e.g. basic.rom) */
299   if( strcmp(image.device().tag(),"cart2") == 0 )
361   if (strcmp(image.device().tag(),"cart2") == 0)
300362   {
301363      a800_cart_is_16k = (size >= 0x2000) ? 1 : 0;
302364

Previous 15994 Revisions Next


© 1998-2018 The MESS Team