diff options
Diffstat (limited to 'source/cpumacro.h')
-rw-r--r-- | source/cpumacro.h | 206 |
1 files changed, 120 insertions, 86 deletions
diff --git a/source/cpumacro.h b/source/cpumacro.h index 7712e49..313e920 100644 --- a/source/cpumacro.h +++ b/source/cpumacro.h @@ -3,26 +3,29 @@ #ifndef _CPUMACRO_H_ #define _CPUMACRO_H_ +#include <retro_inline.h> + extern int32_t OpAddress; -static inline void SetZN16(uint16_t Work) +static INLINE void SetZN16(uint16_t Work) { ICPU._Zero = Work != 0; ICPU._Negative = (uint8_t)(Work >> 8); } -static inline void SetZN8(uint8_t Work) +static INLINE void SetZN8(uint8_t Work) { ICPU._Zero = Work; ICPU._Negative = Work; } -static inline void ADC8() +static INLINE void ADC8() { uint8_t Work8 = S9xGetByte(OpAddress); if (CheckDecimal()) { + uint8_t Ans8; uint8_t A1 = (ICPU.Registers.A.W) & 0x0f; uint8_t A2 = (ICPU.Registers.A.W) & 0xf0; uint8_t W1 = Work8 & 0x0f; @@ -44,7 +47,7 @@ static inline void ADC8() else ClearCarry(); - uint8_t Ans8 = A2 | A1; + Ans8 = A2 | A1; if (~(ICPU.Registers.AL ^ Work8) & (Work8 ^ Ans8) & 0x80) SetOverflow(); else @@ -64,12 +67,13 @@ static inline void ADC8() SetZN8(ICPU.Registers.AL); } -static inline void ADC16() +static INLINE void ADC16() { uint16_t Work16 = S9xGetWord(OpAddress); if (CheckDecimal()) { + uint16_t Ans16; uint16_t A1 = ICPU.Registers.A.W & 0x000f; uint16_t A2 = ICPU.Registers.A.W & 0x00f0; uint16_t A3 = ICPU.Registers.A.W & 0x0f00; @@ -109,7 +113,7 @@ static inline void ADC16() else ClearCarry(); - uint16_t Ans16 = A4 | A3 | A2 | A1; + Ans16 = A4 | A3 | A2 | A1; if (~(ICPU.Registers.A.W ^ Work16) & (Work16 ^ Ans16) & 0x8000) SetOverflow(); else @@ -130,19 +134,19 @@ static inline void ADC16() SetZN16(ICPU.Registers.A.W); } -static inline void AND16() +static INLINE void AND16() { ICPU.Registers.A.W &= S9xGetWord(OpAddress); SetZN16(ICPU.Registers.A.W); } -static inline void AND8() +static INLINE void AND8() { ICPU.Registers.AL &= S9xGetByte(OpAddress); SetZN8(ICPU.Registers.AL); } -static inline void A_ASL16() +static INLINE void A_ASL16() { #ifndef SA1_OPCODES CPU.Cycles += ONE_CYCLE; @@ -152,7 +156,7 @@ static inline void A_ASL16() SetZN16(ICPU.Registers.A.W); } -static inline void A_ASL8() +static INLINE void A_ASL8() { #ifndef SA1_OPCODES CPU.Cycles += ONE_CYCLE; @@ -162,12 +166,13 @@ static inline void A_ASL8() SetZN8(ICPU.Registers.AL); } -static inline void ASL16() +static INLINE void ASL16() { + uint16_t Work16; #ifndef SA1_OPCODES CPU.Cycles += ONE_CYCLE; #endif - uint16_t Work16 = S9xGetWord(OpAddress); + Work16 = S9xGetWord(OpAddress); ICPU._Carry = (Work16 & 0x8000) != 0; Work16 <<= 1; S9xSetByte(Work16 >> 8, OpAddress + 1); @@ -175,19 +180,20 @@ static inline void ASL16() SetZN16(Work16); } -static inline void ASL8() +static INLINE void ASL8() { + uint8_t Work8; #ifndef SA1_OPCODES CPU.Cycles += ONE_CYCLE; #endif - uint8_t Work8 = S9xGetByte(OpAddress); + Work8 = S9xGetByte(OpAddress); ICPU._Carry = (Work8 & 0x80) != 0; Work8 <<= 1; S9xSetByte(Work8, OpAddress); SetZN8(Work8); } -static inline void BIT16() +static INLINE void BIT16() { uint16_t Work16 = S9xGetWord(OpAddress); ICPU._Overflow = (Work16 & 0x4000) != 0; @@ -195,7 +201,7 @@ static inline void BIT16() ICPU._Zero = (Work16 & ICPU.Registers.A.W) != 0; } -static inline void BIT8() +static INLINE void BIT8() { uint8_t Work8 = S9xGetByte(OpAddress); ICPU._Overflow = (Work8 & 0x40) != 0; @@ -203,49 +209,49 @@ static inline void BIT8() ICPU._Zero = Work8 & ICPU.Registers.AL; } -static inline void CMP16() +static INLINE void CMP16() { int32_t Int32 = (int32_t) ICPU.Registers.A.W - (int32_t) S9xGetWord(OpAddress); ICPU._Carry = Int32 >= 0; SetZN16((uint16_t) Int32); } -static inline void CMP8() +static INLINE void CMP8() { int16_t Int16 = (int16_t) ICPU.Registers.AL - (int16_t) S9xGetByte(OpAddress); ICPU._Carry = Int16 >= 0; SetZN8((uint8_t) Int16); } -static inline void CMX16() +static INLINE void CMX16() { int32_t Int32 = (int32_t) ICPU.Registers.X.W - (int32_t) S9xGetWord(OpAddress); ICPU._Carry = Int32 >= 0; SetZN16((uint16_t) Int32); } -static inline void CMX8() +static INLINE void CMX8() { int16_t Int16 = (int16_t) ICPU.Registers.XL - (int16_t) S9xGetByte(OpAddress); ICPU._Carry = Int16 >= 0; SetZN8((uint8_t) Int16); } -static inline void CMY16() +static INLINE void CMY16() { int32_t Int32 = (int32_t) ICPU.Registers.Y.W - (int32_t) S9xGetWord(OpAddress); ICPU._Carry = Int32 >= 0; SetZN16((uint16_t) Int32); } -static inline void CMY8() +static INLINE void CMY8() { int16_t Int16 = (int16_t) ICPU.Registers.YL - (int16_t) S9xGetByte(OpAddress); ICPU._Carry = Int16 >= 0; SetZN8((uint8_t) Int16); } -static inline void A_DEC16() +static INLINE void A_DEC16() { #ifndef SA1_OPCODES CPU.Cycles += ONE_CYCLE; @@ -255,7 +261,7 @@ static inline void A_DEC16() SetZN16(ICPU.Registers.A.W); } -static inline void A_DEC8() +static INLINE void A_DEC8() { #ifndef SA1_OPCODES CPU.Cycles += ONE_CYCLE; @@ -265,42 +271,46 @@ static inline void A_DEC8() SetZN8(ICPU.Registers.AL); } -static inline void DEC16() +static INLINE void DEC16() { + uint16_t Work16; + #ifndef SA1_OPCODES CPU.Cycles += ONE_CYCLE; #endif CPU.WaitAddress = NULL; - uint16_t Work16 = S9xGetWord(OpAddress) - 1; + Work16 = S9xGetWord(OpAddress) - 1; S9xSetByte(Work16 >> 8, OpAddress + 1); S9xSetByte(Work16 & 0xFF, OpAddress); SetZN16(Work16); } -static inline void DEC8() +static INLINE void DEC8() { + uint8_t Work8; + #ifndef SA1_OPCODES CPU.Cycles += ONE_CYCLE; #endif CPU.WaitAddress = NULL; - uint8_t Work8 = S9xGetByte(OpAddress) - 1; + Work8 = S9xGetByte(OpAddress) - 1; S9xSetByte(Work8, OpAddress); SetZN8(Work8); } -static inline void EOR16() +static INLINE void EOR16() { ICPU.Registers.A.W ^= S9xGetWord(OpAddress); SetZN16(ICPU.Registers.A.W); } -static inline void EOR8() +static INLINE void EOR8() { ICPU.Registers.AL ^= S9xGetByte(OpAddress); SetZN8(ICPU.Registers.AL); } -static inline void A_INC16() +static INLINE void A_INC16() { #ifndef SA1_OPCODES CPU.Cycles += ONE_CYCLE; @@ -310,7 +320,7 @@ static inline void A_INC16() SetZN16(ICPU.Registers.A.W); } -static inline void A_INC8() +static INLINE void A_INC8() { #ifndef SA1_OPCODES CPU.Cycles += ONE_CYCLE; @@ -320,66 +330,69 @@ static inline void A_INC8() SetZN8(ICPU.Registers.AL); } -static inline void INC16() +static INLINE void INC16() { + uint16_t Work16; #ifndef SA1_OPCODES CPU.Cycles += ONE_CYCLE; #endif CPU.WaitAddress = NULL; - uint16_t Work16 = S9xGetWord(OpAddress) + 1; + Work16 = S9xGetWord(OpAddress) + 1; S9xSetByte(Work16 >> 8, OpAddress + 1); S9xSetByte(Work16 & 0xFF, OpAddress); SetZN16(Work16); } -static inline void INC8() +static INLINE void INC8() { + uint8_t Work8; + #ifndef SA1_OPCODES CPU.Cycles += ONE_CYCLE; #endif CPU.WaitAddress = NULL; - uint8_t Work8 = S9xGetByte(OpAddress) + 1; + Work8 = S9xGetByte(OpAddress) + 1; S9xSetByte(Work8, OpAddress); SetZN8(Work8); } -static inline void LDA16() +static INLINE void LDA16() { ICPU.Registers.A.W = S9xGetWord(OpAddress); SetZN16(ICPU.Registers.A.W); } -static inline void LDA8() +static INLINE void LDA8() { ICPU.Registers.AL = S9xGetByte(OpAddress); SetZN8(ICPU.Registers.AL); } -static inline void LDX16() +static INLINE void LDX16() { ICPU.Registers.X.W = S9xGetWord(OpAddress); SetZN16(ICPU.Registers.X.W); } -static inline void LDX8() +static INLINE void LDX8() { ICPU.Registers.XL = S9xGetByte(OpAddress); SetZN8(ICPU.Registers.XL); } -static inline void LDY16() +static INLINE void LDY16() { ICPU.Registers.Y.W = S9xGetWord(OpAddress); SetZN16(ICPU.Registers.Y.W); } -static inline void LDY8() +static INLINE void LDY8() { ICPU.Registers.YL = S9xGetByte(OpAddress); SetZN8(ICPU.Registers.YL); } -static inline void A_LSR16() +static INLINE void A_LSR16() { #ifndef SA1_OPCODES CPU.Cycles += ONE_CYCLE; @@ -389,7 +402,7 @@ static inline void A_LSR16() SetZN16(ICPU.Registers.A.W); } -static inline void A_LSR8() +static INLINE void A_LSR8() { #ifndef SA1_OPCODES CPU.Cycles += ONE_CYCLE; @@ -399,12 +412,14 @@ static inline void A_LSR8() SetZN8(ICPU.Registers.AL); } -static inline void LSR16() +static INLINE void LSR16() { + uint16_t Work16; + #ifndef SA1_OPCODES CPU.Cycles += ONE_CYCLE; #endif - uint16_t Work16 = S9xGetWord(OpAddress); + Work16 = S9xGetWord(OpAddress); ICPU._Carry = Work16 & 1; Work16 >>= 1; S9xSetByte(Work16 >> 8, OpAddress + 1); @@ -412,47 +427,51 @@ static inline void LSR16() SetZN16(Work16); } -static inline void LSR8() +static INLINE void LSR8() { + uint8_t Work8; + #ifndef SA1_OPCODES CPU.Cycles += ONE_CYCLE; #endif - uint8_t Work8 = S9xGetByte(OpAddress); + Work8 = S9xGetByte(OpAddress); ICPU._Carry = Work8 & 1; Work8 >>= 1; S9xSetByte(Work8, OpAddress); SetZN8(Work8); } -static inline void ORA16() +static INLINE void ORA16() { ICPU.Registers.A.W |= S9xGetWord(OpAddress); SetZN16(ICPU.Registers.A.W); } -static inline void ORA8() +static INLINE void ORA8() { ICPU.Registers.AL |= S9xGetByte(OpAddress); SetZN8(ICPU.Registers.AL); } -static inline void A_ROL16() +static INLINE void A_ROL16() { + uint32_t Work32; #ifndef SA1_OPCODES CPU.Cycles += ONE_CYCLE; #endif - uint32_t Work32 = (ICPU.Registers.A.W << 1) | CheckCarry(); + Work32 = (ICPU.Registers.A.W << 1) | CheckCarry(); ICPU._Carry = Work32 > 0xffff; ICPU.Registers.A.W = (uint16_t) Work32; SetZN16((uint16_t) Work32); } -static inline void A_ROL8() +static INLINE void A_ROL8() { + uint16_t Work16; #ifndef SA1_OPCODES CPU.Cycles += ONE_CYCLE; #endif - uint16_t Work16 = ICPU.Registers.AL; + Work16 = ICPU.Registers.AL; Work16 <<= 1; Work16 |= CheckCarry(); ICPU._Carry = Work16 > 0xff; @@ -460,12 +479,14 @@ static inline void A_ROL8() SetZN8((uint8_t) Work16); } -static inline void ROL16() +static INLINE void ROL16() { + uint32_t Work32; + #ifndef SA1_OPCODES CPU.Cycles += ONE_CYCLE; #endif - uint32_t Work32 = S9xGetWord(OpAddress); + Work32 = S9xGetWord(OpAddress); Work32 <<= 1; Work32 |= CheckCarry(); ICPU._Carry = Work32 > 0xffff; @@ -474,12 +495,13 @@ static inline void ROL16() SetZN16((uint16_t) Work32); } -static inline void ROL8() +static INLINE void ROL8() { + uint16_t Work16; #ifndef SA1_OPCODES CPU.Cycles += ONE_CYCLE; #endif - uint16_t Work16 = S9xGetByte(OpAddress); + Work16 = S9xGetByte(OpAddress); Work16 <<= 1; Work16 |= CheckCarry(); ICPU._Carry = Work16 > 0xff; @@ -487,12 +509,13 @@ static inline void ROL8() SetZN8((uint8_t) Work16); } -static inline void A_ROR16() +static INLINE void A_ROR16() { + uint32_t Work32; #ifndef SA1_OPCODES CPU.Cycles += ONE_CYCLE; #endif - uint32_t Work32 = ICPU.Registers.A.W; + Work32 = ICPU.Registers.A.W; Work32 |= (int32_t) CheckCarry() << 16; ICPU._Carry = (uint8_t)(Work32 & 1); Work32 >>= 1; @@ -500,24 +523,27 @@ static inline void A_ROR16() SetZN16((uint16_t) Work32); } -static inline void A_ROR8() +static INLINE void A_ROR8() { + uint16_t Work16; #ifndef SA1_OPCODES CPU.Cycles += ONE_CYCLE; #endif - uint16_t Work16 = ICPU.Registers.AL | ((uint16_t) CheckCarry() << 8); + Work16 = ICPU.Registers.AL | ((uint16_t) CheckCarry() << 8); ICPU._Carry = (uint8_t) Work16 & 1; Work16 >>= 1; ICPU.Registers.AL = (uint8_t) Work16; SetZN8((uint8_t) Work16); } -static inline void ROR16() +static INLINE void ROR16() { + uint32_t Work32; + #ifndef SA1_OPCODES CPU.Cycles += ONE_CYCLE; #endif - uint32_t Work32 = S9xGetWord(OpAddress); + Work32 = S9xGetWord(OpAddress); Work32 |= (int32_t) CheckCarry() << 16; ICPU._Carry = (uint8_t)(Work32 & 1); Work32 >>= 1; @@ -526,12 +552,13 @@ static inline void ROR16() SetZN16((uint16_t) Work32); } -static inline void ROR8() +static INLINE void ROR8() { + uint16_t Work16; #ifndef SA1_OPCODES CPU.Cycles += ONE_CYCLE; #endif - uint16_t Work16 = S9xGetByte(OpAddress); + Work16 = S9xGetByte(OpAddress); Work16 |= (int32_t) CheckCarry() << 8; ICPU._Carry = (uint8_t)(Work16 & 1); Work16 >>= 1; @@ -539,12 +566,13 @@ static inline void ROR8() SetZN8((uint8_t) Work16); } -static inline void SBC16() +static INLINE void SBC16() { uint16_t Work16 = S9xGetWord(OpAddress); if (CheckDecimal()) { + uint16_t Ans16; uint16_t A1 = ICPU.Registers.A.W & 0x000f; uint16_t A2 = ICPU.Registers.A.W & 0x00f0; uint16_t A3 = ICPU.Registers.A.W & 0x0f00; @@ -585,7 +613,7 @@ static inline void SBC16() else SetCarry(); - uint16_t Ans16 = A4 | A3 | A2 | A1; + Ans16 = A4 | A3 | A2 | A1; if ((ICPU.Registers.A.W ^ Work16) & (ICPU.Registers.A.W ^ Ans16) & 0x8000) SetOverflow(); else @@ -605,11 +633,12 @@ static inline void SBC16() SetZN16(ICPU.Registers.A.W); } -static inline void SBC8() +static INLINE void SBC8() { uint8_t Work8 = S9xGetByte(OpAddress); if (CheckDecimal()) { + uint8_t Ans8; uint8_t A1 = ICPU.Registers.A.W & 0x0f; uint8_t A2 = ICPU.Registers.A.W & 0xf0; uint8_t W1 = Work8 & 0x0f; @@ -632,7 +661,7 @@ static inline void SBC8() else SetCarry(); - uint8_t Ans8 = A2 | A1; + Ans8 = A2 | A1; if ((ICPU.Registers.AL ^ Work8) & (ICPU.Registers.AL ^ Ans8) & 0x80) SetOverflow(); else @@ -652,87 +681,92 @@ static inline void SBC8() SetZN8(ICPU.Registers.AL); } -static inline void STA16() +static INLINE void STA16() { S9xSetWord(ICPU.Registers.A.W, OpAddress); } -static inline void STA8() +static INLINE void STA8() { S9xSetByte(ICPU.Registers.AL, OpAddress); } -static inline void STX16() +static INLINE void STX16() { S9xSetWord(ICPU.Registers.X.W, OpAddress); } -static inline void STX8() +static INLINE void STX8() { S9xSetByte(ICPU.Registers.XL, OpAddress); } -static inline void STY16() +static INLINE void STY16() { S9xSetWord(ICPU.Registers.Y.W, OpAddress); } -static inline void STY8() +static INLINE void STY8() { S9xSetByte(ICPU.Registers.YL, OpAddress); } -static inline void STZ16() +static INLINE void STZ16() { S9xSetWord(0, OpAddress); } -static inline void STZ8() +static INLINE void STZ8() { S9xSetByte(0, OpAddress); } -static inline void TSB16() +static INLINE void TSB16() { + uint16_t Work16; + #ifndef SA1_OPCODES CPU.Cycles += ONE_CYCLE; #endif - uint16_t Work16 = S9xGetWord(OpAddress); + Work16 = S9xGetWord(OpAddress); ICPU._Zero = (Work16 & ICPU.Registers.A.W) != 0; Work16 |= ICPU.Registers.A.W; S9xSetByte(Work16 >> 8, OpAddress + 1); S9xSetByte(Work16 & 0xFF, OpAddress); } -static inline void TSB8() +static INLINE void TSB8() { + uint8_t Work8; #ifndef SA1_OPCODES CPU.Cycles += ONE_CYCLE; #endif - uint8_t Work8 = S9xGetByte(OpAddress); + Work8 = S9xGetByte(OpAddress); ICPU._Zero = Work8 & ICPU.Registers.AL; Work8 |= ICPU.Registers.AL; S9xSetByte(Work8, OpAddress); } -static inline void TRB16() +static INLINE void TRB16() { + uint16_t Work16; #ifndef SA1_OPCODES CPU.Cycles += ONE_CYCLE; #endif - uint16_t Work16 = S9xGetWord(OpAddress); + Work16 = S9xGetWord(OpAddress); ICPU._Zero = (Work16 & ICPU.Registers.A.W) != 0; Work16 &= ~ICPU.Registers.A.W; S9xSetByte(Work16 >> 8, OpAddress + 1); S9xSetByte(Work16 & 0xFF, OpAddress); } -static inline void TRB8() +static INLINE void TRB8() { + uint8_t Work8; #ifndef SA1_OPCODES CPU.Cycles += ONE_CYCLE; #endif - uint8_t Work8 = S9xGetByte(OpAddress); + Work8 = S9xGetByte(OpAddress); ICPU._Zero = Work8 & ICPU.Registers.AL; Work8 &= ~ICPU.Registers.AL; S9xSetByte(Work8, OpAddress); |