mirror of
https://github.com/sanni/cartreader.git
synced 2024-11-30 16:34:14 +01:00
V18A: Added delay to SNES write
This commit is contained in:
parent
ee01ff3bfa
commit
5d3e4a3628
@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
Author: sanni
|
Author: sanni
|
||||||
Date: 2016-08-25
|
Date: 2016-08-25
|
||||||
Version: V18
|
Version: V18A
|
||||||
|
|
||||||
SD lib: https://github.com/greiman/SdFat
|
SD lib: https://github.com/greiman/SdFat
|
||||||
LCD lib: https://github.com/adafruit/Adafruit_SSD1306
|
LCD lib: https://github.com/adafruit/Adafruit_SSD1306
|
||||||
@ -31,7 +31,7 @@
|
|||||||
Pickle - SDD1 fix
|
Pickle - SDD1 fix
|
||||||
|
|
||||||
**********************************************************************************/
|
**********************************************************************************/
|
||||||
char ver[5] = "V18";
|
char ver[5] = "V18A";
|
||||||
|
|
||||||
/******************************************
|
/******************************************
|
||||||
Define Output
|
Define Output
|
||||||
|
@ -117,7 +117,7 @@ void NPGameMenu() {
|
|||||||
print_Msg(F("Game "));
|
print_Msg(F("Game "));
|
||||||
print_Msg(gameSubMenu + 0x81, HEX);
|
print_Msg(gameSubMenu + 0x81, HEX);
|
||||||
println_Msg(F(" Timeout"));
|
println_Msg(F(" Timeout"));
|
||||||
println_Msg(readBank_SNES(0, 0x2400));
|
println_Msg(readBank_SNES(0, 0x2400), HEX);
|
||||||
println_Msg(F(""));
|
println_Msg(F(""));
|
||||||
print_Error(F("Please powercycle NP cart"), true);
|
print_Error(F("Please powercycle NP cart"), true);
|
||||||
}
|
}
|
||||||
@ -1321,16 +1321,13 @@ byte send_NP(byte command) {
|
|||||||
// Switch to write
|
// Switch to write
|
||||||
dataOut();
|
dataOut();
|
||||||
controlOut_SNES();
|
controlOut_SNES();
|
||||||
__asm__("nop\n\t""nop\n\t""nop\n\t""nop\n\t""nop\n\t""nop\n\t""nop\n\t""nop\n\t");
|
|
||||||
|
|
||||||
// Write command
|
// Write command
|
||||||
writeBank_SNES(0, 0x2400, 0x09);
|
writeBank_SNES(0, 0x2400, 0x09);
|
||||||
__asm__("nop\n\t""nop\n\t""nop\n\t""nop\n\t""nop\n\t""nop\n\t""nop\n\t""nop\n\t");
|
|
||||||
|
|
||||||
// Switch to read
|
// Switch to read
|
||||||
dataIn();
|
dataIn();
|
||||||
controlIn_SNES();
|
controlIn_SNES();
|
||||||
__asm__("nop\n\t""nop\n\t""nop\n\t""nop\n\t""nop\n\t""nop\n\t""nop\n\t""nop\n\t");
|
|
||||||
|
|
||||||
// Read status
|
// Read status
|
||||||
NPReady = readBank_SNES(0, 0x2400);
|
NPReady = readBank_SNES(0, 0x2400);
|
||||||
@ -1338,29 +1335,22 @@ byte send_NP(byte command) {
|
|||||||
// Switch to write
|
// Switch to write
|
||||||
dataOut();
|
dataOut();
|
||||||
controlOut_SNES();
|
controlOut_SNES();
|
||||||
__asm__("nop\n\t""nop\n\t""nop\n\t""nop\n\t""nop\n\t""nop\n\t""nop\n\t""nop\n\t");
|
|
||||||
|
|
||||||
writeBank_SNES(0, 0x2401, 0x28);
|
writeBank_SNES(0, 0x2401, 0x28);
|
||||||
__asm__("nop\n\t""nop\n\t""nop\n\t""nop\n\t""nop\n\t""nop\n\t""nop\n\t""nop\n\t");
|
|
||||||
writeBank_SNES(0, 0x2401, 0x84);
|
writeBank_SNES(0, 0x2401, 0x84);
|
||||||
__asm__("nop\n\t""nop\n\t""nop\n\t""nop\n\t""nop\n\t""nop\n\t""nop\n\t""nop\n\t");
|
|
||||||
|
|
||||||
// NP_CMD_06h, send this only if above read has returned 7Dh, not if it's already returning 2Ah
|
// NP_CMD_06h, send this only if above read has returned 7Dh, not if it's already returning 2Ah
|
||||||
if (NPReady == 0x7D) {
|
if (NPReady == 0x7D) {
|
||||||
writeBank_SNES(0, 0x2400, 0x06);
|
writeBank_SNES(0, 0x2400, 0x06);
|
||||||
__asm__("nop\n\t""nop\n\t""nop\n\t""nop\n\t""nop\n\t""nop\n\t""nop\n\t""nop\n\t");
|
|
||||||
writeBank_SNES(0, 0x2400, 0x39);
|
writeBank_SNES(0, 0x2400, 0x39);
|
||||||
__asm__("nop\n\t""nop\n\t""nop\n\t""nop\n\t""nop\n\t""nop\n\t""nop\n\t""nop\n\t");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Write the command
|
// Write the command
|
||||||
writeBank_SNES(0, 0x2400, command);
|
writeBank_SNES(0, 0x2400, command);
|
||||||
__asm__("nop\n\t""nop\n\t""nop\n\t""nop\n\t""nop\n\t""nop\n\t""nop\n\t""nop\n\t");
|
|
||||||
|
|
||||||
// Switch to read
|
// Switch to read
|
||||||
dataIn();
|
dataIn();
|
||||||
controlIn_SNES();
|
controlIn_SNES();
|
||||||
__asm__("nop\n\t""nop\n\t""nop\n\t""nop\n\t""nop\n\t""nop\n\t""nop\n\t""nop\n\t");
|
|
||||||
|
|
||||||
// Read status
|
// Read status
|
||||||
NPReady = readBank_SNES(0, 0x2400);
|
NPReady = readBank_SNES(0, 0x2400);
|
||||||
|
@ -295,13 +295,13 @@ void writeBank_SNES(byte myBank, word myAddress, byte myData) {
|
|||||||
PORTH &= ~(1 << 5);
|
PORTH &= ~(1 << 5);
|
||||||
|
|
||||||
// Leave WR low for at least 60ns
|
// Leave WR low for at least 60ns
|
||||||
__asm__("nop\n\t""nop\n\t""nop\n\t""nop\n\t""nop\n\t""nop\n\t""nop\n\t""nop\n\t");
|
__asm__("nop\n\t""nop\n\t""nop\n\t""nop\n\t""nop\n\t""nop\n\t""nop\n\t""nop\n\t""nop\n\t""nop\n\t""nop\n\t""nop\n\t""nop\n\t""nop\n\t""nop\n\t""nop\n\t");
|
||||||
|
|
||||||
// Switch WR(PH5) to HIGH
|
// Switch WR(PH5) to HIGH
|
||||||
PORTH |= (1 << 5);
|
PORTH |= (1 << 5);
|
||||||
|
|
||||||
// Leave WR high for at least 50ns
|
// Leave WR high for at least 50ns
|
||||||
__asm__("nop\n\t""nop\n\t""nop\n\t""nop\n\t""nop\n\t""nop\n\t""nop\n\t""nop\n\t");
|
__asm__("nop\n\t""nop\n\t""nop\n\t""nop\n\t""nop\n\t""nop\n\t""nop\n\t""nop\n\t""nop\n\t""nop\n\t""nop\n\t""nop\n\t""nop\n\t""nop\n\t""nop\n\t""nop\n\t");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Read one byte of data from a location specified by bank and address, 00:0000
|
// Read one byte of data from a location specified by bank and address, 00:0000
|
||||||
@ -964,8 +964,6 @@ void writeSRAM (boolean browseFile) {
|
|||||||
myFile.read(sdBuffer, 512);
|
myFile.read(sdBuffer, 512);
|
||||||
for (unsigned long c = 0; c < 512; c++) {
|
for (unsigned long c = 0; c < 512; c++) {
|
||||||
writeBank_SNES(0, currByte + c, sdBuffer[c]);
|
writeBank_SNES(0, currByte + c, sdBuffer[c]);
|
||||||
// Wait a little to prevent 1 byte write error
|
|
||||||
__asm__("nop\n\t""nop\n\t""nop\n\t""nop\n\t""nop\n\t""nop\n\t""nop\n\t""nop\n\t");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user