V28D: Simplify GBA Logo Check

This commit is contained in:
sanni 2017-09-15 17:51:41 +02:00 committed by GitHub
parent 2eb0b8546e
commit 2a0ca1b236
2 changed files with 9 additions and 32 deletions

View File

@ -2,8 +2,8 @@
Cartridge Reader for Arduino Mega2560
Author: sanni
Date: 2017-09-14
Version: V28C
Date: 2017-09-15
Version: V28D
SD lib: https://github.com/greiman/SdFat
LCD lib: https://github.com/adafruit/Adafruit_SSD1306
@ -34,7 +34,7 @@
YamaArashi - GBA flashrom bank switch command
**********************************************************************************/
char ver[5] = "V28C";
char ver[5] = "V28D";
/******************************************
Define Output

View File

@ -8,19 +8,6 @@
char calcChecksumStr[5];
boolean readType;
static const int nintendoLogo[] PROGMEM = {
0x00, 0x00, 0x00, 0x00, 0x24, 0xFF, 0xAE, 0x51, 0x69, 0x9A, 0xA2, 0x21, 0x3D, 0x84, 0x82, 0x0A,
0x84, 0xE4, 0x09, 0xAD, 0x11, 0x24, 0x8B, 0x98, 0xC0, 0x81, 0x7F, 0x21, 0xA3, 0x52, 0xBE, 0x19,
0x93, 0x09, 0xCE, 0x20, 0x10, 0x46, 0x4A, 0x4A, 0xF8, 0x27, 0x31, 0xEC, 0x58, 0xC7, 0xE8, 0x33,
0x82, 0xE3, 0xCE, 0xBF, 0x85, 0xF4, 0xDF, 0x94, 0xCE, 0x4B, 0x09, 0xC1, 0x94, 0x56, 0x8A, 0xC0,
0x13, 0x72, 0xA7, 0xFC, 0x9F, 0x84, 0x4D, 0x73, 0xA3, 0xCA, 0x9A, 0x61, 0x58, 0x97, 0xA3, 0x27,
0xFC, 0x03, 0x98, 0x76, 0x23, 0x1D, 0xC7, 0x61, 0x03, 0x04, 0xAE, 0x56, 0xBF, 0x38, 0x84, 0x00,
0x40, 0xA7, 0x0E, 0xFD, 0xFF, 0x52, 0xFE, 0x03, 0x6F, 0x95, 0x30, 0xF1, 0x97, 0xFB, 0xC0, 0x85,
0x60, 0xD6, 0x80, 0x25, 0xA9, 0x63, 0xBE, 0x03, 0x01, 0x4E, 0x38, 0xE2, 0xF9, 0xA2, 0x34, 0xFF,
0xBB, 0x3E, 0x03, 0x44, 0x78, 0x00, 0x90, 0xCB, 0x88, 0x11, 0x3A, 0x94, 0x65, 0xC0, 0x7C, 0x63,
0x87, 0xF0, 0x3C, 0xAF, 0xD6, 0x25, 0xE4, 0x8B, 0x38, 0x0A, 0xAC, 0x72, 0x21, 0xD4, 0xF8, 0x07
};
/******************************************
Menu
*****************************************/
@ -750,8 +737,8 @@ void writeByte_GBA(unsigned long myAddress, byte myData) {
/******************************************
GBA ROM Functions
*****************************************/
// Test known Nintendo header for errors and sets read method to either sequential or random access
int testHeader() {
// Read info out of rom header
void getCartInfo_GBA() {
// Read Header into array
for (int currWord = 0; currWord < 192; currWord += 2) {
word tempWord = readWord_GBA(currWord);
@ -760,24 +747,14 @@ int testHeader() {
sdBuffer[currWord + 1] = (tempWord >> 8) & 0xFF;
}
// Compare Nintendo logo, 156 bytes starting at 0x04
int errors = 0;
// Compare Nintendo logo against known checksum, 156 bytes starting at 0x04
byte logoChecksum = 0;
for (int currByte = 0x4; currByte < 0xA0; currByte++) {
if (pgm_read_byte(&nintendoLogo[currByte]) != sdBuffer[currByte]) {
errors++;
}
logoChecksum += sdBuffer[currByte];
}
return errors;
}
// Read info out of rom header
void getCartInfo_GBA() {
// Test rom header for errors
int logoErrors = testHeader();
if (logoErrors != 0) {
if (logoChecksum != 0x1B) {
print_Error(F("CARTRIDGE ERROR"), false);
cartSize = 32;
strcpy(romName, "ERROR");
println_Msg(F(""));
println_Msg(F(""));