From 7becd31bfe9ba0cd77ed9dc034563e0ab513a8c9 Mon Sep 17 00:00:00 2001 From: João Silva Date: Sat, 26 Aug 2017 00:26:09 +0100 Subject: Still cleaning things up... --- Makefile | 2 +- source/cheats.c | 2 +- source/cheats2.c | 4 ++-- source/cpuaddr.h | 42 +++++++++++++++++++++--------------------- source/dma.c | 48 ++++++++++++++++++++++++------------------------ source/gfx.c | 51 +++++++++++++++++++++++++-------------------------- source/soundux.c | 4 ++-- source/spc700.c | 24 ++++++++++++------------ source/tile.c | 16 ++++++++++------ 9 files changed, 98 insertions(+), 95 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/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/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); -- cgit v1.2.3