mirror of
https://github.com/sanni/cartreader.git
synced 2025-02-02 06:42:38 +01:00
All: Use f.seekCur(x) instead of f.seekSet(f.curPosition() + x)
Saves 450 bytes of program space.
This commit is contained in:
parent
a555f2117f
commit
0a627e5bd4
@ -399,15 +399,15 @@ void setCart_COL() {
|
||||
if (myFile.curPosition() == 0) {
|
||||
break;
|
||||
} else if (myFile.peek() == '\n') {
|
||||
myFile.seekSet(myFile.curPosition() - 1);
|
||||
myFile.seekCur(-1);
|
||||
break;
|
||||
} else {
|
||||
myFile.seekSet(myFile.curPosition() - 1);
|
||||
myFile.seekCur(-1);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (myFile.curPosition() != 0)
|
||||
myFile.seekSet(myFile.curPosition() + 2);
|
||||
myFile.seekCur(2);
|
||||
}
|
||||
|
||||
// Display database
|
||||
@ -425,7 +425,7 @@ void setCart_COL() {
|
||||
}
|
||||
|
||||
// Skip over semicolon
|
||||
myFile.seekSet(myFile.curPosition() + 1);
|
||||
myFile.seekCur(1);
|
||||
|
||||
// Read CRC32 of first 512 bytes
|
||||
sprintf(crc_search, "%c", myFile.read());
|
||||
@ -435,7 +435,7 @@ void setCart_COL() {
|
||||
}
|
||||
|
||||
// Skip over semicolon
|
||||
myFile.seekSet(myFile.curPosition() + 1);
|
||||
myFile.seekCur(1);
|
||||
|
||||
// Read rom size
|
||||
// Read the next ascii character and subtract 48 to convert to decimal
|
||||
@ -449,7 +449,7 @@ void setCart_COL() {
|
||||
}
|
||||
|
||||
// Skip rest of line
|
||||
myFile.seekSet(myFile.curPosition() + 2);
|
||||
myFile.seekCur(2);
|
||||
|
||||
// Skip every 3rd line
|
||||
skip_line(&myFile);
|
||||
@ -490,15 +490,15 @@ void setCart_COL() {
|
||||
if (myFile.curPosition() == 0) {
|
||||
break;
|
||||
} else if (myFile.peek() == '\n') {
|
||||
myFile.seekSet(myFile.curPosition() - 1);
|
||||
myFile.seekCur(-1);
|
||||
break;
|
||||
} else {
|
||||
myFile.seekSet(myFile.curPosition() - 1);
|
||||
myFile.seekCur(-1);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (myFile.curPosition() != 0)
|
||||
myFile.seekSet(myFile.curPosition() + 2);
|
||||
myFile.seekCur(2);
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -655,7 +655,7 @@ boolean compareCRC(const char* database, char* crcString, boolean renamerom, int
|
||||
#ifdef enable_NES
|
||||
if ((mode == mode_NES) && (offset != 0)) {
|
||||
// Rewind to iNES Header
|
||||
myFile.seekSet(myFile.curPosition() - 36);
|
||||
myFile.seekCur(-36);
|
||||
|
||||
char iNES_STR[33];
|
||||
// Read iNES header
|
||||
@ -668,7 +668,7 @@ boolean compareCRC(const char* database, char* crcString, boolean renamerom, int
|
||||
iNES_HEADER[j] = iNES_BUF;
|
||||
}
|
||||
//Skip CRLF
|
||||
myFile.seekSet(myFile.curPosition() + 4);
|
||||
myFile.seekCur(4);
|
||||
}
|
||||
#endif // enable_NES
|
||||
|
||||
|
@ -873,7 +873,7 @@ void getCartInfo_GBA() {
|
||||
skip_line(&myFile);
|
||||
|
||||
// Skip over the CRC checksum
|
||||
myFile.seekSet(myFile.curPosition() + 9);
|
||||
myFile.seekCur(9);
|
||||
|
||||
// Read 4 bytes into String, do it one at a time so byte order doesn't get mixed up
|
||||
sprintf(tempStr, "%c", myFile.read());
|
||||
@ -890,15 +890,15 @@ void getCartInfo_GBA() {
|
||||
if (myFile.curPosition() == 0) {
|
||||
break;
|
||||
} else if (myFile.peek() == '\n') {
|
||||
myFile.seekSet(myFile.curPosition() - 1);
|
||||
myFile.seekCur(-1);
|
||||
break;
|
||||
} else {
|
||||
myFile.seekSet(myFile.curPosition() - 1);
|
||||
myFile.seekCur(-1);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (myFile.curPosition() != 0)
|
||||
myFile.seekSet(myFile.curPosition() + 2);
|
||||
myFile.seekCur(2);
|
||||
|
||||
// Display database
|
||||
while (myFile.available()) {
|
||||
@ -908,7 +908,7 @@ void getCartInfo_GBA() {
|
||||
get_line(gamename, &myFile, 96);
|
||||
|
||||
// Skip over the CRC checksum
|
||||
myFile.seekSet(myFile.curPosition() + 9);
|
||||
myFile.seekCur(9);
|
||||
|
||||
// Read 4 bytes into String, do it one at a time so byte order doesn't get mixed up
|
||||
sprintf(tempStr, "%c", myFile.read());
|
||||
@ -918,7 +918,7 @@ void getCartInfo_GBA() {
|
||||
}
|
||||
|
||||
// Skip the , in the file
|
||||
myFile.seekSet(myFile.curPosition() + 1);
|
||||
myFile.seekCur(1);
|
||||
|
||||
// Read the next ascii character and subtract 48 to convert to decimal
|
||||
cartSize = myFile.read() - 48;
|
||||
@ -930,7 +930,7 @@ void getCartInfo_GBA() {
|
||||
}
|
||||
|
||||
// Skip the , in the file
|
||||
myFile.seekSet(myFile.curPosition() + 1);
|
||||
myFile.seekCur(1);
|
||||
|
||||
// Read save type into string
|
||||
get_line(saveTypeStr, &myFile, 14);
|
||||
@ -980,15 +980,15 @@ void getCartInfo_GBA() {
|
||||
if (myFile.curPosition() == 0) {
|
||||
break;
|
||||
} else if (myFile.peek() == '\n') {
|
||||
myFile.seekSet(myFile.curPosition() - 1);
|
||||
myFile.seekCur(-1);
|
||||
break;
|
||||
} else {
|
||||
myFile.seekSet(myFile.curPosition() - 1);
|
||||
myFile.seekCur(-1);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (myFile.curPosition() != 0)
|
||||
myFile.seekSet(myFile.curPosition() + 2);
|
||||
myFile.seekCur(2);
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -812,15 +812,15 @@ void setCart_INTV() {
|
||||
if (myFile.curPosition() == 0) {
|
||||
break;
|
||||
} else if (myFile.peek() == '\n') {
|
||||
myFile.seekSet(myFile.curPosition() - 1);
|
||||
myFile.seekCur(-1);
|
||||
break;
|
||||
} else {
|
||||
myFile.seekSet(myFile.curPosition() - 1);
|
||||
myFile.seekCur(-1);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (myFile.curPosition() != 0)
|
||||
myFile.seekSet(myFile.curPosition() + 2);
|
||||
myFile.seekCur(2);
|
||||
}
|
||||
|
||||
// Display database
|
||||
@ -838,7 +838,7 @@ void setCart_INTV() {
|
||||
}
|
||||
|
||||
// Skip over semicolon
|
||||
myFile.seekSet(myFile.curPosition() + 1);
|
||||
myFile.seekCur(1);
|
||||
|
||||
// Read CRC32 of first 512 bytes
|
||||
sprintf(crc_search, "%c", myFile.read());
|
||||
@ -848,13 +848,13 @@ void setCart_INTV() {
|
||||
}
|
||||
|
||||
// Skip over semicolon
|
||||
myFile.seekSet(myFile.curPosition() + 1);
|
||||
myFile.seekCur(1);
|
||||
|
||||
// Read mapper
|
||||
intvmapper = myFile.read() - 48;
|
||||
|
||||
// Skip over semicolon
|
||||
myFile.seekSet(myFile.curPosition() + 1);
|
||||
myFile.seekCur(1);
|
||||
|
||||
// Read rom size
|
||||
// Read the next ascii character and subtract 48 to convert to decimal
|
||||
@ -868,13 +868,13 @@ void setCart_INTV() {
|
||||
}
|
||||
|
||||
// Skip over semicolon
|
||||
myFile.seekSet(myFile.curPosition() + 1);
|
||||
myFile.seekCur(1);
|
||||
|
||||
// Read SRAM size
|
||||
byte sramSize __attribute__ ((unused)) = myFile.read() - 48;
|
||||
|
||||
// Skip rest of line
|
||||
myFile.seekSet(myFile.curPosition() + 2);
|
||||
myFile.seekCur(2);
|
||||
|
||||
// Skip every 3rd line
|
||||
skip_line(&myFile);
|
||||
@ -916,15 +916,15 @@ void setCart_INTV() {
|
||||
if (myFile.curPosition() == 0) {
|
||||
break;
|
||||
} else if (myFile.peek() == '\n') {
|
||||
myFile.seekSet(myFile.curPosition() - 1);
|
||||
myFile.seekCur(-1);
|
||||
break;
|
||||
} else {
|
||||
myFile.seekSet(myFile.curPosition() - 1);
|
||||
myFile.seekCur(-1);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (myFile.curPosition() != 0)
|
||||
myFile.seekSet(myFile.curPosition() + 2);
|
||||
myFile.seekCur(2);
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -2051,7 +2051,7 @@ void printCartInfo_N64() {
|
||||
// Check if string is a match
|
||||
if (strcasecmp(tempStr1, crcStr) == 0) {
|
||||
// Skip the , in the file
|
||||
myFile.seekSet(myFile.curPosition() + 1);
|
||||
myFile.seekCur(1);
|
||||
|
||||
// Read 4 bytes into String, do it one at a time so byte order doesn't get mixed up
|
||||
sprintf(tempStr, "%c", myFile.read());
|
||||
@ -2071,7 +2071,7 @@ void printCartInfo_N64() {
|
||||
}
|
||||
// If no match, empty string, advance by 12 and try again
|
||||
else {
|
||||
myFile.seekSet(myFile.curPosition() + 12);
|
||||
myFile.seekCur(12);
|
||||
}
|
||||
}
|
||||
// Close the file:
|
||||
@ -2106,7 +2106,7 @@ void getCartInfo_N64() {
|
||||
skip_line(&myFile);
|
||||
|
||||
// Skip over the CRC32 checksum
|
||||
myFile.seekSet(myFile.curPosition() + 9);
|
||||
myFile.seekCur(9);
|
||||
|
||||
// Read 8 bytes into String, do it one at a time so byte order doesn't get mixed up
|
||||
sprintf(tempStr, "%c", myFile.read());
|
||||
@ -2118,7 +2118,7 @@ void getCartInfo_N64() {
|
||||
// Check if string is a match
|
||||
if (strcmp(tempStr, checksumStr) == 0) {
|
||||
// Skip the , in the file
|
||||
myFile.seekSet(myFile.curPosition() + 1);
|
||||
myFile.seekCur(1);
|
||||
|
||||
// Read the next ascii character and subtract 48 to convert to decimal
|
||||
cartSize = myFile.read() - 48;
|
||||
@ -2130,7 +2130,7 @@ void getCartInfo_N64() {
|
||||
}
|
||||
|
||||
// Skip the , in the file
|
||||
myFile.seekSet(myFile.curPosition() + 1);
|
||||
myFile.seekCur(1);
|
||||
|
||||
// Read the next ascii character and subtract 48 to convert to decimal
|
||||
saveType = myFile.read() - 48;
|
||||
@ -2141,7 +2141,7 @@ void getCartInfo_N64() {
|
||||
// If no match skip to next entry
|
||||
else {
|
||||
// skip rest of line
|
||||
myFile.seekSet(myFile.curPosition() + 7);
|
||||
myFile.seekCur(7);
|
||||
// skip third empty line
|
||||
skip_line(&myFile);
|
||||
}
|
||||
|
@ -559,7 +559,7 @@ boolean getMapping() {
|
||||
}
|
||||
|
||||
// Skip over semicolon
|
||||
myFile.seekSet(myFile.curPosition() + 1);
|
||||
myFile.seekCur(1);
|
||||
|
||||
// Read CRC32 of first 512 bytes
|
||||
sprintf(crc_search, "%c", myFile.read());
|
||||
@ -569,7 +569,7 @@ boolean getMapping() {
|
||||
}
|
||||
|
||||
// Skip over semicolon
|
||||
myFile.seekSet(myFile.curPosition() + 1);
|
||||
myFile.seekCur(1);
|
||||
|
||||
// Read iNES header
|
||||
get_line(iNES_STR, &myFile, 33);
|
||||
@ -586,15 +586,15 @@ boolean getMapping() {
|
||||
if (myFile.curPosition() == 0) {
|
||||
break;
|
||||
} else if (myFile.peek() == '\n') {
|
||||
myFile.seekSet(myFile.curPosition() - 1);
|
||||
myFile.seekCur(-1);
|
||||
break;
|
||||
} else {
|
||||
myFile.seekSet(myFile.curPosition() - 1);
|
||||
myFile.seekCur(-1);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (myFile.curPosition() != 0)
|
||||
myFile.seekSet(myFile.curPosition() + 2);
|
||||
myFile.seekCur(2);
|
||||
|
||||
|
||||
// Display database
|
||||
@ -612,7 +612,7 @@ boolean getMapping() {
|
||||
}
|
||||
|
||||
// Skip over semicolon
|
||||
myFile.seekSet(myFile.curPosition() + 1);
|
||||
myFile.seekCur(1);
|
||||
|
||||
// Read CRC32 of first 512 bytes
|
||||
sprintf(crc_search, "%c", myFile.read());
|
||||
@ -622,7 +622,7 @@ boolean getMapping() {
|
||||
}
|
||||
|
||||
// Skip over semicolon
|
||||
myFile.seekSet(myFile.curPosition() + 1);
|
||||
myFile.seekCur(1);
|
||||
|
||||
// Read iNES header
|
||||
get_line(iNES_STR, &myFile, 33);
|
||||
@ -756,15 +756,15 @@ boolean getMapping() {
|
||||
if (myFile.curPosition() == 0) {
|
||||
break;
|
||||
} else if (myFile.peek() == '\n') {
|
||||
myFile.seekSet(myFile.curPosition() - 1);
|
||||
myFile.seekCur(-1);
|
||||
break;
|
||||
} else {
|
||||
myFile.seekSet(myFile.curPosition() - 1);
|
||||
myFile.seekCur(-1);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (myFile.curPosition() != 0)
|
||||
myFile.seekSet(myFile.curPosition() + 2);
|
||||
myFile.seekCur(2);
|
||||
break;
|
||||
}
|
||||
|
||||
@ -879,15 +879,15 @@ void selectMapping() {
|
||||
if (myFile.curPosition() == 0) {
|
||||
break;
|
||||
} else if (myFile.peek() == '\n') {
|
||||
myFile.seekSet(myFile.curPosition() - 1);
|
||||
myFile.seekCur(-1);
|
||||
break;
|
||||
} else {
|
||||
myFile.seekSet(myFile.curPosition() - 1);
|
||||
myFile.seekCur(-1);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (myFile.curPosition() != 0)
|
||||
myFile.seekSet(myFile.curPosition() + 2);
|
||||
myFile.seekCur(2);
|
||||
}
|
||||
|
||||
// Display database
|
||||
@ -905,7 +905,7 @@ void selectMapping() {
|
||||
}
|
||||
|
||||
// Skip over semicolon
|
||||
myFile.seekSet(myFile.curPosition() + 1);
|
||||
myFile.seekCur(1);
|
||||
|
||||
// Read CRC32 of first 512 bytes
|
||||
sprintf(crc_search, "%c", myFile.read());
|
||||
@ -915,7 +915,7 @@ void selectMapping() {
|
||||
}
|
||||
|
||||
// Skip over semicolon
|
||||
myFile.seekSet(myFile.curPosition() + 1);
|
||||
myFile.seekCur(1);
|
||||
|
||||
// Read iNES header
|
||||
get_line(iNES_STR, &myFile, 33);
|
||||
@ -1040,15 +1040,15 @@ void selectMapping() {
|
||||
if (myFile.curPosition() == 0) {
|
||||
break;
|
||||
} else if (myFile.peek() == '\n') {
|
||||
myFile.seekSet(myFile.curPosition() - 1);
|
||||
myFile.seekCur(-1);
|
||||
break;
|
||||
} else {
|
||||
myFile.seekSet(myFile.curPosition() - 1);
|
||||
myFile.seekCur(-1);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (myFile.curPosition() != 0)
|
||||
myFile.seekSet(myFile.curPosition() + 2);
|
||||
myFile.seekCur(2);
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -847,7 +847,7 @@ void checkAltConf(char crcStr[9]) {
|
||||
skip_line(&myFile);
|
||||
|
||||
// Skip over the CRC checksum
|
||||
myFile.seekSet(myFile.curPosition() + 9);
|
||||
myFile.seekCur(9);
|
||||
|
||||
// Get internal ROM checksum as string
|
||||
for (byte j = 0; j < 4; j++) {
|
||||
@ -862,7 +862,7 @@ void checkAltConf(char crcStr[9]) {
|
||||
display_Update();
|
||||
|
||||
// Skip the , in the file
|
||||
myFile.seekSet(myFile.curPosition() + 1);
|
||||
myFile.seekCur(1);
|
||||
|
||||
// Read the CRC32 of the SNES header out of database
|
||||
for (byte k = 0; k < 8; k++) {
|
||||
@ -871,13 +871,13 @@ void checkAltConf(char crcStr[9]) {
|
||||
tempStr3[8] = '\0';
|
||||
|
||||
// Skip the , in the file
|
||||
myFile.seekSet(myFile.curPosition() + 1);
|
||||
myFile.seekCur(1);
|
||||
|
||||
// Read file size
|
||||
byte romSize2 = (myFile.read() - 48) * 10 + (myFile.read() - 48);
|
||||
|
||||
// Skip the , in the file
|
||||
myFile.seekSet(myFile.curPosition() + 1);
|
||||
myFile.seekCur(1);
|
||||
|
||||
// Read number of banks
|
||||
byte numBanks2 = (myFile.read() - 48) * 100 + (myFile.read() - 48) * 10 + (myFile.read() - 48);
|
||||
@ -911,7 +911,7 @@ void checkAltConf(char crcStr[9]) {
|
||||
// If no match go to next entry
|
||||
else {
|
||||
// skip rest of line
|
||||
myFile.seekSet(myFile.curPosition() + 18);
|
||||
myFile.seekCur(18);
|
||||
// skip third empty line
|
||||
skip_line(&myFile);
|
||||
}
|
||||
|
@ -413,15 +413,15 @@ void setCart_WSV() {
|
||||
if (myFile.curPosition() == 0) {
|
||||
break;
|
||||
} else if (myFile.peek() == '\n') {
|
||||
myFile.seekSet(myFile.curPosition() - 1);
|
||||
myFile.seekCur(-1);
|
||||
break;
|
||||
} else {
|
||||
myFile.seekSet(myFile.curPosition() - 1);
|
||||
myFile.seekCur(-1);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (myFile.curPosition() != 0)
|
||||
myFile.seekSet(myFile.curPosition() + 2);
|
||||
myFile.seekCur(2);
|
||||
}
|
||||
|
||||
// Display database
|
||||
@ -439,7 +439,7 @@ void setCart_WSV() {
|
||||
}
|
||||
|
||||
// Skip over semicolon
|
||||
myFile.seekSet(myFile.curPosition() + 1);
|
||||
myFile.seekCur(1);
|
||||
|
||||
// Read CRC32 of first 512 bytes
|
||||
sprintf(crc_search, "%c", myFile.read());
|
||||
@ -449,7 +449,7 @@ void setCart_WSV() {
|
||||
}
|
||||
|
||||
// Skip over semicolon
|
||||
myFile.seekSet(myFile.curPosition() + 1);
|
||||
myFile.seekCur(1);
|
||||
|
||||
// Read rom size
|
||||
// Read the next ascii character and subtract 48 to convert to decimal
|
||||
@ -463,7 +463,7 @@ void setCart_WSV() {
|
||||
}
|
||||
|
||||
// Skip rest of line
|
||||
myFile.seekSet(myFile.curPosition() + 2);
|
||||
myFile.seekCur(2);
|
||||
|
||||
// Skip every 3rd line
|
||||
skip_line(&myFile);
|
||||
@ -507,15 +507,15 @@ void setCart_WSV() {
|
||||
if (myFile.curPosition() == 0) {
|
||||
break;
|
||||
} else if (myFile.peek() == '\n') {
|
||||
myFile.seekSet(myFile.curPosition() - 1);
|
||||
myFile.seekCur(-1);
|
||||
break;
|
||||
} else {
|
||||
myFile.seekSet(myFile.curPosition() - 1);
|
||||
myFile.seekCur(-1);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (myFile.curPosition() != 0)
|
||||
myFile.seekSet(myFile.curPosition() + 2);
|
||||
myFile.seekCur(2);
|
||||
break;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user