Compare commits

...

3 Commits

Author SHA1 Message Date
smesgr9000 990b61ca3a make cast in read function explicit and reduce duplicate read functions 2024-05-03 19:12:48 +02:00
smesgr9000 e8e6d15a72 remove duplicate string literals 2024-05-03 17:12:31 +02:00
smesgr9000 6c05709871 fix compiler warnings 2024-05-03 17:11:55 +02:00
15 changed files with 96 additions and 154 deletions

View File

@ -171,7 +171,7 @@ void readSegment_2600(uint16_t startaddr, uint16_t endaddr) {
}
void readDataArray_2600(uint16_t addr, uint16_t size) {
for (int w = 0; w < size; w++) {
for (uint16_t w = 0; w < size; w++) {
sdBuffer[w] = readData_2600(addr + w);
}
myFile.write(sdBuffer, size);
@ -270,7 +270,6 @@ boolean checkE7(int bank) {
}
void readROM_2600() {
byte e7size;
strcpy(fileName, romName);
strcat(fileName, ".a26");
@ -383,7 +382,6 @@ void readROM_2600() {
readData_2600(0x1FE0 + x);
readSegment_2600(0x1000, 0x1800);
}
e7size = 0;
}
// Check Bank 3 - If 0xFFs then BurgerTime
else if (checkE7(3)) { // BurgerTime 12K
@ -396,7 +394,6 @@ void readROM_2600() {
readData_2600(0x1FE0 + x);
readSegment_2600(0x1000, 0x1800);
}
e7size = 1;
}
else { // Masters of the Universe (or Unknown Cart) 16K
writeData_2600(0x1800, 0xFF);
@ -404,7 +401,6 @@ void readROM_2600() {
readData_2600(0x1FE0 + x);
readSegment_2600(0x1000, 0x1800);
}
e7size = 2;
}
readSegment_2600(0x1800, 0x2000); // Bank 7
break;
@ -653,7 +649,7 @@ void checkStatus_2600() {
//******************************************
#if (defined(ENABLE_OLED) || defined(ENABLE_LCD))
void printMapperSelection_2600(uint8_t index) {
void printMapperSelection_2600(int index) {
display_Clear();
print_Msg(F("Mapper: "));
a2600index = index * 2;
@ -713,9 +709,9 @@ setmapper:
//******************************************
// CART SELECT CODE
//******************************************
void readDataLine_2600(FsFile& database, byte* gameMapper) {
void readDataLine_2600(FsFile& database, void* gameMapper) {
// Read mapper with three ascii character and subtract 48 to convert to decimal
(*gameMapper) = ((database.read() - 48) * 100) + ((database.read() - 48) * 10) + (database.read() - 48);
(*(byte*)gameMapper) = ((database.read() - 48) * 100) + ((database.read() - 48) * 10) + (database.read() - 48);
// Skip rest of line
database.seekCur(2);
@ -726,7 +722,6 @@ void setCart_2600() {
sd.chdir();
byte gameMapper;
byte gameSize;
// Select starting letter
byte myLetter = starting_letter();

View File

@ -508,30 +508,11 @@ setmapper:
//******************************************
// CART SELECT CODE
//******************************************
struct database_entry_5200 {
byte gameMapper;
byte gameSize;
};
void readDataLine_5200(FsFile& database, struct database_entry_5200* entry) {
// Read mapper
entry->gameMapper = database.read() - 48;
// Skip over semicolon
database.seekCur(1);
// Read rom size
entry->gameSize = database.read() - 48;
// Skip rest of line
database.seekCur(2);
}
void setCart_5200() {
//go to root
sd.chdir();
struct database_entry_5200 entry;
struct database_entry_mapper_size entry;
// Select starting letter
byte myLetter = starting_letter();
@ -540,7 +521,7 @@ void setCart_5200() {
if (myFile.open("5200.txt", O_READ)) {
seek_first_letter_in_database(myFile, myLetter);
if(checkCartSelection(myFile, &readDataLine_5200, &entry)) {
if(checkCartSelection(myFile, &readDataLineMapperSize, &entry)) {
EEPROM_writeAnything(7, entry.gameMapper);
EEPROM_writeAnything(8, entry.gameSize);
}

View File

@ -515,8 +515,6 @@ void setROMSize_7800() {
if (a7800lo == a7800hi)
new7800size = a7800lo;
else {
uint8_t b = 0;
display_Clear();
new7800size = navigateMenu(a7800lo, a7800hi, &printRomSize_7800);
@ -666,30 +664,12 @@ setmapper:
//******************************************
// CART SELECT CODE
//******************************************
struct database_entry_7800 {
byte gameMapper;
byte gameSize;
};
void readDataLine_7800(FsFile& database, struct database_entry_7800* entry) {
// Read mapper
entry->gameMapper = database.read() - 48;
// Skip over semicolon
database.seekCur(1);
// Read rom size
entry->gameSize = database.read() - 48;
// Skip rest of line
database.seekCur(2);
}
void setCart_7800() {
//go to root
sd.chdir();
struct database_entry_7800 entry;
struct database_entry_mapper_size entry;
// Select starting letter
byte myLetter = starting_letter();
@ -698,7 +678,7 @@ void setCart_7800() {
if (myFile.open("7800.txt", O_READ)) {
seek_first_letter_in_database(myFile, myLetter);
if(checkCartSelection(myFile, &readDataLine_7800, &entry)) {
if(checkCartSelection(myFile, &readDataLineMapperSize, &entry)) {
EEPROM_writeAnything(7, entry.gameMapper);
EEPROM_writeAnything(8, entry.gameSize);
}

View File

@ -281,14 +281,6 @@ void checkStatus_ARC() {
//******************************************
// CART SELECT CODE
//******************************************
void readDataLine_ARC(FsFile& database, byte* gameSize) {
// Read rom size
(*gameSize) = database.read() - 48;
// Skip rest of line
database.seekCur(2);
}
void setCart_ARC() {
//go to root
sd.chdir();
@ -302,7 +294,7 @@ void setCart_ARC() {
if (myFile.open("arccart.txt", O_READ)) {
// seek_first_letter_in_database(myFile, myLetter);
if(checkCartSelection(myFile, &readDataLine_ARC, &gameSize)) {
if(checkCartSelection(myFile, &readDataLineSingleDigit, &gameSize)) {
EEPROM_writeAnything(8, gameSize);
}
} else {

View File

@ -913,30 +913,12 @@ void printMapper_C64(byte c64maplabel) {
//******************************************
// CART SELECT CODE
//******************************************
struct database_entry_C64 {
byte gameMapper;
byte gameSize;
};
void readDataLine_C64(FsFile& database, struct database_entry_C64* entry) {
// Read mapper with two ascii character and subtract 48 to convert to decimal
entry->gameMapper = ((database.read() - 48) * 10) + (database.read() - 48);
// Skip over semicolon
database.seekCur(1);
// Read size and subtract 48 to convert to decimal
entry->gameSize = database.read() - 48;
// Skip rest of line
database.seekCur(2);
}
void setCart_C64() {
//go to root
sd.chdir();
struct database_entry_C64 entry;
struct database_entry_mapper_size entry;
// Select starting letter
byte myLetter = starting_letter();
@ -945,7 +927,7 @@ void setCart_C64() {
if (myFile.open("c64cart.txt", O_READ)) {
seek_first_letter_in_database(myFile, myLetter);
if(checkCartSelection(myFile, &readDataLine_C64, &entry)) {
if(checkCartSelection(myFile, &readDataLineMapperSize, &entry)) {
EEPROM_writeAnything(7, entry.gameMapper);
EEPROM_writeAnything(8, entry.gameSize);
}

View File

@ -317,7 +317,8 @@ struct database_entry_COL {
byte gameSize;
};
void readDataLine_COL(FsFile& database, struct database_entry_COL* entry) {
void readDataLine_COL(FsFile& database, void* entry) {
struct database_entry_COL* castEntry = (database_entry_COL*)entry;
// Read CRC32 checksum
for (byte i = 0; i < 8; i++) {
@ -329,7 +330,7 @@ void readDataLine_COL(FsFile& database, struct database_entry_COL* entry) {
// Read CRC32 of first 512 bytes
for (byte i = 0; i < 8; i++) {
entry->crc_search[i] = char(database.read());
castEntry->crc_search[i] = char(database.read());
}
// Skip over semicolon
@ -337,15 +338,17 @@ void readDataLine_COL(FsFile& database, struct database_entry_COL* entry) {
// Read rom size
// Read the next ascii character and subtract 48 to convert to decimal
entry->gameSize = ((database.read() - 48) * 10) + (database.read() - 48);
castEntry->gameSize = ((database.read() - 48) * 10) + (database.read() - 48);
// Skip rest of line
database.seekCur(2);
}
void printDataLine_COL(struct database_entry_COL* entry) {
void printDataLine_COL(void* entry) {
struct database_entry_COL* castEntry = (database_entry_COL*)entry;
print_Msg(F("Size: "));
print_Msg(entry->gameSize);
print_Msg(castEntry->gameSize);
println_Msg(F("KB"));
}

View File

@ -681,11 +681,50 @@ void seek_first_letter_in_database(FsFile& database, byte myLetter) {
#endif
}
#if (defined(ENABLE_ARC) || defined(ENABLE_FAIRCHILD) || defined(ENABLE_VECTREX))
// read single digit data line as byte
void readDataLineSingleDigit(FsFile& database, void* byteData) {
// Read rom size
(*(byte*)byteData) = database.read() - 48;
// Skip rest of line
database.seekCur(2);
}
#endif
#if (defined(ENABLE_ODY2) || defined(ENABLE_5200) || defined(ENABLE_7800) || defined(ENABLE_C64))
struct database_entry_mapper_size {
byte gameMapper;
byte gameSize;
};
// read database entry with mapper and size digits
void readDataLineMapperSize(FsFile& database, void* entry) {
struct database_entry_mapper_size* castEntry = (database_entry_mapper_size*)entry;
// Read mapper
castEntry->gameMapper = database.read() - 48;
// if next char is not a semicolon expect an additional digit
char temp = database.read();
if(temp != ',') {
castEntry->gameMapper = (castEntry->gameMapper * 10) + (temp - 48);
// Skip over semicolon
database.seekCur(1);
}
// Read rom size
castEntry->gameSize = database.read() - 48;
// Skip rest of line
database.seekCur(2);
}
#endif
// navigate through the database file using OSSC input buttons. Requires function pointer readData for reading device specific data line from database
// printDataLine - optional callback for printing device specific data informations about the currently browsed game
// setRomName - callback function to set rom name if game is selected
// returns true if a game was selected, false otherwise
boolean checkCartSelection(FsFile& database, void (*readData)(FsFile&, void*), void* data, void (*printDataLine)(void*) = NULL, void (setRomName)(const char* input) = NULL) {
boolean checkCartSelection(FsFile& database, void (*readData)(FsFile&, void*), void* data, void (*printDataLine)(void*) = NULL, void (*setRomName)(const char* input) = NULL) {
char gamename[128];
uint8_t fastScrolling = 1;

View File

@ -622,14 +622,6 @@ void checkStatus_FAIRCHILD() {
//******************************************
// CART SELECT CODE
//******************************************
void readDataLine_FAIRCHILD(FsFile& database, byte* gameSize) {
// Read rom size
(*gameSize) = database.read() - 48;
// Skip rest of line
database.seekCur(2);
}
void setCart_FAIRCHILD() {
//go to root
sd.chdir();
@ -643,7 +635,7 @@ void setCart_FAIRCHILD() {
if (myFile.open("fairchildcart.txt", O_READ)) {
// seek_first_letter_in_database(myFile, myLetter);
if(checkCartSelection(myFile, &readDataLine_ARC, &gameSize)) {
if(checkCartSelection(myFile, &readDataLineSingleDigit, &gameSize)) {
EEPROM_writeAnything(8, gameSize);
}
} else {

View File

@ -641,8 +641,8 @@ struct database_entry_INTV {
byte gameSize;
};
void readDataLine_INTV(FsFile& database, struct database_entry_INTV* entry) {
void readDataLine_INTV(FsFile& database, void* entry) {
struct database_entry_INTV* castEntry = (database_entry_INTV*)entry;
// Read CRC32 checksum
for (byte i = 0; i < 8; i++) {
checksumStr[i] = char(database.read());
@ -653,21 +653,21 @@ void readDataLine_INTV(FsFile& database, struct database_entry_INTV* entry) {
// Read CRC32 of first 512 bytes
for (byte i = 0; i < 8; i++) {
entry->crc_search[i] = char(database.read());
castEntry->crc_search[i] = char(database.read());
}
// Skip over semicolon
database.seekCur(1);
// Read mapper
entry->gameMapper = database.read() - 48;
castEntry->gameMapper = database.read() - 48;
// Skip over semicolon
database.seekCur(1);
// Read rom size
// Read the next ascii character and subtract 48 to convert to decimal
entry->gameSize = ((database.read() - 48) * 10) + (database.read() - 48);
castEntry->gameSize = ((database.read() - 48) * 10) + (database.read() - 48);
// Skip over semicolon
database.seekCur(1);
@ -679,12 +679,13 @@ void readDataLine_INTV(FsFile& database, struct database_entry_INTV* entry) {
database.seekCur(2);
}
void printDataLine_INTV(struct database_entry_INTV* entry) {
void printDataLine_INTV(void* entry) {
struct database_entry_INTV* castEntry = (database_entry_INTV*)entry;
print_Msg(F("Size: "));
print_Msg(entry->gameSize);
print_Msg(castEntry->gameSize);
println_Msg(F("KB"));
print_Msg(F("Mapper: "));
println_Msg(entry->gameMapper);
println_Msg(castEntry->gameMapper);
}
void setCart_INTV() {

View File

@ -1281,21 +1281,22 @@ struct database_entry_MSX {
byte ramSize;
};
void readDataLine_MSX(FsFile& database, struct database_entry_MSX* entry) {
void readDataLine_MSX(FsFile& database, void* entry) {
database_entry_MSX* castEntry = (database_entry_MSX*)entry;
// Read mapper
entry->gameMapper = ((database.read() - 48) * 10) + (database.read() - 48);
castEntry->gameMapper = ((database.read() - 48) * 10) + (database.read() - 48);
// Skip over semicolon
database.seekCur(1);
// Read rom size
entry->gameSize = database.read() - 48;
castEntry->gameSize = database.read() - 48;
// Skip over semicolon
database.seekCur(1);
// Read ram size
entry->ramSize = database.read() - 48;
castEntry->ramSize = database.read() - 48;
// Skip rest of line
database.seekCur(2);

View File

@ -511,12 +511,13 @@ void setRomnameFromString(const char* input) {
}
}
void printDataLine_NES(struct database_entry* entry) {
void printDataLine_NES(void* entry) {
struct database_entry* castEntry = (struct database_entry*) entry;
uint8_t iNES[16];
uint8_t* output;
char* input;
input = entry->iNES_str;
input = castEntry->iNES_str;
output = iNES;
for (uint8_t i = 0; i < sizeof(iNES); i++) {
unsigned int buf;
@ -670,7 +671,8 @@ static void readDatabaseEntry(FsFile& database, struct database_entry* entry) {
skip_line(&database);
}
void readDataLine_NES(FsFile& database, struct database_entry* entry) {
void readDataLine_NES(FsFile& database, void* e) {
struct database_entry* entry = (database_entry*)e;
get_line(entry->crc_str, &database, sizeof(entry->crc_str));
entry->crc_str[8] = 0;

View File

@ -369,30 +369,11 @@ void checkStatus_ODY2() {
//******************************************
// CART SELECT CODE
//******************************************
struct database_entry_ODY2 {
byte gameMapper;
byte gameSize;
};
void readDataLine_ODY2(FsFile& database, struct database_entry_ODY2* entry) {
// Read mapper
entry->gameMapper = database.read() - 48;
// Skip over semicolon
database.seekCur(1);
// Read rom size
entry->gameSize = database.read() - 48;
// Skip rest of line
database.seekCur(2);
}
void setCart_ODY2() {
//go to root
sd.chdir();
struct database_entry_ODY2 entry;
struct database_entry_mapper_size entry;
// Select starting letter
byte myLetter = starting_letter();
@ -401,7 +382,7 @@ void setCart_ODY2() {
if (myFile.open("ody2cart.txt", O_READ)) {
seek_first_letter_in_database(myFile, myLetter);
if(checkCartSelection(myFile, &readDataLine_ODY2, &entry)) {
if(checkCartSelection(myFile, &readDataLineMapperSize, &entry)) {
EEPROM_writeAnything(7, entry.gameMapper);
EEPROM_writeAnything(8, entry.gameSize);
}

View File

@ -100,20 +100,20 @@ void smsOperations() {
if (system_sms) {
if (adapter_raphnet) {
SMSOperation = question_box(F("SMS/MarkIII raphnet"), menuOptions, 4, 0);
SMSOperation = question_box(FS(SMSAdapterItem1), menuOptions, 4, 0);
} else if (adapter_retrode) {
SMSOperation = question_box(F("SMS Retrode"), menuOptions, 4, 0);
SMSOperation = question_box(FS(SMSAdapterItem2), menuOptions, 4, 0);
} else if (adapter_retron) {
SMSOperation = question_box(F("SMS Retron 3in1"), menuOptions, 4, 0);
SMSOperation = question_box(FS(SMSAdapterItem3), menuOptions, 4, 0);
}
} else if (system_gg) {
if (adapter_retrode) {
SMSOperation = question_box(F("GameGear Retrode"), menuOptions, 4, 0);
SMSOperation = question_box(FS(SMSAdapterItem4), menuOptions, 4, 0);
} else if (adapter_retron) {
SMSOperation = question_box(F("GameGear Retron 3in1"), menuOptions, 4, 0);
SMSOperation = question_box(FS(SMSAdapterItem5), menuOptions, 4, 0);
}
} else if (system_sg1000) {
SMSOperation = question_box(F("SG-1000 raphnet"), menuOptions, 1, 0);
SMSOperation = question_box(FS(SMSAdapterItem6), menuOptions, 1, 0);
}
switch (SMSOperation) {

View File

@ -340,14 +340,6 @@ void checkStatus_VECTREX() {
//******************************************
// CART SELECT CODE
//******************************************
void readDataLine_VECTREX(FsFile& database, byte* gameSize) {
// Read rom size
(*gameSize) = database.read() - 48;
// Skip rest of line
database.seekCur(2);
}
void setCart_VECTREX() {
//go to root
sd.chdir();
@ -361,7 +353,7 @@ void setCart_VECTREX() {
if (myFile.open("vectrexcart.txt", O_READ)) {
// seek_first_letter_in_database(myFile, myLetter);
if(checkCartSelection(myFile, &readDataLine_ARC, &gameSize)) {
if(checkCartSelection(myFile, &readDataLineSingleDigit, &gameSize)) {
EEPROM_writeAnything(8, gameSize);
}
} else {

View File

@ -330,8 +330,8 @@ struct database_entry_WSV {
byte gameSize;
};
void readDataLine_WSV(FsFile& database, struct database_entry_WSV* entry) {
void readDataLine_WSV(FsFile& database, void* entry) {
struct database_entry_WSV* castEntry = (database_entry_WSV*)entry;
// Read CRC32 checksum
for (byte i = 0; i < 8; i++) {
checksumStr[i] = char(database.read());
@ -342,7 +342,7 @@ void readDataLine_WSV(FsFile& database, struct database_entry_WSV* entry) {
// Read CRC32 of first 512 bytes
for (byte i = 0; i < 8; i++) {
entry->crc_search[i] = char(database.read());
castEntry->crc_search[i] = char(database.read());
}
// Skip over semicolon
@ -350,18 +350,19 @@ void readDataLine_WSV(FsFile& database, struct database_entry_WSV* entry) {
// Read rom size
// Read the next ascii character and subtract 48 to convert to decimal
entry->gameSize = ((database.read() - 48) * 10) + (database.read() - 48);
castEntry->gameSize = ((database.read() - 48) * 10) + (database.read() - 48);
// Skip rest of line
database.seekCur(2);
}
void printDataLine_WSV(struct database_entry_WSV* entry) {
void printDataLine_WSV(void* entry) {
struct database_entry_WSV* castEntry = (database_entry_WSV*)entry;
print_Msg(F("Size: "));
if (entry->gameSize == 51)
if (castEntry->gameSize == 51)
print_Msg(F("512"));
else
print_Msg(entry->gameSize);
print_Msg(castEntry->gameSize);
println_Msg(F("KB"));
}