mirror of
https://github.com/notaz/pcsx_rearmed.git
synced 2026-10-12 02:20:06 +00:00
make it possible to save main exe
convenience tool
This commit is contained in:
+2
-2
@@ -2176,7 +2176,7 @@ bool retro_load_game(const struct retro_game_info *info)
|
||||
if (is_exe)
|
||||
ret = Load(info->path);
|
||||
else
|
||||
ret = LoadCdrom();
|
||||
ret = LoadCdromMainExe(NULL);
|
||||
if (ret != 0)
|
||||
{
|
||||
LogErr("could not load %s (%d)\n", is_exe ? "exe" : "CD", ret);
|
||||
@@ -3499,7 +3499,7 @@ void retro_run(void)
|
||||
if (CheckResetManualExe())
|
||||
;
|
||||
else if (Config.HLE)
|
||||
LoadCdrom();
|
||||
LoadCdromMainExe(NULL);
|
||||
}
|
||||
|
||||
set_vout_fb();
|
||||
|
||||
+7
-1
@@ -588,6 +588,7 @@ int main(int argc, char *argv[])
|
||||
char isofilename[MAXPATHLEN];
|
||||
const char *cdfile = NULL;
|
||||
const char *loadst_f = NULL;
|
||||
const char *save_exe_f = NULL;
|
||||
int psxout = 0;
|
||||
int psxin = 0;
|
||||
int nothread = 0;
|
||||
@@ -635,6 +636,10 @@ int main(int argc, char *argv[])
|
||||
if (i+1 >= argc) break;
|
||||
loadst_f = argv[++i];
|
||||
}
|
||||
else if (!strcmp(argv[i], "-exesave")) {
|
||||
if (i+1 >= argc) break;
|
||||
save_exe_f = argv[++i];
|
||||
}
|
||||
else if (!strcmp(argv[i], "-h") ||
|
||||
!strcmp(argv[i], "-help") ||
|
||||
!strcmp(argv[i], "--help")) {
|
||||
@@ -650,6 +655,7 @@ int main(int argc, char *argv[])
|
||||
"\t-nothread\tDon't use any threads\n"
|
||||
"\t-load STATENUM\tLoads savestate STATENUM (1-9)\n"
|
||||
"\t-loadf FILE\tLoads savestate from FILE\n"
|
||||
"\t-exesave FILE\tWrite main game exe fo FILE\n"
|
||||
"\t-h,-help\tDisplay this message\n"
|
||||
"\tfile\t\tLoads a PSX EXE file\n"));
|
||||
return 0;
|
||||
@@ -720,7 +726,7 @@ int main(int argc, char *argv[])
|
||||
ready_to_go = 1;
|
||||
} else {
|
||||
if (cdfile)
|
||||
ready_to_go = menu_load_cd_image(cdfile) == 0;
|
||||
ready_to_go = menu_load_cd_image(cdfile, save_exe_f) == 0;
|
||||
}
|
||||
|
||||
if (loadst_f) {
|
||||
|
||||
+7
-7
@@ -2164,7 +2164,7 @@ static int reset_game(void)
|
||||
if (CheckResetManualExe())
|
||||
return 0;
|
||||
if (Config.HLE) {
|
||||
if (LoadCdrom() == -1)
|
||||
if (LoadCdromMainExe(NULL) == -1)
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
@@ -2237,7 +2237,7 @@ static int run_exe(void)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int run_cd_image(const char *fname)
|
||||
static int run_cd_image(const char *fname, const char *exe_save_path)
|
||||
{
|
||||
int autoload_state = g_autostateld_opt;
|
||||
size_t fname_len = strlen(fname);
|
||||
@@ -2271,7 +2271,7 @@ static int run_cd_image(const char *fname)
|
||||
SysReset();
|
||||
|
||||
// Read main executable directly from CDRom and start it
|
||||
if (LoadCdrom() == -1) {
|
||||
if (LoadCdromMainExe(exe_save_path) == -1) {
|
||||
ClosePlugins();
|
||||
menu_update_msg("failed to load CD image");
|
||||
return -1;
|
||||
@@ -2305,11 +2305,11 @@ static int run_cd_image(const char *fname)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int menu_load_cd_image(const char *fname)
|
||||
int menu_load_cd_image(const char *fname, const char *exe_save_path)
|
||||
{
|
||||
int prev_gpu, prev_spu;
|
||||
|
||||
if (run_cd_image(fname) != 0)
|
||||
if (run_cd_image(fname, exe_save_path) != 0)
|
||||
return -1;
|
||||
|
||||
prev_gpu = gpu_plugsel;
|
||||
@@ -2321,7 +2321,7 @@ int menu_load_cd_image(const char *fname)
|
||||
// loading if game config changed plugins to reload them
|
||||
if (prev_gpu != gpu_plugsel || prev_spu != spu_plugsel) {
|
||||
printf("plugin change detected, reloading plugins...\n");
|
||||
if (run_cd_image(fname) != 0)
|
||||
if (run_cd_image(fname, NULL) != 0)
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -2344,7 +2344,7 @@ static int romsel_run(void)
|
||||
|
||||
ndrc_clear_full();
|
||||
|
||||
return menu_load_cd_image(fname);
|
||||
return menu_load_cd_image(fname, NULL);
|
||||
}
|
||||
|
||||
static int swap_cd_image(void)
|
||||
|
||||
+1
-1
@@ -7,7 +7,7 @@ void menu_loop(void);
|
||||
void menu_finish(void);
|
||||
|
||||
void menu_notify_mode_change(int w, int h, int bpp);
|
||||
int menu_load_cd_image(const char *fname);
|
||||
int menu_load_cd_image(const char *fname, const char *exe_save_path);
|
||||
int menu_load_config(int is_game);
|
||||
|
||||
enum g_opts_opts {
|
||||
|
||||
+1
-1
@@ -367,7 +367,7 @@ void DebugVSync() {
|
||||
CheckCdrom();
|
||||
SysReset();
|
||||
if (reset == 2)
|
||||
LoadCdrom();
|
||||
LoadCdromMainExe(NULL);
|
||||
reset = resetting = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
+15
-2
@@ -217,12 +217,13 @@ static void getFromCnf(char *buf, const char *key, u32 *val)
|
||||
}
|
||||
}
|
||||
|
||||
int LoadCdrom() {
|
||||
int LoadCdromMainExe(const char *exe_save_path) {
|
||||
union {
|
||||
EXE_HEADER h;
|
||||
u32 d[sizeof(EXE_HEADER) / sizeof(u32)];
|
||||
} tmpHead;
|
||||
struct iso_directory_record *dir;
|
||||
FILE *save_file = NULL;
|
||||
u8 time[4], *buf;
|
||||
u8 mdir[4096];
|
||||
char exename[256];
|
||||
@@ -236,7 +237,7 @@ int LoadCdrom() {
|
||||
|
||||
save_counter = 0;
|
||||
|
||||
if (!Config.HLE) {
|
||||
if (!Config.HLE && !exe_save_path) {
|
||||
if (psxRegs.pc != 0x80030000) // BiosBootBypass'ed or custom BIOS?
|
||||
return 0;
|
||||
if (Config.SlowBoot)
|
||||
@@ -296,6 +297,13 @@ int LoadCdrom() {
|
||||
READTRACK();
|
||||
}
|
||||
|
||||
if (exe_save_path)
|
||||
save_file = fopen(exe_save_path, "wb");
|
||||
if (save_file)
|
||||
fwrite(buf + 12, 1, 2048, save_file);
|
||||
else if (exe_save_path)
|
||||
SysPrintf("could not open '%s', exe not saved\n", exe_save_path);
|
||||
|
||||
memcpy(&tmpHead, buf + 12, sizeof(EXE_HEADER));
|
||||
for (i = 2; i < sizeof(tmpHead.d) / sizeof(tmpHead.d[0]); i++)
|
||||
tmpHead.d[i] = SWAP32(tmpHead.d[i]);
|
||||
@@ -317,6 +325,9 @@ int LoadCdrom() {
|
||||
|
||||
t_addr += 2048;
|
||||
t_size -= 2048;
|
||||
|
||||
if (save_file)
|
||||
fwrite(buf + 12, 1, 2048, save_file);
|
||||
}
|
||||
|
||||
psxCpu->Clear(tmpHead.h.t_addr, tmpHead.h.t_size / 4);
|
||||
@@ -326,6 +337,8 @@ int LoadCdrom() {
|
||||
|
||||
if (Config.HLE)
|
||||
psxBiosCheckExe(tmpHead.h.t_addr, tmpHead.h.t_size, 0);
|
||||
if (save_file)
|
||||
fclose(save_file);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
+1
-1
@@ -59,7 +59,7 @@ extern int CdromFrontendId; // for frontend use
|
||||
|
||||
int BiosBootBypass();
|
||||
|
||||
int LoadCdrom();
|
||||
int LoadCdromMainExe(const char *exe_save_path);
|
||||
int LoadCdromFile(const char *filename, int full, EXE_HEADER *head, u8 *time_bcd_out);
|
||||
int CheckCdrom();
|
||||
int CheckResetManualExe();
|
||||
|
||||
@@ -4723,7 +4723,7 @@ static void hleC0t() {
|
||||
// currently not used
|
||||
static void hleBootstrap() {
|
||||
CheckCdrom();
|
||||
LoadCdrom();
|
||||
LoadCdromMainExe(NULL);
|
||||
}
|
||||
|
||||
static void hleExecRet() {
|
||||
|
||||
+1
-1
@@ -353,7 +353,7 @@ int main(int argc, char **argv)
|
||||
ready_to_go = 1;
|
||||
} else {
|
||||
if (cdfile) {
|
||||
if (LoadCdrom() == -1) {
|
||||
if (LoadCdromMainExe(NULL) == -1) {
|
||||
ClosePlugins();
|
||||
printf(_("Could not load CD-ROM!\n"));
|
||||
return -1;
|
||||
|
||||
Reference in New Issue
Block a user