Fix BgAttributes

This commit is contained in:
DizzyEggg 2018-12-26 13:05:02 +01:00
parent 2dd706ca54
commit 7f6f6c33ab
18 changed files with 237 additions and 231 deletions

View File

@ -13,14 +13,16 @@ struct BGCntrlBitfield // for the I/O registers
enum enum
{ {
BG_CTRL_ATTR_VISIBLE = 1, BG_ATTR_CHARBASEINDEX = 1,
BG_CTRL_ATTR_CHARBASEINDEX = 2, BG_ATTR_MAPBASEINDEX,
BG_CTRL_ATTR_MAPBASEINDEX = 3, BG_ATTR_SCREENSIZE,
BG_CTRL_ATTR_SCREENSIZE = 4, BG_ATTR_PALETTEMODE,
BG_CTRL_ATTR_PALETTEMODE = 5, BG_ATTR_MOSAIC,
BG_CTRL_ATTR_PRIORITY = 6, BG_ATTR_WRAPAROUND,
BG_CTRL_ATTR_MOSAIC = 7, BG_ATTR_PRIORITY,
BG_CTRL_ATTR_WRAPAROUND = 8, BG_ATTR_METRIC,
BG_ATTR_TYPE,
BG_ATTR_BASETILE,
}; };
struct BgTemplate struct BgTemplate
@ -38,8 +40,6 @@ void ResetBgs(void);
u8 GetBgMode(void); u8 GetBgMode(void);
void ResetBgControlStructs(void); void ResetBgControlStructs(void);
void Unused_ResetBgControlStruct(u8 bg); void Unused_ResetBgControlStruct(u8 bg);
void SetBgControlAttributes(u8 bg, u8 charBaseIndex, u8 mapBaseIndex, u8 screenSize, u8 paletteMode, u8 priority, u8 mosaic, u8 wraparound);
u16 GetBgControlAttribute(u8 bg, u8 attributeId);
u8 LoadBgVram(u8 bg, const void *src, u16 size, u16 destOffset, u8 mode); u8 LoadBgVram(u8 bg, const void *src, u16 size, u16 destOffset, u8 mode);
void SetTextModeAndHideBgs(void); void SetTextModeAndHideBgs(void);
bool8 IsInvalidBg(u8 bg); bool8 IsInvalidBg(u8 bg);

View File

@ -1092,7 +1092,7 @@ void DrawBattleEntryBackground(void)
LZDecompressVram(gUnknown_08D778F0, (void*)(VRAM + 0x4000)); LZDecompressVram(gUnknown_08D778F0, (void*)(VRAM + 0x4000));
LZDecompressVram(gUnknown_08D77B0C, (void*)(VRAM + 0x10000)); LZDecompressVram(gUnknown_08D77B0C, (void*)(VRAM + 0x10000));
LoadCompressedPalette(gUnknown_08D77AE4, 0x60, 0x20); LoadCompressedPalette(gUnknown_08D77AE4, 0x60, 0x20);
SetBgAttribute(1, BG_CTRL_ATTR_MAPBASEINDEX, 1); SetBgAttribute(1, BG_ATTR_SCREENSIZE, 1);
SetGpuReg(REG_OFFSET_BG1CNT, 0x5C04); SetGpuReg(REG_OFFSET_BG1CNT, 0x5C04);
CopyToBgTilemapBuffer(1, gUnknown_08D779D8, 0, 0); CopyToBgTilemapBuffer(1, gUnknown_08D779D8, 0, 0);
CopyToBgTilemapBuffer(2, gUnknown_08D779D8, 0, 0); CopyToBgTilemapBuffer(2, gUnknown_08D779D8, 0, 0);
@ -1113,8 +1113,8 @@ void DrawBattleEntryBackground(void)
} }
else else
{ {
SetBgAttribute(1, BG_CTRL_ATTR_VISIBLE, 2); SetBgAttribute(1, BG_ATTR_CHARBASEINDEX, 2);
SetBgAttribute(2, BG_CTRL_ATTR_VISIBLE, 2); SetBgAttribute(2, BG_ATTR_CHARBASEINDEX, 2);
CopyToBgTilemapBuffer(1, gUnknown_08D857A8, 0, 0); CopyToBgTilemapBuffer(1, gUnknown_08D857A8, 0, 0);
CopyToBgTilemapBuffer(2, gUnknown_08D85A1C, 0, 0); CopyToBgTilemapBuffer(2, gUnknown_08D85A1C, 0, 0);
CopyBgTilemapBufferToVram(1); CopyBgTilemapBufferToVram(1);

View File

@ -221,8 +221,8 @@ static void BattleIntroSlide1(u8 taskId)
gScanlineEffect.state = 3; gScanlineEffect.state = 3;
gTasks[taskId].data[0]++; gTasks[taskId].data[0]++;
CpuFill32(0, (void *)BG_SCREEN_ADDR(28), BG_SCREEN_SIZE); CpuFill32(0, (void *)BG_SCREEN_ADDR(28), BG_SCREEN_SIZE);
SetBgAttribute(1, BG_CTRL_ATTR_VISIBLE, 0); SetBgAttribute(1, BG_ATTR_CHARBASEINDEX, 0);
SetBgAttribute(2, BG_CTRL_ATTR_VISIBLE, 0); SetBgAttribute(2, BG_ATTR_CHARBASEINDEX, 0);
SetGpuReg(REG_OFFSET_BG1CNT, BGCNT_PRIORITY(0) | BGCNT_CHARBASE(0) | BGCNT_16COLOR | BGCNT_SCREENBASE(28) | BGCNT_TXT256x512); SetGpuReg(REG_OFFSET_BG1CNT, BGCNT_PRIORITY(0) | BGCNT_CHARBASE(0) | BGCNT_16COLOR | BGCNT_SCREENBASE(28) | BGCNT_TXT256x512);
SetGpuReg(REG_OFFSET_BG2CNT, BGCNT_PRIORITY(0) | BGCNT_CHARBASE(0) | BGCNT_16COLOR | BGCNT_SCREENBASE(30) | BGCNT_TXT512x256); SetGpuReg(REG_OFFSET_BG2CNT, BGCNT_PRIORITY(0) | BGCNT_CHARBASE(0) | BGCNT_16COLOR | BGCNT_SCREENBASE(30) | BGCNT_TXT512x256);
} }
@ -330,8 +330,8 @@ static void BattleIntroSlide2(u8 taskId)
gScanlineEffect.state = 3; gScanlineEffect.state = 3;
gTasks[taskId].data[0]++; gTasks[taskId].data[0]++;
CpuFill32(0, (void *)BG_SCREEN_ADDR(28), BG_SCREEN_SIZE); CpuFill32(0, (void *)BG_SCREEN_ADDR(28), BG_SCREEN_SIZE);
SetBgAttribute(1, BG_CTRL_ATTR_VISIBLE, 0); SetBgAttribute(1, BG_ATTR_CHARBASEINDEX, 0);
SetBgAttribute(2, BG_CTRL_ATTR_VISIBLE, 0); SetBgAttribute(2, BG_ATTR_CHARBASEINDEX, 0);
SetGpuReg(REG_OFFSET_BG1CNT, BGCNT_PRIORITY(0) | BGCNT_CHARBASE(0) | BGCNT_16COLOR | BGCNT_SCREENBASE(28) | BGCNT_TXT256x512); SetGpuReg(REG_OFFSET_BG1CNT, BGCNT_PRIORITY(0) | BGCNT_CHARBASE(0) | BGCNT_16COLOR | BGCNT_SCREENBASE(28) | BGCNT_TXT256x512);
SetGpuReg(REG_OFFSET_BG2CNT, BGCNT_PRIORITY(0) | BGCNT_CHARBASE(0) | BGCNT_16COLOR | BGCNT_SCREENBASE(30) | BGCNT_TXT512x256); SetGpuReg(REG_OFFSET_BG2CNT, BGCNT_PRIORITY(0) | BGCNT_CHARBASE(0) | BGCNT_16COLOR | BGCNT_SCREENBASE(30) | BGCNT_TXT512x256);
} }
@ -418,8 +418,8 @@ static void BattleIntroSlide3(u8 taskId)
gScanlineEffect.state = 3; gScanlineEffect.state = 3;
gTasks[taskId].data[0]++; gTasks[taskId].data[0]++;
CpuFill32(0, (void *)BG_SCREEN_ADDR(28), BG_SCREEN_SIZE); CpuFill32(0, (void *)BG_SCREEN_ADDR(28), BG_SCREEN_SIZE);
SetBgAttribute(1, BG_CTRL_ATTR_VISIBLE, 0); SetBgAttribute(1, BG_ATTR_CHARBASEINDEX, 0);
SetBgAttribute(2, BG_CTRL_ATTR_VISIBLE, 0); SetBgAttribute(2, BG_ATTR_CHARBASEINDEX, 0);
SetGpuReg(REG_OFFSET_BG1CNT, BGCNT_PRIORITY(0) | BGCNT_CHARBASE(0) | BGCNT_16COLOR | BGCNT_SCREENBASE(28) | BGCNT_TXT256x512); SetGpuReg(REG_OFFSET_BG1CNT, BGCNT_PRIORITY(0) | BGCNT_CHARBASE(0) | BGCNT_16COLOR | BGCNT_SCREENBASE(28) | BGCNT_TXT256x512);
SetGpuReg(REG_OFFSET_BG2CNT, BGCNT_PRIORITY(0) | BGCNT_CHARBASE(0) | BGCNT_16COLOR | BGCNT_SCREENBASE(30) | BGCNT_TXT512x256); SetGpuReg(REG_OFFSET_BG2CNT, BGCNT_PRIORITY(0) | BGCNT_CHARBASE(0) | BGCNT_16COLOR | BGCNT_SCREENBASE(30) | BGCNT_TXT512x256);
} }
@ -499,8 +499,8 @@ static void BattleIntroSlideLink(u8 taskId)
{ {
gScanlineEffect.state = 3; gScanlineEffect.state = 3;
gTasks[taskId].data[0]++; gTasks[taskId].data[0]++;
SetBgAttribute(1, BG_CTRL_ATTR_VISIBLE, 0); SetBgAttribute(1, BG_ATTR_CHARBASEINDEX, 0);
SetBgAttribute(2, BG_CTRL_ATTR_VISIBLE, 0); SetBgAttribute(2, BG_ATTR_CHARBASEINDEX, 0);
SetGpuReg(REG_OFFSET_BG1CNT, BGCNT_PRIORITY(0) | BGCNT_CHARBASE(0) | BGCNT_16COLOR | BGCNT_SCREENBASE(28) | BGCNT_TXT256x512); SetGpuReg(REG_OFFSET_BG1CNT, BGCNT_PRIORITY(0) | BGCNT_CHARBASE(0) | BGCNT_16COLOR | BGCNT_SCREENBASE(28) | BGCNT_TXT256x512);
SetGpuReg(REG_OFFSET_BG2CNT, BGCNT_PRIORITY(0) | BGCNT_CHARBASE(0) | BGCNT_16COLOR | BGCNT_SCREENBASE(30) | BGCNT_TXT512x256); SetGpuReg(REG_OFFSET_BG2CNT, BGCNT_PRIORITY(0) | BGCNT_CHARBASE(0) | BGCNT_16COLOR | BGCNT_SCREENBASE(30) | BGCNT_TXT512x256);
} }
@ -567,8 +567,8 @@ static void BattleIntroSlidePartner(u8 taskId)
{ {
CpuFill32(0, (void *)BG_SCREEN_ADDR(28), BG_SCREEN_SIZE * 4); CpuFill32(0, (void *)BG_SCREEN_ADDR(28), BG_SCREEN_SIZE * 4);
SetGpuReg(REG_OFFSET_DISPCNT, GetGpuReg(REG_OFFSET_DISPCNT) & ~DISPCNT_WIN1_ON); SetGpuReg(REG_OFFSET_DISPCNT, GetGpuReg(REG_OFFSET_DISPCNT) & ~DISPCNT_WIN1_ON);
SetBgAttribute(1, BG_CTRL_ATTR_VISIBLE, 0); SetBgAttribute(1, BG_ATTR_CHARBASEINDEX, 0);
SetBgAttribute(2, BG_CTRL_ATTR_VISIBLE, 0); SetBgAttribute(2, BG_ATTR_CHARBASEINDEX, 0);
SetGpuReg(REG_OFFSET_BG1CNT, BGCNT_PRIORITY(0) | BGCNT_CHARBASE(0) | BGCNT_16COLOR | BGCNT_SCREENBASE(28) | BGCNT_TXT256x512); SetGpuReg(REG_OFFSET_BG1CNT, BGCNT_PRIORITY(0) | BGCNT_CHARBASE(0) | BGCNT_16COLOR | BGCNT_SCREENBASE(28) | BGCNT_TXT256x512);
SetGpuReg(REG_OFFSET_BG2CNT, BGCNT_PRIORITY(0) | BGCNT_CHARBASE(0) | BGCNT_16COLOR | BGCNT_SCREENBASE(30) | BGCNT_TXT512x256); SetGpuReg(REG_OFFSET_BG2CNT, BGCNT_PRIORITY(0) | BGCNT_CHARBASE(0) | BGCNT_16COLOR | BGCNT_SCREENBASE(30) | BGCNT_TXT512x256);
gScanlineEffect.state = 3; gScanlineEffect.state = 3;

View File

@ -6237,7 +6237,7 @@ static void atk6C_drawlvlupbox(void)
{ {
case 1: case 1:
gBattle_BG2_Y = 0x60; gBattle_BG2_Y = 0x60;
SetBgAttribute(2, BG_CTRL_ATTR_MOSAIC, 0); SetBgAttribute(2, BG_ATTR_PRIORITY, 0);
ShowBg(2); ShowBg(2);
sub_804F17C(); sub_804F17C();
gBattleScripting.atk6C_state = 2; gBattleScripting.atk6C_state = 2;
@ -6249,8 +6249,8 @@ static void atk6C_drawlvlupbox(void)
case 3: case 3:
gBattle_BG1_X = 0; gBattle_BG1_X = 0;
gBattle_BG1_Y = 0x100; gBattle_BG1_Y = 0x100;
SetBgAttribute(0, BG_CTRL_ATTR_MOSAIC, 1); SetBgAttribute(0, BG_ATTR_PRIORITY, 1);
SetBgAttribute(1, BG_CTRL_ATTR_MOSAIC, 0); SetBgAttribute(1, BG_ATTR_PRIORITY, 0);
ShowBg(0); ShowBg(0);
ShowBg(1); ShowBg(1);
HandleBattleWindow(0x12, 7, 0x1D, 0x13, WINDOW_x80); HandleBattleWindow(0x12, 7, 0x1D, 0x13, WINDOW_x80);
@ -6296,7 +6296,7 @@ static void atk6C_drawlvlupbox(void)
ClearWindowTilemap(13); ClearWindowTilemap(13);
CopyWindowToVram(13, 1); CopyWindowToVram(13, 1);
SetBgAttribute(2, BG_CTRL_ATTR_MOSAIC, 2); SetBgAttribute(2, BG_ATTR_PRIORITY, 2);
ShowBg(2); ShowBg(2);
gBattleScripting.atk6C_state = 10; gBattleScripting.atk6C_state = 10;
@ -6305,8 +6305,8 @@ static void atk6C_drawlvlupbox(void)
case 10: case 10:
if (!IsDma3ManagerBusyWithBgCopy()) if (!IsDma3ManagerBusyWithBgCopy())
{ {
SetBgAttribute(0, BG_CTRL_ATTR_MOSAIC, 0); SetBgAttribute(0, BG_ATTR_PRIORITY, 0);
SetBgAttribute(1, BG_CTRL_ATTR_MOSAIC, 1); SetBgAttribute(1, BG_ATTR_PRIORITY, 1);
ShowBg(0); ShowBg(0);
ShowBg(1); ShowBg(1);
gBattlescriptCurrInstr++; gBattlescriptCurrInstr++;

166
src/bg.c
View File

@ -77,15 +77,27 @@ void ResetBgControlStructs(void)
void Unused_ResetBgControlStruct(u8 bg) void Unused_ResetBgControlStruct(u8 bg)
{ {
if (IsInvalidBg(bg) == FALSE) if (!IsInvalidBg(bg))
{ {
sGpuBgConfigs.configs[bg] = sZeroedBgControlStruct; sGpuBgConfigs.configs[bg] = sZeroedBgControlStruct;
} }
} }
void SetBgControlAttributes(u8 bg, u8 charBaseIndex, u8 mapBaseIndex, u8 screenSize, u8 paletteMode, u8 priority, u8 mosaic, u8 wraparound) enum
{ {
if (IsInvalidBg(bg) == FALSE) 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,
};
static void SetBgControlAttributes(u8 bg, u8 charBaseIndex, u8 mapBaseIndex, u8 screenSize, u8 paletteMode, u8 priority, u8 mosaic, u8 wraparound)
{
if (!IsInvalidBg(bg))
{ {
if (charBaseIndex != 0xFF) if (charBaseIndex != 0xFF)
{ {
@ -129,9 +141,9 @@ void SetBgControlAttributes(u8 bg, u8 charBaseIndex, u8 mapBaseIndex, u8 screenS
} }
} }
u16 GetBgControlAttribute(u8 bg, u8 attributeId) static u16 GetBgControlAttribute(u8 bg, u8 attributeId)
{ {
if (IsInvalidBg(bg) == FALSE && sGpuBgConfigs.configs[bg].visible != FALSE) if (!IsInvalidBg(bg) && sGpuBgConfigs.configs[bg].visible)
{ {
switch (attributeId) switch (attributeId)
{ {
@ -162,7 +174,7 @@ u8 LoadBgVram(u8 bg, const void *src, u16 size, u16 destOffset, u8 mode)
u16 offset; u16 offset;
s8 cursor; s8 cursor;
if (IsInvalidBg(bg) == FALSE && sGpuBgConfigs.configs[bg].visible != FALSE) if (!IsInvalidBg(bg) && sGpuBgConfigs.configs[bg].visible)
{ {
switch (mode) switch (mode)
{ {
@ -198,7 +210,7 @@ end:
static void ShowBgInternal(u8 bg) static void ShowBgInternal(u8 bg)
{ {
u16 value; u16 value;
if (IsInvalidBg(bg) == FALSE && sGpuBgConfigs.configs[bg].visible != FALSE) if (!IsInvalidBg(bg) && sGpuBgConfigs.configs[bg].visible)
{ {
value = sGpuBgConfigs.configs[bg].priority | value = sGpuBgConfigs.configs[bg].priority |
(sGpuBgConfigs.configs[bg].charBaseIndex << 2) | (sGpuBgConfigs.configs[bg].charBaseIndex << 2) |
@ -217,7 +229,7 @@ static void ShowBgInternal(u8 bg)
static void HideBgInternal(u8 bg) static void HideBgInternal(u8 bg)
{ {
if (IsInvalidBg(bg) == FALSE) if (!IsInvalidBg(bg))
{ {
sGpuBgConfigs.bgVisibilityAndMode &= ~(1 << (bg + 8)); sGpuBgConfigs.bgVisibilityAndMode &= ~(1 << (bg + 8));
sGpuBgConfigs.bgVisibilityAndMode &= DISPCNT_ALL_BG_AND_MODE_BITS; sGpuBgConfigs.bgVisibilityAndMode &= DISPCNT_ALL_BG_AND_MODE_BITS;
@ -226,12 +238,12 @@ static void HideBgInternal(u8 bg)
static void SyncBgVisibilityAndMode(void) static void SyncBgVisibilityAndMode(void)
{ {
SetGpuReg(0, (GetGpuReg(0) & ~DISPCNT_ALL_BG_AND_MODE_BITS) | sGpuBgConfigs.bgVisibilityAndMode); SetGpuReg(REG_OFFSET_DISPCNT, (GetGpuReg(REG_OFFSET_DISPCNT) & ~DISPCNT_ALL_BG_AND_MODE_BITS) | sGpuBgConfigs.bgVisibilityAndMode);
} }
void SetTextModeAndHideBgs(void) void SetTextModeAndHideBgs(void)
{ {
SetGpuReg(0, GetGpuReg(0) & ~DISPCNT_ALL_BG_AND_MODE_BITS); SetGpuReg(REG_OFFSET_DISPCNT, GetGpuReg(REG_OFFSET_DISPCNT) & ~DISPCNT_ALL_BG_AND_MODE_BITS);
} }
static void SetBgAffineInternal(u8 bg, u32 srcCenterX, u32 srcCenterY, s16 dispCenterX, s16 dispCenterY, s16 scaleX, s16 scaleY, u16 rotationAngle) static void SetBgAffineInternal(u8 bg, u32 srcCenterX, u32 srcCenterY, s16 dispCenterX, s16 dispCenterY, s16 scaleX, s16 scaleY, u16 rotationAngle)
@ -312,7 +324,8 @@ void InitBgsFromTemplates(u8 bgMode, const struct BgTemplate *templates, u8 numT
for (i = 0; i < numTemplates; i++) for (i = 0; i < numTemplates; i++)
{ {
bg = templates[i].bg; bg = templates[i].bg;
if (bg < 4) { if (bg < 4)
{
SetBgControlAttributes(bg, SetBgControlAttributes(bg,
templates[i].charBaseIndex, templates[i].charBaseIndex,
templates[i].mapBaseIndex, templates[i].mapBaseIndex,
@ -396,9 +409,7 @@ u16 LoadBgTiles(u8 bg, const void* src, u16 size, u16 destOffset)
u16 LoadBgTilemap(u8 bg, const void *src, u16 size, u16 destOffset) u16 LoadBgTilemap(u8 bg, const void *src, u16 size, u16 destOffset)
{ {
u8 cursor; u8 cursor = LoadBgVram(bg, src, size, destOffset * 2, DISPCNT_MODE_2);
cursor = LoadBgVram(bg, src, size, destOffset * 2, DISPCNT_MODE_2);
if (cursor == 0xFF) if (cursor == 0xFF)
{ {
@ -412,12 +423,11 @@ u16 LoadBgTilemap(u8 bg, const void *src, u16 size, u16 destOffset)
u16 Unused_LoadBgPalette(u8 bg, const void *src, u16 size, u16 destOffset) u16 Unused_LoadBgPalette(u8 bg, const void *src, u16 size, u16 destOffset)
{ {
u16 paletteOffset;
s8 cursor; s8 cursor;
if (IsInvalidBg32(bg) == FALSE) if (!IsInvalidBg32(bg))
{ {
paletteOffset = (sGpuBgConfigs2[bg].basePalette * 0x20) + (destOffset * 2); u16 paletteOffset = (sGpuBgConfigs2[bg].basePalette * 0x20) + (destOffset * 2);
cursor = RequestDma3Copy(src, (void*)(paletteOffset + BG_PLTT), size, 0); cursor = RequestDma3Copy(src, (void*)(paletteOffset + BG_PLTT), size, 0);
if (cursor == -1) if (cursor == -1)
@ -437,20 +447,16 @@ u16 Unused_LoadBgPalette(u8 bg, const void *src, u16 size, u16 destOffset)
bool8 IsDma3ManagerBusyWithBgCopy(void) bool8 IsDma3ManagerBusyWithBgCopy(void)
{ {
u8 mod;
u8 div;
s8 reqSpace;
int i; int i;
for (i = 0; i < 0x80; i++) for (i = 0; i < 0x80; i++)
{ {
div = i / 0x20; u8 div = i / 0x20;
mod = i % 0x20; u8 mod = i % 0x20;
if ((sDmaBusyBitfield[div] & (1 << mod)) != FALSE) if ((sDmaBusyBitfield[div] & (1 << mod)))
{ {
reqSpace = CheckForSpaceForDma3Request(i); s8 reqSpace = CheckForSpaceForDma3Request(i);
if (reqSpace == -1) if (reqSpace == -1)
{ {
return TRUE; return TRUE;
@ -479,25 +485,25 @@ void SetBgAttribute(u8 bg, u8 attributeId, u8 value)
{ {
switch (attributeId) switch (attributeId)
{ {
case 1: case BG_ATTR_CHARBASEINDEX:
SetBgControlAttributes(bg, value, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF); SetBgControlAttributes(bg, value, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF);
break; break;
case 2: case BG_ATTR_MAPBASEINDEX:
SetBgControlAttributes(bg, 0xFF, value, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF); SetBgControlAttributes(bg, 0xFF, value, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF);
break; break;
case 3: case BG_ATTR_SCREENSIZE:
SetBgControlAttributes(bg, 0xFF, 0xFF, value, 0xFF, 0xFF, 0xFF, 0xFF); SetBgControlAttributes(bg, 0xFF, 0xFF, value, 0xFF, 0xFF, 0xFF, 0xFF);
break; break;
case 4: case BG_ATTR_PALETTEMODE:
SetBgControlAttributes(bg, 0xFF, 0xFF, 0xFF, value, 0xFF, 0xFF, 0xFF); SetBgControlAttributes(bg, 0xFF, 0xFF, 0xFF, value, 0xFF, 0xFF, 0xFF);
break; break;
case 7: case BG_ATTR_PRIORITY:
SetBgControlAttributes(bg, 0xFF, 0xFF, 0xFF, 0xFF, value, 0xFF, 0xFF); SetBgControlAttributes(bg, 0xFF, 0xFF, 0xFF, 0xFF, value, 0xFF, 0xFF);
break; break;
case 5: case BG_ATTR_MOSAIC:
SetBgControlAttributes(bg, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, value, 0xFF); SetBgControlAttributes(bg, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, value, 0xFF);
break; break;
case 6: case BG_ATTR_WRAPAROUND:
SetBgControlAttributes(bg, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, value); SetBgControlAttributes(bg, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, value);
break; break;
} }
@ -507,21 +513,21 @@ u16 GetBgAttribute(u8 bg, u8 attributeId)
{ {
switch (attributeId) switch (attributeId)
{ {
case 1: case BG_ATTR_CHARBASEINDEX:
return GetBgControlAttribute(bg, BG_CTRL_ATTR_CHARBASEINDEX); return GetBgControlAttribute(bg, BG_CTRL_ATTR_CHARBASEINDEX);
case 2: case BG_ATTR_MAPBASEINDEX:
return GetBgControlAttribute(bg, BG_CTRL_ATTR_MAPBASEINDEX); return GetBgControlAttribute(bg, BG_CTRL_ATTR_MAPBASEINDEX);
case 3: case BG_ATTR_SCREENSIZE:
return GetBgControlAttribute(bg, BG_CTRL_ATTR_SCREENSIZE); return GetBgControlAttribute(bg, BG_CTRL_ATTR_SCREENSIZE);
case 4: case BG_ATTR_PALETTEMODE:
return GetBgControlAttribute(bg, BG_CTRL_ATTR_PALETTEMODE); return GetBgControlAttribute(bg, BG_CTRL_ATTR_PALETTEMODE);
case 7: case BG_ATTR_PRIORITY:
return GetBgControlAttribute(bg, BG_CTRL_ATTR_PRIORITY); return GetBgControlAttribute(bg, BG_CTRL_ATTR_PRIORITY);
case 5: case BG_ATTR_MOSAIC:
return GetBgControlAttribute(bg, BG_CTRL_ATTR_MOSAIC); return GetBgControlAttribute(bg, BG_CTRL_ATTR_MOSAIC);
case 6: case BG_ATTR_WRAPAROUND:
return GetBgControlAttribute(bg, BG_CTRL_ATTR_WRAPAROUND); return GetBgControlAttribute(bg, BG_CTRL_ATTR_WRAPAROUND);
case 8: case BG_ATTR_METRIC:
switch (GetBgType(bg)) switch (GetBgType(bg))
{ {
case 0: case 0:
@ -531,9 +537,9 @@ u16 GetBgAttribute(u8 bg, u8 attributeId)
default: default:
return 0; return 0;
} }
case 9: case BG_ATTR_TYPE:
return GetBgType(bg); return GetBgType(bg);
case 10: case BG_ATTR_BASETILE:
return sGpuBgConfigs2[bg].baseTile; return sGpuBgConfigs2[bg].baseTile;
default: default:
return -1; return -1;
@ -546,7 +552,7 @@ s32 ChangeBgX(u8 bg, s32 value, u8 op)
u16 temp1; u16 temp1;
u16 temp2; u16 temp2;
if (IsInvalidBg32(bg) != FALSE || GetBgControlAttribute(bg, BG_CTRL_ATTR_VISIBLE) == 0) if (IsInvalidBg32(bg) || !GetBgControlAttribute(bg, BG_CTRL_ATTR_VISIBLE))
{ {
return -1; return -1;
} }
@ -612,9 +618,9 @@ s32 ChangeBgX(u8 bg, s32 value, u8 op)
s32 GetBgX(u8 bg) s32 GetBgX(u8 bg)
{ {
if (IsInvalidBg32(bg) != FALSE) if (IsInvalidBg32(bg))
return -1; return -1;
else if (GetBgControlAttribute(bg, BG_CTRL_ATTR_VISIBLE) == 0) else if (!GetBgControlAttribute(bg, BG_CTRL_ATTR_VISIBLE))
return -1; return -1;
else else
return sGpuBgConfigs2[bg].bg_x; return sGpuBgConfigs2[bg].bg_x;
@ -626,7 +632,7 @@ s32 ChangeBgY(u8 bg, s32 value, u8 op)
u16 temp1; u16 temp1;
u16 temp2; u16 temp2;
if (IsInvalidBg32(bg) != FALSE || GetBgControlAttribute(bg, BG_CTRL_ATTR_VISIBLE) == 0) if (IsInvalidBg32(bg) || !GetBgControlAttribute(bg, BG_CTRL_ATTR_VISIBLE))
{ {
return -1; return -1;
} }
@ -696,7 +702,7 @@ s32 ChangeBgY_ScreenOff(u8 bg, u32 value, u8 op)
u16 temp1; u16 temp1;
u16 temp2; u16 temp2;
if (IsInvalidBg32(bg) != FALSE || GetBgControlAttribute(bg, BG_CTRL_ATTR_VISIBLE) == 0) if (IsInvalidBg32(bg) || !GetBgControlAttribute(bg, BG_CTRL_ATTR_VISIBLE))
{ {
return -1; return -1;
} }
@ -763,9 +769,9 @@ s32 ChangeBgY_ScreenOff(u8 bg, u32 value, u8 op)
s32 GetBgY(u8 bg) s32 GetBgY(u8 bg)
{ {
if (IsInvalidBg32(bg) != FALSE) if (IsInvalidBg32(bg))
return -1; return -1;
else if (GetBgControlAttribute(bg, BG_CTRL_ATTR_VISIBLE) == 0) else if (!GetBgControlAttribute(bg, BG_CTRL_ATTR_VISIBLE))
return -1; return -1;
else else
return sGpuBgConfigs2[bg].bg_y; return sGpuBgConfigs2[bg].bg_y;
@ -849,7 +855,7 @@ u8 Unused_AdjustBgMosaic(u8 a1, u8 a2)
void SetBgTilemapBuffer(u8 bg, void *tilemap) void SetBgTilemapBuffer(u8 bg, void *tilemap)
{ {
if (IsInvalidBg32(bg) == FALSE && GetBgControlAttribute(bg, BG_CTRL_ATTR_VISIBLE) != 0x0) if (!IsInvalidBg32(bg) && GetBgControlAttribute(bg, BG_CTRL_ATTR_VISIBLE))
{ {
sGpuBgConfigs2[bg].tilemap = tilemap; sGpuBgConfigs2[bg].tilemap = tilemap;
} }
@ -857,7 +863,7 @@ void SetBgTilemapBuffer(u8 bg, void *tilemap)
void UnsetBgTilemapBuffer(u8 bg) void UnsetBgTilemapBuffer(u8 bg)
{ {
if (IsInvalidBg32(bg) == FALSE && GetBgControlAttribute(bg, BG_CTRL_ATTR_VISIBLE) != 0x0) if (!IsInvalidBg32(bg) && GetBgControlAttribute(bg, BG_CTRL_ATTR_VISIBLE))
{ {
sGpuBgConfigs2[bg].tilemap = NULL; sGpuBgConfigs2[bg].tilemap = NULL;
} }
@ -865,9 +871,9 @@ void UnsetBgTilemapBuffer(u8 bg)
void* GetBgTilemapBuffer(u8 bg) void* GetBgTilemapBuffer(u8 bg)
{ {
if (IsInvalidBg32(bg) != FALSE) if (IsInvalidBg32(bg))
return NULL; return NULL;
else if (GetBgControlAttribute(bg, BG_CTRL_ATTR_VISIBLE) == 0) else if (!GetBgControlAttribute(bg, BG_CTRL_ATTR_VISIBLE))
return NULL; return NULL;
else else
return sGpuBgConfigs2[bg].tilemap; return sGpuBgConfigs2[bg].tilemap;
@ -875,7 +881,7 @@ void* GetBgTilemapBuffer(u8 bg)
void CopyToBgTilemapBuffer(u8 bg, const void *src, u16 mode, u16 destOffset) void CopyToBgTilemapBuffer(u8 bg, const void *src, u16 mode, u16 destOffset)
{ {
if (IsInvalidBg32(bg) == FALSE && IsTileMapOutsideWram(bg) == FALSE) if (!IsInvalidBg32(bg) && !IsTileMapOutsideWram(bg))
{ {
if (mode != 0) if (mode != 0)
CpuCopy16(src, (void *)(sGpuBgConfigs2[bg].tilemap + (destOffset * 2)), mode); CpuCopy16(src, (void *)(sGpuBgConfigs2[bg].tilemap + (destOffset * 2)), mode);
@ -888,7 +894,7 @@ void CopyBgTilemapBufferToVram(u8 bg)
{ {
u16 sizeToLoad; u16 sizeToLoad;
if (IsInvalidBg32(bg) == FALSE && IsTileMapOutsideWram(bg) == FALSE) if (!IsInvalidBg32(bg) && !IsTileMapOutsideWram(bg))
{ {
switch (GetBgType(bg)) switch (GetBgType(bg))
{ {
@ -908,12 +914,12 @@ void CopyBgTilemapBufferToVram(u8 bg)
void CopyToBgTilemapBufferRect(u8 bg, const void* src, u8 destX, u8 destY, u8 width, u8 height) void CopyToBgTilemapBufferRect(u8 bg, const void* src, u8 destX, u8 destY, u8 width, u8 height)
{ {
const void* srcCopy; const void *srcCopy;
u16 destX16; u16 destX16;
u16 destY16; u16 destY16;
u16 mode; u16 mode;
if (IsInvalidBg32(bg) == FALSE && IsTileMapOutsideWram(bg) == FALSE) if (!IsInvalidBg32(bg) && !IsTileMapOutsideWram(bg))
{ {
switch (GetBgType(bg)) switch (GetBgType(bg))
{ {
@ -997,29 +1003,29 @@ void FillBgTilemapBufferRect_Palette0(u8 bg, u16 tileNum, u8 x, u8 y, u8 width,
u16 y16; u16 y16;
u16 mode; u16 mode;
if (IsInvalidBg32(bg) == FALSE && IsTileMapOutsideWram(bg) == FALSE) if (!IsInvalidBg32(bg) && !IsTileMapOutsideWram(bg))
{ {
switch (GetBgType(bg)) switch (GetBgType(bg))
{ {
case 0: case 0:
for (y16 = y; y16 < (y + height); y16++) for (y16 = y; y16 < (y + height); y16++)
{
for (x16 = x; x16 < (x + width); x16++)
{ {
for (x16 = x; x16 < (x + width); x16++) ((u16*)sGpuBgConfigs2[bg].tilemap)[((y16 * 0x20) + x16)] = tileNum;
{
((u16*)sGpuBgConfigs2[bg].tilemap)[((y16 * 0x20) + x16)] = tileNum;
}
} }
break; }
case 1: break;
mode = GetBgMetricAffineMode(bg, 0x1); case 1:
for (y16 = y; y16 < (y + height); y16++) mode = GetBgMetricAffineMode(bg, 0x1);
for (y16 = y; y16 < (y + height); y16++)
{
for (x16 = x; x16 < (x + width); x16++)
{ {
for (x16 = x; x16 < (x + width); x16++) ((u8*)sGpuBgConfigs2[bg].tilemap)[((y16 * mode) + x16)] = tileNum;
{
((u8*)sGpuBgConfigs2[bg].tilemap)[((y16 * mode) + x16)] = tileNum;
}
} }
break; }
break;
} }
} }
} }
@ -1071,12 +1077,12 @@ void WriteSequenceToBgTilemapBuffer(u8 bg, u16 firstTileNum, u8 x, u8 y, u8 widt
u16 GetBgMetricTextMode(u8 bg, u8 whichMetric) u16 GetBgMetricTextMode(u8 bg, u8 whichMetric)
{ {
u8 attribute = GetBgControlAttribute(bg, BG_CTRL_ATTR_SCREENSIZE); u8 screenSize = GetBgControlAttribute(bg, BG_CTRL_ATTR_SCREENSIZE);
switch (whichMetric) switch (whichMetric)
{ {
case 0: case 0:
switch (attribute) switch (screenSize)
{ {
case 0: case 0:
return 1; return 1;
@ -1088,7 +1094,7 @@ u16 GetBgMetricTextMode(u8 bg, u8 whichMetric)
} }
break; break;
case 1: case 1:
switch (attribute) switch (screenSize)
{ {
case 0: case 0:
return 1; return 1;
@ -1101,7 +1107,7 @@ u16 GetBgMetricTextMode(u8 bg, u8 whichMetric)
} }
break; break;
case 2: case 2:
switch (attribute) switch (screenSize)
{ {
case 0: case 0:
case 1: case 1:
@ -1117,12 +1123,12 @@ u16 GetBgMetricTextMode(u8 bg, u8 whichMetric)
u32 GetBgMetricAffineMode(u8 bg, u8 whichMetric) u32 GetBgMetricAffineMode(u8 bg, u8 whichMetric)
{ {
u8 attribute = GetBgControlAttribute(bg, BG_CTRL_ATTR_SCREENSIZE); u8 screenSize = GetBgControlAttribute(bg, BG_CTRL_ATTR_SCREENSIZE);
switch (whichMetric) switch (whichMetric)
{ {
case 0: case 0:
switch (attribute) switch (screenSize)
{ {
case 0: case 0:
return 0x1; return 0x1;
@ -1136,7 +1142,7 @@ u32 GetBgMetricAffineMode(u8 bg, u8 whichMetric)
break; break;
case 1: case 1:
case 2: case 2:
return 0x10 << attribute; return 0x10 << screenSize;
} }
return 0; return 0;
} }

View File

@ -285,7 +285,7 @@ void sub_80D779C(void)
ResetBgsAndClearDma3BusyFlags(0); ResetBgsAndClearDma3BusyFlags(0);
InitBgsFromTemplates(0, gUnknown_08587F34, ARRAY_COUNT(gUnknown_08587F34)); InitBgsFromTemplates(0, gUnknown_08587F34, ARRAY_COUNT(gUnknown_08587F34));
SetBgAttribute(3, BG_CTRL_ATTR_PRIORITY, 1); SetBgAttribute(3, BG_ATTR_WRAPAROUND, 1);
for (i = 0; i < 4; i++) for (i = 0; i < 4; i++)
{ {
SetBgTilemapBuffer(i, gContestResources->field_24[i]); SetBgTilemapBuffer(i, gContestResources->field_24[i]);

View File

@ -502,7 +502,7 @@ static void CB2_EggHatch_0(void)
ChangeBgX(0, 0, 0); ChangeBgX(0, 0, 0);
ChangeBgY(0, 0, 0); ChangeBgY(0, 0, 0);
SetBgAttribute(1, BG_CTRL_ATTR_MOSAIC, 2); SetBgAttribute(1, BG_ATTR_PRIORITY, 2);
SetBgTilemapBuffer(1, Alloc(0x1000)); SetBgTilemapBuffer(1, Alloc(0x1000));
SetBgTilemapBuffer(0, Alloc(0x2000)); SetBgTilemapBuffer(0, Alloc(0x2000));

View File

@ -1483,8 +1483,8 @@ static void InitMovingBackgroundTask(bool8 isLink)
SetGpuReg(REG_OFFSET_BLDALPHA, 0x808); SetGpuReg(REG_OFFSET_BLDALPHA, 0x808);
SetGpuReg(REG_OFFSET_DISPCNT, DISPCNT_OBJ_ON | DISPCNT_BG2_ON | DISPCNT_BG1_ON | DISPCNT_BG0_ON | DISPCNT_OBJ_1D_MAP); SetGpuReg(REG_OFFSET_DISPCNT, DISPCNT_OBJ_ON | DISPCNT_BG2_ON | DISPCNT_BG1_ON | DISPCNT_BG0_ON | DISPCNT_OBJ_1D_MAP);
SetBgAttribute(innerBgId, BG_CTRL_ATTR_MOSAIC, 2); SetBgAttribute(innerBgId, BG_ATTR_PRIORITY, 2);
SetBgAttribute(outerBgId, BG_CTRL_ATTR_MOSAIC, 2); SetBgAttribute(outerBgId, BG_ATTR_PRIORITY, 2);
ShowBg(1); ShowBg(1);
ShowBg(2); ShowBg(2);
@ -1529,8 +1529,8 @@ static void sub_8140174(void)
gBattle_BG1_X = 0; gBattle_BG1_X = 0;
gBattle_BG1_Y = 0; gBattle_BG1_Y = 0;
gBattle_BG2_X = 0; gBattle_BG2_X = 0;
SetBgAttribute(1, BG_CTRL_ATTR_MOSAIC, sub_80391E0(1, 5)); SetBgAttribute(1, BG_ATTR_PRIORITY, sub_80391E0(1, 5));
SetBgAttribute(2, BG_CTRL_ATTR_MOSAIC, sub_80391E0(2, 5)); SetBgAttribute(2, BG_ATTR_PRIORITY, sub_80391E0(2, 5));
SetGpuReg(REG_OFFSET_DISPCNT, DISPCNT_OBJ_ON | DISPCNT_BG3_ON | DISPCNT_BG0_ON | DISPCNT_OBJ_1D_MAP); SetGpuReg(REG_OFFSET_DISPCNT, DISPCNT_OBJ_ON | DISPCNT_BG3_ON | DISPCNT_BG0_ON | DISPCNT_OBJ_1D_MAP);
Free(sEvoMovingBgPtr); Free(sEvoMovingBgPtr);
} }

View File

@ -1934,8 +1934,8 @@ void sub_8199D98(void)
void sub_8199DF0(u32 bg, u8 a1, int a2, int a3) void sub_8199DF0(u32 bg, u8 a1, int a2, int a3)
{ {
int temp = (!GetBgAttribute(bg, 4)) ? 0x20 : 0x40; int temp = (!GetBgAttribute(bg, BG_ATTR_PALETTEMODE)) ? 0x20 : 0x40;
void *addr = (void *)((GetBgAttribute(bg, 1) * 0x4000) + (GetBgAttribute(bg, 10) + a2) * temp); void *addr = (void *)((GetBgAttribute(bg, BG_ATTR_CHARBASEINDEX) * 0x4000) + (GetBgAttribute(bg, BG_ATTR_BASETILE) + a2) * temp);
RequestDma3Fill(a1 << 24 | a1 << 16 | a1 << 8 | a1, addr + VRAM, a3 * temp, 1); RequestDma3Fill(a1 << 24 | a1 << 16 | a1 << 8 | a1, addr + VRAM, a3 * temp, 1);
} }

View File

@ -509,7 +509,7 @@ static void InitMirageTowerShake(u8 taskId)
{ {
case 0: case 0:
FreeAllWindowBuffers(); FreeAllWindowBuffers();
SetBgAttribute(0, BG_CTRL_ATTR_MOSAIC, 2); SetBgAttribute(0, BG_ATTR_PRIORITY, 2);
gTasks[taskId].data[0]++; gTasks[taskId].data[0]++;
break; break;
case 1: case 1:
@ -624,7 +624,7 @@ static void DoMirageTowerDisintegration(u8 taskId)
case 6: case 6:
SetGpuRegBits(REG_OFFSET_BG2CNT, BGCNT_PRIORITY(2)); SetGpuRegBits(REG_OFFSET_BG2CNT, BGCNT_PRIORITY(2));
SetGpuRegBits(REG_OFFSET_BG0CNT, BGCNT_PRIORITY(0)); SetGpuRegBits(REG_OFFSET_BG0CNT, BGCNT_PRIORITY(0));
SetBgAttribute(0, BG_CTRL_ATTR_MOSAIC, 0); SetBgAttribute(0, BG_ATTR_PRIORITY, 0);
sub_81971D0(); sub_81971D0();
break; break;
case 7: case 7:

View File

@ -1448,9 +1448,9 @@ u8 GetCurrentMapBattleScene(void)
static void overworld_bg_setup(void) static void overworld_bg_setup(void)
{ {
InitBgsFromTemplates(0, gUnknown_08339DAC, ARRAY_COUNT(gUnknown_08339DAC)); InitBgsFromTemplates(0, gUnknown_08339DAC, ARRAY_COUNT(gUnknown_08339DAC));
SetBgAttribute(1, BG_CTRL_ATTR_PALETTEMODE, 1); SetBgAttribute(1, BG_ATTR_MOSAIC, 1);
SetBgAttribute(2, BG_CTRL_ATTR_PALETTEMODE, 1); SetBgAttribute(2, BG_ATTR_MOSAIC, 1);
SetBgAttribute(3, BG_CTRL_ATTR_PALETTEMODE, 1); SetBgAttribute(3, BG_ATTR_MOSAIC, 1);
gBGTilemapBuffers2 = AllocZeroed(0x800); gBGTilemapBuffers2 = AllocZeroed(0x800);
gBGTilemapBuffers1 = AllocZeroed(0x800); gBGTilemapBuffers1 = AllocZeroed(0x800);
gBGTilemapBuffers3 = AllocZeroed(0x800); gBGTilemapBuffers3 = AllocZeroed(0x800);

View File

@ -533,7 +533,7 @@ static void Task_PokedexAreaScreen_0(u8 taskId)
HideBg(0); HideBg(0);
break; break;
case 1: case 1:
SetBgAttribute(3, BG_CTRL_ATTR_VISIBLE, 3); SetBgAttribute(3, BG_ATTR_CHARBASEINDEX, 3);
sub_81C4D70(&sUnknown_085B4018); sub_81C4D70(&sUnknown_085B4018);
StringFill(sPokedexAreaScreen->charBuffer, CHAR_SPACE, 16); StringFill(sPokedexAreaScreen->charBuffer, CHAR_SPACE, 16);
break; break;
@ -628,8 +628,8 @@ static void Task_PokedexAreaScreen_1(u8 taskId)
static void sub_813D6B4(void) static void sub_813D6B4(void)
{ {
SetBgAttribute(3, BG_CTRL_ATTR_VISIBLE, 0); SetBgAttribute(3, BG_ATTR_CHARBASEINDEX, 0);
SetBgAttribute(3, BG_CTRL_ATTR_SCREENSIZE, 0); SetBgAttribute(3, BG_ATTR_PALETTEMODE, 0);
} }
static void CreateAreaMarkerSprites(void) static void CreateAreaMarkerSprites(void)

View File

@ -8826,7 +8826,7 @@ static bool8 sub_80D024C(void)
FillBgTilemapBufferRect_Palette0(0, 0, 0, 0, 0x20, 0x20); FillBgTilemapBufferRect_Palette0(0, 0, 0, 0, 0x20, 0x20);
FillWindowPixelBuffer8Bit(sPSSData->field_2200, 0); FillWindowPixelBuffer8Bit(sPSSData->field_2200, 0);
sub_80D07B0(sMoveMonsPtr->fromRow, sMoveMonsPtr->fromColumn); sub_80D07B0(sMoveMonsPtr->fromRow, sMoveMonsPtr->fromColumn);
SetBgAttribute(0, 4, 1); SetBgAttribute(0, BG_ATTR_PALETTEMODE, 1);
PutWindowTilemap(sPSSData->field_2200); PutWindowTilemap(sPSSData->field_2200);
CopyWindowToVram8Bit(sPSSData->field_2200, 3); CopyWindowToVram8Bit(sPSSData->field_2200, 3);
BlendPalettes(0x3F00, 8, RGB_WHITE); BlendPalettes(0x3F00, 8, RGB_WHITE);
@ -9246,7 +9246,7 @@ static void sub_80D0B5C(void)
{ {
ChangeBgX(0, 0, 0); ChangeBgX(0, 0, 0);
ChangeBgY(0, 0, 0); ChangeBgY(0, 0, 0);
SetBgAttribute(0, 4, 0); SetBgAttribute(0, BG_ATTR_PALETTEMODE, 0);
ClearGpuRegBits(REG_OFFSET_BG0CNT, BGCNT_256COLOR); ClearGpuRegBits(REG_OFFSET_BG0CNT, BGCNT_256COLOR);
FillBgTilemapBufferRect_Palette0(0, 0, 0, 0, 32, 32); FillBgTilemapBufferRect_Palette0(0, 0, 0, 0, 32, 32);
CopyBgTilemapBufferToVram(0); CopyBgTilemapBufferToVram(0);
@ -9865,7 +9865,7 @@ static bool8 sub_80D184C(void)
var = 0x15 - sPSSData->field_2236; var = 0x15 - sPSSData->field_2236;
for (i = 0; i < var; i++) for (i = 0; i < var; i++)
{ {
WriteSequenceToBgTilemapBuffer(0, GetBgAttribute(0, 10) + 0x14 + sPSSData->field_2236 + i, i, 13, 1, 7, 15, 21); WriteSequenceToBgTilemapBuffer(0, GetBgAttribute(0, BG_ATTR_BASETILE) + 0x14 + sPSSData->field_2236 + i, i, 13, 1, 7, 15, 21);
} }
sub_80D19B4(var); sub_80D19B4(var);
@ -9886,7 +9886,7 @@ static bool8 sub_80D18E4(void)
var = 0x15 - sPSSData->field_2236; var = 0x15 - sPSSData->field_2236;
for (i = 0; i < var; i++) for (i = 0; i < var; i++)
{ {
WriteSequenceToBgTilemapBuffer(0, GetBgAttribute(0, 10) + 0x14 + sPSSData->field_2236 + i, i, 13, 1, 7, 15, 21); WriteSequenceToBgTilemapBuffer(0, GetBgAttribute(0, BG_ATTR_BASETILE) + 0x14 + sPSSData->field_2236 + i, i, 13, 1, 7, 15, 21);
} }
if (var >= 0) if (var >= 0)
@ -10423,7 +10423,7 @@ static const sUnkVars[][4] =
static void sub_80D2644(u8 id, u8 bg, const void *arg2, u16 arg3, u16 arg4) static void sub_80D2644(u8 id, u8 bg, const void *arg2, u16 arg3, u16 arg4)
{ {
u16 attribute1, attribute2; u16 bgScreenSize, bgType;
if (id >= gUnknown_02039D88) if (id >= gUnknown_02039D88)
return; return;
@ -10434,11 +10434,11 @@ static void sub_80D2644(u8 id, u8 bg, const void *arg2, u16 arg3, u16 arg4)
gUnknown_02039D84[id].field_24 = arg3; gUnknown_02039D84[id].field_24 = arg3;
gUnknown_02039D84[id].field_26 = arg4; gUnknown_02039D84[id].field_26 = arg4;
attribute1 = GetBgAttribute(bg, 3); bgScreenSize = GetBgAttribute(bg, BG_ATTR_SCREENSIZE);
attribute2 = GetBgAttribute(bg, 9); bgType = GetBgAttribute(bg, BG_ATTR_TYPE);
gUnknown_02039D84[id].field_20 = sUnkVars[attribute2][attribute1].a; gUnknown_02039D84[id].field_20 = sUnkVars[bgType][bgScreenSize].a;
gUnknown_02039D84[id].field_22 = sUnkVars[attribute2][attribute1].b; gUnknown_02039D84[id].field_22 = sUnkVars[bgType][bgScreenSize].b;
if (attribute2 != 0) if (bgType != 0)
gUnknown_02039D84[id].field_2A = 1; gUnknown_02039D84[id].field_2A = 1;
else else
gUnknown_02039D84[id].field_2A = 2; gUnknown_02039D84[id].field_2A = 2;

View File

@ -1688,15 +1688,15 @@ static void sub_81C0B8C(u8 taskId)
if (pssData->unk40C9 == 0) if (pssData->unk40C9 == 0)
{ {
data[1] = 1; data[1] = 1;
SetBgAttribute(1, 7, 1); SetBgAttribute(1, BG_ATTR_PRIORITY, 1);
SetBgAttribute(2, 7, 2); SetBgAttribute(2, BG_ATTR_PRIORITY, 2);
schedule_bg_copy_tilemap_to_vram(1); schedule_bg_copy_tilemap_to_vram(1);
} }
else else
{ {
data[1] = 2; data[1] = 2;
SetBgAttribute(2, 7, 1); SetBgAttribute(2, BG_ATTR_PRIORITY, 1);
SetBgAttribute(1, 7, 2); SetBgAttribute(1, BG_ATTR_PRIORITY, 2);
schedule_bg_copy_tilemap_to_vram(2); schedule_bg_copy_tilemap_to_vram(2);
} }
ChangeBgX(data[1], 0, 0); ChangeBgX(data[1], 0, 0);
@ -1745,14 +1745,14 @@ static void sub_81C0D44(u8 taskId)
s16 *data = gTasks[taskId].data; s16 *data = gTasks[taskId].data;
if (pssData->unk40C9 == 0) if (pssData->unk40C9 == 0)
{ {
SetBgAttribute(1, 7, 1); SetBgAttribute(1, BG_ATTR_PRIORITY, 1);
SetBgAttribute(2, 7, 2); SetBgAttribute(2, BG_ATTR_PRIORITY, 2);
schedule_bg_copy_tilemap_to_vram(2); schedule_bg_copy_tilemap_to_vram(2);
} }
else else
{ {
SetBgAttribute(2, 7, 1); SetBgAttribute(2, BG_ATTR_PRIORITY, 1);
SetBgAttribute(1, 7, 2); SetBgAttribute(1, BG_ATTR_PRIORITY, 2);
schedule_bg_copy_tilemap_to_vram(1); schedule_bg_copy_tilemap_to_vram(1);
} }
if (pssData->currPageIndex > 1) if (pssData->currPageIndex > 1)

View File

@ -427,82 +427,82 @@ bool8 sub_8122DB0(void)
{ {
switch (gRegionMap->initStep) switch (gRegionMap->initStep)
{ {
case 0: case 0:
if (gRegionMap->bgManaged) if (gRegionMap->bgManaged)
{ {
decompress_and_copy_tile_data_to_vram(gRegionMap->bgNum, sRegionMapBkgnd_GfxLZ, 0, 0, 0); decompress_and_copy_tile_data_to_vram(gRegionMap->bgNum, sRegionMapBkgnd_GfxLZ, 0, 0, 0);
} }
else else
{ {
LZ77UnCompVram(sRegionMapBkgnd_GfxLZ, (u16 *)BG_CHAR_ADDR(2)); LZ77UnCompVram(sRegionMapBkgnd_GfxLZ, (u16 *)BG_CHAR_ADDR(2));
} }
break; break;
case 1: case 1:
if (gRegionMap->bgManaged) if (gRegionMap->bgManaged)
{ {
if (!free_temp_tile_data_buffers_if_possible()) if (!free_temp_tile_data_buffers_if_possible())
{ {
decompress_and_copy_tile_data_to_vram(gRegionMap->bgNum, sRegionMapBkgnd_TilemapLZ, 0, 0, 1); decompress_and_copy_tile_data_to_vram(gRegionMap->bgNum, sRegionMapBkgnd_TilemapLZ, 0, 0, 1);
} }
} }
else else
{ {
LZ77UnCompVram(sRegionMapBkgnd_TilemapLZ, (u16 *)BG_SCREEN_ADDR(28)); LZ77UnCompVram(sRegionMapBkgnd_TilemapLZ, (u16 *)BG_SCREEN_ADDR(28));
} }
break; break;
case 2: case 2:
if (!free_temp_tile_data_buffers_if_possible()) if (!free_temp_tile_data_buffers_if_possible())
{ {
LoadPalette(sRegionMapBkgnd_Pal, 0x70, 0x60); LoadPalette(sRegionMapBkgnd_Pal, 0x70, 0x60);
} }
break; break;
case 3: case 3:
LZ77UnCompWram(sRegionMapCursorSmallGfxLZ, gRegionMap->cursorSmallImage); LZ77UnCompWram(sRegionMapCursorSmallGfxLZ, gRegionMap->cursorSmallImage);
break; break;
case 4: case 4:
LZ77UnCompWram(sRegionMapCursorLargeGfxLZ, gRegionMap->cursorLargeImage); LZ77UnCompWram(sRegionMapCursorLargeGfxLZ, gRegionMap->cursorLargeImage);
break; break;
case 5: case 5:
RegionMap_InitializeStateBasedOnPlayerLocation(); RegionMap_InitializeStateBasedOnPlayerLocation();
gRegionMap->playerIconSpritePosX = gRegionMap->cursorPosX; gRegionMap->playerIconSpritePosX = gRegionMap->cursorPosX;
gRegionMap->playerIconSpritePosY = gRegionMap->cursorPosY; gRegionMap->playerIconSpritePosY = gRegionMap->cursorPosY;
gRegionMap->mapSecId = CorrectSpecialMapSecId_Internal(gRegionMap->mapSecId); gRegionMap->mapSecId = CorrectSpecialMapSecId_Internal(gRegionMap->mapSecId);
gRegionMap->iconDrawType = get_flagnr_blue_points(gRegionMap->mapSecId); gRegionMap->iconDrawType = get_flagnr_blue_points(gRegionMap->mapSecId);
GetMapName(gRegionMap->mapSecName, gRegionMap->mapSecId, 16); GetMapName(gRegionMap->mapSecName, gRegionMap->mapSecId, 16);
break; break;
case 6: case 6:
if (gRegionMap->zoomed == FALSE) if (gRegionMap->zoomed == FALSE)
{ {
CalcZoomScrollParams(0, 0, 0, 0, 0x100, 0x100, 0); CalcZoomScrollParams(0, 0, 0, 0, 0x100, 0x100, 0);
} }
else else
{ {
gRegionMap->scrollX = gRegionMap->cursorPosX * 8 - 0x34; gRegionMap->scrollX = gRegionMap->cursorPosX * 8 - 0x34;
gRegionMap->scrollY = gRegionMap->cursorPosY * 8 - 0x44; gRegionMap->scrollY = gRegionMap->cursorPosY * 8 - 0x44;
gRegionMap->zoomedCursorPosX = gRegionMap->cursorPosX; gRegionMap->zoomedCursorPosX = gRegionMap->cursorPosX;
gRegionMap->zoomedCursorPosY = gRegionMap->cursorPosY; gRegionMap->zoomedCursorPosY = gRegionMap->cursorPosY;
CalcZoomScrollParams(gRegionMap->scrollX, gRegionMap->scrollY, 0x38, 0x48, 0x80, 0x80, 0); CalcZoomScrollParams(gRegionMap->scrollX, gRegionMap->scrollY, 0x38, 0x48, 0x80, 0x80, 0);
} }
break; break;
case 7: case 7:
RegionMap_GetPositionOfCursorWithinMapSection(); RegionMap_GetPositionOfCursorWithinMapSection();
UpdateRegionMapVideoRegs(); UpdateRegionMapVideoRegs();
gRegionMap->cursorSprite = NULL; gRegionMap->cursorSprite = NULL;
gRegionMap->playerIconSprite = NULL; gRegionMap->playerIconSprite = NULL;
gRegionMap->cursorMovementFrameCounter = 0; gRegionMap->cursorMovementFrameCounter = 0;
gRegionMap->blinkPlayerIcon = FALSE; gRegionMap->blinkPlayerIcon = FALSE;
if (gRegionMap->bgManaged) if (gRegionMap->bgManaged)
{ {
SetBgAttribute(gRegionMap->bgNum, BG_CTRL_ATTR_MAPBASEINDEX, 2); SetBgAttribute(gRegionMap->bgNum, BG_ATTR_SCREENSIZE, 2);
SetBgAttribute(gRegionMap->bgNum, BG_CTRL_ATTR_VISIBLE, gRegionMap->charBaseIdx); SetBgAttribute(gRegionMap->bgNum, BG_ATTR_CHARBASEINDEX, gRegionMap->charBaseIdx);
SetBgAttribute(gRegionMap->bgNum, BG_CTRL_ATTR_CHARBASEINDEX, gRegionMap->mapBaseIdx); SetBgAttribute(gRegionMap->bgNum, BG_ATTR_MAPBASEINDEX, gRegionMap->mapBaseIdx);
SetBgAttribute(gRegionMap->bgNum, BG_CTRL_ATTR_PRIORITY, 1); SetBgAttribute(gRegionMap->bgNum, BG_ATTR_WRAPAROUND, 1);
SetBgAttribute(gRegionMap->bgNum, BG_CTRL_ATTR_SCREENSIZE, 1); SetBgAttribute(gRegionMap->bgNum, BG_ATTR_PALETTEMODE, 1);
} }
gRegionMap->initStep++; gRegionMap->initStep++;
return FALSE; return FALSE;
default: default:
return FALSE; return FALSE;
} }
gRegionMap->initStep++; gRegionMap->initStep++;
return TRUE; return TRUE;

View File

@ -50,8 +50,8 @@ static void CB2_ReshowBattleScreenAfterMenu(void)
case 0: case 0:
ScanlineEffect_Clear(); ScanlineEffect_Clear();
BattleInitBgsAndWindows(); BattleInitBgsAndWindows();
SetBgAttribute(1, BG_CTRL_ATTR_VISIBLE, 0); SetBgAttribute(1, BG_ATTR_CHARBASEINDEX, 0);
SetBgAttribute(2, BG_CTRL_ATTR_VISIBLE, 0); SetBgAttribute(2, BG_ATTR_CHARBASEINDEX, 0);
ShowBg(0); ShowBg(0);
ShowBg(1); ShowBg(1);
ShowBg(2); ShowBg(2);

View File

@ -22,21 +22,21 @@ void sub_81C4D70(const struct UnkStruct_1C4D70 *template)
if (unk == 0) if (unk == 0)
{ {
SetBgAttribute(template->bg, BG_CTRL_ATTR_WRAPAROUND, 0); SetBgAttribute(template->bg, BG_ATTR_METRIC, 0);
decompress_and_copy_tile_data_to_vram(template->bg, gUnknown_0861D1A0, 0, template->unk2, unk); decompress_and_copy_tile_data_to_vram(template->bg, gUnknown_0861D1A0, 0, template->unk2, unk);
sub_8199D3C(decompress_and_copy_tile_data_to_vram(template->bg, gUnknown_0861DEF4, 0, 0, 1), template->unk2, 32, 32, unk); sub_8199D3C(decompress_and_copy_tile_data_to_vram(template->bg, gUnknown_0861DEF4, 0, 0, 1), template->unk2, 32, 32, unk);
} }
else else
{ {
SetBgAttribute(template->bg, BG_CTRL_ATTR_WRAPAROUND, 2); SetBgAttribute(template->bg, BG_ATTR_METRIC, 2);
SetBgAttribute(template->bg, 9, 1); SetBgAttribute(template->bg, BG_ATTR_TYPE, 1);
decompress_and_copy_tile_data_to_vram(template->bg, gUnknown_0861E208, 0, template->unk2, 0); decompress_and_copy_tile_data_to_vram(template->bg, gUnknown_0861E208, 0, template->unk2, 0);
sub_8199D3C(decompress_and_copy_tile_data_to_vram(template->bg, gUnknown_0861EF64, 0, 0, 1), template->unk2, 64, 64, 1); sub_8199D3C(decompress_and_copy_tile_data_to_vram(template->bg, gUnknown_0861EF64, 0, 0, 1), template->unk2, 64, 64, 1);
} }
ChangeBgX(template->bg, 0, 0); ChangeBgX(template->bg, 0, 0);
ChangeBgY(template->bg, 0, 0); ChangeBgY(template->bg, 0, 0);
SetBgAttribute(template->bg, BG_CTRL_ATTR_SCREENSIZE, 1); SetBgAttribute(template->bg, BG_ATTR_PALETTEMODE, 1);
CpuCopy32(gUnknown_0861D140, &gPlttBufferUnfaded[0x70], 0x60); CpuCopy32(gUnknown_0861D140, &gPlttBufferUnfaded[0x70], 0x60);
*gUnknown_0203CF28 = template->bg; *gUnknown_0203CF28 = template->bg;
} }

View File

@ -63,7 +63,7 @@ bool16 InitWindows(const struct WindowTemplate *templates)
if (gUnknown_03002F70[bgLayer] == NULL) if (gUnknown_03002F70[bgLayer] == NULL)
{ {
attrib = GetBgAttribute(bgLayer, 0x8); attrib = GetBgAttribute(bgLayer, BG_ATTR_METRIC);
if (attrib != 0xFFFF) if (attrib != 0xFFFF)
{ {
@ -141,7 +141,7 @@ u16 AddWindow(const struct WindowTemplate *template)
if (gUnknown_03002F70[bgLayer] == NULL) if (gUnknown_03002F70[bgLayer] == NULL)
{ {
attrib = GetBgAttribute(bgLayer, 0x8); attrib = GetBgAttribute(bgLayer, BG_ATTR_METRIC);
if (attrib != 0xFFFF) if (attrib != 0xFFFF)
{ {
@ -328,7 +328,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,
@ -340,7 +340,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)
@ -376,7 +376,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)
@ -617,7 +617,7 @@ u16 AddWindow8Bit(const struct WindowTemplate *template)
bgLayer = template->bg; bgLayer = template->bg;
if (gUnknown_03002F70[bgLayer] == 0) if (gUnknown_03002F70[bgLayer] == 0)
{ {
u16 attribute = GetBgAttribute(bgLayer, 8); u16 attribute = GetBgAttribute(bgLayer, BG_ATTR_METRIC);
if (attribute != 0xFFFF) if (attribute != 0xFFFF)
{ {
s32 i; s32 i;