Decompiled sub_81C7764

This commit is contained in:
Phlosioneer 2019-02-13 02:31:24 -05:00
parent 7c405e08d0
commit 3bb4057bad
3 changed files with 59 additions and 95 deletions

View File

@ -5,98 +5,6 @@
.text
thumb_func_start sub_81C7764
sub_81C7764: @ 81C7764
push {r4,lr}
sub sp, 0x4
cmp r0, 0x1
beq _081C77B0
cmp r0, 0x1
bgt _081C7776
cmp r0, 0
beq _081C7780
b _081C782A
_081C7776:
cmp r0, 0x2
beq _081C77FC
cmp r0, 0x3
beq _081C780E
b _081C782A
_081C7780:
movs r1, 0x82
lsls r1, 5
movs r0, 0
bl SetGpuReg
bl FreeAllWindowBuffers
movs r0, 0
bl ResetBgsAndClearDma3BusyFlags
ldr r1, =gUnknown_0861FA04
movs r0, 0
movs r2, 0x1
bl InitBgsFromTemplates
bl sub_8199D98
bl reset_temp_tile_data_buffers
movs r0, 0x1
b _081C782C
.pool
_081C77B0:
movs r0, 0
bl sub_81C763C
adds r4, r0, 0
ldr r1, =gPokenavHeader_Gfx
movs r0, 0
str r0, [sp]
movs r2, 0
movs r3, 0
bl decompress_and_copy_tile_data_to_vram
adds r4, 0x2C
movs r0, 0
adds r1, r4, 0
bl SetBgTilemapBuffer
ldr r1, =gPokenavHeader_Tilemap
movs r0, 0
movs r2, 0
movs r3, 0
bl CopyToBgTilemapBuffer
ldr r0, =gPokenavHeader_Pal
movs r1, 0
movs r2, 0x20
bl sub_81C7944
movs r0, 0
bl CopyBgTilemapBufferToVram
movs r0, 0
b _081C782C
.pool
_081C77FC:
bl free_temp_tile_data_buffers_if_possible
lsls r0, 24
cmp r0, 0
bne _081C7818
bl sub_81C7B74
movs r0, 0
b _081C782C
_081C780E:
bl IsDma3ManagerBusyWithBgCopy
lsls r0, 24
cmp r0, 0
beq _081C781C
_081C7818:
movs r0, 0x2
b _081C782C
_081C781C:
bl sub_81C7C28
bl sub_81C7D28
movs r0, 0
bl ShowBg
_081C782A:
movs r0, 0x4
_081C782C:
add sp, 0x4
pop {r4}
pop {r1}
bx r1
thumb_func_end sub_81C7764
thumb_func_start sub_81C7834
sub_81C7834: @ 81C7834
push {r4,r5,lr}

View File

@ -4007,9 +4007,12 @@ extern const u32 gBerryPalette_Enigma[];
//credits
extern const u32 gCreditsCopyrightEnd_Gfx[];
//pokenav condition marker
//pokenav
extern const u8 gPokenavConditionMarker_Gfx[];
extern const u16 gPokenavConditionMarker_Pal[];
extern const u16 gPokenavHeader_Pal[];
extern const u32 gPokenavHeader_Gfx[];
extern const u32 gPokenavHeader_Tilemap[];
extern const u32 gUnknown_08D9862C[];
extern const u32 gUnknown_08D98CC8[];

View File

@ -9,6 +9,10 @@
#include "sound.h"
#include "constants/songs.h"
#include "window.h"
#include "gpu_regs.h"
#include "bg.h"
#include "menu.h"
#include "graphics.h"
#define UNKNOWN_OFFSET 100000
@ -29,6 +33,8 @@ struct UnknownStruct_sub_81C76C4 {
u32 data[523];
};
extern struct BgTemplate gUnknown_0861FA04;
extern struct UnknownStruct_0203CF40 *gUnknown_0203CF40;
extern u8 gUnknown_0203CF3C;
extern struct UnknownStruct_0861F3EC gUnknown_0861F3EC[7]; // Unknown size; at least 7.
@ -36,11 +42,15 @@ extern struct UnknownStruct_0861F3EC gUnknown_0861F3EC[7]; // Unknown size; at l
extern void sub_81C7834(u32 (*a0)(void), u32(*a1)(void));
extern void sub_81C7850(u32 a0);
extern void sub_81C9430(void);
extern u32 sub_81C7764(u32 a0);
extern u32 sub_81C786C(void);
extern void sub_81CAADC(void);
extern void sub_81C99D4(void);
extern void sub_81C7C94(void);
extern void sub_8199D98(void);
extern void sub_81C7944(void* palette, u32 a1, u32 a2);
extern void sub_81C7B74(void);
extern void sub_81C7C28(void);
extern void sub_81C7D28(void);
bool32 sub_81C756C(u32 a0);
@ -49,6 +59,7 @@ u32 AnyMonHasRibbon(void);
u32 sub_81C75E0(void);
u32 sub_81C75D4(void);
u32 sub_81C76FC(void);
u32 sub_81C7764(s32 a0);
bool32 sub_81C7738(void);
void sub_81C7360(struct UnknownStruct_0203CF40 *a0);
void sub_81C7650(u32 index);
@ -62,7 +73,7 @@ void sub_81C7418(void);
void sub_81C7400(void);
void sub_81C72BC(void);
u32 sub_81C7078(u32 (*a0)(u32), u32 a1)
u32 sub_81C7078(u32 (*a0)(s32), u32 a1)
{
u16 taskId;
@ -455,4 +466,46 @@ bool32 sub_81C7738(void) {
} else {
return TRUE;
}
}
u32 sub_81C7764(s32 a0) {
// This is a guess.
struct UnknownStruct_sub_81C76C4 *v1;
switch (a0) {
case 0:
SetGpuReg(0, 0x82 << 5);
FreeAllWindowBuffers();
ResetBgsAndClearDma3BusyFlags(0);
InitBgsFromTemplates(0, &gUnknown_0861FA04, 1);
sub_8199D98();
reset_temp_tile_data_buffers();
return 1;
case 1:
v1 = sub_81C763C(0);
decompress_and_copy_tile_data_to_vram(0, &gPokenavHeader_Gfx, 0, 0, 0);
SetBgTilemapBuffer(0, &v1->data[11]);
CopyToBgTilemapBuffer(0, &gPokenavHeader_Tilemap, 0, 0);
sub_81C7944(&gPokenavHeader_Pal, 0, 0x20);
CopyBgTilemapBufferToVram(0);
return 0;
case 2:
if (free_temp_tile_data_buffers_if_possible()) {
return 2;
} else {
sub_81C7B74();
return 0;
}
case 3:
if (IsDma3ManagerBusyWithBgCopy()) {
return 2;
} else {
sub_81C7C28();
sub_81C7D28();
ShowBg(0);
return 4;
}
default:
return 4;
}
}