Slightly less hackishly, use "private" pointers to set struct vals

This commit is contained in:
Aaron Culliney
2014-06-21 14:14:30 -07:00
parent a4670b1eda
commit d650982e51
2 changed files with 30 additions and 17 deletions

View File

@@ -19,6 +19,19 @@
struct cpu65_state cpu65_current = { 0 };
struct cpu65_extra cpu65_debug = { 0 };
const uint16_t *_cpu65_pc = &cpu65_current.pc;
const uint8_t *_cpu65_a = &cpu65_current.a;
const uint8_t *_cpu65_f = &cpu65_current.f;
const uint8_t *_cpu65_x = &cpu65_current.x;
const uint8_t *_cpu65_y = &cpu65_current.y;
const uint8_t *_cpu65_sp = &cpu65_current.sp;
const uint16_t *_cpu65_ea = &cpu65_debug.ea;
const uint8_t *_cpu65_d = &cpu65_debug.d;
const uint8_t *_cpu65_rw = &cpu65_debug.rw;
const uint8_t *_cpu65_opcode = &cpu65_debug.opcode;
const uint8_t *_cpu65_opcycles = &cpu65_debug.opcycles;
int16_t cpu65_cycle_count = 0;
int16_t cpu65_cycles_to_execute = 0;
uint8_t cpu65__signal = 0;

View File

@@ -18,11 +18,11 @@
#include "apple2.h"
#include "misc.h"
#define DebugCurrEA SN(cpu65_debug)
#define DebugCurrByte SN(cpu65_debug)+2
#define DebugCurrRW SN(cpu65_debug)+3
#define DebugCurrOpcode SN(cpu65_debug)+4
#define DebugCycleCount SN(cpu65_debug)+5
#define DebugCurrEA SN(_cpu65_ea)
#define DebugCurrByte SN(_cpu65_d)
#define DebugCurrRW SN(_cpu65_rw)
#define DebugCurrOpcode SN(_cpu65_opcode)
#define DebugCycleCount SN(_cpu65_opcycles)
/* -------------------------------------------------------------------------
CPU (6502) Helper Routines
@@ -2111,13 +2111,13 @@ E(cpu65_run)
// Restore CPU state when being called from C.
movLQ $0x0100, SP_Reg_X
movzwLQ DebugCurrEA, EffectiveAddr_X
movzwLQ SN(cpu65_current), PC_Reg_X
movzbLQ SN(cpu65_current)+2, AF_Reg_X
movzbLQ SN(cpu65_current)+3, _XAX
movzwLQ SN(_cpu65_pc), PC_Reg_X
movzbLQ SN(_cpu65_a), AF_Reg_X
movzbLQ SN(_cpu65_f), _XAX
movb SN(cpu65_flags_decode)(,_XAX,1), F_Reg
movzbLQ SN(cpu65_current)+4, XY_Reg_X
movb SN(cpu65_current)+5, Y_Reg
movb SN(cpu65_current)+6, SP_Reg_L
movzbLQ SN(_cpu65_x), XY_Reg_X
movb SN(_cpu65_y), Y_Reg
movb SN(_cpu65_sp), SP_Reg_L
#ifdef APPLE2_VM
RestoreAltZP
#endif
@@ -2136,15 +2136,15 @@ E(cpu65_run)
exit_cpu65_run:
// Save CPU state when returning from being called from C
movw EffectiveAddr, DebugCurrEA
movw PC_Reg, SN(cpu65_current)
movb A_Reg, SN(cpu65_current)+2
movw PC_Reg, SN(_cpu65_pc)
movb A_Reg, SN(_cpu65_a)
xorw %ax, %ax
movb F_Reg, %al
movb SN(cpu65_flags_encode)(,_XAX,1), %al
movb %al, SN(cpu65_current)+3
movb X_Reg, SN(cpu65_current)+4
movb Y_Reg, SN(cpu65_current)+5
movb SP_Reg_L, SN(cpu65_current)+6
movb %al, SN(_cpu65_f)
movb X_Reg, SN(_cpu65_x)
movb Y_Reg, SN(_cpu65_y)
movb SP_Reg_L, SN(_cpu65_sp)
jmp exit_frame
emul_reinit: movb $0, SN(cpu65__signal)