PICO_INTERNAL void SekInit(void) { #ifdef EMU_C68K CycloneInit(); memset(&PicoCpuCM68k,0,sizeof(PicoCpuCM68k)); PicoCpuCM68k.IrqCallback=SekIntAck; PicoCpuCM68k.ResetCallback=SekResetAck; PicoCpuCM68k.UnrecognizedCallback=SekUnrecognizedOpcode; PicoCpuCM68k.flags=4; // Z set #endif #ifdef EMU_M68K { void *oldcontext = m68ki_cpu_p; m68k_set_context(&PicoCpuMM68k); m68k_set_cpu_type(M68K_CPU_TYPE_68000); m68k_init(); m68k_set_int_ack_callback(SekIntAckM68K); m68k_set_tas_instr_callback(SekTasCallback); //m68k_pulse_reset(); m68k_set_context(oldcontext); } #endif #ifdef EMU_F68K { void *oldcontext = g_m68kcontext; g_m68kcontext = &PicoCpuFM68k; memset(&PicoCpuFM68k, 0, sizeof(PicoCpuFM68k)); fm68k_init(); PicoCpuFM68k.iack_handler = SekIntAckF68K; PicoCpuFM68k.sr = 0x2704; // Z flag g_m68kcontext = oldcontext; } #endif }
PICO_INTERNAL void SekUnpackCpu(const unsigned char *cpu, int is_sub) { #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 = *(unsigned int *)(cpu+0x40); CycloneUnpack(context, NULL); // rebase PC 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); 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); 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); #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 if (is_sub) SekCycleCntS68k = *(unsigned int *)(cpu+0x50); else SekCycleCnt = *(unsigned int *)(cpu+0x50); }
// Pack the cpu into a common format: // XXX: rename PICO_INTERNAL void SekPackCpu(unsigned char *cpu, int is_sub) { unsigned int pc=0; #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; 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)=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); #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; *(unsigned int *)(cpu+0x50) = is_sub ? SekCycleCntS68k : SekCycleCnt; }
// Reset the 68000: PICO_INTERNAL int SekReset(void) { if (Pico.rom==NULL) return 1; #ifdef EMU_C68K CycloneReset(&PicoCpuCM68k); #endif #ifdef EMU_M68K m68k_set_context(&PicoCpuMM68k); // if we ever reset m68k, we always need it's context to be set m68ki_cpu.sp[0]=0; m68k_set_irq(0); m68k_pulse_reset(); REG_USP = 0; // ? #endif #ifdef EMU_F68K { g_m68kcontext = &PicoCpuFM68k; fm68k_reset(); } #endif return 0; }
static void uae4all_reset(void) { int i; #if !defined(USE_CYCLONE_CORE) && !defined(USE_FAME_CORE_ARM2) m68k_set_context(&micontexto); #endif m68k_reset(); for(i=1; i<8; i++) #if defined(DEBUG_INTERRUPTS) M68KCONTEXT.interrupts[i]=0xFF; #else M68KCONTEXT.interrupts[i]=0x18+i; #endif M68KCONTEXT.interrupts[0]=0; m68k_irq_update(0); mispcflags=0; _68k_areg(7) = get_long (0x00f80000); _68k_setpc(get_long (0x00f80004)); //_68k_sreg = 0x2700; // already done by m68k_reset() mispcflags=0; #ifdef DEBUG_FRAMERATE uae4all_update_time(); #endif }
void m68000_set_context(void *src) { m68k_set_context(src); }