diff options
author | alekseiplusplus <alekseijeaves@protonmail.com> | 2023-03-27 12:56:11 +1100 |
---|---|---|
committer | alekseiplusplus <alekseijeaves@protonmail.com> | 2023-03-27 12:56:11 +1100 |
commit | 19d02d1eed0886220e64f4ed87bc8da8666f8760 (patch) | |
tree | 82a619561e2d75dd274168ef10e61ad60a0b61a0 /applesystem.h | |
parent | 514f0a659cebc9d9554dd7bdbb388e66d6e16af1 (diff) |
Added instructions, changed C and V set flag funcs
Diffstat (limited to 'applesystem.h')
-rw-r--r-- | applesystem.h | 24 |
1 files changed, 17 insertions, 7 deletions
diff --git a/applesystem.h b/applesystem.h index a3a33f5..ea9b322 100644 --- a/applesystem.h +++ b/applesystem.h @@ -2,6 +2,12 @@ typedef unsigned char byte; byte acc, X, Y, S, P = 0x00; byte Memory[4096]; // TO DO. Add expansion capability to memory. +/* +To Do. + + Find variables better passed as pointers instead +*/ + + // FLAGS const byte flag_N = 0x80; // Negative (Note that byte cast is necessary here only) const byte flag_V = 0x40; // Overflow @@ -65,8 +71,9 @@ Zero Page ADC $44 $65 2 3 instruction(0x65); -> ADC({enum for Zero Page}); */ // Set particular flags -void setFlagN(){ - if (acc ^ 0x80){ +// Functions which quickly set specific flags that are straightforward checks, and are repeated often. +void setFlagN(byte x){ + if (x ^ flag_N == flag_N){ setFlag(flag_N, 1); }else{ //not sure if this should be present, I think it is setFlag(flag_N, 0); @@ -74,11 +81,13 @@ void setFlagN(){ } //Perform prior to any changes -void setFlagV(byte x, byte y){ //This is pathetic. +void setFlagV(byte x, byte y){ if ((x & flag_N) == (y & flag_N)){ - if (((x + y) & (flag_N ^ 0xFF)) > 0x8F) setFlag(flag_V, 1); + if (((x + y) & (flag_N ^ 0xFF)) > 0x7F) setFlag(flag_V, 1); + else setFlag(flag_V, 0); }else{ - if (((x - y) & (flag_N ^ 0xFF)) > 0x8F) setFlag(flag_V, 1); + if (((x - y) & (flag_N ^ 0xFF)) > 0x7F) setFlag(flag_V, 1); + else setFlag(flag_V, 0); } } /*void setFlagB(){ //WORK ON @@ -95,9 +104,10 @@ void setFlagZ(int x){ setFlag(flag_Z, 1); } } -void setFlagC(){ // NOTE. Must make setFlagC functional with independence. Look into carrying on 6502 +//Only 6 instructions, 2 not including stack instructions, use the carry flag. +/*void setFlagC(){ // NOTE. Must make setFlagC functional with independence. Look into carrying on 6502 setFlag(flag_Z, 1); -} +}*/ |