X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=Pico%2FArea.c;h=17646693913752b64b90830cd2e9f1f030990146;hb=03e4f2a349247334666c87abe3a908df72d23051;hp=e4f680b1d85ec2c5bd0201de8ecb5bab200d7806;hpb=860c6322c346c8e2ec2a4626e79f26d8b0d23777;p=picodrive.git diff --git a/Pico/Area.c b/Pico/Area.c index e4f680b..1764669 100644 --- a/Pico/Area.c +++ b/Pico/Area.c @@ -42,63 +42,74 @@ 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: -int PicoAreaPackCpu(unsigned char *cpu, int is_sub) +PICO_INTERNAL int PicoAreaPackCpu(unsigned char *cpu, int is_sub) { unsigned int pc=0; -#ifdef EMU_A68K - memcpy(cpu,M68000_regs.d,0x40); - pc=M68000_regs.pc; - *(unsigned char *)(cpu+0x44)=(unsigned char)M68000_regs.ccr; - *(unsigned char *)(cpu+0x45)=(unsigned char)M68000_regs.srh; - *(unsigned int *)(cpu+0x48)=M68000_regs.isp; -#endif - -#ifdef EMU_C68K - struct Cyclone *context = is_sub ? &PicoCpuS68k : &PicoCpu; +#if defined(EMU_C68K) + struct Cyclone *context = is_sub ? &PicoCpuCS68k : &PicoCpuCM68k; memcpy(cpu,context->d,0x40); pc=context->pc-context->membase; *(unsigned int *)(cpu+0x44)=CycloneGetSr(context); *(unsigned int *)(cpu+0x48)=context->osp; -#endif - -#ifdef EMU_M68K - m68ki_cpu_core *context = is_sub ? &PicoS68kCPU : &PicoM68kCPU; - memcpy(cpu,context->dar,0x40); - pc=context->pc; + cpu[0x4c] = context->irq; + cpu[0x4d] = context->state_flags & 1; +#elif defined(EMU_M68K) + void *oldcontext = m68ki_cpu_p; + m68k_set_context(is_sub ? &PicoCpuMS68k : &PicoCpuMM68k); + 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)=context->sp[0]; + *(unsigned int *)(cpu+0x48)=m68ki_cpu_p->sp[0]; + cpu[0x4c] = CPU_INT_LEVEL>>8; + cpu[0x4d] = CPU_STOPPED; + m68k_set_context(oldcontext); +#elif defined(EMU_F68K) + M68K_CONTEXT *context = is_sub ? &PicoCpuFS68k : &PicoCpuFM68k; + memcpy(cpu,context->dreg,0x40); + pc=context->pc; + *(unsigned int *)(cpu+0x44)=context->sr; + *(unsigned int *)(cpu+0x48)=context->asp; + cpu[0x4c] = context->interrupts[0]; + cpu[0x4d] = (context->execinfo & FM68K_HALTED) ? 1 : 0; #endif *(unsigned int *)(cpu+0x40)=pc; return 0; } -int PicoAreaUnpackCpu(unsigned char *cpu, int is_sub) +PICO_INTERNAL int PicoAreaUnpackCpu(unsigned char *cpu, int is_sub) { -#ifdef EMU_A68K - memcpy(M68000_regs.d,cpu,0x40); - M68000_regs.pc=pc; - M68000_regs.ccr=*(unsigned char *)(cpu+0x44); - M68000_regs.srh=*(unsigned char *)(cpu+0x45); - M68000_regs.isp=*(unsigned int *)(cpu+0x48); -#endif - -#ifdef EMU_C68K - struct Cyclone *context = is_sub ? &PicoCpuS68k : &PicoCpu; - CycloneSetSr(context, *(unsigned int *)(cpu+0x44)); - context->osp=*(unsigned int *)(cpu+0x48); +#if defined(EMU_C68K) + struct Cyclone *context = is_sub ? &PicoCpuCS68k : &PicoCpuCM68k; + CycloneSetSr(context, *(unsigned int *)(cpu+0x44)); + context->osp=*(unsigned int *)(cpu+0x48); memcpy(context->d,cpu,0x40); context->membase=0; context->pc = context->checkpc(*(unsigned int *)(cpu+0x40)); // Base pc -#endif - -#ifdef EMU_M68K - m68ki_cpu_core *context = is_sub ? &PicoS68kCPU : &PicoM68kCPU; - memcpy(context->dar,cpu,0x40); - context->pc=*(unsigned int *)(cpu+0x40); + context->irq = cpu[0x4c]; + context->state_flags = 0; + if (cpu[0x4d]) + context->state_flags |= 1; +#elif defined(EMU_M68K) + void *oldcontext = m68ki_cpu_p; + m68k_set_context(is_sub ? &PicoCpuMS68k : &PicoCpuMM68k); + 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)); - context->sp[0]=*(unsigned int *)(cpu+0x48); + m68ki_cpu_p->sp[0]=*(unsigned int *)(cpu+0x48); + CPU_INT_LEVEL = cpu[0x4c] << 8; + CPU_STOPPED = cpu[0x4d]; + m68k_set_context(oldcontext); +#elif defined(EMU_F68K) + M68K_CONTEXT *context = is_sub ? &PicoCpuFS68k : &PicoCpuFM68k; + memcpy(context->dreg,cpu,0x40); + context->pc =*(unsigned int *)(cpu+0x40); + context->sr =*(unsigned int *)(cpu+0x44); + context->asp=*(unsigned int *)(cpu+0x48); + context->interrupts[0] = cpu[0x4c]; + context->execinfo &= ~FM68K_HALTED; + if (cpu[0x4d]&1) context->execinfo |= FM68K_HALTED; #endif return 0; }