summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMichael Panzlaff <michael.panzlaff@fau.de>2019-06-25 22:59:21 +0200
committerhuderlem <huderlem@gmail.com>2019-06-29 11:08:46 -0500
commit75005346769b2733dd36ff7ae2239709bc1bc983 (patch)
treebf389c811fa313bb0379cf915f0aa57061c6f5eb /src
parentf3c7e1cc819f1927353f7c236ee36c4965c05167 (diff)
fix unaligned memory access in BlendPalette
This problem is only going to occur in versions where the palette buffer isn't aligned to 4 bytes (which it is in a matching pokeemerald). Since agbcc returns sizeof(PlttData) = 4, it will read words instead of half words. This causes unnecessary emulator warnings in the function "BlendPalette". Aligning the buffers to 4 bytes fixes this.
Diffstat (limited to 'src')
-rw-r--r--src/palette.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/palette.c b/src/palette.c
index 5d1d6635c..eb49ce4c6 100644
--- a/src/palette.c
+++ b/src/palette.c
@@ -54,8 +54,10 @@ static void UpdateBlendRegisters(void);
static bool8 IsSoftwarePaletteFadeFinishing(void);
static void sub_80A2D54(u8 taskId);
-EWRAM_DATA u16 gPlttBufferUnfaded[PLTT_BUFFER_SIZE] = {0};
-EWRAM_DATA u16 gPlttBufferFaded[PLTT_BUFFER_SIZE] = {0};
+// palette buffers require alignment with agbcc because
+// unaligned word reads are issued in BlendPalette otherwise
+ALIGNED(4) EWRAM_DATA u16 gPlttBufferUnfaded[PLTT_BUFFER_SIZE] = {0};
+ALIGNED(4) EWRAM_DATA u16 gPlttBufferFaded[PLTT_BUFFER_SIZE] = {0};
EWRAM_DATA struct PaletteStruct sPaletteStructs[0x10] = {0};
EWRAM_DATA struct PaletteFadeControl gPaletteFade = {0};
static EWRAM_DATA u32 gFiller_2037FE0 = 0;