From f3bab87c3862fc0f9b146877f197b8484447eab3 Mon Sep 17 00:00:00 2001 From: qeeg Date: Sat, 3 Jul 2021 10:27:56 -0500 Subject: [PATCH] Fix SYA and SXA opcodes in the CPU. blargg_nes_cpu_test5 now works --- src/ops.inc | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/ops.inc b/src/ops.inc index 1524d615..c6d43ad8 100644 --- a/src/ops.inc +++ b/src/ops.inc @@ -464,10 +464,16 @@ case 0x93: ST_IY(_A&_X&(((A-_Y)>>8)+1)); case 0x9F: ST_ABY(_A&_X&(((A-_Y)>>8)+1)); /* SYA */ -case 0x9C: ST_ABX(_Y&(((A-_X)>>8)+1)); +case 0x9C: /* Can't reuse existing ST_ABI macro here, due to addressing weirdness. */ +{ + unsigned int A; GetABIWR(A,_X); A = ((_Y&((A>>8)+1)) << 8) | (A & 0xff); WrMem(A,A>>8); break; +} /* SXA */ -case 0x9E: ST_ABY(_X&(((A-_Y)>>8)+1)); +case 0x9E: /* Can't reuse existing ST_ABI macro here, due to addressing weirdness. */ +{ + unsigned int A; GetABIWR(A,_Y); A = ((_X&((A>>8)+1)) << 8) | (A & 0xff); WrMem(A,A>>8); break; +} /* XAS */ case 0x9B: _S=_A&_X;ST_ABY(_S& (((A-_Y)>>8)+1) );