Previous 199869 Revisions Next

r21635 Wednesday 6th March, 2013 at 14:01:23 UTC by Fabio Priuli
few more cleanups. nw.
[src/mess/machine]snescart.c sns_slot.c

trunk/src/mess/machine/sns_slot.c
r21634r21635
10511051
10521052   /* ROM ID */
10531053   for(int i = 0; i < 4; i++ )
1054      rom_id[i] = ROM[hilo_mode - 0x0d + i];
1054      rom_id[i] = ROM[hilo_mode - 0x0e + i];
10551055
10561056   /* Title */
10571057   for(int i = 0; i < 21; i++ )
trunk/src/mess/machine/snescart.c
r21634r21635
413413   return retvalue;
414414}
415415
416static int snes_find_addon_chip( running_machine &machine )
416static int snes_find_addon_chip( running_machine &machine, UINT8 *buffer, UINT32 start_offs )
417417{
418418   snes_state *state = machine.driver_data<snes_state>();
419   address_space &space = machine.device("maincpu")->memory().space(AS_PROGRAM);
420419   int supported_type = 1;
421420   int dsp_prg_offset = 0;
422421
423422   /* Info mostly taken from http://snesemu.black-ship.net/misc/-from%20nsrt.edgeemu.com-chipinfo.htm */
424   switch (snes_r_bank1(space, 0x00ffd6))
423   switch (buffer[start_offs + 0x16])
425424   {
426425      case 0x00:
427426      case 0x01:
r21634r21635
430429         break;
431430
432431      case 0x03:
433         if (snes_r_bank1(space, 0x00ffd5) == 0x30)
432         if (buffer[start_offs + 0x15] == 0x30)
434433         {
435434            state->m_has_addon_chip = HAS_DSP4;
436435            dsp_prg_offset = SNES_DSP4_OFFSET;
r21634r21635
448447         break;
449448
450449      case 0x05:
451         if (snes_r_bank1(space, 0x00ffd5) == 0x20)
450         if (buffer[start_offs + 0x15] == 0x20)
452451         {
453452            state->m_has_addon_chip = HAS_DSP2;
454453            dsp_prg_offset = SNES_DSP2_OFFSET;
455454         }
456455         /* DSP-3 is hard to detect. We exploit the fact that the only game has been manufactured by Bandai */
457         else if ((snes_r_bank1(space, 0x00ffd5) == 0x30) && (snes_r_bank1(space, 0x00ffda) == 0xb2))
456         else if ((buffer[start_offs + 0x15] == 0x30) && (buffer[start_offs + 0x1a] == 0xb2))
458457         {
459458            state->m_has_addon_chip = HAS_DSP3;
460459            dsp_prg_offset = SNES_DSP3_OFFSET;
r21634r21635
470469      case 0x14:  // GSU-x
471470      case 0x15:  // GSU-x
472471      case 0x1a:  // GSU-1 (21 MHz at start)
473         if (snes_r_bank1(space, 0x00ffd5) == 0x20)
472         if (buffer[start_offs + 0x15] == 0x20)
474473            state->m_has_addon_chip = HAS_SUPERFX;
475474         break;
476475
r21634r21635
481480      case 0x32:  // needed by a Sample game (according to ZSNES)
482481      case 0x34:
483482      case 0x35:
484         if (snes_r_bank1(space, 0x00ffd5) == 0x23)
483         if (buffer[start_offs + 0x15] == 0x23)
485484         {
486485            state->m_has_addon_chip = HAS_SA1;
487486            supported_type = 0;
r21634r21635
491490
492491      case 0x43:
493492      case 0x45:
494         if (snes_r_bank1(space, 0x00ffd5) == 0x32)
493         if (buffer[start_offs + 0x15] == 0x32)
495494         {
496495            state->m_has_addon_chip = HAS_SDD1;
497496         }
498497         break;
499498
500499      case 0x55:
501         if (snes_r_bank1(space, 0x00ffd5) == 0x35)
500         if (buffer[start_offs + 0x15] == 0x35)
502501         {
503502            state->m_has_addon_chip = HAS_RTC;
504503         }
r21634r21635
514513         break;
515514
516515      case 0xf5:
517         if (snes_r_bank1(space, 0x00ffd5) == 0x30)
516         if (buffer[start_offs + 0x15] == 0x30)
518517         {
519518            state->m_has_addon_chip = HAS_ST018;
520519            supported_type = 0;
521520         }
522         else if (snes_r_bank1(space, 0x00ffd5) == 0x3a)
521         else if (buffer[start_offs + 0x15] == 0x3a)
523522         {
524523            state->m_has_addon_chip = HAS_SPC7110;
525524         }
r21634r21635
528527      case 0xf6:
529528         /* These Seta ST-01X chips have both 0x30 at 0x00ffd5,
530529          they only differ for the 'size' at 0x00ffd7 */
531         if (snes_r_bank1(space, 0x00ffd7) < 0x0a)
530         if (buffer[start_offs + 0x17] < 0x0a)
532531            state->m_has_addon_chip = HAS_ST011;
533532         else
534533            state->m_has_addon_chip = HAS_ST010;
r21634r21635
539538         break;
540539
541540      case 0xf9:
542         if (snes_r_bank1(space, 0x00ffd5) == 0x3a)
541         if (buffer[start_offs + 0x15] == 0x3a)
543542         {
544543            state->m_has_addon_chip = HAS_SPC7110_RTC;
545544            supported_type = 0;
r21634r21635
595594   return supported_type;
596595}
597596
598static void snes_cart_log_info( running_machine &machine, int total_blocks, int supported )
597static void snes_cart_log_info( running_machine &machine, UINT8* ROM, int total_blocks, int supported )
599598{
600599   snes_state *state = machine.driver_data<snes_state>();
601   address_space &space = machine.device("maincpu")->memory().space(AS_PROGRAM);
600   device_image_interface *image = dynamic_cast<device_image_interface *>(machine.device("cart"));
602601   char title[21], rom_id[4], company_id[2];
603602   int i, company, has_ram = 0, has_sram = 0;
604
603   UINT32 offset = snes_skip_header(*image, state->m_cart_size);
604   UINT32 hilo_mode = snes_find_hilo_mode(*image, ROM, offset, 0);
605   
605606   /* Company */
606607   for (i = 0; i < 2; i++)
607      company_id[i] = snes_r_bank1(space, 0x00ffb0 + i);
608      company_id[i] = ROM[hilo_mode - 0x10 + i];
608609   company = (char_to_int_conv(company_id[0]) << 4) + char_to_int_conv(company_id[1]);
609610   if (company == 0)
610      company = snes_r_bank1(space, 0x00ffda);
611      company = ROM[hilo_mode + 0x1a];
611612
612613   /* ROM ID */
613   for( i = 0; i < 4; i++ )
614      rom_id[i] = snes_r_bank1(space, 0x00ffb2 + i);
614   for (i = 0; i < 4; i++)
615      rom_id[i] = ROM[hilo_mode - 0x0e + i];
615616
616617   /* Title */
617   for( i = 0; i < 21; i++ )
618      title[i] = snes_r_bank1(space, 0x00ffc0 + i);
618   for (i = 0; i < 21; i++)
619      title[i] = ROM[hilo_mode + i];
619620
620621   /* RAM */
621   if (((snes_r_bank1(space, 0x00ffd6) & 0xf) == 1) ||
622      ((snes_r_bank1(space, 0x00ffd6) & 0xf) == 2) ||
623      ((snes_r_bank1(space, 0x00ffd6) & 0xf) == 4) ||
624      ((snes_r_bank1(space, 0x00ffd6) & 0xf) == 5))
622   if (((ROM[hilo_mode + 0x16] & 0xf) == 1) ||
623      ((ROM[hilo_mode + 0x16] & 0xf) == 2) ||
624      ((ROM[hilo_mode + 0x16] & 0xf) == 4) ||
625      ((ROM[hilo_mode + 0x16] & 0xf) == 5))
625626      has_ram = 1;
626627
627628   /* SRAM */
628   if (((snes_r_bank1(space, 0x00ffd6) & 0xf) == 2) ||
629      ((snes_r_bank1(space, 0x00ffd6) & 0xf) == 5) ||
630      ((snes_r_bank1(space, 0x00ffd6) & 0xf) == 6))
629   if (((ROM[hilo_mode + 0x16] & 0xf) == 2) ||
630      ((ROM[hilo_mode + 0x16] & 0xf) == 5) ||
631      ((ROM[hilo_mode + 0x16] & 0xf) == 6))
631632      has_sram = 1;
632633
633634   logerror( "ROM DETAILS\n" );
r21634r21635
644645   logerror( "HEADER DETAILS\n" );
645646   logerror( "==============\n\n" );
646647   logerror( "\tName:          %.21s\n", title );
647   logerror( "\tSpeed:         %s [%d]\n", ((snes_r_bank1(space, 0x00ffd5) & 0xf0)) ? "FastROM" : "SlowROM", (snes_r_bank1(space, 0x00ffd5) & 0xf0) >> 4 );
648   logerror( "\tBank size:     %s [%d]\n", (snes_r_bank1(space, 0x00ffd5) & 0xf) ? "HiROM" : "LoROM", snes_r_bank1(space, 0x00ffd5) & 0xf );
648   logerror( "\tSpeed:         %s [%d]\n", ((ROM[hilo_mode + 0x15] & 0xf0)) ? "FastROM" : "SlowROM", (ROM[hilo_mode + 0x15] & 0xf0) >> 4 );
649   logerror( "\tBank size:     %s [%d]\n", (ROM[hilo_mode + 0x15] & 0xf) ? "HiROM" : "LoROM", ROM[hilo_mode + 0x15] & 0xf );
649650
650651   logerror( "\tType:          %s", types[state->m_has_addon_chip]);
651652   if (has_ram)
652653      logerror( ", RAM");
653654   if (has_sram)
654655      logerror( ", SRAM");
655   logerror( " [%d]\n", snes_r_bank1(space, 0x00ffd6) );
656   logerror( " [%d]\n", ROM[hilo_mode + 0x16] );
656657
657   logerror( "\tSize:          %d megabits [%d]\n", 1 << (snes_r_bank1(space, 0x00ffd7) - 7), snes_r_bank1(space, 0x00ffd7) );
658   logerror( "\tSRAM:          %d kilobits [%d]\n", state->m_cart[0].m_nvram_size * 8, snes_ram[0xffd8] );
659   logerror( "\tCountry:       %s [%d]\n", countries[snes_r_bank1(space, 0x00ffd9)], snes_r_bank1(space, 0x00ffd9) );
660   logerror( "\tLicense:       %s [%X]\n", companies[snes_r_bank1(space, 0x00ffda)], snes_r_bank1(space, 0x00ffda) );
661   logerror( "\tVersion:       1.%d\n", snes_r_bank1(space, 0x00ffdb) );
662   logerror( "\tInv Checksum:  %X %X\n", snes_r_bank1(space, 0x00ffdd), snes_r_bank1(space, 0x00ffdc) );
663   logerror( "\tChecksum:      %X %X\n", snes_r_bank1(space, 0x00ffdf), snes_r_bank1(space, 0x00ffde) );
664   logerror( "\tNMI Address:   %2X%2Xh\n", snes_r_bank1(space, 0x00fffb), snes_r_bank1(space, 0x00fffa) );
665   logerror( "\tStart Address: %2X%2Xh\n\n", snes_r_bank1(space, 0x00fffd), snes_r_bank1(space, 0x00fffc) );
658   logerror( "\tSize:          %d megabits [%d]\n", 1 << (ROM[hilo_mode + 0x17] - 7), ROM[hilo_mode + 0x17] );
659   logerror( "\tSRAM:          %d kilobits [%d]\n", state->m_cart[0].m_nvram_size * 8, ROM[hilo_mode + 0x18] );
660   logerror( "\tCountry:       %s [%d]\n", countries[ROM[hilo_mode + 0x19]], ROM[hilo_mode + 0x19] );
661   logerror( "\tLicense:       %s [%X]\n", companies[ROM[hilo_mode + 0x1a]], ROM[hilo_mode + 0x1a] );
662   logerror( "\tVersion:       1.%d\n", ROM[hilo_mode + 0x1b] );
663   logerror( "\tInv Checksum:  %X %X\n", ROM[hilo_mode + 0x1d], ROM[hilo_mode + 0x1c] );
664   logerror( "\tChecksum:      %X %X\n", ROM[hilo_mode + 0x1f], ROM[hilo_mode + 0x1e] );
665   logerror( "\tNMI Address:   %2X%2Xh\n", ROM[hilo_mode + 0x2b], ROM[hilo_mode + 0x2a] );
666   logerror( "\tStart Address: %2X%2Xh\n\n", ROM[hilo_mode + 0x2d], ROM[hilo_mode + 0x2c] );
666667
667668   logerror( "\tMode: %d\n", state->m_cart[0].mode);
668669
r21634r21635
674675{
675676   int supported_type = 1;
676677   running_machine &machine = image.device().machine();
677   address_space &space = machine.device( "maincpu")->memory().space( AS_PROGRAM );
678678   int total_blocks, read_blocks, has_bsx_slot = 0, st_bios = 0;
679679   UINT32 offset, int_header_offs;
680680   UINT8 *ROM = memregion("cart")->base();
r21634r21635
10031003   }
10041004
10051005   /* Detect special chips */
1006   supported_type = snes_find_addon_chip(machine);
1006   supported_type = snes_find_addon_chip(machine, ROM, int_header_offs);
10071007
10081008   /* Find the amount of cart ram */
10091009   m_cart[0].m_nvram_size = 0;
r21634r21635
10111011   {
10121012      UINT32 nvram_size;
10131013      if ((m_has_addon_chip != HAS_SUPERFX))
1014         nvram_size = snes_r_bank1(space, 0x00ffd8);
1014         nvram_size = ROM[int_header_offs + 0x18];
10151015      else
1016         nvram_size = (snes_r_bank1(space, 0x00ffbd) & 0x07);
1016         nvram_size = (ROM[0x00ffbd] & 0x07);
10171017
10181018      if (nvram_size > 0)
10191019      {
r21634r21635
10441044      m_cart[0].m_nvram = auto_alloc_array_clear(machine, UINT8, m_cart[0].m_nvram_size);
10451045
10461046   /* Log snes_cart information */
1047   snes_cart_log_info(machine, total_blocks, supported_type);
1047   snes_cart_log_info(machine, ROM, total_blocks, supported_type);
10481048
10491049   /* Load SRAM */
10501050   snes_load_sram(machine);

Previous 199869 Revisions Next


© 1997-2024 The MAME Team