diff options
author | Nebuleon Fumika | 2012-12-18 22:53:49 -0500 |
---|---|---|
committer | Nebuleon Fumika | 2012-12-18 22:53:49 -0500 |
commit | e708c127fa51beab567a9ce0e3ab53b58c997773 (patch) | |
tree | 647a8d7aa072ed1cb46ecfe800d4db85a155780d | |
parent | 286bfd58050a13e2e0e30bb35a7a1d189ec7edd1 (diff) | |
download | snes9x2005-e708c127fa51beab567a9ce0e3ab53b58c997773.tar.gz snes9x2005-e708c127fa51beab567a9ce0e3ab53b58c997773.tar.bz2 snes9x2005-e708c127fa51beab567a9ce0e3ab53b58c997773.zip |
Un-inline a bunch of stuff.
With the MIPS instruction cache, this means that two consecutive SNES CPU instructions using e.g. the same addressing style or the same opcode have a chance that the second one will use the first one's code and that it will be cached.
-rw-r--r-- | Makefile | 3 | ||||
-rw-r--r-- | source/apumem.h | 8 | ||||
-rw-r--r-- | source/cpuaddr.h | 44 | ||||
-rw-r--r-- | source/cpumacro.h | 124 | ||||
-rw-r--r-- | source/getset.h | 14 | ||||
-rw-r--r-- | source/memmap.cpp | 7 | ||||
-rw-r--r-- | source/ppu.cpp | 285 | ||||
-rw-r--r-- | source/ppu.h | 293 | ||||
-rw-r--r-- | source/sa1cpu.cpp | 63 | ||||
-rw-r--r-- | source/tile.cpp | 48 |
10 files changed, 483 insertions, 406 deletions
@@ -63,7 +63,8 @@ OBJECTS = $(C_OBJECTS) $(CPP_OBJECTS) # - - - Compilation flags - - -
CFLAGS := -mips32 -Os -mno-abicalls -fno-pic -fno-builtin \
-fno-exceptions -fno-function-sections -mlong-calls \
- -fomit-frame-pointer -msoft-float -G 4
+ -fomit-frame-pointer -msoft-float -G 4 \
+ -fno-inline -fno-early-inlining
DEFS := -DSPC700_C -DEXECUTE_SUPERFX_PER_LINE -DSDD1_DECOMP \
-DVAR_CYCLES -DCPU_SHUTDOWN -DSPC700_SHUTDOWN \
diff --git a/source/apumem.h b/source/apumem.h index 8f6dfa4..573b52c 100644 --- a/source/apumem.h +++ b/source/apumem.h @@ -95,7 +95,7 @@ extern uint8 W4; extern uint8 APUROM[64]; END_EXTERN_C -INLINE uint8 S9xAPUGetByteZ (uint8 Address) +uint8 S9xAPUGetByteZ (uint8 Address) { if (Address >= 0xf0 && IAPU.DirectPage == IAPU.RAM) { @@ -127,7 +127,7 @@ INLINE uint8 S9xAPUGetByteZ (uint8 Address) return (IAPU.DirectPage [Address]); } -INLINE void S9xAPUSetByteZ (uint8 byte, uint8 Address) +void S9xAPUSetByteZ (uint8 byte, uint8 Address) { if (Address >= 0xf0 && IAPU.DirectPage == IAPU.RAM) { @@ -156,7 +156,7 @@ INLINE void S9xAPUSetByteZ (uint8 byte, uint8 Address) IAPU.DirectPage [Address] = byte; } -INLINE uint8 S9xAPUGetByte (uint32 Address) +uint8 S9xAPUGetByte (uint32 Address) { Address &= 0xffff; @@ -189,7 +189,7 @@ INLINE uint8 S9xAPUGetByte (uint32 Address) return (IAPU.RAM [Address]); } -INLINE void S9xAPUSetByte (uint8 byte, uint32 Address) +void S9xAPUSetByte (uint8 byte, uint32 Address) { Address &= 0xffff; diff --git a/source/cpuaddr.h b/source/cpuaddr.h index a4c0ff4..76344db 100644 --- a/source/cpuaddr.h +++ b/source/cpuaddr.h @@ -100,19 +100,19 @@ typedef enum { JUMP = 4 } AccessMode; -STATIC inline void Immediate8 (AccessMode a) +void Immediate8 (AccessMode a) { OpAddress = ICPU.ShiftedPB + CPU.PC - CPU.PCBase; CPU.PC++; } -STATIC inline void Immediate16 (AccessMode a) +void Immediate16 (AccessMode a) { OpAddress = ICPU.ShiftedPB + CPU.PC - CPU.PCBase; CPU.PC += 2; } -STATIC inline void Relative (AccessMode a) +void Relative (AccessMode a) { Int8 = *CPU.PC++; #ifndef SA1_OPCODES @@ -121,7 +121,7 @@ STATIC inline void Relative (AccessMode a) OpAddress = ((int) (CPU.PC - CPU.PCBase) + Int8) & 0xffff; } -STATIC inline void RelativeLong (AccessMode a) +void RelativeLong (AccessMode a) { #ifdef FAST_LSB_WORD_ACCESS OpAddress = *(uint16 *) CPU.PC; @@ -136,7 +136,7 @@ STATIC inline void RelativeLong (AccessMode a) OpAddress &= 0xffff; } -STATIC inline void AbsoluteIndexedIndirect (AccessMode a) +void AbsoluteIndexedIndirect (AccessMode a) { #ifdef FAST_LSB_WORD_ACCESS OpAddress = (Registers.X.W + *(uint16 *) CPU.PC) & 0xffff; @@ -152,7 +152,7 @@ STATIC inline void AbsoluteIndexedIndirect (AccessMode a) if(a&READ) OpenBus = (uint8)(OpAddress>>8); } -STATIC inline void AbsoluteIndirectLong (AccessMode a) +void AbsoluteIndirectLong (AccessMode a) { #ifdef FAST_LSB_WORD_ACCESS OpAddress = *(uint16 *) CPU.PC; @@ -172,7 +172,7 @@ STATIC inline void AbsoluteIndirectLong (AccessMode a) } } -STATIC inline void AbsoluteIndirect (AccessMode a) +void AbsoluteIndirect (AccessMode a) { #ifdef FAST_LSB_WORD_ACCESS OpAddress = *(uint16 *) CPU.PC; @@ -190,7 +190,7 @@ STATIC inline void AbsoluteIndirect (AccessMode a) OpAddress += ICPU.ShiftedPB; } -STATIC inline void Absolute (AccessMode a) +void Absolute (AccessMode a) { #ifdef FAST_LSB_WORD_ACCESS OpAddress = *(uint16 *) CPU.PC + ICPU.ShiftedDB; @@ -204,7 +204,7 @@ STATIC inline void Absolute (AccessMode a) #endif } -STATIC inline void AbsoluteLong (AccessMode a) +void AbsoluteLong (AccessMode a) { #ifdef FAST_LSB_WORD_ACCESS OpAddress = (*(uint32 *) CPU.PC) & 0xffffff; @@ -218,7 +218,7 @@ STATIC inline void AbsoluteLong (AccessMode a) #endif } -STATIC inline void Direct(AccessMode a) +void Direct(AccessMode a) { if(a&READ) OpenBus = *CPU.PC; OpAddress = (*CPU.PC++ + Registers.D.W) & 0xffff; @@ -228,7 +228,7 @@ STATIC inline void Direct(AccessMode a) // if (Registers.DL != 0) CPU.Cycles += ONE_CYCLE; } -STATIC inline void DirectIndirectIndexed (AccessMode a) +void DirectIndirectIndexed (AccessMode a) { OpenBus = *CPU.PC; OpAddress = (*CPU.PC++ + Registers.D.W) & 0xffff; @@ -245,7 +245,7 @@ STATIC inline void DirectIndirectIndexed (AccessMode a) // XXX: else Add one cycle if crosses page boundary } -STATIC inline void DirectIndirectIndexedLong (AccessMode a) +void DirectIndirectIndexedLong (AccessMode a) { OpenBus = *CPU.PC; OpAddress = (*CPU.PC++ + Registers.D.W) & 0xffff; @@ -261,7 +261,7 @@ STATIC inline void DirectIndirectIndexedLong (AccessMode a) // if (Registers.DL != 0) CPU.Cycles += ONE_CYCLE; } -STATIC inline void DirectIndexedIndirect(AccessMode a) +void DirectIndexedIndirect(AccessMode a) { OpenBus = *CPU.PC; OpAddress = (*CPU.PC++ + Registers.D.W + Registers.X.W) & 0xffff; @@ -281,7 +281,7 @@ STATIC inline void DirectIndexedIndirect(AccessMode a) #endif } -STATIC inline void DirectIndexedX (AccessMode a) +void DirectIndexedX (AccessMode a) { if(a&READ) OpenBus = *CPU.PC; OpAddress = (*CPU.PC++ + Registers.D.W + Registers.X.W); @@ -299,7 +299,7 @@ STATIC inline void DirectIndexedX (AccessMode a) #endif } -STATIC inline void DirectIndexedY (AccessMode a) +void DirectIndexedY (AccessMode a) { if(a&READ) OpenBus = *CPU.PC; OpAddress = (*CPU.PC++ + Registers.D.W + Registers.Y.W); @@ -316,7 +316,7 @@ STATIC inline void DirectIndexedY (AccessMode a) #endif } -STATIC inline void AbsoluteIndexedX (AccessMode a) +void AbsoluteIndexedX (AccessMode a) { #ifdef FAST_LSB_WORD_ACCESS OpAddress = ICPU.ShiftedDB + *(uint16 *) CPU.PC + Registers.X.W; @@ -333,7 +333,7 @@ STATIC inline void AbsoluteIndexedX (AccessMode a) // XXX: else is cross page boundary add one cycle } -STATIC inline void AbsoluteIndexedY (AccessMode a) +void AbsoluteIndexedY (AccessMode a) { #ifdef FAST_LSB_WORD_ACCESS OpAddress = ICPU.ShiftedDB + *(uint16 *) CPU.PC + Registers.Y.W; @@ -350,7 +350,7 @@ STATIC inline void AbsoluteIndexedY (AccessMode a) // XXX: else is cross page boundary add one cycle } -STATIC inline void AbsoluteLongIndexedX (AccessMode a) +void AbsoluteLongIndexedX (AccessMode a) { #ifdef FAST_LSB_WORD_ACCESS OpAddress = (*(uint32 *) CPU.PC + Registers.X.W) & 0xffffff; @@ -364,7 +364,7 @@ STATIC inline void AbsoluteLongIndexedX (AccessMode a) #endif } -STATIC inline void DirectIndirect (AccessMode a) +void DirectIndirect (AccessMode a) { OpenBus = *CPU.PC; OpAddress = (*CPU.PC++ + Registers.D.W) & 0xffff; @@ -378,7 +378,7 @@ STATIC inline void DirectIndirect (AccessMode a) // if (Registers.DL != 0) CPU.Cycles += ONE_CYCLE; } -STATIC inline void DirectIndirectLong (AccessMode a) +void DirectIndirectLong (AccessMode a) { OpenBus = *CPU.PC; OpAddress = (*CPU.PC++ + Registers.D.W) & 0xffff; @@ -393,7 +393,7 @@ STATIC inline void DirectIndirectLong (AccessMode a) // if (Registers.DL != 0) CPU.Cycles += ONE_CYCLE; } -STATIC inline void StackRelative (AccessMode a) +void StackRelative (AccessMode a) { if(a&READ) OpenBus = *CPU.PC; OpAddress = (*CPU.PC++ + Registers.S.W) & 0xffff; @@ -403,7 +403,7 @@ STATIC inline void StackRelative (AccessMode a) #endif } -STATIC inline void StackRelativeIndirectIndexed (AccessMode a) +void StackRelativeIndirectIndexed (AccessMode a) { OpenBus = *CPU.PC; OpAddress = (*CPU.PC++ + Registers.S.W) & 0xffff; diff --git a/source/cpumacro.h b/source/cpumacro.h index d97aa53..5b4e15b 100644 --- a/source/cpumacro.h +++ b/source/cpumacro.h @@ -90,19 +90,19 @@ #ifndef _CPUMACRO_H_ #define _CPUMACRO_H_ -STATIC inline void SetZN16 (uint16 Work) +void SetZN16 (uint16 Work) { ICPU._Zero = Work != 0; ICPU._Negative = (uint8) (Work >> 8); } -STATIC inline void SetZN8 (uint8 Work) +void SetZN8 (uint8 Work) { ICPU._Zero = Work; ICPU._Negative = Work; } -STATIC inline void ADC8 () +void ADC8 () { Work8 = S9xGetByte (OpAddress); @@ -159,7 +159,7 @@ STATIC inline void ADC8 () } } -STATIC inline void ADC16 () +void ADC16 () { Work16 = S9xGetWord (OpAddress); @@ -235,19 +235,19 @@ STATIC inline void ADC16 () } } -STATIC inline void AND16 () +void AND16 () { Registers.A.W &= S9xGetWord (OpAddress); SetZN16 (Registers.A.W); } -STATIC inline void AND8 () +void AND8 () { Registers.AL &= S9xGetByte (OpAddress); SetZN8 (Registers.AL); } -STATIC inline void A_ASL16 () +void A_ASL16 () { #ifndef SA1_OPCODES CPU.Cycles += ONE_CYCLE; @@ -257,7 +257,7 @@ STATIC inline void A_ASL16 () SetZN16 (Registers.A.W); } -STATIC inline void A_ASL8 () +void A_ASL8 () { #ifndef SA1_OPCODES CPU.Cycles += ONE_CYCLE; @@ -267,7 +267,7 @@ STATIC inline void A_ASL8 () SetZN8 (Registers.AL); } -STATIC inline void ASL16 () +void ASL16 () { #ifndef SA1_OPCODES CPU.Cycles += ONE_CYCLE; @@ -281,7 +281,7 @@ STATIC inline void ASL16 () SetZN16 (Work16); } -STATIC inline void ASL8 () +void ASL8 () { #ifndef SA1_OPCODES CPU.Cycles += ONE_CYCLE; @@ -293,7 +293,7 @@ STATIC inline void ASL8 () SetZN8 (Work8); } -STATIC inline void BIT16 () +void BIT16 () { Work16 = S9xGetWord (OpAddress); ICPU._Overflow = (Work16 & 0x4000) != 0; @@ -301,7 +301,7 @@ STATIC inline void BIT16 () ICPU._Zero = (Work16 & Registers.A.W) != 0; } -STATIC inline void BIT8 () +void BIT8 () { Work8 = S9xGetByte (OpAddress); ICPU._Overflow = (Work8 & 0x40) != 0; @@ -309,7 +309,7 @@ STATIC inline void BIT8 () ICPU._Zero = Work8 & Registers.AL; } -STATIC inline void CMP16 () +void CMP16 () { Int32 = (long) Registers.A.W - (long) S9xGetWord (OpAddress); @@ -317,7 +317,7 @@ STATIC inline void CMP16 () SetZN16 ((uint16) Int32); } -STATIC inline void CMP8 () +void CMP8 () { Int16 = (short) Registers.AL - (short) S9xGetByte (OpAddress); @@ -325,7 +325,7 @@ STATIC inline void CMP8 () SetZN8 ((uint8) Int16); } -STATIC inline void CMX16 () +void CMX16 () { Int32 = (long) Registers.X.W - (long) S9xGetWord (OpAddress); @@ -333,7 +333,7 @@ STATIC inline void CMX16 () SetZN16 ((uint16) Int32); } -STATIC inline void CMX8 () +void CMX8 () { Int16 = (short) Registers.XL - (short) S9xGetByte (OpAddress); @@ -341,7 +341,7 @@ STATIC inline void CMX8 () SetZN8 ((uint8) Int16); } -STATIC inline void CMY16 () +void CMY16 () { Int32 = (long) Registers.Y.W - (long) S9xGetWord (OpAddress); @@ -349,7 +349,7 @@ STATIC inline void CMY16 () SetZN16 ((uint16) Int32); } -STATIC inline void CMY8 () +void CMY8 () { Int16 = (short) Registers.YL - (short) S9xGetByte (OpAddress); @@ -357,7 +357,7 @@ STATIC inline void CMY8 () SetZN8 ((uint8) Int16); } -STATIC inline void A_DEC16 () +void A_DEC16 () { #ifndef SA1_OPCODES CPU.Cycles += ONE_CYCLE; @@ -370,7 +370,7 @@ STATIC inline void A_DEC16 () SetZN16 (Registers.A.W); } -STATIC inline void A_DEC8 () +void A_DEC8 () { #ifndef SA1_OPCODES CPU.Cycles += ONE_CYCLE; @@ -383,7 +383,7 @@ STATIC inline void A_DEC8 () SetZN8 (Registers.AL); } -STATIC inline void DEC16 () +void DEC16 () { #ifndef SA1_OPCODES CPU.Cycles += ONE_CYCLE; @@ -399,7 +399,7 @@ STATIC inline void DEC16 () SetZN16 (Work16); } -STATIC inline void DEC8 () +void DEC8 () { #ifndef SA1_OPCODES CPU.Cycles += ONE_CYCLE; @@ -413,19 +413,19 @@ STATIC inline void DEC8 () SetZN8 (Work8); } -STATIC inline void EOR16 () +void EOR16 () { Registers.A.W ^= S9xGetWord (OpAddress); SetZN16 (Registers.A.W); } -STATIC inline void EOR8 () +void EOR8 () { Registers.AL ^= S9xGetByte (OpAddress); SetZN8 (Registers.AL); } -STATIC inline void A_INC16 () +void A_INC16 () { #ifndef SA1_OPCODES CPU.Cycles += ONE_CYCLE; @@ -438,7 +438,7 @@ STATIC inline void A_INC16 () SetZN16 (Registers.A.W); } -STATIC inline void A_INC8 () +void A_INC8 () { #ifndef SA1_OPCODES CPU.Cycles += ONE_CYCLE; @@ -451,7 +451,7 @@ STATIC inline void A_INC8 () SetZN8 (Registers.AL); } -STATIC inline void INC16 () +void INC16 () { #ifndef SA1_OPCODES CPU.Cycles += ONE_CYCLE; @@ -467,7 +467,7 @@ STATIC inline void INC16 () SetZN16 (Work16); } -STATIC inline void INC8 () +void INC8 () { #ifndef SA1_OPCODES CPU.Cycles += ONE_CYCLE; @@ -481,43 +481,43 @@ STATIC inline void INC8 () SetZN8 (Work8); } -STATIC inline void LDA16 () +void LDA16 () { Registers.A.W = S9xGetWord (OpAddress); SetZN16 (Registers.A.W); } -STATIC inline void LDA8 () +void LDA8 () { Registers.AL = S9xGetByte (OpAddress); SetZN8 (Registers.AL); } -STATIC inline void LDX16 () +void LDX16 () { Registers.X.W = S9xGetWord (OpAddress); SetZN16 (Registers.X.W); } -STATIC inline void LDX8 () +void LDX8 () { Registers.XL = S9xGetByte (OpAddress); SetZN8 (Registers.XL); } -STATIC inline void LDY16 () +void LDY16 () { Registers.Y.W = S9xGetWord (OpAddress); SetZN16 (Registers.Y.W); } -STATIC inline void LDY8 () +void LDY8 () { Registers.YL = S9xGetByte (OpAddress); SetZN8 (Registers.YL); } -STATIC inline void A_LSR16 () +void A_LSR16 () { #ifndef SA1_OPCODES CPU.Cycles += ONE_CYCLE; @@ -527,7 +527,7 @@ STATIC inline void A_LSR16 () SetZN16 (Registers.A.W); } -STATIC inline void A_LSR8 () +void A_LSR8 () { #ifndef SA1_OPCODES CPU.Cycles += ONE_CYCLE; @@ -537,7 +537,7 @@ STATIC inline void A_LSR8 () SetZN8 (Registers.AL); } -STATIC inline void LSR16 () +void LSR16 () { #ifndef SA1_OPCODES CPU.Cycles += ONE_CYCLE; @@ -551,7 +551,7 @@ STATIC inline void LSR16 () SetZN16 (Work16); } -STATIC inline void LSR8 () +void LSR8 () { #ifndef SA1_OPCODES CPU.Cycles += ONE_CYCLE; @@ -563,19 +563,19 @@ STATIC inline void LSR8 () SetZN8 (Work8); } -STATIC inline void ORA16 () +void ORA16 () { Registers.A.W |= S9xGetWord (OpAddress); SetZN16 (Registers.A.W); } -STATIC inline void ORA8 () +void ORA8 () { Registers.AL |= S9xGetByte (OpAddress); SetZN8 (Registers.AL); } -STATIC inline void A_ROL16 () +void A_ROL16 () { #ifndef SA1_OPCODES CPU.Cycles += ONE_CYCLE; @@ -586,7 +586,7 @@ STATIC inline void A_ROL16 () SetZN16 ((uint16) Work32); } -STATIC inline void A_ROL8 () +void A_ROL8 () { #ifndef SA1_OPCODES CPU.Cycles += ONE_CYCLE; @@ -599,7 +599,7 @@ STATIC inline void A_ROL8 () SetZN8 ((uint8) Work16); } -STATIC inline void ROL16 () +void ROL16 () { #ifndef SA1_OPCODES CPU.Cycles += ONE_CYCLE; @@ -614,7 +614,7 @@ STATIC inline void ROL16 () SetZN16 ((uint16) Work32); } -STATIC inline void ROL8 () +void ROL8 () { #ifndef SA1_OPCODES CPU.Cycles += ONE_CYCLE; @@ -627,7 +627,7 @@ STATIC inline void ROL8 () SetZN8 ((uint8) Work16); } -STATIC inline void A_ROR16 () +void A_ROR16 () { #ifndef SA1_OPCODES CPU.Cycles += ONE_CYCLE; @@ -640,7 +640,7 @@ STATIC inline void A_ROR16 () SetZN16 ((uint16) Work32); } -STATIC inline void A_ROR8 () +void A_ROR8 () { #ifndef SA1_OPCODES CPU.Cycles += ONE_CYCLE; @@ -652,7 +652,7 @@ STATIC inline void A_ROR8 () SetZN8 ((uint8) Work16); } -STATIC inline void ROR16 () +void ROR16 () { #ifndef SA1_OPCODES CPU.Cycles += ONE_CYCLE; @@ -667,7 +667,7 @@ STATIC inline void ROR16 () SetZN16 ((uint16) Work32); } -STATIC inline void ROR8 () +void ROR8 () { #ifndef SA1_OPCODES CPU.Cycles += ONE_CYCLE; @@ -680,7 +680,7 @@ STATIC inline void ROR8 () SetZN8 ((uint8) Work16); } -STATIC inline void SBC16 () +void SBC16 () { Work16 = S9xGetWord (OpAddress); @@ -750,7 +750,7 @@ STATIC inline void SBC16 () } } -STATIC inline void SBC8 () +void SBC8 () { Work8 = S9xGetByte (OpAddress); if (CheckDecimal ()) @@ -801,47 +801,47 @@ STATIC inline void SBC8 () } } -STATIC inline void STA16 () +void STA16 () { S9xSetWord (Registers.A.W, OpAddress); } -STATIC inline void STA8 () +void STA8 () { S9xSetByte (Registers.AL, OpAddress); } -STATIC inline void STX16 () +void STX16 () { S9xSetWord (Registers.X.W, OpAddress); } -STATIC inline void STX8 () +void STX8 () { S9xSetByte (Registers.XL, OpAddress); } -STATIC inline void STY16 () +void STY16 () { S9xSetWord (Registers.Y.W, OpAddress); } -STATIC inline void STY8 () +void STY8 () { S9xSetByte (Registers.YL, OpAddress); } -STATIC inline void STZ16 () +void STZ16 () { S9xSetWord (0, OpAddress); } -STATIC inline void STZ8 () +void STZ8 () { S9xSetByte (0, OpAddress); } -STATIC inline void TSB16 () +void TSB16 () { #ifndef SA1_OPCODES CPU.Cycles += ONE_CYCLE; @@ -854,7 +854,7 @@ STATIC inline void TSB16 () S9xSetByte (Work16&0xFF, OpAddress); } -STATIC inline void TSB8 () +void TSB8 () { #ifndef SA1_OPCODES CPU.Cycles += ONE_CYCLE; @@ -865,7 +865,7 @@ STATIC inline void TSB8 () S9xSetByte (Work8, OpAddress); } -STATIC inline void TRB16 () +void TRB16 () { #ifndef SA1_OPCODES CPU.Cycles += ONE_CYCLE; @@ -878,7 +878,7 @@ STATIC inline void TRB16 () S9xSetByte (Work16&0xFF, OpAddress); } -STATIC inline void TRB8 () +void TRB8 () { #ifndef SA1_OPCODES CPU.Cycles += ONE_CYCLE; diff --git a/source/getset.h b/source/getset.h index 2368ac2..f04bf95 100644 --- a/source/getset.h +++ b/source/getset.h @@ -103,7 +103,7 @@ extern "C" extern uint8 OpenBus; } -INLINE uint8 S9xGetByte (uint32 Address) +uint8 S9xGetByte (uint32 Address) { int block; uint8 *GetAddress = Memory.Map [block = (Address >> MEMMAP_SHIFT) & MEMMAP_MASK]; @@ -197,7 +197,7 @@ INLINE uint8 S9xGetByte (uint32 Address) } } -INLINE uint16 S9xGetWord (uint32 Address) +uint16 S9xGetWord (uint32 Address) { if ((Address & 0x0fff) == 0x0fff) { @@ -320,7 +320,7 @@ INLINE uint16 S9xGetWord (uint32 Address) } } -INLINE void S9xSetByte (uint8 Byte, uint32 Address) +void S9xSetByte (uint8 Byte, uint32 Address) { #if defined(CPU_SHUTDOWN) CPU.WaitAddress = NULL; @@ -436,7 +436,7 @@ INLINE void S9xSetByte (uint8 Byte, uint32 Address) } } -INLINE void S9xSetWord (uint16 Word, uint32 Address) +void S9xSetWord (uint16 Word, uint32 Address) { if((Address & 0x0FFF)==0x0FFF) { @@ -594,7 +594,7 @@ INLINE void S9xSetWord (uint16 Word, uint32 Address) } } -INLINE uint8 *GetBasePointer (uint32 Address) +uint8 *GetBasePointer (uint32 Address) { uint8 *GetAddress = Memory.Map [(Address >> MEMMAP_SHIFT) & MEMMAP_MASK]; if (GetAddress >= (uint8 *) CMemory::MAP_LAST) @@ -660,7 +660,7 @@ INLINE uint8 *GetBasePointer (uint32 Address) } } -INLINE uint8 *S9xGetMemPointer (uint32 Address) +uint8 *S9xGetMemPointer (uint32 Address) { uint8 *GetAddress = Memory.Map [(Address >> MEMMAP_SHIFT) & MEMMAP_MASK]; if (GetAddress >= (uint8 *) CMemory::MAP_LAST) @@ -714,7 +714,7 @@ INLINE uint8 *S9xGetMemPointer (uint32 Address) } } -INLINE void S9xSetPCBase (uint32 Address) +void S9xSetPCBase (uint32 Address) { int block; uint8 *GetAddress = Memory.Map [block = (Address >> MEMMAP_SHIFT) & MEMMAP_MASK]; diff --git a/source/memmap.cpp b/source/memmap.cpp index 65b8739..e378601 100644 --- a/source/memmap.cpp +++ b/source/memmap.cpp @@ -146,7 +146,7 @@ int is_bsx(unsigned char *); int bs_name(unsigned char *); int check_char(unsigned); void S9xDeinterleaveType2 (bool8 reset=TRUE); -inline uint32 caCRC32(uint8 *array, uint32 size, register uint32 crc32 = 0xFFFFFFFF); +uint32 caCRC32(uint8 *array, uint32 size, register uint32 crc32 = 0xFFFFFFFF); extern char *rom_filename; @@ -395,10 +395,11 @@ char *CMemory::Safe (const char *s) /**********************************************************************************************/ /* Init() */ -/* This function allocates all the memory needed by the emulator */ +/* This function allocates and zeroes all the memory needed by the emulator */ /**********************************************************************************************/ bool8 CMemory::Init () { + // memset? Really? We could just memcpy after the first allocation... [Neb] RAM = (uint8 *) malloc (0x20000); SRAM = (uint8 *) malloc (0x20000); VRAM = (uint8 *) malloc (0x10000); @@ -1213,7 +1214,7 @@ void S9xDeinterleaveType2 (bool8 reset) } //CRC32 for char arrays -inline uint32 caCRC32(uint8 *array, uint32 size, register uint32 crc32) +uint32 caCRC32(uint8 *array, uint32 size, register uint32 crc32) { for (register uint32 i = 0; i < size; i++) { diff --git a/source/ppu.cpp b/source/ppu.cpp index fc0bd51..389bdd2 100644 --- a/source/ppu.cpp +++ b/source/ppu.cpp @@ -117,7 +117,7 @@ uint8 in_bit=0; extern uint8 *HDMAMemPointers [8]; -static inline void S9xLatchCounters (bool force) +void S9xLatchCounters (bool force) { if(!force && !(Memory.FillRAM[0x4213] & 0x80)) return; @@ -3297,3 +3297,286 @@ printf ("%06x: %d\n", t, FxEmulate (2000000)); } #endif +// Register reads and writes... + +uint8 REGISTER_4212() +{ + GetBank = 0; + if (CPU.V_Counter >= PPU.ScreenHeight + FIRST_VISIBLE_LINE && + CPU.V_Counter < PPU.ScreenHeight + FIRST_VISIBLE_LINE + 3) + GetBank = 1; + + GetBank |= CPU.Cycles >= Settings.HBlankStart ? 0x40 : 0; + if (CPU.V_Counter >= PPU.ScreenHeight + FIRST_VISIBLE_LINE) + GetBank |= 0x80; /* XXX: 0x80 or 0xc0 ? */ + + return (GetBank); +} + +void FLUSH_REDRAW () +{ + if (IPPU.PreviousLine != IPPU.CurrentLine) + S9xUpdateScreen (); +} + +void REGISTER_2104 (uint8 byte) +{ + if (PPU.OAMAddr & 0x100) + { + int addr = ((PPU.OAMAddr & 0x10f) << 1) + (PPU.OAMFlip & 1); + if (byte != PPU.OAMData [addr]){ + FLUSH_REDRAW (); + PPU.OAMData [addr] = byte; + IPPU.OBJChanged = TRUE; + + // X position high bit, and sprite size (x4) + struct SOBJ *pObj = &PPU.OBJ [(addr & 0x1f) * 4]; + + pObj->HPos = (pObj->HPos & 0xFF) | SignExtend[(byte >> 0) & 1]; + pObj++->Size = byte & 2; + pObj->HPos = (pObj->HPos & 0xFF) | SignExtend[(byte >> 2) & 1]; + pObj++->Size = byte & 8; + pObj->HPos = (pObj->HPos & 0xFF) | SignExtend[(byte >> 4) & 1]; + pObj++->Size = byte & 32; + pObj->HPos = (pObj->HPos & 0xFF) | SignExtend[(byte >> 6) & 1]; + pObj->Size = byte & 128; + } + PPU.OAMFlip ^= 1; + if(!(PPU.OAMFlip & 1)){ + ++PPU.OAMAddr; + PPU.OAMAddr &= 0x1ff; + if (PPU.OAMPriorityRotation && PPU.FirstSprite != (PPU.OAMAddr >> 1)) + { + PPU.FirstSprite = (PPU.OAMAddr&0xFE) >> 1; + IPPU.OBJChanged = TRUE; + } + } else { + if (PPU.OAMPriorityRotation && (PPU.OAMAddr&1)) IPPU.OBJChanged = TRUE; + } + } else if(!(PPU.OAMFlip & 1)){ + PPU.OAMWriteRegister &= 0xff00; + PPU.OAMWriteRegister |= byte; + PPU.OAMFlip |= 1; + if (PPU.OAMPriorityRotation && (PPU.OAMAddr&1)) IPPU.OBJChanged = TRUE; + } else { + PPU.OAMWriteRegister &= 0x00ff; + uint8 lowbyte = (uint8)(PPU.OAMWriteRegister); + uint8 highbyte = byte; + PPU.OAMWriteRegister |= byte << 8; + + int addr = (PPU.OAMAddr << 1); + + if (lowbyte != PPU.OAMData [addr] || + highbyte != PPU.OAMData [addr+1]) + { + FLUSH_REDRAW (); + PPU.OAMData [addr] = lowbyte; + PPU.OAMData [addr+1] = highbyte; + IPPU.OBJChanged = TRUE; + if (addr & 2) + { + // Tile + PPU.OBJ[addr = PPU.OAMAddr >> 1].Name = PPU.OAMWriteRegister & 0x1ff; + + // priority, h and v flip. + PPU.OBJ[addr].Palette = (highbyte >> 1) & 7; + PPU.OBJ[addr].Priority = (highbyte >> 4) & 3; + PPU.OBJ[addr].HFlip = (highbyte >> 6) & 1; + PPU.OBJ[addr].VFlip = (highbyte >> 7) & 1; + } + else + { + // X position (low) + PPU.OBJ[addr = PPU.OAMAddr >> 1].HPos &= 0xFF00; + PPU.OBJ[addr].HPos |= lowbyte; + + // Sprite Y position + PPU.OBJ[addr].VPos = highbyte; + } + } + PPU.OAMFlip &= ~1; + ++PPU.OAMAddr; + if (PPU.OAMPriorityRotation && PPU.FirstSprite != (PPU.OAMAddr >> 1)) + { + PPU.FirstSprite = (PPU.OAMAddr&0xFE) >> 1; + IPPU.OBJChanged = TRUE; + } + } + + Memory.FillRAM [0x2104] = byte; +} + +void REGISTER_2118 (uint8 Byte) +{ + uint32 address; + if (PPU.VMA.FullGraphicCount) + { + uint32 rem = PPU.VMA.Address & PPU.VMA.Mask1; + address = (((PPU.VMA.Address & ~PPU.VMA.Mask1) + + (rem >> PPU.VMA.Shift) + + ((rem & (PPU.VMA.FullGraphicCount - 1)) << 3)) << 1) & 0xffff; + Memory.VRAM [address] = Byte; + } + else + { + Memory.VRAM[address = (PPU.VMA.Address << 1) & 0xFFFF] = Byte; + } + IPPU.TileCached [TILE_2BIT][address >> 4] = FALSE; + IPPU.TileCached [TILE_4BIT][address >> 5] = FALSE; + IPPU.TileCached [TILE_8BIT][address >> 6] = FALSE; + if (!PPU.VMA.High) + { +#ifdef DEBUGGER + if (Settings.TraceVRAM && !CPU.InDMA) + { + printf ("VRAM write byte: $%04X (%d,%d)\n", PPU.VMA.Address, + Memory.FillRAM[0x2115] & 3, + (Memory.FillRAM [0x2115] & 0x0c) >> 2); + } +#endif + PPU.VMA.Address += PPU.VMA.Increment; + } +// Memory.FillRAM [0x2118] = Byte; +} + +void REGISTER_2118_tile (uint8 Byte) +{ + uint32 address; + uint32 rem = PPU.VMA.Address & PPU.VMA.Mask1; + address = (((PPU.VMA.Address & ~PPU.VMA.Mask1) + + (rem >> PPU.VMA.Shift) + + ((rem & (PPU.VMA.FullGraphicCount - 1)) << 3)) << 1) & 0xffff; + Memory.VRAM [address] = Byte; + IPPU.TileCached [TILE_2BIT][address >> 4] = FALSE; + IPPU.TileCached [TILE_4BIT][address >> 5] = FALSE; + IPPU.TileCached [TILE_8BIT][address >> 6] = FALSE; + if (!PPU.VMA.High) + PPU.VMA.Address += PPU.VMA.Increment; +// Memory.FillRAM [0x2118] = Byte; +} + +void REGISTER_2118_linear (uint8 Byte) +{ + uint32 address; + Memory.VRAM[address = (PPU.VMA.Address << 1) & 0xFFFF] = Byte; + IPPU.TileCached [TILE_2BIT][address >> 4] = FALSE; + IPPU.TileCached [TILE_4BIT][address >> 5] = FALSE; + IPPU.TileCached [TILE_8BIT][address >> 6] = FALSE; + if (!PPU.VMA.High) + PPU.VMA.Address += PPU.VMA.Increment; +// Memory.FillRAM [0x2118] = Byte; +} + +void REGISTER_2119 (uint8 Byte) +{ + uint32 address; + if (PPU.VMA.FullGraphicCount) + { + uint32 rem = PPU.VMA.Address & PPU.VMA.Mask1; + address = ((((PPU.VMA.Address & ~PPU.VMA.Mask1) + + (rem >> PPU.VMA.Shift) + + ((rem & (PPU.VMA.FullGraphicCount - 1)) << 3)) << 1) + 1) & 0xFFFF; + Memory.VRAM [address] = Byte; + } + else + { + Memory.VRAM[address = ((PPU.VMA.Address << 1) + 1) & 0xFFFF] = Byte; + } + IPPU.TileCached [TILE_2BIT][address >> 4] = FALSE; + IPPU.TileCached [TILE_4BIT][address >> 5] = FALSE; + IPPU.TileCached [TILE_8BIT][address >> 6] = FALSE; + if (PPU.VMA.High) + { +#ifdef DEBUGGER + if (Settings.TraceVRAM && !CPU.InDMA) + { + printf ("VRAM write word: $%04X (%d,%d)\n", PPU.VMA.Address, + Memory.FillRAM[0x2115] & 3, + (Memory.FillRAM [0x2115] & 0x0c) >> 2); + } +#endif + PPU.VMA.Address += PPU.VMA.Increment; + } +// Memory.FillRAM [0x2119] = Byte; +} + +void REGISTER_2119_tile (uint8 Byte) +{ + uint32 rem = PPU.VMA.Address & PPU.VMA.Mask1; + uint32 address = ((((PPU.VMA.Address & ~PPU.VMA.Mask1) + + (rem >> PPU.VMA.Shift) + + ((rem & (PPU.VMA.FullGraphicCount - 1)) << 3)) << 1) + 1) & 0xFFFF; + Memory.VRAM [address] = Byte; + IPPU.TileCached [TILE_2BIT][address >> 4] = FALSE; + IPPU.TileCached [TILE_4BIT][address >> 5] = FALSE; + IPPU.TileCached [TILE_8BIT][address >> 6] = FALSE; + if (PPU.VMA.High) + PPU.VMA.Address += PPU.VMA.Increment; +// Memory.FillRAM [0x2119] = Byte; +} + +void REGISTER_2119_linear (uint8 Byte) +{ + uint32 address; + Memory.VRAM[address = ((PPU.VMA.Address << 1) + 1) & 0xFFFF] = Byte; + IPPU.TileCached [TILE_2BIT][address >> 4] = FALSE; + IPPU.TileCached [TILE_4BIT][address >> 5] = FALSE; + IPPU.TileCached [TILE_8BIT][address >> 6] = FALSE; + if (PPU.VMA.High) + PPU.VMA.Address += PPU.VMA.Increment; +// Memory.FillRAM [0x2119] = Byte; +} + +void REGISTER_2122(uint8 Byte) +{ + // CG-RAM (palette) write + + if (PPU.CGFLIP) + { + if ((Byte & 0x7f) != (PPU.CGDATA[PPU.CGADD] >> 8)) + { + if (Settings.SixteenBit) + FLUSH_REDRAW (); + PPU.CGDATA[PPU.CGADD] &= 0x00FF; + PPU.CGDATA[PPU.CGADD] |= (Byte & 0x7f) << 8; + IPPU.ColorsChanged = TRUE; + if (Settings.SixteenBit) + { + IPPU.Blue [PPU.CGADD] = IPPU.XB [(Byte >> 2) & 0x1f]; + IPPU.Green [PPU.CGADD] = IPPU.XB [(PPU.CGDATA[PPU.CGADD] >> 5) & 0x1f]; + IPPU.ScreenColors [PPU.CGADD] = (uint16) BUILD_PIXEL (IPPU.Red [PPU.CGADD], + IPPU.Green [PPU.CGADD], + IPPU.Blue [PPU.CGADD]); + } + } + PPU.CGADD++; + } + else + { + if (Byte != (uint8) (PPU.CGDATA[PPU.CGADD] & 0xff)) + { + if (Settings.SixteenBit) + FLUSH_REDRAW (); + PPU.CGDATA[PPU.CGADD] &= 0x7F00; + PPU.CGDATA[PPU.CGADD] |= Byte; + IPPU.ColorsChanged = TRUE; + if (Settings.SixteenBit) + { + IPPU.Red [PPU.CGADD] = IPPU.XB [Byte & 0x1f]; + IPPU.Green [PPU.CGADD] = IPPU.XB [(PPU.CGDATA[PPU.CGADD] >> 5) & 0x1f]; + IPPU.ScreenColors [PPU.CGADD] = (uint16) BUILD_PIXEL (IPPU.Red [PPU.CGADD], + IPPU.Green [PPU.CGADD], + IPPU.Blue [PPU.CGADD]); + } + } + } + PPU.CGFLIP ^= 1; +// Memory.FillRAM [0x2122] = Byte; +} + +void REGISTER_2180(uint8 Byte) +{ + Memory.RAM[PPU.WRAM++] = Byte; + PPU.WRAM &= 0x1FFFF; + Memory.FillRAM [0x2180] = Byte; +} diff --git a/source/ppu.h b/source/ppu.h index 99dde34..5a889ef 100644 --- a/source/ppu.h +++ b/source/ppu.h @@ -342,288 +342,17 @@ END_EXTERN_C #define MAX_5C78_VERSION 0x03 #define MAX_5A22_VERSION 0x02 -STATIC inline uint8 REGISTER_4212() -{ - GetBank = 0; - if (CPU.V_Counter >= PPU.ScreenHeight + FIRST_VISIBLE_LINE && - CPU.V_Counter < PPU.ScreenHeight + FIRST_VISIBLE_LINE + 3) - GetBank = 1; - - GetBank |= CPU.Cycles >= Settings.HBlankStart ? 0x40 : 0; - if (CPU.V_Counter >= PPU.ScreenHeight + FIRST_VISIBLE_LINE) - GetBank |= 0x80; /* XXX: 0x80 or 0xc0 ? */ - - return (GetBank); -} - -STATIC inline void FLUSH_REDRAW () -{ - if (IPPU.PreviousLine != IPPU.CurrentLine) - S9xUpdateScreen (); -} - -STATIC inline void REGISTER_2104 (uint8 byte) -{ - if (PPU.OAMAddr & 0x100) - { - int addr = ((PPU.OAMAddr & 0x10f) << 1) + (PPU.OAMFlip & 1); - if (byte != PPU.OAMData [addr]){ - FLUSH_REDRAW (); - PPU.OAMData [addr] = byte; - IPPU.OBJChanged = TRUE; - - // X position high bit, and sprite size (x4) - struct SOBJ *pObj = &PPU.OBJ [(addr & 0x1f) * 4]; - - pObj->HPos = (pObj->HPos & 0xFF) | SignExtend[(byte >> 0) & 1]; - pObj++->Size = byte & 2; - pObj->HPos = (pObj->HPos & 0xFF) | SignExtend[(byte >> 2) & 1]; - pObj++->Size = byte & 8; - pObj->HPos = (pObj->HPos & 0xFF) | SignExtend[(byte >> 4) & 1]; - pObj++->Size = byte & 32; - pObj->HPos = (pObj->HPos & 0xFF) | SignExtend[(byte >> 6) & 1]; - pObj->Size = byte & 128; - } - PPU.OAMFlip ^= 1; - if(!(PPU.OAMFlip & 1)){ - ++PPU.OAMAddr; - PPU.OAMAddr &= 0x1ff; - if (PPU.OAMPriorityRotation && PPU.FirstSprite != (PPU.OAMAddr >> 1)) - { - PPU.FirstSprite = (PPU.OAMAddr&0xFE) >> 1; - IPPU.OBJChanged = TRUE; - } - } else { - if (PPU.OAMPriorityRotation && (PPU.OAMAddr&1)) IPPU.OBJChanged = TRUE; - } - } else if(!(PPU.OAMFlip & 1)){ - PPU.OAMWriteRegister &= 0xff00; - PPU.OAMWriteRegister |= byte; - PPU.OAMFlip |= 1; - if (PPU.OAMPriorityRotation && (PPU.OAMAddr&1)) IPPU.OBJChanged = TRUE; - } else { - PPU.OAMWriteRegister &= 0x00ff; - uint8 lowbyte = (uint8)(PPU.OAMWriteRegister); - uint8 highbyte = byte; - PPU.OAMWriteRegister |= byte << 8; - - int addr = (PPU.OAMAddr << 1); - - if (lowbyte != PPU.OAMData [addr] || - highbyte != PPU.OAMData [addr+1]) - { - FLUSH_REDRAW (); - PPU.OAMData [addr] = lowbyte; - PPU.OAMData [addr+1] = highbyte; - IPPU.OBJChanged = TRUE; - if (addr & 2) - { - // Tile - PPU.OBJ[addr = PPU.OAMAddr >> 1].Name = PPU.OAMWriteRegister & 0x1ff; - - // priority, h and v flip. - PPU.OBJ[addr].Palette = (highbyte >> 1) & 7; - PPU.OBJ[addr].Priority = (highbyte >> 4) & 3; - PPU.OBJ[addr].HFlip = (highbyte >> 6) & 1; - PPU.OBJ[addr].VFlip = (highbyte >> 7) & 1; - } - else - { - // X position (low) - PPU.OBJ[addr = PPU.OAMAddr >> 1].HPos &= 0xFF00; - PPU.OBJ[addr].HPos |= lowbyte; - - // Sprite Y position - PPU.OBJ[addr].VPos = highbyte; - } - } - PPU.OAMFlip &= ~1; - ++PPU.OAMAddr; - if (PPU.OAMPriorityRotation && PPU.FirstSprite != (PPU.OAMAddr >> 1)) - { - PPU.FirstSprite = (PPU.OAMAddr&0xFE) >> 1; - IPPU.OBJChanged = TRUE; - } - } - - Memory.FillRAM [0x2104] = byte; -} - -STATIC inline void REGISTER_2118 (uint8 Byte) -{ - uint32 address; - if (PPU.VMA.FullGraphicCount) - { - uint32 rem = PPU.VMA.Address & PPU.VMA.Mask1; - address = (((PPU.VMA.Address & ~PPU.VMA.Mask1) + - (rem >> PPU.VMA.Shift) + - ((rem & (PPU.VMA.FullGraphicCount - 1)) << 3)) << 1) & 0xffff; - Memory.VRAM [address] = Byte; - } - else - { - Memory.VRAM[address = (PPU.VMA.Address << 1) & 0xFFFF] = Byte; - } - IPPU.TileCached [TILE_2BIT][address >> 4] = FALSE; - IPPU.TileCached [TILE_4BIT][address >> 5] = FALSE; - IPPU.TileCached [TILE_8BIT][address >> 6] = FALSE; - if (!PPU.VMA.High) - { -#ifdef DEBUGGER - if (Settings.TraceVRAM && !CPU.InDMA) - { - printf ("VRAM write byte: $%04X (%d,%d)\n", PPU.VMA.Address, - Memory.FillRAM[0x2115] & 3, - (Memory.FillRAM [0x2115] & 0x0c) >> 2); - } -#endif - PPU.VMA.Address += PPU.VMA.Increment; - } -// Memory.FillRAM [0x2118] = Byte; -} - -STATIC inline void REGISTER_2118_tile (uint8 Byte) -{ - uint32 address; - uint32 rem = PPU.VMA.Address & PPU.VMA.Mask1; - address = (((PPU.VMA.Address & ~PPU.VMA.Mask1) + - (rem >> PPU.VMA.Shift) + - ((rem & (PPU.VMA.FullGraphicCount - 1)) << 3)) << 1) & 0xffff; - Memory.VRAM [address] = Byte; - IPPU.TileCached [TILE_2BIT][address >> 4] = FALSE; - IPPU.TileCached [TILE_4BIT][address >> 5] = FALSE; - IPPU.TileCached [TILE_8BIT][address >> 6] = FALSE; - if (!PPU.VMA.High) - PPU.VMA.Address += PPU.VMA.Increment; -// Memory.FillRAM [0x2118] = Byte; -} - -STATIC inline void REGISTER_2118_linear (uint8 Byte) -{ - uint32 address; - Memory.VRAM[address = (PPU.VMA.Address << 1) & 0xFFFF] = Byte; - IPPU.TileCached [TILE_2BIT][address >> 4] = FALSE; - IPPU.TileCached [TILE_4BIT][address >> 5] = FALSE; - IPPU.TileCached [TILE_8BIT][address >> 6] = FALSE; - if (!PPU.VMA.High) - PPU.VMA.Address += PPU.VMA.Increment; -// Memory.FillRAM [0x2118] = Byte; -} - -STATIC inline void REGISTER_2119 (uint8 Byte) -{ - uint32 address; - if (PPU.VMA.FullGraphicCount) - { - uint32 rem = PPU.VMA.Address & PPU.VMA.Mask1; - address = ((((PPU.VMA.Address & ~PPU.VMA.Mask1) + - (rem >> PPU.VMA.Shift) + - ((rem & (PPU.VMA.FullGraphicCount - 1)) << 3)) << 1) + 1) & 0xFFFF; - Memory.VRAM [address] = Byte; - } - else - { - Memory.VRAM[address = ((PPU.VMA.Address << 1) + 1) & 0xFFFF] = Byte; - } - IPPU.TileCached [TILE_2BIT][address >> 4] = FALSE; - IPPU.TileCached [TILE_4BIT][address >> 5] = FALSE; - IPPU.TileCached [TILE_8BIT][address >> 6] = FALSE; - if (PPU.VMA.High) - { -#ifdef DEBUGGER - if (Settings.TraceVRAM && !CPU.InDMA) - { - printf ("VRAM write word: $%04X (%d,%d)\n", PPU.VMA.Address, - Memory.FillRAM[0x2115] & 3, - (Memory.FillRAM [0x2115] & 0x0c) >> 2); - } -#endif - PPU.VMA.Address += PPU.VMA.Increment; - } -// Memory.FillRAM [0x2119] = Byte; -} - -STATIC inline void REGISTER_2119_tile (uint8 Byte) -{ - uint32 rem = PPU.VMA.Address & PPU.VMA.Mask1; - uint32 address = ((((PPU.VMA.Address & ~PPU.VMA.Mask1) + - (rem >> PPU.VMA.Shift) + - ((rem & (PPU.VMA.FullGraphicCount - 1)) << 3)) << 1) + 1) & 0xFFFF; - Memory.VRAM [address] = Byte; - IPPU.TileCached [TILE_2BIT][address >> 4] = FALSE; - IPPU.TileCached [TILE_4BIT][address >> 5] = FALSE; - IPPU.TileCached [TILE_8BIT][address >> 6] = FALSE; - if (PPU.VMA.High) - PPU.VMA.Address += PPU.VMA.Increment; -// Memory.FillRAM [0x2119] = Byte; -} - -STATIC inline void REGISTER_2119_linear (uint8 Byte) -{ - uint32 address; - Memory.VRAM[address = ((PPU.VMA.Address << 1) + 1) & 0xFFFF] = Byte; - IPPU.TileCached [TILE_2BIT][address >> 4] = FALSE; - IPPU.TileCached [TILE_4BIT][address >> 5] = FALSE; - IPPU.TileCached [TILE_8BIT][address >> 6] = FALSE; - if (PPU.VMA.High) - PPU.VMA.Address += PPU.VMA.Increment; -// Memory.FillRAM [0x2119] = Byte; -} - -STATIC inline void REGISTER_2122(uint8 Byte) -{ - // CG-RAM (palette) write - - if (PPU.CGFLIP) - { - if ((Byte & 0x7f) != (PPU.CGDATA[PPU.CGADD] >> 8)) - { - if (Settings.SixteenBit) - FLUSH_REDRAW (); - PPU.CGDATA[PPU.CGADD] &= 0x00FF; - PPU.CGDATA[PPU.CGADD] |= (Byte & 0x7f) << 8; - IPPU.ColorsChanged = TRUE; - if (Settings.SixteenBit) - { - IPPU.Blue [PPU.CGADD] = IPPU.XB [(Byte >> 2) & 0x1f]; - IPPU.Green [PPU.CGADD] = IPPU.XB [(PPU.CGDATA[PPU.CGADD] >> 5) & 0x1f]; - IPPU.ScreenColors [PPU.CGADD] = (uint16) BUILD_PIXEL (IPPU.Red [PPU.CGADD], - IPPU.Green [PPU.CGADD], - IPPU.Blue [PPU.CGADD]); - } - } - PPU.CGADD++; - } - else - { - if (Byte != (uint8) (PPU.CGDATA[PPU.CGADD] & 0xff)) - { - if (Settings.SixteenBit) - FLUSH_REDRAW (); - PPU.CGDATA[PPU.CGADD] &= 0x7F00; - PPU.CGDATA[PPU.CGADD] |= Byte; - IPPU.ColorsChanged = TRUE; - if (Settings.SixteenBit) - { - IPPU.Red [PPU.CGADD] = IPPU.XB [Byte & 0x1f]; - IPPU.Green [PPU.CGADD] = IPPU.XB [(PPU.CGDATA[PPU.CGADD] >> 5) & 0x1f]; - IPPU.ScreenColors [PPU.CGADD] = (uint16) BUILD_PIXEL (IPPU.Red [PPU.CGADD], - IPPU.Green [PPU.CGADD], - IPPU.Blue [PPU.CGADD]); - } - } - } - PPU.CGFLIP ^= 1; -// Memory.FillRAM [0x2122] = Byte; -} - -STATIC inline void REGISTER_2180(uint8 Byte) -{ - Memory.RAM[PPU.WRAM++] = Byte; - PPU.WRAM &= 0x1FFFF; - Memory.FillRAM [0x2180] = Byte; -} - +extern uint8 REGISTER_4212(); +extern void FLUSH_REDRAW (); +extern void REGISTER_2104 (uint8 byte); +extern void REGISTER_2118 (uint8 Byte); +extern void REGISTER_2118_tile (uint8 Byte); +extern void REGISTER_2118_linear (uint8 Byte); +extern void REGISTER_2119 (uint8 Byte); +extern void REGISTER_2119_tile (uint8 Byte); +extern void REGISTER_2119_linear (uint8 Byte); +extern void REGISTER_2122(uint8 Byte); +extern void REGISTER_2180(uint8 Byte); //Platform specific input functions used by PPU.CPP void JustifierButtons(uint32&); diff --git a/source/sa1cpu.cpp b/source/sa1cpu.cpp index 1532f57..655fa5c 100644 --- a/source/sa1cpu.cpp +++ b/source/sa1cpu.cpp @@ -134,6 +134,69 @@ #define StackRelative SA1StackRelative #define StackRelativeIndirectIndexed SA1StackRelativeIndirectIndexed +#define SetZN16 SA1SetZN16 +#define SetZN8 SA1SetZN8 +#define ADC8 SA1ADC8 +#define ADC16 SA1ADC16 +#define AND16 SA1AND16 +#define AND8 SA1AND8 +#define A_ASL16 SA1A_ASL16 +#define A_ASL8 SA1A_ASL8 +#define ASL16 SA1ASL16 +#define ASL8 SA1ASL8 +#define BIT16 SA1BIT16 +#define BIT8 SA1BIT8 +#define CMP16 SA1CMP16 +#define CMP8 SA1CMP8 +#define CMX16 SA1CMX16 +#define CMX8 SA1CMX8 +#define CMY16 SA1CMY16 +#define CMY8 SA1CMY8 +#define A_DEC16 SA1A_DEC16 +#define A_DEC8 SA1A_DEC8 +#define DEC16 SA1DEC16 +#define DEC8 SA1DEC8 +#define EOR16 SA1EOR16 +#define EOR8 SA1EOR8 +#define A_INC16 SA1A_INC16 +#define A_INC8 SA1A_INC8 +#define INC16 SA1INC16 +#define INC8 SA1INC8 +#define LDA16 SA1LDA16 +#define LDA8 SA1LDA8 +#define LDX16 SA1LDX16 +#define LDX8 SA1LDX8 +#define LDY16 SA1LDY16 +#define LDY8 SA1LDY8 +#define A_LSR16 SA1A_LSR16 +#define A_LSR8 SA1A_LSR8 +#define LSR16 SA1LSR16 +#define LSR8 SA1LSR8 +#define ORA16 SA1ORA16 +#define ORA8 SA1ORA8 +#define A_ROL16 SA1A_ROL16 +#define A_ROL8 SA1A_ROL8 +#define ROL16 SA1ROL16 +#define ROL8 SA1ROL8 +#define A_ROR16 SA1A_ROR16 +#define A_ROR8 SA1A_ROR8 +#define ROR16 SA1ROR16 +#define ROR8 SA1ROR8 +#define SBC16 SA1SBC16 +#define SBC8 SA1SBC8 +#define STA16 SA1STA16 +#define STA8 SA1STA8 +#define STX16 SA1STX16 +#define STX8 SA1STX8 +#define STY16 SA1STY16 +#define STY8 SA1STY8 +#define STZ16 SA1STZ16 +#define STZ8 SA1STZ8 +#define TSB16 SA1TSB16 +#define TSB8 SA1TSB8 +#define TRB16 SA1TRB16 +#define TRB8 SA1TRB8 + //#undef CPU_SHUTDOWN #undef VAR_CYCLES #define SA1_OPCODES diff --git a/source/tile.cpp b/source/tile.cpp index 27e61f0..d4cdcbf 100644 --- a/source/tile.cpp +++ b/source/tile.cpp @@ -216,7 +216,7 @@ uint8 ConvertTile (uint8 *pCache, uint32 TileAddr) return (non_zero ? TRUE : BLANK_TILE); } -inline void WRITE_4PIXELS (uint32 Offset, uint8 *Pixels) +void WRITE_4PIXELS (uint32 Offset, uint8 *Pixels) { uint8 Pixel; uint8 *Screen = GFX.S + Offset; @@ -236,7 +236,7 @@ inline void WRITE_4PIXELS (uint32 Offset, uint8 *Pixels) #undef FN } -inline void WRITE_4PIXELS_FLIPPED (uint32 Offset, uint8 *Pixels) +void WRITE_4PIXELS_FLIPPED (uint32 Offset, uint8 *Pixels) { uint8 Pixel; uint8 *Screen = GFX.S + Offset; @@ -256,7 +256,7 @@ inline void WRITE_4PIXELS_FLIPPED (uint32 Offset, uint8 *Pixels) #undef FN } -inline void WRITE_4PIXELSx2 (uint32 Offset, uint8 *Pixels) +void WRITE_4PIXELSx2 (uint32 Offset, uint8 *Pixels) { uint8 Pixel; uint8 *Screen = GFX.S + Offset; @@ -276,7 +276,7 @@ inline void WRITE_4PIXELSx2 (uint32 Offset, uint8 *Pixels) #undef FN } -inline void WRITE_4PIXELS_FLIPPEDx2 (uint32 Offset, uint8 *Pixels) +void WRITE_4PIXELS_FLIPPEDx2 (uint32 Offset, uint8 *Pixels) { uint8 Pixel; uint8 *Screen = GFX.S + Offset; @@ -296,7 +296,7 @@ inline void WRITE_4PIXELS_FLIPPEDx2 (uint32 Offset, uint8 *Pixels) #undef FN } -inline void WRITE_4PIXELSx2x2 (uint32 Offset, uint8 *Pixels) +void WRITE_4PIXELSx2x2 (uint32 Offset, uint8 *Pixels) { uint8 Pixel; uint8 *Screen = GFX.S + Offset; @@ -318,7 +318,7 @@ inline void WRITE_4PIXELSx2x2 (uint32 Offset, uint8 *Pixels) #undef FN } -inline void WRITE_4PIXELS_FLIPPEDx2x2 (uint32 Offset, uint8 *Pixels) +void WRITE_4PIXELS_FLIPPEDx2x2 (uint32 Offset, uint8 *Pixels) { uint8 Pixel; uint8 *Screen = GFX.S + Offset; @@ -417,7 +417,7 @@ void DrawLargePixel (uint32 Tile, uint32 Offset, RENDER_TILE_LARGE (((uint8) GFX.ScreenColors [pixel]), PLOT_PIXEL) } -inline void WRITE_4PIXELS16 (uint32 Offset, uint8 *Pixels) +void WRITE_4PIXELS16 (uint32 Offset, uint8 *Pixels) { uint32 Pixel; uint16 *Screen = (uint16 *) GFX.S + Offset; @@ -437,7 +437,7 @@ inline void WRITE_4PIXELS16 (uint32 Offset, uint8 *Pixels) #undef FN } -inline void WRITE_4PIXELS16_FLIPPED (uint32 Offset, uint8 *Pixels) +void WRITE_4PIXELS16_FLIPPED (uint32 Offset, uint8 *Pixels) { uint32 Pixel; uint16 *Screen = (uint16 *) GFX.S + Offset; @@ -457,7 +457,7 @@ inline void WRITE_4PIXELS16_FLIPPED (uint32 Offset, uint8 *Pixels) #undef FN } -inline void WRITE_4PIXELS16x2 (uint32 Offset, uint8 *Pixels) +void WRITE_4PIXELS16x2 (uint32 Offset, uint8 *Pixels) { uint32 Pixel; uint16 *Screen = (uint16 *) GFX.S + Offset; @@ -477,7 +477,7 @@ inline void WRITE_4PIXELS16x2 (uint32 Offset, uint8 *Pixels) #undef FN } -inline void WRITE_4PIXELS16_FLIPPEDx2 (uint32 Offset, uint8 *Pixels) +void WRITE_4PIXELS16_FLIPPEDx2 (uint32 Offset, uint8 *Pixels) { uint32 Pixel; uint16 *Screen = (uint16 *) GFX.S + Offset; @@ -497,7 +497,7 @@ inline void WRITE_4PIXELS16_FLIPPEDx2 (uint32 Offset, uint8 *Pixels) #undef FN } -inline void WRITE_4PIXELS16x2x2 (uint32 Offset, uint8 *Pixels) +void WRITE_4PIXELS16x2x2 (uint32 Offset, uint8 *Pixels) { uint32 Pixel; uint16 *Screen = (uint16 *) GFX.S + Offset; @@ -519,7 +519,7 @@ inline void WRITE_4PIXELS16x2x2 (uint32 Offset, uint8 *Pixels) #undef FN } -inline void WRITE_4PIXELS16_FLIPPEDx2x2 (uint32 Offset, uint8 *Pixels) +void WRITE_4PIXELS16_FLIPPEDx2x2 (uint32 Offset, uint8 *Pixels) { uint32 Pixel; uint16 *Screen = (uint16 *) GFX.S + Offset; @@ -614,7 +614,7 @@ void DrawLargePixel16 (uint32 Tile, uint32 Offset, RENDER_TILE_LARGE (GFX.ScreenColors [pixel], PLOT_PIXEL) } -inline void WRITE_4PIXELS16_ADD (uint32 Offset, uint8 *Pixels) +void WRITE_4PIXELS16_ADD (uint32 Offset, uint8 *Pixels) { uint32 Pixel; uint16 *Screen = (uint16 *) GFX.S + Offset; @@ -646,7 +646,7 @@ inline void WRITE_4PIXELS16_ADD (uint32 Offset, uint8 *Pixels) #undef FN } -inline void WRITE_4PIXELS16_FLIPPED_ADD (uint32 Offset, uint8 *Pixels) +void WRITE_4PIXELS16_FLIPPED_ADD (uint32 Offset, uint8 *Pixels) { uint32 Pixel; uint16 *Screen = (uint16 *) GFX.S + Offset; @@ -678,7 +678,7 @@ inline void WRITE_4PIXELS16_FLIPPED_ADD (uint32 Offset, uint8 *Pixels) #undef FN } -inline void WRITE_4PIXELS16_ADD1_2 (uint32 Offset, uint8 *Pixels) +void WRITE_4PIXELS16_ADD1_2 (uint32 Offset, uint8 *Pixels) { uint32 Pixel; uint16 *Screen = (uint16 *) GFX.S + Offset; @@ -710,7 +710,7 @@ inline void WRITE_4PIXELS16_ADD1_2 (uint32 Offset, uint8 *Pixels) #undef FN } -inline void WRITE_4PIXELS16_FLIPPED_ADD1_2 (uint32 Offset, uint8 *Pixels) +void WRITE_4PIXELS16_FLIPPED_ADD1_2 (uint32 Offset, uint8 *Pixels) { uint32 Pixel; uint16 *Screen = (uint16 *) GFX.S + Offset; @@ -742,7 +742,7 @@ inline void WRITE_4PIXELS16_FLIPPED_ADD1_2 (uint32 Offset, uint8 *Pixels) #undef FN } -inline void WRITE_4PIXELS16_SUB (uint32 Offset, uint8 *Pixels) +void WRITE_4PIXELS16_SUB (uint32 Offset, uint8 *Pixels) { uint32 Pixel; uint16 *Screen = (uint16 *) GFX.S + Offset; @@ -774,7 +774,7 @@ inline void WRITE_4PIXELS16_SUB (uint32 Offset, uint8 *Pixels) #undef FN } -inline void WRITE_4PIXELS16_FLIPPED_SUB (uint32 Offset, uint8 *Pixels) +void WRITE_4PIXELS16_FLIPPED_SUB (uint32 Offset, uint8 *Pixels) { uint32 Pixel; uint16 *Screen = (uint16 *) GFX.S + Offset; @@ -806,7 +806,7 @@ inline void WRITE_4PIXELS16_FLIPPED_SUB (uint32 Offset, uint8 *Pixels) #undef FN } -inline void WRITE_4PIXELS16_SUB1_2 (uint32 Offset, uint8 *Pixels) +void WRITE_4PIXELS16_SUB1_2 (uint32 Offset, uint8 *Pixels) { uint32 Pixel; uint16 *Screen = (uint16 *) GFX.S + Offset; @@ -838,7 +838,7 @@ inline void WRITE_4PIXELS16_SUB1_2 (uint32 Offset, uint8 *Pixels) #undef FN } -inline void WRITE_4PIXELS16_FLIPPED_SUB1_2 (uint32 Offset, uint8 *Pixels) +void WRITE_4PIXELS16_FLIPPED_SUB1_2 (uint32 Offset, uint8 *Pixels) { uint32 Pixel; uint16 *Screen = (uint16 *) GFX.S + Offset; @@ -951,7 +951,7 @@ void DrawClippedTile16Sub1_2 (uint32 Tile, uint32 Offset, RENDER_CLIPPED_TILE(WRITE_4PIXELS16_SUB1_2, WRITE_4PIXELS16_FLIPPED_SUB1_2, 4) } -inline void WRITE_4PIXELS16_ADDF1_2 (uint32 Offset, uint8 *Pixels) +void WRITE_4PIXELS16_ADDF1_2 (uint32 Offset, uint8 *Pixels) { uint32 Pixel; uint16 *Screen = (uint16 *) GFX.S + Offset; @@ -977,7 +977,7 @@ inline void WRITE_4PIXELS16_ADDF1_2 (uint32 Offset, uint8 *Pixels) #undef FN } -inline void WRITE_4PIXELS16_FLIPPED_ADDF1_2 (uint32 Offset, uint8 *Pixels) +void WRITE_4PIXELS16_FLIPPED_ADDF1_2 (uint32 Offset, uint8 *Pixels) { uint32 Pixel; uint16 *Screen = (uint16 *) GFX.S + Offset; @@ -1003,7 +1003,7 @@ inline void WRITE_4PIXELS16_FLIPPED_ADDF1_2 (uint32 Offset, uint8 *Pixels) #undef FN } -inline void WRITE_4PIXELS16_SUBF1_2 (uint32 Offset, uint8 *Pixels) +void WRITE_4PIXELS16_SUBF1_2 (uint32 Offset, uint8 *Pixels) { uint32 Pixel; uint16 *Screen = (uint16 *) GFX.S + Offset; @@ -1029,7 +1029,7 @@ inline void WRITE_4PIXELS16_SUBF1_2 (uint32 Offset, uint8 *Pixels) #undef FN } -inline void WRITE_4PIXELS16_FLIPPED_SUBF1_2 (uint32 Offset, uint8 *Pixels) +void WRITE_4PIXELS16_FLIPPED_SUBF1_2 (uint32 Offset, uint8 *Pixels) { uint32 Pixel; uint16 *Screen = (uint16 *) GFX.S + Offset; |