Previous 15994 Revisions Next

r3376 Friday 3rd October, 2008 at 14:28:37 UTC by Fabio Priuli
[LYNX] Added partial support for .lyx files. Removed old MESS quickload code that crashed the emu since rev. 2429 (but -quik is still not working)
[src/mess/drivers]lynx.c

src/mess/drivers/lynx.c
r3375r3376
236236
237237   /* sound hardware */
238238   MDRV_SPEAKER_STANDARD_MONO("mono")
239        MDRV_SOUND_ADD("lynx", CUSTOM, 0)
239   MDRV_SOUND_ADD("lynx", CUSTOM, 0)
240240   MDRV_SOUND_CONFIG(lynx_sound_interface)
241241   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.50)
242242
r3375r3376
249249   MDRV_IMPORT_FROM( lynx )
250250
251251   /* sound hardware */
252        MDRV_SPEAKER_REMOVE("mono")
252   MDRV_SPEAKER_REMOVE("mono")
253253   MDRV_SPEAKER_STANDARD_STEREO("left", "right")
254        MDRV_SOUND_REMOVE("lynx")
255        MDRV_SOUND_ADD("lynx2", CUSTOM, 0)
254   MDRV_SOUND_REMOVE("lynx")
255   MDRV_SOUND_ADD("lynx2", CUSTOM, 0)
256256   MDRV_SOUND_CONFIG(lynx2_sound_interface)
257257   MDRV_SOUND_ROUTE(0, "left", 0.50)
258258   MDRV_SOUND_ROUTE(1, "right", 0.50)
r3375r3376
265265   these 2 dumps differ only in this byte!
266266*/
267267
268#define MYROM_LOAD_BIOS(bios,name,offset,length,hash) \
269      ROMX_LOAD(name, offset, length, hash, ROM_BIOS(bios+1)) /* Note '+1' */
270
271268ROM_START(lynx)
272269   ROM_REGION(0x200,"main", 0)
273270   ROM_SYSTEM_BIOS( 0, "default",   "rom save" )
274   MYROM_LOAD_BIOS( 0, "lynx.bin",    0x00000, 0x200, CRC(e1ffecb6) SHA1(de60f2263851bbe10e5801ef8f6c357a4bc077e6))
271   ROMX_LOAD( "lynx.bin",  0x00000, 0x200, CRC(e1ffecb6) SHA1(de60f2263851bbe10e5801ef8f6c357a4bc077e6), ROM_BIOS(1))
275272   ROM_SYSTEM_BIOS( 1, "a", "alternate rom save" )
276   MYROM_LOAD_BIOS( 1, "lynxa.bin",    0x00000, 0x200, CRC(0d973c9d) SHA1(e4ed47fae31693e016b081c6bda48da5b70d7ccb))
277//  ROM_LOAD("lynx.bin", 0, 0x200, CRC(e1ffecb6) SHA1(de60f2263851bbe10e5801ef8f6c357a4bc077e6))
273   ROMX_LOAD( "lynxa.bin", 0x00000, 0x200, CRC(0d973c9d) SHA1(e4ed47fae31693e016b081c6bda48da5b70d7ccb), ROM_BIOS(2))
274
278275   ROM_REGION(0x100,"gfx1", ROMREGION_ERASE00)
276
279277   ROM_REGION(0x100000, "user1", ROMREGION_ERASEFF)
280278ROM_END
281279
282280ROM_START(lynx2)
283281   ROM_REGION(0x200,"main", 0)
284282   ROM_LOAD("lynx2.bin", 0, 0x200, NO_DUMP)
283
285284   ROM_REGION(0x100,"gfx1", ROMREGION_ERASE00)
285
286286   ROM_REGION(0x100000, "user1", ROMREGION_ERASEFF)
287287ROM_END
288288
r3375r3376
296296   hash_compute(dest, &data[64], length - 64, functions);
297297}
298298
299#define LYNX_CART      0
300#define LYNX_QUICKLOAD   1
299301
300
301static int lynx_verify_cart (char *header)
302static int lynx_verify_cart (char *header, int kind)
302303{
303
304304   logerror("Trying Header Compare\n");
305305
306   if (strncmp("LYNX",&header[0],4) && strncmp("BS9",&header[6],3)) {
307      logerror("Not an valid Lynx image\n");
308      return IMAGE_VERIFY_FAIL;
306   if (kind)
307   {
308      if (strncmp("BS93", &header[6], 4))
309      {
310         logerror("Not an valid Lynx image\n");
311         return IMAGE_VERIFY_FAIL;
312      }
309313   }
314   else
315   {
316      if (strncmp("LYNX",&header[0],4))
317      {
318         logerror("Not an valid Lynx image\n");
319         return IMAGE_VERIFY_FAIL;
320      }
321   }
322
310323   logerror("returning ID_OK\n");
311324   return IMAGE_VERIFY_PASS;
312325}
r3375r3376
330343static DEVICE_IMAGE_LOAD( lynx_cart )
331344{
332345   UINT8 *rom = memory_region(image->machine, "user1");
333   int size;
346   int size = image_length(image);
347   const char *filetype;
334348   UINT8 header[0x40];
335349/* 64 byte header
336350   LYNX
r3375r3376
340354   22 chars manufacturer
341355*/
342356
343   size = image_length(image);
344   if (image_fread(image, header, 0x40)!=0x40)
345   {
346      logerror("%s load error\n", image_filename(image));
347      return 1;
348   }
357   filetype = image_filetype(image);
349358
350   /* Check the image */
351   if (lynx_verify_cart((char*)header) == IMAGE_VERIFY_FAIL)
359   if (!mame_stricmp (filetype, "lnx"))
352360   {
353      return INIT_FAIL;
354   }
361      if (image_fread(image, header, 0x40)!=0x40)
362         return INIT_FAIL;
355363
356   size-=0x40;
357   lynx_granularity=header[4]|(header[5]<<8);
364      /* Check the image */
365      if (lynx_verify_cart((char*)header, LYNX_CART) == IMAGE_VERIFY_FAIL)
366         return INIT_FAIL;
358367
359   logerror ("%s %dkb cartridge with %dbyte granularity from %s\n",
360           header+10,size/1024,lynx_granularity, header+42);
368      /* 2008-10 FP: According to Handy source these should be page_size_bank0. Are we using
369      it correctly in MESS? Moreover, the next two values should be page_size_bank1. We should
370      implement this as well */
371      lynx_granularity = header[4] | (header[5] << 8);
361372
362   if (image_fread(image, rom, size) != size)
373      logerror ("%s %dkb cartridge with %dbyte granularity from %s\n",
374           header + 10, size / 1024, lynx_granularity, header + 42);
375
376      size -= 0x40;
377   }
378   else if (!mame_stricmp (filetype, "lyx"))
363379   {
364      logerror("%s load error\n", image_filename(image));
365      return 1;
380      /* 2008-10 FP: FIXME: .lyx file don't have an header, hence they miss "lynx_granularity"
381      (see above). What if bank 0 has to be loaded elsewhere? And what about bank 1?
382      This should work with most .lyx files, but we need additional info on raw cart images */
383      lynx_granularity = 0x0400;
366384   }
367385
386   if (image_fread(image, rom, size) != size)
387      return INIT_FAIL;
388
368389   lynx_crc_keyword(image);
369390
370   return 0;
391   return INIT_PASS;
371392}
372393
373394static QUICKLOAD_LOAD( lynx )
374395{
396   UINT8 *data = NULL;
375397   UINT8 *rom = memory_region(image->machine, "main");
376398   UINT8 header[10]; // 80 08 dw Start dw Len B S 9 3
377   // maybe the first 2 bytes must be used to identify the endianess of the file
378   UINT16 start;
399   UINT16 start, length;
400   int i;
379401
380402   if (image_fread(image, header, sizeof(header)) != sizeof(header))
381403      return INIT_FAIL;
382404
383   quickload_size -= sizeof(header);
405   /* Check the image */
406   if (lynx_verify_cart((char*)header, LYNX_QUICKLOAD) == IMAGE_VERIFY_FAIL)
407      return INIT_FAIL;
408
384409   start = header[3] | (header[2]<<8); //! big endian format in file format for little endian cpu
410   length = header[5] | (header[4]<<8);
411   length -= 10;
385412
386   if (image_fread(image, rom+start, quickload_size) != quickload_size)
413   data = malloc(length);
414
415   if (image_fread(image, data, length) != length)
387416      return INIT_FAIL;
388417
389   rom[0xfffc+0x200] = start&0xff;
390   rom[0xfffd+0x200] = start>>8;
418   for (i = 0; i < length; i++)
419      program_write_byte(start + i, data[i]);
391420
392   lynx_crc_keyword(image_from_devtype_and_index(IO_QUICKLOAD, 0));
393   return 0;
421   rom[0x1fc] = start & 0xff;
422   rom[0x1fd] = start >> 8;
423
424   lynx_crc_keyword(device_list_find_by_tag( image->machine->config->devicelist, QUICKLOAD, TAG_QUICKLOAD ));
425
426   return INIT_PASS;
394427}
395428
396429static void lynx_cartslot_getinfo(const mess_device_class *devclass, UINT32 state, union devinfo *info)
r3375r3376
406439      case MESS_DEVINFO_PTR_PARTIAL_HASH:               info->partialhash = lynx_partialhash; break;
407440
408441      /* --- the following bits of info are returned as NULL-terminated strings --- */
409      case MESS_DEVINFO_STR_FILE_EXTENSIONS:            strcpy(info->s = device_temp_str(), "lnx"); break;
442      case MESS_DEVINFO_STR_FILE_EXTENSIONS:            strcpy(info->s = device_temp_str(), "lnx,lyx"); break;
410443
411444      default:                              cartslot_device_getinfo(devclass, state, info); break;
412445   }

Previous 15994 Revisions Next


© 1998-2018 The MESS Team