REFACTOR : move special case initialization codepath to C

This commit is contained in:
Aaron Culliney 2015-02-14 22:58:24 -08:00
parent 30c09da259
commit 0801050455
2 changed files with 11 additions and 14 deletions

View File

@ -631,10 +631,17 @@ static void initialize_code_tables()
}
}
void cpu65_init()
void cpu65_init(void)
{
initialize_code_tables();
cpu65__signal = 0;
cpu65_pc = 0x0;
cpu65_ea = 0x0;
cpu65_a = 0xFF;
cpu65_x = 0xFF;
cpu65_y = 0xFF;
cpu65_f = (C_Flag_6502|X_Flag_6502|I_Flag_6502|V_Flag_6502|B_Flag_6502|Z_Flag_6502|N_Flag_6502);
cpu65_sp = 0xFC;
}
void cpu65_interrupt(int reason)

View File

@ -2198,8 +2198,6 @@ ENTRY(cpu65_run)
#endif
pushLQ _XBP
movLQ _XSP, _XBP
cmpb $0, SYM(emul_reinitialize)
jnz enter_reinit
// Restore CPU state when being called from C.
movzwLQ DebugCurrEA, EffectiveAddr_X
@ -2219,20 +2217,11 @@ ENTRY(cpu65_run)
#ifdef APPLE2_VM
RestoreAltZP
#endif
cmpb $0, SYM(emul_reinitialize)
jnz enter_reinit
jmp continue1
enter_reinit: movb $0, SYM(emul_reinitialize)
// Zero all used registers
xorLQ _XAX, _XAX
xorLQ XY_Reg_X, XY_Reg_X
movb $0xFF, X_Reg
movb $0xFF, Y_Reg
xorLQ AF_Reg_X, AF_Reg_X
movb $0xFF, A_Reg
orb $(C_Flag|X_Flag|I_Flag|V_Flag|B_Flag|Z_Flag|N_Flag), F_Reg
xorLQ PC_Reg_X, PC_Reg_X
xorLQ EffectiveAddr_X, EffectiveAddr_X
movLQ $0x1FC, SP_Reg_X
jmp ex_reset
/* -------------------------------------------------------------------------
@ -2262,6 +2251,7 @@ exit_reinit: movb $0, SYM(cpu65__signal)
------------------------------------------------------------------------- */
ENTRY(cpu65_direct_write)
#warning FIXME TODO cpu65_direct_write should be implemented in plain C ...
pushLQ EffectiveAddr_X
movLQ 8(_XSP),EffectiveAddr_X
movLQ 12(_XSP),_XAX