Merge pull request #482 from DizzyEggg/bg

Fix raw SetGpuReg and SetBgAttribute args
This commit is contained in:
Marcus Huderle 2018-12-26 10:07:56 -06:00 committed by GitHub
commit 7480a41cfe
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
32 changed files with 306 additions and 300 deletions

View File

@ -13,14 +13,16 @@ struct BGCntrlBitfield // for the I/O registers
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,
BG_ATTR_CHARBASEINDEX = 1,
BG_ATTR_MAPBASEINDEX,
BG_ATTR_SCREENSIZE,
BG_ATTR_PALETTEMODE,
BG_ATTR_MOSAIC,
BG_ATTR_WRAPAROUND,
BG_ATTR_PRIORITY,
BG_ATTR_METRIC,
BG_ATTR_TYPE,
BG_ATTR_BASETILE,
};
struct BgTemplate
@ -38,8 +40,6 @@ void ResetBgs(void);
u8 GetBgMode(void);
void ResetBgControlStructs(void);
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);
void SetTextModeAndHideBgs(void);
bool8 IsInvalidBg(u8 bg);

View File

@ -2283,7 +2283,7 @@ static void ScriptCmd_setalpha(void)
sBattleAnimScriptPtr++;
half1 = *(sBattleAnimScriptPtr++);
half2 = *(sBattleAnimScriptPtr++) << 8;
SetGpuReg(REG_OFFSET_BLDCNT, 0x3F40);
SetGpuReg(REG_OFFSET_BLDCNT, BLDCNT_EFFECT_BLEND | BLDCNT_TGT2_ALL);
SetGpuReg(REG_OFFSET_BLDALPHA, half1 | half2);
}

View File

@ -3134,7 +3134,7 @@ void sub_8105EB0(u8 taskId)
SetGpuReg(REG_OFFSET_WIN0V, gBattle_WIN0V);
SetGpuReg(REG_OFFSET_WININ, 0x3F1F);
SetGpuReg(REG_OFFSET_WINOUT, 0x3F3F);
SetGpuReg(REG_OFFSET_BLDCNT, 0xC8);
SetGpuReg(REG_OFFSET_BLDCNT, BLDCNT_TGT1_BG3 | BLDCNT_EFFECT_DARKEN);
SetGpuReg(REG_OFFSET_BLDY, 0x10);
gTasks[taskId].data[0] = win0v;
gTasks[taskId].data[1] = win0h;

View File

@ -3220,7 +3220,7 @@ void sub_815CED8(u8 taskId)
gSprites[spriteId].oam.objMode = ST_OAM_OBJ_BLEND;
FillPalette(RGB(31, 31, 31), (gSprites[spriteId].oam.paletteNum << 4) + 0x100, 32);
gSprites[spriteId].oam.priority = priority;
SetGpuReg(REG_OFFSET_BLDCNT, 0x3F40);
SetGpuReg(REG_OFFSET_BLDCNT, BLDCNT_EFFECT_BLEND | BLDCNT_TGT2_ALL);
SetGpuReg(REG_OFFSET_BLDALPHA, BLDALPHA_BLEND(gTasks[taskId].data[1], 16 - gTasks[taskId].data[1]));
gTasks[taskId].data[0] = spriteId;

View File

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

View File

@ -1753,7 +1753,7 @@ static void sub_8073E08(u8 taskId)
if (--gTasks[taskId].tData15 < 0)
return;
SetGpuReg(REG_OFFSET_BLDALPHA, (gTasks[taskId].data[15]) | ((16 - gTasks[taskId].data[15]) << 8));
SetGpuReg(REG_OFFSET_BLDALPHA, BLDALPHA_BLEND(gTasks[taskId].data[15], 16 - gTasks[taskId].data[15]));
}
if (gTasks[taskId].tData15 == 0)
gTasks[taskId].func = sub_8073E64;
@ -1806,7 +1806,7 @@ static void sub_8073F98(u8 taskId)
if (--gTasks[taskId].tData15 >= 0)
{
SetGpuReg(REG_OFFSET_BLDALPHA, (gTasks[taskId].tData15) | ((16 - gTasks[taskId].tData15) << 8));
SetGpuReg(REG_OFFSET_BLDALPHA, BLDALPHA_BLEND(gTasks[taskId].data[15], 16 - gTasks[taskId].data[15]));
}
else if (gTasks[taskId].tData15 == -1)
{

View File

@ -221,8 +221,8 @@ static void BattleIntroSlide1(u8 taskId)
gScanlineEffect.state = 3;
gTasks[taskId].data[0]++;
CpuFill32(0, (void *)BG_SCREEN_ADDR(28), BG_SCREEN_SIZE);
SetBgAttribute(1, BG_CTRL_ATTR_VISIBLE, 0);
SetBgAttribute(2, BG_CTRL_ATTR_VISIBLE, 0);
SetBgAttribute(1, BG_ATTR_CHARBASEINDEX, 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_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;
gTasks[taskId].data[0]++;
CpuFill32(0, (void *)BG_SCREEN_ADDR(28), BG_SCREEN_SIZE);
SetBgAttribute(1, BG_CTRL_ATTR_VISIBLE, 0);
SetBgAttribute(2, BG_CTRL_ATTR_VISIBLE, 0);
SetBgAttribute(1, BG_ATTR_CHARBASEINDEX, 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_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;
gTasks[taskId].data[0]++;
CpuFill32(0, (void *)BG_SCREEN_ADDR(28), BG_SCREEN_SIZE);
SetBgAttribute(1, BG_CTRL_ATTR_VISIBLE, 0);
SetBgAttribute(2, BG_CTRL_ATTR_VISIBLE, 0);
SetBgAttribute(1, BG_ATTR_CHARBASEINDEX, 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_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;
gTasks[taskId].data[0]++;
SetBgAttribute(1, BG_CTRL_ATTR_VISIBLE, 0);
SetBgAttribute(2, BG_CTRL_ATTR_VISIBLE, 0);
SetBgAttribute(1, BG_ATTR_CHARBASEINDEX, 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_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);
SetGpuReg(REG_OFFSET_DISPCNT, GetGpuReg(REG_OFFSET_DISPCNT) & ~DISPCNT_WIN1_ON);
SetBgAttribute(1, BG_CTRL_ATTR_VISIBLE, 0);
SetBgAttribute(2, BG_CTRL_ATTR_VISIBLE, 0);
SetBgAttribute(1, BG_ATTR_CHARBASEINDEX, 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_BG2CNT, BGCNT_PRIORITY(0) | BGCNT_CHARBASE(0) | BGCNT_16COLOR | BGCNT_SCREENBASE(30) | BGCNT_TXT512x256);
gScanlineEffect.state = 3;

View File

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

View File

@ -67,7 +67,7 @@ static const u16 sUnknown_08618138[] = {
0x7fff, 0x7fff, 0x318c, 0x675a,
0x043c, 0x3aff, 0x0664, 0x4bd2,
0x6546, 0x7b14, 0x7fff, 0x318c,
0x675a, 0x0000, 0x0000, 0x0000
0x675a, 0, 0, 0
};
static const u8 sUnknown_08618158[] = {10, 11, 12};
@ -124,7 +124,7 @@ void CB2_InitBerryFixProgram(void)
ResetSpriteData();
ResetTasks();
ScanlineEffect_Stop();
SetGpuReg(REG_OFFSET_DISPCNT, 0x0000);
SetGpuReg(REG_OFFSET_DISPCNT, 0);
berry_fix_mb_manager = AllocZeroed(0x50);
berry_fix_mb_manager->state = 0;
berry_fix_mb_manager->unk1 = 6;
@ -203,13 +203,13 @@ static void berry_fix_gpu_set(void)
{
s32 width, left;
SetGpuReg(REG_OFFSET_BG0CNT, 0x0000);
SetGpuReg(REG_OFFSET_BG1CNT, 0x0000);
SetGpuReg(REG_OFFSET_BG0HOFS, 0x0000);
SetGpuReg(REG_OFFSET_BG0VOFS, 0x0000);
SetGpuReg(REG_OFFSET_BG1HOFS, 0x0000);
SetGpuReg(REG_OFFSET_BG1VOFS, 0x0000);
SetGpuReg(REG_OFFSET_BLDCNT, 0x0000);
SetGpuReg(REG_OFFSET_BG0CNT, 0);
SetGpuReg(REG_OFFSET_BG1CNT, 0);
SetGpuReg(REG_OFFSET_BG0HOFS, 0);
SetGpuReg(REG_OFFSET_BG0VOFS, 0);
SetGpuReg(REG_OFFSET_BG1HOFS, 0);
SetGpuReg(REG_OFFSET_BG1VOFS, 0);
SetGpuReg(REG_OFFSET_BLDCNT, 0);
DmaFill32(3, 0, VRAM, VRAM_SIZE);
DmaFill32(3, 0, OAM, OAM_SIZE);

166
src/bg.c
View File

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

View File

@ -285,7 +285,7 @@ void sub_80D779C(void)
ResetBgsAndClearDma3BusyFlags(0);
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++)
{
SetBgTilemapBuffer(i, gContestResources->field_24[i]);

View File

@ -2219,8 +2219,8 @@ static void sub_8177050(struct Sprite *sprite)
}
else
{
SetGpuReg(REG_OFFSET_BLDCNT, 0xF40);
SetGpuReg(REG_OFFSET_BLDALPHA, 0x10);
SetGpuReg(REG_OFFSET_BLDCNT, BLDCNT_EFFECT_BLEND | BLDCNT_TGT2_BG0 | BLDCNT_TGT2_BG1 | BLDCNT_TGT2_BG2 | BLDCNT_TGT2_BG3);
SetGpuReg(REG_OFFSET_BLDALPHA, BLDALPHA_BLEND(16, 0));
sprite->oam.objMode = 1;
sprite->data[3] = 16;
sprite->data[0] += 1;

View File

@ -502,7 +502,7 @@ static void CB2_EggHatch_0(void)
ChangeBgX(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(0, Alloc(0x2000));

View File

@ -1479,20 +1479,20 @@ static void InitMovingBackgroundTask(bool8 isLink)
if (!isLink)
{
SetGpuReg(REG_OFFSET_BLDCNT, 0x442);
SetGpuReg(REG_OFFSET_BLDALPHA, 0x808);
SetGpuReg(REG_OFFSET_BLDCNT, BLDCNT_TGT1_BG1 | BLDCNT_EFFECT_BLEND | BLDCNT_TGT2_BG2);
SetGpuReg(REG_OFFSET_BLDALPHA, BLDALPHA_BLEND(8, 8));
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(outerBgId, BG_CTRL_ATTR_MOSAIC, 2);
SetBgAttribute(innerBgId, BG_ATTR_PRIORITY, 2);
SetBgAttribute(outerBgId, BG_ATTR_PRIORITY, 2);
ShowBg(1);
ShowBg(2);
}
else
{
SetGpuReg(REG_OFFSET_BLDCNT, 0x842);
SetGpuReg(REG_OFFSET_BLDALPHA, 0x808);
SetGpuReg(REG_OFFSET_BLDCNT, BLDCNT_TGT1_BG1 | BLDCNT_EFFECT_BLEND | BLDCNT_TGT2_BG3);
SetGpuReg(REG_OFFSET_BLDALPHA, BLDALPHA_BLEND(8, 8));
SetGpuReg(REG_OFFSET_DISPCNT, DISPCNT_OBJ_ON | DISPCNT_BG3_ON | DISPCNT_BG1_ON | DISPCNT_BG0_ON | DISPCNT_OBJ_1D_MAP);
}
@ -1529,8 +1529,8 @@ static void sub_8140174(void)
gBattle_BG1_X = 0;
gBattle_BG1_Y = 0;
gBattle_BG2_X = 0;
SetBgAttribute(1, BG_CTRL_ATTR_MOSAIC, sub_80391E0(1, 5));
SetBgAttribute(2, BG_CTRL_ATTR_MOSAIC, sub_80391E0(2, 5));
SetBgAttribute(1, BG_ATTR_PRIORITY, sub_80391E0(1, 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);
Free(sEvoMovingBgPtr);
}

View File

@ -376,7 +376,7 @@ static void sub_80F9C90(u8 taskId)
task->data[7] = GetGpuReg(REG_OFFSET_BLDCNT);
task->data[8] = GetGpuReg(REG_OFFSET_BLDY);
SetGpuReg(REG_OFFSET_BLDCNT, 0xBF);
SetGpuReg(REG_OFFSET_BLDCNT, BLDCNT_TGT1_ALL | BLDCNT_EFFECT_LIGHTEN);
SetGpuReg(REG_OFFSET_BLDY, 0x10);
break;
@ -452,7 +452,7 @@ static void sub_80F9DFC(u8 taskId)
{
task->data[5] = 0x50;
task->data[6] = 0x51;
SetGpuReg(REG_OFFSET_BLDCNT, 0xBF);
SetGpuReg(REG_OFFSET_BLDCNT, BLDCNT_TGT1_ALL | BLDCNT_EFFECT_LIGHTEN);
SetGpuReg(REG_OFFSET_BLDY, 0x10);
}
SetGpuReg(REG_OFFSET_WIN0V, WIN_RANGE(task->data[5], task->data[6]));

View File

@ -355,8 +355,8 @@ static bool8 InitHallOfFameScreen(void)
gMain.state++;
break;
case 2:
SetGpuReg(REG_OFFSET_BLDCNT, 0x3F42);
SetGpuReg(REG_OFFSET_BLDALPHA, 0x710);
SetGpuReg(REG_OFFSET_BLDCNT, BLDCNT_TGT1_BG1 | BLDCNT_EFFECT_BLEND | BLDCNT_TGT2_ALL);
SetGpuReg(REG_OFFSET_BLDALPHA, BLDALPHA_BLEND(16, 7));
SetGpuReg(REG_OFFSET_BLDY, 0);
sub_8174FAC();
sHofGfxPtr->state = 0;
@ -817,8 +817,8 @@ void CB2_DoHallOfFamePC(void)
{
u8 taskId, i;
SetGpuReg(REG_OFFSET_BLDCNT, 0x3F42);
SetGpuReg(REG_OFFSET_BLDALPHA, 0x710);
SetGpuReg(REG_OFFSET_BLDCNT, BLDCNT_TGT1_BG1 | BLDCNT_EFFECT_BLEND | BLDCNT_TGT2_ALL);
SetGpuReg(REG_OFFSET_BLDALPHA, BLDALPHA_BLEND(16, 7));
SetGpuReg(REG_OFFSET_BLDY, 0);
taskId = CreateTask(Task_HofPC_CopySaveData, 0);

View File

@ -170,29 +170,29 @@ static const u16 sUnknown_0859F2B0[][2] = {
static const struct MailGraphics sUnknown_0859F2B8[] = {
{
gMailPalette_Orange, gMailTiles_Orange, gMailTilemap_Orange, 0x02c0, 0x0000, 0x294a, 0x6739
gMailPalette_Orange, gMailTiles_Orange, gMailTilemap_Orange, 0x02c0, 0, 0x294a, 0x6739
}, {
gMailPalette_Harbor, gMailTiles_Harbor, gMailTilemap_Harbor, 0x02e0, 0x0000, 0x7fff, 0x4631
gMailPalette_Harbor, gMailTiles_Harbor, gMailTilemap_Harbor, 0x02e0, 0, 0x7fff, 0x4631
}, {
gMailPalette_Glitter, gMailTiles_Glitter, gMailTilemap_Glitter, 0x0400, 0x0000, 0x294a, 0x6739
gMailPalette_Glitter, gMailTiles_Glitter, gMailTilemap_Glitter, 0x0400, 0, 0x294a, 0x6739
}, {
gMailPalette_Mech, gMailTiles_Mech, gMailTilemap_Mech, 0x01e0, 0x0000, 0x7fff, 0x4631
gMailPalette_Mech, gMailTiles_Mech, gMailTilemap_Mech, 0x01e0, 0, 0x7fff, 0x4631
}, {
gMailPalette_Wood, gMailTiles_Wood, gMailTilemap_Wood, 0x02e0, 0x0000, 0x7fff, 0x4631
gMailPalette_Wood, gMailTiles_Wood, gMailTilemap_Wood, 0x02e0, 0, 0x7fff, 0x4631
}, {
gMailPalette_Wave, gMailTiles_Wave, gMailTilemap_Wave, 0x0300, 0x0000, 0x294a, 0x6739
gMailPalette_Wave, gMailTiles_Wave, gMailTilemap_Wave, 0x0300, 0, 0x294a, 0x6739
}, {
gMailPalette_Bead, gMailTiles_Bead, gMailTilemap_Bead, 0x0140, 0x0000, 0x7fff, 0x4631
gMailPalette_Bead, gMailTiles_Bead, gMailTilemap_Bead, 0x0140, 0, 0x7fff, 0x4631
}, {
gMailPalette_Shadow, gMailTiles_Shadow, gMailTilemap_Shadow, 0x0300, 0x0000, 0x7fff, 0x4631
gMailPalette_Shadow, gMailTiles_Shadow, gMailTilemap_Shadow, 0x0300, 0, 0x7fff, 0x4631
}, {
gMailPalette_Tropic, gMailTiles_Tropic, gMailTilemap_Tropic, 0x0220, 0x0000, 0x294a, 0x6739
gMailPalette_Tropic, gMailTiles_Tropic, gMailTilemap_Tropic, 0x0220, 0, 0x294a, 0x6739
}, {
gMailPalette_Dream, gMailTiles_Dream, gMailTilemap_Dream, 0x0340, 0x0000, 0x294a, 0x6739
gMailPalette_Dream, gMailTiles_Dream, gMailTilemap_Dream, 0x0340, 0, 0x294a, 0x6739
}, {
gMailPalette_Fab, gMailTiles_Fab, gMailTilemap_Fab, 0x02a0, 0x0000, 0x294a, 0x6739
gMailPalette_Fab, gMailTiles_Fab, gMailTilemap_Fab, 0x02a0, 0, 0x294a, 0x6739
}, {
gMailPalette_Retro, gMailTiles_Retro, gMailTilemap_Retro, 0x0520, 0x0000, 0x294a, 0x6739
gMailPalette_Retro, gMailTiles_Retro, gMailTilemap_Retro, 0x0520, 0, 0x294a, 0x6739
}
};
@ -306,7 +306,7 @@ static bool8 MailReadBuildGraphics(void)
case 0:
SetVBlankCallback(NULL);
ScanlineEffect_Stop();
SetGpuReg(REG_OFFSET_DISPCNT, 0x0000);
SetGpuReg(REG_OFFSET_DISPCNT, 0);
break;
case 1:
CpuFill16(0, (void *)OAM, OAM_SIZE);
@ -323,16 +323,16 @@ static bool8 MailReadBuildGraphics(void)
case 5:
FreeAllSpritePalettes();
reset_temp_tile_data_buffers();
SetGpuReg(REG_OFFSET_BG0HOFS, 0x0000);
SetGpuReg(REG_OFFSET_BG0VOFS, 0x0000);
SetGpuReg(REG_OFFSET_BG1HOFS, 0x0000);
SetGpuReg(REG_OFFSET_BG1VOFS, 0x0000);
SetGpuReg(REG_OFFSET_BG2VOFS, 0x0000);
SetGpuReg(REG_OFFSET_BG2HOFS, 0x0000);
SetGpuReg(REG_OFFSET_BG3HOFS, 0x0000);
SetGpuReg(REG_OFFSET_BG3VOFS, 0x0000);
SetGpuReg(REG_OFFSET_BLDCNT, 0x0000);
SetGpuReg(REG_OFFSET_BLDALPHA, 0x0000);
SetGpuReg(REG_OFFSET_BG0HOFS, 0);
SetGpuReg(REG_OFFSET_BG0VOFS, 0);
SetGpuReg(REG_OFFSET_BG1HOFS, 0);
SetGpuReg(REG_OFFSET_BG1VOFS, 0);
SetGpuReg(REG_OFFSET_BG2VOFS, 0);
SetGpuReg(REG_OFFSET_BG2HOFS, 0);
SetGpuReg(REG_OFFSET_BG3HOFS, 0);
SetGpuReg(REG_OFFSET_BG3VOFS, 0);
SetGpuReg(REG_OFFSET_BLDCNT, 0);
SetGpuReg(REG_OFFSET_BLDALPHA, 0);
break;
case 6:
ResetBgsAndClearDma3BusyFlags(0);

View File

@ -1934,8 +1934,8 @@ void sub_8199D98(void)
void sub_8199DF0(u32 bg, u8 a1, int a2, int a3)
{
int temp = (!GetBgAttribute(bg, 4)) ? 0x20 : 0x40;
void *addr = (void *)((GetBgAttribute(bg, 1) * 0x4000) + (GetBgAttribute(bg, 10) + a2) * temp);
int temp = (!GetBgAttribute(bg, BG_ATTR_PALETTEMODE)) ? 0x20 : 0x40;
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);
}

View File

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

View File

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

View File

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

View File

@ -8826,7 +8826,7 @@ static bool8 sub_80D024C(void)
FillBgTilemapBufferRect_Palette0(0, 0, 0, 0, 0x20, 0x20);
FillWindowPixelBuffer8Bit(sPSSData->field_2200, 0);
sub_80D07B0(sMoveMonsPtr->fromRow, sMoveMonsPtr->fromColumn);
SetBgAttribute(0, 4, 1);
SetBgAttribute(0, BG_ATTR_PALETTEMODE, 1);
PutWindowTilemap(sPSSData->field_2200);
CopyWindowToVram8Bit(sPSSData->field_2200, 3);
BlendPalettes(0x3F00, 8, RGB_WHITE);
@ -9246,7 +9246,7 @@ static void sub_80D0B5C(void)
{
ChangeBgX(0, 0, 0);
ChangeBgY(0, 0, 0);
SetBgAttribute(0, 4, 0);
SetBgAttribute(0, BG_ATTR_PALETTEMODE, 0);
ClearGpuRegBits(REG_OFFSET_BG0CNT, BGCNT_256COLOR);
FillBgTilemapBufferRect_Palette0(0, 0, 0, 0, 32, 32);
CopyBgTilemapBufferToVram(0);
@ -9865,7 +9865,7 @@ static bool8 sub_80D184C(void)
var = 0x15 - sPSSData->field_2236;
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);
@ -9886,7 +9886,7 @@ static bool8 sub_80D18E4(void)
var = 0x15 - sPSSData->field_2236;
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)
@ -10423,7 +10423,7 @@ static const sUnkVars[][4] =
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)
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_26 = arg4;
attribute1 = GetBgAttribute(bg, 3);
attribute2 = GetBgAttribute(bg, 9);
gUnknown_02039D84[id].field_20 = sUnkVars[attribute2][attribute1].a;
gUnknown_02039D84[id].field_22 = sUnkVars[attribute2][attribute1].b;
if (attribute2 != 0)
bgScreenSize = GetBgAttribute(bg, BG_ATTR_SCREENSIZE);
bgType = GetBgAttribute(bg, BG_ATTR_TYPE);
gUnknown_02039D84[id].field_20 = sUnkVars[bgType][bgScreenSize].a;
gUnknown_02039D84[id].field_22 = sUnkVars[bgType][bgScreenSize].b;
if (bgType != 0)
gUnknown_02039D84[id].field_2A = 1;
else
gUnknown_02039D84[id].field_2A = 2;

View File

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

View File

@ -1708,7 +1708,7 @@ static void sub_81D752C(u8 taskId)
if (data[0] != 16)
{
data[0]++;
SetGpuReg(REG_OFFSET_BLDALPHA, (data[0] << 8) | (16 - data[0]));
SetGpuReg(REG_OFFSET_BLDALPHA, BLDALPHA_BLEND(16 - data[0], data[0]));
}
}
@ -1954,7 +1954,7 @@ static void Task_RayTakesFlightAnim(u8 taskId)
sub_81D7E10();
sub_81D7E9C();
SetGpuReg(REG_OFFSET_BLDCNT, BLDCNT_TGT1_OBJ | BLDCNT_TGT2_BG1 | BLDCNT_EFFECT_BLEND);
SetGpuReg(REG_OFFSET_BLDALPHA, 0x808);
SetGpuReg(REG_OFFSET_BLDALPHA, BLDALPHA_BLEND(8, 8));
BlendPalettes(-1, 0x10, 0);
SetVBlankCallback(VBlankCB_RayquazaScene);
CreateTask(sub_81D81A4, 0);
@ -2153,7 +2153,7 @@ static void Task_RayDescendsAnim(u8 taskId)
sub_81D82B0();
sub_81D8358();
SetGpuRegBits(REG_OFFSET_BLDCNT, BLDCNT_TGT1_BG0 | BLDCNT_TGT2_BG1 | BLDCNT_TGT2_BG2 | BLDCNT_TGT2_BG3 | BLDCNT_TGT2_OBJ | BLDCNT_EFFECT_BLEND);
SetGpuReg(REG_OFFSET_BLDALPHA, 0x1000);
SetGpuReg(REG_OFFSET_BLDALPHA, BLDALPHA_BLEND(0, 16));
BlendPalettes(-1, 0x10, 0);
SetVBlankCallback(VBlankCB_RayquazaScene);
sRayScene->field_2008 = 0;
@ -2509,7 +2509,7 @@ static void Task_RayChasesAwayAnim(u8 taskId)
sub_81D68C8();
ClearGpuRegBits(REG_OFFSET_DISPCNT, DISPCNT_BG2_ON);
SetGpuReg(REG_OFFSET_BLDCNT, BLDCNT_TGT1_BG0 | BLDCNT_TGT2_BG1 | BLDCNT_EFFECT_BLEND);
SetGpuReg(REG_OFFSET_BLDALPHA, 0xE09);
SetGpuReg(REG_OFFSET_BLDALPHA, BLDALPHA_BLEND(9, 14));
BlendPalettes(-1, 0x10, 0);
SetVBlankCallback(VBlankCB_RayquazaScene);
data[0] = 0;

View File

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

View File

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

View File

@ -425,7 +425,7 @@ void CB2_ChooseStarter(void)
SetGpuReg(REG_OFFSET_WINOUT, 0x1F);
SetGpuReg(REG_OFFSET_WIN0H, 0);
SetGpuReg(REG_OFFSET_WIN0V, 0);
SetGpuReg(REG_OFFSET_BLDCNT, 0xFE);
SetGpuReg(REG_OFFSET_BLDCNT, BLDCNT_TGT1_BG1 | BLDCNT_TGT1_BG2 | BLDCNT_TGT1_BG3 | BLDCNT_TGT1_OBJ | BLDCNT_TGT1_BD | BLDCNT_EFFECT_DARKEN);
SetGpuReg(REG_OFFSET_BLDALPHA, 0);
SetGpuReg(REG_OFFSET_BLDY, 7);
SetGpuReg(REG_OFFSET_DISPCNT, DISPCNT_WIN0_ON | DISPCNT_OBJ_ON | DISPCNT_OBJ_1D_MAP);

View File

@ -553,7 +553,7 @@ void CB2_InitTitleScreen(void)
SetGpuReg(REG_OFFSET_WIN1V, 0);
SetGpuReg(REG_OFFSET_WININ, 0x1F1F);
SetGpuReg(REG_OFFSET_WINOUT, 0x3F1F);
SetGpuReg(REG_OFFSET_BLDCNT, 0x84);
SetGpuReg(REG_OFFSET_BLDCNT, BLDCNT_TGT1_BG2 | BLDCNT_EFFECT_LIGHTEN);
SetGpuReg(REG_OFFSET_BLDALPHA, 0);
SetGpuReg(REG_OFFSET_BLDY, 0xC);
SetGpuReg(REG_OFFSET_BG0CNT, BGCNT_PRIORITY(3) | BGCNT_CHARBASE(2) | BGCNT_SCREENBASE(26) | BGCNT_16COLOR | BGCNT_TXT256x256);
@ -615,8 +615,8 @@ static void Task_TitleScreenPhase1(u8 taskId)
SetGpuReg(REG_OFFSET_DISPCNT, DISPCNT_MODE_1 | DISPCNT_OBJ_1D_MAP | DISPCNT_BG2_ON | DISPCNT_OBJ_ON);
SetGpuReg(REG_OFFSET_WININ, 0);
SetGpuReg(REG_OFFSET_WINOUT, 0);
SetGpuReg(REG_OFFSET_BLDCNT, 0x3F50);
SetGpuReg(REG_OFFSET_BLDALPHA, 0x10);
SetGpuReg(REG_OFFSET_BLDCNT, BLDCNT_TGT1_OBJ | BLDCNT_EFFECT_BLEND | BLDCNT_TGT2_ALL);
SetGpuReg(REG_OFFSET_BLDALPHA, BLDALPHA_BLEND(16, 0));
SetGpuReg(REG_OFFSET_BLDY, 0);
// Create left side of version banner
@ -652,8 +652,8 @@ static void Task_TitleScreenPhase2(u8 taskId)
else
{
gTasks[taskId].tSkipToNext = TRUE;
SetGpuReg(REG_OFFSET_BLDCNT, 0x2142);
SetGpuReg(REG_OFFSET_BLDALPHA, 0xF06);
SetGpuReg(REG_OFFSET_BLDCNT, BLDCNT_TGT1_BG1 | BLDCNT_EFFECT_BLEND | BLDCNT_TGT2_BG0 | BLDCNT_TGT2_BD);
SetGpuReg(REG_OFFSET_BLDALPHA, BLDALPHA_BLEND(6, 15));
SetGpuReg(REG_OFFSET_BLDY, 0);
SetGpuReg(REG_OFFSET_DISPCNT, DISPCNT_MODE_1
| DISPCNT_OBJ_1D_MAP

View File

@ -22,21 +22,21 @@ void sub_81C4D70(const struct UnkStruct_1C4D70 *template)
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);
sub_8199D3C(decompress_and_copy_tile_data_to_vram(template->bg, gUnknown_0861DEF4, 0, 0, 1), template->unk2, 32, 32, unk);
}
else
{
SetBgAttribute(template->bg, BG_CTRL_ATTR_WRAPAROUND, 2);
SetBgAttribute(template->bg, 9, 1);
SetBgAttribute(template->bg, BG_ATTR_METRIC, 2);
SetBgAttribute(template->bg, BG_ATTR_TYPE, 1);
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);
}
ChangeBgX(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);
*gUnknown_0203CF28 = template->bg;
}

View File

@ -337,8 +337,8 @@ static bool8 sub_81DAACC(struct Task *task)
else
{
sub_81DA700();
SetGpuReg(REG_OFFSET_BLDCNT, 0x3F41);
SetGpuReg(REG_OFFSET_BLDALPHA, 0x1000);
SetGpuReg(REG_OFFSET_BLDCNT, BLDCNT_TGT1_BG0 | BLDCNT_EFFECT_BLEND | BLDCNT_TGT2_ALL);
SetGpuReg(REG_OFFSET_BLDALPHA, BLDALPHA_BLEND(0, 16));
ChangeBgX(0, 0, 0);
ChangeBgY(0, 0, 0);
ChangeBgY(0, 0x500, 2);
@ -368,11 +368,11 @@ static bool8 sub_81DAB4C(struct Task *task)
}
else
{
u16 var;
u16 blnd;
task->data[2]++;
var = task->data[2];
SetGpuReg(REG_OFFSET_BLDALPHA, (var) | ((16 - var) << 8));
blnd = task->data[2];
SetGpuReg(REG_OFFSET_BLDALPHA, BLDALPHA_BLEND(blnd, 16 - blnd));
}
return FALSE;

View File

@ -585,11 +585,11 @@ static void WallClockVblankCallback(void)
static void LoadWallClockGraphics(void)
{
SetVBlankCallback(NULL);
SetGpuReg(REG_OFFSET_DISPCNT, 0x0000);
SetGpuReg(REG_OFFSET_BG3CNT, 0x0000);
SetGpuReg(REG_OFFSET_BG2CNT, 0x0000);
SetGpuReg(REG_OFFSET_BG1CNT, 0x0000);
SetGpuReg(REG_OFFSET_BG0CNT, 0x0000);
SetGpuReg(REG_OFFSET_DISPCNT, 0);
SetGpuReg(REG_OFFSET_BG3CNT, 0);
SetGpuReg(REG_OFFSET_BG2CNT, 0);
SetGpuReg(REG_OFFSET_BG1CNT, 0);
SetGpuReg(REG_OFFSET_BG0CNT, 0);
ChangeBgX(0, 0, 0);
ChangeBgY(0, 0, 0);
ChangeBgX(1, 0, 0);
@ -633,9 +633,9 @@ static void WallClockInit(void)
EnableInterrupts(INTR_FLAG_VBLANK);
SetVBlankCallback(WallClockVblankCallback);
SetMainCallback2(WallClockMainCallback);
SetGpuReg(REG_OFFSET_BLDCNT, 0x0000);
SetGpuReg(REG_OFFSET_BLDALPHA, 0x0000);
SetGpuReg(REG_OFFSET_BLDY, 0x0000);
SetGpuReg(REG_OFFSET_BLDCNT, 0);
SetGpuReg(REG_OFFSET_BLDALPHA, 0);
SetGpuReg(REG_OFFSET_BLDY, 0);
SetGpuReg(REG_OFFSET_DISPCNT, DISPCNT_OBJ_1D_MAP | DISPCNT_OBJ_ON);
ShowBg(0);
ShowBg(2);

View File

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