mirror of
https://github.com/sanni/cartreader.git
synced 2024-11-15 01:15:06 +01:00
Change N64 timings
Seems to more reliable read SRAM with some delays removed.
This commit is contained in:
parent
19514f619e
commit
afade35b6c
@ -4,8 +4,8 @@
|
|||||||
This project represents a community-driven effort to provide
|
This project represents a community-driven effort to provide
|
||||||
an easy to build and easy to modify cartridge dumper.
|
an easy to build and easy to modify cartridge dumper.
|
||||||
|
|
||||||
Date: 2024-08-02
|
Date: 2024-08-11
|
||||||
Version: 14.1
|
Version: 14.2
|
||||||
|
|
||||||
SD lib: https://github.com/greiman/SdFat
|
SD lib: https://github.com/greiman/SdFat
|
||||||
LCD lib: https://github.com/olikraus/u8g2
|
LCD lib: https://github.com/olikraus/u8g2
|
||||||
|
@ -536,9 +536,7 @@ void setAddress_N64(unsigned long myAddress) {
|
|||||||
|
|
||||||
// Switch WR(PH5) RD(PH6) ale_L(PC0) ale_H(PC1) to high (since the pins are active low)
|
// Switch WR(PH5) RD(PH6) ale_L(PC0) ale_H(PC1) to high (since the pins are active low)
|
||||||
PORTH |= (1 << 5) | (1 << 6);
|
PORTH |= (1 << 5) | (1 << 6);
|
||||||
PORTC |= (1 << 1);
|
PORTC |= (1 << 0) | (1 << 1);
|
||||||
__asm__("nop\n\t");
|
|
||||||
PORTC |= (1 << 0);
|
|
||||||
|
|
||||||
// Output high part to address pins
|
// Output high part to address pins
|
||||||
PORTF = myAdrHighOut & 0xFF;
|
PORTF = myAdrHighOut & 0xFF;
|
||||||
@ -561,18 +559,6 @@ void setAddress_N64(unsigned long myAddress) {
|
|||||||
// Pull ale_L(PC0) low
|
// Pull ale_L(PC0) low
|
||||||
PORTC &= ~(1 << 0);
|
PORTC &= ~(1 << 0);
|
||||||
|
|
||||||
// Wait ~600ns just to be sure address is set
|
|
||||||
__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");
|
|
||||||
|
|
||||||
// Set data pins to input
|
// Set data pins to input
|
||||||
adIn_N64();
|
adIn_N64();
|
||||||
}
|
}
|
||||||
@ -595,8 +581,6 @@ word readWord_N64() {
|
|||||||
// Pull read(PH6) high
|
// Pull read(PH6) high
|
||||||
PORTH |= (1 << 6);
|
PORTH |= (1 << 6);
|
||||||
|
|
||||||
// Wait 62.5ns
|
|
||||||
__asm__("nop\n\t");
|
|
||||||
return tempWord;
|
return tempWord;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2184,6 +2168,8 @@ void idCart() {
|
|||||||
sdBuffer[c] = hiByte;
|
sdBuffer[c] = hiByte;
|
||||||
sdBuffer[c + 1] = loByte;
|
sdBuffer[c + 1] = loByte;
|
||||||
}
|
}
|
||||||
|
// Pull ale_H(PC1) high
|
||||||
|
PORTC |= (1 << 1);
|
||||||
|
|
||||||
// CRC1
|
// CRC1
|
||||||
sprintf(checksumStr, "%02X%02X%02X%02X", sdBuffer[0x10], sdBuffer[0x11], sdBuffer[0x12], sdBuffer[0x13]);
|
sprintf(checksumStr, "%02X%02X%02X%02X", sdBuffer[0x10], sdBuffer[0x11], sdBuffer[0x12], sdBuffer[0x13]);
|
||||||
@ -2409,6 +2395,7 @@ void writeSram(unsigned long sramSize) {
|
|||||||
|
|
||||||
// Read sram and save to the SD card
|
// Read sram and save to the SD card
|
||||||
void readSram(unsigned long sramSize, byte flashramType) {
|
void readSram(unsigned long sramSize, byte flashramType) {
|
||||||
|
word myWord;
|
||||||
int offset = 512;
|
int offset = 512;
|
||||||
int bufferSize = 512;
|
int bufferSize = 512;
|
||||||
if (flashramType == 2) {
|
if (flashramType == 2) {
|
||||||
@ -2435,23 +2422,17 @@ void readSram(unsigned long sramSize, byte flashramType) {
|
|||||||
setAddress_N64(currByte);
|
setAddress_N64(currByte);
|
||||||
|
|
||||||
for (int c = 0; c < bufferSize; c += 2) {
|
for (int c = 0; c < bufferSize; c += 2) {
|
||||||
// split word
|
// read, split and write word to buffer
|
||||||
word myWord = readWord_N64();
|
myWord = readWord_N64();
|
||||||
byte loByte = myWord & 0xFF;
|
sdBuffer[c] = myWord >> 8;
|
||||||
byte hiByte = myWord >> 8;
|
sdBuffer[c + 1] = myWord & 0xFF;
|
||||||
|
|
||||||
// write to buffer
|
|
||||||
sdBuffer[c] = hiByte;
|
|
||||||
sdBuffer[c + 1] = loByte;
|
|
||||||
}
|
}
|
||||||
|
// Pull ale_H(PC1) high
|
||||||
|
PORTC |= (1 << 1);
|
||||||
myFile.write(sdBuffer, bufferSize);
|
myFile.write(sdBuffer, bufferSize);
|
||||||
}
|
}
|
||||||
// Close the file:
|
// Close the file:
|
||||||
myFile.close();
|
myFile.close();
|
||||||
print_Msg(F("Saved to "));
|
|
||||||
print_Msg(folder);
|
|
||||||
println_Msg(F("/"));
|
|
||||||
display_Update();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned long verifySram(unsigned long sramSize, byte flashramType) {
|
unsigned long verifySram(unsigned long sramSize, byte flashramType) {
|
||||||
@ -2510,6 +2491,8 @@ void sendFramCmd(unsigned long myCommand) {
|
|||||||
// Send command
|
// Send command
|
||||||
writeWord_N64(myComHighOut);
|
writeWord_N64(myComHighOut);
|
||||||
writeWord_N64(myComLowOut);
|
writeWord_N64(myComLowOut);
|
||||||
|
// Pull ale_H(PC1) high
|
||||||
|
PORTC |= (1 << 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Init fram
|
// Init fram
|
||||||
@ -2744,6 +2727,8 @@ byte waitForFram(byte flashramType) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// Pull ale_H(PC1) high
|
||||||
|
PORTC |= (1 << 1);
|
||||||
return framStatus;
|
return framStatus;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2800,10 +2785,15 @@ void getFramType() {
|
|||||||
else {
|
else {
|
||||||
for (byte c = 0; c < 8; c++) {
|
for (byte c = 0; c < 8; c++) {
|
||||||
print_Msg(sdBuffer[c], HEX);
|
print_Msg(sdBuffer[c], HEX);
|
||||||
print_Msg(F(", "));
|
if (c < 7)
|
||||||
|
print_Msg(F(", "));
|
||||||
|
if (c == 7)
|
||||||
|
println_Msg(FS(FSTRING_EMPTY));
|
||||||
}
|
}
|
||||||
print_FatalError(F("Flashram unknown"));
|
print_FatalError(F("Flashram unknown"));
|
||||||
}
|
}
|
||||||
|
// Pull ale_H(PC1) high
|
||||||
|
PORTC |= (1 << 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/******************************************
|
/******************************************
|
||||||
@ -2847,6 +2837,9 @@ void readRom_N64() {
|
|||||||
|
|
||||||
processedProgressBar += 512;
|
processedProgressBar += 512;
|
||||||
draw_progressbar(processedProgressBar, totalProgressBar);
|
draw_progressbar(processedProgressBar, totalProgressBar);
|
||||||
|
|
||||||
|
// Pull ale_H(PC1) high
|
||||||
|
PORTC |= (1 << 1);
|
||||||
}
|
}
|
||||||
// Close the file:
|
// Close the file:
|
||||||
myFile.close();
|
myFile.close();
|
||||||
|
@ -49,7 +49,7 @@
|
|||||||
* String Constants
|
* String Constants
|
||||||
**/
|
**/
|
||||||
// Firmware Version
|
// Firmware Version
|
||||||
constexpr char PROGMEM FSTRING_VERSION[] = "V14.1";
|
constexpr char PROGMEM FSTRING_VERSION[] = "V14.2";
|
||||||
|
|
||||||
// Universal
|
// Universal
|
||||||
constexpr char PROGMEM FSTRING_RESET[] = "Reset";
|
constexpr char PROGMEM FSTRING_RESET[] = "Reset";
|
||||||
|
Loading…
Reference in New Issue
Block a user