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_MOSAIC = 5,
BG_ATTR_WRAPAROUND = 6, BG_ATTR_WRAPAROUND = 6,
BG_ATTR_PRIORITY = 7, BG_ATTR_PRIORITY = 7,
BG_ATTR_TEXTORAFFINEMODE = 8, BG_ATTR_MAPSIZE = 8,
BG_ATTR_BGTYPE = 9, BG_ATTR_BGTYPE = 9,
BG_ATTR_BASETILE = 10 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); return GetBgControlAttribute(bg, BG_CTRL_ATTR_MOSAIC);
case BG_ATTR_WRAPAROUND: case BG_ATTR_WRAPAROUND:
return GetBgControlAttribute(bg, BG_CTRL_ATTR_WRAPAROUND); return GetBgControlAttribute(bg, BG_CTRL_ATTR_WRAPAROUND);
case BG_ATTR_TEXTORAFFINEMODE: case BG_ATTR_MAPSIZE:
switch (GetBgType(bg)) switch (GetBgType(bg))
{ {
case 0: case 0:
+19 -19
View File
@@ -21,11 +21,11 @@ bool16 InitWindows(const struct WindowTemplate *templates)
void *bgTilemapBuffer; void *bgTilemapBuffer;
int j; int j;
u8 bgLayer; u8 bgLayer;
u16 attrib; u16 bgSize;
u8* allocatedTilemapBuffer; u8* allocatedTilemapBuffer;
int allocatedBaseBlock; int allocatedBaseBlock;
for (i = 0; i < 0x4; ++i) for (i = 0; i < 4; ++i)
{ {
bgTilemapBuffer = GetBgTilemapBuffer(i); bgTilemapBuffer = GetBgTilemapBuffer(i);
if (bgTilemapBuffer != NULL) if (bgTilemapBuffer != NULL)
@@ -34,13 +34,13 @@ bool16 InitWindows(const struct WindowTemplate *templates)
gWindowBgTilemapBuffers[i] = bgTilemapBuffer; gWindowBgTilemapBuffers[i] = bgTilemapBuffer;
} }
for (i = 0; i < 0x20; ++i) for (i = 0; i < WINDOWS_MAX; ++i)
{ {
gWindows[i].window = sDummyWindowTemplate; gWindows[i].window = sDummyWindowTemplate;
gWindows[i].tileData = NULL; 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) if (gWindowTileAutoAllocEnabled == TRUE)
{ {
@@ -51,11 +51,11 @@ bool16 InitWindows(const struct WindowTemplate *templates)
if (gWindowBgTilemapBuffers[bgLayer] == NULL) 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) if (allocatedTilemapBuffer == NULL)
{ {
@@ -63,7 +63,7 @@ bool16 InitWindows(const struct WindowTemplate *templates)
return FALSE; return FALSE;
} }
for (j = 0; j < attrib; ++j) for (j = 0; j < bgSize; ++j)
allocatedTilemapBuffer[j] = 0; allocatedTilemapBuffer[j] = 0;
gWindowBgTilemapBuffers[bgLayer] = allocatedTilemapBuffer; gWindowBgTilemapBuffers[bgLayer] = allocatedTilemapBuffer;
@@ -103,17 +103,17 @@ u16 AddWindow(const struct WindowTemplate *template)
u16 win; u16 win;
u8 bgLayer; u8 bgLayer;
int allocatedBaseBlock; int allocatedBaseBlock;
u16 attrib; u16 bgSize;
u8 *allocatedTilemapBuffer; u8 *allocatedTilemapBuffer;
int i; int i;
for (win = 0; win < 0x20; ++win) for (win = 0; win < WINDOWS_MAX; ++win)
{ {
if ((bgLayer = gWindows[win].window.bg) == 0xFF) if ((bgLayer = gWindows[win].window.bg) == 0xFF)
break; break;
} }
if (win == 0x20) if (win == WINDOWS_MAX)
return 0xFF; return 0xFF;
bgLayer = template->bg; bgLayer = template->bg;
@@ -129,16 +129,16 @@ u16 AddWindow(const struct WindowTemplate *template)
if (gWindowBgTilemapBuffers[bgLayer] == NULL) 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) if (allocatedTilemapBuffer == NULL)
return 0xFF; return 0xFF;
for (i = 0; i < attrib; ++i) for (i = 0; i < bgSize; ++i)
allocatedTilemapBuffer[i] = 0; allocatedTilemapBuffer[i] = 0;
gWindowBgTilemapBuffers[bgLayer] = allocatedTilemapBuffer; 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) if (gWindows[i].tileData != NULL)
{ {
@@ -246,7 +246,7 @@ void PutWindowTilemap(u8 windowId)
WriteSequenceToBgTilemapBuffer( WriteSequenceToBgTilemapBuffer(
windowLocal.window.bg, 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.tilemapLeft,
windowLocal.window.tilemapTop, windowLocal.window.tilemapTop,
windowLocal.window.width, 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) void PutWindowRectTilemapOverridePalette(u8 windowId, u8 x, u8 y, u8 width, u8 height, u8 palette)
{ {
struct Window windowLocal = gWindows[windowId]; 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; int i;
for (i = 0; i < height; ++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) void PutWindowRectTilemap(u8 windowId, u8 x, u8 y, u8 width, u8 height)
{ {
struct Window windowLocal = gWindows[windowId]; 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; int i;
for (i = 0; i < height; ++i) for (i = 0; i < height; ++i)
+3 -3
View File
@@ -16,7 +16,7 @@ u16 AddWindow8Bit(const struct WindowTemplate *template)
u8* memAddress; u8* memAddress;
u8 bgLayer; u8 bgLayer;
for (windowId = 0; windowId < 32; windowId++) for (windowId = 0; windowId < WINDOWS_MAX; windowId++)
{ {
if (gWindows[windowId].window.bg == 0xFF) if (gWindows[windowId].window.bg == 0xFF)
break; break;
@@ -24,9 +24,9 @@ u16 AddWindow8Bit(const struct WindowTemplate *template)
if (windowId == WINDOWS_MAX) if (windowId == WINDOWS_MAX)
return 0xFF; return 0xFF;
bgLayer = template->bg; 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) if (attribute != 0xFFFF)
{ {
s32 i; s32 i;