X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=Pico%2FArea.c;h=35f28c284860fd9d725f0881f06ae45479793c5c;hb=6a13ef3f56a80ac698d463f5d00235ea2a090f52;hp=0ec25ecc49b85415e2ec0ee3e4b0968ef84a7fa1;hpb=fad248933b6676d30ccf419858b4ee10cc123fc5;p=picodrive.git diff --git a/Pico/Area.c b/Pico/Area.c index 0ec25ec..35f28c2 100644 --- a/Pico/Area.c +++ b/Pico/Area.c @@ -44,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); // Pack the cpu into a common format: -PICO_INTERNAL int PicoAreaPackCpu(unsigned char *cpu, int is_sub) +PICO_INTERNAL void PicoAreaPackCpu(unsigned char *cpu, int is_sub) { unsigned int pc=0; @@ -62,7 +62,7 @@ PICO_INTERNAL int PicoAreaPackCpu(unsigned char *cpu, int is_sub) memcpy(cpu,m68ki_cpu_p->dar,0x40); pc=m68ki_cpu_p->pc; *(unsigned int *)(cpu+0x44)=m68k_get_reg(NULL, M68K_REG_SR); - *(unsigned int *)(cpu+0x48)=m68ki_cpu_p->sp[0]; + *(unsigned int *)(cpu+0x48)=m68ki_cpu_p->sp[m68ki_cpu_p->s_flag^SFLAG_SET]; cpu[0x4c] = CPU_INT_LEVEL>>8; cpu[0x4d] = CPU_STOPPED; m68k_set_context(oldcontext); @@ -77,10 +77,9 @@ PICO_INTERNAL int PicoAreaPackCpu(unsigned char *cpu, int is_sub) #endif *(unsigned int *)(cpu+0x40)=pc; - return 0; } -PICO_INTERNAL int PicoAreaUnpackCpu(unsigned char *cpu, int is_sub) +PICO_INTERNAL void PicoAreaUnpackCpu(unsigned char *cpu, int is_sub) { #if defined(EMU_C68K) struct Cyclone *context = is_sub ? &PicoCpuCS68k : &PicoCpuCM68k; @@ -96,10 +95,10 @@ PICO_INTERNAL int PicoAreaUnpackCpu(unsigned char *cpu, int is_sub) #elif defined(EMU_M68K) void *oldcontext = m68ki_cpu_p; m68k_set_context(is_sub ? &PicoCpuMS68k : &PicoCpuMM68k); + m68k_set_reg(M68K_REG_SR, *(unsigned int *)(cpu+0x44)); memcpy(m68ki_cpu_p->dar,cpu,0x40); m68ki_cpu_p->pc=*(unsigned int *)(cpu+0x40); - m68k_set_reg(M68K_REG_SR, *(unsigned int *)(cpu+0x44)); - m68ki_cpu_p->sp[0]=*(unsigned int *)(cpu+0x48); + m68ki_cpu_p->sp[m68ki_cpu_p->s_flag^SFLAG_SET]=*(unsigned int *)(cpu+0x48); CPU_INT_LEVEL = cpu[0x4c] << 8; CPU_STOPPED = cpu[0x4d]; m68k_set_context(oldcontext); @@ -113,7 +112,6 @@ PICO_INTERNAL int PicoAreaUnpackCpu(unsigned char *cpu, int is_sub) context->execinfo &= ~FM68K_HALTED; if (cpu[0x4d]&1) context->execinfo |= FM68K_HALTED; #endif - return 0; } // Scan the contents of the virtual machine's memory for saving or loading @@ -138,7 +136,6 @@ static int PicoAreaScan(int PmovAction,unsigned int ver, void *PmovFile) // Pack, scan and unpack the cpu data: if((PmovAction&3)==1) PicoAreaPackCpu(cpu, 0); - //SekInit(); // notaz: do we really have to do this here? //PicoMemInit(); SCAN_VAR(cpu,"cpu") if((PmovAction&3)==2) PicoAreaUnpackCpu(cpu, 0); @@ -146,8 +143,7 @@ static int PicoAreaScan(int PmovAction,unsigned int ver, void *PmovFile) SCAN_VAR(Pico.m ,"misc") SCAN_VAR(Pico.video,"video") - // notaz: save/load z80, YM2612, sn76496 states instead of Pico.s (which is unused anyway) - if(PicoOpt&7) { + if (PicoOpt&7) { if((PmovAction&3)==1) z80_pack(cpu_z80); ret = SCAN_VAR(cpu_z80,"cpu_z80") // do not unpack if we fail to load z80 state @@ -156,11 +152,12 @@ static int PicoAreaScan(int PmovAction,unsigned int ver, void *PmovFile) else z80_unpack(cpu_z80); } } - if(PicoOpt&3) + if (PicoOpt&3) ScanVar(sn76496_regs,28*4,"SN76496state", PmovFile, PmovAction); // regs and other stuff - if(PicoOpt&1) { + if (PicoOpt&1) { + if((PmovAction&3)==1) ym2612_pack_state(); ScanVar(ym2612_regs, 0x200+4, "YM2612state", PmovFile, PmovAction); // regs + addr line - if((PmovAction&3)==2) YM2612PicoStateLoad(); // reload YM2612 state from it's regs + if((PmovAction&3)==2) ym2612_unpack_state(); // reload YM2612 state from it's regs } } @@ -176,7 +173,7 @@ int PmovState(int PmovAction, void *PmovFile) int minimum=0; unsigned char head[32]; - if ((PicoMCD & 1) || carthw_chunks != NULL) + if ((PicoAHW & PAHW_MCD) || carthw_chunks != NULL) { if (PmovAction&1) return PicoCdSaveState(PmovFile); if (PmovAction&2) {