Use defines/enums in window.c, window_8bpp.c

This commit is contained in:
PikalaxALT
2020-04-10 16:36:41 -04:00
parent aea30489fc
commit c29408cbbb
4 changed files with 24 additions and 24 deletions
+1 -1
View File
@@ -34,7 +34,7 @@ enum
BG_ATTR_MOSAIC = 5,
BG_ATTR_WRAPAROUND = 6,
BG_ATTR_PRIORITY = 7,
BG_ATTR_TEXTORAFFINEMODE = 8,
BG_ATTR_MAPSIZE = 8,
BG_ATTR_BGTYPE = 9,
BG_ATTR_BASETILE = 10
};
+1 -1
View File
@@ -567,7 +567,7 @@ u16 GetBgAttribute(u8 bg, u8 attributeId)
return GetBgControlAttribute(bg, BG_CTRL_ATTR_MOSAIC);
case BG_ATTR_WRAPAROUND:
return GetBgControlAttribute(bg, BG_CTRL_ATTR_WRAPAROUND);
case BG_ATTR_TEXTORAFFINEMODE:
case BG_ATTR_MAPSIZE:
switch (GetBgType(bg))
{
case 0:
+19 -19
View File
@@ -21,11 +21,11 @@ bool16 InitWindows(const struct WindowTemplate *templates)
void *bgTilemapBuffer;
int j;
u8 bgLayer;
u16 attrib;
u16 bgSize;
u8* allocatedTilemapBuffer;
int allocatedBaseBlock;
for (i = 0; i < 0x4; ++i)
for (i = 0; i < 4; ++i)
{
bgTilemapBuffer = GetBgTilemapBuffer(i);
if (bgTilemapBuffer != NULL)
@@ -34,13 +34,13 @@ bool16 InitWindows(const struct WindowTemplate *templates)
gWindowBgTilemapBuffers[i] = bgTilemapBuffer;
}
for (i = 0; i < 0x20; ++i)
for (i = 0; i < WINDOWS_MAX; ++i)
{
gWindows[i].window = sDummyWindowTemplate;
gWindows[i].tileData = NULL;
}
for (i = 0, allocatedBaseBlock = 0, bgLayer = templates[i].bg; bgLayer != 0xFF && i < 0x20; ++i, bgLayer = templates[i].bg)
for (i = 0, allocatedBaseBlock = 0, bgLayer = templates[i].bg; bgLayer != 0xFF && i < WINDOWS_MAX; ++i, bgLayer = templates[i].bg)
{
if (gWindowTileAutoAllocEnabled == TRUE)
{
@@ -51,11 +51,11 @@ bool16 InitWindows(const struct WindowTemplate *templates)
if (gWindowBgTilemapBuffers[bgLayer] == NULL)
{
attrib = GetBgAttribute(bgLayer, 0x8);
bgSize = GetBgAttribute(bgLayer, BG_ATTR_MAPSIZE);
if (attrib != 0xFFFF)
if (bgSize != 0xFFFF)
{
allocatedTilemapBuffer = Alloc(attrib);
allocatedTilemapBuffer = Alloc(bgSize);
if (allocatedTilemapBuffer == NULL)
{
@@ -63,7 +63,7 @@ bool16 InitWindows(const struct WindowTemplate *templates)
return FALSE;
}
for (j = 0; j < attrib; ++j)
for (j = 0; j < bgSize; ++j)
allocatedTilemapBuffer[j] = 0;
gWindowBgTilemapBuffers[bgLayer] = allocatedTilemapBuffer;
@@ -103,17 +103,17 @@ u16 AddWindow(const struct WindowTemplate *template)
u16 win;
u8 bgLayer;
int allocatedBaseBlock;
u16 attrib;
u16 bgSize;
u8 *allocatedTilemapBuffer;
int i;
for (win = 0; win < 0x20; ++win)
for (win = 0; win < WINDOWS_MAX; ++win)
{
if ((bgLayer = gWindows[win].window.bg) == 0xFF)
break;
}
if (win == 0x20)
if (win == WINDOWS_MAX)
return 0xFF;
bgLayer = template->bg;
@@ -129,16 +129,16 @@ u16 AddWindow(const struct WindowTemplate *template)
if (gWindowBgTilemapBuffers[bgLayer] == NULL)
{
attrib = GetBgAttribute(bgLayer, 0x8);
bgSize = GetBgAttribute(bgLayer, BG_ATTR_MAPSIZE);
if (attrib != 0xFFFF)
if (bgSize != 0xFFFF)
{
allocatedTilemapBuffer = Alloc(attrib);
allocatedTilemapBuffer = Alloc(bgSize);
if (allocatedTilemapBuffer == NULL)
return 0xFF;
for (i = 0; i < attrib; ++i)
for (i = 0; i < bgSize; ++i)
allocatedTilemapBuffer[i] = 0;
gWindowBgTilemapBuffers[bgLayer] = allocatedTilemapBuffer;
@@ -210,7 +210,7 @@ void FreeAllWindowBuffers(void)
}
}
for (i = 0; i < 0x20; ++i)
for (i = 0; i < WINDOWS_MAX; ++i)
{
if (gWindows[i].tileData != NULL)
{
@@ -246,7 +246,7 @@ void PutWindowTilemap(u8 windowId)
WriteSequenceToBgTilemapBuffer(
windowLocal.window.bg,
GetBgAttribute(windowLocal.window.bg, 0xA) + windowLocal.window.baseBlock,
GetBgAttribute(windowLocal.window.bg, BG_ATTR_BASETILE) + windowLocal.window.baseBlock,
windowLocal.window.tilemapLeft,
windowLocal.window.tilemapTop,
windowLocal.window.width,
@@ -258,7 +258,7 @@ void PutWindowTilemap(u8 windowId)
void PutWindowRectTilemapOverridePalette(u8 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, 0xA);
u16 currentRow = windowLocal.window.baseBlock + (y * windowLocal.window.width) + x + GetBgAttribute(windowLocal.window.bg, BG_ATTR_BASETILE);
int i;
for (i = 0; i < height; ++i)
@@ -294,7 +294,7 @@ void ClearWindowTilemap(u8 windowId)
void PutWindowRectTilemap(u8 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, 0xA);
u16 currentRow = windowLocal.window.baseBlock + (y * windowLocal.window.width) + x + GetBgAttribute(windowLocal.window.bg, BG_ATTR_BASETILE);
int i;
for (i = 0; i < height; ++i)
+3 -3
View File
@@ -16,7 +16,7 @@ u16 AddWindow8Bit(const struct WindowTemplate *template)
u8* memAddress;
u8 bgLayer;
for (windowId = 0; windowId < 32; windowId++)
for (windowId = 0; windowId < WINDOWS_MAX; windowId++)
{
if (gWindows[windowId].window.bg == 0xFF)
break;
@@ -24,9 +24,9 @@ u16 AddWindow8Bit(const struct WindowTemplate *template)
if (windowId == WINDOWS_MAX)
return 0xFF;
bgLayer = template->bg;
if (gWindowBgTilemapBuffers[bgLayer] == 0)
if (gWindowBgTilemapBuffers[bgLayer] == NULL)
{
u16 attribute = GetBgAttribute(bgLayer, 8);
u16 attribute = GetBgAttribute(bgLayer, BG_ATTR_MAPSIZE);
if (attribute != 0xFFFF)
{
s32 i;