Skip to content

Commit

Permalink
Fix flashing N64 repro and add progress bar
Browse files Browse the repository at this point in the history
  • Loading branch information
sanni committed Aug 16, 2024
1 parent 34e2ef2 commit edc2b2f
Showing 1 changed file with 41 additions and 6 deletions.
47 changes: 41 additions & 6 deletions Cart_Reader/N64.ino
Original file line number Diff line number Diff line change
Expand Up @@ -545,7 +545,9 @@ 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)
PORTH |= (1 << 5) | (1 << 6);
PORTC |= (1 << 0) | (1 << 1);
PORTC |= (1 << 1);
__asm__("nop\n\t"); // needed for repro
PORTC |= (1 << 0);

// Output high part to address pins
PORTF = myAdrHighOut & 0xFF;
Expand Down Expand Up @@ -3302,13 +3304,11 @@ void flashRepro_N64() {
myFile.close();

// Verify
print_STR(verifying_STR, 0);
print_STR(verifying_STR, 1);
display_Update();
writeErrors = verifyFlashrom_N64();
if (writeErrors == 0) {
println_Msg(FS(FSTRING_OK));
display_Update();
} else {
if (writeErrors != 0) {
display_Clear();
print_Msg(writeErrors);
print_Msg(F(" bytes "));
print_Error(did_not_verify_STR);
Expand Down Expand Up @@ -3753,6 +3753,11 @@ boolean blankcheckFlashrom_N64() {

// Write Intel flashrom
void writeIntel4400_N64() {
//Initialize progress bar
uint32_t processedProgressBar = 0;
uint32_t totalProgressBar = (uint32_t)(fileSize);
draw_progressbar(0, totalProgressBar);

for (unsigned long currSector = 0; currSector < fileSize; currSector += 131072) {
// Blink led
blinkLED();
Expand Down Expand Up @@ -3800,13 +3805,20 @@ void writeIntel4400_N64() {
statusReg = readWord_N64();
}
}
processedProgressBar += 512;
draw_progressbar(processedProgressBar, totalProgressBar);
}
}
}
// Write Fujitsu MSP55LV100S flashrom consisting out of two MSP55LV512 flashroms one used for the high byte the other for the low byte
void writeMSP55LV100_N64(unsigned long sectorSize) {
unsigned long flashBase = romBase;

//Initialize progress bar
uint32_t processedProgressBar = 0;
uint32_t totalProgressBar = (uint32_t)(fileSize);
draw_progressbar(0, totalProgressBar);

for (unsigned long currSector = 0; currSector < fileSize; currSector += sectorSize) {
// Blink led
blinkLED();
Expand Down Expand Up @@ -3856,6 +3868,8 @@ void writeMSP55LV100_N64(unsigned long sectorSize) {
statusReg = readWord_N64();
}
}
processedProgressBar += 512;
draw_progressbar(processedProgressBar, totalProgressBar);
}
}
}
Expand All @@ -3864,6 +3878,11 @@ void writeMSP55LV100_N64(unsigned long sectorSize) {
void writeFlashBuffer_N64(unsigned long sectorSize, byte bufferSize) {
unsigned long flashBase = romBase;

//Initialize progress bar
uint32_t processedProgressBar = 0;
uint32_t totalProgressBar = (uint32_t)(fileSize);
draw_progressbar(0, totalProgressBar);

for (unsigned long currSector = 0; currSector < fileSize; currSector += sectorSize) {
// Blink led
blinkLED();
Expand Down Expand Up @@ -3918,6 +3937,8 @@ void writeFlashBuffer_N64(unsigned long sectorSize, byte bufferSize) {
statusReg = readWord_N64();
}
}
processedProgressBar += 512;
draw_progressbar(processedProgressBar, totalProgressBar);
}
}
}
Expand All @@ -3926,6 +3947,11 @@ void writeFlashBuffer_N64(unsigned long sectorSize, byte bufferSize) {
void writeFlashrom_N64(unsigned long sectorSize) {
unsigned long flashBase = romBase;

//Initialize progress bar
uint32_t processedProgressBar = 0;
uint32_t totalProgressBar = (uint32_t)(fileSize);
draw_progressbar(0, totalProgressBar);

for (unsigned long currSector = 0; currSector < fileSize; currSector += sectorSize) {
// Blink led
blinkLED();
Expand Down Expand Up @@ -3956,6 +3982,8 @@ void writeFlashrom_N64(unsigned long sectorSize) {
statusReg = readWord_N64();
}
}
processedProgressBar += 512;
draw_progressbar(processedProgressBar, totalProgressBar);
}
}
}
Expand All @@ -3965,6 +3993,11 @@ unsigned long verifyFlashrom_N64() {
if (myFile.open(filePath, O_READ)) {
writeErrors = 0;

//Initialize progress bar
uint32_t processedProgressBar = 0;
uint32_t totalProgressBar = (uint32_t)(fileSize);
draw_progressbar(0, totalProgressBar);

for (unsigned long currSector = 0; currSector < fileSize; currSector += 131072) {
// Blink led
blinkLED();
Expand All @@ -3988,6 +4021,8 @@ unsigned long verifyFlashrom_N64() {
}
}
}
processedProgressBar += 512;
draw_progressbar(processedProgressBar, totalProgressBar);
}
}
// Close the file:
Expand Down

0 comments on commit edc2b2f

Please sign in to comment.