Commit 0a4fe2c7 authored by Chips-fr's avatar Chips-fr
Browse files

add whdload support

parent 241461c2
# uae4arm-libretro
Basic port. Based on r-type version. Updated by Chips-fr.
Based on old uae4arm version.
## Controls
......@@ -17,12 +17,14 @@ Basic port. Based on r-type version. Updated by Chips-fr.
Right analog stick controls the mouse.
In mouse emulation dpad and fire buttons controls the mouse.
In mouse emulation mode dpad and fire button controls the mouse.
Two joysticks support. Switch automatically between mouse or second joystick when a mouse or 2nd joystick button is pressed.
L & R button can change DF0: current disk for multiple disk roms. Each disk should be named with "(Disk x of y)"
Automatic support of WHDload slave in .lha file.
Kickstarts supported in options configuration:
|System|Version|Filename|Size|MD5|
......
......@@ -43,35 +43,8 @@ int pre_main(const char *argv)
{
char tmpstr[512];
Add_Option("uaearm");
// Add_Option("-cpctype"); //FIXME:first not taken in account so some padding
// Add_Option("2");
/*
if (strlen(RPATH) >= strlen("crt")){
if(!strcasecmp(&RPATH[strlen(RPATH)-strlen("crt")], "crt"))
Add_Option("-cart");
else if (!strcasecmp(&RPATH[strlen(RPATH)-strlen("cpr")], "cpr"))
Add_Option("-cart");
else if (!strcasecmp(&RPATH[strlen(RPATH)-strlen("cdt")], "cdt"))
Add_Option("-tape");
else if (!strcasecmp(&RPATH[strlen(RPATH)-strlen("wav")], "wav"))
Add_Option("-tape");
else if (!strcasecmp(&RPATH[strlen(RPATH)-strlen("tzx")], "tzx"))
Add_Option("-tape");
else if (!strcasecmp(&RPATH[strlen(RPATH)-strlen("voc")], "voc"))
Add_Option("-tape");
else if (!strcasecmp(&RPATH[strlen(RPATH)-strlen("czw")], "czw"))
Add_Option("-tape");
else if(!strcasecmp(&RPATH[strlen(RPATH)-strlen("sna")], "sna"))
Add_Option("-snapshot");
else if (!strcasecmp(&RPATH[strlen(RPATH)-strlen("drv")], "drv"))
Add_Option("-drivea");
Add_Option("uaearm");
else
Add_Option("-drivea");
}
*/
if (strlen(RPATH) >= strlen("uae")){
if(!strcasecmp(&RPATH[strlen(RPATH)-strlen("uae")], "uae"))
{
......@@ -90,19 +63,18 @@ int pre_main(const char *argv)
sprintf(tmpstr,"hardfile=rw,32,1,2,512,%s\0",RPATH);
Add_Option(tmpstr);
}
else if(!strcasecmp(&RPATH[strlen(RPATH)-strlen("lha")], "lha"))
{
// Will be handled later not through cmdline option...
}
else
{
Add_Option("-s");
sprintf(tmpstr,"floppy0=%s\0",RPATH);
Add_Option(tmpstr);
//Add_Option(RPATH/*ARGUV[0]*/)
}
}
//Add_Option(RPATH/*ARGUV[0]*/);
}
else
{ // Pass all cmdline args
......
......@@ -5,6 +5,8 @@
#endif
#include "libretro-core.h"
#include "libretro/retrodep/WHDLoad_hdf.gz.c"
#include "sysconfig.h"
#include "sysdeps.h"
#include "options.h"
......@@ -12,6 +14,11 @@
#include "uae.h"
#include "zlib.h"
#include "fsdb.h"
#include "filesys.h"
#include "autoconf.h"
cothread_t mainThread;
cothread_t emuThread;
......@@ -147,6 +154,24 @@ void Retro_Kickstart_Replacement_Msg(void)
}
void gz_uncompress(gzFile in, FILE *out)
{
char gzbuf[16384];
int len;
int err;
for (;;)
{
len = gzread(in, gzbuf, sizeof(gzbuf));
if (len < 0)
fprintf(stdout, "%s", gzerror(in, &err));
if (len == 0)
break;
if ((int)fwrite(gzbuf, 1, (unsigned)len, out) != len)
fprintf(stdout, "Write error!\n");
}
}
void update_prefs_retrocfg(struct uae_prefs * prefs)
{
uae_machine[0] = '\0';
......@@ -206,10 +231,19 @@ void update_prefs_retrocfg(struct uae_prefs * prefs)
}
else
{
if (strcasestr(RPATH,".hdf") != NULL)
if ((strcasestr(RPATH,".hdf") != NULL) || (strcasestr(RPATH,".lha") != NULL))
{
LOGI("[libretro-uae4arm]: Auto-model -> A600 selected\n");
var.value = "A600";
if (strcasestr(RPATH,"cd32") != NULL)
{
// Some whdload have cd32 in their name...
LOGI("[libretro-uae4arm]: Auto-model -> A1200 selected\n");
var.value = "A1200";
}
else
{
LOGI("[libretro-uae4arm]: Auto-model -> A600 selected\n");
var.value = "A600";
}
}
else
{
......@@ -218,6 +252,72 @@ void update_prefs_retrocfg(struct uae_prefs * prefs)
}
}
}
// Treat .lha files as whdload slave. A better implementation would use zfile_isdiskimage...
if (strcasestr(RPATH,".lha") != NULL)
{
char whdload_hdf[512] = {0};
path_join((char*)&whdload_hdf, retro_save_directory, "WHDLoad.hdf");
/* Verify WHDLoad.hdf */
if (!my_existsfile(whdload_hdf))
{
LOGI("[libretro-uae4arm]: WHDLoad image file '%s' not found, attempting to create one\n", (const char*)&whdload_hdf);
char whdload_hdf_gz[512];
path_join((char*)&whdload_hdf_gz, retro_save_directory, "WHDLoad.hdf.gz");
FILE *whdload_hdf_gz_fp;
if ((whdload_hdf_gz_fp = fopen(whdload_hdf_gz, "wb")))
{
/* Write GZ */
fwrite(___whdload_WHDLoad_hdf_gz, ___whdload_WHDLoad_hdf_gz_len, 1, whdload_hdf_gz_fp);
fclose(whdload_hdf_gz_fp);
/* Extract GZ */
struct gzFile_s *whdload_hdf_gz_fp;
if ((whdload_hdf_gz_fp = gzopen(whdload_hdf_gz, "r")))
{
FILE *whdload_hdf_fp;
if ((whdload_hdf_fp = fopen(whdload_hdf, "wb")))
{
gz_uncompress(whdload_hdf_gz_fp, whdload_hdf_fp);
fclose(whdload_hdf_fp);
}
gzclose(whdload_hdf_gz_fp);
}
remove(whdload_hdf_gz);
}
else
LOGI("[libretro-uae4arm]: Unable to create WHDLoad image file: '%s'\n", (const char*)&whdload_hdf);
}
/* Attach HDF */
if (my_existsfile(whdload_hdf))
{
//uaedev_config_info ci;
struct uaedev_config_info *uci;
LOGI("[libretro-uae4arm]: Attach HDF\n");
uci = add_filesys_config(prefs, -1, "WHDLoad", 0, whdload_hdf, 0,
32, 1, 2, 512, 0, 0, 0, 0);
if (uci)
hardfile_do_disk_change (uci, 1);
}
/* Attach LHA */
struct uaedev_config_info *uci;
LOGI("[libretro-uae4arm]: Attach LHA\n");
uci = add_filesys_config(prefs, -1, "DH0", "LHA", RPATH,
0, 0, 0, 0, 0, -128, 0, 0, 0);
if (uci)
filesys_media_change (uci->rootdir, 1, uci);
}
if (strcmp(var.value, "A600") == 0)
{
//strcat(uae_machine, A600);
......@@ -245,7 +345,7 @@ void update_prefs_retrocfg(struct uae_prefs * prefs)
//strcpy(prefs->romfile, A1200_ROM);
path_join(prefs->romfile, retro_system_directory, A1200_ROM);
}
else // if (strcmp(var.value, "A500") == 0)
else // if (strcmp(var.value, "A500") == 0)
{
//strcat(uae_machine, A500);
//strcpy(uae_kickstart, A500_ROM);
......
......@@ -349,10 +349,11 @@ int target_cfgfile_load (struct uae_prefs *p, char *filename, int type, int isde
{
int i;
int result = 0;
#if 0
filesys_prepare_reset();
while(p->mountitems > 0)
kill_filesys_unitconfig(p, 0);
#endif
discard_prefs(p, type);
char *ptr = strstr(filename, ".uae");
......
This diff is collapsed.
......@@ -83,8 +83,10 @@ void discard_prefs (struct uae_prefs *p, int type)
}
#ifdef FILESYS
filesys_cleanup ();
#ifndef __LIBRETRO__
p->mountitems = 0;
#endif
#endif
}
static void fixup_prefs_dim2 (struct wh *wh)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment