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 }
// Pulse the RESET line on the CPU void m68k_pulse_reset(void) { static uint32_t emulation_initialized = 0; // The first call to this function initializes the opcode handler jump table if (!emulation_initialized) { #if 0 m68ki_build_opcode_table(); m68k_set_int_ack_callback(NULL); m68k_set_bkpt_ack_callback(NULL); m68k_set_reset_instr_callback(NULL); m68k_set_pc_changed_callback(NULL); m68k_set_fc_callback(NULL); m68k_set_instr_hook_callback(NULL); #else // Build opcode handler table here... read_table68k(); do_merges(); BuildCPUFunctionTable(); #endif emulation_initialized = 1; } // if (CPU_TYPE == 0) /* KW 990319 */ // m68k_set_cpu_type(M68K_CPU_TYPE_68000); #if 0 /* Clear all stop levels and eat up all remaining cycles */ CPU_STOPPED = 0; SET_CYCLES(0); /* Turn off tracing */ FLAG_T1 = FLAG_T0 = 0; m68ki_clear_trace(); /* Interrupt mask to level 7 */ FLAG_INT_MASK = 0x0700; /* Reset VBR */ REG_VBR = 0; /* Go to supervisor mode */ m68ki_set_sm_flag(SFLAG_SET | MFLAG_CLEAR); /* Invalidate the prefetch queue */ #if M68K_EMULATE_PREFETCH /* Set to arbitrary number since our first fetch is from 0 */ CPU_PREF_ADDR = 0x1000; #endif /* M68K_EMULATE_PREFETCH */ /* Read the initial stack pointer and program counter */ m68ki_jump(0); REG_SP = m68ki_read_imm_32(); REG_PC = m68ki_read_imm_32(); m68ki_jump(REG_PC); #else regs.spcflags = 0; regs.stopped = 0; regs.remainingCycles = 0; regs.intmask = 0x07; regs.s = 1; // Supervisor mode ON // Read initial SP and PC m68k_areg(regs, 7) = m68k_read_memory_32(0); m68k_setpc(m68k_read_memory_32(4)); refill_prefetch(m68k_getpc(), 0); #endif }
void m68000_set_irq_callback(int (*callback)(int irqline)) { m68k_set_int_ack_callback(callback); }