notaz.gp2x.de
/
picodrive.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
more idle detection, minor stuff
[picodrive.git]
/
Pico
/
Area.c
diff --git
a/Pico/Area.c
b/Pico/Area.c
index
1764669
..
49c2afc
100644
(file)
--- a/
Pico/Area.c
+++ b/
Pico/Area.c
@@
-28,6
+28,8
@@
areaeof *areaEof = (areaeof *) 0;
areaseek *areaSeek = (areaseek *) 0;
\r
areaclose *areaClose = (areaclose *) 0;
\r
\r
areaseek *areaSeek = (areaseek *) 0;
\r
areaclose *areaClose = (areaclose *) 0;
\r
\r
+void (*PicoLoadStateHook)(void) = NULL;
\r
+
\r
\r
// Scan one variable and callback
\r
static int ScanVar(void *data,int len,char *name,void *PmovFile,int PmovAction)
\r
\r
// Scan one variable and callback
\r
static int ScanVar(void *data,int len,char *name,void *PmovFile,int PmovAction)
\r
@@
-42,7
+44,7
@@
static int ScanVar(void *data,int len,char *name,void *PmovFile,int PmovAction)
#define SCANP(x) ScanVar(&Pico.x,sizeof(Pico.x),#x,PmovFile,PmovAction);
\r
\r
// Pack the cpu into a common format:
\r
#define SCANP(x) ScanVar(&Pico.x,sizeof(Pico.x),#x,PmovFile,PmovAction);
\r
\r
// Pack the cpu into a common format:
\r
-PICO_INTERNAL
int
PicoAreaPackCpu(unsigned char *cpu, int is_sub)
\r
+PICO_INTERNAL
void
PicoAreaPackCpu(unsigned char *cpu, int is_sub)
\r
{
\r
unsigned int pc=0;
\r
\r
{
\r
unsigned int pc=0;
\r
\r
@@
-75,10
+77,9
@@
PICO_INTERNAL int PicoAreaPackCpu(unsigned char *cpu, int is_sub)
#endif
\r
\r
*(unsigned int *)(cpu+0x40)=pc;
\r
#endif
\r
\r
*(unsigned int *)(cpu+0x40)=pc;
\r
- return 0;
\r
}
\r
\r
}
\r
\r
-PICO_INTERNAL
int
PicoAreaUnpackCpu(unsigned char *cpu, int is_sub)
\r
+PICO_INTERNAL
void
PicoAreaUnpackCpu(unsigned char *cpu, int is_sub)
\r
{
\r
#if defined(EMU_C68K)
\r
struct Cyclone *context = is_sub ? &PicoCpuCS68k : &PicoCpuCM68k;
\r
{
\r
#if defined(EMU_C68K)
\r
struct Cyclone *context = is_sub ? &PicoCpuCS68k : &PicoCpuCM68k;
\r
@@
-111,7
+112,6
@@
PICO_INTERNAL int PicoAreaUnpackCpu(unsigned char *cpu, int is_sub)
context->execinfo &= ~FM68K_HALTED;
\r
if (cpu[0x4d]&1) context->execinfo |= FM68K_HALTED;
\r
#endif
\r
context->execinfo &= ~FM68K_HALTED;
\r
if (cpu[0x4d]&1) context->execinfo |= FM68K_HALTED;
\r
#endif
\r
- return 0;
\r
}
\r
\r
// Scan the contents of the virtual machine's memory for saving or loading
\r
}
\r
\r
// Scan the contents of the virtual machine's memory for saving or loading
\r
@@
-136,7
+136,6
@@
static int PicoAreaScan(int PmovAction,unsigned int ver, void *PmovFile)
\r
// Pack, scan and unpack the cpu data:
\r
if((PmovAction&3)==1) PicoAreaPackCpu(cpu, 0);
\r
\r
// Pack, scan and unpack the cpu data:
\r
if((PmovAction&3)==1) PicoAreaPackCpu(cpu, 0);
\r
- //SekInit(); // notaz: do we really have to do this here?
\r
//PicoMemInit();
\r
SCAN_VAR(cpu,"cpu")
\r
if((PmovAction&3)==2) PicoAreaUnpackCpu(cpu, 0);
\r
//PicoMemInit();
\r
SCAN_VAR(cpu,"cpu")
\r
if((PmovAction&3)==2) PicoAreaUnpackCpu(cpu, 0);
\r
@@
-144,8
+143,7
@@
static int PicoAreaScan(int PmovAction,unsigned int ver, void *PmovFile)
SCAN_VAR(Pico.m ,"misc")
\r
SCAN_VAR(Pico.video,"video")
\r
\r
SCAN_VAR(Pico.m ,"misc")
\r
SCAN_VAR(Pico.video,"video")
\r
\r
- // notaz: save/load z80, YM2612, sn76496 states instead of Pico.s (which is unused anyway)
\r
- if(PicoOpt&7) {
\r
+ if (PicoOpt&7) {
\r
if((PmovAction&3)==1) z80_pack(cpu_z80);
\r
ret = SCAN_VAR(cpu_z80,"cpu_z80")
\r
// do not unpack if we fail to load z80 state
\r
if((PmovAction&3)==1) z80_pack(cpu_z80);
\r
ret = SCAN_VAR(cpu_z80,"cpu_z80")
\r
// do not unpack if we fail to load z80 state
\r
@@
-154,11
+152,12
@@
static int PicoAreaScan(int PmovAction,unsigned int ver, void *PmovFile)
else z80_unpack(cpu_z80);
\r
}
\r
}
\r
else z80_unpack(cpu_z80);
\r
}
\r
}
\r
- if(PicoOpt&3)
\r
+ if
(PicoOpt&3)
\r
ScanVar(sn76496_regs,28*4,"SN76496state", PmovFile, PmovAction); // regs and other stuff
\r
ScanVar(sn76496_regs,28*4,"SN76496state", PmovFile, PmovAction); // regs and other stuff
\r
- if(PicoOpt&1) {
\r
+ if (PicoOpt&1) {
\r
+ if((PmovAction&3)==1) ym2612_pack_state();
\r
ScanVar(ym2612_regs, 0x200+4, "YM2612state", PmovFile, PmovAction); // regs + addr line
\r
ScanVar(ym2612_regs, 0x200+4, "YM2612state", PmovFile, PmovAction); // regs + addr line
\r
- if((PmovAction&3)==2)
YM2612PicoStateLoad
(); // reload YM2612 state from it's regs
\r
+ if((PmovAction&3)==2)
ym2612_unpack_state
(); // reload YM2612 state from it's regs
\r
}
\r
}
\r
\r
}
\r
}
\r
\r
@@
-174,10
+173,14
@@
int PmovState(int PmovAction, void *PmovFile)
int minimum=0;
\r
unsigned char head[32];
\r
\r
int minimum=0;
\r
unsigned char head[32];
\r
\r
- if (
PicoMCD & 1
)
\r
+ if (
(PicoAHW & PAHW_MCD) || carthw_chunks != NULL
)
\r
{
\r
if (PmovAction&1) return PicoCdSaveState(PmovFile);
\r
{
\r
if (PmovAction&1) return PicoCdSaveState(PmovFile);
\r
- if (PmovAction&2) return PicoCdLoadState(PmovFile);
\r
+ if (PmovAction&2) {
\r
+ int ret = PicoCdLoadState(PmovFile);
\r
+ if (PicoLoadStateHook) PicoLoadStateHook();
\r
+ return ret;
\r
+ }
\r
}
\r
\r
memset(head,0,sizeof(head));
\r
}
\r
\r
memset(head,0,sizeof(head));
\r
@@
-197,6
+200,8
@@
int PmovState(int PmovAction, void *PmovFile)
// Scan memory areas:
\r
PicoAreaScan(PmovAction, *(unsigned int *)(head+0x8), PmovFile);
\r
\r
// Scan memory areas:
\r
PicoAreaScan(PmovAction, *(unsigned int *)(head+0x8), PmovFile);
\r
\r
+ if ((PmovAction&2) && PicoLoadStateHook) PicoLoadStateHook();
\r
+
\r
return 0;
\r
}
\r
\r
return 0;
\r
}
\r
\r