X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=config_file%2Frominfo.c;h=75b4c6c5e30c8921f0baa955c5321adba2d81c37;hb=5a120a647d9befd58710b38b65a13e06826ff6e8;hp=d264db6c2518114a965653b14448dcd345a5d541;hpb=840e75be868f82a3974371b16aa1d0ca7b90fd44;p=pistorm diff --git a/config_file/rominfo.c b/config_file/rominfo.c index d264db6..75b4c6c 100644 --- a/config_file/rominfo.c +++ b/config_file/rominfo.c @@ -46,12 +46,32 @@ static void getDiagRom(uint8_t *address, struct romInfo *info) info->extra = strtoul(endptr, NULL, 10); } -static void getRomInfo(uint8_t *address, struct romInfo *info) +static void swapRom(uint8_t *address, size_t length) +{ + uint8_t *ptr = address; + for (size_t pos = 0; pos < length; pos = pos + 2) + { + uint8_t low = ptr[pos]; + uint8_t high = ptr[pos+1]; + ptr[pos] = high; + ptr[pos+1] = low; + } +} + +static void getRomInfo(uint8_t *address, size_t length, struct romInfo *info) { uint8_t *ptr = address; uint8_t data = *ptr; info->isDiagRom = false; + if ((ptr[2] == 0xF9) && (ptr[3] == 0x4E)) + { + // ROM byte swapped! + printf("[CFG] Byte swapped ROM found, swapping back\n"); + swapRom(address, length); + data = *ptr; + } + if (data != 0x11) { info->id = ROM_TYPE_UNKNOWN; @@ -94,13 +114,13 @@ static void getRomInfo(uint8_t *address, struct romInfo *info) return; } -void displayRomInfo(uint8_t *address) +void displayRomInfo(uint8_t *address, size_t length) { struct romInfo info = {0}; const char *kversion; const char *size; - getRomInfo(address, &info); + getRomInfo(address, length, &info); if ((!info.isDiagRom) && (info.id != ROM_TYPE_UNKNOWN)) { @@ -172,6 +192,9 @@ void displayRomInfo(uint8_t *address) case 46: kversion = "Kickstart 3.1.4"; break; + case 47: + kversion = "Kickstart 3.2"; + break; default: kversion = "Unknown"; break; @@ -196,7 +219,7 @@ void displayRomInfo(uint8_t *address) } else if (info.id == ROM_TYPE_UNKNOWN) { - printf("[CFG] ROM cannot be identified, if it is a byte swapped Kickstart this will fail\n"); + printf("[CFG] ROM cannot be identified\n"); } else {