summaryrefslogtreecommitdiff
path: root/src/cpu/6502.c
diff options
context:
space:
mode:
authoralekseiplusplus <alekseijeaves@protonmail.com>2023-12-03 21:03:44 +1100
committeralekseiplusplus <alekseijeaves@protonmail.com>2023-12-03 21:03:44 +1100
commit78d3f650b2ca507e3d5376d3cad4d93df1901569 (patch)
tree997f7fae4c137af410e38f6acf790e2c7e20cebc /src/cpu/6502.c
parent09288876a8080b2a643a8c644eb116c021f0c397 (diff)
making CPU more correct, STILL not working
Diffstat (limited to 'src/cpu/6502.c')
-rw-r--r--src/cpu/6502.c11
1 files changed, 2 insertions, 9 deletions
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){