aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile2
-rw-r--r--source/cheats.c2
-rw-r--r--source/cheats2.c4
-rw-r--r--source/cpuaddr.h42
-rw-r--r--source/dma.c48
-rw-r--r--source/fxemu.c177
-rw-r--r--source/gfx.c51
-rw-r--r--source/sa1.c83
-rw-r--r--source/soundux.c4
-rw-r--r--source/spc700.c24
-rw-r--r--source/tile.c16
11 files changed, 202 insertions, 251 deletions
diff --git a/Makefile b/Makefile
index f1c2ad1..24d5571 100644
--- a/Makefile
+++ b/Makefile
@@ -293,7 +293,7 @@ ifneq (,$(findstring msvc,$(platform)))
LD = link.exe
else
OBJOUT = -o
- LINKOUT = -o
+ LINKOUT = -o
LD = $(CC)
endif
diff --git a/source/cheats.c b/source/cheats.c
index 572fd55..0bedfd4 100644
--- a/source/cheats.c
+++ b/source/cheats.c
@@ -64,7 +64,7 @@ const char* S9xGameGenieToRaw(const char* code, uint32_t* address, uint8_t* byte
uint32_t data = 0;
int32_t i;
- if (strlen(code) != 9 || *(code + 4) != '-' || !S9xAllHex(code, 4) || !S9xAllHex(code + 5, 4))
+ if (strlen(code) != 9 || code[4] != '-' || !S9xAllHex(code, 4) || !S9xAllHex(code + 5, 4))
return "Invalid Game Genie(tm) code - should be 'xxxx-xxxx'.";
strcpy(new_code, "0x");
diff --git a/source/cheats2.c b/source/cheats2.c
index cc303b8..067a929 100644
--- a/source/cheats2.c
+++ b/source/cheats2.c
@@ -81,7 +81,7 @@ void S9xRemoveCheat(uint32_t which1)
uint8_t* ptr = Memory.Map [block];
if (ptr >= (uint8_t*) MAP_LAST)
- *(ptr + (address & 0xffff)) = Cheat.c [which1].saved_byte;
+ ptr[address & 0xffff] = Cheat.c [which1].saved_byte;
else
S9xSetByte(Cheat.c [which1].saved_byte, address);
/* Unsave the address for the next call to S9xRemoveCheat. */
@@ -102,7 +102,7 @@ void S9xApplyCheat(uint32_t which1)
ptr = Memory.Map [block];
if (ptr >= (uint8_t*) MAP_LAST)
- *(ptr + (address & 0xffff)) = Cheat.c [which1].byte;
+ ptr[address & 0xffff] = Cheat.c [which1].byte;
else
S9xSetByte(Cheat.c [which1].byte, address);
Cheat.c [which1].saved = true;
diff --git a/source/cpuaddr.h b/source/cpuaddr.h
index bdeb242..2d638b9 100644
--- a/source/cpuaddr.h
+++ b/source/cpuaddr.h
@@ -33,7 +33,7 @@ static INLINE void RelativeLong(void)
#ifdef FAST_LSB_WORD_ACCESS
OpAddress = *(uint16_t*) CPU.PC;
#else
- OpAddress = *CPU.PC + (*(CPU.PC + 1) << 8);
+ OpAddress = CPU.PC[0] + (CPU.PC[1] << 8);
#endif
#ifndef SA1_OPCODES
CPU.Cycles += CPU.MemSpeedx2 + ONE_CYCLE;
@@ -48,12 +48,12 @@ static INLINE void AbsoluteIndexedIndirect(bool read)
#ifdef FAST_LSB_WORD_ACCESS
OpAddress = (ICPU.Registers.X.W + * (uint16_t*) CPU.PC) & 0xffff;
#else
- OpAddress = (ICPU.Registers.X.W + *CPU.PC + (*(CPU.PC + 1) << 8)) & 0xffff;
+ OpAddress = (ICPU.Registers.X.W + CPU.PC[0] + (CPU.PC[1] << 8)) & 0xffff;
#endif
#ifndef SA1_OPCODES
CPU.Cycles += CPU.MemSpeedx2;
#endif
- OpenBus = *(CPU.PC + 1);
+ OpenBus = CPU.PC[1];
CPU.PC += 2;
OpAddress = S9xGetWord(ICPU.ShiftedPB + OpAddress);
if (read)
@@ -65,12 +65,12 @@ static INLINE void AbsoluteIndirectLong(bool read)
#ifdef FAST_LSB_WORD_ACCESS
OpAddress = *(uint16_t*) CPU.PC;
#else
- OpAddress = *CPU.PC + (*(CPU.PC + 1) << 8);
+ OpAddress = CPU.PC[0] + (CPU.PC[1] << 8);
#endif
#ifndef SA1_OPCODES
CPU.Cycles += CPU.MemSpeedx2;
#endif
- OpenBus = *(CPU.PC + 1);
+ OpenBus = CPU.PC[1];
CPU.PC += 2;
if (read)
OpAddress = S9xGetWord(OpAddress) | ((OpenBus = S9xGetByte(OpAddress + 2)) << 16);
@@ -83,12 +83,12 @@ static INLINE void AbsoluteIndirect(bool read)
#ifdef FAST_LSB_WORD_ACCESS
OpAddress = *(uint16_t*) CPU.PC;
#else
- OpAddress = *CPU.PC + (*(CPU.PC + 1) << 8);
+ OpAddress = CPU.PC[0] + (CPU.PC[1] << 8);
#endif
#ifndef SA1_OPCODES
CPU.Cycles += CPU.MemSpeedx2;
#endif
- OpenBus = *(CPU.PC + 1);
+ OpenBus = CPU.PC[1];
CPU.PC += 2;
OpAddress = S9xGetWord(OpAddress);
if (read)
@@ -101,10 +101,10 @@ static INLINE void Absolute(bool read)
#ifdef FAST_LSB_WORD_ACCESS
OpAddress = *(uint16_t*) CPU.PC + ICPU.ShiftedDB;
#else
- OpAddress = *CPU.PC + (*(CPU.PC + 1) << 8) + ICPU.ShiftedDB;
+ OpAddress = CPU.PC[0] + (CPU.PC[1] << 8) + ICPU.ShiftedDB;
#endif
if (read)
- OpenBus = *(CPU.PC + 1);
+ OpenBus = CPU.PC[1];
CPU.PC += 2;
#ifndef SA1_OPCODES
CPU.Cycles += CPU.MemSpeedx2;
@@ -117,14 +117,14 @@ static INLINE void AbsoluteLong(bool read)
OpAddress = (*(uint32_t*) CPU.PC) & 0xffffff;
#elif defined FAST_ALIGNED_LSB_WORD_ACCESS
if (((int32_t) CPU.PC & 1) == 0)
- OpAddress = (*(uint16_t*) CPU.PC) + (*(CPU.PC + 2) << 16);
+ OpAddress = (*(uint16_t*) CPU.PC) + (CPU.PC[2] << 16);
else
- OpAddress = *CPU.PC + ((*(uint16_t*)(CPU.PC + 1)) << 8);
+ OpAddress = *CPU.PC + ((*(uint16_t*) (CPU.PC + 1)) << 8);
#else
- OpAddress = *CPU.PC + (*(CPU.PC + 1) << 8) + (*(CPU.PC + 2) << 16);
+ OpAddress = CPU.PC[0] + (CPU.PC[1] << 8) + (CPU.PC[2] << 16);
#endif
if (read)
- OpenBus = *(CPU.PC + 2);
+ OpenBus = CPU.PC[2];
CPU.PC += 3;
#ifndef SA1_OPCODES
CPU.Cycles += CPU.MemSpeedx2 + CPU.MemSpeed;
@@ -210,10 +210,10 @@ static INLINE void AbsoluteIndexedX(bool read)
#ifdef FAST_LSB_WORD_ACCESS
OpAddress = ICPU.ShiftedDB + *(uint16_t*) CPU.PC + ICPU.Registers.X.W;
#else
- OpAddress = ICPU.ShiftedDB + *CPU.PC + (*(CPU.PC + 1) << 8) + ICPU.Registers.X.W;
+ OpAddress = ICPU.ShiftedDB + CPU.PC[0] + (CPU.PC[1] << 8) + ICPU.Registers.X.W;
#endif
if (read)
- OpenBus = *(CPU.PC + 1);
+ OpenBus = CPU.PC[1];
CPU.PC += 2;
#ifndef SA1_OPCODES
CPU.Cycles += CPU.MemSpeedx2;
@@ -225,10 +225,10 @@ static INLINE void AbsoluteIndexedY(bool read)
#ifdef FAST_LSB_WORD_ACCESS
OpAddress = ICPU.ShiftedDB + *(uint16_t*) CPU.PC + ICPU.Registers.Y.W;
#else
- OpAddress = ICPU.ShiftedDB + *CPU.PC + (*(CPU.PC + 1) << 8) + ICPU.Registers.Y.W;
+ OpAddress = ICPU.ShiftedDB + CPU.PC[0] + (CPU.PC[1] << 8) + ICPU.Registers.Y.W;
#endif
if (read)
- OpenBus = *(CPU.PC + 1);
+ OpenBus = CPU.PC[1];
CPU.PC += 2;
#ifndef SA1_OPCODES
CPU.Cycles += CPU.MemSpeedx2;
@@ -241,14 +241,14 @@ static INLINE void AbsoluteLongIndexedX(bool read)
OpAddress = (*(uint32_t*) CPU.PC + ICPU.Registers.X.W) & 0xffffff;
#elif defined FAST_ALIGNED_LSB_WORD_ACCESS
if (((int32_t) CPU.PC & 1) == 0)
- OpAddress = ((*(uint16_t*) CPU.PC) + (*(CPU.PC + 2) << 16) + ICPU.Registers.X.W) & 0xFFFFFF;
+ OpAddress = ((*(uint16_t*) CPU.PC) + (CPU.PC[2] << 16) + ICPU.Registers.X.W) & 0xFFFFFF;
else
- OpAddress = (*CPU.PC + ((*(uint16_t*)(CPU.PC + 1)) << 8) + ICPU.Registers.X.W) & 0xFFFFFF;
+ OpAddress = (*CPU.PC + ((*(uint16_t*) (CPU.PC + 1)) << 8) + ICPU.Registers.X.W) & 0xFFFFFF;
#else
- OpAddress = (*CPU.PC + (*(CPU.PC + 1) << 8) + (*(CPU.PC + 2) << 16) + ICPU.Registers.X.W) & 0xffffff;
+ OpAddress = (CPU.PC[0] + (CPU.PC[1] << 8) + (CPU.PC[2] << 16) + ICPU.Registers.X.W) & 0xffffff;
#endif
if (read)
- OpenBus = *(CPU.PC + 2);
+ OpenBus = CPU.PC[2];
CPU.PC += 3;
#ifndef SA1_OPCODES
CPU.Cycles += CPU.MemSpeedx2 + CPU.MemSpeed;
diff --git a/source/dma.c b/source/dma.c
index 7effb25..b9f977f 100644
--- a/source/dma.c
+++ b/source/dma.c
@@ -130,14 +130,14 @@ void S9xDoDMA(uint8_t Channel)
for (b = 0; b < 2; b++)
{
uint8_t r = *(q + b);
- *(p + 0) = (*(p + 0) << 1) | ((r >> 0) & 1);
- *(p + 1) = (*(p + 1) << 1) | ((r >> 1) & 1);
- *(p + 0) = (*(p + 0) << 1) | ((r >> 2) & 1);
- *(p + 1) = (*(p + 1) << 1) | ((r >> 3) & 1);
- *(p + 0) = (*(p + 0) << 1) | ((r >> 4) & 1);
- *(p + 1) = (*(p + 1) << 1) | ((r >> 5) & 1);
- *(p + 0) = (*(p + 0) << 1) | ((r >> 6) & 1);
- *(p + 1) = (*(p + 1) << 1) | ((r >> 7) & 1);
+ p[0] = (p[0] << 1) | ((r >> 0) & 1);
+ p[1] = (p[1] << 1) | ((r >> 1) & 1);
+ p[0] = (p[0] << 1) | ((r >> 2) & 1);
+ p[1] = (p[1] << 1) | ((r >> 3) & 1);
+ p[0] = (p[0] << 1) | ((r >> 4) & 1);
+ p[1] = (p[1] << 1) | ((r >> 5) & 1);
+ p[0] = (p[0] << 1) | ((r >> 6) & 1);
+ p[1] = (p[1] << 1) | ((r >> 7) & 1);
}
p += 2;
}
@@ -158,14 +158,14 @@ void S9xDoDMA(uint8_t Channel)
for (b = 0; b < 4; b++)
{
uint8_t r = *(q + b);
- *(p + 0) = (*(p + 0) << 1) | ((r >> 0) & 1);
- *(p + 1) = (*(p + 1) << 1) | ((r >> 1) & 1);
- *(p + 16) = (*(p + 16) << 1) | ((r >> 2) & 1);
- *(p + 17) = (*(p + 17) << 1) | ((r >> 3) & 1);
- *(p + 0) = (*(p + 0) << 1) | ((r >> 4) & 1);
- *(p + 1) = (*(p + 1) << 1) | ((r >> 5) & 1);
- *(p + 16) = (*(p + 16) << 1) | ((r >> 6) & 1);
- *(p + 17) = (*(p + 17) << 1) | ((r >> 7) & 1);
+ p[0] = (p[0] << 1) | ((r >> 0) & 1);
+ p[1] = (p[1] << 1) | ((r >> 1) & 1);
+ p[16] = (p[16] << 1) | ((r >> 2) & 1);
+ p[17] = (p[17] << 1) | ((r >> 3) & 1);
+ p[0] = (p[0] << 1) | ((r >> 4) & 1);
+ p[1] = (p[1] << 1) | ((r >> 5) & 1);
+ p[16] = (p[16] << 1) | ((r >> 6) & 1);
+ p[17] = (p[17] << 1) | ((r >> 7) & 1);
}
p += 2;
}
@@ -187,14 +187,14 @@ void S9xDoDMA(uint8_t Channel)
for (b = 0; b < 8; b++)
{
uint8_t r = *(q + b);
- *(p + 0) = (*(p + 0) << 1) | ((r >> 0) & 1);
- *(p + 1) = (*(p + 1) << 1) | ((r >> 1) & 1);
- *(p + 16) = (*(p + 16) << 1) | ((r >> 2) & 1);
- *(p + 17) = (*(p + 17) << 1) | ((r >> 3) & 1);
- *(p + 32) = (*(p + 32) << 1) | ((r >> 4) & 1);
- *(p + 33) = (*(p + 33) << 1) | ((r >> 5) & 1);
- *(p + 48) = (*(p + 48) << 1) | ((r >> 6) & 1);
- *(p + 49) = (*(p + 49) << 1) | ((r >> 7) & 1);
+ p[0] = (p[0] << 1) | ((r >> 0) & 1);
+ p[1] = (p[1] << 1) | ((r >> 1) & 1);
+ p[16] = (p[16] << 1) | ((r >> 2) & 1);
+ p[17] = (p[17] << 1) | ((r >> 3) & 1);
+ p[32] = (p[32] << 1) | ((r >> 4) & 1);
+ p[33] = (p[33] << 1) | ((r >> 5) & 1);
+ p[48] = (p[48] << 1) | ((r >> 6) & 1);
+ p[49] = (p[49] << 1) | ((r >> 7) & 1);
}
p += 2;
}
diff --git a/source/fxemu.c b/source/fxemu.c
index dd798fd..9d62b05 100644
--- a/source/fxemu.c
+++ b/source/fxemu.c
@@ -6,6 +6,8 @@
#include <string.h>
#include <stdio.h>
+#include <retro_inline.h>
+
/* The FxChip Emulator's internal variables */
FxRegs_s GSU; /* This will be initialized when loading a ROM */
@@ -27,13 +29,10 @@ void fx_updateRamBank(uint8_t Byte)
GSU.pvRamBank = GSU.apvRamBank[Byte & 0x3];
}
-static void fx_readRegisterSpaceForCheck(void)
+static INLINE void fx_readRegisterSpaceForCheck(void)
{
R15 = GSU.pvRegisters[30];
R15 |= ((uint32_t) GSU.pvRegisters[31]) << 8;
- GSU.vStatusReg = (uint32_t) GSU.pvRegisters[GSU_SFR];
- GSU.vStatusReg |= ((uint32_t) GSU.pvRegisters[GSU_SFR + 1]) << 8;
- GSU.vPrgBankReg = (uint32_t) GSU.pvRegisters[GSU_PBR];
}
static void fx_readRegisterSpaceForUse(void)
@@ -52,6 +51,9 @@ static void fx_readRegisterSpaceForUse(void)
/* Update other registers */
p = GSU.pvRegisters;
+ GSU.vStatusReg = (uint32_t) GSU.pvRegisters[GSU_SFR];
+ GSU.vStatusReg |= ((uint32_t) GSU.pvRegisters[GSU_SFR + 1]) << 8;
+ GSU.vPrgBankReg = (uint32_t) GSU.pvRegisters[GSU_PBR];
GSU.vRomBankReg = (uint32_t)p[GSU_ROMBR];
GSU.vRamBankReg = ((uint32_t)p[GSU_RAMBR]) & (FX_RAM_BANKS - 1);
GSU.vCacheBaseReg = (uint32_t)p[GSU_CBR];
@@ -75,9 +77,9 @@ static void fx_readRegisterSpaceForUse(void)
GSU.vScreenHeight = GSU.vScreenRealHeight = avHeight[i];
GSU.vMode = p[GSU_SCMR] & 0x03;
if (i == 3)
- GSU.vScreenSize = (256 / 8) * (256 / 8) * 32;
+ GSU.vScreenSize = 32768;
else
- GSU.vScreenSize = (GSU.vScreenHeight / 8) * (256 / 8) * avMult[GSU.vMode];
+ GSU.vScreenSize = GSU.vScreenHeight * 4 * avMult[GSU.vMode];
if (GSU.vPlotOptionReg & 0x10)
GSU.vScreenHeight = 256; /* OBJ Mode (for drawing into sprites) */
if (GSU.pvScreenBase + GSU.vScreenSize > GSU.pvRam + (GSU.nRamBanks * 65536))
@@ -90,7 +92,8 @@ static void fx_readRegisterSpaceForUse(void)
fx_apfOpcodeTable[0x24c] = GSU.pfPlot;
fx_apfOpcodeTable[0x34c] = GSU.pfRpix;
- fx_computeScreenPointers();
+ if(GSU.vMode != GSU.vPrevMode || GSU.vPrevScreenHeight != GSU.vScreenHeight || GSU.vSCBRDirty)
+ fx_computeScreenPointers();
}
void fx_dirtySCBR(void)
@@ -100,135 +103,52 @@ void fx_dirtySCBR(void)
void fx_computeScreenPointers(void)
{
- if (GSU.vMode != GSU.vPrevMode || GSU.vPrevScreenHeight != GSU.vScreenHeight || GSU.vSCBRDirty)
+ int32_t i, j, condition, mask, result;
+ uint32_t apvIncrement, vMode, xIncrement;
+ GSU.vSCBRDirty = false;
+
+ /* Make a list of pointers to the start of each screen column*/
+ vMode = GSU.vMode;
+ condition = vMode - 2;
+ mask = (condition | -condition) >> 31;
+ result = (vMode & mask) | (3 & ~mask);
+ vMode = result + 1;
+ GSU.x[0] = 0;
+ GSU.apvScreen[0] = GSU.pvScreenBase;
+ apvIncrement = vMode << 4;
+
+ if(GSU.vScreenHeight == 256)
{
- int32_t i;
- GSU.vSCBRDirty = false;
+ GSU.x[16] = vMode << 12;
+ GSU.apvScreen[16] = GSU.pvScreenBase + (vMode << 13);
+ apvIncrement <<= 4;
+ xIncrement = vMode << 4;
- /* Make a list of pointers to the start of each screen column */
- switch (GSU.vScreenHeight)
+ for(i = 1, j = 17 ; i < 16 ; i++, j++)
+ {
+ GSU.x[i] = GSU.x[i - 1] + xIncrement;
+ GSU.apvScreen[i] = GSU.apvScreen[i - 1] + apvIncrement;
+ GSU.x[j] = GSU.x[j - 1] + xIncrement;
+ GSU.apvScreen[j] = GSU.apvScreen[j - 1] + apvIncrement;
+ }
+ }
+ else
+ {
+ xIncrement = (vMode * GSU.vScreenHeight) << 1;
+ for(i = 1 ; i < 32 ; i++)
{
- case 128:
- switch (GSU.vMode)
- {
- case 0:
- for (i = 0; i < 32; i++)
- {
- GSU.apvScreen[i] = GSU.pvScreenBase + (i << 4);
- GSU.x[i] = i << 8;
- }
- break;
- case 1:
- for (i = 0; i < 32; i++)
- {
- GSU.apvScreen[i] = GSU.pvScreenBase + (i << 5);
- GSU.x[i] = i << 9;
- }
- break;
- case 2:
- case 3:
- for (i = 0; i < 32; i++)
- {
- GSU.apvScreen[i] = GSU.pvScreenBase + (i << 6);
- GSU.x[i] = i << 10;
- }
- break;
- }
- break;
- case 160:
- switch (GSU.vMode)
- {
- case 0:
- for (i = 0; i < 32; i++)
- {
- GSU.apvScreen[i] = GSU.pvScreenBase + (i << 4);
- GSU.x[i] = (i << 8) + (i << 6);
- }
- break;
- case 1:
- for (i = 0; i < 32; i++)
- {
- GSU.apvScreen[i] = GSU.pvScreenBase + (i << 5);
- GSU.x[i] = (i << 9) + (i << 7);
- }
- break;
- case 2:
- case 3:
- for (i = 0; i < 32; i++)
- {
- GSU.apvScreen[i] = GSU.pvScreenBase + (i << 6);
- GSU.x[i] = (i << 10) + (i << 8);
- }
- break;
- }
- break;
- case 192:
- switch (GSU.vMode)
- {
- case 0:
- for (i = 0; i < 32; i++)
- {
- GSU.apvScreen[i] = GSU.pvScreenBase + (i << 4);
- GSU.x[i] = (i << 8) + (i << 7);
- }
- break;
- case 1:
- for (i = 0; i < 32; i++)
- {
- GSU.apvScreen[i] = GSU.pvScreenBase + (i << 5);
- GSU.x[i] = (i << 9) + (i << 8);
- }
- break;
- case 2:
- case 3:
- for (i = 0; i < 32; i++)
- {
- GSU.apvScreen[i] = GSU.pvScreenBase + (i << 6);
- GSU.x[i] = (i << 10) + (i << 9);
- }
- break;
- }
- break;
- case 256:
- switch (GSU.vMode)
- {
- case 0:
- for (i = 0; i < 32; i++)
- {
- GSU.apvScreen[i] = GSU.pvScreenBase + ((i & 0x10) << 9) + ((i & 0xf) << 8);
- GSU.x[i] = ((i & 0x10) << 8) + ((i & 0xf) << 4);
- }
- break;
- case 1:
- for (i = 0; i < 32; i++)
- {
- GSU.apvScreen[i] = GSU.pvScreenBase + ((i & 0x10) << 10) + ((i & 0xf) << 9);
- GSU.x[i] = ((i & 0x10) << 9) + ((i & 0xf) << 5);
- }
- break;
- case 2:
- case 3:
- for (i = 0; i < 32; i++)
- {
- GSU.apvScreen[i] = GSU.pvScreenBase + ((i & 0x10) << 11) + ((i & 0xf) << 10);
- GSU.x[i] = ((i & 0x10) << 10) + ((i & 0xf) << 6);
- }
- break;
- }
- break;
+ GSU.x[i] = GSU.x[i - 1] + xIncrement;
+ GSU.apvScreen[i] = GSU.apvScreen[i - 1] + apvIncrement;
}
- GSU.vPrevMode = GSU.vMode;
- GSU.vPrevScreenHeight = GSU.vScreenHeight;
}
+ GSU.vPrevMode = GSU.vMode;
+ GSU.vPrevScreenHeight = GSU.vScreenHeight;
}
-static void fx_writeRegisterSpaceAfterCheck(void)
+static INLINE void fx_writeRegisterSpaceAfterCheck(void)
{
GSU.pvRegisters[30] = (uint8_t) R15;
GSU.pvRegisters[31] = (uint8_t) (R15 >> 8);
- GSU.pvRegisters[GSU_SFR] = (uint8_t) GSU.vStatusReg;
- GSU.pvRegisters[GSU_SFR + 1] = (uint8_t) (GSU.vStatusReg >> 8);
- GSU.pvRegisters[GSU_PBR] = (uint8_t) GSU.vPrgBankReg;
}
static void fx_writeRegisterSpaceAfterUse(void)
@@ -260,6 +180,9 @@ static void fx_writeRegisterSpaceAfterUse(void)
CF(CY);
p = GSU.pvRegisters;
+ p[GSU_SFR] = (uint8_t) GSU.vStatusReg;
+ p[GSU_SFR + 1] = (uint8_t) (GSU.vStatusReg >> 8);
+ p[GSU_PBR] = (uint8_t) GSU.vPrgBankReg;
p[GSU_ROMBR] = (uint8_t)GSU.vRomBankReg;
p[GSU_RAMBR] = (uint8_t)GSU.vRamBankReg;
p[GSU_CBR] = (uint8_t)GSU.vCacheBaseReg;
@@ -342,7 +265,7 @@ static bool fx_checkStartAddress(void)
return false;
/* Check if we're in RAM and the RAN flag is not set */
- if (GSU.vPrgBankReg >= 0x70 && GSU.vPrgBankReg <= 0x73 && !(SCMR & (1 << 3)))
+ if (GSU.vPrgBankReg >= 0x70 && !(SCMR & (1 << 3)))
return false;
/* If not, we're in ROM, so check if the RON flag is set */
diff --git a/source/gfx.c b/source/gfx.c
index f3b59a5..6dd9ff5 100644
--- a/source/gfx.c
+++ b/source/gfx.c
@@ -673,10 +673,9 @@ void S9xSetupOBJ(void)
for (Y = 1; Y < SNES_HEIGHT_EXTENDED; Y++)
GFX.OBJLines[Y].RTOFlags |= GFX.OBJLines[Y - 1].RTOFlags;
}
- else
+ else /* evil FirstSprite+Y case */
{
int32_t j, Y;
- /* evil FirstSprite+Y case */
/* First, find out which sprites are on which lines */
uint8_t OBJOnLine[SNES_HEIGHT_EXTENDED][128];
/* We only initialise this per line, as needed. [Neb]
@@ -2080,7 +2079,7 @@ static void DrawBackground(uint32_t BGMode, uint32_t bg, uint8_t Z1, uint8_t Z2)
int32_t X = ((AA + BB) >> 8) & 0x3ff; \
int32_t Y = ((CC + DD) >> 8) & 0x3ff; \
uint8_t *TileData = VRAM1 + (Memory.VRAM[((Y & ~7) << 5) + ((X >> 2) & ~1)] << 7); \
- uint32_t b = *(TileData + ((Y & 7) << 4) + ((X & 7) << 1)); \
+ uint32_t b = TileData[((Y & 7) << 4) + ((X & 7) << 1)]; \
GFX.Z1 = Mode7Depths [(b & GFX.Mode7PriorityMask) >> 7]; \
if (GFX.Z1 > *d && (b & GFX.Mode7Mask) ) \
{ \
@@ -2100,7 +2099,7 @@ static void DrawBackground(uint32_t BGMode, uint32_t bg, uint8_t Z1, uint8_t Z2)
if (((X | Y) & ~0x3ff) == 0) \
{ \
uint8_t *TileData = VRAM1 + (Memory.VRAM[((Y & ~7) << 5) + ((X >> 2) & ~1)] << 7); \
- uint32_t b = *(TileData + ((Y & 7) << 4) + ((X & 7) << 1)); \
+ uint32_t b = TileData[((Y & 7) << 4) + ((X & 7) << 1)]; \
GFX.Z1 = Mode7Depths [(b & GFX.Mode7PriorityMask) >> 7]; \
if (GFX.Z1 > *d && (b & GFX.Mode7Mask) ) \
{ \
@@ -2115,7 +2114,7 @@ static void DrawBackground(uint32_t BGMode, uint32_t bg, uint8_t Z1, uint8_t Z2)
uint32_t b; \
X = (x + HOffset) & 7; \
Y = (yy + CentreY) & 7; \
- b = *(VRAM1 + ((Y & 7) << 4) + ((X & 7) << 1)); \
+ b = VRAM1[((Y & 7) << 4) + ((X & 7) << 1)]; \
GFX.Z1 = Mode7Depths [(b & GFX.Mode7PriorityMask) >> 7]; \
if (GFX.Z1 > *d && (b & GFX.Mode7Mask) ) \
{ \
@@ -2284,7 +2283,7 @@ static void DrawBGMode7Background16Sub1_2(uint8_t * Screen, int32_t bg)
int32_t X = ((AA + BB) >> 8) & 0x3ff; \
int32_t Y = (DD >> 8) & 0x3ff; \
uint8_t *TileData = VRAM1 + (Memory.VRAM[((Y & ~7) << 5) + ((X >> 2) & ~1)] << 7); \
- b = *(TileData + ((Y & 7) << 4) + ((X & 7) << 1)); \
+ b = TileData[((Y & 7) << 4) + ((X & 7) << 1)]; \
GFX.Z1 = Mode7Depths [(b & GFX.Mode7PriorityMask) >> 7]; \
if (GFX.Z1 > *d && (b & GFX.Mode7Mask) ) \
{ \
@@ -2306,7 +2305,7 @@ static void DrawBGMode7Background16Sub1_2(uint8_t * Screen, int32_t bg)
if (((X | Y) & ~0x3ff) == 0) \
{ \
uint8_t *TileData = VRAM1 + (Memory.VRAM[((Y & ~7) << 5) + ((X >> 2) & ~1)] << 7); \
- b = *(TileData + ((Y & 7) << 4) + ((X & 7) << 1)); \
+ b = TileData[((Y & 7) << 4) + ((X & 7) << 1)]; \
GFX.Z1 = Mode7Depths [(b & GFX.Mode7PriorityMask) >> 7]; \
if (GFX.Z1 > *d && (b & GFX.Mode7Mask) ) \
{ \
@@ -2322,7 +2321,7 @@ static void DrawBGMode7Background16Sub1_2(uint8_t * Screen, int32_t bg)
X = (x + HOffset) & 7; \
Y = (yy + CentreY) & 7; \
TileData = VRAM1 + (Memory.VRAM[((Y & ~7) << 5) + ((X >> 2) & ~1)] << 7); \
- b = *(TileData + ((Y & 7) << 4) + ((X & 7) << 1)); \
+ b = TileData[((Y & 7) << 4) + ((X & 7) << 1)]; \
GFX.Z1 = Mode7Depths [(b & GFX.Mode7PriorityMask) >> 7]; \
if (GFX.Z1 > *d && (b & GFX.Mode7Mask) ) \
{ \
@@ -2360,7 +2359,7 @@ static void DrawBGMode7Background16Sub1_2(uint8_t * Screen, int32_t bg)
uint32_t X = xPix & 0x3ff; \
uint32_t Y = yPix & 0x3ff; \
uint8_t *TileData = VRAM1 + (Memory.VRAM[((Y & ~7) << 5) + ((X >> 2) & ~1)] << 7); \
- b = *(TileData + ((Y & 7) << 4) + ((X & 7) << 1)); \
+ b = TileData[((Y & 7) << 4) + ((X & 7) << 1)]; \
GFX.Z1 = Mode7Depths [(b & GFX.Mode7PriorityMask) >> 7]; \
if (GFX.Z1 > *d && (b & GFX.Mode7Mask) ) \
{ \
@@ -2375,13 +2374,13 @@ static void DrawBGMode7Background16Sub1_2(uint8_t * Screen, int32_t bg)
uint8_t *TileData01 = VRAM1 + (Memory.VRAM[((Y01 & ~7) << 5) + ((X >> 2) & ~1)] << 7); \
p1 = COLORFUNC; \
p1 = (p1 & FIRST_THIRD_COLOR_MASK) | ((p1 & SECOND_COLOR_MASK) << 16); \
- b = *(TileData10 + ((Y & 7) << 4) + ((X10 & 7) << 1)); \
+ b = TileData10[((Y & 7) << 4) + ((X10 & 7) << 1)]; \
p2 = COLORFUNC; \
p2 = (p2 & FIRST_THIRD_COLOR_MASK) | ((p2 & SECOND_COLOR_MASK) << 16); \
- b = *(TileData11 + ((Y01 & 7) << 4) + ((X10 & 7) << 1)); \
+ b = TileData11[((Y01 & 7) << 4) + ((X10 & 7) << 1)]; \
p4 = COLORFUNC; \
p4 = (p4 & FIRST_THIRD_COLOR_MASK) | ((p4 & SECOND_COLOR_MASK) << 16); \
- b = *(TileData01 + ((Y01 & 7) << 4) + ((X & 7) << 1)); \
+ b = TileData01[((Y01 & 7) << 4) + ((X & 7) << 1)]; \
p3 = COLORFUNC; \
p3 = (p3 & FIRST_THIRD_COLOR_MASK) | ((p3 & SECOND_COLOR_MASK) << 16); \
/* Xdel, Ydel: position (in 1/32nds) between the points */ \
@@ -2439,7 +2438,7 @@ static void DrawBGMode7Background16Sub1_2(uint8_t * Screen, int32_t bg)
uint32_t X = ((AA + BB) >> 8) & 0x3ff; \
uint32_t Y = ((CC + DD) >> 8) & 0x3ff; \
uint8_t *TileData = VRAM1 + (Memory.VRAM[((Y & ~7) << 5) + ((X >> 2) & ~1)] << 7); \
- b = *(TileData + ((Y & 7) << 4) + ((X & 7) << 1)); \
+ b = TileData[((Y & 7) << 4) + ((X & 7) << 1)]; \
GFX.Z1 = Mode7Depths [(b & GFX.Mode7PriorityMask) >> 7]; \
if (GFX.Z1 > *d && (b & GFX.Mode7Mask) ) \
{ \
@@ -2456,11 +2455,11 @@ static void DrawBGMode7Background16Sub1_2(uint8_t * Screen, int32_t bg)
uint8_t *TileData01 = VRAM1 + (Memory.VRAM[((Y01 & ~7) << 5) + ((X01 >> 2) & ~1)] << 7); \
uint8_t *TileData11 = VRAM1 + (Memory.VRAM[((Y11 & ~7) << 5) + ((X11 >> 2) & ~1)] << 7); \
p1 = COLORFUNC; \
- b = *(TileData10 + ((Y10 & 7) << 4) + ((X10 & 7) << 1)); \
+ b = TileData10[((Y10 & 7) << 4) + ((X10 & 7) << 1)]; \
p2 = COLORFUNC; \
- b = *(TileData01 + ((Y01 & 7) << 4) + ((X01 & 7) << 1)); \
+ b = TileData01[((Y01 & 7) << 4) + ((X01 & 7) << 1)]; \
p3 = COLORFUNC; \
- b = *(TileData11 + ((Y11 & 7) << 4) + ((X11 & 7) << 1)); \
+ b = TileData11[((Y11 & 7) << 4) + ((X11 & 7) << 1)]; \
p4 = COLORFUNC; \
theColor = Q_INTERPOLATE(p1, p2, p3, p4); \
*p = (FUNC) | ALPHA_BITS_MASK; \
@@ -2485,7 +2484,7 @@ static void DrawBGMode7Background16Sub1_2(uint8_t * Screen, int32_t bg)
if (((X | Y) & ~0x3ff) == 0) \
{ \
uint8_t *TileData = VRAM1 + (Memory.VRAM[((Y & ~7) << 5) + ((X >> 2) & ~1)] << 7); \
- b = *(TileData + ((Y & 7) << 4) + ((X & 7) << 1)); \
+ b = TileData[((Y & 7) << 4) + ((X & 7) << 1)]; \
GFX.Z1 = Mode7Depths [(b & GFX.Mode7PriorityMask) >> 7]; \
if (GFX.Z1 > *d && (b & GFX.Mode7Mask) ) \
{ \
@@ -2501,13 +2500,13 @@ static void DrawBGMode7Background16Sub1_2(uint8_t * Screen, int32_t bg)
uint8_t *TileData01 = VRAM1 + (Memory.VRAM[((Y01 & ~7) << 5) + ((X >> 2) & ~1)] << 7); \
p1 = COLORFUNC; \
p1 = (p1 & FIRST_THIRD_COLOR_MASK) | ((p1 & SECOND_COLOR_MASK) << 16); \
- b = *(TileData10 + ((Y & 7) << 4) + ((X10 & 7) << 1)); \
+ b = TileData10[((Y & 7) << 4) + ((X10 & 7) << 1)]; \
p2 = COLORFUNC; \
p2 = (p2 & FIRST_THIRD_COLOR_MASK) | ((p2 & SECOND_COLOR_MASK) << 16); \
- b = *(TileData11 + ((Y01 & 7) << 4) + ((X10 & 7) << 1)); \
+ b = TileData11[((Y01 & 7) << 4) + ((X10 & 7) << 1)]; \
p4 = COLORFUNC; \
p4 = (p4 & FIRST_THIRD_COLOR_MASK) | ((p4 & SECOND_COLOR_MASK) << 16); \
- b = *(TileData01 + ((Y01 & 7) << 4) + ((X & 7) << 1)); \
+ b = TileData01[((Y01 & 7) << 4) + ((X & 7) << 1)]; \
p3 = COLORFUNC; \
p3 = (p3 & FIRST_THIRD_COLOR_MASK) | ((p3 & SECOND_COLOR_MASK) << 16); \
/* Xdel, Ydel: position (in 1/32nds) between the points */ \
@@ -2533,7 +2532,7 @@ static void DrawBGMode7Background16Sub1_2(uint8_t * Screen, int32_t bg)
{ \
X = (x + HOffset) & 7; \
Y = (yy + CentreY) & 7; \
- b = *(VRAM1 + ((Y & 7) << 4) + ((X & 7) << 1)); \
+ b = VRAM1[((Y & 7) << 4) + ((X & 7) << 1)]; \
GFX.Z1 = Mode7Depths [(b & GFX.Mode7PriorityMask) >> 7]; \
if (GFX.Z1 > *d && (b & GFX.Mode7Mask) ) \
{ \
@@ -2768,10 +2767,10 @@ void S9xUpdateScreen(void)
for (y = 0; y < starty; y++)
{
int32_t x;
- uint16_t* p = (uint16_t*)(GFX.Screen + y * GFX.Pitch2) + 255;
- uint16_t* q = (uint16_t*)(GFX.Screen + y * GFX.Pitch2) + 510;
+ uint16_t* p = (uint16_t*) (GFX.Screen + y * GFX.Pitch2) + 255;
+ uint16_t* q = (uint16_t*) p + 255;
for (x = 255; x >= 0; x--, p--, q -= 2)
- * q = *(q + 1) = *p;
+ q[0] = q[1] = p[0];
}
IPPU.DoubleWidthPixels = true;
IPPU.HalfWidthPixels = false;
@@ -3219,9 +3218,9 @@ void S9xUpdateScreen(void)
{
int32_t x;
uint16_t* p = (uint16_t*)(GFX.Screen + y * GFX.Pitch2) + 255;
- uint16_t* q = (uint16_t*)(GFX.Screen + y * GFX.Pitch2) + 510;
+ uint16_t* q = p + 255;
for (x = 255; x >= 0; x--, p--, q -= 2)
- * q = *(q + 1) = *p;
+ q[0] = q[1] = p[0];
}
}
diff --git a/source/sa1.c b/source/sa1.c
index b17b562..afa3021 100644
--- a/source/sa1.c
+++ b/source/sa1.c
@@ -151,7 +151,7 @@ void S9xSA1SetByte(uint8_t byte, uint32_t address)
if (SetAddress >= (uint8_t*) MAP_LAST)
{
- *(SetAddress + (address & 0xffff)) = byte;
+ SetAddress[address & 0xffff] = byte;
return;
}
@@ -162,10 +162,10 @@ void S9xSA1SetByte(uint8_t byte, uint32_t address)
return;
case MAP_SA1RAM:
case MAP_LOROM_SRAM:
- *(Memory.SRAM + (address & 0xffff)) = byte;
+ Memory.SRAM[address & 0xffff] = byte;
return;
case MAP_BWRAM:
- *(SA1.BWRAM + ((address & 0x7fff) - 0x6000)) = byte;
+ SA1.BWRAM[(address & 0x7fff) - 0x6000] = byte;
return;
case MAP_BWRAM_BITMAP:
address -= 0x600000;
@@ -186,7 +186,7 @@ void S9xSA1SetByte(uint8_t byte, uint32_t address)
address = (address & 0xffff) - 0x6000;
if (SA1.VirtualBitmapFormat == 2)
{
- uint8_t* ptr = &SA1.BWRAM [(address >> 2) & 0xffff];
+ uint8_t* ptr = &SA1.BWRAM[(address >> 2) & 0xffff];
*ptr &= ~(3 << ((address & 3) << 1));
*ptr |= (byte & 3) << ((address & 3) << 1);
}
@@ -264,8 +264,8 @@ void S9xSetSA1MemMap(uint32_t which1, uint8_t map)
for (c = 0; c < 0x200; c += 16)
{
- /*Code from Snes9x 1.54.1 - This allows Super Mario World VLDC 9 hack to load.
- Conversion to int is needed here - map is promoted but which1 is not */
+ /* Code from Snes9x 1.54.1 - This allows Super Mario World VLDC 9 hack to load.
+ Conversion to int is needed here - map is promoted but which1 is not */
int32_t offset = (((map & 0x80) ? map : which1) & 7) * 0x100000 + (c << 11) - 0x8000;
block = &Memory.ROM [offset];
for (i = c + 8; i < c + 16; i++)
@@ -532,35 +532,60 @@ void S9xSetSA1(uint8_t byte, uint32_t address)
Memory.FillRAM[address] = byte;
}
-static void S9xSA1CharConv2()
+static void S9xSA1CharConv2(void)
{
- uint32_t dest = Memory.FillRAM [0x2235] | (Memory.FillRAM [0x2236] << 8);
+ uint32_t dest = Memory.FillRAM[0x2235] | (Memory.FillRAM[0x2236] << 8);
uint32_t offset = (SA1.in_char_dma & 7) ? 0 : 1;
- int32_t depth = (Memory.FillRAM [0x2231] & 3) == 0 ? 8 : (Memory.FillRAM [0x2231] & 3) == 1 ? 4 : 2;
- int32_t bytes_per_char = 8 * depth;
- uint8_t* p = &Memory.FillRAM [0x3000] + dest + offset * bytes_per_char;
- uint8_t* q = &Memory.ROM [MAX_ROM_SIZE - 0x10000] + offset * 64;
+ int32_t depthX8 = (Memory.FillRAM[0x2231] & 3) == 0 ? 64 : (Memory.FillRAM[0x2231] & 3) == 1 ? 32 : 16;
+ uint8_t* p = &Memory.FillRAM[0x3000] + (dest & 0x7ff) + offset * depthX8;
+ uint8_t* q = &Memory.ROM[MAX_ROM_SIZE - 0x10000] + offset * 64;
- if (depth == 8)
+ switch(depthX8)
{
- int32_t l;
- for (l = 0; l < 8; l++, q += 8)
- {
- int32_t b;
- for (b = 0; b < 8; b++)
+ case 16:
+ for (int l = 0; l < 8; l++, q += 8)
{
- uint8_t r = *(q + b);
- *(p + 0) = (*(p + 0) << 1) | ((r >> 0) & 1);
- *(p + 1) = (*(p + 1) << 1) | ((r >> 1) & 1);
- *(p + 16) = (*(p + 16) << 1) | ((r >> 2) & 1);
- *(p + 17) = (*(p + 17) << 1) | ((r >> 3) & 1);
- *(p + 32) = (*(p + 32) << 1) | ((r >> 4) & 1);
- *(p + 33) = (*(p + 33) << 1) | ((r >> 5) & 1);
- *(p + 48) = (*(p + 48) << 1) | ((r >> 6) & 1);
- *(p + 49) = (*(p + 49) << 1) | ((r >> 7) & 1);
+ for (int b = 0; b < 8; b++)
+ {
+ uint8_t r = q[b];
+ p[0] = (p[0] << 1) | ((r >> 0) & 1);
+ p[1] = (p[1] << 1) | ((r >> 1) & 1);
+ }
+ p += 2;
}
- p += 2;
- }
+ break;
+ case 32:
+ for (int l = 0; l < 8; l++, q += 8)
+ {
+ for (int b = 0; b < 8; b++)
+ {
+ uint8_t r = q[b];
+ p[0] = (p[0] << 1) | ((r >> 0) & 1);
+ p[1] = (p[1] << 1) | ((r >> 1) & 1);
+ p[16] = (p[16] << 1) | ((r >> 2) & 1);
+ p[17] = (p[17] << 1) | ((r >> 3) & 1);
+ }
+ p += 2;
+ }
+ break;
+ case 64:
+ for (int l = 0; l < 8; l++, q += 8)
+ {
+ for (int b = 0; b < 8; b++)
+ {
+ uint8_t r = q[b];
+ p[0] = (p[0] << 1) | ((r >> 0) & 1);
+ p[1] = (p[1] << 1) | ((r >> 1) & 1);
+ p[16] = (p[16] << 1) | ((r >> 2) & 1);
+ p[17] = (p[17] << 1) | ((r >> 3) & 1);
+ p[32] = (p[32] << 1) | ((r >> 4) & 1);
+ p[33] = (p[33] << 1) | ((r >> 5) & 1);
+ p[48] = (p[48] << 1) | ((r >> 6) & 1);
+ p[49] = (p[49] << 1) | ((r >> 7) & 1);
+ }
+ p += 2;
+ }
+ break;
}
}
diff --git a/source/soundux.c b/source/soundux.c
index 0de7f4b..ebf6915 100644
--- a/source/soundux.c
+++ b/source/soundux.c
@@ -391,8 +391,8 @@ void DecodeBlock(Channel* ch)
*raw++ = ((int32_t) sample1 << shift);
*raw++ = ((int32_t) sample2 << shift);
}
- prev1 = *(raw - 2);
- prev0 = *(raw - 1);
+ prev1 = raw[-2];
+ prev0 = raw[-1];
break;
case 1:
for (i = 8; i != 0; i--)
diff --git a/source/spc700.c b/source/spc700.c
index c5ea4ef..f16ba5b 100644
--- a/source/spc700.c
+++ b/source/spc700.c
@@ -111,14 +111,14 @@ uint32_t Work32 = 0;
#define Pop(b) \
IAPU.Registers.S++; \
- (b) = *(IAPU.RAM + 0x100 + IAPU.Registers.S)
+ (b) = IAPU.RAM[0x100 + IAPU.Registers.S]
#ifdef FAST_LSB_WORD_ACCESS
#define PushW(w) \
if (IAPU.Registers.S == 0) \
{\
- *(IAPU.RAM + 0x1ff) = (w); \
- *(IAPU.RAM + 0x100) = ((w) >> 8); \
+ IAPU.RAM[0x1ff] = (w); \
+ IAPU.RAM[0x100] = ((w) >> 8); \
} \
else \
*(uint16_t *) (IAPU.RAM + 0xff + IAPU.Registers.S) = w; \
@@ -127,21 +127,21 @@ uint32_t Work32 = 0;
#define PopW(w) \
IAPU.Registers.S += 2; \
if (IAPU.Registers.S == 0) \
- (w) = *(IAPU.RAM + 0x1ff) | (*(IAPU.RAM + 0x100) << 8); \
+ (w) = IAPU.RAM[0x1ff] | (IAPU.RAM[0x100] << 8); \
else \
(w) = *(uint16_t *) (IAPU.RAM + 0xff + IAPU.Registers.S)
#else
#define PushW(w) \
- *(IAPU.RAM + 0xff + IAPU.Registers.S) = w; \
- *(IAPU.RAM + 0x100 + IAPU.Registers.S) = ((w) >> 8); \
+ IAPU.RAM[0xff + IAPU.Registers.S] = w; \
+ IAPU.RAM[0x100 + IAPU.Registers.S] = ((w) >> 8); \
IAPU.Registers.S -= 2
#define PopW(w) \
IAPU.Registers.S += 2; \
if(IAPU.Registers.S == 0) \
- (w) = *(IAPU.RAM + 0x1ff) | (*(IAPU.RAM + 0x100) << 8); \
+ (w) = IAPU.RAM[0x1ff] | (IAPU.RAM[0x100] << 8); \
else \
- (w) = *(IAPU.RAM + 0xff + IAPU.Registers.S) + (*(IAPU.RAM + 0x100 + IAPU.Registers.S) << 8)
+ (w) = IAPU.RAM[0xff + IAPU.Registers.S] + (IAPU.RAM[0x100 + IAPU.Registers.S] << 8)
#endif
#define Relative() \
@@ -174,8 +174,8 @@ uint32_t Work32 = 0;
IAPU.Address = *(uint16_t *) (IAPU.DirectPage + OP1) + IAPU.Registers.YA.B.Y;
#else
#define IndexedXIndirect() \
- IAPU.Address = *(IAPU.DirectPage + ((OP1 + IAPU.Registers.X) & 0xff)) + \
- (*(IAPU.DirectPage + ((OP1 + IAPU.Registers.X + 1) & 0xff)) << 8);
+ IAPU.Address = IAPU.DirectPage[(OP1 + IAPU.Registers.X) & 0xff] + \
+ (IAPU.DirectPage[(OP1 + IAPU.Registers.X + 1) & 0xff] << 8);
#define Absolute() \
IAPU.Address = OP1 + (OP2 << 8);
@@ -192,8 +192,8 @@ uint32_t Work32 = 0;
IAPU.Address &= 0x1fff;
#define IndirectIndexedY() \
- IAPU.Address = *(IAPU.DirectPage + OP1) + \
- (*(IAPU.DirectPage + OP1 + 1) << 8) + \
+ IAPU.Address = IAPU.DirectPage[OP1] + \
+ (IAPU.DirectPage[OP1 + 1] << 8) + \
IAPU.Registers.YA.B.Y;
#endif
diff --git a/source/tile.c b/source/tile.c
index aa0cfaf..17a2934 100644
--- a/source/tile.c
+++ b/source/tile.c
@@ -779,9 +779,10 @@ static void WRITE_4PIXELS16_ADDF1_2(int32_t Offset, uint8_t* Pixels, uint16_t* S
{
if (GFX.Z1 > Depth [N] && (Pixel = Pixels[N]))
{
- Screen [N] = ScreenColors [Pixel];
if (SubDepth [N] == 1)
Screen [N] = (uint16_t)(COLOR_ADD1_2(ScreenColors [Pixel], GFX.FixedColour));
+ else
+ Screen [N] = ScreenColors [Pixel];
Depth [N] = GFX.Z2;
}
}
@@ -798,9 +799,10 @@ static void WRITE_4PIXELS16_FLIPPED_ADDF1_2(int32_t Offset, uint8_t* Pixels, uin
{
if (GFX.Z1 > Depth [N] && (Pixel = Pixels[3 - N]))
{
- Screen [N] = ScreenColors [Pixel];
if (SubDepth [N] == 1)
Screen [N] = (uint16_t)(COLOR_ADD1_2(ScreenColors [Pixel], GFX.FixedColour));
+ else
+ Screen [N] = ScreenColors [Pixel];
Depth [N] = GFX.Z2;
}
}
@@ -817,9 +819,10 @@ static void WRITE_4PIXELS16_SUBF1_2(int32_t Offset, uint8_t* Pixels, uint16_t* S
{
if (GFX.Z1 > Depth [N] && (Pixel = Pixels[N]))
{
- Screen [N] = ScreenColors [Pixel];
if (SubDepth [N] == 1)
Screen [N] = (uint16_t) COLOR_SUB1_2(ScreenColors [Pixel], GFX.FixedColour);
+ else
+ Screen [N] = ScreenColors [Pixel];
Depth [N] = GFX.Z2;
}
}
@@ -836,9 +839,10 @@ static void WRITE_4PIXELS16_FLIPPED_SUBF1_2(int32_t Offset, uint8_t* Pixels, uin
{
if (GFX.Z1 > Depth [N] && (Pixel = Pixels[3 - N]))
{
- Screen [N] = ScreenColors [Pixel];
if (SubDepth [N] == 1)
Screen [N] = (uint16_t) COLOR_SUB1_2(ScreenColors [Pixel], GFX.FixedColour);
+ else
+ Screen [N] = ScreenColors [Pixel];
Depth [N] = GFX.Z2;
}
}
@@ -924,7 +928,7 @@ void DrawLargePixel16Sub(uint32_t Tile, int32_t Offset, uint32_t StartPixel, uin
#define LARGE_SUB_PIXEL(s, p) \
(Depth [z + GFX.DepthDelta] ? (Depth [z + GFX.DepthDelta] != 1 ? \
- COLOR_SUB (p, *(s + GFX.Delta)) : \
+ COLOR_SUB (p, *(s + GFX.Delta)) : \
COLOR_SUB (p, GFX.FixedColour)) : p)
RENDER_TILE_LARGE(ScreenColors [pixel], LARGE_SUB_PIXEL);
@@ -940,7 +944,7 @@ void DrawLargePixel16Sub1_2(uint32_t Tile, int32_t Offset, uint32_t StartPixel,
#define LARGE_SUB_PIXEL1_2(s, p) \
(Depth [z + GFX.DepthDelta] ? (Depth [z + GFX.DepthDelta] != 1 ? \
- COLOR_SUB1_2 (p, *(s + GFX.Delta)) : \
+ COLOR_SUB1_2 (p, *(s + GFX.Delta)) : \
COLOR_SUB (p, GFX.FixedColour)) : p)
RENDER_TILE_LARGE(ScreenColors [pixel], LARGE_SUB_PIXEL1_2);