From 8ec080d0cd9fd62c0de20780581a4750d078ea94 Mon Sep 17 00:00:00 2001 From: alekseiplusplus Date: Fri, 1 Dec 2023 02:56:13 +1100 Subject: progress, still WIP --- src/cpu/6502.c | 14 ++++++-------- src/cpu/instructions.c | 2 +- 2 files changed, 7 insertions(+), 9 deletions(-) (limited to 'src/cpu') diff --git a/src/cpu/6502.c b/src/cpu/6502.c index ab8248e..366882f 100644 --- a/src/cpu/6502.c +++ b/src/cpu/6502.c @@ -40,15 +40,13 @@ void SetFlagN(byte x){ P = (x & flag_N) | (P & ~flag_N); } -//Perform prior to any changes +//Perform prior to any changes TODO: FIX THIS! WTF WERE YOU THINKING? void SetFlagV(byte x, byte y){ - if ((x & flag_N) == (y & flag_N)){ - if (((x + y) & (flag_N ^ 0xFF)) > 0x7F) SetFlag(flag_V, 1); - else SetFlag(flag_V, 0); - }else{ - if (((x - y) & (flag_N ^ 0xFF)) > 0x7F) SetFlag(flag_V, 1); - else SetFlag(flag_V, 0); - } + address z = (address)x + (address)y; + if (z > 0xFF) + SetFlag(flag_V, 1); + else + SetFlag(flag_V, 0); } /*void SetFlagB(){ //WORK ON diff --git a/src/cpu/instructions.c b/src/cpu/instructions.c index c043ac4..cf69fc2 100644 --- a/src/cpu/instructions.c +++ b/src/cpu/instructions.c @@ -136,7 +136,7 @@ void fEOR(Addressing addr, address val){ // Jump, Branch, Compare, and Test Bits void fJMP(Addressing addr, address val){ - PC = val; + PC = val; PC -= 2; } void fBCC(Addressing addr, address val){ //FINISH ALL BRANCH INSTRUCTIONS -- cgit v1.2.3