Skip to content

Commit

Permalink
[SMS] Fix CRC32 for coleco files smaller than 16K.
Browse files Browse the repository at this point in the history
  • Loading branch information
OtherCrashOverride committed Aug 10, 2018
1 parent b9089a6 commit 46bc0c5
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
9 changes: 5 additions & 4 deletions smsplusgx-go/components/smsplus/loadrom.c
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,6 @@ void set_config()

int load_rom (char *filename)
{

FILE *fd = NULL;

size_t nameLength = strlen(filename);
Expand Down Expand Up @@ -400,10 +399,12 @@ int load_rom (char *filename)
if(!fd) abort();

/* Seek to end of file, and get size */

fseek(fd, 0, SEEK_END);
cart.size = ftell(fd);
size_t actual_size = ftell(fd);
fseek(fd, 0, SEEK_SET);

cart.size = actual_size;
if (cart.size < 0x4000) cart.size = 0x4000;

cart.rom = ESP32_PSRAM;
Expand All @@ -414,7 +415,7 @@ int load_rom (char *filename)
__asm__("nop");
__asm__("nop");
__asm__("memw");

fclose(fd);


Expand All @@ -432,7 +433,7 @@ int load_rom (char *filename)
/* 16k pages */
cart.pages = cart.size / 0x4000;

cart.crc = crc32 (0, cart.rom, cart.size);
cart.crc = crc32(0, cart.rom, option.console == 6 ? actual_size : cart.size);
cart.loaded = 1;

set_config();
Expand Down
2 changes: 1 addition & 1 deletion smsplusgx-go/main/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -684,7 +684,7 @@ void app_main(void)
// 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, *, #
switch (cart.crc)
{
case 0xab021f1a: // Frogger
case 0x798002a2: // Frogger
case 0x9cc3fabc: // Alcazar
if (joystick.values[ODROID_INPUT_START])
{
Expand Down

0 comments on commit 46bc0c5

Please sign in to comment.