#ifndef NALL_EMULATION_FAMICOM_HPP #define NALL_EMULATION_FAMICOM_HPP #include #include namespace nall { struct FamicomCartridge { string markup; inline FamicomCartridge(const uint8_t *data, unsigned size); //private: unsigned mapper; unsigned mirror; unsigned prgrom; unsigned prgram; unsigned chrrom; unsigned chrram; }; FamicomCartridge::FamicomCartridge(const uint8_t *data, unsigned size) { markup = ""; if(size < 16) return; if(data[0] != 'N') return; if(data[1] != 'E') return; if(data[2] != 'S') return; if(data[3] != 26) return; markup.append("\n"); mapper = ((data[7] >> 4) << 4) | (data[6] >> 4); mirror = ((data[6] & 0x08) >> 2) | (data[6] & 0x01); prgrom = data[4] * 0x4000; chrrom = data[5] * 0x2000; prgram = 0u; chrram = chrrom == 0u ? 8192u : 0u; markup.append("\n"); switch(mapper) { default: markup.append(" \n"); markup.append(" \n"); break; case 1: markup.append(" \n"); markup.append(" \n"); prgram = 8192; break; case 2: markup.append(" \n"); markup.append(" \n"); break; case 3: markup.append(" \n"); markup.append(" \n"); break; case 4: //MMC3 markup.append(" \n"); markup.append(" \n"); prgram = 8192; //MMC6 //markup.append(" \n"); //markup.append(" \n"); //prgram = 1024; break; case 5: markup.append(" \n"); markup.append(" \n"); prgram = 65536; break; case 7: markup.append(" \n"); break; case 9: markup.append(" \n"); markup.append(" \n"); prgram = 8192; break; case 10: markup.append(" \n"); markup.append(" \n"); prgram = 8192; break; case 16: markup.append(" \n"); markup.append(" \n"); break; case 21: case 23: case 25: //VRC4 markup.append(" \n"); markup.append(" \n"); markup.append(" \n"); markup.append(" \n"); prgram = 8192; break; case 22: //VRC2 markup.append(" \n"); markup.append(" \n"); markup.append(" \n"); markup.append(" \n"); break; case 24: markup.append(" \n"); markup.append(" \n"); break; case 26: markup.append(" \n"); markup.append(" \n"); prgram = 8192; break; case 34: markup.append(" \n"); markup.append(" \n"); break; case 66: markup.append(" \n"); markup.append(" \n"); break; case 69: markup.append(" \n"); markup.append(" \n"); prgram = 8192; break; case 73: markup.append(" \n"); markup.append(" \n"); markup.append(" \n"); prgram = 8192; break; case 75: markup.append(" \n"); markup.append(" \n"); break; case 85: markup.append(" \n"); markup.append(" \n"); prgram = 8192; break; } markup.append(" \n"); if(prgrom) markup.append(" \n"); if(prgram) markup.append(" \n"); markup.append(" \n"); markup.append(" \n"); if(chrrom) markup.append(" \n"); if(chrram) markup.append(" \n"); markup.append(" \n"); markup.append("\n"); markup.transform("'", "\""); } } #endif