aboutsummaryrefslogtreecommitdiff
path: root/source/getset.h
diff options
context:
space:
mode:
authorTwinaphex2017-06-18 18:41:06 +0200
committerGitHub2017-06-18 18:41:06 +0200
commit1aecedc999445e9a27e04f665fd562b576775d08 (patch)
treec526c7d332be548a42364eea9113b6d33345b840 /source/getset.h
parentdc596c886e0ec2728dc353dd7862cdf1e5a5ff44 (diff)
parentbcaf44c511efaad9d803dde9b0fdbb046498c66f (diff)
downloadsnes9x2005-1aecedc999445e9a27e04f665fd562b576775d08.tar.gz
snes9x2005-1aecedc999445e9a27e04f665fd562b576775d08.tar.bz2
snes9x2005-1aecedc999445e9a27e04f665fd562b576775d08.zip
Merge pull request #36 from jamsilva/master
Compatibility fixes.
Diffstat (limited to 'source/getset.h')
-rw-r--r--source/getset.h46
1 files changed, 11 insertions, 35 deletions
diff --git a/source/getset.h b/source/getset.h
index 7d28a04..ebf996f 100644
--- a/source/getset.h
+++ b/source/getset.h
@@ -13,20 +13,18 @@
extern uint8_t OpenBus;
-INLINE uint8_t S9xGetByte(uint32_t Address)
+inline uint8_t S9xGetByte(uint32_t Address)
{
int32_t block;
uint8_t* GetAddress = Memory.Map [block = (Address >> MEMMAP_SHIFT) & MEMMAP_MASK];
- if (!CPU.InDMA)
+ if ((intptr_t) GetAddress != MAP_CPU || !CPU.InDMA)
CPU.Cycles += Memory.MemorySpeed [block];
if (GetAddress >= (uint8_t*) MAP_LAST)
{
-#ifdef CPU_SHUTDOWN
if (Memory.BlockIsRAM [block])
CPU.WaitAddress = CPU.PCAtOpcodeStart;
-#endif
return (*(GetAddress + (Address & 0xffff)));
}
@@ -67,7 +65,7 @@ INLINE uint8_t S9xGetByte(uint32_t Address)
}
}
-INLINE uint16_t S9xGetWord(uint32_t Address)
+inline uint16_t S9xGetWord(uint32_t Address)
{
if ((Address & 0x0fff) == 0x0fff)
{
@@ -77,15 +75,13 @@ INLINE uint16_t S9xGetWord(uint32_t Address)
int32_t block;
uint8_t* GetAddress = Memory.Map [block = (Address >> MEMMAP_SHIFT) & MEMMAP_MASK];
- if (!CPU.InDMA)
+ if ((intptr_t) GetAddress != MAP_CPU || !CPU.InDMA)
CPU.Cycles += (Memory.MemorySpeed [block] << 1);
if (GetAddress >= (uint8_t*) MAP_LAST)
{
-#ifdef CPU_SHUTDOWN
if (Memory.BlockIsRAM [block])
CPU.WaitAddress = CPU.PCAtOpcodeStart;
-#endif
#ifdef FAST_LSB_WORD_ACCESS
return (*(uint16_t*)(GetAddress + (Address & 0xffff)));
#else
@@ -145,21 +141,17 @@ INLINE uint16_t S9xGetWord(uint32_t Address)
}
}
-INLINE void S9xSetByte(uint8_t Byte, uint32_t Address)
+inline void S9xSetByte(uint8_t Byte, uint32_t Address)
{
-#if defined(CPU_SHUTDOWN)
CPU.WaitAddress = NULL;
-#endif
int32_t block;
uint8_t* SetAddress = Memory.WriteMap [block = ((Address >> MEMMAP_SHIFT) & MEMMAP_MASK)];
- if (!CPU.InDMA)
+ if ((intptr_t) SetAddress != MAP_CPU || !CPU.InDMA)
CPU.Cycles += Memory.MemorySpeed [block];
-
if (SetAddress >= (uint8_t*) MAP_LAST)
{
-#ifdef CPU_SHUTDOWN
SetAddress += Address & 0xffff;
if (SetAddress == SA1.WaitByteAddress1 ||
SetAddress == SA1.WaitByteAddress2)
@@ -168,9 +160,6 @@ INLINE void S9xSetByte(uint8_t Byte, uint32_t Address)
SA1.WaitCounter = 0;
}
*SetAddress = Byte;
-#else
- *(SetAddress + (Address & 0xffff)) = Byte;
-#endif
return;
}
@@ -227,7 +216,7 @@ INLINE void S9xSetByte(uint8_t Byte, uint32_t Address)
}
}
-INLINE void S9xSetWord(uint16_t Word, uint32_t Address)
+inline void S9xSetWord(uint16_t Word, uint32_t Address)
{
if ((Address & 0x0FFF) == 0x0FFF)
{
@@ -236,19 +225,15 @@ INLINE void S9xSetWord(uint16_t Word, uint32_t Address)
return;
}
-#if defined(CPU_SHUTDOWN)
CPU.WaitAddress = NULL;
-#endif
int32_t block;
uint8_t* SetAddress = Memory.WriteMap [block = ((Address >> MEMMAP_SHIFT) & MEMMAP_MASK)];
- if (!CPU.InDMA)
+ if ((intptr_t) SetAddress != MAP_CPU || !CPU.InDMA)
CPU.Cycles += Memory.MemorySpeed [block] << 1;
-
if (SetAddress >= (uint8_t*) MAP_LAST)
{
-#ifdef CPU_SHUTDOWN
SetAddress += Address & 0xffff;
if (SetAddress == SA1.WaitByteAddress1 ||
SetAddress == SA1.WaitByteAddress2)
@@ -262,14 +247,6 @@ INLINE void S9xSetWord(uint16_t Word, uint32_t Address)
*SetAddress = (uint8_t) Word;
*(SetAddress + 1) = Word >> 8;
#endif
-#else
-#ifdef FAST_LSB_WORD_ACCESS
- *(uint16_t*)(SetAddress + (Address & 0xffff)) = Word;
-#else
- *(SetAddress + (Address & 0xffff)) = (uint8_t) Word;
- *(SetAddress + ((Address + 1) & 0xffff)) = Word >> 8;
-#endif
-#endif
return;
}
@@ -350,7 +327,7 @@ INLINE void S9xSetWord(uint16_t Word, uint32_t Address)
}
}
-INLINE uint8_t* GetBasePointer(uint32_t Address)
+inline uint8_t* GetBasePointer(uint32_t Address)
{
uint8_t* GetAddress = Memory.Map [(Address >> MEMMAP_SHIFT) & MEMMAP_MASK];
if (GetAddress >= (uint8_t*) MAP_LAST)
@@ -384,7 +361,7 @@ INLINE uint8_t* GetBasePointer(uint32_t Address)
}
}
-INLINE uint8_t* S9xGetMemPointer(uint32_t Address)
+inline uint8_t* S9xGetMemPointer(uint32_t Address)
{
uint8_t* GetAddress = Memory.Map [(Address >> MEMMAP_SHIFT) & MEMMAP_MASK];
if (GetAddress >= (uint8_t*) MAP_LAST)
@@ -421,7 +398,7 @@ INLINE uint8_t* S9xGetMemPointer(uint32_t Address)
}
}
-INLINE void S9xSetPCBase(uint32_t Address)
+inline void S9xSetPCBase(uint32_t Address)
{
int32_t block;
uint8_t* GetAddress = Memory.Map [block = (Address >> MEMMAP_SHIFT) & MEMMAP_MASK];
@@ -458,5 +435,4 @@ INLINE void S9xSetPCBase(uint32_t Address)
CPU.PC = CPU.PCBase + (Address & 0xffff);
}
-
#endif