diff --git a/include/bg.h b/include/bg.h index f2d4e7948..a10abaa8d 100644 --- a/include/bg.h +++ b/include/bg.h @@ -70,14 +70,14 @@ void CopyToBgTilemapBuffer(u8 bg, const void *src, u16 mode, u16 destOffset); void CopyBgTilemapBufferToVram(u8 bg); void CopyToBgTilemapBufferRect(u8 bg, const void* src, u8 destX, u8 destY, u8 width, u8 height); void CopyToBgTilemapBufferRect_ChangePalette(u8 bg, const void *src, u8 destX, u8 destY, u8 rectWidth, u8 rectHeight, u8 palette); -void CopyRectToBgTilemapBufferRect(u8 bg, const void *src, u8 srcX, u8 srcY, u8 srcWidth, u8 srcHeight, u8 destX, u8 destY, u8 rectWidth, u8 rectHeight, u8 palette1, u16 tileOffset, u16 palette2); +void CopyRectToBgTilemapBufferRect(u8 bg, const void *src, u8 srcX, u8 srcY, u8 srcWidth, u8 unused, u8 srcHeight, u8 destX, u8 destY, u8 rectWidth, u8 rectHeight, s16 palette1, s16 tileOffset); void FillBgTilemapBufferRect_Palette0(u8 bg, u16 tileNum, u8 x, u8 y, u8 width, u8 height); void FillBgTilemapBufferRect(u8 bg, u16 tileNum, u8 x, u8 y, u8 width, u8 height, u8 palette); void WriteSequenceToBgTilemapBuffer(u8 bg, u16 firstTileNum, u8 x, u8 y, u8 width, u8 height, u8 paletteSlot, s16 tileNumDelta); u16 GetBgMetricTextMode(u8 bg, u8 whichMetric); u32 GetBgMetricAffineMode(u8 bg, u8 whichMetric); u32 GetTileMapIndexFromCoords(s32 x, s32 y, s32 screenSize, u32 screenWidth, u32 screenHeight); -void CopyTileMapEntry(u16 *src, u16 *dest, s32 palette1, u32 tileOffset, u32 palette2); +void CopyTileMapEntry(const u16 *src, u16 *dest, s32 palette1, s32 tileOffset, s32 palette2); u32 GetBgType(u8 bg); bool32 IsInvalidBg32(u8 bg); bool32 IsTileMapOutsideWram(u8 bg); diff --git a/include/pokemon.h b/include/pokemon.h index 3bf728244..5d7f7f2ae 100644 --- a/include/pokemon.h +++ b/include/pokemon.h @@ -446,7 +446,6 @@ extern const u8 gUnknown_08329D2A[]; extern const u8 gStatStageRatios[][2]; extern const u16 gUnknown_08329D54[]; extern const struct SpriteTemplate gUnknown_08329D98[]; -extern const struct CompressedSpritePalette gMonPaletteTable[]; extern const s8 gNatureStatTable[][5]; void ZeroBoxMonData(struct BoxPokemon *boxMon); diff --git a/src/bg.c b/src/bg.c index 7c55410b1..a41075ad7 100644 --- a/src/bg.c +++ b/src/bg.c @@ -135,22 +135,22 @@ u16 GetBgControlAttribute(u8 bg, u8 attributeId) { switch (attributeId) { - case BG_CTRL_ATTR_VISIBLE: - return sGpuBgConfigs.configs[bg].visible; - case BG_CTRL_ATTR_CHARBASEINDEX: - return sGpuBgConfigs.configs[bg].charBaseIndex; - case BG_CTRL_ATTR_MAPBASEINDEX: - return sGpuBgConfigs.configs[bg].mapBaseIndex; - case BG_CTRL_ATTR_SCREENSIZE: - return sGpuBgConfigs.configs[bg].screenSize; - case BG_CTRL_ATTR_PALETTEMODE: - return sGpuBgConfigs.configs[bg].paletteMode; - case BG_CTRL_ATTR_PRIORITY: - return sGpuBgConfigs.configs[bg].priority; - case BG_CTRL_ATTR_MOSAIC: - return sGpuBgConfigs.configs[bg].mosaic; - case BG_CTRL_ATTR_WRAPAROUND: - return sGpuBgConfigs.configs[bg].wraparound; + case BG_CTRL_ATTR_VISIBLE: + return sGpuBgConfigs.configs[bg].visible; + case BG_CTRL_ATTR_CHARBASEINDEX: + return sGpuBgConfigs.configs[bg].charBaseIndex; + case BG_CTRL_ATTR_MAPBASEINDEX: + return sGpuBgConfigs.configs[bg].mapBaseIndex; + case BG_CTRL_ATTR_SCREENSIZE: + return sGpuBgConfigs.configs[bg].screenSize; + case BG_CTRL_ATTR_PALETTEMODE: + return sGpuBgConfigs.configs[bg].paletteMode; + case BG_CTRL_ATTR_PRIORITY: + return sGpuBgConfigs.configs[bg].priority; + case BG_CTRL_ATTR_MOSAIC: + return sGpuBgConfigs.configs[bg].mosaic; + case BG_CTRL_ATTR_WRAPAROUND: + return sGpuBgConfigs.configs[bg].wraparound; } } @@ -166,15 +166,15 @@ u8 LoadBgVram(u8 bg, const void *src, u16 size, u16 destOffset, u8 mode) { switch (mode) { - case 0x1: - offset = sGpuBgConfigs.configs[bg].charBaseIndex * BG_CHAR_SIZE; - break; - case 0x2: - offset = sGpuBgConfigs.configs[bg].mapBaseIndex * BG_SCREEN_SIZE; - break; - default: - cursor = -1; - goto end; + case 0x1: + offset = sGpuBgConfigs.configs[bg].charBaseIndex * BG_CHAR_SIZE; + break; + case 0x2: + offset = sGpuBgConfigs.configs[bg].mapBaseIndex * BG_SCREEN_SIZE; + break; + default: + cursor = -1; + goto end; } offset = destOffset + offset; @@ -241,17 +241,17 @@ static void SetBgAffineInternal(u8 bg, u32 srcCenterX, u32 srcCenterY, s16 dispC switch (sGpuBgConfigs.bgVisibilityAndMode & 0x7) { - case 1: - if (bg != 2) - return; - break; - case 2: - if (bg < 2 || bg > 3) - return; - break; - case 0: - default: + case 1: + if (bg != 2) return; + break; + case 2: + if (bg < 2 || bg > 3) + return; + break; + case 0: + default: + return; } src.texX = srcCenterX; @@ -279,7 +279,8 @@ bool8 IsInvalidBg(u8 bg) { if (bg > 3) return TRUE; - return FALSE; + else + return FALSE; } int DummiedOutFireRedLeafGreenTileAllocFunc(int a1, int a2, int a3, int a4) @@ -434,7 +435,6 @@ u16 Unused_LoadBgPalette(u8 bg, const void *src, u16 size, u16 destOffset) return (u8)cursor; } -#ifdef NONMATCHING // Matches everything but r5 and r6 are flipped, rrr bool8 IsDma3ManagerBusyWithBgCopy(void) { u8 mod; @@ -462,60 +462,6 @@ bool8 IsDma3ManagerBusyWithBgCopy(void) return FALSE; } -#else -NAKED -bool8 IsDma3ManagerBusyWithBgCopy(void) -{ - asm("push {r4-r7,lr}\n\ - mov r5, #0\n\ - mov r7, #0x1\n\ - neg r7, r7\n\ -_08001ADC:\n\ - add r0, r5, #0\n\ - cmp r5, #0\n\ - bge _08001AE4\n\ - add r0, #0x1F\n\ -_08001AE4:\n\ - asr r0, #5\n\ - lsl r2, r0, #24\n\ - lsl r0, #5\n\ - sub r0, r5, r0\n\ - lsl r0, #24\n\ - lsr r0, #24\n\ - ldr r1, =sDmaBusyBitfield\n\ - lsr r2, #22\n\ - add r4, r2, r1\n\ - mov r6, #0x1\n\ - lsl r6, r0\n\ - ldr r0, [r4]\n\ - and r0, r6\n\ - cmp r0, #0\n\ - beq _08001B22\n\ - lsl r0, r5, #16\n\ - asr r0, #16\n\ - bl CheckForSpaceForDma3Request\n\ - lsl r0, #24\n\ - asr r0, #24\n\ - cmp r0, r7\n\ - bne _08001B1C\n\ - mov r0, #0x1\n\ - b _08001B2A\n\ - .pool\n\ -_08001B1C:\n\ - ldr r0, [r4]\n\ - bic r0, r6\n\ - str r0, [r4]\n\ -_08001B22:\n\ - add r5, #0x1\n\ - cmp r5, #0x7F\n\ - ble _08001ADC\n\ - mov r0, #0\n\ -_08001B2A:\n\ - pop {r4-r7}\n\ - pop {r1}\n\ - bx r1\n"); -} -#endif // NONMATCHING void ShowBg(u8 bg) { @@ -533,27 +479,27 @@ void SetBgAttribute(u8 bg, u8 attributeId, u8 value) { switch (attributeId) { - case 1: - SetBgControlAttributes(bg, value, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF); - break; - case 2: - SetBgControlAttributes(bg, 0xFF, value, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF); - break; - case 3: - SetBgControlAttributes(bg, 0xFF, 0xFF, value, 0xFF, 0xFF, 0xFF, 0xFF); - break; - case 4: - SetBgControlAttributes(bg, 0xFF, 0xFF, 0xFF, value, 0xFF, 0xFF, 0xFF); - break; - case 7: - SetBgControlAttributes(bg, 0xFF, 0xFF, 0xFF, 0xFF, value, 0xFF, 0xFF); - break; - case 5: - SetBgControlAttributes(bg, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, value, 0xFF); - break; - case 6: - SetBgControlAttributes(bg, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, value); - break; + case 1: + SetBgControlAttributes(bg, value, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF); + break; + case 2: + SetBgControlAttributes(bg, 0xFF, value, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF); + break; + case 3: + SetBgControlAttributes(bg, 0xFF, 0xFF, value, 0xFF, 0xFF, 0xFF, 0xFF); + break; + case 4: + SetBgControlAttributes(bg, 0xFF, 0xFF, 0xFF, value, 0xFF, 0xFF, 0xFF); + break; + case 7: + SetBgControlAttributes(bg, 0xFF, 0xFF, 0xFF, 0xFF, value, 0xFF, 0xFF); + break; + case 5: + SetBgControlAttributes(bg, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, value, 0xFF); + break; + case 6: + SetBgControlAttributes(bg, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, value); + break; } } @@ -561,36 +507,36 @@ u16 GetBgAttribute(u8 bg, u8 attributeId) { switch (attributeId) { - case 1: - return GetBgControlAttribute(bg, BG_CTRL_ATTR_CHARBASEINDEX); - case 2: - return GetBgControlAttribute(bg, BG_CTRL_ATTR_MAPBASEINDEX); - case 3: - return GetBgControlAttribute(bg, BG_CTRL_ATTR_SCREENSIZE); - case 4: - return GetBgControlAttribute(bg, BG_CTRL_ATTR_PALETTEMODE); - case 7: - return GetBgControlAttribute(bg, BG_CTRL_ATTR_PRIORITY); - case 5: - return GetBgControlAttribute(bg, BG_CTRL_ATTR_MOSAIC); - case 6: - return GetBgControlAttribute(bg, BG_CTRL_ATTR_WRAPAROUND); - case 8: - switch (GetBgType(bg)) - { - case 0: - return GetBgMetricTextMode(bg, 0) * 0x800; - case 1: - return GetBgMetricAffineMode(bg, 0) * 0x100; - default: - return 0; - } - case 9: - return GetBgType(bg); - case 10: - return sGpuBgConfigs2[bg].baseTile; - default: - return -1; + case 1: + return GetBgControlAttribute(bg, BG_CTRL_ATTR_CHARBASEINDEX); + case 2: + return GetBgControlAttribute(bg, BG_CTRL_ATTR_MAPBASEINDEX); + case 3: + return GetBgControlAttribute(bg, BG_CTRL_ATTR_SCREENSIZE); + case 4: + return GetBgControlAttribute(bg, BG_CTRL_ATTR_PALETTEMODE); + case 7: + return GetBgControlAttribute(bg, BG_CTRL_ATTR_PRIORITY); + case 5: + return GetBgControlAttribute(bg, BG_CTRL_ATTR_MOSAIC); + case 6: + return GetBgControlAttribute(bg, BG_CTRL_ATTR_WRAPAROUND); + case 8: + switch (GetBgType(bg)) + { + case 0: + return GetBgMetricTextMode(bg, 0) * 0x800; + case 1: + return GetBgMetricAffineMode(bg, 0) * 0x100; + default: + return 0; + } + case 9: + return GetBgType(bg); + case 10: + return sGpuBgConfigs2[bg].baseTile; + default: + return -1; } } @@ -607,58 +553,58 @@ u32 ChangeBgX(u8 bg, u32 value, u8 op) switch (op) { - case 0: - default: - sGpuBgConfigs2[bg].bg_x = value; - break; - case 1: - sGpuBgConfigs2[bg].bg_x += value; - break; - case 2: - sGpuBgConfigs2[bg].bg_x -= value; - break; + case 0: + default: + sGpuBgConfigs2[bg].bg_x = value; + break; + case 1: + sGpuBgConfigs2[bg].bg_x += value; + break; + case 2: + sGpuBgConfigs2[bg].bg_x -= value; + break; } mode = GetBgMode(); switch (bg) { - case 0: - temp1 = sGpuBgConfigs2[0].bg_x >> 0x8; - SetGpuReg(REG_OFFSET_BG0HOFS, temp1); - break; - case 1: - temp1 = sGpuBgConfigs2[1].bg_x >> 0x8; - SetGpuReg(REG_OFFSET_BG1HOFS, temp1); - break; - case 2: - if (mode == 0) - { - temp1 = sGpuBgConfigs2[2].bg_x >> 0x8; - SetGpuReg(REG_OFFSET_BG2HOFS, temp1); - } - else - { - temp1 = sGpuBgConfigs2[2].bg_x >> 0x10; - temp2 = sGpuBgConfigs2[2].bg_x & 0xFFFF; - SetGpuReg(REG_OFFSET_BG2X_H, temp1); - SetGpuReg(REG_OFFSET_BG2X_L, temp2); - } - break; - case 3: - if (mode == 0) - { - temp1 = sGpuBgConfigs2[3].bg_x >> 0x8; - SetGpuReg(REG_OFFSET_BG3HOFS, temp1); - } - else if (mode == 2) - { - temp1 = sGpuBgConfigs2[3].bg_x >> 0x10; - temp2 = sGpuBgConfigs2[3].bg_x & 0xFFFF; - SetGpuReg(REG_OFFSET_BG3X_H, temp1); - SetGpuReg(REG_OFFSET_BG3X_L, temp2); - } - break; + case 0: + temp1 = sGpuBgConfigs2[0].bg_x >> 0x8; + SetGpuReg(REG_OFFSET_BG0HOFS, temp1); + break; + case 1: + temp1 = sGpuBgConfigs2[1].bg_x >> 0x8; + SetGpuReg(REG_OFFSET_BG1HOFS, temp1); + break; + case 2: + if (mode == 0) + { + temp1 = sGpuBgConfigs2[2].bg_x >> 0x8; + SetGpuReg(REG_OFFSET_BG2HOFS, temp1); + } + else + { + temp1 = sGpuBgConfigs2[2].bg_x >> 0x10; + temp2 = sGpuBgConfigs2[2].bg_x & 0xFFFF; + SetGpuReg(REG_OFFSET_BG2X_H, temp1); + SetGpuReg(REG_OFFSET_BG2X_L, temp2); + } + break; + case 3: + if (mode == 0) + { + temp1 = sGpuBgConfigs2[3].bg_x >> 0x8; + SetGpuReg(REG_OFFSET_BG3HOFS, temp1); + } + else if (mode == 2) + { + temp1 = sGpuBgConfigs2[3].bg_x >> 0x10; + temp2 = sGpuBgConfigs2[3].bg_x & 0xFFFF; + SetGpuReg(REG_OFFSET_BG3X_H, temp1); + SetGpuReg(REG_OFFSET_BG3X_L, temp2); + } + break; } return sGpuBgConfigs2[bg].bg_x; @@ -668,9 +614,10 @@ u32 GetBgX(u8 bg) { if (IsInvalidBg32(bg) != FALSE) return -1; - if (GetBgControlAttribute(bg, BG_CTRL_ATTR_VISIBLE) == 0) + else if (GetBgControlAttribute(bg, BG_CTRL_ATTR_VISIBLE) == 0) return -1; - return sGpuBgConfigs2[bg].bg_x; + else + return sGpuBgConfigs2[bg].bg_x; } u32 ChangeBgY(u8 bg, u32 value, u8 op) @@ -686,58 +633,58 @@ u32 ChangeBgY(u8 bg, u32 value, u8 op) switch (op) { - case 0: - default: - sGpuBgConfigs2[bg].bg_y = value; - break; - case 1: - sGpuBgConfigs2[bg].bg_y += value; - break; - case 2: - sGpuBgConfigs2[bg].bg_y -= value; - break; + case 0: + default: + sGpuBgConfigs2[bg].bg_y = value; + break; + case 1: + sGpuBgConfigs2[bg].bg_y += value; + break; + case 2: + sGpuBgConfigs2[bg].bg_y -= value; + break; } mode = GetBgMode(); switch (bg) { - case 0: - temp1 = sGpuBgConfigs2[0].bg_y >> 0x8; - SetGpuReg(REG_OFFSET_BG0VOFS, temp1); - break; - case 1: - temp1 = sGpuBgConfigs2[1].bg_y >> 0x8; - SetGpuReg(REG_OFFSET_BG1VOFS, temp1); - break; - case 2: - if (mode == 0) - { - temp1 = sGpuBgConfigs2[2].bg_y >> 0x8; - SetGpuReg(REG_OFFSET_BG2VOFS, temp1); - } - else - { - temp1 = sGpuBgConfigs2[2].bg_y >> 0x10; - temp2 = sGpuBgConfigs2[2].bg_y & 0xFFFF; - SetGpuReg(REG_OFFSET_BG2Y_H, temp1); - SetGpuReg(REG_OFFSET_BG2Y_L, temp2); - } - break; - case 3: - if (mode == 0) - { - temp1 = sGpuBgConfigs2[3].bg_y >> 0x8; - SetGpuReg(REG_OFFSET_BG3VOFS, temp1); - } - else if (mode == 2) - { - temp1 = sGpuBgConfigs2[3].bg_y >> 0x10; - temp2 = sGpuBgConfigs2[3].bg_y & 0xFFFF; - SetGpuReg(REG_OFFSET_BG3Y_H, temp1); - SetGpuReg(REG_OFFSET_BG3Y_L, temp2); - } - break; + case 0: + temp1 = sGpuBgConfigs2[0].bg_y >> 0x8; + SetGpuReg(REG_OFFSET_BG0VOFS, temp1); + break; + case 1: + temp1 = sGpuBgConfigs2[1].bg_y >> 0x8; + SetGpuReg(REG_OFFSET_BG1VOFS, temp1); + break; + case 2: + if (mode == 0) + { + temp1 = sGpuBgConfigs2[2].bg_y >> 0x8; + SetGpuReg(REG_OFFSET_BG2VOFS, temp1); + } + else + { + temp1 = sGpuBgConfigs2[2].bg_y >> 0x10; + temp2 = sGpuBgConfigs2[2].bg_y & 0xFFFF; + SetGpuReg(REG_OFFSET_BG2Y_H, temp1); + SetGpuReg(REG_OFFSET_BG2Y_L, temp2); + } + break; + case 3: + if (mode == 0) + { + temp1 = sGpuBgConfigs2[3].bg_y >> 0x8; + SetGpuReg(REG_OFFSET_BG3VOFS, temp1); + } + else if (mode == 2) + { + temp1 = sGpuBgConfigs2[3].bg_y >> 0x10; + temp2 = sGpuBgConfigs2[3].bg_y & 0xFFFF; + SetGpuReg(REG_OFFSET_BG3Y_H, temp1); + SetGpuReg(REG_OFFSET_BG3Y_L, temp2); + } + break; } return sGpuBgConfigs2[bg].bg_y; @@ -756,59 +703,59 @@ u32 ChangeBgY_ScreenOff(u8 bg, u32 value, u8 op) switch (op) { - case 0: - default: - sGpuBgConfigs2[bg].bg_y = value; - break; - case 1: - sGpuBgConfigs2[bg].bg_y += value; - break; - case 2: - sGpuBgConfigs2[bg].bg_y -= value; - break; + case 0: + default: + sGpuBgConfigs2[bg].bg_y = value; + break; + case 1: + sGpuBgConfigs2[bg].bg_y += value; + break; + case 2: + sGpuBgConfigs2[bg].bg_y -= value; + break; } mode = GetBgMode(); switch (bg) { - case 0: - temp1 = sGpuBgConfigs2[0].bg_y >> 0x8; - SetGpuReg_ForcedBlank(REG_OFFSET_BG0VOFS, temp1); - break; - case 1: - temp1 = sGpuBgConfigs2[1].bg_y >> 0x8; - SetGpuReg_ForcedBlank(REG_OFFSET_BG1VOFS, temp1); - break; - case 2: - if (mode == 0) - { - temp1 = sGpuBgConfigs2[2].bg_y >> 0x8; - SetGpuReg_ForcedBlank(REG_OFFSET_BG2VOFS, temp1); + case 0: + temp1 = sGpuBgConfigs2[0].bg_y >> 0x8; + SetGpuReg_ForcedBlank(REG_OFFSET_BG0VOFS, temp1); + break; + case 1: + temp1 = sGpuBgConfigs2[1].bg_y >> 0x8; + SetGpuReg_ForcedBlank(REG_OFFSET_BG1VOFS, temp1); + break; + case 2: + if (mode == 0) + { + temp1 = sGpuBgConfigs2[2].bg_y >> 0x8; + SetGpuReg_ForcedBlank(REG_OFFSET_BG2VOFS, temp1); - } - else - { - temp1 = sGpuBgConfigs2[2].bg_y >> 0x10; - temp2 = sGpuBgConfigs2[2].bg_y & 0xFFFF; - SetGpuReg_ForcedBlank(REG_OFFSET_BG2Y_H, temp1); - SetGpuReg_ForcedBlank(REG_OFFSET_BG2Y_L, temp2); - } - break; - case 3: - if (mode == 0) - { - temp1 = sGpuBgConfigs2[3].bg_y >> 0x8; - SetGpuReg_ForcedBlank(REG_OFFSET_BG3VOFS, temp1); - } - else if (mode == 2) - { - temp1 = sGpuBgConfigs2[3].bg_y >> 0x10; - temp2 = sGpuBgConfigs2[3].bg_y & 0xFFFF; - SetGpuReg_ForcedBlank(REG_OFFSET_BG3Y_H, temp1); - SetGpuReg_ForcedBlank(REG_OFFSET_BG3Y_L, temp2); - } - break; + } + else + { + temp1 = sGpuBgConfigs2[2].bg_y >> 0x10; + temp2 = sGpuBgConfigs2[2].bg_y & 0xFFFF; + SetGpuReg_ForcedBlank(REG_OFFSET_BG2Y_H, temp1); + SetGpuReg_ForcedBlank(REG_OFFSET_BG2Y_L, temp2); + } + break; + case 3: + if (mode == 0) + { + temp1 = sGpuBgConfigs2[3].bg_y >> 0x8; + SetGpuReg_ForcedBlank(REG_OFFSET_BG3VOFS, temp1); + } + else if (mode == 2) + { + temp1 = sGpuBgConfigs2[3].bg_y >> 0x10; + temp2 = sGpuBgConfigs2[3].bg_y & 0xFFFF; + SetGpuReg_ForcedBlank(REG_OFFSET_BG3Y_H, temp1); + SetGpuReg_ForcedBlank(REG_OFFSET_BG3Y_L, temp2); + } + break; } return sGpuBgConfigs2[bg].bg_y; @@ -818,9 +765,10 @@ u32 GetBgY(u8 bg) { if (IsInvalidBg32(bg) != FALSE) return -1; - if (GetBgControlAttribute(bg, BG_CTRL_ATTR_VISIBLE) == 0) + else if (GetBgControlAttribute(bg, BG_CTRL_ATTR_VISIBLE) == 0) return -1; - return sGpuBgConfigs2[bg].bg_y; + else + return sGpuBgConfigs2[bg].bg_y; } void SetBgAffine(u8 bg, u32 srcCenterX, u32 srcCenterY, s16 dispCenterX, s16 dispCenterY, s16 scaleX, s16 scaleY, u16 rotationAngle) @@ -842,57 +790,57 @@ u8 Unused_AdjustBgMosaic(u8 a1, u8 a2) switch (a2) { - case 0: - default: - test1 = a1 & 0xF; - test2 = a1 >> 0x4; - break; - case 1: - test1 = a1 & 0xF; - break; - case 2: - if ((test1 + a1) > 0xF) - { - test1 = 0xF; - } - else - { - test1 += a1; - } - break; - case 3: - if ((test1 - a1) < 0) - { - test1 = 0x0; - } - else - { - test1 -= a1; - } - break; - case 4: - test2 = a1 & 0xF; - break; - case 5: - if ((test2 + a1) > 0xF) - { - test2 = 0xF; - } - else - { - test2 += a1; - } - break; - case 6: - if ((test2 - a1) < 0) - { - test2 = 0x0; - } - else - { - test2 -= a1; - } - break; + case 0: + default: + test1 = a1 & 0xF; + test2 = a1 >> 0x4; + break; + case 1: + test1 = a1 & 0xF; + break; + case 2: + if ((test1 + a1) > 0xF) + { + test1 = 0xF; + } + else + { + test1 += a1; + } + break; + case 3: + if ((test1 - a1) < 0) + { + test1 = 0x0; + } + else + { + test1 -= a1; + } + break; + case 4: + test2 = a1 & 0xF; + break; + case 5: + if ((test2 + a1) > 0xF) + { + test2 = 0xF; + } + else + { + test2 += a1; + } + break; + case 6: + if ((test2 - a1) < 0) + { + test2 = 0x0; + } + else + { + test2 -= a1; + } + break; } result |= ((test2 << 0x4) & 0xF0); @@ -923,9 +871,10 @@ void* GetBgTilemapBuffer(u8 bg) { if (IsInvalidBg32(bg) != FALSE) return NULL; - if (GetBgControlAttribute(bg, BG_CTRL_ATTR_VISIBLE) == 0) + else if (GetBgControlAttribute(bg, BG_CTRL_ATTR_VISIBLE) == 0) return NULL; - return sGpuBgConfigs2[bg].tilemap; + else + return sGpuBgConfigs2[bg].tilemap; } void CopyToBgTilemapBuffer(u8 bg, const void *src, u16 mode, u16 destOffset) @@ -933,13 +882,9 @@ void CopyToBgTilemapBuffer(u8 bg, const void *src, u16 mode, u16 destOffset) if (IsInvalidBg32(bg) == FALSE && IsTileMapOutsideWram(bg) == FALSE) { if (mode != 0) - { CpuCopy16(src, (void *)(sGpuBgConfigs2[bg].tilemap + (destOffset * 2)), mode); - } else - { LZ77UnCompWram(src, (void *)(sGpuBgConfigs2[bg].tilemap + (destOffset * 2))); - } } } @@ -951,15 +896,15 @@ void CopyBgTilemapBufferToVram(u8 bg) { switch (GetBgType(bg)) { - case 0: - sizeToLoad = GetBgMetricTextMode(bg, 0) * 0x800; - break; - case 1: - sizeToLoad = GetBgMetricAffineMode(bg, 0) * 0x100; - break; - default: - sizeToLoad = 0; - break; + case 0: + sizeToLoad = GetBgMetricTextMode(bg, 0) * 0x800; + break; + case 1: + sizeToLoad = GetBgMetricAffineMode(bg, 0) * 0x100; + break; + default: + sizeToLoad = 0; + break; } LoadBgVram(bg, sGpuBgConfigs2[bg].tilemap, sizeToLoad, 0, 2); } @@ -976,27 +921,27 @@ void CopyToBgTilemapBufferRect(u8 bg, const void* src, u8 destX, u8 destY, u8 wi { switch (GetBgType(bg)) { - case 0: - srcCopy = src; - for (destY16 = destY; destY16 < (destY + height); destY16++) + case 0: + srcCopy = src; + for (destY16 = destY; destY16 < (destY + height); destY16++) + { + for (destX16 = destX; destX16 < (destX + width); destX16++) { - for (destX16 = destX; destX16 < (destX + width); destX16++) - { - ((u16*)sGpuBgConfigs2[bg].tilemap)[((destY16 * 0x20) + destX16)] = *((u16*)srcCopy)++; - } + ((u16*)sGpuBgConfigs2[bg].tilemap)[((destY16 * 0x20) + destX16)] = *((u16*)srcCopy)++; } - break; - case 1: - srcCopy = src; - mode = GetBgMetricAffineMode(bg, 0x1); - for (destY16 = destY; destY16 < (destY + height); destY16++) + } + break; + case 1: + srcCopy = src; + mode = GetBgMetricAffineMode(bg, 0x1); + for (destY16 = destY; destY16 < (destY + height); destY16++) + { + for (destX16 = destX; destX16 < (destX + width); destX16++) { - for (destX16 = destX; destX16 < (destX + width); destX16++) - { - ((u8*)sGpuBgConfigs2[bg].tilemap)[((destY16 * mode) + destX16)] = *((u8*)srcCopy)++; - } + ((u8*)sGpuBgConfigs2[bg].tilemap)[((destY16 * mode) + destX16)] = *((u8*)srcCopy)++; } - break; + } + break; } } } @@ -1005,295 +950,49 @@ void CopyToBgTilemapBufferRect_ChangePalette(u8 bg, const void *src, u8 destX, u { CopyRectToBgTilemapBufferRect(bg, src, 0, 0, rectWidth, rectHeight, destX, destY, rectWidth, rectHeight, palette, 0, 0); } -// Skipping for now, it probably uses structs passed by value -/* -void CopyRectToBgTilemapBufferRect(u8 bg, const void* src, u8 srcX, u8 srcY, u8 srcWidth, u8 srcHeight, u8 destX, u8 destY, u8 rectWidth, u8 rectHeight, u8 palette1, u16 tileOffset, u16 palette2) + +void CopyRectToBgTilemapBufferRect(u8 bg, const void *src, u8 srcX, u8 srcY, u8 srcWidth, u8 unused, u8 srcHeight, u8 destX, u8 destY, u8 rectWidth, u8 rectHeight, s16 palette1, s16 tileOffset) { - u16 attribute; - u16 mode; - u16 mode2; + u16 screenWidth, screenHeight, screenSize; + u16 var; + const void *srcPtr; + u16 i, j; - void* srcCopy; - u16 destX16; - u16 destY16; - - if (IsInvalidBg32(bg) == FALSE && IsTileMapOutsideWram(bg) == FALSE) + if (!IsInvalidBg32(bg) && !IsTileMapOutsideWram(bg)) { - attribute = GetBgControlAttribute(bg, BG_CTRL_ATTR_SCREENSIZE); - mode = GetBgMetricTextMode(bg, 0x1) * 0x20; - mode2 = GetBgMetricTextMode(bg, 0x2) * 0x20; + screenSize = GetBgControlAttribute(bg, BG_CTRL_ATTR_SCREENSIZE); + screenWidth = GetBgMetricTextMode(bg, 0x1) * 0x20; + screenHeight = GetBgMetricTextMode(bg, 0x2) * 0x20; switch (GetBgType(bg)) { - case 0: - srcCopy = src; - for (destY16 = destY; destY16 < (destY + rectHeight); destY16++) + case 0: + srcPtr = src + ((srcY * srcWidth) + srcX) * 2; + for (i = destX; i < (destX + rectWidth); i++) + { + for (j = srcHeight; j < (srcHeight + destY); j++) { - for (destX16 = destX; destX16 < (destX + rectWidth); destX16++) - { - CopyTileMapEntry(&((u16*)srcCopy)[(srcY * rectWidth) + srcX], &((u16*)sGpuBgConfigs2[bg].tilemap)[GetTileMapIndexFromCoords(destX16, destY16, attribute, mode, mode2)], palette1, tileOffset, palette2); - } + u16 index = GetTileMapIndexFromCoords(j, i, screenSize, screenWidth, screenHeight); + CopyTileMapEntry(srcPtr, sGpuBgConfigs2[bg].tilemap + (index * 2), rectHeight, palette1, tileOffset); + srcPtr += 2; } - break; - case 1: - srcCopy = src; - mode = GetBgMetricAffineMode(bg, 0x1); - for (destY16 = destY; destY16 < (destY + rectHeight); destY16++) + srcPtr += (srcWidth - destY) * 2; + } + break; + case 1: + srcPtr = src + ((srcY * srcWidth) + srcX); + var = GetBgMetricAffineMode(bg, 0x1); + for (i = destX; i < (destX + rectWidth); i++) + { + for (j = srcHeight; j < (srcHeight + destY); j++) { - for (destX16 = destX; destX16 < (destX + rectWidth); destX16++) - { - CopyTileMapEntry(&((u16*)srcCopy)[(srcY * rectWidth) + srcX], &((u16*)sGpuBgConfigs2[bg].tilemap)[GetTileMapIndexFromCoords(destX16, destY16, attribute, mode, mode2)], palette1, tileOffset, palette2); - } + *(u8*)(sGpuBgConfigs2[bg].tilemap + ((var * i) + j)) = *(u8*)(srcPtr) + palette1; + srcPtr++; } - break; + srcPtr += (srcWidth - destY); + } + break; } } -}*/ -NAKED -void CopyRectToBgTilemapBufferRect(u8 bg, const void* src, u8 srcX, u8 srcY, u8 srcWidth, u8 srcHeight, u8 destX, u8 destY, u8 rectWidth, u8 rectHeight, u8 palette1, u16 tileOffset, u16 palette2) -{ - asm("push {r4-r7,lr}\n\ - mov r7, r10\n\ - mov r6, r9\n\ - mov r5, r8\n\ - push {r5-r7}\n\ - sub sp, #0x40\n\ - str r1, [sp, #0x8]\n\ - ldr r1, [sp, #0x60]\n\ - ldr r4, [sp, #0x68]\n\ - ldr r5, [sp, #0x6C]\n\ - ldr r6, [sp, #0x70]\n\ - ldr r7, [sp, #0x74]\n\ - mov r8, r7\n\ - ldr r7, [sp, #0x78]\n\ - mov r9, r7\n\ - ldr r7, [sp, #0x7C]\n\ - mov r10, r7\n\ - ldr r7, [sp, #0x80]\n\ - mov r12, r7\n\ - lsl r0, #24\n\ - lsr r0, #24\n\ - str r0, [sp, #0x4]\n\ - lsl r2, #24\n\ - lsr r2, #24\n\ - str r2, [sp, #0xC]\n\ - lsl r3, #24\n\ - lsr r3, #24\n\ - str r3, [sp, #0x10]\n\ - lsl r1, #24\n\ - lsr r7, r1, #24\n\ - lsl r4, #24\n\ - lsr r4, #24\n\ - str r4, [sp, #0x14]\n\ - lsl r5, #24\n\ - lsr r5, #24\n\ - lsl r6, #24\n\ - lsr r6, #24\n\ - str r6, [sp, #0x18]\n\ - mov r0, r8\n\ - lsl r0, #24\n\ - lsr r4, r0, #24\n\ - mov r1, r9\n\ - lsl r1, #24\n\ - lsr r1, #24\n\ - str r1, [sp, #0x1C]\n\ - mov r2, r10\n\ - lsl r2, #16\n\ - lsr r2, #16\n\ - str r2, [sp, #0x20]\n\ - mov r0, r12\n\ - lsl r0, #16\n\ - lsr r0, #16\n\ - str r0, [sp, #0x24]\n\ - ldr r0, [sp, #0x4]\n\ - bl IsInvalidBg32\n\ - cmp r0, #0\n\ - beq _08002592\n\ - b _080026EE\n\ -_08002592:\n\ - ldr r0, [sp, #0x4]\n\ - bl IsTileMapOutsideWram\n\ - cmp r0, #0\n\ - beq _0800259E\n\ - b _080026EE\n\ -_0800259E:\n\ - ldr r0, [sp, #0x4]\n\ - mov r1, #0x4\n\ - bl GetBgControlAttribute\n\ - lsl r0, #16\n\ - lsr r0, #16\n\ - str r0, [sp, #0x30]\n\ - ldr r0, [sp, #0x4]\n\ - mov r1, #0x1\n\ - bl GetBgMetricTextMode\n\ - lsl r0, #21\n\ - lsr r0, #16\n\ - str r0, [sp, #0x28]\n\ - ldr r0, [sp, #0x4]\n\ - mov r1, #0x2\n\ - bl GetBgMetricTextMode\n\ - lsl r0, #21\n\ - lsr r0, #16\n\ - str r0, [sp, #0x2C]\n\ - ldr r0, [sp, #0x4]\n\ - bl GetBgType\n\ - cmp r0, #0\n\ - beq _080025D8\n\ - cmp r0, #0x1\n\ - beq _08002674\n\ - b _080026EE\n\ -_080025D8:\n\ - ldr r1, [sp, #0x10]\n\ - add r0, r1, #0\n\ - mul r0, r7\n\ - ldr r2, [sp, #0xC]\n\ - add r0, r2\n\ - lsl r0, #1\n\ - ldr r1, [sp, #0x8]\n\ - add r6, r1, r0\n\ - add r0, r5, r4\n\ - cmp r5, r0\n\ - blt _080025F0\n\ - b _080026EE\n\ -_080025F0:\n\ - ldr r2, [sp, #0x18]\n\ - sub r2, r7, r2\n\ - str r2, [sp, #0x34]\n\ - str r0, [sp, #0x38]\n\ -_080025F8:\n\ - ldr r4, [sp, #0x14]\n\ - ldr r7, [sp, #0x18]\n\ - add r0, r4, r7\n\ - add r1, r5, #0x1\n\ - str r1, [sp, #0x3C]\n\ - cmp r4, r0\n\ - bge _0800265A\n\ - ldr r2, [sp, #0x4]\n\ - lsl r0, r2, #4\n\ - ldr r1, =sGpuBgConfigs2+4\n\ - add r0, r1\n\ - mov r10, r0\n\ - ldr r7, [sp, #0x20]\n\ - lsl r7, #16\n\ - mov r9, r7\n\ - ldr r1, [sp, #0x24]\n\ - lsl r0, r1, #16\n\ - asr r0, #16\n\ - mov r8, r0\n\ -_0800261E:\n\ - ldr r2, [sp, #0x2C]\n\ - str r2, [sp]\n\ - add r0, r4, #0\n\ - add r1, r5, #0\n\ - ldr r2, [sp, #0x30]\n\ - ldr r3, [sp, #0x28]\n\ - bl GetTileMapIndexFromCoords\n\ - lsl r0, #16\n\ - lsr r0, #15\n\ - mov r7, r10\n\ - ldr r1, [r7]\n\ - add r1, r0\n\ - mov r0, r8\n\ - str r0, [sp]\n\ - add r0, r6, #0\n\ - ldr r2, [sp, #0x1C]\n\ - mov r7, r9\n\ - asr r3, r7, #16\n\ - bl CopyTileMapEntry\n\ - add r6, #0x2\n\ - add r0, r4, #0x1\n\ - lsl r0, #16\n\ - lsr r4, r0, #16\n\ - ldr r1, [sp, #0x14]\n\ - ldr r2, [sp, #0x18]\n\ - add r0, r1, r2\n\ - cmp r4, r0\n\ - blt _0800261E\n\ -_0800265A:\n\ - ldr r5, [sp, #0x34]\n\ - lsl r0, r5, #1\n\ - add r6, r0\n\ - ldr r7, [sp, #0x3C]\n\ - lsl r0, r7, #16\n\ - lsr r5, r0, #16\n\ - ldr r0, [sp, #0x38]\n\ - cmp r5, r0\n\ - blt _080025F8\n\ - b _080026EE\n\ - .pool\n\ -_08002674:\n\ - ldr r1, [sp, #0x10]\n\ - add r0, r1, #0\n\ - mul r0, r7\n\ - ldr r2, [sp, #0xC]\n\ - add r0, r2\n\ - ldr r1, [sp, #0x8]\n\ - add r6, r1, r0\n\ - ldr r0, [sp, #0x4]\n\ - mov r1, #0x1\n\ - bl GetBgMetricAffineMode\n\ - lsl r0, #16\n\ - lsr r0, #16\n\ - mov r9, r0\n\ - add r0, r5, r4\n\ - cmp r5, r0\n\ - bge _080026EE\n\ - ldr r2, [sp, #0x18]\n\ - sub r2, r7, r2\n\ - str r2, [sp, #0x34]\n\ - str r0, [sp, #0x38]\n\ - ldr r7, =sGpuBgConfigs2+4\n\ - mov r10, r7\n\ - ldr r0, [sp, #0x4]\n\ - lsl r0, #4\n\ - mov r8, r0\n\ -_080026A8:\n\ - ldr r4, [sp, #0x14]\n\ - ldr r1, [sp, #0x18]\n\ - add r0, r4, r1\n\ - add r2, r5, #0x1\n\ - str r2, [sp, #0x3C]\n\ - cmp r4, r0\n\ - bge _080026DE\n\ - mov r3, r8\n\ - add r3, r10\n\ - mov r7, r9\n\ - mul r7, r5\n\ - mov r12, r7\n\ - add r2, r0, #0\n\ -_080026C2:\n\ - ldr r1, [r3]\n\ - mov r5, r12\n\ - add r0, r5, r4\n\ - add r1, r0\n\ - ldrb r0, [r6]\n\ - ldr r7, [sp, #0x20]\n\ - add r0, r7\n\ - strb r0, [r1]\n\ - add r6, #0x1\n\ - add r0, r4, #0x1\n\ - lsl r0, #16\n\ - lsr r4, r0, #16\n\ - cmp r4, r2\n\ - blt _080026C2\n\ -_080026DE:\n\ - ldr r0, [sp, #0x34]\n\ - add r6, r0\n\ - ldr r1, [sp, #0x3C]\n\ - lsl r0, r1, #16\n\ - lsr r5, r0, #16\n\ - ldr r2, [sp, #0x38]\n\ - cmp r5, r2\n\ - blt _080026A8\n\ -_080026EE:\n\ - add sp, #0x40\n\ - pop {r3-r5}\n\ - mov r8, r3\n\ - mov r9, r4\n\ - mov r10, r5\n\ - pop {r4-r7}\n\ - pop {r0}\n\ - bx r0\n\ - .pool\n"); } void FillBgTilemapBufferRect_Palette0(u8 bg, u16 tileNum, u8 x, u8 y, u8 width, u8 height) @@ -1384,42 +1083,42 @@ u16 GetBgMetricTextMode(u8 bg, u8 whichMetric) switch (whichMetric) { + case 0: + switch (attribute) + { case 0: - switch (attribute) - { - case 0: - return 1; - case 1: - case 2: - return 2; - case 3: - return 4; - } - break; + return 1; case 1: - switch (attribute) - { - case 0: - return 1; - case 1: - return 2; - case 2: - return 1; - case 3: - return 2; - } - break; case 2: - switch (attribute) - { - case 0: - case 1: - return 1; - case 2: - case 3: - return 2; - } - break; + return 2; + case 3: + return 4; + } + break; + case 1: + switch (attribute) + { + case 0: + return 1; + case 1: + return 2; + case 2: + return 1; + case 3: + return 2; + } + break; + case 2: + switch (attribute) + { + case 0: + case 1: + return 1; + case 2: + case 3: + return 2; + } + break; } return 0; } @@ -1432,22 +1131,22 @@ u32 GetBgMetricAffineMode(u8 bg, u8 whichMetric) switch (whichMetric) { + case 0: + switch (attribute) + { case 0: - switch (attribute) - { - case 0: - return 0x1; - case 1: - return 0x4; - case 2: - return 0x10; - case 3: - return 0x40; - } - break; + return 0x1; case 1: + return 0x4; case 2: - return 0x10 << attribute; + return 0x10; + case 3: + return 0x40; + } + break; + case 1: + case 2: + return 0x10 << attribute; } return 0; } @@ -1459,44 +1158,45 @@ u32 GetTileMapIndexFromCoords(s32 x, s32 y, s32 screenSize, u32 screenWidth, u32 switch (screenSize) { - case 0: - case 2: - break; - case 3: - if (y >= 0x20) - y += 0x20; - case 1: - if (x >= 0x20) - { - x -= 0x20; - y += 0x20; - } + case 0: + case 2: + break; + case 3: + if (y >= 0x20) + y += 0x20; + case 1: + if (x >= 0x20) + { + x -= 0x20; + y += 0x20; + } + break; } return (y * 0x20) + x; } #ifdef NONMATCHING // This one has some weird switch statement cases that refuse to cooperate -void CopyTileMapEntry(u16 *src, u16 *dest, s32 palette1, u32 tileOffset, u32 palette2) +void CopyTileMapEntry(const u16 *src, u16 *dest, s32 palette1, s32 tileOffset, s32 palette2) { - u16 test; + u16 var; switch (palette1) { - default: - if (palette1 > 0x10 || palette1 < 0) - test = *src + tileOffset + (palette2 << 12); - else - test = ((*src + tileOffset) & 0xFFF) + ((palette1 + palette2) << 12); - break; - case 0x10: - test = ((*dest & 0xFC00) + (palette2 << 12)) | ((*src + tileOffset) & 0x3FF); - break; + case 0 ... 16: + if (palette1 != 16) + var = ((*src + tileOffset) & 0xFFF) + ((palette1 + palette2) << 12); + else + var = ((*dest & 0xFC00) + (palette2 << 12)) | ((*src + tileOffset) & 0x3FF); + break; + default: + var = *src + tileOffset + (palette2 << 12); + break; } - *dest = test; + *dest = var; } #else NAKED -void CopyTileMapEntry(u16 *src, u16 *dest, s32 palette1, u32 tileOffset, u32 palette2) +void CopyTileMapEntry(const u16 *src, u16 *dest, s32 palette1, s32 tileOffset, s32 palette2) { asm("push {r4-r6,lr}\n\ add r4, r0, #0\n\ @@ -1550,41 +1250,38 @@ _08002B3C:\n\ u32 GetBgType(u8 bg) { - u8 mode; - - mode = GetBgMode(); - + u8 mode = GetBgMode(); switch (bg) { + case 0: + case 1: + switch (mode) + { case 0: case 1: - switch (mode) - { - case 0: - case 1: - return 0; - } - break; + return 0; + } + break; + case 2: + switch (mode) + { + case 0: + return 0; + case 1: case 2: - switch (mode) - { - case 0: - return 0; - case 1: - case 2: - return 1; - } - break; - case 3: - switch (mode) - { - case 0: - return 0; - case 2: - return 1; - } - break; + return 1; + } + break; + case 3: + switch (mode) + { + case 0: + return 0; + case 2: + return 1; + } + break; } return 0xFFFF; @@ -1594,14 +1291,16 @@ bool32 IsInvalidBg32(u8 bg) { if (bg > 3) return TRUE; - return FALSE; + else + return FALSE; } bool32 IsTileMapOutsideWram(u8 bg) { if (sGpuBgConfigs2[bg].tilemap > (void*)IWRAM_END) return TRUE; - if (sGpuBgConfigs2[bg].tilemap == 0x0) + else if (sGpuBgConfigs2[bg].tilemap == NULL) return TRUE; - return FALSE; + else + return FALSE; } diff --git a/src/field_effect.c b/src/field_effect.c index 2ec5edf1e..a26d43030 100644 --- a/src/field_effect.c +++ b/src/field_effect.c @@ -32,6 +32,8 @@ #define subsprite_table(ptr) {.subsprites = ptr, .subspriteCount = (sizeof ptr) / (sizeof(struct Subsprite))} +extern struct CompressedSpritePalette gMonPaletteTable[]; // GF made a mistake and did not extern it as const. + EWRAM_DATA s32 gFieldEffectArguments[8] = {0}; // Static type declarations @@ -755,67 +757,15 @@ u8 AddNewGameBirchObject(s16 x, s16 y, u8 subpriority) return CreateSprite(&gNewGameBirchObjectTemplate, x, y, subpriority); } -#ifdef NONMATCHING u8 CreateMonSprite_PicBox(u16 species, s16 x, s16 y, u8 subpriority) { - u16 spriteId = CreateMonPicSprite_HandleDeoxys(species, 0, 0x8000, 1, x, y, 0, gMonPaletteTable[species].tag); + s32 spriteId = CreateMonPicSprite_HandleDeoxys(species, 0, 0x8000, 1, x, y, 0, gMonPaletteTable[species].tag); PreservePaletteInWeather(IndexOfSpritePaletteTag(gMonPaletteTable[species].tag) + 0x10); if (spriteId == 0xFFFF) return MAX_SPRITES; - - return spriteId; + else + return spriteId; } -#else -NAKED -u8 CreateMonSprite_PicBox(u16 species, s16 x, s16 y, u8 subpriority) -{ - asm_unified("push {r4,r5,lr}\n\ - sub sp, 0x10\n\ - lsls r0, 16\n\ - lsrs r0, 16\n\ - movs r3, 0x80\n\ - lsls r3, 8\n\ - lsls r1, 16\n\ - asrs r1, 16\n\ - str r1, [sp]\n\ - lsls r2, 16\n\ - asrs r2, 16\n\ - str r2, [sp, 0x4]\n\ - movs r1, 0\n\ - str r1, [sp, 0x8]\n\ - ldr r1, =gMonPaletteTable\n\ - lsls r4, r0, 3\n\ - adds r4, r1\n\ - ldrh r1, [r4, 0x4]\n\ - str r1, [sp, 0xC]\n\ - movs r1, 0\n\ - adds r2, r3, 0\n\ - movs r3, 0x1\n\ - bl CreateMonPicSprite_HandleDeoxys\n\ - lsls r0, 16\n\ - lsrs r5, r0, 16\n\ - ldrh r0, [r4, 0x4]\n\ - bl IndexOfSpritePaletteTag\n\ - adds r0, 0x10\n\ - lsls r0, 24\n\ - lsrs r0, 24\n\ - bl PreservePaletteInWeather\n\ - ldr r0, =0x0000ffff\n\ - cmp r5, r0\n\ - beq _080B5FDC\n\ - lsls r0, r5, 24\n\ - lsrs r0, 24\n\ - b _080B5FDE\n\ - .pool\n\ -_080B5FDC:\n\ - movs r0, 0x40\n\ -_080B5FDE:\n\ - add sp, 0x10\n\ - pop {r4,r5}\n\ - pop {r1}\n\ - bx r1"); -} -#endif //NONMATCHING u8 CreateMonSprite_FieldMove(u16 species, u32 d, u32 g, s16 x, s16 y, u8 subpriority) { @@ -824,8 +774,8 @@ u8 CreateMonSprite_FieldMove(u16 species, u32 d, u32 g, s16 x, s16 y, u8 subprio PreservePaletteInWeather(IndexOfSpritePaletteTag(spritePalette->tag) + 0x10); if (spriteId == 0xFFFF) return 0x40; - - return spriteId; + else + return spriteId; } void FreeResourcesAndDestroySprite(struct Sprite *sprite, u8 spriteId) @@ -3123,134 +3073,134 @@ NAKED u8 sub_80B8F98(void) { asm_unified("push {r4-r7,lr}\n\ - mov r7, r8\n\ - push {r7}\n\ - ldr r0, =gFieldEffectObjectTemplatePointers\n\ - adds r0, 0x90\n\ - ldr r0, [r0]\n\ - movs r2, 0x18\n\ - negs r2, r2\n\ - movs r1, 0x78\n\ - movs r3, 0x1\n\ - bl CreateSprite\n\ - lsls r0, 24\n\ - lsrs r0, 24\n\ - mov r8, r0\n\ - lsls r1, r0, 4\n\ - add r1, r8\n\ - lsls r1, 2\n\ - ldr r0, =gSprites\n\ - adds r1, r0\n\ - ldrb r2, [r1, 0x5]\n\ - movs r0, 0xD\n\ - negs r0, r0\n\ - ands r0, r2\n\ - movs r2, 0x4\n\ - orrs r0, r2\n\ - movs r2, 0xF\n\ - ands r0, r2\n\ - movs r2, 0x40\n\ - orrs r0, r2\n\ - strb r0, [r1, 0x5]\n\ - movs r2, 0\n\ - strh r2, [r1, 0x2E]\n\ - strh r2, [r1, 0x30]\n\ - strh r2, [r1, 0x32]\n\ - ldr r0, =0x0000ffff\n\ - strh r0, [r1, 0x34]\n\ - ldrh r0, [r1, 0x22]\n\ - strh r0, [r1, 0x36]\n\ - strh r2, [r1, 0x38]\n\ - ldr r1, =0x00003e41\n\ - movs r0, 0x50\n\ - bl SetGpuReg\n\ - ldr r1, =0x00000e0e\n\ - movs r0, 0x52\n\ - bl SetGpuReg\n\ - ldr r1, =0x00003f3f\n\ - movs r0, 0x48\n\ - bl SetGpuReg\n\ - ldr r0, =gUnknown_0855B610\n\ - movs r1, 0xC0\n\ - movs r2, 0x20\n\ - bl LoadPalette\n\ - movs r0, 0x12\n\ - movs r1, 0x78\n\ - bl SetGpuReg\n\ - movs r4, 0x3\n\ - ldr r7, =0x0600f800\n\ - ldr r0, =0x0000bff4\n\ - adds r6, r0, 0\n\ + mov r7, r8\n\ + push {r7}\n\ + ldr r0, =gFieldEffectObjectTemplatePointers\n\ + adds r0, 0x90\n\ + ldr r0, [r0]\n\ + movs r2, 0x18\n\ + negs r2, r2\n\ + movs r1, 0x78\n\ + movs r3, 0x1\n\ + bl CreateSprite\n\ + lsls r0, 24\n\ + lsrs r0, 24\n\ + mov r8, r0\n\ + lsls r1, r0, 4\n\ + add r1, r8\n\ + lsls r1, 2\n\ + ldr r0, =gSprites\n\ + adds r1, r0\n\ + ldrb r2, [r1, 0x5]\n\ + movs r0, 0xD\n\ + negs r0, r0\n\ + ands r0, r2\n\ + movs r2, 0x4\n\ + orrs r0, r2\n\ + movs r2, 0xF\n\ + ands r0, r2\n\ + movs r2, 0x40\n\ + orrs r0, r2\n\ + strb r0, [r1, 0x5]\n\ + movs r2, 0\n\ + strh r2, [r1, 0x2E]\n\ + strh r2, [r1, 0x30]\n\ + strh r2, [r1, 0x32]\n\ + ldr r0, =0x0000ffff\n\ + strh r0, [r1, 0x34]\n\ + ldrh r0, [r1, 0x22]\n\ + strh r0, [r1, 0x36]\n\ + strh r2, [r1, 0x38]\n\ + ldr r1, =0x00003e41\n\ + movs r0, 0x50\n\ + bl SetGpuReg\n\ + ldr r1, =0x00000e0e\n\ + movs r0, 0x52\n\ + bl SetGpuReg\n\ + ldr r1, =0x00003f3f\n\ + movs r0, 0x48\n\ + bl SetGpuReg\n\ + ldr r0, =gUnknown_0855B610\n\ + movs r1, 0xC0\n\ + movs r2, 0x20\n\ + bl LoadPalette\n\ + movs r0, 0x12\n\ + movs r1, 0x78\n\ + bl SetGpuReg\n\ + movs r4, 0x3\n\ + ldr r7, =0x0600f800\n\ + ldr r0, =0x0000bff4\n\ + adds r6, r0, 0\n\ _080B901A:\n\ - movs r2, 0xC\n\ - lsls r0, r4, 1\n\ - lsls r5, r4, 5\n\ - adds r0, r4\n\ - lsls r3, r0, 1\n\ + movs r2, 0xC\n\ + lsls r0, r4, 1\n\ + lsls r5, r4, 5\n\ + adds r0, r4\n\ + lsls r3, r0, 1\n\ _080B9024:\n\ - adds r0, r5, r2\n\ - lsls r0, 1\n\ - adds r0, r7\n\ - adds r1, r2, r6\n\ - adds r1, r3, r1\n\ - adds r1, 0x1\n\ - strh r1, [r0]\n\ - adds r0, r2, 0x1\n\ - lsls r0, 24\n\ - lsrs r2, r0, 24\n\ - cmp r2, 0x11\n\ - bls _080B9024\n\ - adds r0, r4, 0x1\n\ - lsls r0, 24\n\ - lsrs r4, r0, 24\n\ - cmp r4, 0xE\n\ - bls _080B901A\n\ - movs r0, 0\n\ - ldr r5, =gUnknown_0855B630\n\ + adds r0, r5, r2\n\ + lsls r0, 1\n\ + adds r0, r7\n\ + adds r1, r2, r6\n\ + adds r1, r3, r1\n\ + adds r1, 0x1\n\ + strh r1, [r0]\n\ + adds r0, r2, 0x1\n\ + lsls r0, 24\n\ + lsrs r2, r0, 24\n\ + cmp r2, 0x11\n\ + bls _080B9024\n\ + adds r0, r4, 0x1\n\ + lsls r0, 24\n\ + lsrs r4, r0, 24\n\ + cmp r4, 0xE\n\ + bls _080B901A\n\ + movs r0, 0\n\ + ldr r5, =gUnknown_0855B630\n\ _080B904A:\n\ - movs r4, 0\n\ - adds r7, r0, 0x1\n\ - lsls r6, r0, 5\n\ + movs r4, 0\n\ + adds r7, r0, 0x1\n\ + lsls r6, r0, 5\n\ _080B9050:\n\ - lsls r1, r4, 2\n\ - adds r1, r6, r1\n\ - ldr r0, =0x06008020\n\ - adds r3, r1, r0\n\ - adds r0, r1, 0x1\n\ - adds r0, r5\n\ - ldrb r2, [r0]\n\ - lsls r2, 8\n\ - adds r0, r1, r5\n\ - ldrb r0, [r0]\n\ - adds r0, r2\n\ - strh r0, [r3]\n\ - ldr r0, =0x06008022\n\ - adds r3, r1, r0\n\ - adds r0, r1, 0x3\n\ - adds r0, r5\n\ - ldrb r2, [r0]\n\ - lsls r2, 8\n\ - adds r1, 0x2\n\ - adds r1, r5\n\ - ldrb r0, [r1]\n\ - adds r0, r2\n\ - strh r0, [r3]\n\ - adds r0, r4, 0x1\n\ - lsls r0, 24\n\ - lsrs r4, r0, 24\n\ - cmp r4, 0x7\n\ - bls _080B9050\n\ - lsls r0, r7, 24\n\ - lsrs r0, 24\n\ - cmp r0, 0x59\n\ - bls _080B904A\n\ - mov r0, r8\n\ - pop {r3}\n\ - mov r8, r3\n\ - pop {r4-r7}\n\ - pop {r1}\n\ - bx r1\n\ - .pool"); + lsls r1, r4, 2\n\ + adds r1, r6, r1\n\ + ldr r0, =0x06008020\n\ + adds r3, r1, r0\n\ + adds r0, r1, 0x1\n\ + adds r0, r5\n\ + ldrb r2, [r0]\n\ + lsls r2, 8\n\ + adds r0, r1, r5\n\ + ldrb r0, [r0]\n\ + adds r0, r2\n\ + strh r0, [r3]\n\ + ldr r0, =0x06008022\n\ + adds r3, r1, r0\n\ + adds r0, r1, 0x3\n\ + adds r0, r5\n\ + ldrb r2, [r0]\n\ + lsls r2, 8\n\ + adds r1, 0x2\n\ + adds r1, r5\n\ + ldrb r0, [r1]\n\ + adds r0, r2\n\ + strh r0, [r3]\n\ + adds r0, r4, 0x1\n\ + lsls r0, 24\n\ + lsrs r4, r0, 24\n\ + cmp r4, 0x7\n\ + bls _080B9050\n\ + lsls r0, r7, 24\n\ + lsrs r0, 24\n\ + cmp r0, 0x59\n\ + bls _080B904A\n\ + mov r0, r8\n\ + pop {r3}\n\ + mov r8, r3\n\ + pop {r4-r7}\n\ + pop {r1}\n\ + bx r1\n\ + .pool"); } #endif // NONMATCHING diff --git a/src/field_effect_helpers.c b/src/field_effect_helpers.c index 856f7d5ef..1f90c02b9 100755 --- a/src/field_effect_helpers.c +++ b/src/field_effect_helpers.c @@ -142,7 +142,7 @@ static void UpdateObjectReflectionSprite(struct Sprite *reflectionSprite) reflectionSprite->pos2.x = mainSprite->pos2.x; reflectionSprite->pos2.y = -mainSprite->pos2.y; reflectionSprite->coordOffsetEnabled = mainSprite->coordOffsetEnabled; - + if (eventObject->unk3_3 == TRUE) reflectionSprite->invisible = TRUE; @@ -1022,19 +1022,19 @@ static void SynchroniseSurfAnim(struct EventObject *eventObject, struct Sprite * StartSpriteAnimIfDifferent(sprite, surfBlobDirectionAnims[eventObject->movementDirection]); } -#ifdef NONMATCHING void sub_81556E8(struct EventObject *eventObject, struct Sprite *sprite) { - s16 x; - s16 y; u8 i; + s16 x = eventObject->currentCoords.x; + s16 y = eventObject->currentCoords.y; + s32 spriteY = sprite->pos2.y; - x = eventObject->currentCoords.x; - y = eventObject->currentCoords.y; - if (sprite->pos2.y == 0 && (x != sprite->data[6] || y != sprite->data[7])) + if (spriteY == 0 && (x != sprite->data[6] || y != sprite->data[7])) { - sprite->data[5] = sprite->pos2.y; - for (sprite->data[6] = x, sprite->data[7] = y, i = DIR_SOUTH; i <= DIR_EAST; i ++, x = sprite->data[6], y = sprite->data[7]) + sprite->data[5] = spriteY; + sprite->data[6] = x; + sprite->data[7] = y; + for (i = DIR_SOUTH; i <= DIR_EAST; i++, x = sprite->data[6], y = sprite->data[7]) { MoveCoords(i, &x, &y); if (MapGridGetZCoordAt(x, y) == 3) @@ -1045,87 +1045,6 @@ void sub_81556E8(struct EventObject *eventObject, struct Sprite *sprite) } } } -#else -NAKED void sub_81556E8(struct EventObject *eventObject, struct Sprite *sprite) -{ - asm_unified("push {r4-r7,lr}\n\ - mov r7, r8\n\ - push {r7}\n\ - sub sp, 0x4\n\ - adds r4, r1, 0\n\ - ldrh r2, [r0, 0x10]\n\ - mov r1, sp\n\ - strh r2, [r1]\n\ - ldrh r1, [r0, 0x12]\n\ - mov r0, sp\n\ - adds r0, 0x2\n\ - strh r1, [r0]\n\ - movs r2, 0x26\n\ - ldrsh r3, [r4, r2]\n\ - mov r8, r0\n\ - cmp r3, 0\n\ - bne _08155770\n\ - mov r0, sp\n\ - movs r5, 0\n\ - ldrsh r2, [r0, r5]\n\ - movs r5, 0x3A\n\ - ldrsh r0, [r4, r5]\n\ - cmp r2, r0\n\ - bne _08155724\n\ - lsls r0, r1, 16\n\ - asrs r0, 16\n\ - movs r5, 0x3C\n\ - ldrsh r1, [r4, r5]\n\ - cmp r0, r1\n\ - beq _08155770\n\ -_08155724:\n\ - strh r3, [r4, 0x38]\n\ - strh r2, [r4, 0x3A]\n\ - mov r1, r8\n\ - movs r2, 0\n\ - ldrsh r0, [r1, r2]\n\ - strh r0, [r4, 0x3C]\n\ - movs r5, 0x1\n\ - mov r7, r8\n\ - mov r6, sp\n\ -_08155736:\n\ - adds r0, r5, 0\n\ - mov r1, sp\n\ - adds r2, r7, 0\n\ - bl MoveCoords\n\ - movs r1, 0\n\ - ldrsh r0, [r6, r1]\n\ - movs r2, 0\n\ - ldrsh r1, [r7, r2]\n\ - bl MapGridGetZCoordAt\n\ - lsls r0, 24\n\ - lsrs r0, 24\n\ - cmp r0, 0x3\n\ - bne _0815575C\n\ - ldrh r0, [r4, 0x38]\n\ - adds r0, 0x1\n\ - strh r0, [r4, 0x38]\n\ - b _08155770\n\ -_0815575C:\n\ - adds r0, r5, 0x1\n\ - lsls r0, 24\n\ - lsrs r5, r0, 24\n\ - ldrh r0, [r4, 0x3A]\n\ - strh r0, [r6]\n\ - ldrh r0, [r4, 0x3C]\n\ - mov r1, r8\n\ - strh r0, [r1]\n\ - cmp r5, 0x4\n\ - bls _08155736\n\ -_08155770:\n\ - add sp, 0x4\n\ - pop {r3}\n\ - mov r8, r3\n\ - pop {r4-r7}\n\ - pop {r0}\n\ - bx r0"); -} -#endif static void CreateBobbingEffect(struct EventObject *eventObject, struct Sprite *linkedSprite, struct Sprite *sprite) { @@ -1450,7 +1369,7 @@ void sub_8155EA0(struct Sprite *sprite) bool8 sub_8155EA8(struct Sprite *sprite) { bool8 returnBool = FALSE; - + switch (sprite->data[7]) { case 0: @@ -1470,7 +1389,7 @@ bool8 sub_8155EA8(struct Sprite *sprite) sprite->pos2.y += sub_8097728(0x47 - sprite->data[6]); break; } - + SetGpuReg(REG_OFFSET_BG0HOFS, -sprite->pos2.x); if (++sprite->data[6] == 72) { @@ -1483,14 +1402,14 @@ bool8 sub_8155EA8(struct Sprite *sprite) sprite->pos2.x = 0; returnBool = TRUE; } - + return returnBool; } void sub_8155F80(struct Sprite *sprite) { u8 i, j; - + switch (sprite->data[2]) { case 0: @@ -1594,7 +1513,7 @@ void sub_8155F80(struct Sprite *sprite) FieldEffectStop(sprite, FLDEFF_64); break; } - + if (sprite->data[2] == 1) { if ((sprite->data[1] & 7) == 0) @@ -1603,7 +1522,7 @@ void sub_8155F80(struct Sprite *sprite) sprite->data[3] = -sprite->data[3]; sprite->data[1]++; } - + sprite->data[0]++; } @@ -1676,102 +1595,102 @@ static void sub_81561FC(struct Sprite *sprite /*r6*/, u8 z, u8 offset) NAKED void sub_81561FC(struct Sprite *sprite /*r6*/, u8 z, u8 offset) { asm_unified("push {r4-r7,lr}\n\ - adds r6, r0, 0\n\ - adds r0, r1, 0\n\ - lsls r0, 24\n\ - lsrs r0, 24\n\ - lsls r2, 24\n\ - lsrs r2, 24\n\ - adds r1, r6, 0\n\ - bl SetObjectSubpriorityByZCoord\n\ - movs r7, 0\n\ + adds r6, r0, 0\n\ + adds r0, r1, 0\n\ + lsls r0, 24\n\ + lsrs r0, 24\n\ + lsls r2, 24\n\ + lsrs r2, 24\n\ + adds r1, r6, 0\n\ + bl SetObjectSubpriorityByZCoord\n\ + movs r7, 0\n\ _08156212:\n\ - lsls r0, r7, 3\n\ - adds r0, r7\n\ - lsls r0, 2\n\ - ldr r1, =gEventObjects\n\ - adds r4, r0, r1\n\ - ldrb r0, [r4]\n\ - lsls r0, 31\n\ - cmp r0, 0\n\ - beq _081562B4\n\ - ldrb r0, [r4, 0x5]\n\ - bl GetEventObjectGraphicsInfo\n\ - ldrb r1, [r4, 0x4]\n\ - lsls r0, r1, 4\n\ - adds r0, r1\n\ - lsls r0, 2\n\ - ldr r1, =gSprites\n\ - adds r5, r0, r1\n\ - adds r0, r6, 0\n\ - adds r0, 0x28\n\ - movs r2, 0\n\ - ldrsb r2, [r0, r2]\n\ - ldrh r0, [r6, 0x20]\n\ - adds r1, r0, r2\n\ - subs r0, r2\n\ - lsls r0, 16\n\ - lsrs r4, r0, 16\n\ - lsls r1, 16\n\ - asrs r1, 16\n\ - movs r0, 0x20\n\ - ldrsh r2, [r5, r0]\n\ - cmp r1, r2\n\ - bge _081562B4\n\ - lsls r0, r4, 16\n\ - asrs r0, 16\n\ - cmp r0, r2\n\ - ble _081562B4\n\ - adds r0, r5, 0\n\ - adds r0, 0x29\n\ - movs r3, 0\n\ - ldrsb r3, [r0, r3]\n\ - ldrh r2, [r5, 0x22]\n\ - adds r2, r3\n\ - ldrh r4, [r5, 0x22]\n\ - adds r0, r6, 0\n\ - adds r0, 0x29\n\ - movs r1, 0\n\ - ldrsb r1, [r0, r1]\n\ - ldrh r0, [r6, 0x22]\n\ - subs r0, r1\n\ - lsls r0, 16\n\ - asrs r0, 16\n\ - adds r3, r0, r3\n\ - lsls r2, 16\n\ - asrs r2, 16\n\ - lsls r3, 16\n\ - asrs r3, 16\n\ - cmp r2, r3\n\ - blt _0815628C\n\ - cmp r2, r0\n\ - bge _081562B4\n\ + lsls r0, r7, 3\n\ + adds r0, r7\n\ + lsls r0, 2\n\ + ldr r1, =gEventObjects\n\ + adds r4, r0, r1\n\ + ldrb r0, [r4]\n\ + lsls r0, 31\n\ + cmp r0, 0\n\ + beq _081562B4\n\ + ldrb r0, [r4, 0x5]\n\ + bl GetEventObjectGraphicsInfo\n\ + ldrb r1, [r4, 0x4]\n\ + lsls r0, r1, 4\n\ + adds r0, r1\n\ + lsls r0, 2\n\ + ldr r1, =gSprites\n\ + adds r5, r0, r1\n\ + adds r0, r6, 0\n\ + adds r0, 0x28\n\ + movs r2, 0\n\ + ldrsb r2, [r0, r2]\n\ + ldrh r0, [r6, 0x20]\n\ + adds r1, r0, r2\n\ + subs r0, r2\n\ + lsls r0, 16\n\ + lsrs r4, r0, 16\n\ + lsls r1, 16\n\ + asrs r1, 16\n\ + movs r0, 0x20\n\ + ldrsh r2, [r5, r0]\n\ + cmp r1, r2\n\ + bge _081562B4\n\ + lsls r0, r4, 16\n\ + asrs r0, 16\n\ + cmp r0, r2\n\ + ble _081562B4\n\ + adds r0, r5, 0\n\ + adds r0, 0x29\n\ + movs r3, 0\n\ + ldrsb r3, [r0, r3]\n\ + ldrh r2, [r5, 0x22]\n\ + adds r2, r3\n\ + ldrh r4, [r5, 0x22]\n\ + adds r0, r6, 0\n\ + adds r0, 0x29\n\ + movs r1, 0\n\ + ldrsb r1, [r0, r1]\n\ + ldrh r0, [r6, 0x22]\n\ + subs r0, r1\n\ + lsls r0, 16\n\ + asrs r0, 16\n\ + adds r3, r0, r3\n\ + lsls r2, 16\n\ + asrs r2, 16\n\ + lsls r3, 16\n\ + asrs r3, 16\n\ + cmp r2, r3\n\ + blt _0815628C\n\ + cmp r2, r0\n\ + bge _081562B4\n\ _0815628C:\n\ - lsls r0, r4, 16\n\ - asrs r0, 16\n\ - cmp r0, r3\n\ - ble _081562B4\n\ - adds r2, r6, 0\n\ - adds r2, 0x43\n\ - adds r0, r5, 0\n\ - adds r0, 0x43\n\ - ldrb r1, [r0]\n\ - ldrb r0, [r2]\n\ - cmp r0, r1\n\ - bhi _081562B4\n\ - adds r0, r1, 0x2\n\ - strb r0, [r2]\n\ - b _081562BE\n\ - .pool\n\ + lsls r0, r4, 16\n\ + asrs r0, 16\n\ + cmp r0, r3\n\ + ble _081562B4\n\ + adds r2, r6, 0\n\ + adds r2, 0x43\n\ + adds r0, r5, 0\n\ + adds r0, 0x43\n\ + ldrb r1, [r0]\n\ + ldrb r0, [r2]\n\ + cmp r0, r1\n\ + bhi _081562B4\n\ + adds r0, r1, 0x2\n\ + strb r0, [r2]\n\ + b _081562BE\n\ + .pool\n\ _081562B4:\n\ - adds r0, r7, 0x1\n\ - lsls r0, 24\n\ - lsrs r7, r0, 24\n\ - cmp r7, 0xF\n\ - bls _08156212\n\ + adds r0, r7, 0x1\n\ + lsls r0, 24\n\ + lsrs r7, r0, 24\n\ + cmp r7, 0xF\n\ + bls _08156212\n\ _081562BE:\n\ - pop {r4-r7}\n\ - pop {r0}\n\ - bx r0"); + pop {r4-r7}\n\ + pop {r0}\n\ + bx r0"); } #endif diff --git a/src/frontier_util.c b/src/frontier_util.c index 5260585d7..a35088f6f 100644 --- a/src/frontier_util.c +++ b/src/frontier_util.c @@ -111,397 +111,397 @@ static const struct FrontierBrainMon sFrontierBrainsMons[][2][3] = // Silver Symbol. { { - .species = SPECIES_ALAKAZAM, - .heldItem = ITEM_BRIGHT_POWDER, - .fixedIV = 24, - .nature = 15, - .evs = {106, 0, 152, 152, 100, 0}, - .moves = {MOVE_THUNDER_PUNCH, MOVE_FIRE_PUNCH, MOVE_ICE_PUNCH, MOVE_DISABLE}, + .species = SPECIES_ALAKAZAM, + .heldItem = ITEM_BRIGHT_POWDER, + .fixedIV = 24, + .nature = 15, + .evs = {106, 0, 152, 152, 100, 0}, + .moves = {MOVE_THUNDER_PUNCH, MOVE_FIRE_PUNCH, MOVE_ICE_PUNCH, MOVE_DISABLE}, }, { - .species = SPECIES_ENTEI, - .heldItem = ITEM_LUM_BERRY, - .fixedIV = 24, - .nature = 1, - .evs = {100, 152, 152, 0, 100, 6}, - .moves = {MOVE_FIRE_BLAST, MOVE_CALM_MIND, MOVE_RETURN, MOVE_ROAR}, + .species = SPECIES_ENTEI, + .heldItem = ITEM_LUM_BERRY, + .fixedIV = 24, + .nature = 1, + .evs = {100, 152, 152, 0, 100, 6}, + .moves = {MOVE_FIRE_BLAST, MOVE_CALM_MIND, MOVE_RETURN, MOVE_ROAR}, }, { - .species = SPECIES_SNORLAX, - .heldItem = ITEM_QUICK_CLAW, - .fixedIV = 24, - .nature = 3, - .evs = {152, 152, 0, 0, 106, 100}, - .moves = {MOVE_BODY_SLAM, MOVE_BELLY_DRUM, MOVE_YAWN, MOVE_SHADOW_BALL}, + .species = SPECIES_SNORLAX, + .heldItem = ITEM_QUICK_CLAW, + .fixedIV = 24, + .nature = 3, + .evs = {152, 152, 0, 0, 106, 100}, + .moves = {MOVE_BODY_SLAM, MOVE_BELLY_DRUM, MOVE_YAWN, MOVE_SHADOW_BALL}, }, }, // Gold Symbol. { { - .species = SPECIES_RAIKOU, - .heldItem = ITEM_LUM_BERRY, - .fixedIV = 31, - .nature = 15, - .evs = {158, 0, 252, 100, 0, 0}, - .moves = {MOVE_THUNDERBOLT, MOVE_CALM_MIND, MOVE_REFLECT, MOVE_REST}, + .species = SPECIES_RAIKOU, + .heldItem = ITEM_LUM_BERRY, + .fixedIV = 31, + .nature = 15, + .evs = {158, 0, 252, 100, 0, 0}, + .moves = {MOVE_THUNDERBOLT, MOVE_CALM_MIND, MOVE_REFLECT, MOVE_REST}, }, { - .species = SPECIES_LATIOS, - .heldItem = ITEM_BRIGHT_POWDER, - .fixedIV = 31, - .nature = 15, - .evs = {252, 0, 252, 6, 0, 0}, - .moves = {MOVE_PSYCHIC, MOVE_CALM_MIND, MOVE_RECOVER, MOVE_DRAGON_CLAW}, + .species = SPECIES_LATIOS, + .heldItem = ITEM_BRIGHT_POWDER, + .fixedIV = 31, + .nature = 15, + .evs = {252, 0, 252, 6, 0, 0}, + .moves = {MOVE_PSYCHIC, MOVE_CALM_MIND, MOVE_RECOVER, MOVE_DRAGON_CLAW}, }, { - .species = SPECIES_SNORLAX, - .heldItem = ITEM_CHESTO_BERRY, - .fixedIV = 31, - .nature = 3, - .evs = {252, 252, 0, 0, 6, 0}, - .moves = {MOVE_CURSE, MOVE_RETURN, MOVE_REST, MOVE_SHADOW_BALL}, + .species = SPECIES_SNORLAX, + .heldItem = ITEM_CHESTO_BERRY, + .fixedIV = 31, + .nature = 3, + .evs = {252, 252, 0, 0, 6, 0}, + .moves = {MOVE_CURSE, MOVE_RETURN, MOVE_REST, MOVE_SHADOW_BALL}, }, }, }, - [FRONTIER_FACILITY_DOME] = - { + [FRONTIER_FACILITY_DOME] = + { // Silver Symbol. { { - .species = SPECIES_SWAMPERT, - .heldItem = ITEM_FOCUS_BAND, - .fixedIV = 20, - .nature = 2, - .evs = {152, 152, 106, 0, 100, 0}, - .moves = {MOVE_SURF, MOVE_EARTHQUAKE, MOVE_ICE_BEAM, MOVE_COUNTER}, + .species = SPECIES_SWAMPERT, + .heldItem = ITEM_FOCUS_BAND, + .fixedIV = 20, + .nature = 2, + .evs = {152, 152, 106, 0, 100, 0}, + .moves = {MOVE_SURF, MOVE_EARTHQUAKE, MOVE_ICE_BEAM, MOVE_COUNTER}, }, { - .species = SPECIES_SALAMENCE, - .heldItem = ITEM_LUM_BERRY, - .fixedIV = 20, - .nature = 3, - .evs = {152, 152, 106, 100, 0, 0}, - .moves = {MOVE_EARTHQUAKE, MOVE_BRICK_BREAK, MOVE_DRAGON_CLAW, MOVE_AERIAL_ACE}, + .species = SPECIES_SALAMENCE, + .heldItem = ITEM_LUM_BERRY, + .fixedIV = 20, + .nature = 3, + .evs = {152, 152, 106, 100, 0, 0}, + .moves = {MOVE_EARTHQUAKE, MOVE_BRICK_BREAK, MOVE_DRAGON_CLAW, MOVE_AERIAL_ACE}, }, { - .species = SPECIES_CHARIZARD, - .heldItem = ITEM_WHITE_HERB, - .fixedIV = 20, - .nature = 17, - .evs = {100, 152, 106, 152, 0, 0}, - .moves = {MOVE_OVERHEAT, MOVE_ROCK_SLIDE, MOVE_AERIAL_ACE, MOVE_EARTHQUAKE}, + .species = SPECIES_CHARIZARD, + .heldItem = ITEM_WHITE_HERB, + .fixedIV = 20, + .nature = 17, + .evs = {100, 152, 106, 152, 0, 0}, + .moves = {MOVE_OVERHEAT, MOVE_ROCK_SLIDE, MOVE_AERIAL_ACE, MOVE_EARTHQUAKE}, }, }, // Gold Symbol. { { - .species = SPECIES_SWAMPERT, - .heldItem = ITEM_LEFTOVERS, - .fixedIV = 31, - .nature = 2, - .evs = {252, 252, 6, 0, 0, 0}, - .moves = {MOVE_SURF, MOVE_EARTHQUAKE, MOVE_ICE_BEAM, MOVE_MIRROR_COAT}, + .species = SPECIES_SWAMPERT, + .heldItem = ITEM_LEFTOVERS, + .fixedIV = 31, + .nature = 2, + .evs = {252, 252, 6, 0, 0, 0}, + .moves = {MOVE_SURF, MOVE_EARTHQUAKE, MOVE_ICE_BEAM, MOVE_MIRROR_COAT}, }, { - .species = SPECIES_METAGROSS, - .heldItem = ITEM_QUICK_CLAW, - .fixedIV = 31, - .nature = 2, - .evs = {252, 252, 6, 0, 0, 0}, - .moves = {MOVE_PSYCHIC, MOVE_METEOR_MASH, MOVE_EARTHQUAKE, MOVE_PROTECT}, + .species = SPECIES_METAGROSS, + .heldItem = ITEM_QUICK_CLAW, + .fixedIV = 31, + .nature = 2, + .evs = {252, 252, 6, 0, 0, 0}, + .moves = {MOVE_PSYCHIC, MOVE_METEOR_MASH, MOVE_EARTHQUAKE, MOVE_PROTECT}, }, { - .species = SPECIES_LATIAS, - .heldItem = ITEM_CHESTO_BERRY, - .fixedIV = 31, - .nature = 15, - .evs = {252, 0, 252, 6, 0, 0}, - .moves = {MOVE_THUNDERBOLT, MOVE_PSYCHIC, MOVE_CALM_MIND, MOVE_REST}, + .species = SPECIES_LATIAS, + .heldItem = ITEM_CHESTO_BERRY, + .fixedIV = 31, + .nature = 15, + .evs = {252, 0, 252, 6, 0, 0}, + .moves = {MOVE_THUNDERBOLT, MOVE_PSYCHIC, MOVE_CALM_MIND, MOVE_REST}, }, }, }, - [FRONTIER_FACILITY_PALACE] = - { + [FRONTIER_FACILITY_PALACE] = + { // Silver Symbol. { { - .species = SPECIES_CROBAT, - .heldItem = ITEM_BRIGHT_POWDER, - .fixedIV = 16, - .nature = 3, - .evs = {152, 0, 0, 152, 100, 106}, - .moves = {MOVE_CONFUSE_RAY, MOVE_DOUBLE_TEAM, MOVE_TOXIC, MOVE_FLY}, + .species = SPECIES_CROBAT, + .heldItem = ITEM_BRIGHT_POWDER, + .fixedIV = 16, + .nature = 3, + .evs = {152, 0, 0, 152, 100, 106}, + .moves = {MOVE_CONFUSE_RAY, MOVE_DOUBLE_TEAM, MOVE_TOXIC, MOVE_FLY}, }, { - .species = SPECIES_SLAKING, - .heldItem = ITEM_SCOPE_LENS, - .fixedIV = 16, - .nature = 0, - .evs = {152, 152, 0, 106, 100, 0}, - .moves = {MOVE_EARTHQUAKE, MOVE_SWAGGER, MOVE_SHADOW_BALL, MOVE_BRICK_BREAK}, + .species = SPECIES_SLAKING, + .heldItem = ITEM_SCOPE_LENS, + .fixedIV = 16, + .nature = 0, + .evs = {152, 152, 0, 106, 100, 0}, + .moves = {MOVE_EARTHQUAKE, MOVE_SWAGGER, MOVE_SHADOW_BALL, MOVE_BRICK_BREAK}, }, { - .species = SPECIES_LAPRAS, - .heldItem = ITEM_QUICK_CLAW, - .fixedIV = 16, - .nature = 17, - .evs = {0, 0, 252, 0, 106, 152}, - .moves = {MOVE_ICE_BEAM, MOVE_HORN_DRILL, MOVE_CONFUSE_RAY, MOVE_PROTECT}, + .species = SPECIES_LAPRAS, + .heldItem = ITEM_QUICK_CLAW, + .fixedIV = 16, + .nature = 17, + .evs = {0, 0, 252, 0, 106, 152}, + .moves = {MOVE_ICE_BEAM, MOVE_HORN_DRILL, MOVE_CONFUSE_RAY, MOVE_PROTECT}, }, }, // Gold Symbol. { { - .species = SPECIES_ARCANINE, - .heldItem = ITEM_WHITE_HERB, - .fixedIV = 31, - .nature = 11, - .evs = {6, 252, 252, 0, 0, 0}, - .moves = {MOVE_OVERHEAT, MOVE_EXTREME_SPEED, MOVE_ROAR, MOVE_PROTECT}, + .species = SPECIES_ARCANINE, + .heldItem = ITEM_WHITE_HERB, + .fixedIV = 31, + .nature = 11, + .evs = {6, 252, 252, 0, 0, 0}, + .moves = {MOVE_OVERHEAT, MOVE_EXTREME_SPEED, MOVE_ROAR, MOVE_PROTECT}, }, { - .species = SPECIES_SLAKING, - .heldItem = ITEM_SCOPE_LENS, - .fixedIV = 31, - .nature = 0, - .evs = {6, 252, 0, 252, 0, 0}, - .moves = {MOVE_HYPER_BEAM, MOVE_EARTHQUAKE, MOVE_SHADOW_BALL, MOVE_YAWN}, + .species = SPECIES_SLAKING, + .heldItem = ITEM_SCOPE_LENS, + .fixedIV = 31, + .nature = 0, + .evs = {6, 252, 0, 252, 0, 0}, + .moves = {MOVE_HYPER_BEAM, MOVE_EARTHQUAKE, MOVE_SHADOW_BALL, MOVE_YAWN}, }, { - .species = SPECIES_SUICUNE, - .heldItem = ITEM_KINGS_ROCK, - .fixedIV = 31, - .nature = 11, - .evs = {252, 0, 252, 6, 0, 0}, - .moves = {MOVE_BLIZZARD, MOVE_SURF, MOVE_BITE, MOVE_CALM_MIND}, + .species = SPECIES_SUICUNE, + .heldItem = ITEM_KINGS_ROCK, + .fixedIV = 31, + .nature = 11, + .evs = {252, 0, 252, 6, 0, 0}, + .moves = {MOVE_BLIZZARD, MOVE_SURF, MOVE_BITE, MOVE_CALM_MIND}, }, }, }, - [FRONTIER_FACILITY_ARENA] = - { + [FRONTIER_FACILITY_ARENA] = + { // Silver Symbol. { { - .species = SPECIES_HERACROSS, - .heldItem = ITEM_SALAC_BERRY, - .fixedIV = 20, - .nature = 13, - .evs = {106, 152, 0, 152, 0, 100}, - .moves = {MOVE_MEGAHORN, MOVE_ROCK_TOMB, MOVE_ENDURE, MOVE_REVERSAL}, + .species = SPECIES_HERACROSS, + .heldItem = ITEM_SALAC_BERRY, + .fixedIV = 20, + .nature = 13, + .evs = {106, 152, 0, 152, 0, 100}, + .moves = {MOVE_MEGAHORN, MOVE_ROCK_TOMB, MOVE_ENDURE, MOVE_REVERSAL}, }, { - .species = SPECIES_UMBREON, - .heldItem = ITEM_LEFTOVERS, - .fixedIV = 20, - .nature = 20, - .evs = {152, 0, 100, 0, 152, 106}, - .moves = {MOVE_BODY_SLAM, MOVE_CONFUSE_RAY, MOVE_PSYCHIC, MOVE_FAINT_ATTACK}, + .species = SPECIES_UMBREON, + .heldItem = ITEM_LEFTOVERS, + .fixedIV = 20, + .nature = 20, + .evs = {152, 0, 100, 0, 152, 106}, + .moves = {MOVE_BODY_SLAM, MOVE_CONFUSE_RAY, MOVE_PSYCHIC, MOVE_FAINT_ATTACK}, }, { - .species = SPECIES_SHEDINJA, - .heldItem = ITEM_BRIGHT_POWDER, - .fixedIV = 20, - .nature = 3, - .evs = {0, 252, 6, 252, 0, 0}, - .moves = {MOVE_SHADOW_BALL, MOVE_RETURN, MOVE_CONFUSE_RAY, MOVE_AERIAL_ACE}, + .species = SPECIES_SHEDINJA, + .heldItem = ITEM_BRIGHT_POWDER, + .fixedIV = 20, + .nature = 3, + .evs = {0, 252, 6, 252, 0, 0}, + .moves = {MOVE_SHADOW_BALL, MOVE_RETURN, MOVE_CONFUSE_RAY, MOVE_AERIAL_ACE}, }, }, // Gold Symbol. { { - .species = SPECIES_UMBREON, - .heldItem = ITEM_CHESTO_BERRY, - .fixedIV = 31, - .nature = 20, - .evs = {252, 0, 0, 0, 252, 6}, - .moves = {MOVE_DOUBLE_EDGE, MOVE_CONFUSE_RAY, MOVE_REST, MOVE_PSYCHIC}, + .species = SPECIES_UMBREON, + .heldItem = ITEM_CHESTO_BERRY, + .fixedIV = 31, + .nature = 20, + .evs = {252, 0, 0, 0, 252, 6}, + .moves = {MOVE_DOUBLE_EDGE, MOVE_CONFUSE_RAY, MOVE_REST, MOVE_PSYCHIC}, }, { - .species = SPECIES_GENGAR, - .heldItem = ITEM_LEFTOVERS, - .fixedIV = 31, - .nature = 15, - .evs = {252, 0, 252, 0, 6, 0}, - .moves = {MOVE_PSYCHIC, MOVE_HYPNOSIS, MOVE_DREAM_EATER, MOVE_DESTINY_BOND}, + .species = SPECIES_GENGAR, + .heldItem = ITEM_LEFTOVERS, + .fixedIV = 31, + .nature = 15, + .evs = {252, 0, 252, 0, 6, 0}, + .moves = {MOVE_PSYCHIC, MOVE_HYPNOSIS, MOVE_DREAM_EATER, MOVE_DESTINY_BOND}, }, { - .species = SPECIES_BRELOOM, - .heldItem = ITEM_LUM_BERRY, - .fixedIV = 31, - .nature = 13, - .evs = {6, 252, 0, 252, 0, 0}, - .moves = {MOVE_SPORE, MOVE_FOCUS_PUNCH, MOVE_GIGA_DRAIN, MOVE_HEADBUTT}, + .species = SPECIES_BRELOOM, + .heldItem = ITEM_LUM_BERRY, + .fixedIV = 31, + .nature = 13, + .evs = {6, 252, 0, 252, 0, 0}, + .moves = {MOVE_SPORE, MOVE_FOCUS_PUNCH, MOVE_GIGA_DRAIN, MOVE_HEADBUTT}, }, }, }, - [FRONTIER_FACILITY_FACTORY] = - { + [FRONTIER_FACILITY_FACTORY] = + { // Because Factory's pokemon are random, this facility's Brain also uses random pokemon. // What is interesting, this team is actually the one Steven uses in the multi tag battle alongside the player. { { - .species = SPECIES_METANG, - .heldItem = ITEM_SITRUS_BERRY, - .fixedIV = 31, - .nature = 2, - .evs = {0, 252, 252, 0, 6, 0}, - .moves = {MOVE_LIGHT_SCREEN, MOVE_PSYCHIC, MOVE_REFLECT, MOVE_METAL_CLAW}, + .species = SPECIES_METANG, + .heldItem = ITEM_SITRUS_BERRY, + .fixedIV = 31, + .nature = 2, + .evs = {0, 252, 252, 0, 6, 0}, + .moves = {MOVE_LIGHT_SCREEN, MOVE_PSYCHIC, MOVE_REFLECT, MOVE_METAL_CLAW}, }, { - .species = SPECIES_SKARMORY, - .heldItem = ITEM_SITRUS_BERRY, - .fixedIV = 31, - .nature = 8, - .evs = {252, 0, 0, 0, 6, 252}, - .moves = {MOVE_TOXIC, MOVE_AERIAL_ACE, MOVE_PROTECT, MOVE_STEEL_WING}, + .species = SPECIES_SKARMORY, + .heldItem = ITEM_SITRUS_BERRY, + .fixedIV = 31, + .nature = 8, + .evs = {252, 0, 0, 0, 6, 252}, + .moves = {MOVE_TOXIC, MOVE_AERIAL_ACE, MOVE_PROTECT, MOVE_STEEL_WING}, }, { - .species = SPECIES_AGGRON, - .heldItem = ITEM_SITRUS_BERRY, - .fixedIV = 31, - .nature = 3, - .evs = {0, 252, 0, 0, 252, 6}, - .moves = {MOVE_THUNDERBOLT, MOVE_PROTECT, MOVE_SOLAR_BEAM, MOVE_DRAGON_CLAW}, + .species = SPECIES_AGGRON, + .heldItem = ITEM_SITRUS_BERRY, + .fixedIV = 31, + .nature = 3, + .evs = {0, 252, 0, 0, 252, 6}, + .moves = {MOVE_THUNDERBOLT, MOVE_PROTECT, MOVE_SOLAR_BEAM, MOVE_DRAGON_CLAW}, }, }, { { - .species = SPECIES_METANG, - .heldItem = ITEM_SITRUS_BERRY, - .fixedIV = 31, - .nature = 2, - .evs = {0, 252, 252, 0, 6, 0}, - .moves = {MOVE_LIGHT_SCREEN, MOVE_PSYCHIC, MOVE_REFLECT, MOVE_METAL_CLAW}, + .species = SPECIES_METANG, + .heldItem = ITEM_SITRUS_BERRY, + .fixedIV = 31, + .nature = 2, + .evs = {0, 252, 252, 0, 6, 0}, + .moves = {MOVE_LIGHT_SCREEN, MOVE_PSYCHIC, MOVE_REFLECT, MOVE_METAL_CLAW}, }, { - .species = SPECIES_SKARMORY, - .heldItem = ITEM_SITRUS_BERRY, - .fixedIV = 31, - .nature = 8, - .evs = {252, 0, 0, 0, 6, 252}, - .moves = {MOVE_TOXIC, MOVE_AERIAL_ACE, MOVE_PROTECT, MOVE_STEEL_WING}, + .species = SPECIES_SKARMORY, + .heldItem = ITEM_SITRUS_BERRY, + .fixedIV = 31, + .nature = 8, + .evs = {252, 0, 0, 0, 6, 252}, + .moves = {MOVE_TOXIC, MOVE_AERIAL_ACE, MOVE_PROTECT, MOVE_STEEL_WING}, }, { - .species = SPECIES_AGGRON, - .heldItem = ITEM_SITRUS_BERRY, - .fixedIV = 31, - .nature = 3, - .evs = {0, 252, 0, 0, 252, 6}, - .moves = {MOVE_THUNDERBOLT, MOVE_PROTECT, MOVE_SOLAR_BEAM, MOVE_DRAGON_CLAW}, + .species = SPECIES_AGGRON, + .heldItem = ITEM_SITRUS_BERRY, + .fixedIV = 31, + .nature = 3, + .evs = {0, 252, 0, 0, 252, 6}, + .moves = {MOVE_THUNDERBOLT, MOVE_PROTECT, MOVE_SOLAR_BEAM, MOVE_DRAGON_CLAW}, }, }, }, - [FRONTIER_FACILITY_PIKE] = - { + [FRONTIER_FACILITY_PIKE] = + { // Silver Symbol. { { - .species = SPECIES_SEVIPER, - .heldItem = ITEM_QUICK_CLAW, - .fixedIV = 16, - .nature = 2, - .evs = {252, 0, 252, 0, 6, 0}, - .moves = {MOVE_SWAGGER, MOVE_CRUNCH, MOVE_POISON_FANG, MOVE_GIGA_DRAIN}, + .species = SPECIES_SEVIPER, + .heldItem = ITEM_QUICK_CLAW, + .fixedIV = 16, + .nature = 2, + .evs = {252, 0, 252, 0, 6, 0}, + .moves = {MOVE_SWAGGER, MOVE_CRUNCH, MOVE_POISON_FANG, MOVE_GIGA_DRAIN}, }, { - .species = SPECIES_SHUCKLE, - .heldItem = ITEM_CHESTO_BERRY, - .fixedIV = 16, - .nature = 5, - .evs = {252, 0, 0, 0, 106, 252}, - .moves = {MOVE_TOXIC, MOVE_SANDSTORM, MOVE_PROTECT, MOVE_REST}, + .species = SPECIES_SHUCKLE, + .heldItem = ITEM_CHESTO_BERRY, + .fixedIV = 16, + .nature = 5, + .evs = {252, 0, 0, 0, 106, 252}, + .moves = {MOVE_TOXIC, MOVE_SANDSTORM, MOVE_PROTECT, MOVE_REST}, }, { - .species = SPECIES_MILOTIC, - .heldItem = ITEM_LEFTOVERS, - .fixedIV = 16, - .nature = 15, - .evs = {152, 0, 100, 0, 152, 106}, - .moves = {MOVE_ICE_BEAM, MOVE_MIRROR_COAT, MOVE_SURF, MOVE_RECOVER}, + .species = SPECIES_MILOTIC, + .heldItem = ITEM_LEFTOVERS, + .fixedIV = 16, + .nature = 15, + .evs = {152, 0, 100, 0, 152, 106}, + .moves = {MOVE_ICE_BEAM, MOVE_MIRROR_COAT, MOVE_SURF, MOVE_RECOVER}, }, }, // Gold Symbol. { { - .species = SPECIES_SEVIPER, - .heldItem = ITEM_FOCUS_BAND, - .fixedIV = 31, - .nature = 5, - .evs = {252, 0, 0, 0, 252, 6}, - .moves = {MOVE_SWAGGER, MOVE_CRUNCH, MOVE_SLUDGE_BOMB, MOVE_GIGA_DRAIN}, + .species = SPECIES_SEVIPER, + .heldItem = ITEM_FOCUS_BAND, + .fixedIV = 31, + .nature = 5, + .evs = {252, 0, 0, 0, 252, 6}, + .moves = {MOVE_SWAGGER, MOVE_CRUNCH, MOVE_SLUDGE_BOMB, MOVE_GIGA_DRAIN}, }, { - .species = SPECIES_STEELIX, - .heldItem = ITEM_BRIGHT_POWDER, - .fixedIV = 31, - .nature = 2, - .evs = {252, 0, 0, 0, 6, 252}, - .moves = {MOVE_EARTHQUAKE, MOVE_ROCK_SLIDE, MOVE_EXPLOSION, MOVE_SCREECH}, + .species = SPECIES_STEELIX, + .heldItem = ITEM_BRIGHT_POWDER, + .fixedIV = 31, + .nature = 2, + .evs = {252, 0, 0, 0, 6, 252}, + .moves = {MOVE_EARTHQUAKE, MOVE_ROCK_SLIDE, MOVE_EXPLOSION, MOVE_SCREECH}, }, { - .species = SPECIES_GYARADOS, - .heldItem = ITEM_CHESTO_BERRY, - .fixedIV = 31, - .nature = 3, - .evs = {252, 6, 0, 0, 0, 252}, - .moves = {MOVE_DRAGON_DANCE, MOVE_RETURN, MOVE_ROAR, MOVE_REST}, + .species = SPECIES_GYARADOS, + .heldItem = ITEM_CHESTO_BERRY, + .fixedIV = 31, + .nature = 3, + .evs = {252, 6, 0, 0, 0, 252}, + .moves = {MOVE_DRAGON_DANCE, MOVE_RETURN, MOVE_ROAR, MOVE_REST}, }, }, }, - [FRONTIER_FACILITY_PYRAMID] = - { + [FRONTIER_FACILITY_PYRAMID] = + { // Silver Symbol. { { - .species = SPECIES_REGIROCK, - .heldItem = ITEM_QUICK_CLAW, - .fixedIV = 16, - .nature = 3, - .evs = {152, 152, 0, 0, 106, 100}, - .moves = {MOVE_EXPLOSION, MOVE_SUPERPOWER, MOVE_EARTHQUAKE, MOVE_ANCIENT_POWER}, + .species = SPECIES_REGIROCK, + .heldItem = ITEM_QUICK_CLAW, + .fixedIV = 16, + .nature = 3, + .evs = {152, 152, 0, 0, 106, 100}, + .moves = {MOVE_EXPLOSION, MOVE_SUPERPOWER, MOVE_EARTHQUAKE, MOVE_ANCIENT_POWER}, }, { - .species = SPECIES_REGISTEEL, - .heldItem = ITEM_LEFTOVERS, - .fixedIV = 16, - .nature = 3, - .evs = {152, 152, 0, 0, 6, 200}, - .moves = {MOVE_EARTHQUAKE, MOVE_METAL_CLAW, MOVE_TOXIC, MOVE_IRON_DEFENSE}, + .species = SPECIES_REGISTEEL, + .heldItem = ITEM_LEFTOVERS, + .fixedIV = 16, + .nature = 3, + .evs = {152, 152, 0, 0, 6, 200}, + .moves = {MOVE_EARTHQUAKE, MOVE_METAL_CLAW, MOVE_TOXIC, MOVE_IRON_DEFENSE}, }, { - .species = SPECIES_REGICE, - .heldItem = ITEM_CHESTO_BERRY, - .fixedIV = 16, - .nature = 15, - .evs = {106, 0, 152, 0, 100, 152}, - .moves = {MOVE_ICE_BEAM, MOVE_AMNESIA, MOVE_THUNDER, MOVE_REST}, + .species = SPECIES_REGICE, + .heldItem = ITEM_CHESTO_BERRY, + .fixedIV = 16, + .nature = 15, + .evs = {106, 0, 152, 0, 100, 152}, + .moves = {MOVE_ICE_BEAM, MOVE_AMNESIA, MOVE_THUNDER, MOVE_REST}, }, }, // Gold Symbol. { { - .species = SPECIES_ARTICUNO, - .heldItem = ITEM_SCOPE_LENS, - .fixedIV = 31, - .nature = 16, - .evs = {6, 0, 252, 252, 0, 0}, - .moves = {MOVE_BLIZZARD, MOVE_WATER_PULSE, MOVE_AERIAL_ACE, MOVE_REFLECT}, + .species = SPECIES_ARTICUNO, + .heldItem = ITEM_SCOPE_LENS, + .fixedIV = 31, + .nature = 16, + .evs = {6, 0, 252, 252, 0, 0}, + .moves = {MOVE_BLIZZARD, MOVE_WATER_PULSE, MOVE_AERIAL_ACE, MOVE_REFLECT}, }, { - .species = SPECIES_ZAPDOS, - .heldItem = ITEM_LUM_BERRY, - .fixedIV = 31, - .nature = 16, - .evs = {6, 0, 252, 252, 0, 0}, - .moves = {MOVE_THUNDER, MOVE_DETECT, MOVE_DRILL_PECK, MOVE_LIGHT_SCREEN}, + .species = SPECIES_ZAPDOS, + .heldItem = ITEM_LUM_BERRY, + .fixedIV = 31, + .nature = 16, + .evs = {6, 0, 252, 252, 0, 0}, + .moves = {MOVE_THUNDER, MOVE_DETECT, MOVE_DRILL_PECK, MOVE_LIGHT_SCREEN}, }, { - .species = SPECIES_MOLTRES, - .heldItem = ITEM_BRIGHT_POWDER, - .fixedIV = 31, - .nature = 16, - .evs = {6, 0, 252, 252, 0, 0}, - .moves = {MOVE_FIRE_BLAST, MOVE_HYPER_BEAM, MOVE_AERIAL_ACE, MOVE_SAFEGUARD}, + .species = SPECIES_MOLTRES, + .heldItem = ITEM_BRIGHT_POWDER, + .fixedIV = 31, + .nature = 16, + .evs = {6, 0, 252, 252, 0, 0}, + .moves = {MOVE_FIRE_BLAST, MOVE_HYPER_BEAM, MOVE_AERIAL_ACE, MOVE_SAFEGUARD}, }, }, }, @@ -614,29 +614,29 @@ static const u16 gUnknown_08611BFC[][2] = static void (* const sFrontierUtilFuncs[])(void) = { - sub_81A17A0, - sub_81A1830, - sub_81A1968, - sub_81A1AD4, - DoSoftReset_, - sub_81A1B28, - sub_81A1B38, - ShowFacilityResultsWindow, - sub_81A31FC, - sub_81A35EC, - sub_81A3B00, - sub_81A3B64, - sub_81A3D30, - sub_81A3D58, - sub_81A3DA0, - sub_81A3FD4, - sub_81A4224, - sub_81A4230, - sub_81A43A8, - sub_81A4410, - sub_81A443C, - sub_81A447C, - sub_81A457C, + sub_81A17A0, + sub_81A1830, + sub_81A1968, + sub_81A1AD4, + DoSoftReset_, + sub_81A1B28, + sub_81A1B38, + ShowFacilityResultsWindow, + sub_81A31FC, + sub_81A35EC, + sub_81A3B00, + sub_81A3B64, + sub_81A3D30, + sub_81A3D58, + sub_81A3DA0, + sub_81A3FD4, + sub_81A4224, + sub_81A4230, + sub_81A43A8, + sub_81A4410, + sub_81A443C, + sub_81A447C, + sub_81A457C, }; static const struct WindowTemplate gUnknown_08611C74 = @@ -676,12 +676,12 @@ static const struct WindowTemplate gUnknown_08611C84 = static const u8 sFacilityToBrainEventObjGfx[][2] = { [FRONTIER_FACILITY_TOWER] = {EVENT_OBJ_GFX_ANABEL, TRUE}, - [FRONTIER_FACILITY_DOME] = {EVENT_OBJ_GFX_TUCKER, FALSE}, - [FRONTIER_FACILITY_PALACE] = {EVENT_OBJ_GFX_SPENSER, FALSE}, - [FRONTIER_FACILITY_ARENA] = {EVENT_OBJ_GFX_GRETA, TRUE}, - [FRONTIER_FACILITY_FACTORY] = {EVENT_OBJ_GFX_NOLAND, FALSE}, - [FRONTIER_FACILITY_PIKE] = {EVENT_OBJ_GFX_LUCY, TRUE}, - [FRONTIER_FACILITY_PYRAMID] = {EVENT_OBJ_GFX_BRANDON, FALSE}, + [FRONTIER_FACILITY_DOME] = {EVENT_OBJ_GFX_TUCKER, FALSE}, + [FRONTIER_FACILITY_PALACE] = {EVENT_OBJ_GFX_SPENSER, FALSE}, + [FRONTIER_FACILITY_ARENA] = {EVENT_OBJ_GFX_GRETA, TRUE}, + [FRONTIER_FACILITY_FACTORY] = {EVENT_OBJ_GFX_NOLAND, FALSE}, + [FRONTIER_FACILITY_PIKE] = {EVENT_OBJ_GFX_LUCY, TRUE}, + [FRONTIER_FACILITY_PYRAMID] = {EVENT_OBJ_GFX_BRANDON, FALSE}, }; const u16 gFrontierBannedSpecies[] = @@ -765,7 +765,7 @@ static void sub_81A1968(void) switch (gSpecialVar_0x8005) { - case 0: + case 0: gSaveBlock2Ptr->frontier.field_CA8 = gSpecialVar_0x8006; break; case 1: @@ -2434,235 +2434,235 @@ NAKED void CreateFrontierBrainPokemon(void) { asm_unified("\n\ - push {r4-r7,lr}\n\ - mov r7, r10\n\ - mov r6, r9\n\ - mov r5, r8\n\ - push {r5-r7}\n\ - sub sp, 0x44\n\ - ldr r0, =0x000040cf\n\ - bl VarGet\n\ - lsls r0, 16\n\ - lsrs r0, 16\n\ - str r0, [sp, 0x20]\n\ - bl GetFronterBrainSymbol\n\ - str r0, [sp, 0x24]\n\ - ldr r0, [sp, 0x20]\n\ - cmp r0, 0x1\n\ - bne _081A4E44\n\ - ldr r0, =0x000003fe\n\ - bl TrainerIdToDomeTournamentId\n\ - lsls r0, 16\n\ - lsrs r0, 16\n\ - bl GetDomeTrainerMonCountInBits\n\ - adds r4, r0, 0\n\ - b _081A4E46\n\ - .pool\n\ + push {r4-r7,lr}\n\ + mov r7, r10\n\ + mov r6, r9\n\ + mov r5, r8\n\ + push {r5-r7}\n\ + sub sp, 0x44\n\ + ldr r0, =0x000040cf\n\ + bl VarGet\n\ + lsls r0, 16\n\ + lsrs r0, 16\n\ + str r0, [sp, 0x20]\n\ + bl GetFronterBrainSymbol\n\ + str r0, [sp, 0x24]\n\ + ldr r0, [sp, 0x20]\n\ + cmp r0, 0x1\n\ + bne _081A4E44\n\ + ldr r0, =0x000003fe\n\ + bl TrainerIdToDomeTournamentId\n\ + lsls r0, 16\n\ + lsrs r0, 16\n\ + bl GetDomeTrainerMonCountInBits\n\ + adds r4, r0, 0\n\ + b _081A4E46\n\ + .pool\n\ _081A4E44:\n\ - movs r4, 0x7\n\ + movs r4, 0x7\n\ _081A4E46:\n\ - bl ZeroEnemyPartyMons\n\ - movs r1, 0\n\ - str r1, [sp, 0x18]\n\ - bl SetFacilityPtrsGetLevel\n\ - lsls r0, 24\n\ - lsrs r0, 24\n\ - str r0, [sp, 0x1C]\n\ - movs r2, 0\n\ - str r2, [sp, 0x14]\n\ + bl ZeroEnemyPartyMons\n\ + movs r1, 0\n\ + str r1, [sp, 0x18]\n\ + bl SetFacilityPtrsGetLevel\n\ + lsls r0, 24\n\ + lsrs r0, 24\n\ + str r0, [sp, 0x1C]\n\ + movs r2, 0\n\ + str r2, [sp, 0x14]\n\ _081A4E5C:\n\ - movs r0, 0x1\n\ - ands r0, r4\n\ - asrs r4, 1\n\ - str r4, [sp, 0x30]\n\ - ldr r3, [sp, 0x14]\n\ - adds r3, 0x1\n\ - str r3, [sp, 0x28]\n\ - cmp r0, 0\n\ - bne _081A4E70\n\ - b _081A4FC4\n\ + movs r0, 0x1\n\ + ands r0, r4\n\ + asrs r4, 1\n\ + str r4, [sp, 0x30]\n\ + ldr r3, [sp, 0x14]\n\ + adds r3, 0x1\n\ + str r3, [sp, 0x28]\n\ + cmp r0, 0\n\ + bne _081A4E70\n\ + b _081A4FC4\n\ _081A4E70:\n\ - ldr r4, [sp, 0x14]\n\ - lsls r4, 2\n\ - mov r9, r4\n\ - ldr r0, [sp, 0x24]\n\ - lsls r0, 4\n\ - str r0, [sp, 0x38]\n\ - ldr r1, [sp, 0x20]\n\ - lsls r1, 4\n\ - str r1, [sp, 0x34]\n\ - ldr r2, [sp, 0x1C]\n\ - lsls r2, 24\n\ - str r2, [sp, 0x3C]\n\ - ldr r3, [sp, 0x18]\n\ - adds r3, 0x1\n\ - str r3, [sp, 0x2C]\n\ - ldr r0, [sp, 0x14]\n\ - add r0, r9\n\ - lsls r0, 2\n\ - mov r8, r0\n\ + ldr r4, [sp, 0x14]\n\ + lsls r4, 2\n\ + mov r9, r4\n\ + ldr r0, [sp, 0x24]\n\ + lsls r0, 4\n\ + str r0, [sp, 0x38]\n\ + ldr r1, [sp, 0x20]\n\ + lsls r1, 4\n\ + str r1, [sp, 0x34]\n\ + ldr r2, [sp, 0x1C]\n\ + lsls r2, 24\n\ + str r2, [sp, 0x3C]\n\ + ldr r3, [sp, 0x18]\n\ + adds r3, 0x1\n\ + str r3, [sp, 0x2C]\n\ + ldr r0, [sp, 0x14]\n\ + add r0, r9\n\ + lsls r0, 2\n\ + mov r8, r0\n\ _081A4E96:\n\ - bl Random\n\ - adds r4, r0, 0\n\ - bl Random\n\ - lsls r4, 16\n\ - lsrs r7, r4, 16\n\ - lsls r0, 16\n\ - orrs r7, r0\n\ - ldr r0, =0x0000ef2a\n\ - adds r1, r7, 0\n\ - bl IsShinyOtIdPersonality\n\ - lsls r0, 24\n\ - cmp r0, 0\n\ - bne _081A4E96\n\ - ldr r4, [sp, 0x38]\n\ - ldr r1, [sp, 0x24]\n\ - subs r0, r4, r1\n\ - lsls r5, r0, 2\n\ - mov r2, r8\n\ - adds r4, r2, r5\n\ - ldr r3, [sp, 0x34]\n\ - ldr r1, [sp, 0x20]\n\ - subs r0, r3, r1\n\ - lsls r6, r0, 3\n\ - adds r4, r6\n\ - ldr r2, =sFrontierBrainsMons\n\ - adds r4, r2\n\ - adds r0, r7, 0\n\ - bl GetNatureFromPersonality\n\ - ldrb r1, [r4, 0x5]\n\ - lsls r0, 24\n\ - lsrs r0, 24\n\ - cmp r1, r0\n\ - bne _081A4E96\n\ - ldr r4, [sp, 0x18]\n\ - movs r0, 0x64\n\ - adds r3, r4, 0\n\ - muls r3, r0\n\ - mov r8, r3\n\ - ldr r1, =gEnemyParty\n\ - add r1, r8\n\ - mov r10, r1\n\ - ldr r4, [sp, 0x14]\n\ - add r4, r9\n\ - lsls r4, 2\n\ - adds r0, r4, r5\n\ - adds r0, r6\n\ - ldr r2, =sFrontierBrainsMons\n\ - adds r0, r2\n\ - ldrh r1, [r0]\n\ - ldr r3, [sp, 0x3C]\n\ - lsrs r2, r3, 24\n\ - ldrb r3, [r0, 0x4]\n\ - movs r0, 0x1\n\ - str r0, [sp]\n\ - str r7, [sp, 0x4]\n\ - str r0, [sp, 0x8]\n\ - ldr r0, =0x0000ef2a\n\ - str r0, [sp, 0xC]\n\ - mov r0, r10\n\ - bl CreateMon\n\ - ldr r0, =sFrontierBrainsMons\n\ - adds r5, r0\n\ - adds r5, r6, r5\n\ - adds r4, r5, r4\n\ - adds r4, 0x2\n\ - mov r0, r10\n\ - movs r1, 0xC\n\ - adds r2, r4, 0\n\ - bl SetMonData\n\ - movs r7, 0\n\ - mov r6, r8\n\ - ldr r3, =gEnemyParty\n\ + bl Random\n\ + adds r4, r0, 0\n\ + bl Random\n\ + lsls r4, 16\n\ + lsrs r7, r4, 16\n\ + lsls r0, 16\n\ + orrs r7, r0\n\ + ldr r0, =0x0000ef2a\n\ + adds r1, r7, 0\n\ + bl IsShinyOtIdPersonality\n\ + lsls r0, 24\n\ + cmp r0, 0\n\ + bne _081A4E96\n\ + ldr r4, [sp, 0x38]\n\ + ldr r1, [sp, 0x24]\n\ + subs r0, r4, r1\n\ + lsls r5, r0, 2\n\ + mov r2, r8\n\ + adds r4, r2, r5\n\ + ldr r3, [sp, 0x34]\n\ + ldr r1, [sp, 0x20]\n\ + subs r0, r3, r1\n\ + lsls r6, r0, 3\n\ + adds r4, r6\n\ + ldr r2, =sFrontierBrainsMons\n\ + adds r4, r2\n\ + adds r0, r7, 0\n\ + bl GetNatureFromPersonality\n\ + ldrb r1, [r4, 0x5]\n\ + lsls r0, 24\n\ + lsrs r0, 24\n\ + cmp r1, r0\n\ + bne _081A4E96\n\ + ldr r4, [sp, 0x18]\n\ + movs r0, 0x64\n\ + adds r3, r4, 0\n\ + muls r3, r0\n\ + mov r8, r3\n\ + ldr r1, =gEnemyParty\n\ + add r1, r8\n\ + mov r10, r1\n\ + ldr r4, [sp, 0x14]\n\ + add r4, r9\n\ + lsls r4, 2\n\ + adds r0, r4, r5\n\ + adds r0, r6\n\ + ldr r2, =sFrontierBrainsMons\n\ + adds r0, r2\n\ + ldrh r1, [r0]\n\ + ldr r3, [sp, 0x3C]\n\ + lsrs r2, r3, 24\n\ + ldrb r3, [r0, 0x4]\n\ + movs r0, 0x1\n\ + str r0, [sp]\n\ + str r7, [sp, 0x4]\n\ + str r0, [sp, 0x8]\n\ + ldr r0, =0x0000ef2a\n\ + str r0, [sp, 0xC]\n\ + mov r0, r10\n\ + bl CreateMon\n\ + ldr r0, =sFrontierBrainsMons\n\ + adds r5, r0\n\ + adds r5, r6, r5\n\ + adds r4, r5, r4\n\ + adds r4, 0x2\n\ + mov r0, r10\n\ + movs r1, 0xC\n\ + adds r2, r4, 0\n\ + bl SetMonData\n\ + movs r7, 0\n\ + mov r6, r8\n\ + ldr r3, =gEnemyParty\n\ _081A4F32:\n\ - adds r1, r7, 0\n\ - adds r1, 0x1A\n\ - ldr r0, [sp, 0x14]\n\ - add r0, r9\n\ - lsls r4, r0, 2\n\ - adds r2, r5, r4\n\ - adds r0, r7, 0x6\n\ - adds r2, r0\n\ - adds r0, r6, r3\n\ - str r3, [sp, 0x40]\n\ - bl SetMonData\n\ - adds r7, 0x1\n\ - ldr r3, [sp, 0x40]\n\ - cmp r7, 0x5\n\ - ble _081A4F32\n\ - movs r1, 0xFF\n\ - add r0, sp, 0x10\n\ - strb r1, [r0]\n\ - movs r7, 0\n\ - ldr r1, [sp, 0x18]\n\ - movs r2, 0x64\n\ - adds r6, r1, 0\n\ - muls r6, r2\n\ - ldr r3, =sFrontierBrainsMons + 0xC\n\ - mov r8, r3\n\ - ldr r3, =gEnemyParty\n\ - adds r5, r4, 0\n\ + adds r1, r7, 0\n\ + adds r1, 0x1A\n\ + ldr r0, [sp, 0x14]\n\ + add r0, r9\n\ + lsls r4, r0, 2\n\ + adds r2, r5, r4\n\ + adds r0, r7, 0x6\n\ + adds r2, r0\n\ + adds r0, r6, r3\n\ + str r3, [sp, 0x40]\n\ + bl SetMonData\n\ + adds r7, 0x1\n\ + ldr r3, [sp, 0x40]\n\ + cmp r7, 0x5\n\ + ble _081A4F32\n\ + movs r1, 0xFF\n\ + add r0, sp, 0x10\n\ + strb r1, [r0]\n\ + movs r7, 0\n\ + ldr r1, [sp, 0x18]\n\ + movs r2, 0x64\n\ + adds r6, r1, 0\n\ + muls r6, r2\n\ + ldr r3, =sFrontierBrainsMons + 0xC\n\ + mov r8, r3\n\ + ldr r3, =gEnemyParty\n\ + adds r5, r4, 0\n\ _081A4F6A:\n\ - ldr r4, [sp, 0x38]\n\ - ldr r0, [sp, 0x24]\n\ - subs r1, r4, r0\n\ - lsls r1, 2\n\ - adds r1, r5, r1\n\ - ldr r2, [sp, 0x34]\n\ - ldr r4, [sp, 0x20]\n\ - subs r0, r2, r4\n\ - lsls r0, 3\n\ - adds r1, r0\n\ - add r1, r8\n\ - ldrh r4, [r1]\n\ - lsls r2, r7, 24\n\ - lsrs r2, 24\n\ - adds r0, r6, r3\n\ - adds r1, r4, 0\n\ - str r3, [sp, 0x40]\n\ - bl SetMonMoveSlot\n\ - ldr r3, [sp, 0x40]\n\ - cmp r4, 0xDA\n\ - bne _081A4F9C\n\ - movs r1, 0\n\ - add r0, sp, 0x10\n\ - strb r1, [r0]\n\ + ldr r4, [sp, 0x38]\n\ + ldr r0, [sp, 0x24]\n\ + subs r1, r4, r0\n\ + lsls r1, 2\n\ + adds r1, r5, r1\n\ + ldr r2, [sp, 0x34]\n\ + ldr r4, [sp, 0x20]\n\ + subs r0, r2, r4\n\ + lsls r0, 3\n\ + adds r1, r0\n\ + add r1, r8\n\ + ldrh r4, [r1]\n\ + lsls r2, r7, 24\n\ + lsrs r2, 24\n\ + adds r0, r6, r3\n\ + adds r1, r4, 0\n\ + str r3, [sp, 0x40]\n\ + bl SetMonMoveSlot\n\ + ldr r3, [sp, 0x40]\n\ + cmp r4, 0xDA\n\ + bne _081A4F9C\n\ + movs r1, 0\n\ + add r0, sp, 0x10\n\ + strb r1, [r0]\n\ _081A4F9C:\n\ - adds r5, 0x2\n\ - adds r7, 0x1\n\ - cmp r7, 0x3\n\ - ble _081A4F6A\n\ - ldr r0, [sp, 0x18]\n\ - movs r1, 0x64\n\ - adds r4, r0, 0\n\ - muls r4, r1\n\ - ldr r0, =gEnemyParty\n\ - adds r4, r0\n\ - adds r0, r4, 0\n\ - movs r1, 0x20\n\ - add r2, sp, 0x10\n\ - bl SetMonData\n\ - adds r0, r4, 0\n\ - bl CalculateMonStats\n\ - ldr r2, [sp, 0x2C]\n\ - str r2, [sp, 0x18]\n\ + adds r5, 0x2\n\ + adds r7, 0x1\n\ + cmp r7, 0x3\n\ + ble _081A4F6A\n\ + ldr r0, [sp, 0x18]\n\ + movs r1, 0x64\n\ + adds r4, r0, 0\n\ + muls r4, r1\n\ + ldr r0, =gEnemyParty\n\ + adds r4, r0\n\ + adds r0, r4, 0\n\ + movs r1, 0x20\n\ + add r2, sp, 0x10\n\ + bl SetMonData\n\ + adds r0, r4, 0\n\ + bl CalculateMonStats\n\ + ldr r2, [sp, 0x2C]\n\ + str r2, [sp, 0x18]\n\ _081A4FC4:\n\ - ldr r4, [sp, 0x30]\n\ - ldr r3, [sp, 0x28]\n\ - str r3, [sp, 0x14]\n\ - cmp r3, 0x2\n\ - bgt _081A4FD0\n\ - b _081A4E5C\n\ + ldr r4, [sp, 0x30]\n\ + ldr r3, [sp, 0x28]\n\ + str r3, [sp, 0x14]\n\ + cmp r3, 0x2\n\ + bgt _081A4FD0\n\ + b _081A4E5C\n\ _081A4FD0:\n\ - add sp, 0x44\n\ - pop {r3-r5}\n\ - mov r8, r3\n\ - mov r9, r4\n\ - mov r10, r5\n\ - pop {r4-r7}\n\ - pop {r0}\n\ - bx r0\n\ - .pool\n\ + add sp, 0x44\n\ + pop {r3-r5}\n\ + mov r8, r3\n\ + mov r9, r4\n\ + mov r10, r5\n\ + pop {r4-r7}\n\ + pop {r0}\n\ + bx r0\n\ + .pool\n\ "); } #endif diff --git a/src/map_name_popup.c b/src/map_name_popup.c index 172fcc723..ab52cb37e 100644 --- a/src/map_name_popup.c +++ b/src/map_name_popup.c @@ -15,7 +15,6 @@ #include "task.h" #include "text.h" - // enums enum MapPopUp_Themes { @@ -33,7 +32,7 @@ static void ShowMapNamePopUpWindow(void); static void LoadMapNamePopUpWindowBg(void); // EWRAM -static EWRAM_DATA u8 mapNamePopupTaskId = 0; +static EWRAM_DATA u8 sPopupTaskId = 0; // .rodata static const u8 gMapPopUp_Table[][960] = @@ -202,7 +201,7 @@ bool8 sub_80D47D4(void) { HideStartMenu(); ShowMapNamePopup(); - return 1; + return TRUE; } void ShowMapNamePopup(void) @@ -211,16 +210,16 @@ void ShowMapNamePopup(void) { if (!FuncIsActiveTask(Task_MapNamePopUpWindow)) { - mapNamePopupTaskId = CreateTask(Task_MapNamePopUpWindow, 90); + sPopupTaskId = CreateTask(Task_MapNamePopUpWindow, 90); SetGpuReg(REG_OFFSET_BG0VOFS, 40); - gTasks[mapNamePopupTaskId].data[0] = 6; - gTasks[mapNamePopupTaskId].data[2] = 40; + gTasks[sPopupTaskId].data[0] = 6; + gTasks[sPopupTaskId].data[2] = 40; } else { - if (gTasks[mapNamePopupTaskId].data[0] != 2) - gTasks[mapNamePopupTaskId].data[0] = 2; - gTasks[mapNamePopupTaskId].data[3] = 1; + if (gTasks[sPopupTaskId].data[0] != 2) + gTasks[sPopupTaskId].data[0] = 2; + gTasks[sPopupTaskId].data[3] = 1; } } } @@ -246,7 +245,7 @@ static void Task_MapNamePopUpWindow(u8 taskId) { task->data[2] = 0; task->data[0] = 1; - gTasks[mapNamePopupTaskId].data[1] = 0; + gTasks[sPopupTaskId].data[1] = 0; } break; case 1: @@ -293,7 +292,7 @@ void HideMapNamePopUpWindow(void) sub_819746C(GetMapNamePopUpWindowId(), TRUE); RemoveMapNamePopUpWindow(); SetGpuReg_ForcedBlank(REG_OFFSET_BG0VOFS, 0); - DestroyTask(mapNamePopupTaskId); + DestroyTask(sPopupTaskId); } } @@ -304,9 +303,9 @@ static void ShowMapNamePopUpWindow(void) u8 x; const u8* mapDisplayHeaderSource; - if(InBattlePyramid()) + if (InBattlePyramid()) { - if(gMapHeader.mapLayoutId == 0x17A) + if (gMapHeader.mapLayoutId == 0x17A) { withoutPrefixPtr = &(mapDisplayHeader[3]); mapDisplayHeaderSource = gBattlePyramid_MapHeaderStrings[7]; @@ -333,220 +332,47 @@ static void ShowMapNamePopUpWindow(void) CopyWindowToVram(GetMapNamePopUpWindowId(), 3); } -#ifdef NONMATCHING static void sub_80D4A78(u8 bg, u8 x, u8 y, u8 deltaX, u8 deltaY, u8 unused) { s32 i; - for(i=0; i<=11; i++) + for (i = 0; i < 12; i++) { - FillBgTilemapBufferRect(bg, 0x21D + i, x + i - 1, y - 1, 1, 1, 0xE); + FillBgTilemapBufferRect(bg, 0x21D + i, i - 1 + x, y - 1, 1, 1, 0xE); } - FillBgTilemapBufferRect(bg, 0x229 + i, x - 1, y, 1, 1, 0xE); - FillBgTilemapBufferRect(bg, 0x22A + i, deltaX + x, y, 1, 1, 0xE); - FillBgTilemapBufferRect(bg, 0x22B + i, x - 1, y + 1 , 1, 1, 0xE); - FillBgTilemapBufferRect(bg, 0x22C + i, deltaX + x, y + 1, 1, 1, 0xE); - FillBgTilemapBufferRect(bg, 0x22D + i, x - 1, y + 2, 1, 1, 0xE); - FillBgTilemapBufferRect(bg, 0x22E + i, deltaX + x, y + 2, 1, 1, 0xE); - for(i=0; i<=11; i++) + FillBgTilemapBufferRect(bg, 0x229, x - 1, y, 1, 1, 0xE); + FillBgTilemapBufferRect(bg, 0x22A, deltaX + x, y, 1, 1, 0xE); + FillBgTilemapBufferRect(bg, 0x22B, x - 1, y + 1 , 1, 1, 0xE); + FillBgTilemapBufferRect(bg, 0x22C, deltaX + x, y + 1, 1, 1, 0xE); + FillBgTilemapBufferRect(bg, 0x22D, x - 1, y + 2, 1, 1, 0xE); + FillBgTilemapBufferRect(bg, 0x22E, deltaX + x, y + 2, 1, 1, 0xE); + for (i = 0; i < 12; i++) { - FillBgTilemapBufferRect(bg, 0x22F + i, x + i - 1, y + deltaY, 1, 1, 0xE); + FillBgTilemapBufferRect(bg, 0x22F + i, i - 1 + x, y + deltaY, 1, 1, 0xE); } } -#else -NAKED -static void sub_80D4A78(u8 bg, u8 x, u8 y, u8 deltaX, u8 deltaY, u8 unused) -{ - asm("\n\ - .syntax unified\n\ - push {r4-r7,lr}\n\ - mov r7, r10\n\ - mov r6, r9\n\ - mov r5, r8\n\ - push {r5-r7}\n\ - sub sp, 0x1C\n\ - ldr r4, [sp, 0x3C]\n\ - lsls r0, 24\n\ - lsrs r7, r0, 24\n\ - lsls r1, 24\n\ - lsrs r1, 24\n\ - mov r10, r1\n\ - lsls r2, 24\n\ - lsls r3, 24\n\ - lsrs r3, 24\n\ - str r3, [sp, 0x10]\n\ - lsls r4, 24\n\ - lsrs r4, 24\n\ - str r4, [sp, 0x14]\n\ - movs r5, 0\n\ - lsls r0, r1, 24\n\ - asrs r1, r0, 24\n\ - lsrs r3, r2, 24\n\ - str r3, [sp, 0xC]\n\ - movs r6, 0xFF\n\ - lsls r6, 24\n\ - adds r6, r2\n\ - mov r8, r6\n\ - str r0, [sp, 0x18]\n\ - subs r4, r1, 0x1\n\ - _080D4AB4:\n\ - ldr r0, =0x0000021d\n\ - adds r1, r5, r0\n\ - lsls r1, 16\n\ - lsrs r1, 16\n\ - lsls r2, r4, 24\n\ - lsrs r2, 24\n\ - movs r3, 0x1\n\ - str r3, [sp]\n\ - str r3, [sp, 0x4]\n\ - movs r6, 0xE\n\ - mov r9, r6\n\ - str r6, [sp, 0x8]\n\ - adds r0, r7, 0\n\ - mov r6, r8\n\ - lsrs r3, r6, 24\n\ - bl FillBgTilemapBufferRect\n\ - adds r4, 0x1\n\ - adds r5, 0x1\n\ - cmp r5, 0xB\n\ - ble _080D4AB4\n\ - ldr r1, =0x00000229\n\ - movs r0, 0x1\n\ - negs r0, r0\n\ - add r0, r10\n\ - lsls r0, 24\n\ - lsrs r0, 24\n\ - mov r8, r0\n\ - movs r5, 0x1\n\ - str r5, [sp]\n\ - str r5, [sp, 0x4]\n\ - mov r2, r9\n\ - str r2, [sp, 0x8]\n\ - adds r0, r7, 0\n\ - mov r2, r8\n\ - ldr r3, [sp, 0xC]\n\ - bl FillBgTilemapBufferRect\n\ - ldr r1, =0x0000022a\n\ - ldr r6, [sp, 0x10]\n\ - add r6, r10\n\ - lsls r6, 24\n\ - lsrs r6, 24\n\ - str r5, [sp]\n\ - str r5, [sp, 0x4]\n\ - mov r3, r9\n\ - str r3, [sp, 0x8]\n\ - adds r0, r7, 0\n\ - adds r2, r6, 0\n\ - ldr r3, [sp, 0xC]\n\ - bl FillBgTilemapBufferRect\n\ - ldr r1, =0x0000022b\n\ - ldr r4, [sp, 0xC]\n\ - adds r4, 0x1\n\ - lsls r4, 24\n\ - lsrs r4, 24\n\ - str r5, [sp]\n\ - str r5, [sp, 0x4]\n\ - mov r0, r9\n\ - str r0, [sp, 0x8]\n\ - adds r0, r7, 0\n\ - mov r2, r8\n\ - adds r3, r4, 0\n\ - bl FillBgTilemapBufferRect\n\ - movs r1, 0x8B\n\ - lsls r1, 2\n\ - str r5, [sp]\n\ - str r5, [sp, 0x4]\n\ - mov r2, r9\n\ - str r2, [sp, 0x8]\n\ - adds r0, r7, 0\n\ - adds r2, r6, 0\n\ - adds r3, r4, 0\n\ - bl FillBgTilemapBufferRect\n\ - ldr r1, =0x0000022d\n\ - ldr r4, [sp, 0xC]\n\ - adds r4, 0x2\n\ - lsls r4, 24\n\ - lsrs r4, 24\n\ - str r5, [sp]\n\ - str r5, [sp, 0x4]\n\ - mov r3, r9\n\ - str r3, [sp, 0x8]\n\ - adds r0, r7, 0\n\ - mov r2, r8\n\ - adds r3, r4, 0\n\ - bl FillBgTilemapBufferRect\n\ - ldr r1, =0x0000022e\n\ - str r5, [sp]\n\ - str r5, [sp, 0x4]\n\ - mov r0, r9\n\ - str r0, [sp, 0x8]\n\ - adds r0, r7, 0\n\ - adds r2, r6, 0\n\ - adds r3, r4, 0\n\ - bl FillBgTilemapBufferRect\n\ - movs r5, 0\n\ - ldr r1, [sp, 0xC]\n\ - ldr r2, [sp, 0x14]\n\ - adds r0, r1, r2\n\ - lsls r4, r0, 24\n\ - movs r6, 0x1\n\ - _080D4B8A:\n\ - ldr r3, =0x0000022f\n\ - adds r1, r5, r3\n\ - lsls r1, 16\n\ - lsrs r1, 16\n\ - subs r0, r5, 0x1\n\ - ldr r3, [sp, 0x18]\n\ - asrs r2, r3, 24\n\ - adds r2, r0\n\ - lsls r2, 24\n\ - lsrs r2, 24\n\ - str r6, [sp]\n\ - str r6, [sp, 0x4]\n\ - movs r0, 0xE\n\ - str r0, [sp, 0x8]\n\ - adds r0, r7, 0\n\ - lsrs r3, r4, 24\n\ - bl FillBgTilemapBufferRect\n\ - adds r5, 0x1\n\ - cmp r5, 0xB\n\ - ble _080D4B8A\n\ - add sp, 0x1C\n\ - pop {r3-r5}\n\ - mov r8, r3\n\ - mov r9, r4\n\ - mov r10, r5\n\ - pop {r4-r7}\n\ - pop {r0}\n\ - bx r0\n\ - .pool\n\ - .syntax divided"); -} -#endif // NONMATCHING static void LoadMapNamePopUpWindowBg(void) { - u8 popupWindowId; - u16 regionMapSectionId; u8 popUpThemeId; + u8 popupWindowId = GetMapNamePopUpWindowId(); + u16 regionMapSectionId = gMapHeader.regionMapSectionId; - popupWindowId = GetMapNamePopUpWindowId(); - regionMapSectionId = gMapHeader.regionMapSectionId; - if(regionMapSectionId > MAPSEC_DYNAMIC) + if (regionMapSectionId > MAPSEC_DYNAMIC) { - if(regionMapSectionId > MAPSEC_SPECIAL_AREA) + if (regionMapSectionId > MAPSEC_SPECIAL_AREA) regionMapSectionId -= (MAPSEC_SPECIAL_AREA - MAPSEC_DYNAMIC); else - regionMapSectionId = 0; //discard kanto region sections + regionMapSectionId = 0; // Discard kanto region sections; } popUpThemeId = gRegionMapSectionId_To_PopUpThemeIdMapping[regionMapSectionId]; - LoadBgTiles(GetWindowAttribute(popupWindowId, WINDOW_BG), &(gMapPopUp_Outline_Table[popUpThemeId][0]), 0x400, 0x21D); + LoadBgTiles(GetWindowAttribute(popupWindowId, WINDOW_BG), gMapPopUp_Outline_Table[popUpThemeId], 0x400, 0x21D); CallWindowFunction(popupWindowId, sub_80D4A78); PutWindowTilemap(popupWindowId); if(gMapHeader.weather == WEATHER_BUBBLES) LoadPalette(&gUnknown_0857F444, 0xE0, 0x20); else - LoadPalette(&(gMapPopUp_Palette_Table[popUpThemeId][0]), 0xE0, 0x20); - BlitBitmapToWindow(popupWindowId, &(gMapPopUp_Table[popUpThemeId][0]), 0, 0, 80, 24); + LoadPalette(gMapPopUp_Palette_Table[popUpThemeId], 0xE0, 0x20); + BlitBitmapToWindow(popupWindowId, gMapPopUp_Table[popUpThemeId], 0, 0, 80, 24); } diff --git a/src/text.c b/src/text.c index 2380e3191..ecd3a3095 100644 --- a/src/text.c +++ b/src/text.c @@ -257,584 +257,156 @@ u32 RenderFont(struct TextPrinter *textPrinter) } } -#ifdef NONMATCHING void GenerateFontHalfRowLookupTable(u8 fgColor, u8 bgColor, u8 shadowColor) { - u16* current = gFontHalfRowLookupTable; + u32 fg12, bg12, shadow12; + u32 temp; + + u16 *current = gFontHalfRowLookupTable; gLastTextBgColor = bgColor; gLastTextFgColor = fgColor; gLastTextShadowColor = shadowColor; - *(current++) = (bgColor << 12) | (bgColor << 8) | (bgColor << 4) | bgColor; - *(current++) = (fgColor << 12) | (bgColor << 8) | (bgColor << 4) | bgColor; - *(current++) = (shadowColor << 12) | (bgColor << 8) | (bgColor << 4) | bgColor; + bg12 = bgColor << 12; + fg12 = fgColor << 12; + shadow12 = shadowColor << 12; - *(current++) = (bgColor << 12) | (fgColor << 8) | (bgColor << 4) | bgColor; - *(current++) = (fgColor << 12) | (fgColor << 8) | (bgColor << 4) | bgColor; - *(current++) = (shadowColor << 12) | (fgColor << 8) | (bgColor << 4) | bgColor; + temp = (bgColor << 8) | (bgColor << 4) | bgColor; + *(current++) = (bg12) | temp; + *(current++) = (fg12) | temp; + *(current++) = (shadow12) | temp; - *(current++) = (bgColor << 12) | (shadowColor << 8) | (bgColor << 4) | bgColor; - *(current++) = (fgColor << 12) | (shadowColor << 8) | (bgColor << 4) | bgColor; - *(current++) = (shadowColor << 12) | (shadowColor << 8) | (bgColor << 4) | bgColor; + temp = (fgColor << 8) | (bgColor << 4) | bgColor; + *(current++) = (bg12) | temp; + *(current++) = (fg12) | temp; + *(current++) = (shadow12) | temp; - *(current++) = (bgColor << 12) | (bgColor << 8) | (fgColor << 4) | bgColor; - *(current++) = (fgColor << 12) | (bgColor << 8) | (fgColor << 4) | bgColor; - *(current++) = (shadowColor << 12) | (bgColor << 8) | (fgColor << 4) | bgColor; + temp = (shadowColor << 8) | (bgColor << 4) | bgColor; + *(current++) = (bg12) | temp; + *(current++) = (fg12) | temp; + *(current++) = (shadow12) | temp; - *(current++) = (bgColor << 12) | (fgColor << 8) | (fgColor << 4) | bgColor; - *(current++) = (fgColor << 12) | (fgColor << 8) | (fgColor << 4) | bgColor; - *(current++) = (shadowColor << 12) | (fgColor << 8) | (fgColor << 4) | bgColor; + temp = (bgColor << 8) | (fgColor << 4) | bgColor; + *(current++) = (bg12) | temp; + *(current++) = (fg12) | temp; + *(current++) = (shadow12) | temp; - *(current++) = (bgColor << 12) | (shadowColor << 8) | (fgColor << 4) | bgColor; - *(current++) = (fgColor << 12) | (shadowColor << 8) | (fgColor << 4) | bgColor; - *(current++) = (shadowColor << 12) | (shadowColor << 8) | (fgColor << 4) | bgColor; + temp = (fgColor << 8) | (fgColor << 4) | bgColor; + *(current++) = (bg12) | temp; + *(current++) = (fg12) | temp; + *(current++) = (shadow12) | temp; - *(current++) = (bgColor << 12) | (bgColor << 8) | (shadowColor << 4) | bgColor; - *(current++) = (fgColor << 12) | (bgColor << 8) | (shadowColor << 4) | bgColor; - *(current++) = (shadowColor << 12) | (bgColor << 8) | (shadowColor << 4) | bgColor; + temp = (shadowColor << 8) | (fgColor << 4) | bgColor; + *(current++) = (bg12) | temp; + *(current++) = (fg12) | temp; + *(current++) = (shadow12) | temp; - *(current++) = (bgColor << 12) | (fgColor << 8) | (shadowColor << 4) | bgColor; - *(current++) = (fgColor << 12) | (fgColor << 8) | (shadowColor << 4) | bgColor; - *(current++) = (shadowColor << 12) | (fgColor << 8) | (shadowColor << 4) | bgColor; + temp = (bgColor << 8) | (shadowColor << 4) | bgColor; + *(current++) = (bg12) | temp; + *(current++) = (fg12) | temp; + *(current++) = (shadow12) | temp; - *(current++) = (bgColor << 12) | (shadowColor << 8) | (shadowColor << 4) | bgColor; - *(current++) = (fgColor << 12) | (shadowColor << 8) | (shadowColor << 4) | bgColor; - *(current++) = (shadowColor << 12) | (shadowColor << 8) | (shadowColor << 4) | bgColor; + temp = (fgColor << 8) | (shadowColor << 4) | bgColor; + *(current++) = (bg12) | temp; + *(current++) = (fg12) | temp; + *(current++) = (shadow12) | temp; - *(current++) = (bgColor << 12) | (bgColor << 8) | (bgColor << 4) | fgColor; - *(current++) = (fgColor << 12) | (bgColor << 8) | (bgColor << 4) | fgColor; - *(current++) = (shadowColor << 12) | (bgColor << 8) | (bgColor << 4) | fgColor; + temp = (shadowColor << 8) | (shadowColor << 4) | bgColor; + *(current++) = (bg12) | temp; + *(current++) = (fg12) | temp; + *(current++) = (shadow12) | temp; - *(current++) = (bgColor << 12) | (fgColor << 8) | (bgColor << 4) | fgColor; - *(current++) = (fgColor << 12) | (fgColor << 8) | (bgColor << 4) | fgColor; - *(current++) = (shadowColor << 12) | (fgColor << 8) | (bgColor << 4) | fgColor; + temp = (bgColor << 8) | (bgColor << 4) | fgColor; + *(current++) = (bg12) | temp; + *(current++) = (fg12) | temp; + *(current++) = (shadow12) | temp; - *(current++) = (bgColor << 12) | (shadowColor << 8) | (bgColor << 4) | fgColor; - *(current++) = (fgColor << 12) | (shadowColor << 8) | (bgColor << 4) | fgColor; - *(current++) = (shadowColor << 12) | (shadowColor << 8) | (bgColor << 4) | fgColor; + temp = (fgColor << 8) | (bgColor << 4) | fgColor; + *(current++) = (bg12) | temp; + *(current++) = (fg12) | temp; + *(current++) = (shadow12) | temp; - *(current++) = (bgColor << 12) | (bgColor << 8) | (fgColor << 4) | fgColor; - *(current++) = (fgColor << 12) | (bgColor << 8) | (fgColor << 4) | fgColor; - *(current++) = (shadowColor << 12) | (bgColor << 8) | (fgColor << 4) | fgColor; + temp = (shadowColor << 8) | (bgColor << 4) | fgColor; + *(current++) = (bg12) | temp; + *(current++) = (fg12) | temp; + *(current++) = (shadow12) | temp; - *(current++) = (bgColor << 12) | (fgColor << 8) | (fgColor << 4) | fgColor; - *(current++) = (fgColor << 12) | (fgColor << 8) | (fgColor << 4) | fgColor; - *(current++) = (shadowColor << 12) | (fgColor << 8) | (fgColor << 4) | fgColor; + temp = (bgColor << 8) | (fgColor << 4) | fgColor; + *(current++) = (bg12) | temp; + *(current++) = (fg12) | temp; + *(current++) = (shadow12) | temp; - *(current++) = (bgColor << 12) | (shadowColor << 8) | (fgColor << 4) | fgColor; - *(current++) = (fgColor << 12) | (shadowColor << 8) | (fgColor << 4) | fgColor; - *(current++) = (shadowColor << 12) | (shadowColor << 8) | (fgColor << 4) | fgColor; + temp = (fgColor << 8) | (fgColor << 4) | fgColor; + *(current++) = (bg12) | temp; + *(current++) = (fg12) | temp; + *(current++) = (shadow12) | temp; - *(current++) = (bgColor << 12) | (bgColor << 8) | (shadowColor << 4) | fgColor; - *(current++) = (fgColor << 12) | (bgColor << 8) | (shadowColor << 4) | fgColor; - *(current++) = (shadowColor << 12) | (bgColor << 8) | (shadowColor << 4) | fgColor; + temp = (shadowColor << 8) | (fgColor << 4) | fgColor; + *(current++) = (bg12) | temp; + *(current++) = (fg12) | temp; + *(current++) = (shadow12) | temp; - *(current++) = (bgColor << 12) | (fgColor << 8) | (shadowColor << 4) | fgColor; - *(current++) = (fgColor << 12) | (fgColor << 8) | (shadowColor << 4) | fgColor; - *(current++) = (shadowColor << 12) | (fgColor << 8) | (shadowColor << 4) | fgColor; + temp = (bgColor << 8) | (shadowColor << 4) | fgColor; + *(current++) = (bg12) | temp; + *(current++) = (fg12) | temp; + *(current++) = (shadow12) | temp; - *(current++) = (bgColor << 12) | (shadowColor << 8) | (shadowColor << 4) | fgColor; - *(current++) = (fgColor << 12) | (shadowColor << 8) | (shadowColor << 4) | fgColor; - *(current++) = (shadowColor << 12) | (shadowColor << 8) | (shadowColor << 4) | fgColor; + temp = (fgColor << 8) | (shadowColor << 4) | fgColor; + *(current++) = (bg12) | temp; + *(current++) = (fg12) | temp; + *(current++) = (shadow12) | temp; - *(current++) = (bgColor << 12) | (bgColor << 8) | (bgColor << 4) | shadowColor; - *(current++) = (fgColor << 12) | (bgColor << 8) | (bgColor << 4) | shadowColor; - *(current++) = (shadowColor << 12) | (bgColor << 8) | (bgColor << 4) | shadowColor; + temp = (shadowColor << 8) | (shadowColor << 4) | fgColor; + *(current++) = (bg12) | temp; + *(current++) = (fg12) | temp; + *(current++) = (shadow12) | temp; - *(current++) = (bgColor << 12) | (fgColor << 8) | (bgColor << 4) | shadowColor; - *(current++) = (fgColor << 12) | (fgColor << 8) | (bgColor << 4) | shadowColor; - *(current++) = (shadowColor << 12) | (fgColor << 8) | (bgColor << 4) | shadowColor; + temp = (bgColor << 8) | (bgColor << 4) | shadowColor; + *(current++) = (bg12) | temp; + *(current++) = (fg12) | temp; + *(current++) = (shadow12) | temp; - *(current++) = (bgColor << 12) | (shadowColor << 8) | (bgColor << 4) | shadowColor; - *(current++) = (fgColor << 12) | (shadowColor << 8) | (bgColor << 4) | shadowColor; - *(current++) = (shadowColor << 12) | (shadowColor << 8) | (bgColor << 4) | shadowColor; + temp = (fgColor << 8) | (bgColor << 4) | shadowColor; + *(current++) = (bg12) | temp; + *(current++) = (fg12) | temp; + *(current++) = (shadow12) | temp; - *(current++) = (bgColor << 12) | (bgColor << 8) | (fgColor << 4) | shadowColor; - *(current++) = (fgColor << 12) | (bgColor << 8) | (fgColor << 4) | shadowColor; - *(current++) = (shadowColor << 12) | (bgColor << 8) | (fgColor << 4) | shadowColor; + temp = (shadowColor << 8) | (bgColor << 4) | shadowColor; + *(current++) = (bg12) | temp; + *(current++) = (fg12) | temp; + *(current++) = (shadow12) | temp; - *(current++) = (bgColor << 12) | (fgColor << 8) | (fgColor << 4) | shadowColor; - *(current++) = (fgColor << 12) | (fgColor << 8) | (fgColor << 4) | shadowColor; - *(current++) = (shadowColor << 12) | (fgColor << 8) | (fgColor << 4) | shadowColor; + temp = (bgColor << 8) | (fgColor << 4) | shadowColor; + *(current++) = (bg12) | temp; + *(current++) = (fg12) | temp; + *(current++) = (shadow12) | temp; - *(current++) = (bgColor << 12) | (shadowColor << 8) | (fgColor << 4) | shadowColor; - *(current++) = (fgColor << 12) | (shadowColor << 8) | (fgColor << 4) | shadowColor; - *(current++) = (shadowColor << 12) | (shadowColor << 8) | (fgColor << 4) | shadowColor; + temp = (fgColor << 8) | (fgColor << 4) | shadowColor; + *(current++) = (bg12) | temp; + *(current++) = (fg12) | temp; + *(current++) = (shadow12) | temp; - *(current++) = (bgColor << 12) | (bgColor << 8) | (shadowColor << 4) | shadowColor; - *(current++) = (fgColor << 12) | (bgColor << 8) | (shadowColor << 4) | shadowColor; - *(current++) = (shadowColor << 12) | (bgColor << 8) | (shadowColor << 4) | shadowColor; + temp = (shadowColor << 8) | (fgColor << 4) | shadowColor; + *(current++) = (bg12) | temp; + *(current++) = (fg12) | temp; + *(current++) = (shadow12) | temp; - *(current++) = (bgColor << 12) | (fgColor << 8) | (shadowColor << 4) | shadowColor; - *(current++) = (fgColor << 12) | (fgColor << 8) | (shadowColor << 4) | shadowColor; - *(current++) = (shadowColor << 12) | (fgColor << 8) | (shadowColor << 4) | shadowColor; + temp = (bgColor << 8) | (shadowColor << 4) | shadowColor; + *(current++) = (bg12) | temp; + *(current++) = (fg12) | temp; + *(current++) = (shadow12) | temp; - *(current++) = (bgColor << 12) | (shadowColor << 8) | (shadowColor << 4) | shadowColor; - *(current++) = (fgColor << 12) | (shadowColor << 8) | (shadowColor << 4) | shadowColor; - *(current++) = (shadowColor << 12) | (shadowColor << 8) | (shadowColor << 4) | shadowColor; + temp = (fgColor << 8) | (shadowColor << 4) | shadowColor; + *(current++) = (bg12) | temp; + *(current++) = (fg12) | temp; + *(current++) = (shadow12) | temp; + + temp = (shadowColor << 8) | (shadowColor << 4) | shadowColor; + *(current++) = (bg12) | temp; + *(current++) = (fg12) | temp; + *(current++) = (shadow12) | temp; } -#else -NAKED -void GenerateFontHalfRowLookupTable(u8 fgColor, u8 bgColor, u8 shadowColor) -{ - asm("push {r4-r7,lr}\n\ - mov r7, r10\n\ - mov r6, r9\n\ - mov r5, r8\n\ - push {r5-r7}\n\ - sub sp, #0x24\n\ - lsl r0, #24\n\ - lsr r0, #24\n\ - lsl r1, #24\n\ - lsr r1, #24\n\ - lsl r2, #24\n\ - lsr r2, #24\n\ - ldr r3, =gFontHalfRowLookupTable\n\ - ldr r4, =gLastTextBgColor\n\ - strh r1, [r4]\n\ - ldr r4, =gLastTextFgColor\n\ - strh r0, [r4]\n\ - ldr r4, =gLastTextShadowColor\n\ - strh r2, [r4]\n\ - lsl r5, r1, #12\n\ - lsl r6, r0, #12\n\ - lsl r4, r2, #12\n\ - mov r8, r4\n\ - lsl r7, r1, #8\n\ - str r7, [sp]\n\ - lsl r4, r1, #4\n\ - mov r9, r4\n\ - orr r7, r4\n\ - str r7, [sp, #0x4]\n\ - orr r7, r1\n\ - add r4, r5, #0\n\ - orr r4, r7\n\ - strh r4, [r3]\n\ - add r3, #0x2\n\ - add r4, r6, #0\n\ - orr r4, r7\n\ - strh r4, [r3]\n\ - add r3, #0x2\n\ - mov r4, r8\n\ - orr r7, r4\n\ - strh r7, [r3]\n\ - add r3, #0x2\n\ - lsl r7, r0, #8\n\ - mov r10, r7\n\ - mov r4, r10\n\ - mov r7, r9\n\ - orr r4, r7\n\ - str r4, [sp, #0x8]\n\ - add r7, r4, #0\n\ - orr r7, r1\n\ - add r4, r5, #0\n\ - orr r4, r7\n\ - strh r4, [r3]\n\ - add r3, #0x2\n\ - add r4, r6, #0\n\ - orr r4, r7\n\ - strh r4, [r3]\n\ - add r3, #0x2\n\ - mov r4, r8\n\ - orr r7, r4\n\ - strh r7, [r3]\n\ - add r3, #0x2\n\ - lsl r7, r2, #8\n\ - mov r12, r7\n\ - mov r4, r12\n\ - mov r7, r9\n\ - orr r4, r7\n\ - str r4, [sp, #0xC]\n\ - add r7, r4, #0\n\ - orr r7, r1\n\ - add r4, r5, #0\n\ - orr r4, r7\n\ - strh r4, [r3]\n\ - add r3, #0x2\n\ - add r4, r6, #0\n\ - orr r4, r7\n\ - strh r4, [r3]\n\ - add r3, #0x2\n\ - mov r4, r8\n\ - orr r7, r4\n\ - strh r7, [r3]\n\ - add r3, #0x2\n\ - lsl r7, r0, #4\n\ - mov r9, r7\n\ - ldr r4, [sp]\n\ - orr r4, r7\n\ - str r4, [sp, #0x10]\n\ - add r7, r4, #0\n\ - orr r7, r1\n\ - add r4, r5, #0\n\ - orr r4, r7\n\ - strh r4, [r3]\n\ - add r3, #0x2\n\ - add r4, r6, #0\n\ - orr r4, r7\n\ - strh r4, [r3]\n\ - add r3, #0x2\n\ - mov r4, r8\n\ - orr r7, r4\n\ - strh r7, [r3]\n\ - add r3, #0x2\n\ - mov r7, r10\n\ - add r4, r7, #0\n\ - mov r7, r9\n\ - orr r4, r7\n\ - str r4, [sp, #0x14]\n\ - add r7, r4, #0\n\ - orr r7, r1\n\ - add r4, r5, #0\n\ - orr r4, r7\n\ - strh r4, [r3]\n\ - add r3, #0x2\n\ - add r4, r6, #0\n\ - orr r4, r7\n\ - strh r4, [r3]\n\ - add r3, #0x2\n\ - mov r4, r8\n\ - orr r7, r4\n\ - strh r7, [r3]\n\ - add r3, #0x2\n\ - mov r7, r12\n\ - add r4, r7, #0\n\ - mov r7, r9\n\ - orr r4, r7\n\ - str r4, [sp, #0x18]\n\ - add r7, r4, #0\n\ - orr r7, r1\n\ - add r4, r5, #0\n\ - orr r4, r7\n\ - strh r4, [r3]\n\ - add r3, #0x2\n\ - add r4, r6, #0\n\ - orr r4, r7\n\ - strh r4, [r3]\n\ - add r3, #0x2\n\ - mov r4, r8\n\ - orr r7, r4\n\ - strh r7, [r3]\n\ - add r3, #0x2\n\ - lsl r7, r2, #4\n\ - mov r9, r7\n\ - mov r4, r9\n\ - ldr r7, [sp]\n\ - orr r7, r4\n\ - str r7, [sp, #0x1C]\n\ - orr r7, r1\n\ - add r4, r5, #0\n\ - orr r4, r7\n\ - strh r4, [r3]\n\ - add r3, #0x2\n\ - add r4, r6, #0\n\ - orr r4, r7\n\ - strh r4, [r3]\n\ - add r3, #0x2\n\ - mov r4, r8\n\ - orr r7, r4\n\ - strh r7, [r3]\n\ - add r3, #0x2\n\ - mov r7, r9\n\ - mov r4, r10\n\ - orr r4, r7\n\ - str r4, [sp, #0x20]\n\ - add r7, r4, #0\n\ - orr r7, r1\n\ - add r4, r5, #0\n\ - orr r4, r7\n\ - strh r4, [r3]\n\ - add r3, #0x2\n\ - add r4, r6, #0\n\ - orr r4, r7\n\ - strh r4, [r3]\n\ - add r3, #0x2\n\ - mov r4, r8\n\ - orr r7, r4\n\ - strh r7, [r3]\n\ - add r3, #0x2\n\ - mov r4, r12\n\ - mov r7, r9\n\ - orr r4, r7\n\ - add r7, r4, #0\n\ - orr r7, r1\n\ - add r1, r5, #0\n\ - orr r1, r7\n\ - strh r1, [r3]\n\ - add r3, #0x2\n\ - add r1, r6, #0\n\ - orr r1, r7\n\ - strh r1, [r3]\n\ - add r3, #0x2\n\ - mov r1, r8\n\ - orr r7, r1\n\ - strh r7, [r3]\n\ - add r3, #0x2\n\ - ldr r7, [sp, #0x4]\n\ - orr r7, r0\n\ - add r1, r5, #0\n\ - orr r1, r7\n\ - strh r1, [r3]\n\ - add r3, #0x2\n\ - add r1, r6, #0\n\ - orr r1, r7\n\ - strh r1, [r3]\n\ - add r3, #0x2\n\ - mov r1, r8\n\ - orr r7, r1\n\ - strh r7, [r3]\n\ - add r3, #0x2\n\ - ldr r7, [sp, #0x8]\n\ - orr r7, r0\n\ - add r1, r5, #0\n\ - orr r1, r7\n\ - strh r1, [r3]\n\ - add r3, #0x2\n\ - add r1, r6, #0\n\ - orr r1, r7\n\ - strh r1, [r3]\n\ - add r3, #0x2\n\ - mov r1, r8\n\ - orr r7, r1\n\ - strh r7, [r3]\n\ - add r3, #0x2\n\ - ldr r7, [sp, #0xC]\n\ - orr r7, r0\n\ - add r1, r5, #0\n\ - orr r1, r7\n\ - strh r1, [r3]\n\ - add r3, #0x2\n\ - add r1, r6, #0\n\ - orr r1, r7\n\ - strh r1, [r3]\n\ - add r3, #0x2\n\ - mov r1, r8\n\ - orr r7, r1\n\ - strh r7, [r3]\n\ - add r3, #0x2\n\ - ldr r7, [sp, #0x10]\n\ - orr r7, r0\n\ - add r1, r5, #0\n\ - orr r1, r7\n\ - strh r1, [r3]\n\ - add r3, #0x2\n\ - add r1, r6, #0\n\ - orr r1, r7\n\ - strh r1, [r3]\n\ - add r3, #0x2\n\ - mov r1, r8\n\ - orr r7, r1\n\ - strh r7, [r3]\n\ - add r3, #0x2\n\ - ldr r7, [sp, #0x14]\n\ - orr r7, r0\n\ - add r1, r5, #0\n\ - orr r1, r7\n\ - strh r1, [r3]\n\ - add r3, #0x2\n\ - add r1, r6, #0\n\ - orr r1, r7\n\ - strh r1, [r3]\n\ - add r3, #0x2\n\ - mov r1, r8\n\ - orr r7, r1\n\ - strh r7, [r3]\n\ - add r3, #0x2\n\ - ldr r7, [sp, #0x18]\n\ - orr r7, r0\n\ - add r1, r5, #0\n\ - orr r1, r7\n\ - strh r1, [r3]\n\ - add r3, #0x2\n\ - add r1, r6, #0\n\ - orr r1, r7\n\ - strh r1, [r3]\n\ - add r3, #0x2\n\ - mov r1, r8\n\ - orr r7, r1\n\ - strh r7, [r3]\n\ - add r3, #0x2\n\ - ldr r7, [sp, #0x1C]\n\ - orr r7, r0\n\ - add r1, r5, #0\n\ - orr r1, r7\n\ - strh r1, [r3]\n\ - add r3, #0x2\n\ - add r1, r6, #0\n\ - orr r1, r7\n\ - strh r1, [r3]\n\ - add r3, #0x2\n\ - mov r1, r8\n\ - orr r7, r1\n\ - strh r7, [r3]\n\ - add r3, #0x2\n\ - ldr r7, [sp, #0x20]\n\ - orr r7, r0\n\ - add r1, r5, #0\n\ - orr r1, r7\n\ - strh r1, [r3]\n\ - add r3, #0x2\n\ - add r1, r6, #0\n\ - orr r1, r7\n\ - strh r1, [r3]\n\ - add r3, #0x2\n\ - mov r1, r8\n\ - orr r7, r1\n\ - strh r7, [r3]\n\ - add r3, #0x2\n\ - add r7, r4, #0\n\ - orr r7, r0\n\ - add r0, r5, #0\n\ - orr r0, r7\n\ - strh r0, [r3]\n\ - add r3, #0x2\n\ - add r0, r6, #0\n\ - orr r0, r7\n\ - strh r0, [r3]\n\ - add r3, #0x2\n\ - orr r7, r1\n\ - strh r7, [r3]\n\ - add r3, #0x2\n\ - add r7, r2, #0\n\ - ldr r0, [sp, #0x4]\n\ - orr r7, r0\n\ - add r0, r5, #0\n\ - orr r0, r7\n\ - strh r0, [r3]\n\ - add r3, #0x2\n\ - add r0, r6, #0\n\ - orr r0, r7\n\ - strh r0, [r3]\n\ - add r3, #0x2\n\ - orr r7, r1\n\ - strh r7, [r3]\n\ - add r3, #0x2\n\ - add r7, r2, #0\n\ - ldr r1, [sp, #0x8]\n\ - orr r7, r1\n\ - add r0, r5, #0\n\ - orr r0, r7\n\ - strh r0, [r3]\n\ - add r3, #0x2\n\ - add r0, r6, #0\n\ - orr r0, r7\n\ - strh r0, [r3]\n\ - add r3, #0x2\n\ - mov r0, r8\n\ - orr r7, r0\n\ - strh r7, [r3]\n\ - add r3, #0x2\n\ - add r7, r2, #0\n\ - ldr r1, [sp, #0xC]\n\ - orr r7, r1\n\ - add r0, r5, #0\n\ - orr r0, r7\n\ - strh r0, [r3]\n\ - add r3, #0x2\n\ - add r0, r6, #0\n\ - orr r0, r7\n\ - strh r0, [r3]\n\ - add r3, #0x2\n\ - mov r0, r8\n\ - orr r7, r0\n\ - strh r7, [r3]\n\ - add r3, #0x2\n\ - add r7, r2, #0\n\ - ldr r1, [sp, #0x10]\n\ - orr r7, r1\n\ - add r0, r5, #0\n\ - orr r0, r7\n\ - strh r0, [r3]\n\ - add r3, #0x2\n\ - add r0, r6, #0\n\ - orr r0, r7\n\ - strh r0, [r3]\n\ - add r3, #0x2\n\ - mov r0, r8\n\ - orr r7, r0\n\ - strh r7, [r3]\n\ - add r3, #0x2\n\ - add r7, r2, #0\n\ - ldr r1, [sp, #0x14]\n\ - orr r7, r1\n\ - add r0, r5, #0\n\ - orr r0, r7\n\ - strh r0, [r3]\n\ - add r3, #0x2\n\ - add r0, r6, #0\n\ - orr r0, r7\n\ - strh r0, [r3]\n\ - add r3, #0x2\n\ - mov r0, r8\n\ - orr r7, r0\n\ - strh r7, [r3]\n\ - add r3, #0x2\n\ - add r7, r2, #0\n\ - ldr r1, [sp, #0x18]\n\ - orr r7, r1\n\ - add r0, r5, #0\n\ - orr r0, r7\n\ - strh r0, [r3]\n\ - add r3, #0x2\n\ - add r0, r6, #0\n\ - orr r0, r7\n\ - strh r0, [r3]\n\ - add r3, #0x2\n\ - mov r0, r8\n\ - orr r7, r0\n\ - strh r7, [r3]\n\ - add r3, #0x2\n\ - add r7, r2, #0\n\ - ldr r1, [sp, #0x1C]\n\ - orr r7, r1\n\ - add r0, r5, #0\n\ - orr r0, r7\n\ - strh r0, [r3]\n\ - add r3, #0x2\n\ - add r0, r6, #0\n\ - orr r0, r7\n\ - strh r0, [r3]\n\ - add r3, #0x2\n\ - mov r0, r8\n\ - orr r7, r0\n\ - strh r7, [r3]\n\ - add r3, #0x2\n\ - add r7, r2, #0\n\ - ldr r1, [sp, #0x20]\n\ - orr r7, r1\n\ - add r0, r5, #0\n\ - orr r0, r7\n\ - strh r0, [r3]\n\ - add r3, #0x2\n\ - add r0, r6, #0\n\ - orr r0, r7\n\ - strh r0, [r3]\n\ - add r3, #0x2\n\ - mov r0, r8\n\ - orr r7, r0\n\ - strh r7, [r3]\n\ - add r3, #0x2\n\ - add r7, r2, #0\n\ - orr r7, r4\n\ - orr r5, r7\n\ - strh r5, [r3]\n\ - add r3, #0x2\n\ - orr r6, r7\n\ - strh r6, [r3]\n\ - orr r0, r7\n\ - strh r0, [r3, #0x2]\n\ - add sp, #0x24\n\ - pop {r3-r5}\n\ - mov r8, r3\n\ - mov r9, r4\n\ - mov r10, r5\n\ - pop {r4-r7}\n\ - pop {r0}\n\ - bx r0\n\ - .pool"); -} -#endif void SaveTextColors(u8 *fgColor, u8 *bgColor, u8 *shadowColor) {