aboutsummaryrefslogtreecommitdiffhomepage
path: root/Cart_Reader/GB.ino
diff options
context:
space:
mode:
authorsanni <[email protected]>2022-02-15 12:59:25 +0100
committersanni <[email protected]>2022-02-15 12:59:25 +0100
commit5a59ed155bbd7d8fa53e023b9d14f8118381ce71 (patch)
treee12161c481d13bf4457c97c92015e938c9645dab /Cart_Reader/GB.ino
parent7b92953e0b2ebd8e820bfa3bfde159b0509c28a6 (diff)
downloadcartreader-5a59ed155bbd7d8fa53e023b9d14f8118381ce71.tar.gz
cartreader-5a59ed155bbd7d8fa53e023b9d14f8118381ce71.zip
Use already existing sdBuffer array
Diffstat (limited to 'Cart_Reader/GB.ino')
-rw-r--r--Cart_Reader/GB.ino24
1 files changed, 11 insertions, 13 deletions
diff --git a/Cart_Reader/GB.ino b/Cart_Reader/GB.ino
index e8fe37e..a99766e 100644
--- a/Cart_Reader/GB.ino
+++ b/Cart_Reader/GB.ino
@@ -472,7 +472,7 @@ byte readByte_GB(word myAddress) {
return tempByte;
}
-void writeByte_GB(int myAddress, uint8_t myData) {
+void writeByte_GB(int myAddress, byte myData) {
PORTF = myAddress & 0xFF;
PORTK = (myAddress >> 8) & 0xFF;
PORTC = myData;
@@ -520,7 +520,7 @@ byte readByteSRAM_GB(word myAddress) {
return tempByte;
}
-void writeByteSRAM_GB(int myAddress, uint8_t myData) {
+void writeByteSRAM_GB(int myAddress, byte myData) {
PORTF = myAddress & 0xFF;
PORTK = (myAddress >> 8) & 0xFF;
PORTC = myData;
@@ -809,14 +809,14 @@ void readSRAM_GB() {
writeByte_GB(0x0000, 0x0A);
// Switch SRAM banks
- for (uint8_t bank = 0; bank < sramBanks; bank++) {
+ for (byte currBank = 0; currBank < sramBanks; currBank++) {
dataOut();
- writeByte_GB(0x4000, bank);
+ writeByte_GB(0x4000, currBank);
// Read SRAM
dataIn_GB();
for (word sramAddress = 0xA000; sramAddress <= lastByte; sramAddress += 64) {
- for (uint8_t i = 0; i < 64; i++) {
+ for (byte i = 0; i < 64; i++) {
sdBuffer[i] = readByteSRAM_GB(sramAddress + i);
}
myFile.write(sdBuffer, 64);
@@ -923,9 +923,9 @@ unsigned long verifySRAM_GB() {
writeByte_GB(0x0000, 0x0A);
// Switch SRAM banks
- for (uint8_t bank = 0; bank < sramBanks; bank++) {
+ for (byte currBank = 0; currBank < sramBanks; currBank++) {
dataOut();
- writeByte_GB(0x4000, bank);
+ writeByte_GB(0x4000, currBank);
// Read SRAM
dataIn_GB();
@@ -1095,12 +1095,11 @@ void writeFlash29F_GB(byte MBC) {
dataIn();
for (unsigned int currAddr = 0x4000; currAddr < 0x7FFF; currAddr += 512) {
- uint8_t readData[512];
for (int currByte = 0; currByte < 512; currByte++) {
- readData[currByte] = readByte_GB(currAddr + currByte);
+ sdBuffer[currByte] = readByte_GB(currAddr + currByte);
}
for (int j = 0; j < 512; j++) {
- if (readData[j] != 0xFF) {
+ if (sdBuffer[j] != 0xFF) {
println_Msg(F("Not empty"));
print_Error(F("Erase failed"), true);
}
@@ -1496,12 +1495,11 @@ bool writeCFI_GB() {
dataIn();
for (unsigned int currAddr = 0x4000; currAddr < 0x7FFF; currAddr += 512) {
- uint8_t readData[512];
for (int currByte = 0; currByte < 512; currByte++) {
- readData[currByte] = readByte_GB(currAddr + currByte);
+ sdBuffer[currByte] = readByte_GB(currAddr + currByte);
}
for (int j = 0; j < 512; j++) {
- if (readData[j] != 0xFF) {
+ if (sdBuffer[j] != 0xFF) {
println_Msg(F("Not empty"));
print_Error(F("Erase failed"), true);
}