From 78d3f650b2ca507e3d5376d3cad4d93df1901569 Mon Sep 17 00:00:00 2001 From: alekseiplusplus Date: Sun, 3 Dec 2023 21:03:44 +1100 Subject: making CPU more correct, STILL not working --- src/cpu/6502.c | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) (limited to 'src/cpu/6502.c') diff --git a/src/cpu/6502.c b/src/cpu/6502.c index 366882f..e7c1669 100644 --- a/src/cpu/6502.c +++ b/src/cpu/6502.c @@ -8,18 +8,11 @@ address PC = 0x0000; byte* Memory; byte getFlag(byte flag) { - return ((P & flag) == flag) ? 1 : 0; + return (P & flag) ? 1 : 0; } void SetFlag(byte flag, int x) { - if (x == 1){ - if ((P & flag) == 0x0) P += flag; - }else if (x == 0){ - if ((P & flag) == flag) P -= flag; - } - else{ - fprintf(stderr, "SetFlag() passed arg neither 0 or 1"); - } + P = (P & ~flag) | ((x != 0) ? flag : 0); } void flagSet(byte flag){ -- cgit v1.2.3