Add auto mapper detecting for MMC3 carts

"E000-FFFF is always fixed to the last bank of ROM." Source: http://kevtris.org/mappers/mmc3/index.html
Therefore calculate CRC32 of the first 512 bytes of the last bank of the PRG ROM instead of the first bank.

Database creation code example:

````
// Convert iNES to useful info (thx to fceux)
    mapper = (romFile[6] >> 4);
    mapper |= (romFile[7] & 0xF0);
    mapper |= ((romFile[8] & 0x0F) << 8);

    // PRG size
    if ((romFile[9] & 0x0F) != 0x0F) {
      // simple notation
      prgsize = (romFile[4] | ((romFile[9] & 0x0F) << 8)); 
    }
    else {
      // exponent-multiplier notation
      prgsize = (((1 << (romFile[4] >> 2)) * ((romFile[4] & 0x3) * 2 + 1)) >> 14); 
    }
    if (prgsize != 0)
      prgsize = (int(log(prgsize) / log(2)));
              
    prgsize = (int_pow(2, prgsize)) * 16;
    
    byte[] first512 = new byte[512];
     
    // MMC1
    if(mapper == 1){
    }
     // MMC2
    if(mapper == 9){
    }
    // MMC3
    if(mapper == 4){
	// MMC3 has 8KB banks
      int startoffset = (prgsize/8 - 1) *8 *1024;  
      // Get crc32 of first 512 bytes of last PRG bank
      for(int l = 0; l < 512; l++){
        first512[l] = romFile[16 + startoffset + l];
      }  
    }
    // MMC4
    else if(mapper == 10){
    }
    // MMC5
    else if(mapper == 5){
    }
    else {
      // Get crc32 of first 512 bytes after iNES header
      for(int l = 0; l < 512; l++){
      first512[l] = romFile[16 + l];
      }
    }
````
This commit is contained in:
sanni 2022-10-04 22:31:23 +02:00 committed by GitHub
parent 3d7c424344
commit f52df29266
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

1390
sd/nes.txt

File diff suppressed because it is too large Load Diff