-// (c) Copyright 2006-2007 notaz, All rights reserved.\r
+// (c) Copyright 2006-2009 notaz, All rights reserved.\r
// Free for non-commercial use.\r
\r
// For commercial use, separate licencing terms must be obtained.\r
#include <pico/pico_int.h>\r
#include <pico/patch.h>\r
#include <pico/cd/cue.h>\r
-#include <zlib/zlib.h>\r
\r
\r
#define STATUS_MSG_TIMEOUT 2000\r
emu_status_msg(Pico.m.pal ? "PAL SYSTEM / 50 FPS" : "NTSC SYSTEM / 60 FPS");\r
}\r
\r
+ strncpy(rom_fname_loaded, rom_fname, sizeof(rom_fname_loaded)-1);\r
+ rom_fname_loaded[sizeof(rom_fname_loaded)-1] = 0;\r
+ rom_loaded = 1;\r
+\r
// load SRAM for this ROM\r
if (currentConfig.EmuOpt & EOPT_EN_SRAM)\r
emu_save_load_game(1, 1);\r
\r
- strncpy(rom_fname_loaded, rom_fname, sizeof(rom_fname_loaded)-1);\r
- rom_fname_loaded[sizeof(rom_fname_loaded)-1] = 0;\r
- rom_loaded = 1;\r
return 1;\r
\r
fail2:\r
}\r
}\r
\r
-\r
-static size_t gzRead2(void *p, size_t _size, size_t _n, void *file)\r
-{\r
- return gzread(file, p, _n);\r
-}\r
-\r
-\r
-static size_t gzWrite2(void *p, size_t _size, size_t _n, void *file)\r
-{\r
- return gzwrite(file, p, _n);\r
-}\r
-\r
static int try_ropen_file(const char *fname)\r
{\r
FILE *f;\r
return emu_get_save_fname(1, 0, slot) ? 1 : 0;\r
}\r
\r
-void emu_setSaveStateCbs(int gz)\r
-{\r
- if (gz) {\r
- areaRead = gzRead2;\r
- areaWrite = gzWrite2;\r
- areaEof = (areaeof *) gzeof;\r
- areaSeek = (areaseek *) gzseek;\r
- areaClose = (areaclose *) gzclose;\r
- } else {\r
- areaRead = (arearw *) fread;\r
- areaWrite = (arearw *) fwrite;\r
- areaEof = (areaeof *) feof;\r
- areaSeek = (areaseek *) fseek;\r
- areaClose = (areaclose *) fclose;\r
- }\r
-}\r
-\r
int emu_save_load_game(int load, int sram)\r
{\r
int ret = 0;\r
}\r
else\r
{\r
- void *PmovFile = NULL;\r
- if (strcmp(saveFname + strlen(saveFname) - 3, ".gz") == 0)\r
- {\r
- if( (PmovFile = gzopen(saveFname, load ? "rb" : "wb")) ) {\r
- emu_setSaveStateCbs(1);\r
- if (!load) gzsetparams(PmovFile, 9, Z_DEFAULT_STRATEGY);\r
- }\r
- }\r
- else\r
- {\r
- if( (PmovFile = fopen(saveFname, load ? "rb" : "wb")) ) {\r
- emu_setSaveStateCbs(0);\r
- }\r
- }\r
- if(PmovFile) {\r
- ret = PmovState(load ? 6 : 5, PmovFile);\r
- areaClose(PmovFile);\r
- PmovFile = 0;\r
- if (load) Pico.m.dirtyPal=1;\r
+ ret = PicoState(saveFname, !load);\r
+ if (!ret) {\r
#ifndef NO_SYNC\r
- else sync();\r
+ if (!load) sync();\r
#endif\r
- }\r
- else ret = -1;\r
- if (!ret)\r
emu_status_msg(load ? "STATE LOADED" : "STATE SAVED");\r
- else\r
- {\r
+ } else {\r
emu_status_msg(load ? "LOAD FAILED" : "SAVE FAILED");\r
ret = -1;\r
}\r
\r
#include <pico/pico_int.h>\r
#include <pico/patch.h>\r
-#include <zlib/zlib.h>\r
\r
#define array_size(x) (sizeof(x) / sizeof(x[0]))\r
\r
struct PicoVideo tmp_pv;\r
unsigned short tmp_cram[0x40];\r
unsigned short tmp_vsram[0x40];\r
- void *tmp_vram, *file;\r
+ void *tmp_vram;\r
char *fname;\r
\r
fname = emu_get_save_fname(1, 0, slot);\r
memcpy(tmp_vsram, Pico.vsram, sizeof(Pico.vsram));\r
memcpy(&tmp_pv, &Pico.video, sizeof(Pico.video));\r
\r
- if (strcmp(fname + strlen(fname) - 3, ".gz") == 0) {\r
- file = gzopen(fname, "rb");\r
- emu_setSaveStateCbs(1);\r
- } else {\r
- file = fopen(fname, "rb");\r
- emu_setSaveStateCbs(0);\r
- }\r
-\r
- if (file) {\r
- if (PicoAHW & PAHW_MCD) {\r
- PicoCdLoadStateGfx(file);\r
- } else {\r
- areaSeek(file, 0x10020, SEEK_SET); // skip header and RAM in state file\r
- areaRead(Pico.vram, 1, sizeof(Pico.vram), file);\r
- areaSeek(file, 0x2000, SEEK_CUR);\r
- areaRead(Pico.cram, 1, sizeof(Pico.cram), file);\r
- areaRead(Pico.vsram, 1, sizeof(Pico.vsram), file);\r
- areaSeek(file, 0x221a0, SEEK_SET);\r
- areaRead(&Pico.video, 1, sizeof(Pico.video), file);\r
- }\r
- areaClose(file);\r
- }\r
+ PicoStateLoadVDP(fname);\r
\r
/* do a frame and fetch menu bg */\r
pemu_forced_frame(POPT_EN_SOFTSCALE);\r