mirror of
https://github.com/RaySollium99/picodrive.git
synced 2025-09-05 15:27:46 -04:00
savestate loader in menu
git-svn-id: file:///home/notaz/opt/svn/PicoDrive@56 be3aeb3a-fb24-0410-a615-afba39da0efa
This commit is contained in:
parent
913ef4b7a3
commit
860c6322c3
9 changed files with 344 additions and 79 deletions
|
@ -22,10 +22,11 @@ struct PicoArea { void *data; int len; char *name; };
|
|||
// taking an address of fread or fwrite causes "application could't be started" error
|
||||
// on startup randomly depending on binary layout of executable file.
|
||||
|
||||
arearw *areaRead = (arearw *) 0; // fread; // read and write function pointers for
|
||||
arearw *areaWrite = (arearw *) 0; // fwrite; // gzip save state ability
|
||||
areaeof *areaEof = (areaeof *) 0;
|
||||
areaseek *areaSeek = (areaseek *) 0;
|
||||
arearw *areaRead = (arearw *) 0; // fread; // read and write function pointers for
|
||||
arearw *areaWrite = (arearw *) 0; // fwrite; // gzip save state ability
|
||||
areaeof *areaEof = (areaeof *) 0;
|
||||
areaseek *areaSeek = (areaseek *) 0;
|
||||
areaclose *areaClose = (areaclose *) 0;
|
||||
|
||||
|
||||
// Scan one variable and callback
|
||||
|
|
|
@ -50,12 +50,14 @@ int PicoFrameMCD(void);
|
|||
typedef size_t (arearw)(void *p, size_t _size, size_t _n, void *file);
|
||||
typedef size_t (areaeof)(void *file);
|
||||
typedef int (areaseek)(void *file, long offset, int whence);
|
||||
typedef int (areaclose)(void *file);
|
||||
// Save or load the state from PmovFile:
|
||||
int PmovState(int PmovAction, void *PmovFile); // &1=for reading &2=for writing &4=volatile &8=non-volatile
|
||||
extern arearw *areaRead; // external read and write function pointers for
|
||||
extern arearw *areaWrite; // gzip save state ability
|
||||
extern areaeof *areaEof;
|
||||
extern areaseek *areaSeek;
|
||||
extern areaclose *areaClose;
|
||||
extern void (*PicoStateProgressCB)(const char *str);
|
||||
|
||||
// Cart.c
|
||||
|
|
|
@ -236,6 +236,7 @@ int PicoAreaUnpackCpu(unsigned char *cpu, int is_sub);
|
|||
// cd/Area.c
|
||||
int PicoCdSaveState(void *file);
|
||||
int PicoCdLoadState(void *file);
|
||||
int PicoCdLoadStateGfx(void *file);
|
||||
|
||||
// Draw.c
|
||||
int PicoLine(int scan);
|
||||
|
|
|
@ -250,3 +250,37 @@ int PicoCdLoadState(void *file)
|
|||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int PicoCdLoadStateGfx(void *file)
|
||||
{
|
||||
int ver, len, found = 0;
|
||||
char buff[8];
|
||||
|
||||
g_read_offs = 0;
|
||||
CHECKED_READ(8, buff);
|
||||
if (strncmp(buff, "PicoSMCD", 8)) R_ERROR_RETURN("bad header");
|
||||
CHECKED_READ(4, &ver);
|
||||
|
||||
while (!areaEof(file) && found < 4)
|
||||
{
|
||||
CHECKED_READ(1, buff);
|
||||
CHECKED_READ(4, &len);
|
||||
if (len < 0 || len > 1024*512) R_ERROR_RETURN("bad length");
|
||||
if (buff[0] > CHUNK_FM && !(PicoMCD & 1)) R_ERROR_RETURN("cd chunk in non CD state?");
|
||||
|
||||
switch (buff[0])
|
||||
{
|
||||
case CHUNK_VRAM: CHECKED_READ_BUFF(Pico.vram); found++; break;
|
||||
case CHUNK_CRAM: CHECKED_READ_BUFF(Pico.cram); found++; break;
|
||||
case CHUNK_VSRAM: CHECKED_READ_BUFF(Pico.vsram); found++; break;
|
||||
case CHUNK_VIDEO: CHECKED_READ_BUFF(Pico.video); found++; break;
|
||||
default:
|
||||
areaSeek(file, len, SEEK_CUR);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue