mirror of
https://github.com/sanni/cartreader.git
synced 2024-11-27 15:04:15 +01:00
V18A: Added delay to SNES write
This commit is contained in:
parent
ee01ff3bfa
commit
5d3e4a3628
@ -3,7 +3,7 @@
|
||||
|
||||
Author: sanni
|
||||
Date: 2016-08-25
|
||||
Version: V18
|
||||
Version: V18A
|
||||
|
||||
SD lib: https://github.com/greiman/SdFat
|
||||
LCD lib: https://github.com/adafruit/Adafruit_SSD1306
|
||||
@ -31,7 +31,7 @@
|
||||
Pickle - SDD1 fix
|
||||
|
||||
**********************************************************************************/
|
||||
char ver[5] = "V18";
|
||||
char ver[5] = "V18A";
|
||||
|
||||
/******************************************
|
||||
Define Output
|
||||
|
@ -117,7 +117,7 @@ void NPGameMenu() {
|
||||
print_Msg(F("Game "));
|
||||
print_Msg(gameSubMenu + 0x81, HEX);
|
||||
println_Msg(F(" Timeout"));
|
||||
println_Msg(readBank_SNES(0, 0x2400));
|
||||
println_Msg(readBank_SNES(0, 0x2400), HEX);
|
||||
println_Msg(F(""));
|
||||
print_Error(F("Please powercycle NP cart"), true);
|
||||
}
|
||||
@ -1321,46 +1321,36 @@ byte send_NP(byte command) {
|
||||
// Switch to write
|
||||
dataOut();
|
||||
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
|
||||
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
|
||||
dataIn();
|
||||
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
|
||||
NPReady = readBank_SNES(0, 0x2400);
|
||||
|
||||
// Switch to write
|
||||
dataOut();
|
||||
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);
|
||||
__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);
|
||||
__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
|
||||
if (NPReady == 0x7D) {
|
||||
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);
|
||||
__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
|
||||
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
|
||||
dataIn();
|
||||
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
|
||||
NPReady = readBank_SNES(0, 0x2400);
|
||||
|
@ -295,13 +295,13 @@ void writeBank_SNES(byte myBank, word myAddress, byte myData) {
|
||||
PORTH &= ~(1 << 5);
|
||||
|
||||
// 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
|
||||
PORTH |= (1 << 5);
|
||||
|
||||
// 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
|
||||
@ -964,8 +964,6 @@ void writeSRAM (boolean browseFile) {
|
||||
myFile.read(sdBuffer, 512);
|
||||
for (unsigned long c = 0; c < 512; 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