diff --git a/include/bg.h b/include/bg.h deleted file mode 100644 index b9410afa3..000000000 --- a/include/bg.h +++ /dev/null @@ -1,70 +0,0 @@ -#ifndef GUARD_BG_H -#define GUARD_BG_H - -#include "global.h" - -enum { - BG_CTRL_ATTR_VISIBLE = 1, - BG_CTRL_ATTR_CHARBASEINDEX = 2, - BG_CTRL_ATTR_MAPBASEINDEX = 3, - BG_CTRL_ATTR_SCREENSIZE = 4, - BG_CTRL_ATTR_PALETTEMODE = 5, - BG_CTRL_ATTR_PRIORITY = 6, - BG_CTRL_ATTR_MOSAIC = 7, - BG_CTRL_ATTR_WRAPAROUND = 8, -}; - -struct BgControl { - struct BgConfig { - u16 visible:1; - u16 unknown_1:1; - u16 screenSize:2; - u16 priority:2; - u16 mosaic:1; - u16 wraparound:1; - - u16 charBaseIndex:2; - u16 mapBaseIndex:5; - u16 paletteMode:1; - - u8 unknown_2; - u8 unknown_3; - } configs[4]; - - u16 bgVisibilityAndMode; -}; - -struct BgTemplate { - u32 bg:2; - u32 charBaseIndex:2; - u32 mapBaseIndex:5; - u32 screenSize:2; - u32 paletteMode:1; - u32 priority:2; - u32 baseTile:10; -}; - -struct BgConfig2 { - u32 baseTile:10; - u32 basePalette:4; - u32 unk_3:18; - - void* tilemap; - u32 bg_x; - u32 bg_y; -}; - -bool32 IsInvalidBg32(u8); -void ResetBgControlStructs(); -u16 GetBgMetricTextMode(u8, u8); -u32 GetBgMetricAffineMode(u8, u8); -u32 GetBgType(u8); -void SetTextModeAndHideBgs(); -bool8 IsInvalidBg(u8); -bool32 IsTileMapOutsideWram(u8); -void CopyRectToBgTilemapBufferRect(u8, void*, u8, u8, u8, u8, u8, u8, u8, u8, u8, u16, u16); -void CopyTileMapEntry(u16*, u16*, s32, u32, u32); -u32 GetTileMapIndexFromCoords(s32, s32, s32, u32, u32); -void WriteSequenceToBgTilemapBuffer(u8, u16, u8, u8, u8, u8, u8, s16); - -#endif // GUARD_BG_H diff --git a/src/bg.c b/src/bg.c index d3c366659..ee26aaa89 100644 --- a/src/bg.c +++ b/src/bg.c @@ -1,9 +1,59 @@ #include "global.h" -#include "bg.h" #include "dma3.h" #define DISPCNT_ALL_BG_AND_MODE_BITS 0x0F07 +enum { + BG_CTRL_ATTR_VISIBLE = 1, + BG_CTRL_ATTR_CHARBASEINDEX = 2, + BG_CTRL_ATTR_MAPBASEINDEX = 3, + BG_CTRL_ATTR_SCREENSIZE = 4, + BG_CTRL_ATTR_PALETTEMODE = 5, + BG_CTRL_ATTR_PRIORITY = 6, + BG_CTRL_ATTR_MOSAIC = 7, + BG_CTRL_ATTR_WRAPAROUND = 8, +}; + +struct BgControl { + struct BgConfig { + u16 visible:1; + u16 unknown_1:1; + u16 screenSize:2; + u16 priority:2; + u16 mosaic:1; + u16 wraparound:1; + + u16 charBaseIndex:2; + u16 mapBaseIndex:5; + u16 paletteMode:1; + + u8 unknown_2; + u8 unknown_3; + } configs[4]; + + u16 bgVisibilityAndMode; +}; + +struct BgTemplate { + u32 bg:2; + u32 charBaseIndex:2; + u32 mapBaseIndex:5; + u32 screenSize:2; + u32 paletteMode:1; + u32 priority:2; + u32 baseTile:10; +}; + +struct BgConfig2 { + u32 baseTile:10; + u32 basePalette:4; + u32 unk_3:18; + + void* tilemap; + u32 bg_x; + u32 bg_y; +}; + static struct BgControl gGpuBgConfigs; static struct BgConfig2 gGpuBgConfigs2[4]; static u32 gDmaBusyBitfield[4]; @@ -17,6 +67,19 @@ extern void SetGpuReg_ForcedBlank(u8 regOffset, u16 value); extern u16 GetGpuReg(u8 regOffset); extern int CheckForSpaceForDma3Request(s16 index); +bool32 IsInvalidBg32(u8); +void ResetBgControlStructs(); +u16 GetBgMetricTextMode(u8, u8); +u32 GetBgMetricAffineMode(u8, u8); +u32 GetBgType(u8); +void SetTextModeAndHideBgs(); +bool8 IsInvalidBg(u8); +bool32 IsTileMapOutsideWram(u8); +void CopyRectToBgTilemapBufferRect(u8, void*, u8, u8, u8, u8, u8, u8, u8, u8, u8, u16, u16); +void CopyTileMapEntry(u16*, u16*, s32, u32, u32); +u32 GetTileMapIndexFromCoords(s32, s32, s32, u32, u32); +void WriteSequenceToBgTilemapBuffer(u8, u16, u8, u8, u8, u8, u8, s16); + void ResetBgs(void) { ResetBgControlStructs();