summaryrefslogtreecommitdiff
path: root/src/cpu/6502.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/cpu/6502.c')
-rw-r--r--src/cpu/6502.c50
1 files changed, 8 insertions, 42 deletions
diff --git a/src/cpu/6502.c b/src/cpu/6502.c
index 595cd4e..7ae3f16 100644
--- a/src/cpu/6502.c
+++ b/src/cpu/6502.c
@@ -7,34 +7,23 @@ byte acc, X, Y, P, S = 0x00;
address PC = 0x0000;
byte* Memory;
-byte getFlag(byte flag) {
+
+byte GetFlag(byte flag) {
return (P & flag) ? 1 : 0;
}
+
void SetFlag(byte flag, int x) {
P = (P & ~flag) | ((x != 0) ? flag : 0);
}
-void flagSet(byte flag){
- P |= flag;
-}
-
-void flagClear(byte flag){
- P &= ~flag;
-}
-
-// Functions which perform reusable routines for finding if a specific flag should be set.
-void SetFlagN(byte x){
- /*if ((x & flag_N) == flag_N)
- SetFlag(flag_N, 1);
- else
- SetFlag(flag_N, 0);*/
+void SetFlag_N(byte x){
P = (x & flag_N) | (P & ~flag_N);
}
-//Perform prior to any changes TODO: FIX THIS! WTF WERE YOU THINKING?
-void SetFlagV(byte x, byte y){
+
+void SetFlag_V(byte x, byte y){
address z = (address)x + (address)y;
if ((x & 0x80) != (y & 0x80))
SetFlag(flag_V, 1);
@@ -42,44 +31,21 @@ void SetFlagV(byte x, byte y){
SetFlag(flag_V, 0);
}
-/*void SetFlagB(){ //WORK ON
- SetFlag(flag_B, 1);
-}*/
-/*void SetFlagD(){
- SetFlag(flag_D, 1);
-}*/
-
-/*void SetFlagI(){ //WORK ON
- SetFlag(flag_Z, 1);
-}*/
-
-void SetFlagZ(int x){
+void SetFlag_Z(int x){
if (x == 0)
SetFlag(flag_Z, 1);
else
SetFlag(flag_Z, 0);
}
-/*void SetFlagC(){
- SetFlag(flag_Z, 1);
-}*/
-
-
-/*byte GetMemory(address x){
- return Memory[x];
-}
-
-void SetMemory(address x, byte y){
- Memory[x] = y;
-}*/
-
byte GetStack() {
S--;
return GetMemory(0x01FF - S);
}
+
void SetStack(byte x) {
SetMemory(0x01FF - S, x);
S++;