Merge pull request #530 from lesserkuma/master

Update to displaying full ROM title on SNES, N64, GB, GBA
This commit is contained in:
sanni 2022-09-24 14:39:10 +02:00 committed by GitHub
commit f3153cd135
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 83 additions and 19 deletions

View File

@ -426,6 +426,8 @@ void showCartInfo_GB() {
print_Msg(F("HuC-3")); print_Msg(F("HuC-3"));
else if (romType == 255) else if (romType == 255)
print_Msg(F("HuC-1")); print_Msg(F("HuC-1"));
else if (romType == 0x104)
print_Msg(F("M161"));
println_Msg(F(" ")); println_Msg(F(" "));
print_Msg(F("Rom Size: ")); print_Msg(F("Rom Size: "));
@ -792,19 +794,33 @@ void getCartInfo_GB() {
sprintf(checksumStr, "%02X%02X", eepbit[6], eepbit[7]); sprintf(checksumStr, "%02X%02X", eepbit[6], eepbit[7]);
// Get name // Get name
byte myByte = 0;
byte myLength = 0; byte myLength = 0;
byte x = 0; byte x = 0;
if (sdBuffer[0x143] == 0x80 || sdBuffer[0x143] == 0xC0) { if (sdBuffer[0x143] == 0x80 || sdBuffer[0x143] == 0xC0) {
x++; x++;
} }
for (int addr = 0x0134; addr <= 0x0143-x; addr++) { for (int addr = 0x0134; addr <= 0x0143-x; addr++) {
if (isprint(sdBuffer[addr]) && sdBuffer[addr] != '<' && sdBuffer[addr] != '>' && sdBuffer[addr] != ':' && sdBuffer[addr] != '"' && sdBuffer[addr] != '/' && sdBuffer[addr] != '\\' && sdBuffer[addr] != '|' && sdBuffer[addr] != '?' && sdBuffer[addr] != '*') { myByte = sdBuffer[addr];
romName[myLength] = char(sdBuffer[addr]); if (isprint(myByte) && myByte != '<' && myByte != '>' && myByte != ':' && myByte != '"' && myByte != '/' && myByte != '\\' && myByte != '|' && myByte != '?' && myByte != '*') {
myLength++; romName[myLength] = char(myByte);
} else if (char(sdBuffer[addr]) != 0) { } else {
if (romName[myLength-1] == 0x5F) myLength--;
romName[myLength] = 0x5F; romName[myLength] = 0x5F;
myLength++;
} }
myLength++;
}
// Strip trailing white space
for (unsigned int i = myLength - 1; i > 0; i--) {
if ((romName[i] != 0x5F) && (romName[i] != 0x20)) break;
romName[i] = 0x00;
myLength--;
}
// Detect M161 game
if ((strncmp(romName, "TETRIS SET", 9) == 0) && (sdBuffer[0x14D] == 0x3F)) {
romType = 0x104;
} }
} }
@ -838,21 +854,39 @@ void readROM_GB() {
print_Error(F("Can't create file on SD"), true); print_Error(F("Can't create file on SD"), true);
} }
int endAddress = 0x7FFF;
word romAddress = 0; word romAddress = 0;
word startBank = 1;
//Initialize progress bar //Initialize progress bar
uint32_t processedProgressBar = 0; uint32_t processedProgressBar = 0;
uint32_t totalProgressBar = (uint32_t)(romBanks) * 16384; uint32_t totalProgressBar = (uint32_t)(romBanks) * 16384;
draw_progressbar(0, totalProgressBar); draw_progressbar(0, totalProgressBar);
for (word currBank = 1; currBank < romBanks; currBank++) { // M161 banks are double size and start with 0
if (romType == 0x104) {
startBank = 0;
romBanks >>= 1;
}
for (word currBank = startBank; currBank < romBanks; currBank++) {
// Second bank starts at 0x4000 // Second bank starts at 0x4000
if (currBank > 1) { if (currBank > 1) {
romAddress = 0x4000; romAddress = 0x4000;
} }
// M161 banks are double size and need mapper reset
if (romType == 0x104) {
romAddress = 0;
endAddress = 0x7FFF;
PORTH &= ~(1 << 0);
delay(50);
PORTH |= (1 << 0);
writeByte_GB(0x4000, currBank & 0x7);
}
// Set ROM bank for MBC2/3/4/5 // Set ROM bank for MBC2/3/4/5
if (romType >= 5) { else if (romType >= 5) {
if (romType >= 11 && romType <= 13) { if (romType >= 11 && romType <= 13) {
if ((currBank & 0x1f) == 0) { if ((currBank & 0x1f) == 0) {
// reset MMM01 // reset MMM01
@ -887,7 +921,7 @@ void readROM_GB() {
} }
// Read banks and save to SD // Read banks and save to SD
while (romAddress <= 0x7FFF) { while (romAddress <= endAddress) {
for (int i = 0; i < 512; i++) { for (int i = 0; i < 512; i++) {
sdBuffer[i] = readByte_GB(romAddress + i); sdBuffer[i] = readByte_GB(romAddress + i);
} }

View File

@ -897,13 +897,20 @@ void getCartInfo_GBA() {
myByte = sdBuffer[addr]; myByte = sdBuffer[addr];
if (isprint(myByte) && myByte != '<' && myByte != '>' && myByte != ':' && myByte != '"' && myByte != '/' && myByte != '\\' && myByte != '|' && myByte != '?' && myByte != '*') { if (isprint(myByte) && myByte != '<' && myByte != '>' && myByte != ':' && myByte != '"' && myByte != '/' && myByte != '\\' && myByte != '|' && myByte != '?' && myByte != '*') {
romName[myLength] = char(myByte); romName[myLength] = char(myByte);
myLength++; } else {
} else if (char(sdBuffer[addr]) != 0) { if (romName[myLength-1] == 0x5F) myLength--;
romName[myLength] = 0x5F; romName[myLength] = 0x5F;
myLength++;
} }
myLength++;
} }
// Strip trailing white space
for (unsigned int i = myLength - 1; i > 0; i--) {
if ((romName[i] != 0x5F) && (romName[i] != 0x20)) break;
romName[i] = 0x00;
myLength--;
}
// Get ROM version // Get ROM version
romVersion = sdBuffer[0xBC]; romVersion = sdBuffer[0xBC];

View File

@ -2711,12 +2711,24 @@ void idCart() {
romVersion = sdBuffer[0x3F]; romVersion = sdBuffer[0x3F];
// Get name // Get name
byte myByte = 0;
byte myLength = 0; byte myLength = 0;
for (unsigned int i = 0; i < 20; i++) { for (unsigned int i = 0; i < 20; i++) {
if (((char(sdBuffer[0x20 + i]) >= 48 && char(sdBuffer[0x20 + i]) <= 57) || (char(sdBuffer[0x20 + i]) >= 65 && char(sdBuffer[0x20 + i]) <= 90) || (char(sdBuffer[0x20 + i]) >= 97 && char(sdBuffer[0x20 + i]) <= 122)) && (myLength < 15)) { myByte = sdBuffer[0x20 + i];
romName[myLength] = char(sdBuffer[0x20 + i]); if (isprint(myByte) && myByte != '<' && myByte != '>' && myByte != ':' && myByte != '"' && myByte != '/' && myByte != '\\' && myByte != '|' && myByte != '?' && myByte != '*') {
myLength++; romName[myLength] = char(myByte);
} else {
if (romName[myLength-1] == 0x5F) myLength--;
romName[myLength] = 0x5F;
} }
myLength++;
}
// Strip trailing white space
for (unsigned int i = myLength - 1; i > 0; i--) {
if ((romName[i] != 0x5F) && (romName[i] != 0x20)) break;
romName[i] = 0x00;
myLength--;
} }
// If name consists out of all japanese characters use cart id // If name consists out of all japanese characters use cart id

View File

@ -1009,11 +1009,22 @@ boolean checkcart_SNES() {
byte myLength = 0; byte myLength = 0;
for (unsigned int i = 0xFFC0; i < 0xFFD4; i++) { for (unsigned int i = 0xFFC0; i < 0xFFD4; i++) {
myByte = snesHeader[i - headerStart]; myByte = snesHeader[i - headerStart];
if (((char(myByte) >= 48 && char(myByte) <= 57) || (char(myByte) >= 65 && char(myByte) <= 122)) && myLength < 15) { if (isprint(myByte) && myByte != '<' && myByte != '>' && myByte != ':' && myByte != '"' && myByte != '/' && myByte != '\\' && myByte != '|' && myByte != '?' && myByte != '*') {
romName[myLength] = char(myByte); romName[myLength] = char(myByte);
myLength++; } else {
if (romName[myLength-1] == 0x5F) myLength--;
romName[myLength] = 0x5F;
} }
myLength++;
} }
// Strip trailing white space
for (unsigned int i = myLength - 1; i > 0; i--) {
if ((romName[i] != 0x5F) && (romName[i] != 0x20)) break;
romName[i] = 0x00;
myLength--;
}
// If name consists out of all japanese characters use game code // If name consists out of all japanese characters use game code
if (myLength == 0) { if (myLength == 0) {
// Get rom code // Get rom code
@ -1225,7 +1236,7 @@ unsigned int calc_checksum (char* fileName, char* folder) {
} }
boolean compare_checksum() { boolean compare_checksum() {
print_Msg(F("Chksum...")); print_Msg(F("Checksum..."));
display_Update(); display_Update();
strcpy(fileName, romName); strcpy(fileName, romName);