Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Proposed fix for the behaviour of STP #4

Merged
merged 2 commits into from
Feb 2, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading