diff options
author | alekseiplusplus <alekseijeaves@protonmail.com> | 2023-11-29 17:38:56 +1100 |
---|---|---|
committer | alekseiplusplus <alekseijeaves@protonmail.com> | 2023-11-29 17:38:56 +1100 |
commit | 44a1ea6542c812b173fb9685837c0b2fdc6a7c61 (patch) | |
tree | 5ca86b97f79c38a07d4c532be6edcc12a887cbc1 /src/cpu/instructions.c | |
parent | 8d3aaacf14997bbac177ae37ccab4618264cf29c (diff) |
bug fix apple.c:9 + inconsequential refactoring
Diffstat (limited to 'src/cpu/instructions.c')
-rw-r--r-- | src/cpu/instructions.c | 138 |
1 files changed, 69 insertions, 69 deletions
diff --git a/src/cpu/instructions.c b/src/cpu/instructions.c index a4c96d6..c83a428 100644 --- a/src/cpu/instructions.c +++ b/src/cpu/instructions.c @@ -29,22 +29,22 @@ void fLDY(Addressing addr, address val){ } void fSTA(Addressing addr, address val){ - setMemory(idata.add, acc); + SetMemory(idata.add, acc); } void fSTX(Addressing addr, address val){ - setMemory(idata.add, X); + SetMemory(idata.add, X); } void fSTY(Addressing addr, address val){ - setMemory(idata.add, Y); + SetMemory(idata.add, Y); } // Arithmetic Instructions void fADC(Addressing addr, address val){ int buffer = acc + idata.value; - setFlagV(buffer, acc); + SetFlagV(buffer, acc); if (buffer > 255) flagSet(flag_C); @@ -52,13 +52,13 @@ void fADC(Addressing addr, address val){ flagClear(flag_C); acc += idata.value; - setFlagN(acc); - setFlagZ(acc); + SetFlagN(acc); + SetFlagZ(acc); } void fSBC(Addressing addr, address val){ int buffer = acc - idata.value; - setFlagV(buffer, acc); + SetFlagV(buffer, acc); if (buffer < 0) flagSet(flag_C); @@ -66,70 +66,70 @@ void fSBC(Addressing addr, address val){ flagClear(flag_C); acc -= idata.value; - setFlagN(acc); - setFlagZ(acc); + SetFlagN(acc); + SetFlagZ(acc); } //Increment and Decrement Instructions void fINC(Addressing addr, address val){ - byte a = getMemory(idata.add); + byte a = GetMemory(idata.add); a++; - setMemory(idata.add, a); - setFlagN(Memory[idata.add]); - setFlagZ(Memory[idata.add]); + SetMemory(idata.add, a); + SetFlagN(Memory[idata.add]); + SetFlagZ(Memory[idata.add]); } void fINX(Addressing addr, address val){ X++; - setFlagN(X); - setFlagZ(X); + SetFlagN(X); + SetFlagZ(X); } void fINY(Addressing addr, address val){ Y++; - setFlagN(Y); - setFlagZ(Y); + SetFlagN(Y); + SetFlagZ(Y); } void fDEC(Addressing addr, address val){ - byte a = getMemory(idata.add); + byte a = GetMemory(idata.add); a--; - setMemory(idata.add, a); - setFlagN(Memory[idata.add]); - setFlagZ(Memory[idata.add]); + SetMemory(idata.add, a); + SetFlagN(Memory[idata.add]); + SetFlagZ(Memory[idata.add]); } void fDEX(Addressing addr, address val){ X--; - setFlagN(X); - setFlagZ(X); + SetFlagN(X); + SetFlagZ(X); } void fDEY(Addressing addr, address val){ Y--; - setFlagN(Y); - setFlagZ(Y); + SetFlagN(Y); + SetFlagZ(Y); } // Logical Instructions void fAND(Addressing addr, address val){ acc &= idata.value; - setFlagN(acc); - setFlagZ(acc); + SetFlagN(acc); + SetFlagZ(acc); } void fORA(Addressing addr, address val){ acc |= idata.value; - setFlagN(acc); - setFlagZ(acc); + SetFlagN(acc); + SetFlagZ(acc); } void fEOR(Addressing addr, address val){ acc ^= idata.value; - setFlagN(acc); - setFlagZ(acc); + SetFlagN(acc); + SetFlagZ(acc); } // Jump, Branch, Compare, and Test Bits @@ -209,8 +209,8 @@ void fCPY(Addressing addr, address val){ //NEED TO DOUBLE CHECK THIS INSTRUCTION void fBIT(Addressing addr, address val){ - setFlag(flag_N, (idata.value & flag_N)); - setFlag(flag_V, (idata.value & flag_V)); + SetFlag(flag_N, (idata.value & flag_N)); + SetFlag(flag_V, (idata.value & flag_V)); if (((idata.value & flag_N) & (idata.value & flag_V)) == 0) { flagSet(flag_Z); @@ -222,59 +222,59 @@ void fBIT(Addressing addr, address val){ // Shift and Rotate Instructions void fASL(Addressing addr, address val){ - setFlag(flag_C, (idata.value & 0x80)); + SetFlag(flag_C, (idata.value & 0x80)); acc = (idata.value << 1); - setFlagN(acc); - setFlagZ(acc); + SetFlagN(acc); + SetFlagZ(acc); } void fLSR(Addressing addr, address val){ - setFlag(flag_C, (idata.value & 0x01)); + SetFlag(flag_C, (idata.value & 0x01)); acc = (idata.value >> 1); - setFlagN(acc); - setFlagZ(acc); + SetFlagN(acc); + SetFlagZ(acc); } void fROL(Addressing addr, address val){ - setFlag(flag_C, (val & 0x80)); + SetFlag(flag_C, (val & 0x80)); acc = (val << 1); acc |= (getFlag(flag_C) * 0x01); - setFlagN(acc); - setFlagZ(acc); + SetFlagN(acc); + SetFlagZ(acc); } void fROR(Addressing addr, address val){ - setFlag(flag_C, (val & 0x01)); + SetFlag(flag_C, (val & 0x01)); acc = (val >> 1); acc |= (getFlag(flag_C) * 0x80); - setFlagN(acc); - setFlagZ(acc); + SetFlagN(acc); + SetFlagZ(acc); } // Transfer Instructions void fTAX(Addressing addr, address val){ X = acc; - //setFlagN(X); - //setFlagZ(X); + //SetFlagN(X); + //SetFlagZ(X); } void fTAY(Addressing addr, address val){ Y = acc; - //setFlagN(Y); - //setFlagZ(Y); + //SetFlagN(Y); + //SetFlagZ(Y); } void fTXA(Addressing addr, address val){ acc = X; - setFlagN(acc); - setFlagZ(acc); + SetFlagN(acc); + SetFlagZ(acc); } void fTYA(Addressing addr, address val){ acc = Y; - setFlagN(acc); - setFlagZ(acc); + SetFlagN(acc); + SetFlagZ(acc); } // Stack Instructions @@ -288,50 +288,50 @@ void fTXS(Addressing addr, address val){ } void fPHA(Addressing addr, address val){ - setStack(acc); + SetStack(acc); S++; } void fPHP(Addressing addr, address val){ - setStack(P); + SetStack(P); S++; } void fPLA(Addressing addr, address val){ S--; - acc = getStack(); + acc = GetStack(); } void fPLP(Addressing addr, address val){ S--; - P = getStack(); + P = GetStack(); } // Subroutine Instructions // NEED TO FINISH THESE void fJSR(Addressing addr, address val){ - setStack(((PC-1) & 0xFF00) >> 8); + SetStack(((PC-1) & 0xFF00) >> 8); S++; - setStack((PC-1) & 0x00FF); + SetStack((PC-1) & 0x00FF); S++; PC = idata.add; } void fRTS(Addressing addr, address val){ S--; - PC = (address)(getStack() + 1); + PC = (address)(GetStack() + 1); S--; - PC += ((address)(getStack())) << 8; + PC += ((address)(GetStack())) << 8; } void fRTI(Addressing addr, address val){ S--; - P = getStack(); //NEED TO FIX + P = GetStack(); //NEED TO FIX S--; - PC = (address)(getStack()); + PC = (address)(GetStack()); S--; - PC += (address)(getStack() << 8); + PC += (address)(GetStack() << 8); } // Set/Reset Insutrctions @@ -370,14 +370,14 @@ void fNOP(Addressing addr, address val){ } void fBRK(Addressing addr, address val){ - setStack((((PC+2) & 0xFF00) >> 8)); + SetStack((((PC+2) & 0xFF00) >> 8)); S++; - setStack((PC+2) & 0x00FF); + SetStack((PC+2) & 0x00FF); S++; - setStack(P); + SetStack(P); S++; - PC = (address)(getMemory(0xFFFE)); - PC += ((address)(getMemory(0xFFFF)) << 8); + PC = (address)(GetMemory(0xFFFE)); + PC += ((address)(GetMemory(0xFFFF)) << 8); } #ifdef ILLEGAL_INSTRUCTIONS |