mirror of
https://github.com/Pecusx/libretro-atari800.git
synced 2026-05-20 22:33:22 +02:00
autodetect a52 cart type
This commit is contained in:
@@ -1370,7 +1370,10 @@ void CARTRIDGE_ColdStart(void) {
|
||||
ResetCartState(&CARTRIDGE_piggyback);
|
||||
MapActiveCart();
|
||||
}
|
||||
|
||||
#ifdef __LIBRETRO__
|
||||
#include "atari5200_hash.h"
|
||||
extern int autorun5200;
|
||||
#endif
|
||||
/* Loads a cartridge from FILENAME. Copies FILENAME to CART_FILENAME.
|
||||
Allocates a buffer with cartridge image data and puts it in *CART_IMAGE.
|
||||
Sets *CART_TYPE to the cartridge type. */
|
||||
@@ -1380,7 +1383,9 @@ static int InsertCartridge(const char *filename, CARTRIDGE_image_t *cart)
|
||||
int len;
|
||||
int type;
|
||||
UBYTE header[16];
|
||||
|
||||
#ifdef __LIBRETRO__
|
||||
ULONG crc;
|
||||
#endif
|
||||
/* open file */
|
||||
fp = fopen(filename, "rb");
|
||||
if (fp == NULL)
|
||||
@@ -1388,7 +1393,12 @@ static int InsertCartridge(const char *filename, CARTRIDGE_image_t *cart)
|
||||
/* check file length */
|
||||
len = Util_flen(fp);
|
||||
Util_rewind(fp);
|
||||
|
||||
#ifdef __LIBRETRO__
|
||||
if(autorun5200){
|
||||
CRC32_FromFile(fp, &crc);
|
||||
Util_rewind(fp);
|
||||
}
|
||||
#endif
|
||||
/* Guard against providing cart->filename as parameter. */
|
||||
if (cart->filename != filename)
|
||||
/* Save Filename for state save */
|
||||
@@ -1406,6 +1416,41 @@ static int InsertCartridge(const char *filename, CARTRIDGE_image_t *cart)
|
||||
cart->type = CARTRIDGE_NONE;
|
||||
len >>= 10; /* number of kilobytes */
|
||||
cart->size = len;
|
||||
#ifdef __LIBRETRO__
|
||||
if(autorun5200){
|
||||
int match=0,i=0;
|
||||
printf("Hack Libretro:atari800_opt1 ON\n");
|
||||
while(a5200_game[i].type!=-1){
|
||||
if(crc==a5200_game[i].crc){
|
||||
match=1;
|
||||
if(a5200_game[i].type==0)
|
||||
switch(cart->size){
|
||||
case 4096:
|
||||
cart->type =CARTRIDGE_5200_4;
|
||||
break;
|
||||
case 8192:
|
||||
cart->type =CARTRIDGE_5200_8;
|
||||
break;
|
||||
case 16384:
|
||||
cart->type =CARTRIDGE_5200_NS_16;
|
||||
break;
|
||||
case 32768:
|
||||
cart->type =CARTRIDGE_5200_32;
|
||||
break;
|
||||
|
||||
}
|
||||
else if(a5200_game[i].type==1)cart->type =CARTRIDGE_5200_40;
|
||||
else if(a5200_game[i].type==2)cart->type =CARTRIDGE_5200_EE_16;
|
||||
printf("Hack Libretro:A5200 cart->type:%d %x\n",cart->type,crc);
|
||||
break;
|
||||
}
|
||||
|
||||
i++;
|
||||
}
|
||||
|
||||
if(match==1)goto label_fin;
|
||||
}
|
||||
#endif
|
||||
for (type = 1; type <= CARTRIDGE_LAST_SUPPORTED; type++)
|
||||
if (CARTRIDGE_kb[type] == len) {
|
||||
if (cart->type == CARTRIDGE_NONE) {
|
||||
@@ -1416,6 +1461,9 @@ static int InsertCartridge(const char *filename, CARTRIDGE_image_t *cart)
|
||||
return len;
|
||||
}
|
||||
}
|
||||
#ifdef __LIBRETRO__
|
||||
label_fin:
|
||||
#endif
|
||||
if (cart->type != CARTRIDGE_NONE) {
|
||||
InitCartridge(cart);
|
||||
return 0; /* ok */
|
||||
|
||||
@@ -0,0 +1,122 @@
|
||||
#define a5200 0
|
||||
#define a5200_40 1
|
||||
#define a5200_ee_16 2
|
||||
|
||||
typedef struct {
|
||||
int type;
|
||||
char name[50];
|
||||
int size;
|
||||
ULONG crc;
|
||||
} a5200_rom;
|
||||
|
||||
a5200_rom a5200_game[]={
|
||||
|
||||
{ a5200,"5200menu.bin",8192,0x0de2db48},
|
||||
{ a5200,"aep.bin",16384,0x35484751},
|
||||
{ a5200,"decathln.bin",16384,0xf43e7cd0},
|
||||
{ a5200,"asteroid.bin",8192,0x38480891},
|
||||
{ a5200_ee_16,"astrchse.bin",16384,0x4019ecec},
|
||||
{ a5200,"ballblze.bin",32768,0x94d97d14},
|
||||
{ a5200_ee_16,"bzone.bin",16384,0xb3b8e314},
|
||||
{ a5200,"beamrid.bin",16384,0x9bae58dc},
|
||||
{ a5200,"berzerk.bin",16384,0xbe3cd348},
|
||||
{ a5200,"blckbelt.bin",32768,0xed47b0d8},
|
||||
{ a5200,"blaster.bin",16384,0xc8f9c094},
|
||||
{ a5200,"blueprnt.bin",16384,0x0624e6e7},
|
||||
{ a5200_40,"bbstrksb.bin",40960,0x7873c6dd},
|
||||
{ a5200_ee_16,"buckrog.bin",16384,0x04807705},
|
||||
{ a5200_ee_16,"centiped.bin",16384,0x536a70fe},
|
||||
{ a5200,"choplift.bin",16384,0x9ad53bbc},
|
||||
{ a5200_ee_16,"congo.bin",16384,0xf1f42bbd},
|
||||
{ a5200_ee_16,"cntrmsre.bin",16384,0xfd541c80},
|
||||
{ a5200,"pitfall2.bin",16384,0x4b910461},
|
||||
{ a5200_ee_16,"defender.bin",16384,0xbd52623b},
|
||||
{ a5200_ee_16,"digdug.bin",16384,0x6a687f9c},
|
||||
{ a5200,"dredfctr.bin",8192,0x460def2d},
|
||||
{ a5200,"finalleg.bin",16384,0xd3bd3221},
|
||||
{ a5200_ee_16,"friskyt.bin",16384,0x04b299a4},
|
||||
{ a5200,"frogger.bin",8192,0xae7e3444},
|
||||
{ a5200_ee_16,"frogger2.bin",16384,0x0af19345},
|
||||
{ a5200,"galaxian.bin",8192,0x3ef4a23f},
|
||||
{ a5200,"gorf.bin",8192,0xe955db74},
|
||||
{ a5200,"gremlins.bin",32768,0x063ec2c4},
|
||||
{ a5200_ee_16,"gyruss.bin",16384,0xcfd4a7f9},
|
||||
{ a5200,"hero.bin",16384,0x18a73af3},
|
||||
{ a5200_ee_16,"jamesbnd.bin",16384,0xd9ae4518},
|
||||
{ a5200_ee_16,"joust.bin",16384,0xbfd30c01},
|
||||
{ a5200_ee_16,"jrpacman.bin",16384,0x59983c40},
|
||||
{ a5200_ee_16,"jungleh.bin",16384,0x2c676662},
|
||||
{ a5200,"krazysht.bin",8192,0xee702214},
|
||||
{ a5200,"kaboom.bin",4096,0x420f5d0b},
|
||||
{ a5200_ee_16,"kangaroo.bin",16384,0xecfa624f},
|
||||
{ a5200,"keystone.bin",8192,0x8fe3bb2c},
|
||||
{ a5200,"laststar.bin",16384,0x83517703},
|
||||
{ a5200_ee_16,"loontoon.bin",16384,0x84df4925},
|
||||
{ a5200,"mario.bin",32768,0x873742f1},
|
||||
{ a5200,"meebzork.bin",32768,0x9fb13411},
|
||||
{ a5200,"megamnia.bin",8192,0x240a1e1a},
|
||||
{ a5200,"meteorit.bin",16384,0xab8e035b},
|
||||
{ a5200_ee_16,"microgam.bin",16384,0x931a454a},
|
||||
{ a5200,"milliped.bin",16384,0x969cfe1a},
|
||||
{ a5200,"mine2049.bin",16384,0x7df1adfb},
|
||||
{ a5200_ee_16,"minigolf.bin",16384,0xc597c087},
|
||||
{ a5200,"missile.bin",8192,0x44d3ff6f},
|
||||
{ a5200_ee_16,"montezum.bin",16384,0x2a640143},
|
||||
{ a5200,"mpatrol.bin",16384,0xd0b2f285},
|
||||
{ a5200,"mntnking.bin",8192,0x0f24243c},
|
||||
{ a5200,"docastle.bin",8192,0xaa55f9be},
|
||||
{ a5200_ee_16,"mspacman.bin",16384,0x752f5efd},
|
||||
{ a5200_ee_16,"pacman.bin",16384,0x8873ef51},
|
||||
{ a5200,"pengo.bin",32768,0xe4f8ba8c},
|
||||
{ a5200,"pitfall.bin",8192,0xb2887833},
|
||||
{ a5200_ee_16,"polepos.bin",16384,0xabc2d1e4},
|
||||
{ a5200_ee_16,"popeye.bin",16384,0xa18a9a40},
|
||||
{ a5200,"qbert.bin",8192,0x3fe4a401},
|
||||
{ a5200_ee_16,"qix.bin",16384,0xaea6d2c2},
|
||||
{ a5200,"questroo.bin",16384,0xb5f3402b},
|
||||
{ a5200,"rsbsebll.bin",32768,0x44166592},
|
||||
{ a5200,"rsbktbll.bin",32768,0xdd217276},
|
||||
{ a5200,"rsbktbll1.bin",32768,0xc90196fa},
|
||||
{ a5200_ee_16,"rsbktbll2.bin",16384,0x0f996184},
|
||||
{ a5200_ee_16,"rsftball.bin",16384,0x4336c2cc},
|
||||
{ a5200_ee_16,"rssoccer.bin",16384,0xecbd1853},
|
||||
{ a5200_ee_16,"rstennis.bin",16384,0x10f33c90},
|
||||
{ a5200,"fractal.bin",32768,0x762c591b},
|
||||
{ a5200,"riveraid.bin",8192,0x09fc7648},
|
||||
{ a5200_ee_16,"roadrun.bin",16384,0xa97606ab},
|
||||
{ a5200,"robotron.bin",16384,0x4252abd9},
|
||||
{ a5200_ee_16,"spcedngn.bin",16384,0xb68d61e8},
|
||||
{ a5200,"spaceinv.bin",8192,0xde5c354a},
|
||||
{ a5200,"spceshut.bin",16384,0x387365dc},
|
||||
{ a5200,"spitfire.bin",32768,0x3c311303},
|
||||
{ a5200_ee_16,"sprtgoof.bin",16384,0x73b5b6fb},
|
||||
{ a5200_ee_16,"starraid.bin",16384,0x7d819a9f},
|
||||
{ a5200_ee_16,"startrek.bin",16384,0x69f23548},
|
||||
{ a5200,"starwars.bin",8192,0x0675f0a5},
|
||||
{ a5200_ee_16,"swa.bin",16384,0x75f566df},
|
||||
{ a5200_ee_16,"stargate.bin",16384,0x1d1cee27},
|
||||
{ a5200,"sprbreak.bin",4096,0xa0642110},
|
||||
{ a5200,"scobra.bin",8192,0x97debcd2},
|
||||
{ a5200,"spacman.bin",16384,0x0a4ddb1e},
|
||||
{ a5200,"tempest.bin",16384,0x1187342f},
|
||||
{ a5200,"trackfld.bin",16384,0x0ba22ece},
|
||||
{ a5200,"vanguard.bin",32768,0xcaaea0a4},
|
||||
{ a5200,"wow.bin",16384,0xd6f7ddfd},
|
||||
{ a5200_ee_16,"xariarna.bin",16384,0xb8faaec3},
|
||||
{ a5200,"xevious.bin",32768,0x382634dc},
|
||||
{ a5200,"yllowsub.bin",4096,0xf47bc091},
|
||||
{ a5200,"zaxxon.bin",32768,0x741746d1},
|
||||
{ a5200,"zenji.bin",8192,0xda228530},
|
||||
{ a5200,"znerangr.bin",16384,0x2959d827},
|
||||
{ a5200,"petetest.bin",8192,0x28278cd6},
|
||||
{ a5200_ee_16,"pamdiag2.bin",16384,0xe8b130c4},
|
||||
{ a5200_ee_16,"pamdg23.bin",16384,0xce07d9ad},
|
||||
{ a5200,"finaltst.bin",8192,0x7ea86e87},
|
||||
{ a5200,"boogie.bin",4096,0x3bd5fdd6},
|
||||
{ a5200,"cblast.bin",32768,0x7c988054},
|
||||
{ a5200,"ccrisis.bin",32768,0xd50e4061},
|
||||
{ a5200,"koffiyk.bin",32768,0x917be656},
|
||||
{ a5200,"tempest (atariage).bin",32768,0xa6400e17},
|
||||
{ -1,"",0,0},
|
||||
} ;
|
||||
|
||||
@@ -16,7 +16,7 @@ int retroh=300;
|
||||
|
||||
unsigned atari_devices[ 2 ];
|
||||
|
||||
int autorun=0;
|
||||
int autorun5200=0;
|
||||
|
||||
int RETROJOY=0,RETROPT0=0,RETROSTATUS=0,RETRODRVTYPE=0;
|
||||
int retrojoy_init=0,retro_ui_finalized=0;
|
||||
@@ -78,7 +78,7 @@ void retro_set_environment(retro_environment_t cb)
|
||||
|
||||
{
|
||||
"atari800_opt1",
|
||||
"Option 1; disabled|enabled" ,
|
||||
"Autodetect A5200 CartType; disabled|enabled" ,
|
||||
},
|
||||
{
|
||||
"atari800_resolution",
|
||||
@@ -102,7 +102,7 @@ static void update_variables(void)
|
||||
if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value)
|
||||
{
|
||||
if (strcmp(var.value, "enabled") == 0)
|
||||
autorun = 1;
|
||||
autorun5200 = 1;
|
||||
}
|
||||
|
||||
var.key = "atari800_resolution";
|
||||
@@ -438,6 +438,21 @@ lastchar=character;
|
||||
*/
|
||||
}
|
||||
|
||||
int HandleExtension(char *path,char *ext)
|
||||
{
|
||||
int len = strlen(path);
|
||||
|
||||
if (len >= 4 &&
|
||||
path[len-4] == '.' &&
|
||||
path[len-3] == ext[0] &&
|
||||
path[len-2] == ext[1] &&
|
||||
path[len-1] == ext[2])
|
||||
{printf("path (%s)\n",path);
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool retro_load_game(const struct retro_game_info *info)
|
||||
{
|
||||
@@ -455,6 +470,9 @@ bool retro_load_game(const struct retro_game_info *info)
|
||||
|
||||
update_variables();
|
||||
|
||||
if( HandleExtension((char*)RPATH,"a52") || HandleExtension((char*)RPATH,"A52"))
|
||||
autorun5200=1;
|
||||
|
||||
#ifdef RENDER16B
|
||||
memset(Retro_Screen,0,400*300*2);
|
||||
#else
|
||||
|
||||
Reference in New Issue
Block a user