Start decompiling contest_link_80F57C4.c

This commit is contained in:
Marcus Huderle 2019-01-03 20:28:42 -06:00 committed by huderlem
parent 2857f7fff9
commit fd201f8395
5 changed files with 169 additions and 326 deletions

View File

@ -5,332 +5,6 @@
.text
thumb_func_start sub_80F57C4
sub_80F57C4: @ 80F57C4
push {r4,lr}
movs r0, 0
movs r1, 0x40
bl SetGpuReg
movs r0, 0
bl ResetBgsAndClearDma3BusyFlags
ldr r1, =gUnknown_0858D888
movs r0, 0
movs r2, 0x4
bl InitBgsFromTemplates
movs r4, 0
_080F57E0:
lsls r0, r4, 24
lsrs r0, 24
ldr r1, =gUnknown_0203A034
ldr r1, [r1]
lsls r2, r4, 2
adds r1, 0xC
adds r1, r2
ldr r1, [r1]
bl SetBgTilemapBuffer
adds r4, 0x1
cmp r4, 0x3
ble _080F57E0
ldr r0, =gUnknown_0858D898
bl InitWindows
bl DeactivateAllTextPrinters
movs r0, 0x4C
movs r1, 0
bl SetGpuReg
ldr r1, =0x00003f3f
movs r0, 0x48
bl SetGpuReg
ldr r1, =0x00003f2e
movs r0, 0x4A
bl SetGpuReg
movs r0, 0x40
movs r1, 0
bl SetGpuReg
movs r0, 0x44
movs r1, 0
bl SetGpuReg
movs r0, 0x42
movs r1, 0
bl SetGpuReg
movs r0, 0x46
movs r1, 0
bl SetGpuReg
movs r0, 0x50
movs r1, 0
bl SetGpuReg
movs r0, 0x52
movs r1, 0
bl SetGpuReg
movs r0, 0x54
movs r1, 0
bl SetGpuReg
movs r0, 0x10
movs r1, 0
bl SetGpuReg
movs r0, 0x12
movs r1, 0
bl SetGpuReg
movs r0, 0x14
movs r1, 0
bl SetGpuReg
movs r0, 0x16
movs r1, 0
bl SetGpuReg
movs r0, 0x18
movs r1, 0
bl SetGpuReg
movs r0, 0x1A
movs r1, 0
bl SetGpuReg
movs r0, 0x1C
movs r1, 0
bl SetGpuReg
movs r0, 0x1E
movs r1, 0
bl SetGpuReg
movs r1, 0xFF
lsls r1, 8
movs r0, 0
bl SetGpuRegBits
ldr r0, =gBattle_BG0_X
movs r1, 0
strh r1, [r0]
ldr r0, =gBattle_BG0_Y
strh r1, [r0]
ldr r0, =gBattle_BG1_X
strh r1, [r0]
ldr r0, =gBattle_BG1_Y
strh r1, [r0]
ldr r0, =gBattle_BG2_X
strh r1, [r0]
ldr r0, =gBattle_BG2_Y
strh r1, [r0]
ldr r0, =gBattle_BG3_X
strh r1, [r0]
ldr r0, =gBattle_BG3_Y
strh r1, [r0]
ldr r0, =gBattle_WIN0H
strh r1, [r0]
ldr r0, =gBattle_WIN0V
strh r1, [r0]
ldr r0, =gBattle_WIN1H
strh r1, [r0]
ldr r0, =gBattle_WIN1V
strh r1, [r0]
pop {r4}
pop {r0}
bx r0
.pool
thumb_func_end sub_80F57C4
thumb_func_start sub_80F591C
sub_80F591C: @ 80F591C
push {r4-r7,lr}
mov r7, r10
mov r6, r9
mov r5, r8
push {r5-r7}
sub sp, 0x10
ldr r0, =gUnknown_08C19588
movs r1, 0xC0
lsls r1, 19
bl LZDecompressVram
ldr r1, =gUnknown_08C1A12C
movs r0, 0x3
movs r2, 0
movs r3, 0
bl CopyToBgTilemapBuffer
ldr r1, =gUnknown_08C1A000
movs r0, 0x2
movs r2, 0
movs r3, 0
bl CopyToBgTilemapBuffer
ldr r1, =gUnknown_08C19EEC
movs r0, 0
movs r2, 0
movs r3, 0
bl CopyToBgTilemapBuffer
bl sub_80F71C8
ldr r0, =gUnknown_08C1A2B4
movs r2, 0x80
lsls r2, 2
movs r1, 0
bl LoadCompressedPalette
ldr r0, =gUnknown_0858D6B0
movs r1, 0xF0
movs r2, 0x20
bl LoadPalette
movs r7, 0
movs r0, 0x1
mov r8, r0
_080F5976:
lsls r5, r7, 24
lsrs r5, 24
adds r0, r5, 0
movs r1, 0x1
bl sub_80F7310
adds r4, r0, 0
lsls r4, 24
lsrs r4, 24
adds r0, r5, 0
movs r1, 0x1
bl sub_80F7364
lsls r0, 24
lsrs r0, 24
str r0, [sp, 0x8]
movs r6, 0
lsls r1, r7, 1
adds r2, r7, 0x1
str r2, [sp, 0xC]
lsls r4, 24
asrs r4, 24
mov r10, r4
adds r1, r7
adds r0, r1, 0x6
lsls r0, 24
mov r9, r0
adds r1, 0x5
lsls r7, r1, 24
_080F59B0:
ldr r1, =0x000060b2
cmp r6, r10
bge _080F59B8
adds r1, 0x2
_080F59B8:
ldr r4, [sp, 0x8]
lsls r0, r4, 24
asrs r0, 24
adds r2, r0, 0
cmp r0, 0
bge _080F59C6
negs r2, r0
_080F59C6:
cmp r6, r2
bge _080F59F4
ldr r5, =0x000060a4
cmp r0, 0
bge _080F59F6
adds r5, 0x2
b _080F59F6
.pool
_080F59F4:
ldr r5, =0x000060a2
_080F59F6:
adds r4, r6, 0
adds r4, 0x13
lsls r4, 24
lsrs r4, 24
mov r0, r8
str r0, [sp]
str r0, [sp, 0x4]
movs r0, 0x1
adds r2, r4, 0
lsrs r3, r7, 24
bl FillBgTilemapBufferRect_Palette0
mov r2, r8
str r2, [sp]
str r2, [sp, 0x4]
movs r0, 0x1
adds r1, r5, 0
adds r2, r4, 0
mov r4, r9
lsrs r3, r4, 24
bl FillBgTilemapBufferRect_Palette0
adds r6, 0x1
cmp r6, 0x9
ble _080F59B0
ldr r7, [sp, 0xC]
cmp r7, 0x3
ble _080F5976
movs r0, 0
bl CopyBgTilemapBufferToVram
movs r0, 0x1
bl CopyBgTilemapBufferToVram
movs r0, 0x2
bl CopyBgTilemapBufferToVram
movs r0, 0x3
bl CopyBgTilemapBufferToVram
movs r0, 0
bl ShowBg
movs r0, 0x1
bl ShowBg
movs r0, 0x2
bl ShowBg
movs r0, 0x3
bl ShowBg
add sp, 0x10
pop {r3-r5}
mov r8, r3
mov r9, r4
mov r10, r5
pop {r4-r7}
pop {r0}
bx r0
.pool
thumb_func_end sub_80F591C
thumb_func_start sub_80F5A74
sub_80F5A74: @ 80F5A74
push {r4-r7,lr}
lsls r0, 24
lsrs r0, 24
adds r5, r0, 0
lsls r1, r5, 6
ldr r0, =gContestMons
adds r7, r1, r0
ldr r6, =gDisplayedStringBattle
ldr r0, =gContestPlayerMonIndex
ldrb r0, [r0]
cmp r5, r0
bne _080F5A96
ldr r1, =gText_ColorDarkGrey
adds r0, r6, 0
bl StringCopy
adds r6, r0, 0
_080F5A96:
adds r1, r7, 0x2
adds r0, r6, 0
bl StringCopy
ldr r4, =gDisplayedStringBattle
adds r0, r5, 0
adds r1, r4, 0
movs r2, 0
bl sub_80F7ED0
ldr r1, =gText_Slash
adds r0, r6, 0
bl StringCopy
adds r1, r7, 0
adds r1, 0xD
adds r0, r6, 0
bl StringAppend
adds r0, r5, 0
adds r1, r4, 0
movs r2, 0x32
bl sub_80F7ED0
pop {r4-r7}
pop {r0}
bx r0
.pool
thumb_func_end sub_80F5A74
thumb_func_start sub_80F5AE0
sub_80F5AE0: @ 80F5AE0
push {r4,lr}
movs r4, 0
_080F5AE4:
lsls r0, r4, 24
lsrs r0, 24
bl sub_80F5A74
adds r4, 0x1
cmp r4, 0x3
ble _080F5AE4
movs r0, 0x1
bl CopyBgTilemapBufferToVram
pop {r4}
pop {r0}
bx r0
thumb_func_end sub_80F5AE0
thumb_func_start sub_80F5B00
sub_80F5B00: @ 80F5B00
push {r4-r6,lr}

View File

@ -4827,4 +4827,12 @@ extern const u32 gRouletteCreditTiles[];
extern const u32 gRouletteNumbersTiles[];
extern const u32 gRouletteMultiplierTiles[];
// Contest Link
extern const u32 gUnknown_0858D6B0[];
extern const u32 gUnknown_08C19588[];
extern const u32 gUnknown_08C19EEC[];
extern const u32 gUnknown_08C1A000[];
extern const u32 gUnknown_08C1A12C[];
extern const u32 gUnknown_08C1A2B4[];
#endif //GUARD_GRAPHICS_H

View File

@ -2207,4 +2207,7 @@ extern const u8 MatchCall_BattlePyramidText12[];
extern const u8 MatchCall_BattlePyramidText13[];
extern const u8 MatchCall_BattlePyramidText14[];
// Contest Link
extern const u8 gText_ColorDarkGrey[];
#endif //GUARD_STRINGS_H

View File

@ -146,6 +146,7 @@ SECTIONS {
src/record_mixing.o(.text);
src/secret_base.o(.text);
src/tv.o(.text);
src/contest_link_80F57C4.o(.text);
asm/contest_link_80F57C4.o(.text);
src/script_pokemon_util_80F87D8.o(.text);
src/field_poison.o(.text);

157
src/contest_link_80F57C4.c Executable file
View File

@ -0,0 +1,157 @@
#include "global.h"
#include "battle.h"
#include "bg.h"
#include "contest.h"
#include "decompress.h"
#include "event_data.h"
#include "gpu_regs.h"
#include "graphics.h"
#include "link.h"
#include "palette.h"
#include "random.h"
#include "string_util.h"
#include "strings.h"
#include "task.h"
#include "text.h"
#include "window.h"
struct ContestLink80F57C4
{
u8 filler0[0xC];
u8 *unkC[4];
};
extern struct ContestLink80F57C4 *gUnknown_0203A034;
extern const struct BgTemplate gUnknown_0858D888[4];
extern const struct WindowTemplate gUnknown_0858D898[];
void sub_80F71C8(void);
u8 sub_80F7310(u8, u8);
s8 sub_80F7364(u8, u8);
void sub_80F7ED0(int, u8 *, int);
void sub_80F57C4(void)
{
int i;
SetGpuReg(REG_OFFSET_DISPCNT, DISPCNT_OBJ_1D_MAP);
ResetBgsAndClearDma3BusyFlags(0);
InitBgsFromTemplates(0, gUnknown_0858D888, ARRAY_COUNT(gUnknown_0858D888));
for (i = 0; i < 4; i++)
SetBgTilemapBuffer(i, gUnknown_0203A034->unkC[i]);
InitWindows(gUnknown_0858D898);
DeactivateAllTextPrinters();
SetGpuReg(REG_OFFSET_MOSAIC, 0);
SetGpuReg(REG_OFFSET_WININ, WININ_WIN0_BG_ALL | WININ_WIN0_OBJ | WININ_WIN0_CLR | WININ_WIN1_BG_ALL | WININ_WIN1_OBJ | WININ_WIN1_CLR);
SetGpuReg(REG_OFFSET_WINOUT, WINOUT_WIN01_BG1 | WINOUT_WIN01_BG2 | WINOUT_WIN01_BG3 | WINOUT_WIN01_CLR | WINOUT_WINOBJ_BG_ALL | WINOUT_WINOBJ_OBJ | WINOUT_WINOBJ_CLR);
SetGpuReg(REG_OFFSET_WIN0H, 0);
SetGpuReg(REG_OFFSET_WIN0V, 0);
SetGpuReg(REG_OFFSET_WIN1H, 0);
SetGpuReg(REG_OFFSET_WIN1V, 0);
SetGpuReg(REG_OFFSET_BLDCNT, 0);
SetGpuReg(REG_OFFSET_BLDALPHA, 0);
SetGpuReg(REG_OFFSET_BLDY, 0);
SetGpuReg(REG_OFFSET_BG0HOFS, 0);
SetGpuReg(REG_OFFSET_BG0VOFS, 0);
SetGpuReg(REG_OFFSET_BG1HOFS, 0);
SetGpuReg(REG_OFFSET_BG1VOFS, 0);
SetGpuReg(REG_OFFSET_BG2HOFS, 0);
SetGpuReg(REG_OFFSET_BG2VOFS, 0);
SetGpuReg(REG_OFFSET_BG3HOFS, 0);
SetGpuReg(REG_OFFSET_BG3VOFS, 0);
SetGpuRegBits(REG_OFFSET_DISPCNT, DISPCNT_BG_ALL_ON | DISPCNT_OBJ_ON | DISPCNT_WIN0_ON | DISPCNT_WIN1_ON | DISPCNT_OBJWIN_ON);
gBattle_BG0_X = 0;
gBattle_BG0_Y = 0;
gBattle_BG1_X = 0;
gBattle_BG1_Y = 0;
gBattle_BG2_X = 0;
gBattle_BG2_Y = 0;
gBattle_BG3_X = 0;
gBattle_BG3_Y = 0;
gBattle_WIN0H = 0;
gBattle_WIN0V = 0;
gBattle_WIN1H = 0;
gBattle_WIN1V = 0;
}
void sub_80F591C(void)
{
int i, j;
s8 var0;
s8 var1;
int var2;
u16 tile1, tile2;
LZDecompressVram(gUnknown_08C19588, (void *)BG_CHAR_ADDR(0));
CopyToBgTilemapBuffer(3, gUnknown_08C1A12C, 0, 0);
CopyToBgTilemapBuffer(2, gUnknown_08C1A000, 0, 0);
CopyToBgTilemapBuffer(0, gUnknown_08C19EEC, 0, 0);
sub_80F71C8();
LoadCompressedPalette(gUnknown_08C1A2B4, 0, 0x200);
LoadPalette(gUnknown_0858D6B0, 0xF0, 0x20);
for (i = 0; i < 4; i++)
{
var0 = sub_80F7310(i, 1);
var1 = sub_80F7364(i, 1);
for (j = 0; j < 10; j++)
{
tile1 = 0x60B2;
if (j < var0)
tile1 += 2;
var2 = var1;
if (var1 < 0)
var2 = -var2;
if (j < var2)
{
tile2 = 0x60A4;
if (var1 < 0)
tile2 += 2;
}
else
{
tile2 = 0x60A2;
}
FillBgTilemapBufferRect_Palette0(1, tile1, j + 19, i * 3 + 5, 1, 1);
FillBgTilemapBufferRect_Palette0(1, tile2, j + 19, i * 3 + 6, 1, 1);
}
}
CopyBgTilemapBufferToVram(0);
CopyBgTilemapBufferToVram(1);
CopyBgTilemapBufferToVram(2);
CopyBgTilemapBufferToVram(3);
ShowBg(0);
ShowBg(1);
ShowBg(2);
ShowBg(3);
}
static void sub_80F5A74(u8 monIndex)
{
struct ContestPokemon *mon = &gContestMons[monIndex];
u8 *str = gDisplayedStringBattle;
if (monIndex == gContestPlayerMonIndex)
str = StringCopy(gDisplayedStringBattle, gText_ColorDarkGrey);
StringCopy(str, mon->nickname);
sub_80F7ED0(monIndex, gDisplayedStringBattle, 0);
StringCopy(str, gText_Slash);
StringAppend(str, mon->trainerName);
sub_80F7ED0(monIndex, gDisplayedStringBattle, 50);
}
void sub_80F5AE0(void)
{
int i;
for (i = 0; i < 4; i++)
sub_80F5A74(i);
CopyBgTilemapBufferToVram(1);
}