Fixes #40 - Intellicart roms w/o A8

Detects Intellicart roms using a different method for files that don't begin with 0xA8
This commit is contained in:
recompileorg 2020-04-13 05:57:49 -04:00 committed by GitHub
parent 41348d6ec4
commit 8db1146c5d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 59 additions and 27 deletions

View File

@ -16,9 +16,13 @@
*/
#include <stdio.h>
#include <stdlib.h>
#include "memory.h"
#include "cart.h"
#include "osd.h"
int isIntellicart(void);
int loadIntellicart(void);
int isROM(void);
int loadROM(void);
int getLoadMethod(void);
@ -65,33 +69,50 @@ int LoadCart(const char *path)
if (ferror(fp))
{
printf("[ERROR] [FREEINTV] Cartridge load error indicator set\n");
return 0;
}
if(isROM()) // intellicart format
char buffer[8] = {0,0,0,0,0,0,0,0};
itoa(size, buffer, 10);
OSD_drawText(8, 4, "SIZE:");
OSD_drawText(14, 4, buffer);
if(isIntellicart()) // intellicart format
{
OSD_drawText(8, 4, "INTELLICART");
printf("[INFO] [FREEINTV] Intellicart cartridge format detected\n");
return loadROM();
return loadIntellicart();
}
else
{
// check cartinfo database for load method
printf("[INFO] [FREEINTV] Intelllicart format not detected. Determining load method via database.\n");
switch(getLoadMethod())
{
case 0: load0(); break;
case 1: load1(); break;
case 2: load2(); break;
case 3: load3(); break;
case 4: load4(); break;
case 5: load5(); break;
case 6: load6(); break;
case 7: load7(); break;
case 8: load8(); break;
case 9: load9(); break;
default: printf("[INFO] [FREEINTV] No database match. Using default cartridge memory map.\n"); load0();
}
if(isROM())
{
OSD_drawText(8, 4, "INTELLICART");
OSD_drawText(8, 5, "MISSING A8!");
printf("[INFO] [FREEINTV] Possible Intellicart cartridge format detected\n");
return loadROM();
}
else
{
// check cartinfo database for load method
printf("[INFO] [FREEINTV] Raw ROM image. Determining load method via database.\n");
switch(getLoadMethod())
{
case 0: load0(); break;
case 1: load1(); break;
case 2: load2(); break;
case 3: load3(); break;
case 4: load4(); break;
case 5: load5(); break;
case 6: load6(); break;
case 7: load7(); break;
case 8: load8(); break;
case 9: load9(); break;
default: printf("[INFO] [FREEINTV] No database match. Using default cartridge memory map.\n"); load0();
}
}
}
return 1;
return 1; // loaded okay
}
else
{
@ -120,13 +141,19 @@ void loadRange(int start, int stop)
}
// http://spatula-city.org/~im14u2c/intv/jzintv-1.0-beta3/doc/rom_fmt/IntellicartManual.booklet.pdf
int isROM() // check for intellicart format rom
int isIntellicart() // check for intellicart format rom
{
// check magic number (used for intellicart baud rate detection)
return (data[0]==0xA8);
}
int loadROM() // load intellicart format rom
int isROM() // some Intellicart roms don't start with A8 for no apparent reason
{
// the third byte should be the 1's compliment of the second byte
return data[1] == (data[2]^0xFF);
}
int loadIntellicart() // load intellicart format rom
{
int start;
int stop;
@ -149,6 +176,11 @@ int loadROM() // load intellicart format rom
return 1;
}
int loadROM() // load ROM formatted cart
{
return loadIntellicart();
}
// http://atariage.com/forums/topic/203179-config-files-to-use-with-various-intellivision-titles/
void load0() // default - handles majority of carts

View File

@ -33,11 +33,11 @@ void LoadGame(const char* path) // load cart rom //
{
if(LoadCart(path))
{
OSD_drawText(3, 3, "Load Cart: OKAY");
OSD_drawText(3, 3, "LOAD CART: OKAY");
}
else
{
OSD_drawText(3, 3, "Load Cart: FAIL");
OSD_drawText(3, 3, "LOAD CART: FAIL");
}
}
@ -56,12 +56,12 @@ void loadExec(const char* path)
}
fclose(fp);
OSD_drawText(3, 1, "Load EXEC: OKAY");
OSD_drawText(3, 1, "LOAD EXEC: OKAY");
printf("[INFO] [FREEINTV] Succeeded loading Executive BIOS from: %s\n", path);
}
else
{
OSD_drawText(3, 1, "Load EXEC: FAIL");
OSD_drawText(3, 1, "LOAD EXEC: FAIL");
printf("[ERROR] [FREEINTV] Failed loading Executive BIOS from: %s\n", path);
}
}
@ -81,13 +81,13 @@ void loadGrom(const char* path)
}
fclose(fp);
OSD_drawText(3, 2, "Load GROM: OKAY");
OSD_drawText(3, 2, "LOAD GROM: OKAY");
printf("[INFO] [FREEINTV] Succeeded loading Graphics BIOS from: %s\n", path);
}
else
{
OSD_drawText(3, 2, "Load GROM: FAIL");
OSD_drawText(3, 2, "LOAD GROM: FAIL");
printf("[ERROR] [FREEINTV] Failed loading Graphics BIOS from: %s\n", path);
}
}