diff --git a/Cart_Reader/Cart_Reader.ino b/Cart_Reader/Cart_Reader.ino index f526faf..822a0f9 100644 --- a/Cart_Reader/Cart_Reader.ino +++ b/Cart_Reader/Cart_Reader.ino @@ -2,8 +2,8 @@ Cartridge Reader for Arduino Mega2560 Author: sanni - Date: 2017-06-28 - Version: V27B + Date: 2017-07-13 + Version: V27D 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] = "V27B"; +char ver[5] = "V27D"; /****************************************** Define Output diff --git a/Cart_Reader/FLASH.ino b/Cart_Reader/FLASH.ino index ca24ba6..1562d9b 100644 --- a/Cart_Reader/FLASH.ino +++ b/Cart_Reader/FLASH.ino @@ -1019,7 +1019,7 @@ void writeFlash16() { // Write one full page at a time for (byte c = 0; c < 64; c++) { - word currWord = ( ( sdBuffer[d] & 0xFF ) << 8 ) | ( sdBuffer[d + 1] & 0xFF ); + word currWord = ( ( sdBuffer[d + 1] & 0xFF ) << 8 ) | ( sdBuffer[d] & 0xFF ); writeWord_Flash(currByte + c, currWord); d += 2; } @@ -1078,7 +1078,7 @@ void writeFlash16_29F1601() { // Write one full page at a time for (byte c = 0; c < 64; c++) { - word currWord = ( ( sdBuffer[d] & 0xFF ) << 8 ) | ( sdBuffer[d + 1] & 0xFF ); + word currWord = ( ( sdBuffer[d + 1] & 0xFF ) << 8 ) | ( sdBuffer[d] & 0xFF ); writeWord_Flash(currByte + c, currWord); if (c == 63) { @@ -1195,7 +1195,7 @@ void verifyFlash16() { //fill sdBuffer myFile.read(sdBuffer, 512); for (int c = 0; c < 256; c++) { - word currWord = ((sdBuffer[d] << 8) | sdBuffer[d + 1]); + word currWord = ((sdBuffer[d + 1] << 8) | sdBuffer[d]); if (readWord_Flash(currByte + c) != currWord) { blank++; @@ -1254,10 +1254,10 @@ void readFlash16() { for (word c = 0; c < 256; c++) { word currWord = readWord_Flash(currByte + c); // Split word into two bytes - // Left - sdBuffer[d] = (( currWord >> 8 ) & 0xFF); // Right - sdBuffer[d + 1] = (currWord & 0xFF); + sdBuffer[d + 1] = (( currWord >> 8 ) & 0xFF); + // Left + sdBuffer[d] = (currWord & 0xFF); d += 2; } myFile.write(sdBuffer, 512); @@ -1277,30 +1277,31 @@ void printFlash16(int numBytes) { short_val = ( ( left_byte & 0xFF ) << 8 ) | ( right_byte & 0xFF ); */ - char buffer[3]; + char buf[3]; for (int currByte = 0; currByte < numBytes / 2; currByte += 5) { + // 5 words per line for (int c = 0; c < 5; c++) { - word currWord = readWord_Flash(currByte + c); // Split word into two bytes - byte right_byte = currWord & 0xFF; - byte left_byte = ( currWord >> 8 ) & 0xFF; + byte left_byte = currWord & 0xFF; + byte right_byte = ( currWord >> 8 ) & 0xFF; - itoa (left_byte, buffer, 16); - for (int i = 0; i < 2 - strlen(buffer); i++) { - print_Msg('0'); + + sprintf (buf, "%x", left_byte); + for (int i = 0; i < 2 - strlen(buf); i++) { + print_Msg("0"); } // Now print the significant bits - print_Msg(buffer); + print_Msg(buf); - itoa (right_byte, buffer, 16); - for (int i = 0; i < 2 - strlen(buffer); i++) { - print_Msg('0'); + sprintf (buf, "%x", right_byte); + for (int i = 0; i < 2 - strlen(buf); i++) { + print_Msg("0"); } // Now print the significant bits - print_Msg(buffer); + print_Msg(buf); } println_Msg(""); } diff --git a/Cart_Reader/SNES.ino b/Cart_Reader/SNES.ino index 7874194..1f55308 100644 --- a/Cart_Reader/SNES.ino +++ b/Cart_Reader/SNES.ino @@ -1076,26 +1076,26 @@ void writeSRAM (boolean browseFile) { // Disable CPU clock clockgen.output_enable(SI5351_CLK1, 0); -/* // MOVED RESET TO AFTER VERIFY - // Reset SA1 - // Set pins to input - dataIn(); - // Close the file: - myFile.close(); - println_Msg(F("SRAM writing finished")); - println_Msg(F("Press Button to reset")); - display_Update(); - wait(); - // Set reset pin to output (PH0) - DDRH |= (1 << 0); - // Switch RST(PH0) to LOW - PORTH &= ~(1 << 0); - display_Clear(); - print_Msg("Resetting..."); - display_Update(); - delay(3000); // wait 3 secs to switch to next game - asm volatile (" jmp 0"); -*/ + /* // MOVED RESET TO AFTER VERIFY + // Reset SA1 + // Set pins to input + dataIn(); + // Close the file: + myFile.close(); + println_Msg(F("SRAM writing finished")); + println_Msg(F("Press Button to reset")); + display_Update(); + wait(); + // Set reset pin to output (PH0) + DDRH |= (1 << 0); + // Switch RST(PH0) to LOW + PORTH &= ~(1 << 0); + display_Clear(); + print_Msg("Resetting..."); + display_Update(); + delay(3000); // wait 3 secs to switch to next game + asm volatile (" jmp 0"); + */ } // Set pins to input @@ -1749,4 +1749,4 @@ boolean eraseSRAM (byte b) { //****************************************** // End of File -//****************************************** +//******************************************