mirror of
https://github.com/sanni/cartreader.git
synced 2024-11-13 08:25:05 +01:00
Merge pull request #530 from lesserkuma/master
Update to displaying full ROM title on SNES, N64, GB, GBA
This commit is contained in:
commit
f3153cd135
@ -426,6 +426,8 @@ void showCartInfo_GB() {
|
||||
print_Msg(F("HuC-3"));
|
||||
else if (romType == 255)
|
||||
print_Msg(F("HuC-1"));
|
||||
else if (romType == 0x104)
|
||||
print_Msg(F("M161"));
|
||||
|
||||
println_Msg(F(" "));
|
||||
print_Msg(F("Rom Size: "));
|
||||
@ -792,19 +794,33 @@ void getCartInfo_GB() {
|
||||
sprintf(checksumStr, "%02X%02X", eepbit[6], eepbit[7]);
|
||||
|
||||
// Get name
|
||||
byte myByte = 0;
|
||||
byte myLength = 0;
|
||||
byte x = 0;
|
||||
if (sdBuffer[0x143] == 0x80 || sdBuffer[0x143] == 0xC0) {
|
||||
x++;
|
||||
}
|
||||
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] != '*') {
|
||||
romName[myLength] = char(sdBuffer[addr]);
|
||||
myLength++;
|
||||
} else if (char(sdBuffer[addr]) != 0) {
|
||||
myByte = sdBuffer[addr];
|
||||
if (isprint(myByte) && myByte != '<' && myByte != '>' && myByte != ':' && myByte != '"' && myByte != '/' && myByte != '\\' && myByte != '|' && myByte != '?' && myByte != '*') {
|
||||
romName[myLength] = char(myByte);
|
||||
} else {
|
||||
if (romName[myLength-1] == 0x5F) myLength--;
|
||||
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);
|
||||
}
|
||||
|
||||
int endAddress = 0x7FFF;
|
||||
word romAddress = 0;
|
||||
word startBank = 1;
|
||||
|
||||
//Initialize progress bar
|
||||
uint32_t processedProgressBar = 0;
|
||||
uint32_t totalProgressBar = (uint32_t)(romBanks) * 16384;
|
||||
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
|
||||
if (currBank > 1) {
|
||||
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
|
||||
if (romType >= 5) {
|
||||
else if (romType >= 5) {
|
||||
if (romType >= 11 && romType <= 13) {
|
||||
if ((currBank & 0x1f) == 0) {
|
||||
// reset MMM01
|
||||
@ -887,7 +921,7 @@ void readROM_GB() {
|
||||
}
|
||||
|
||||
// Read banks and save to SD
|
||||
while (romAddress <= 0x7FFF) {
|
||||
while (romAddress <= endAddress) {
|
||||
for (int i = 0; i < 512; i++) {
|
||||
sdBuffer[i] = readByte_GB(romAddress + i);
|
||||
}
|
||||
|
@ -897,13 +897,20 @@ void getCartInfo_GBA() {
|
||||
myByte = sdBuffer[addr];
|
||||
if (isprint(myByte) && myByte != '<' && myByte != '>' && myByte != ':' && myByte != '"' && myByte != '/' && myByte != '\\' && myByte != '|' && myByte != '?' && myByte != '*') {
|
||||
romName[myLength] = char(myByte);
|
||||
myLength++;
|
||||
} else if (char(sdBuffer[addr]) != 0) {
|
||||
} else {
|
||||
if (romName[myLength-1] == 0x5F) myLength--;
|
||||
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
|
||||
romVersion = sdBuffer[0xBC];
|
||||
|
||||
|
@ -2711,12 +2711,24 @@ void idCart() {
|
||||
romVersion = sdBuffer[0x3F];
|
||||
|
||||
// Get name
|
||||
byte myByte = 0;
|
||||
byte myLength = 0;
|
||||
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)) {
|
||||
romName[myLength] = char(sdBuffer[0x20 + i]);
|
||||
myLength++;
|
||||
myByte = sdBuffer[0x20 + i];
|
||||
if (isprint(myByte) && myByte != '<' && myByte != '>' && myByte != ':' && myByte != '"' && myByte != '/' && myByte != '\\' && myByte != '|' && myByte != '?' && myByte != '*') {
|
||||
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
|
||||
|
@ -1009,11 +1009,22 @@ boolean checkcart_SNES() {
|
||||
byte myLength = 0;
|
||||
for (unsigned int i = 0xFFC0; i < 0xFFD4; i++) {
|
||||
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);
|
||||
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 (myLength == 0) {
|
||||
// Get rom code
|
||||
@ -1225,7 +1236,7 @@ unsigned int calc_checksum (char* fileName, char* folder) {
|
||||
}
|
||||
|
||||
boolean compare_checksum() {
|
||||
print_Msg(F("Chksum..."));
|
||||
print_Msg(F("Checksum..."));
|
||||
display_Update();
|
||||
|
||||
strcpy(fileName, romName);
|
||||
|
Loading…
Reference in New Issue
Block a user