summaryrefslogtreecommitdiff
path: root/applesystem.h
diff options
context:
space:
mode:
Diffstat (limited to 'applesystem.h')
-rw-r--r--applesystem.h24
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);
-}
+}*/