Skip to content

Commit

Permalink
Proposed fix for the behaviour of STP (#4)
Browse files Browse the repository at this point in the history
* First fix for the behaviour of STP

* Combining STP and JAM for better performance
  • Loading branch information
NollKollTroll authored Feb 2, 2024
1 parent 07173c8 commit 61f7371
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions src/vrEmu6502.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ struct vrEmu6502_s
uint16_t currentOpcodeAddr;

bool wai;
bool stp;

uint16_t pc;

Expand All @@ -72,7 +73,6 @@ struct vrEmu6502_s
uint16_t zpBase;
uint16_t spBase;
uint16_t tmpAddr;
bool jam;

const vrEmu6502Opcode* opcodes;
const char* mnemonicNames[256];
Expand Down Expand Up @@ -293,9 +293,9 @@ VR_EMU_6502_DLLEXPORT void vrEmu6502Reset(VrEmu6502* vr6502)
vr6502->pc = read16(vr6502, RESET_VEC);
vr6502->step = 0;
vr6502->wai = false;
vr6502->stp = false;
vr6502->currentOpcode = 0;
vr6502->tmpAddr = 0;
vr6502->jam = 0;

/* 65c02 clears D and sets I on reset */
if (is65c02(vr6502))
Expand Down Expand Up @@ -325,7 +325,7 @@ static void beginInterrupt(VrEmu6502* vr6502, uint16_t addr)
*/
VR_EMU_6502_DLLEXPORT void __time_critical_func(vrEmu6502Tick)(VrEmu6502* vr6502)
{
if (vr6502->jam) return;
if (vr6502->stp) return;

if (vr6502->step == 0)
{
Expand Down Expand Up @@ -1789,8 +1789,9 @@ static void bbs7(VrEmu6502* vr6502, vrEmu6502AddrModeFn modeAddr) { bbs(vr6502,
*/
static void stp(VrEmu6502* vr6502, vrEmu6502AddrModeFn modeAddr)
{
if (modeAddr)
--vr6502->pc;
(void)modeAddr;

vr6502->stp = true;
}

/*
Expand Down Expand Up @@ -2006,7 +2007,7 @@ static void jam(VrEmu6502* vr6502, vrEmu6502AddrModeFn modeAddr)
(void)modeAddr;

vr6502->readFn(imm(vr6502), false);
vr6502->jam = 1;
vr6502->stp = true;
}

/* ------------------------------------------------------------------
Expand Down

0 comments on commit 61f7371

Please sign in to comment.