diff --git a/ArcadeHacker_Sega_FD1094.ino b/ArcadeHacker_Sega_FD1094.ino index 7ced7eb..2d61fac 100644 --- a/ArcadeHacker_Sega_FD1094.ino +++ b/ArcadeHacker_Sega_FD1094.ino @@ -1,4 +1,4 @@ -#define version "Sega System16/18/24/X Hitachi FD1094 Security Programmer 1.1 by arcadehacker.blogspot.com" +#define version "Sega System16/18/24/X Hitachi FD1094 Security Programmer 1.2 by arcadehacker.blogspot.com" // Uncomment the game you would like to program from the list below, only one line must be uncommented at any time. @@ -210,21 +210,21 @@ int invertbit(int Bit) int parity(unsigned char cByte) { -int bits[8]; -Byte2Bits(cByte, bits); -int xor1 = bits[0] ^ bits[1]; -int xor2 = bits[2] ^ bits[3]; -int xor3 = bits[4] ^ bits[5]; -int xor4 = bits[6] ^ bits[7]; -int xora = xor1 ^ xor2; -int xorb = xor3 ^ xor4; -int xorf = xora ^ xorb; -return invertbit(xorf); + int bits[8]; + + Byte2Bits(cByte, bits); + int xor1 = bits[0] ^ bits[1]; + int xor2 = bits[2] ^ bits[3]; + int xor3 = bits[4] ^ bits[5]; + int xor4 = bits[6] ^ bits[7]; + int xora = xor1 ^ xor2; + int xorb = xor3 ^ xor4; + int xorf = xora ^ xorb; + return invertbit(xorf); } float readportanalog(char port) { - int value = analogRead(port); float voltage = value * (5.0 / 1023.0); //Serial.print(voltage); @@ -305,9 +305,31 @@ void writesecret() digitalWrite(D0, HIGH); clkrw(); } + void dataverifydo() { - int ok = 0, fail = 0; + verifysecret(); + + digitalWrite(RW, HIGH); digitalWrite(AD1, HIGH); // activate D0 INPUT + pinMode(D0, INPUT); + + for (int c=0; c <= 8191; c++) { + float voltage; + + p(" Addr: "); Serial.print(c); + p(" Read volts: "); voltage = readportanalog(D0); Serial.print(voltage); + cByte = pgm_read_byte_near(EncryptionKey + c); + p(" Config Parity: "); Serial.print(parity(cByte)); + p(" Chip Parity: "); Serial.print(digitalRead(D0)); + if (parity(cByte) != digitalRead(D0)) {p(" NO MATCH");} + p("\r\n"); + digitalWrite(AS, HIGH); digitalWrite(AS, LOW); + } +} + +void dataverifyfastdo() +{ + int differences = 0; verifysecret(); digitalWrite(RW, HIGH); digitalWrite(AD1, HIGH); // activate D0 INPUT @@ -318,26 +340,15 @@ void dataverifydo() float voltage = readportanalog(D0); cByte = pgm_read_byte_near(EncryptionKey + c); if (parity(cByte) != digitalRead(D0)) - { - p(" Addr: "); Serial.print(c); - p(" Read volts: "); Serial.print(voltage); - p(" Config Parity: "); Serial.print(parity(cByte)); - p(" Chip Parity: "); Serial.print(digitalRead(D0)); - p(" NO MATCH\r\n"); - fail++; - } - else - ok ++; + differences ++; + digitalWrite(AS, HIGH); digitalWrite(AS, LOW); } - if(!fail) - { - p("\r\nVerify OK, Correct Bytes: "); Serial.print(ok); - p("\r\n"); - } + if(!differences) + p("Verified OK\r\n"); else { - p("\r\nVerify FAILED, Errors "); Serial.print(fail); + p("Veify FAILED, Number of differences: "); Serial.print(differences); p("\r\n"); } } @@ -450,38 +461,41 @@ void setup() p("\r\n"); p(version); p("\r\n\r\n"); p("Commands:\r\n"); p("w - Writes encryption key data into the FD1094 chip. Select your game by uncommenting the appropriate line in the arduino program source code.\r\n"); - p("v - Dumps and compares a parity bit for all encryption data bytes stored inside the FD1094 chip.\r\n\r\n"); + p("v - Dumps and compares a parity bit for all encryption data bytes stored inside the FD1094 chip.\r\n"); + p("c - Dumps and compares jus as 'v' but giving only the global results from the operation.\r\n\r\n"); p("Game configuration selected: "); p(Game); p("\r\n\r\n"); } void loop() -{ - - if (Serial.available()>0) - { - - memset(temp, 0, TEMP_SIZE); - Serial.readBytesUntil('\r', temp, TEMP_SIZE-1); +{ + if (Serial.available()>0) + { + memset(temp, 0, TEMP_SIZE); + Serial.readBytesUntil('\r', temp, TEMP_SIZE-1); - char *pTemp = temp; + char *pTemp = temp; + if (temp[0]=='w') + { + p("Data Write...\r\n"); + datawrite(); + p("Done!\r\n\r\n"); + } + + if (temp[0]=='v') + { + p("Data Verify...\r\n"); + dataverify(); + p("Done!\r\n\r\n"); + } - if (temp[0]=='w') - { - p("Data Write...\r\n"); - datawrite(); - p("Done!\r\n\r\n"); - } - - if (temp[0]=='v') - { - p("Data Verify...\r\n"); - dataverify(); - p("Done!\r\n\r\n"); - } - - } - + if (temp[0]=='c') + { + p("Data Verify...\r\n"); + dataverifyfastdo(); + p("Done!\r\n\r\n"); + } + } }