diff --git a/gflib/bg.c b/gflib/bg.c index 4e426b762b45..08bc402f7191 100644 --- a/gflib/bg.c +++ b/gflib/bg.c @@ -19,9 +19,6 @@ struct BgControl u8 charBaseIndex:2; u8 mapBaseIndex:5; u8 paletteMode:1; - - u8 unknown_2; // Assigned to but never read - u8 unknown_3; // Assigned to but never read } configs[NUM_BACKGROUNDS]; u16 bgVisibilityAndMode; @@ -31,7 +28,6 @@ struct BgConfig2 { u32 baseTile:10; u32 basePalette:4; - u32 unk_3:18; void *tilemap; s32 bg_x; @@ -46,7 +42,7 @@ u32 gWindowTileAutoAllocEnabled; static const struct BgConfig sZeroedBgControlStruct = { 0 }; -static u32 GetBgType(u8 bg); +static u32 GetBgType(u32 bg); void ResetBgs(void) { @@ -55,13 +51,13 @@ void ResetBgs(void) SetTextModeAndHideBgs(); } -static void SetBgModeInternal(u8 bgMode) +static void SetBgModeInternal(u32 bgMode) { sGpuBgConfigs.bgVisibilityAndMode &= ~0x7; sGpuBgConfigs.bgVisibilityAndMode |= bgMode; } -u8 GetBgMode(void) +u32 GetBgMode(void) { return sGpuBgConfigs.bgVisibilityAndMode & 0x7; } @@ -76,7 +72,7 @@ void ResetBgControlStructs(void) } } -void Unused_ResetBgControlStruct(u8 bg) +void Unused_ResetBgControlStruct(u32 bg) { if (!IsInvalidBg(bg)) { @@ -96,7 +92,7 @@ enum BG_CTRL_ATTR_WRAPAROUND = 8, }; -static void SetBgControlAttributes(u8 bg, u8 charBaseIndex, u8 mapBaseIndex, u8 screenSize, u8 paletteMode, u8 priority, u8 mosaic, u8 wraparound) +static void SetBgControlAttributes(u32 bg, u8 charBaseIndex, u8 mapBaseIndex, u8 screenSize, u8 paletteMode, u8 priority, u8 mosaic, u8 wraparound) { if (!IsInvalidBg(bg)) { @@ -135,14 +131,11 @@ static void SetBgControlAttributes(u8 bg, u8 charBaseIndex, u8 mapBaseIndex, u8 sGpuBgConfigs.configs[bg].wraparound = wraparound; } - sGpuBgConfigs.configs[bg].unknown_2 = 0; - sGpuBgConfigs.configs[bg].unknown_3 = 0; - sGpuBgConfigs.configs[bg].visible = 1; } } -static u16 GetBgControlAttribute(u8 bg, u8 attributeId) +static u16 GetBgControlAttribute(u32 bg, u32 attributeId) { if (!IsInvalidBg(bg) && sGpuBgConfigs.configs[bg].visible) { @@ -170,7 +163,7 @@ static u16 GetBgControlAttribute(u8 bg, u8 attributeId) return 0xFF; } -u8 LoadBgVram(u8 bg, const void *src, u16 size, u16 destOffset, u8 mode) +u8 LoadBgVram(u32 bg, const void *src, u16 size, u16 destOffset, u32 mode) { u16 offset; s8 cursor; @@ -202,7 +195,7 @@ u8 LoadBgVram(u8 bg, const void *src, u16 size, u16 destOffset, u8 mode) return cursor; } -static void ShowBgInternal(u8 bg) +static void ShowBgInternal(u32 bg) { u16 value; if (!IsInvalidBg(bg) && sGpuBgConfigs.configs[bg].visible) @@ -222,7 +215,7 @@ static void ShowBgInternal(u8 bg) } } -static void HideBgInternal(u8 bg) +static void HideBgInternal(u32 bg) { if (!IsInvalidBg(bg)) { @@ -241,7 +234,7 @@ void SetTextModeAndHideBgs(void) SetGpuReg(REG_OFFSET_DISPCNT, GetGpuReg(REG_OFFSET_DISPCNT) & ~DISPCNT_ALL_BG_AND_MODE_BITS); } -static void SetBgAffineInternal(u8 bg, s32 srcCenterX, s32 srcCenterY, s16 dispCenterX, s16 dispCenterY, s16 scaleX, s16 scaleY, u16 rotationAngle) +static void SetBgAffineInternal(u32 bg, s32 srcCenterX, s32 srcCenterY, s16 dispCenterX, s16 dispCenterY, s16 scaleX, s16 scaleY, u16 rotationAngle) { struct BgAffineSrcData src; struct BgAffineDstData dest; @@ -282,7 +275,7 @@ static void SetBgAffineInternal(u8 bg, s32 srcCenterX, s32 srcCenterY, s16 dispC SetGpuReg(REG_OFFSET_BG2Y_H, (s16)(dest.dy >> 16)); } -bool8 IsInvalidBg(u8 bg) +bool32 IsInvalidBg(u32 bg) { if (bg >= NUM_BACKGROUNDS) return TRUE; @@ -309,10 +302,10 @@ void ResetBgsAndClearDma3BusyFlags(u32 leftoverFireRedLeafGreenVariable) gWindowTileAutoAllocEnabled = leftoverFireRedLeafGreenVariable; } -void InitBgsFromTemplates(u8 bgMode, const struct BgTemplate *templates, u8 numTemplates) +void InitBgsFromTemplates(u32 bgMode, const struct BgTemplate *templates, u8 numTemplates) { int i; - u8 bg; + u32 bg; SetBgModeInternal(bgMode); ResetBgControlStructs(); @@ -333,7 +326,6 @@ void InitBgsFromTemplates(u8 bgMode, const struct BgTemplate *templates, u8 numT sGpuBgConfigs2[bg].baseTile = templates[i].baseTile; sGpuBgConfigs2[bg].basePalette = 0; - sGpuBgConfigs2[bg].unk_3 = 0; sGpuBgConfigs2[bg].tilemap = NULL; sGpuBgConfigs2[bg].bg_x = 0; @@ -344,7 +336,7 @@ void InitBgsFromTemplates(u8 bgMode, const struct BgTemplate *templates, u8 numT void InitBgFromTemplate(const struct BgTemplate *template) { - u8 bg = template->bg; + u32 bg = template->bg; if (bg < NUM_BACKGROUNDS) { @@ -359,7 +351,6 @@ void InitBgFromTemplate(const struct BgTemplate *template) sGpuBgConfigs2[bg].baseTile = template->baseTile; sGpuBgConfigs2[bg].basePalette = 0; - sGpuBgConfigs2[bg].unk_3 = 0; sGpuBgConfigs2[bg].tilemap = NULL; sGpuBgConfigs2[bg].bg_x = 0; @@ -367,12 +358,12 @@ void InitBgFromTemplate(const struct BgTemplate *template) } } -void SetBgMode(u8 bgMode) +void SetBgMode(u32 bgMode) { SetBgModeInternal(bgMode); } -u16 LoadBgTiles(u8 bg, const void *src, u16 size, u16 destOffset) +u16 LoadBgTiles(u32 bg, const void *src, u16 size, u16 destOffset) { u16 tileOffset; u8 cursor; @@ -404,7 +395,7 @@ u16 LoadBgTiles(u8 bg, const void *src, u16 size, u16 destOffset) return cursor; } -u16 LoadBgTilemap(u8 bg, const void *src, u16 size, u16 destOffset) +u16 LoadBgTilemap(u32 bg, const void *src, u16 size, u16 destOffset) { u8 cursor = LoadBgVram(bg, src, size, destOffset * 2, DISPCNT_MODE_2); @@ -418,11 +409,11 @@ u16 LoadBgTilemap(u8 bg, const void *src, u16 size, u16 destOffset) return cursor; } -u16 Unused_LoadBgPalette(u8 bg, const void *src, u16 size, u16 destOffset) +u16 Unused_LoadBgPalette(u32 bg, const void *src, u16 size, u16 destOffset) { s8 cursor; - if (!IsInvalidBg32(bg)) + if (!IsInvalidBg(bg)) { u16 paletteOffset = PLTT_OFFSET_4BPP(sGpuBgConfigs2[bg].basePalette) + (destOffset * 2); cursor = RequestDma3Copy(src, (void *)(paletteOffset + BG_PLTT), size, 0); @@ -440,7 +431,7 @@ u16 Unused_LoadBgPalette(u8 bg, const void *src, u16 size, u16 destOffset) return (u8)cursor; } -bool8 IsDma3ManagerBusyWithBgCopy(void) +bool32 IsDma3ManagerBusyWithBgCopy(void) { int i; @@ -464,19 +455,19 @@ bool8 IsDma3ManagerBusyWithBgCopy(void) return FALSE; } -void ShowBg(u8 bg) +void ShowBg(u32 bg) { ShowBgInternal(bg); SyncBgVisibilityAndMode(); } -void HideBg(u8 bg) +void HideBg(u32 bg) { HideBgInternal(bg); SyncBgVisibilityAndMode(); } -void SetBgAttribute(u8 bg, u8 attributeId, u8 value) +void SetBgAttribute(u32 bg, u32 attributeId, u8 value) { switch (attributeId) { @@ -504,7 +495,7 @@ void SetBgAttribute(u8 bg, u8 attributeId, u8 value) } } -u16 GetBgAttribute(u8 bg, u8 attributeId) +u16 GetBgAttribute(u32 bg, u32 attributeId) { switch (attributeId) { @@ -541,13 +532,13 @@ u16 GetBgAttribute(u8 bg, u8 attributeId) } } -s32 ChangeBgX(u8 bg, s32 value, u8 op) +s32 ChangeBgX(u32 bg, s32 value, u8 op) { - u8 mode; + u32 mode; u16 temp1; u16 temp2; - if (IsInvalidBg32(bg) || !GetBgControlAttribute(bg, BG_CTRL_ATTR_VISIBLE)) + if (IsInvalidBg(bg) || !GetBgControlAttribute(bg, BG_CTRL_ATTR_VISIBLE)) { return -1; } @@ -611,9 +602,9 @@ s32 ChangeBgX(u8 bg, s32 value, u8 op) return sGpuBgConfigs2[bg].bg_x; } -s32 GetBgX(u8 bg) +s32 GetBgX(u32 bg) { - if (IsInvalidBg32(bg)) + if (IsInvalidBg(bg)) return -1; else if (!GetBgControlAttribute(bg, BG_CTRL_ATTR_VISIBLE)) return -1; @@ -621,13 +612,13 @@ s32 GetBgX(u8 bg) return sGpuBgConfigs2[bg].bg_x; } -s32 ChangeBgY(u8 bg, s32 value, u8 op) +s32 ChangeBgY(u32 bg, s32 value, u8 op) { - u8 mode; + u32 mode; u16 temp1; u16 temp2; - if (IsInvalidBg32(bg) || !GetBgControlAttribute(bg, BG_CTRL_ATTR_VISIBLE)) + if (IsInvalidBg(bg) || !GetBgControlAttribute(bg, BG_CTRL_ATTR_VISIBLE)) { return -1; } @@ -691,13 +682,13 @@ s32 ChangeBgY(u8 bg, s32 value, u8 op) return sGpuBgConfigs2[bg].bg_y; } -s32 ChangeBgY_ScreenOff(u8 bg, s32 value, u8 op) +s32 ChangeBgY_ScreenOff(u32 bg, s32 value, u8 op) { - u8 mode; + u32 mode; u16 temp1; u16 temp2; - if (IsInvalidBg32(bg) || !GetBgControlAttribute(bg, BG_CTRL_ATTR_VISIBLE)) + if (IsInvalidBg(bg) || !GetBgControlAttribute(bg, BG_CTRL_ATTR_VISIBLE)) { return -1; } @@ -762,9 +753,9 @@ s32 ChangeBgY_ScreenOff(u8 bg, s32 value, u8 op) return sGpuBgConfigs2[bg].bg_y; } -s32 GetBgY(u8 bg) +s32 GetBgY(u32 bg) { - if (IsInvalidBg32(bg)) + if (IsInvalidBg(bg)) return -1; else if (!GetBgControlAttribute(bg, BG_CTRL_ATTR_VISIBLE)) return -1; @@ -772,12 +763,12 @@ s32 GetBgY(u8 bg) return sGpuBgConfigs2[bg].bg_y; } -void SetBgAffine(u8 bg, s32 srcCenterX, s32 srcCenterY, s16 dispCenterX, s16 dispCenterY, s16 scaleX, s16 scaleY, u16 rotationAngle) +void SetBgAffine(u32 bg, s32 srcCenterX, s32 srcCenterY, s16 dispCenterX, s16 dispCenterY, s16 scaleX, s16 scaleY, u16 rotationAngle) { SetBgAffineInternal(bg, srcCenterX, srcCenterY, dispCenterX, dispCenterY, scaleX, scaleY, rotationAngle); } -u8 Unused_AdjustBgMosaic(u8 val, u8 mode) +u8 Unused_AdjustBgMosaic(u8 val, u32 mode) { u16 mosaic = GetGpuReg(REG_OFFSET_MOSAIC); s16 bgH = mosaic & 0xF; @@ -848,25 +839,25 @@ u8 Unused_AdjustBgMosaic(u8 val, u8 mode) return mosaic; } -void SetBgTilemapBuffer(u8 bg, void *tilemap) +void SetBgTilemapBuffer(u32 bg, void *tilemap) { - if (!IsInvalidBg32(bg) && GetBgControlAttribute(bg, BG_CTRL_ATTR_VISIBLE)) + if (!IsInvalidBg(bg) && GetBgControlAttribute(bg, BG_CTRL_ATTR_VISIBLE)) { sGpuBgConfigs2[bg].tilemap = tilemap; } } -void UnsetBgTilemapBuffer(u8 bg) +void UnsetBgTilemapBuffer(u32 bg) { - if (!IsInvalidBg32(bg) && GetBgControlAttribute(bg, BG_CTRL_ATTR_VISIBLE)) + if (!IsInvalidBg(bg) && GetBgControlAttribute(bg, BG_CTRL_ATTR_VISIBLE)) { sGpuBgConfigs2[bg].tilemap = NULL; } } -void *GetBgTilemapBuffer(u8 bg) +void *GetBgTilemapBuffer(u32 bg) { - if (IsInvalidBg32(bg)) + if (IsInvalidBg(bg)) return NULL; else if (!GetBgControlAttribute(bg, BG_CTRL_ATTR_VISIBLE)) return NULL; @@ -874,9 +865,9 @@ void *GetBgTilemapBuffer(u8 bg) return sGpuBgConfigs2[bg].tilemap; } -void CopyToBgTilemapBuffer(u8 bg, const void *src, u16 mode, u16 destOffset) +void CopyToBgTilemapBuffer(u32 bg, const void *src, u16 mode, u16 destOffset) { - if (!IsInvalidBg32(bg) && !IsTileMapOutsideWram(bg)) + if (!IsInvalidBg(bg) && !IsTileMapOutsideWram(bg)) { if (mode != 0) CpuCopy16(src, (void *)(sGpuBgConfigs2[bg].tilemap + (destOffset * 2)), mode); @@ -885,11 +876,11 @@ void CopyToBgTilemapBuffer(u8 bg, const void *src, u16 mode, u16 destOffset) } } -void CopyBgTilemapBufferToVram(u8 bg) +void CopyBgTilemapBufferToVram(u32 bg) { u16 sizeToLoad; - if (!IsInvalidBg32(bg) && !IsTileMapOutsideWram(bg)) + if (!IsInvalidBg(bg) && !IsTileMapOutsideWram(bg)) { switch (GetBgType(bg)) { @@ -907,13 +898,13 @@ void CopyBgTilemapBufferToVram(u8 bg) } } -void CopyToBgTilemapBufferRect(u8 bg, const void *src, u8 destX, u8 destY, u8 width, u8 height) +void CopyToBgTilemapBufferRect(u32 bg, const void *src, u8 destX, u8 destY, u8 width, u8 height) { u16 destX16; u16 destY16; u16 mode; - if (!IsInvalidBg32(bg) && !IsTileMapOutsideWram(bg)) + if (!IsInvalidBg(bg) && !IsTileMapOutsideWram(bg)) { switch (GetBgType(bg)) { @@ -946,19 +937,19 @@ void CopyToBgTilemapBufferRect(u8 bg, const void *src, u8 destX, u8 destY, u8 wi } } -void CopyToBgTilemapBufferRect_ChangePalette(u8 bg, const void *src, u8 destX, u8 destY, u8 rectWidth, u8 rectHeight, u8 palette) +void CopyToBgTilemapBufferRect_ChangePalette(u32 bg, const void *src, u8 destX, u8 destY, u8 rectWidth, u8 rectHeight, u8 palette) { CopyRectToBgTilemapBufferRect(bg, src, 0, 0, rectWidth, rectHeight, destX, destY, rectWidth, rectHeight, palette, 0, 0); } -void CopyRectToBgTilemapBufferRect(u8 bg, const void *src, u8 srcX, u8 srcY, u8 srcWidth, u8 srcHeight, u8 destX, u8 destY, u8 rectWidth, u8 rectHeight, u8 palette1, s16 tileOffset, s16 palette2) +void CopyRectToBgTilemapBufferRect(u32 bg, const void *src, u8 srcX, u8 srcY, u8 srcWidth, u8 srcHeight, u8 destX, u8 destY, u8 rectWidth, u8 rectHeight, u8 palette1, s16 tileOffset, s16 palette2) { u16 screenWidth, screenHeight, screenSize; u16 var; const void *srcPtr; u16 i, j; - if (!IsInvalidBg32(bg) && !IsTileMapOutsideWram(bg)) + if (!IsInvalidBg(bg) && !IsTileMapOutsideWram(bg)) { screenSize = GetBgControlAttribute(bg, BG_CTRL_ATTR_SCREENSIZE); screenWidth = GetBgMetricTextMode(bg, 0x1) * 0x20; @@ -995,13 +986,13 @@ void CopyRectToBgTilemapBufferRect(u8 bg, const void *src, u8 srcX, u8 srcY, u8 } } -void FillBgTilemapBufferRect_Palette0(u8 bg, u16 tileNum, u8 x, u8 y, u8 width, u8 height) +void FillBgTilemapBufferRect_Palette0(u32 bg, u16 tileNum, u8 x, u8 y, u8 width, u8 height) { u16 x16; u16 y16; u16 mode; - if (!IsInvalidBg32(bg) && !IsTileMapOutsideWram(bg)) + if (!IsInvalidBg(bg) && !IsTileMapOutsideWram(bg)) { switch (GetBgType(bg)) { @@ -1028,12 +1019,12 @@ void FillBgTilemapBufferRect_Palette0(u8 bg, u16 tileNum, u8 x, u8 y, u8 width, } } -void FillBgTilemapBufferRect(u8 bg, u16 tileNum, u8 x, u8 y, u8 width, u8 height, u8 palette) +void FillBgTilemapBufferRect(u32 bg, u16 tileNum, u8 x, u8 y, u8 width, u8 height, u8 palette) { WriteSequenceToBgTilemapBuffer(bg, tileNum, x, y, width, height, palette, 0); } -void WriteSequenceToBgTilemapBuffer(u8 bg, u16 firstTileNum, u8 x, u8 y, u8 width, u8 height, u8 paletteSlot, s16 tileNumDelta) +void WriteSequenceToBgTilemapBuffer(u32 bg, u16 firstTileNum, u8 x, u8 y, u8 width, u8 height, u8 paletteSlot, s16 tileNumDelta) { u16 mode; u16 mode2; @@ -1041,7 +1032,7 @@ void WriteSequenceToBgTilemapBuffer(u8 bg, u16 firstTileNum, u8 x, u8 y, u8 widt u16 mode3; u16 x16, y16; - if (!IsInvalidBg32(bg) && !IsTileMapOutsideWram(bg)) + if (!IsInvalidBg(bg) && !IsTileMapOutsideWram(bg)) { attribute = GetBgControlAttribute(bg, BG_CTRL_ATTR_SCREENSIZE); mode = GetBgMetricTextMode(bg, 0x1) * 0x20; @@ -1073,7 +1064,7 @@ void WriteSequenceToBgTilemapBuffer(u8 bg, u16 firstTileNum, u8 x, u8 y, u8 widt } } -u16 GetBgMetricTextMode(u8 bg, u8 whichMetric) +u16 GetBgMetricTextMode(u32 bg, u32 whichMetric) { u8 screenSize = GetBgControlAttribute(bg, BG_CTRL_ATTR_SCREENSIZE); @@ -1119,7 +1110,7 @@ u16 GetBgMetricTextMode(u8 bg, u8 whichMetric) return 0; } -u32 GetBgMetricAffineMode(u8 bg, u8 whichMetric) +u32 GetBgMetricAffineMode(u32 bg, u32 whichMetric) { u8 screenSize = GetBgControlAttribute(bg, BG_CTRL_ATTR_SCREENSIZE); @@ -1192,9 +1183,9 @@ void CopyTileMapEntry(const u16 *src, u16 *dest, s32 palette1, s32 tileOffset, s *dest = var; } -static u32 GetBgType(u8 bg) +static u32 GetBgType(u32 bg) { - u8 mode = GetBgMode(); + u32 mode = GetBgMode(); switch (bg) { @@ -1231,15 +1222,7 @@ static u32 GetBgType(u8 bg) return BG_TYPE_NONE; } -bool32 IsInvalidBg32(u8 bg) -{ - if (bg >= NUM_BACKGROUNDS) - return TRUE; - else - return FALSE; -} - -bool32 IsTileMapOutsideWram(u8 bg) +bool32 IsTileMapOutsideWram(u32 bg) { if (sGpuBgConfigs2[bg].tilemap > (void *)IWRAM_END) return TRUE; diff --git a/gflib/bg.h b/gflib/bg.h index 98183399100e..f981ed4b8c13 100644 --- a/gflib/bg.h +++ b/gflib/bg.h @@ -51,48 +51,47 @@ struct BgTemplate }; void ResetBgs(void); -u8 GetBgMode(void); +u32 GetBgMode(void); void ResetBgControlStructs(void); -void Unused_ResetBgControlStruct(u8 bg); -u8 LoadBgVram(u8 bg, const void *src, u16 size, u16 destOffset, u8 mode); +void Unused_ResetBgControlStruct(u32 bg); +u8 LoadBgVram(u32 bg, const void *src, u16 size, u16 destOffset, u32 mode); void SetTextModeAndHideBgs(void); -bool8 IsInvalidBg(u8 bg); +bool32 IsInvalidBg(u32 bg); int BgTileAllocOp(int bg, int offset, int count, int mode); void ResetBgsAndClearDma3BusyFlags(u32 leftoverFireRedLeafGreenVariable); -void InitBgsFromTemplates(u8 bgMode, const struct BgTemplate *templates, u8 numTemplates); +void InitBgsFromTemplates(u32 bgMode, const struct BgTemplate *templates, u8 numTemplates); void InitBgFromTemplate(const struct BgTemplate *template); -void SetBgMode(u8 bgMode); -u16 LoadBgTiles(u8 bg, const void *src, u16 size, u16 destOffset); -u16 LoadBgTilemap(u8 bg, const void *src, u16 size, u16 destOffset); -u16 Unused_LoadBgPalette(u8 bg, const void *src, u16 size, u16 destOffset); -bool8 IsDma3ManagerBusyWithBgCopy(void); -void ShowBg(u8 bg); -void HideBg(u8 bg); -void SetBgAttribute(u8 bg, u8 attributeId, u8 value); -u16 GetBgAttribute(u8 bg, u8 attributeId); -s32 ChangeBgX(u8 bg, s32 value, u8 op); -s32 GetBgX(u8 bg); -s32 ChangeBgY(u8 bg, s32 value, u8 op); -s32 ChangeBgY_ScreenOff(u8 bg, s32 value, u8 op); -s32 GetBgY(u8 bg); -void SetBgAffine(u8 bg, s32 srcCenterX, s32 srcCenterY, s16 dispCenterX, s16 dispCenterY, s16 scaleX, s16 scaleY, u16 rotationAngle); -u8 Unused_AdjustBgMosaic(u8 val, u8 mode); -void SetBgTilemapBuffer(u8 bg, void *tilemap); -void UnsetBgTilemapBuffer(u8 bg); -void *GetBgTilemapBuffer(u8 bg); -void CopyToBgTilemapBuffer(u8 bg, const void *src, u16 mode, u16 destOffset); -void CopyBgTilemapBufferToVram(u8 bg); -void CopyToBgTilemapBufferRect(u8 bg, const void *src, u8 destX, u8 destY, u8 width, u8 height); -void CopyToBgTilemapBufferRect_ChangePalette(u8 bg, const void *src, u8 destX, u8 destY, u8 rectWidth, u8 rectHeight, u8 palette); -void CopyRectToBgTilemapBufferRect(u8 bg, const void *src, u8 srcX, u8 srcY, u8 srcWidth, u8 srcHeight, u8 destX, u8 destY, u8 rectWidth, u8 rectHeight, u8 palette1, s16 tileOffset, s16 palette2); -void FillBgTilemapBufferRect_Palette0(u8 bg, u16 tileNum, u8 x, u8 y, u8 width, u8 height); -void FillBgTilemapBufferRect(u8 bg, u16 tileNum, u8 x, u8 y, u8 width, u8 height, u8 palette); -void WriteSequenceToBgTilemapBuffer(u8 bg, u16 firstTileNum, u8 x, u8 y, u8 width, u8 height, u8 paletteSlot, s16 tileNumDelta); -u16 GetBgMetricTextMode(u8 bg, u8 whichMetric); -u32 GetBgMetricAffineMode(u8 bg, u8 whichMetric); +void SetBgMode(u32 bgMode); +u16 LoadBgTiles(u32 bg, const void *src, u16 size, u16 destOffset); +u16 LoadBgTilemap(u32 bg, const void *src, u16 size, u16 destOffset); +u16 Unused_LoadBgPalette(u32 bg, const void *src, u16 size, u16 destOffset); +bool32 IsDma3ManagerBusyWithBgCopy(void); +void ShowBg(u32 bg); +void HideBg(u32 bg); +void SetBgAttribute(u32 bg, u32 attributeId, u8 value); +u16 GetBgAttribute(u32 bg, u32 attributeId); +s32 ChangeBgX(u32 bg, s32 value, u8 op); +s32 GetBgX(u32 bg); +s32 ChangeBgY(u32 bg, s32 value, u8 op); +s32 ChangeBgY_ScreenOff(u32 bg, s32 value, u8 op); +s32 GetBgY(u32 bg); +void SetBgAffine(u32 bg, s32 srcCenterX, s32 srcCenterY, s16 dispCenterX, s16 dispCenterY, s16 scaleX, s16 scaleY, u16 rotationAngle); +u8 Unused_AdjustBgMosaic(u8 val, u32 mode); +void SetBgTilemapBuffer(u32 bg, void *tilemap); +void UnsetBgTilemapBuffer(u32 bg); +void *GetBgTilemapBuffer(u32 bg); +void CopyToBgTilemapBuffer(u32 bg, const void *src, u16 mode, u16 destOffset); +void CopyBgTilemapBufferToVram(u32 bg); +void CopyToBgTilemapBufferRect(u32 bg, const void *src, u8 destX, u8 destY, u8 width, u8 height); +void CopyToBgTilemapBufferRect_ChangePalette(u32 bg, const void *src, u8 destX, u8 destY, u8 rectWidth, u8 rectHeight, u8 palette); +void CopyRectToBgTilemapBufferRect(u32 bg, const void *src, u8 srcX, u8 srcY, u8 srcWidth, u8 srcHeight, u8 destX, u8 destY, u8 rectWidth, u8 rectHeight, u8 palette1, s16 tileOffset, s16 palette2); +void FillBgTilemapBufferRect_Palette0(u32 bg, u16 tileNum, u8 x, u8 y, u8 width, u8 height); +void FillBgTilemapBufferRect(u32 bg, u16 tileNum, u8 x, u8 y, u8 width, u8 height, u8 palette); +void WriteSequenceToBgTilemapBuffer(u32 bg, u16 firstTileNum, u8 x, u8 y, u8 width, u8 height, u8 paletteSlot, s16 tileNumDelta); +u16 GetBgMetricTextMode(u32 bg, u32 whichMetric); +u32 GetBgMetricAffineMode(u32 bg, u32 whichMetric); u32 GetTileMapIndexFromCoords(s32 x, s32 y, s32 screenSize, u32 screenWidth, u32 screenHeight); void CopyTileMapEntry(const u16 *src, u16 *dest, s32 palette1, s32 tileOffset, s32 palette2); -bool32 IsInvalidBg32(u8 bg); -bool32 IsTileMapOutsideWram(u8 bg); +bool32 IsTileMapOutsideWram(u32 bg); #endif // GUARD_BG_H diff --git a/gflib/dma3.h b/gflib/dma3.h index 8eff34f557b2..9c4d8bce0580 100644 --- a/gflib/dma3.h +++ b/gflib/dma3.h @@ -48,8 +48,8 @@ void ClearDma3Requests(void); void ProcessDma3Requests(void); -s16 RequestDma3Copy(const void *src, void *dest, u16 size, u8 mode); -s16 RequestDma3Fill(s32 value, void *dest, u16 size, u8 mode); +s16 RequestDma3Copy(const void *src, void *dest, u16 size, u32 mode); +s16 RequestDma3Fill(s32 value, void *dest, u16 size, u32 mode); s16 CheckForSpaceForDma3Request(s16 index); #endif // GUARD_DMA3_H diff --git a/gflib/dma3_manager.c b/gflib/dma3_manager.c index d774efe8cef2..71e69322ab4e 100644 --- a/gflib/dma3_manager.c +++ b/gflib/dma3_manager.c @@ -95,7 +95,7 @@ void ProcessDma3Requests(void) } } -s16 RequestDma3Copy(const void *src, void *dest, u16 size, u8 mode) +s16 RequestDma3Copy(const void *src, void *dest, u16 size, u32 mode) { int cursor; int i = 0; @@ -127,7 +127,7 @@ s16 RequestDma3Copy(const void *src, void *dest, u16 size, u8 mode) return -1; // no free DMA request was found } -s16 RequestDma3Fill(s32 value, void *dest, u16 size, u8 mode) +s16 RequestDma3Fill(s32 value, void *dest, u16 size, u32 mode) { int cursor; int i = 0; diff --git a/gflib/io_reg.c b/gflib/io_reg.c index 66b8dbe64c5f..6c4671718a99 100644 --- a/gflib/io_reg.c +++ b/gflib/io_reg.c @@ -2,25 +2,6 @@ #include "io_reg.h" #include "gba/io_reg.h" -static const u32 sUnused[] = { - 0, - 0, - (1 << 26) | (1 << 3), - (1 << 26) | (1 << 3) | (1 << 1), - (1 << 26) | (1 << 3) | (1 << 2), - (1 << 26) | (1 << 3) | (1 << 2) | (1 << 1), - (1 << 26) | (1 << 4), - (1 << 26) | (1 << 4) | (1 << 2), - (1 << 26) | (1 << 4) | (1 << 3), - (1 << 26) | (1 << 4) | (1 << 3) | (1 << 2), - (1 << 26) | (1 << 4) | (1 << 1), - (1 << 26) | (1 << 4) | (1 << 2) | (1 << 1), - (1 << 26) | (1 << 4) | (1 << 3) | (1 << 1), - (1 << 26) | (1 << 4) | (1 << 3) | (1 << 2) | (1 << 1), - (1 << 25) | (1 << 8), - (1 << 27) | (1 << 10), -}; - const u16 gOverworldBackgroundLayerFlags[] = { BLDCNT_TGT2_BG0, BLDCNT_TGT2_BG1, diff --git a/gflib/sprite.c b/gflib/sprite.c index 58ca5e2b5d3f..7ae70670223c 100644 --- a/gflib/sprite.c +++ b/gflib/sprite.c @@ -49,7 +49,7 @@ struct OamDimensions }; static void SortSprites(u32 *spritePriorities, s32 n); -static u8 CreateSpriteAt(u8 index, const struct SpriteTemplate *template, s16 x, s16 y, u8 subpriority); +static u32 CreateSpriteAt(u32 index, const struct SpriteTemplate *template, s16 x, s16 y, u32 subpriority); static void ResetOamMatrices(void); static void ResetSprite(struct Sprite *sprite); static s16 AllocSpriteTiles(u16 tileCount); @@ -121,17 +121,6 @@ const union AnimCmd * const gDummySpriteAnimTable[]; const union AffineAnimCmd * const gDummySpriteAffineAnimTable[]; const struct SpriteTemplate gDummySpriteTemplate; -// Unreferenced data. Also unreferenced in R/S. -static const u8 sUnknownData[24] = -{ - 0x01, 0x04, 0x10, 0x40, - 0x02, 0x04, 0x08, 0x20, - 0x02, 0x04, 0x08, 0x20, - 0x01, 0x04, 0x10, 0x40, - 0x02, 0x04, 0x08, 0x20, - 0x02, 0x04, 0x08, 0x20, -}; - static const u8 sCenterToCornerVecTable[3][4][2] = { { // square @@ -306,7 +295,7 @@ void ResetSpriteData(void) void AnimateSprites(void) { - u8 i; + u32 i; for (i = 0; i < MAX_SPRITES; i++) { struct Sprite *sprite = &gSprites[i]; @@ -447,9 +436,9 @@ static void SortSprites(u32 *spritePriorities, s32 n) InsertionSort(spritePriorities, n); } -u8 CreateSprite(const struct SpriteTemplate *template, s16 x, s16 y, u8 subpriority) +u32 CreateSprite(const struct SpriteTemplate *template, s16 x, s16 y, u32 subpriority) { - u8 i; + u32 i; for (i = 0; i < MAX_SPRITES; i++) if (!gSprites[i].inUse) @@ -458,9 +447,9 @@ u8 CreateSprite(const struct SpriteTemplate *template, s16 x, s16 y, u8 subprior return MAX_SPRITES; } -u8 CreateSpriteAtEnd(const struct SpriteTemplate *template, s16 x, s16 y, u8 subpriority) +u32 CreateSpriteAtEnd(const struct SpriteTemplate *template, s16 x, s16 y, u32 subpriority) { - s16 i; + s32 i; for (i = MAX_SPRITES - 1; i > -1; i--) if (!gSprites[i].inUse) @@ -469,9 +458,9 @@ u8 CreateSpriteAtEnd(const struct SpriteTemplate *template, s16 x, s16 y, u8 sub return MAX_SPRITES; } -u8 CreateInvisibleSprite(void (*callback)(struct Sprite *)) +u32 CreateInvisibleSprite(void (*callback)(struct Sprite *)) { - u8 index = CreateSprite(&gDummySpriteTemplate, 0, 0, 31); + u32 index = CreateSprite(&gDummySpriteTemplate, 0, 0, 31); if (index == MAX_SPRITES) { @@ -485,7 +474,7 @@ u8 CreateInvisibleSprite(void (*callback)(struct Sprite *)) } } -u8 CreateSpriteAt(u8 index, const struct SpriteTemplate *template, s16 x, s16 y, u8 subpriority) +u32 CreateSpriteAt(u32 index, const struct SpriteTemplate *template, s16 x, s16 y, u32 subpriority) { struct Sprite *sprite = &gSprites[index]; @@ -536,9 +525,9 @@ u8 CreateSpriteAt(u8 index, const struct SpriteTemplate *template, s16 x, s16 y, return index; } -u8 CreateSpriteAndAnimate(const struct SpriteTemplate *template, s16 x, s16 y, u8 subpriority) +u32 CreateSpriteAndAnimate(const struct SpriteTemplate *template, s16 x, s16 y, u32 subpriority) { - u8 i; + u32 i; for (i = 0; i < MAX_SPRITES; i++) { @@ -546,7 +535,7 @@ u8 CreateSpriteAndAnimate(const struct SpriteTemplate *template, s16 x, s16 y, u if (!gSprites[i].inUse) { - u8 index = CreateSpriteAt(i, template, x, y, subpriority); + u32 index = CreateSpriteAt(i, template, x, y, subpriority); if (index == MAX_SPRITES) return MAX_SPRITES; @@ -578,11 +567,11 @@ void DestroySprite(struct Sprite *sprite) } } -void ResetOamRange(u8 start, u8 end) +void ResetOamRange(u32 start, u32 end) { - u8 i; + u32 i; for (i = start; i < end; i++) - gMain.oamBuffer[i] = *(struct OamData *)&gDummyOamData; + gMain.oamBuffer[i] = gDummyOamData; } void LoadOam(void) @@ -593,7 +582,7 @@ void LoadOam(void) void ClearSpriteCopyRequests(void) { - u8 i; + u32 i; sShouldProcessSpriteCopyRequests = FALSE; sSpriteCopyRequestCount = 0; @@ -608,7 +597,7 @@ void ClearSpriteCopyRequests(void) void ResetOamMatrices(void) { - u8 i; + u32 i; for (i = 0; i < OAM_MATRIX_COUNT; i++) { // set to identity matrix @@ -1365,7 +1354,7 @@ void SetSpriteSheetFrameTileNum(struct Sprite *sprite) void ResetAffineAnimData(void) { - u8 i; + u32 i; gAffineAnimsDisabled = FALSE; gOamMatrixAllocBitmap = 0; @@ -1453,7 +1442,7 @@ u16 LoadSpriteSheet(const struct SpriteSheet *sheet) void LoadSpriteSheets(const struct SpriteSheet *sheets) { - u8 i; + u32 i; for (i = 0; sheets[i].data != NULL; i++) LoadSpriteSheet(&sheets[i]); } @@ -1482,7 +1471,7 @@ void FreeSpriteTilesByTag(u16 tag) void FreeSpriteTileRanges(void) { - u8 i; + u32 i; for (i = 0; i < MAX_SPRITES; i++) { @@ -1501,7 +1490,7 @@ u16 GetSpriteTileStartByTag(u16 tag) u8 IndexOfSpriteTileTag(u16 tag) { - u8 i; + u32 i; for (i = 0; i < MAX_SPRITES; i++) if (sSpriteTileRangeTags[i] == tag) @@ -1512,7 +1501,7 @@ u8 IndexOfSpriteTileTag(u16 tag) u16 GetSpriteTileTagByTileStart(u16 start) { - u8 i; + u32 i; for (i = 0; i < MAX_SPRITES; i++) { @@ -1532,7 +1521,7 @@ void AllocSpriteTileRange(u16 tag, u16 start, u16 count) void FreeAllSpritePalettes(void) { - u8 i; + u32 i; gReservedSpritePaletteCount = 0; for (i = 0; i < 16; i++) sSpritePaletteTags[i] = TAG_NONE; @@ -1561,7 +1550,7 @@ u8 LoadSpritePalette(const struct SpritePalette *palette) void LoadSpritePalettes(const struct SpritePalette *palettes) { - u8 i; + u32 i; for (i = 0; palettes[i].data != NULL; i++) if (LoadSpritePalette(&palettes[i]) == 0xFF) break; @@ -1588,7 +1577,7 @@ u8 AllocSpritePalette(u16 tag) u8 IndexOfSpritePaletteTag(u16 tag) { - u8 i; + u32 i; for (i = gReservedSpritePaletteCount; i < 16; i++) if (sSpritePaletteTags[i] == tag) return i; @@ -1657,7 +1646,7 @@ bool8 AddSubspritesToOamBuffer(struct Sprite *sprite, struct OamData *destOam, u u8 subspriteCount; u8 hFlip; u8 vFlip; - u8 i; + u32 i; tileNum = oam->tileNum; subspriteCount = subspriteTable->subspriteCount; diff --git a/gflib/sprite.h b/gflib/sprite.h index 270a755b4410..9772434a3b4e 100644 --- a/gflib/sprite.h +++ b/gflib/sprite.h @@ -267,12 +267,12 @@ extern bool8 gAffineAnimsDisabled; void ResetSpriteData(void); void AnimateSprites(void); void BuildOamBuffer(void); -u8 CreateSprite(const struct SpriteTemplate *template, s16 x, s16 y, u8 subpriority); -u8 CreateSpriteAtEnd(const struct SpriteTemplate *template, s16 x, s16 y, u8 subpriority); -u8 CreateInvisibleSprite(void (*callback)(struct Sprite *)); -u8 CreateSpriteAndAnimate(const struct SpriteTemplate *template, s16 x, s16 y, u8 subpriority); +u32 CreateSprite(const struct SpriteTemplate *template, s16 x, s16 y, u32 subpriority); +u32 CreateSpriteAtEnd(const struct SpriteTemplate *template, s16 x, s16 y, u32 subpriority); +u32 CreateInvisibleSprite(void (*callback)(struct Sprite *)); +u32 CreateSpriteAndAnimate(const struct SpriteTemplate *template, s16 x, s16 y, u32 subpriority); void DestroySprite(struct Sprite *sprite); -void ResetOamRange(u8 start, u8 end); +void ResetOamRange(u32 start, u32 end); void LoadOam(void); void SetOamMatrix(u8 matrixNum, u16 a, u16 b, u16 c, u16 d); void CalcCenterToCornerVec(struct Sprite *sprite, u8 shape, u8 size, u8 affineMode); diff --git a/gflib/string_util.c b/gflib/string_util.c index 9aef8d543ac6..17b055ad0a52 100644 --- a/gflib/string_util.c +++ b/gflib/string_util.c @@ -63,7 +63,7 @@ u8 *StringCopy_Nickname(u8 *dest, const u8 *src) u8 *StringGet_Nickname(u8 *str) { - u8 i; + u32 i; u32 limit = POKEMON_NAME_LENGTH; if (DECAP_ENABLED && !DECAP_NICKNAMES && *str == CHAR_FIXED_CASE) @@ -124,7 +124,7 @@ u8 *StringAppend(u8 *dest, const u8 *src) u8 *StringCopyN(u8 *dest, const u8 *src, u8 n) { - u16 i; + u32 i; for (i = 0; i < n; i++) dest[i] = src[i]; @@ -196,7 +196,7 @@ s32 StringCompareN(const u8 *str1, const u8 *str2, u32 n) bool8 IsStringLengthAtLeast(const u8 *str, s32 n) { - u8 i; + u32 i; for (i = 0; i < n; i++) if (str[i] && str[i] != EOS) @@ -320,7 +320,7 @@ u8 *ConvertUIntToDecimalStringN(u8 *dest, u32 value, enum StringConvertMode mode u8 *ConvertIntToHexStringN(u8 *dest, s32 value, enum StringConvertMode mode, u8 n) { enum { WAITING_FOR_NONZERO_DIGIT, WRITING_DIGITS, WRITING_SPACES } state; - u8 i; + u32 i; s32 powerOfSixteen; s32 largestPowerOfSixteen = 1; @@ -596,7 +596,7 @@ const u8 *GetExpandedPlaceholder(u32 id) u8 *StringFill(u8 *dest, u8 c, u16 n) { - u16 i; + u32 i; for (i = 0; i < n; i++) *dest++ = c; @@ -813,7 +813,7 @@ void ConvertInternationalString(u8 *s, u8 language) { if (language == LANGUAGE_JAPANESE) { - u8 i; + u32 i; StripExtCtrlCodes(s); i = StringLength(s); diff --git a/gflib/text.c b/gflib/text.c index 139fd5ee1a78..cc6a6e90f202 100644 --- a/gflib/text.c +++ b/gflib/text.c @@ -302,7 +302,7 @@ u16 AddTextPrinterFixedCaseParameterized(u8 windowId, u8 fontId, const u8 *str, return AddTextPrinterParameterized(windowId, fontId, MirrorPtr(str), x, y, speed, callback); } -bool16 AddTextPrinter(struct TextPrinterTemplate *printerTemplate, u8 speed, void (*callback)(struct TextPrinterTemplate *, u16)) +bool32 AddTextPrinter(struct TextPrinterTemplate *printerTemplate, u8 speed, void (*callback)(struct TextPrinterTemplate *, u16)) { int i; u16 j; @@ -388,7 +388,7 @@ void RunTextPrinters(void) } } -bool16 IsTextPrinterActive(u8 id) +bool32 IsTextPrinterActive(u8 id) { return sTextPrinters[id].active; } @@ -891,7 +891,7 @@ void TextPrinterClearDownArrow(struct TextPrinter *textPrinter) CopyWindowToVram(textPrinter->printerTemplate.windowId, COPYWIN_GFX); } -bool8 TextPrinterWaitAutoMode(struct TextPrinter *textPrinter) +bool32 TextPrinterWaitAutoMode(struct TextPrinter *textPrinter) { struct TextPrinterSubStruct *subStruct = (struct TextPrinterSubStruct *)(&textPrinter->subStructFields); @@ -906,9 +906,9 @@ bool8 TextPrinterWaitAutoMode(struct TextPrinter *textPrinter) } } -bool16 TextPrinterWaitWithDownArrow(struct TextPrinter *textPrinter) +bool32 TextPrinterWaitWithDownArrow(struct TextPrinter *textPrinter) { - bool8 result = FALSE; + bool32 result = FALSE; if (gTextFlags.autoScroll != 0) { result = TextPrinterWaitAutoMode(textPrinter); @@ -925,9 +925,9 @@ bool16 TextPrinterWaitWithDownArrow(struct TextPrinter *textPrinter) return result; } -bool16 TextPrinterWait(struct TextPrinter *textPrinter) +bool32 TextPrinterWait(struct TextPrinter *textPrinter) { - bool16 result = FALSE; + bool32 result = FALSE; if (gTextFlags.autoScroll != 0) { result = TextPrinterWaitAutoMode(textPrinter); @@ -943,7 +943,7 @@ bool16 TextPrinterWait(struct TextPrinter *textPrinter) return result; } -void DrawDownArrow(u8 windowId, u16 x, u16 y, u8 bgColor, bool8 drawArrow, u8 *counter, u8 *yCoordIndex) +void DrawDownArrow(u8 windowId, u16 x, u16 y, u8 bgColor, bool32 drawArrow, u8 *counter, u8 *yCoordIndex) { const u8 *arrowTiles; @@ -1437,7 +1437,7 @@ static u32 (*GetFontWidthFunc(u8 fontId))(u16, bool32) s32 GetStringWidth(u8 fontId, const u8 *str, s16 letterSpacing) { - bool8 isJapanese; + bool32 isJapanese; int minGlyphWidth; u32 (*func)(u16 fontId, bool32 isJapanese); int localLetterSpacing; diff --git a/gflib/text.h b/gflib/text.h index 18af356f3df5..7e1d7bfb111f 100644 --- a/gflib/text.h +++ b/gflib/text.h @@ -159,9 +159,9 @@ u16 AddTextPrinterFixedCaseParameterized(u8 windowId, u8 fontId, const u8 *str, void DeactivateAllTextPrinters(void); u16 AddTextPrinterParameterized(u8 windowId, u8 fontId, const u8 *str, u8 x, u8 y, u8 speed, void (*callback)(struct TextPrinterTemplate *, u16)); -bool16 AddTextPrinter(struct TextPrinterTemplate *template, u8 speed, void (*callback)(struct TextPrinterTemplate *, u16)); +bool32 AddTextPrinter(struct TextPrinterTemplate *template, u8 speed, void (*callback)(struct TextPrinterTemplate *, u16)); void RunTextPrinters(void); -bool16 IsTextPrinterActive(u8 id); +bool32 IsTextPrinterActive(u8 id); void GenerateFontHalfRowLookupTable(u8 fgColor, u8 bgColor, u8 shadowColor); void SaveTextColors(u8 *fgColor, u8 *bgColor, u8 *shadowColor); void RestoreTextColors(u8 *fgColor, u8 *bgColor, u8 *shadowColor); @@ -172,10 +172,10 @@ void ClearTextSpan(struct TextPrinter *textPrinter, u32 width); void TextPrinterInitDownArrowCounters(struct TextPrinter *textPrinter); void TextPrinterDrawDownArrow(struct TextPrinter *textPrinter); void TextPrinterClearDownArrow(struct TextPrinter *textPrinter); -bool8 TextPrinterWaitAutoMode(struct TextPrinter *textPrinter); -bool16 TextPrinterWaitWithDownArrow(struct TextPrinter *textPrinter); -bool16 TextPrinterWait(struct TextPrinter *textPrinter); -void DrawDownArrow(u8 windowId, u16 x, u16 y, u8 bgColor, bool8 drawArrow, u8 *counter, u8 *yCoordIndex); +bool32 TextPrinterWaitAutoMode(struct TextPrinter *textPrinter); +bool32 TextPrinterWaitWithDownArrow(struct TextPrinter *textPrinter); +bool32 TextPrinterWait(struct TextPrinter *textPrinter); +void DrawDownArrow(u8 windowId, u16 x, u16 y, u8 bgColor, bool32 drawArrow, u8 *counter, u8 *yCoordIndex); s32 GetStringWidth(u8 fontId, const u8 *str, s16 letterSpacing); u8 RenderTextHandleBold(u8 *pixels, u8 fontId, u8 *str); u8 DrawKeypadIcon(u8 windowId, u8 keypadIconId, u16 x, u16 y); diff --git a/gflib/window.c b/gflib/window.c index 6f7af457d3ed..61264000ea35 100644 --- a/gflib/window.c +++ b/gflib/window.c @@ -13,8 +13,8 @@ EWRAM_DATA struct Window gWindows[WINDOWS_MAX] = {0}; EWRAM_DATA static struct Window* sWindowPtr = NULL; EWRAM_DATA static u16 sWindowSize = 0; -static u8 GetNumActiveWindowsOnBg(u8 bgId); -static u8 GetNumActiveWindowsOnBg8Bit(u8 bgId); +static u32 GetNumActiveWindowsOnBg(u32 bgId); +static u32 GetNumActiveWindowsOnBg8Bit(u32 bgId); static const struct WindowTemplate sDummyWindowTemplate = DUMMY_WIN_TEMPLATE; @@ -23,12 +23,12 @@ static void DummyWindowBgTilemap(void) } -bool16 InitWindows(const struct WindowTemplate *templates) +bool32 InitWindows(const struct WindowTemplate *templates) { int i; void *bgTilemapBuffer; int j; - u8 bgLayer; + u32 bgLayer; u16 attrib; u8 *allocatedTilemapBuffer; int allocatedBaseBlock; @@ -106,10 +106,10 @@ bool16 InitWindows(const struct WindowTemplate *templates) return TRUE; } -u16 AddWindow(const struct WindowTemplate *template) +u32 AddWindow(const struct WindowTemplate *template) { - u16 win; - u8 bgLayer; + u32 win; + u32 bgLayer; int allocatedBaseBlock; u16 attrib; u8 *allocatedTilemapBuffer; @@ -180,8 +180,8 @@ u16 AddWindow(const struct WindowTemplate *template) int AddWindowWithoutTileMap(const struct WindowTemplate *template) { - u16 win; - u8 bgLayer; + int win; + u32 bgLayer; int allocatedBaseBlock; for (win = 0; win < WINDOWS_MAX; ++win) @@ -215,9 +215,9 @@ int AddWindowWithoutTileMap(const struct WindowTemplate *template) return win; } -void RemoveWindow(u8 windowId) +void RemoveWindow(u32 windowId) { - u8 bgLayer = gWindows[windowId].window.bg; + u32 bgLayer = gWindows[windowId].window.bg; if (gWindowTileAutoAllocEnabled == TRUE) BgTileAllocOp(bgLayer, gWindows[windowId].window.baseBlock, gWindows[windowId].window.width * gWindows[windowId].window.height, 2); @@ -263,7 +263,7 @@ void FreeAllWindowBuffers(void) } } -void CopyWindowToVram(u8 windowId, u8 mode) +void CopyWindowToVram(u32 windowId, u32 mode) { struct Window windowLocal = gWindows[windowId]; u16 windowSize = 32 * (windowLocal.window.width * windowLocal.window.height); @@ -316,7 +316,7 @@ void CopyWindowRectToVram(u32 windowId, u32 mode, u32 x, u32 y, u32 w, u32 h) } } -void PutWindowTilemap(u8 windowId) +void PutWindowTilemap(u32 windowId) { struct Window windowLocal = gWindows[windowId]; @@ -331,7 +331,7 @@ void PutWindowTilemap(u8 windowId) 1); } -void PutWindowRectTilemapOverridePalette(u8 windowId, u8 x, u8 y, u8 width, u8 height, u8 palette) +void PutWindowRectTilemapOverridePalette(u32 windowId, u8 x, u8 y, u8 width, u8 height, u8 palette) { struct Window windowLocal = gWindows[windowId]; u16 currentRow = windowLocal.window.baseBlock + (y * windowLocal.window.width) + x + GetBgAttribute(windowLocal.window.bg, BG_ATTR_BASETILE); @@ -354,7 +354,7 @@ void PutWindowRectTilemapOverridePalette(u8 windowId, u8 x, u8 y, u8 width, u8 h } // Fills a window with transparent tiles. -void ClearWindowTilemap(u8 windowId) +void ClearWindowTilemap(u32 windowId) { struct Window windowLocal = gWindows[windowId]; @@ -368,7 +368,7 @@ void ClearWindowTilemap(u8 windowId) windowLocal.window.paletteNum); } -void PutWindowRectTilemap(u8 windowId, u8 x, u8 y, u8 width, u8 height) +void PutWindowRectTilemap(u32 windowId, u8 x, u8 y, u8 width, u8 height) { struct Window windowLocal = gWindows[windowId]; u16 currentRow = windowLocal.window.baseBlock + (y * windowLocal.window.width) + x + GetBgAttribute(windowLocal.window.bg, BG_ATTR_BASETILE); @@ -390,12 +390,12 @@ void PutWindowRectTilemap(u8 windowId, u8 x, u8 y, u8 width, u8 height) } } -void BlitBitmapToWindow(u8 windowId, const u8 *pixels, u16 x, u16 y, u16 width, u16 height) +void BlitBitmapToWindow(u32 windowId, const u8 *pixels, u16 x, u16 y, u16 width, u16 height) { BlitBitmapRectToWindow(windowId, pixels, 0, 0, width, height, x, y, width, height); } -void BlitBitmapRectToWindow(u8 windowId, const u8 *pixels, u16 srcX, u16 srcY, u16 srcWidth, int srcHeight, u16 destX, u16 destY, u16 rectWidth, u16 rectHeight) +void BlitBitmapRectToWindow(u32 windowId, const u8 *pixels, u16 srcX, u16 srcY, u16 srcWidth, int srcHeight, u16 destX, u16 destY, u16 rectWidth, u16 rectHeight) { struct Bitmap sourceRect; struct Bitmap destRect; @@ -411,7 +411,7 @@ void BlitBitmapRectToWindow(u8 windowId, const u8 *pixels, u16 srcX, u16 srcY, u BlitBitmapRect4Bit(&sourceRect, &destRect, srcX, srcY, destX, destY, rectWidth, rectHeight, 0); } -static void UNUSED BlitBitmapRectToWindowWithColorKey(u8 windowId, const u8 *pixels, u16 srcX, u16 srcY, u16 srcWidth, int srcHeight, u16 destX, u16 destY, u16 rectWidth, u16 rectHeight, u8 colorKey) +static void UNUSED BlitBitmapRectToWindowWithColorKey(u32 windowId, const u8 *pixels, u16 srcX, u16 srcY, u16 srcWidth, int srcHeight, u16 destX, u16 destY, u16 rectWidth, u16 rectHeight, u8 colorKey) { struct Bitmap sourceRect; struct Bitmap destRect; @@ -427,7 +427,7 @@ static void UNUSED BlitBitmapRectToWindowWithColorKey(u8 windowId, const u8 *pix BlitBitmapRect4Bit(&sourceRect, &destRect, srcX, srcY, destX, destY, rectWidth, rectHeight, colorKey); } -void FillWindowPixelRect(u8 windowId, u8 fillValue, u16 x, u16 y, u16 width, u16 height) +void FillWindowPixelRect(u32 windowId, u8 fillValue, u16 x, u16 y, u16 width, u16 height) { struct Bitmap pixelRect; @@ -438,7 +438,7 @@ void FillWindowPixelRect(u8 windowId, u8 fillValue, u16 x, u16 y, u16 width, u16 FillBitmapRect4Bit(&pixelRect, x, y, width, height, fillValue); } -void CopyToWindowPixelBuffer(u8 windowId, const void *src, u16 size, u16 tileOffset) +void CopyToWindowPixelBuffer(u32 windowId, const void *src, u16 size, u16 tileOffset) { if (size != 0) CpuCopy16(src, gWindows[windowId].tileData + (32 * tileOffset), size); @@ -447,7 +447,7 @@ void CopyToWindowPixelBuffer(u8 windowId, const void *src, u16 size, u16 tileOff } // Sets all pixels within the window to the fillValue color. -void FillWindowPixelBuffer(u8 windowId, u8 fillValue) +void FillWindowPixelBuffer(u32 windowId, u8 fillValue) { int fillSize = gWindows[windowId].window.width * gWindows[windowId].window.height; CpuFastFill8(fillValue, gWindows[windowId].tileData, 32 * fillSize); @@ -475,7 +475,7 @@ void FillWindowPixelBuffer(u8 windowId, u8 fillValue) distanceLoop++; \ } -void ScrollWindow(u8 windowId, u8 direction, u8 distance, u8 fillValue) +void ScrollWindow(u32 windowId, u8 direction, u8 distance, u8 fillValue) { struct WindowTemplate window = gWindows[windowId].window; u8 *tileData = gWindows[windowId].tileData; @@ -522,13 +522,13 @@ void ScrollWindow(u8 windowId, u8 direction, u8 distance, u8 fillValue) } } -void CallWindowFunction(u8 windowId, void ( *func)(u8, u8, u8, u8, u8, u8)) +void CallWindowFunction(u32 windowId, void ( *func)(u8, u8, u8, u8, u8, u8)) { struct WindowTemplate window = gWindows[windowId].window; func(window.bg, window.tilemapLeft, window.tilemapTop, window.width, window.height, window.paletteNum); } -bool8 SetWindowAttribute(u8 windowId, u8 attributeId, u32 value) +bool32 SetWindowAttribute(u32 windowId, u32 attributeId, u32 value) { switch (attributeId) { @@ -555,7 +555,7 @@ bool8 SetWindowAttribute(u8 windowId, u8 attributeId, u32 value) } } -u32 GetWindowAttribute(u8 windowId, u8 attributeId) +u32 GetWindowAttribute(u32 windowId, u32 attributeId) { switch (attributeId) { @@ -580,9 +580,9 @@ u32 GetWindowAttribute(u8 windowId, u8 attributeId) } } -static u8 GetNumActiveWindowsOnBg(u8 bgId) +static u32 GetNumActiveWindowsOnBg(u32 bgId) { - u8 windowsNum = 0; + u32 windowsNum = 0; s32 i; for (i = 0; i < WINDOWS_MAX; i++) { @@ -597,11 +597,11 @@ static void DummyWindowBgTilemap8Bit(void) } -u16 AddWindow8Bit(const struct WindowTemplate *template) +u32 AddWindow8Bit(const struct WindowTemplate *template) { - u16 windowId; + u32 windowId; u8 *memAddress; - u8 bgLayer; + u32 bgLayer; for (windowId = 0; windowId < WINDOWS_MAX; windowId++) { @@ -644,7 +644,7 @@ u16 AddWindow8Bit(const struct WindowTemplate *template) } } -void FillWindowPixelBuffer8Bit(u8 windowId, u8 fillValue) +void FillWindowPixelBuffer8Bit(u32 windowId, u8 fillValue) { s32 i; s32 size; @@ -654,7 +654,7 @@ void FillWindowPixelBuffer8Bit(u8 windowId, u8 fillValue) gWindows[windowId].tileData[i] = fillValue; } -void FillWindowPixelRect8Bit(u8 windowId, u8 fillValue, u16 x, u16 y, u16 width, u16 height) +void FillWindowPixelRect8Bit(u32 windowId, u8 fillValue, u16 x, u16 y, u16 width, u16 height) { struct Bitmap pixelRect; @@ -665,7 +665,7 @@ void FillWindowPixelRect8Bit(u8 windowId, u8 fillValue, u16 x, u16 y, u16 width, FillBitmapRect8Bit(&pixelRect, x, y, width, height, fillValue); } -void BlitBitmapRectToWindow4BitTo8Bit(u8 windowId, const u8 *pixels, u16 srcX, u16 srcY, u16 srcWidth, int srcHeight, u16 destX, u16 destY, u16 rectWidth, u16 rectHeight, u8 paletteNum) +void BlitBitmapRectToWindow4BitTo8Bit(u32 windowId, const u8 *pixels, u16 srcX, u16 srcY, u16 srcWidth, int srcHeight, u16 destX, u16 destY, u16 rectWidth, u16 rectHeight, u8 paletteNum) { struct Bitmap sourceRect; struct Bitmap destRect; @@ -681,7 +681,7 @@ void BlitBitmapRectToWindow4BitTo8Bit(u8 windowId, const u8 *pixels, u16 srcX, u BlitBitmapRect4BitTo8Bit(&sourceRect, &destRect, srcX, srcY, destX, destY, rectWidth, rectHeight, 0, paletteNum); } -void CopyWindowToVram8Bit(u8 windowId, u8 mode) +void CopyWindowToVram8Bit(u32 windowId, u8 mode) { sWindowPtr = &gWindows[windowId]; sWindowSize = 64 * (sWindowPtr->window.width * sWindowPtr->window.height); @@ -701,9 +701,9 @@ void CopyWindowToVram8Bit(u8 windowId, u8 mode) } } -static u8 GetNumActiveWindowsOnBg8Bit(u8 bgId) +static u32 GetNumActiveWindowsOnBg8Bit(u32 bgId) { - u8 windowsNum = 0; + u32 windowsNum = 0; s32 i; for (i = 0; i < WINDOWS_MAX; i++) { diff --git a/gflib/window.h b/gflib/window.h index 0f2dff2a8aea..85e385cb9f87 100644 --- a/gflib/window.h +++ b/gflib/window.h @@ -48,31 +48,31 @@ struct Window u8 *tileData; }; -bool16 InitWindows(const struct WindowTemplate *templates); -u16 AddWindow(const struct WindowTemplate *template); +bool32 InitWindows(const struct WindowTemplate *templates); +u32 AddWindow(const struct WindowTemplate *template); int AddWindowWithoutTileMap(const struct WindowTemplate *template); -void RemoveWindow(u8 windowId); +void RemoveWindow(u32 windowId); void FreeAllWindowBuffers(void); -void CopyWindowToVram(u8 windowId, u8 mode); +void CopyWindowToVram(u32 windowId, u32 mode); void CopyWindowRectToVram(u32 windowId, u32 mode, u32 x, u32 y, u32 w, u32 h); -void PutWindowTilemap(u8 windowId); -void PutWindowRectTilemapOverridePalette(u8 windowId, u8 x, u8 y, u8 width, u8 height, u8 palette); -void ClearWindowTilemap(u8 windowId); -void PutWindowRectTilemap(u8 windowId, u8 x, u8 y, u8 width, u8 height); -void BlitBitmapToWindow(u8 windowId, const u8 *pixels, u16 x, u16 y, u16 width, u16 height); -void BlitBitmapRectToWindow(u8 windowId, const u8 *pixels, u16 srcX, u16 srcY, u16 srcWidth, int srcHeight, u16 destX, u16 destY, u16 rectWidth, u16 rectHeight); -void FillWindowPixelRect(u8 windowId, u8 fillValue, u16 x, u16 y, u16 width, u16 height); -void CopyToWindowPixelBuffer(u8 windowId, const void *src, u16 size, u16 tileOffset); -void FillWindowPixelBuffer(u8 windowId, u8 fillValue); -void ScrollWindow(u8 windowId, u8 direction, u8 distance, u8 fillValue); -void CallWindowFunction(u8 windowId, void ( *func)(u8, u8, u8, u8, u8, u8)); -bool8 SetWindowAttribute(u8 windowId, u8 attributeId, u32 value); -u32 GetWindowAttribute(u8 windowId, u8 attributeId); -u16 AddWindow8Bit(const struct WindowTemplate *template); -void FillWindowPixelBuffer8Bit(u8 windowId, u8 fillValue); -void FillWindowPixelRect8Bit(u8 windowId, u8 fillValue, u16 x, u16 y, u16 width, u16 height); -void BlitBitmapRectToWindow4BitTo8Bit(u8 windowId, const u8 *pixels, u16 srcX, u16 srcY, u16 srcWidth, int srcHeight, u16 destX, u16 destY, u16 rectWidth, u16 rectHeight, u8 paletteNum); -void CopyWindowToVram8Bit(u8 windowId, u8 mode); +void PutWindowTilemap(u32 windowId); +void PutWindowRectTilemapOverridePalette(u32 windowId, u8 x, u8 y, u8 width, u8 height, u8 palette); +void ClearWindowTilemap(u32 windowId); +void PutWindowRectTilemap(u32 windowId, u8 x, u8 y, u8 width, u8 height); +void BlitBitmapToWindow(u32 windowId, const u8 *pixels, u16 x, u16 y, u16 width, u16 height); +void BlitBitmapRectToWindow(u32 windowId, const u8 *pixels, u16 srcX, u16 srcY, u16 srcWidth, int srcHeight, u16 destX, u16 destY, u16 rectWidth, u16 rectHeight); +void FillWindowPixelRect(u32 windowId, u8 fillValue, u16 x, u16 y, u16 width, u16 height); +void CopyToWindowPixelBuffer(u32 windowId, const void *src, u16 size, u16 tileOffset); +void FillWindowPixelBuffer(u32 windowId, u8 fillValue); +void ScrollWindow(u32 windowId, u8 direction, u8 distance, u8 fillValue); +void CallWindowFunction(u32 windowId, void ( *func)(u8, u8, u8, u8, u8, u8)); +bool32 SetWindowAttribute(u32 windowId, u32 attributeId, u32 value); +u32 GetWindowAttribute(u32 windowId, u32 attributeId); +u32 AddWindow8Bit(const struct WindowTemplate *template); +void FillWindowPixelBuffer8Bit(u32 windowId, u8 fillValue); +void FillWindowPixelRect8Bit(u32 windowId, u8 fillValue, u16 x, u16 y, u16 width, u16 height); +void BlitBitmapRectToWindow4BitTo8Bit(u32 windowId, const u8 *pixels, u16 srcX, u16 srcY, u16 srcWidth, int srcHeight, u16 destX, u16 destY, u16 rectWidth, u16 rectHeight, u8 paletteNum); +void CopyWindowToVram8Bit(u32 windowId, u8 mode); extern struct Window gWindows[]; extern void *gWindowBgTilemapBuffers[]; diff --git a/src/main.c b/src/main.c index 79c406610787..32e103b6e8f6 100644 --- a/src/main.c +++ b/src/main.c @@ -61,8 +61,6 @@ const IntrFunc gIntrTableTemplate[] = #define INTR_COUNT ((int)(sizeof(gIntrTableTemplate)/sizeof(IntrFunc))) -static u16 sUnusedVar; // Never read - u16 gKeyRepeatStartDelay; bool8 gLinkTransferringData; struct Main gMain; @@ -126,7 +124,6 @@ void AgbMain() SetMainCallback2(NULL); gLinkTransferringData = FALSE; - sUnusedVar = 0xFC0; #ifndef NDEBUG #if (LOG_HANDLER == LOG_HANDLER_MGBA_PRINT)