Merge pull request #235 from deppong/sub_8099360-809965C
Some checks failed
GithubCI / build (push) Has been cancelled

Decomp and integrate sub_8099360 - sub_809965C.
This commit is contained in:
Seth Barberee 2024-10-22 07:27:45 -07:00 committed by GitHub
commit e3e15a329a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
8 changed files with 372 additions and 396 deletions

View File

@ -5,392 +5,6 @@
.text
thumb_func_start sub_8099360
sub_8099360:
push {r4,lr}
adds r4, r0, 0
movs r0, 0
movs r1, 0x13
bl GetScriptVarValue
lsls r0, 16
asrs r0, 16
cmp r0, 0x52
beq _08099378
movs r0, 0
b _0809938E
_08099378:
movs r0, 0
movs r1, 0x14
bl GetScriptVarValue
lsls r0, 16
asrs r0, 16
bl GetDungeonInfo_80A2608
ldrb r0, [r0, 0xC]
strb r0, [r4]
movs r0, 0x1
_0809938E:
pop {r4}
pop {r1}
bx r1
thumb_func_end sub_8099360
thumb_func_start sub_8099394
sub_8099394:
push {r4,lr}
adds r4, r0, 0
movs r0, 0
movs r1, 0x13
bl GetScriptVarValue
lsls r0, 16
asrs r0, 16
cmp r0, 0x50
beq _080993AC
movs r0, 0
b _080993B8
_080993AC:
movs r0, 0
movs r1, 0x14
bl GetScriptVarValue
strb r0, [r4]
movs r0, 0x1
_080993B8:
pop {r4}
pop {r1}
bx r1
thumb_func_end sub_8099394
thumb_func_start sub_80993C0
sub_80993C0:
push {lr}
lsls r0, 24
ldr r2, _080993D4
movs r1, 0
cmp r0, 0
bne _080993CE
movs r1, 0x1
_080993CE:
strb r1, [r2]
pop {r0}
bx r0
.align 2, 0
_080993D4: .4byte gUnknown_20398B8
thumb_func_end sub_80993C0
thumb_func_start sub_80993D8
sub_80993D8:
push {lr}
bl sub_80A4B38
pop {r0}
bx r0
thumb_func_end sub_80993D8
thumb_func_start sub_80993E4
sub_80993E4:
push {lr}
bl sub_80A4B54
pop {r0}
bx r0
thumb_func_end sub_80993E4
thumb_func_start sub_80993F0
sub_80993F0:
push {r4-r7,lr}
mov r7, r10
mov r6, r9
mov r5, r8
push {r5-r7}
sub sp, 0x28
movs r0, 0
mov r10, r0
bl sub_801180C
movs r0, 0x10
bl FadeOutAllMusic
ldr r1, _0809948C
ldr r2, _08099490
adds r0, r2, 0
strh r0, [r1]
movs r0, 0
bl UpdateFadeInTile
movs r0, 0
movs r1, 0x14
bl sub_80095CC
movs r0, 0
movs r1, 0x1
movs r2, 0x1
bl xxx_call_save_unk_text_struct_800641C
movs r0, 0
movs r1, 0x14
bl sub_8009408
bl sub_8099648
bl sub_809975C
bl sub_809D0AC
bl sub_8014144
movs r0, 0
movs r1, 0
bl sub_8005838
bl AllocGroundMapAction
mov r7, sp
add r0, sp, 0x8
mov r8, r0
_08099454:
bl sub_801D9E4
lsls r0, 24
cmp r0, 0
beq _0809949C
mov r0, r10
bl sub_801DA58
_08099464:
movs r0, 0
movs r1, 0
bl sub_8005838
movs r0, 0
bl sub_8012A18
bl sub_801DA78
cmp r0, 0x2
beq _08099494
cmp r0, 0x3
bne _08099464
bl sub_801DAC0
lsls r0, 16
asrs r0, 16
mov r10, r0
b _080994A2
.align 2, 0
_0809948C: .4byte gUnknown_2026E4E
_08099490: .4byte 0x00000808
_08099494:
movs r1, 0x1
negs r1, r1
mov r10, r1
b _080994A2
_0809949C:
movs r2, 0x1
negs r2, r2
mov r10, r2
_080994A2:
bl sub_801DB0C
movs r0, 0x1
negs r0, r0
cmp r10, r0
bne _080994B0
b _08099624
_080994B0:
movs r0, 0
movs r1, 0x1
movs r2, 0x1
bl xxx_call_save_unk_text_struct_800641C
bl GroundMap_Reset
bl sub_809D0BC
mov r0, r10
bl GroundMap_Select
mov r0, sp
mov r1, r8
bl sub_80A579C
ldr r0, [r7, 0x4]
movs r1, 0xC0
lsls r1, 4
adds r0, r1
str r0, [r7, 0x4]
mov r2, r8
ldr r0, [r2, 0x4]
adds r0, r1
str r0, [r2, 0x4]
ldr r0, [sp]
ldr r1, _08099520
adds r0, r1
str r0, [sp]
ldr r0, [r7, 0x4]
adds r0, r1
str r0, [r7, 0x4]
ldr r0, [sp, 0x8]
movs r2, 0x80
lsls r2, 3
adds r0, r2
str r0, [sp, 0x8]
mov r0, r8
ldr r1, [r0, 0x4]
adds r1, r2
str r1, [r0, 0x4]
ldr r2, [sp, 0x8]
ldr r0, [sp]
subs r0, r2, r0
str r0, [sp, 0x20]
ldr r0, [r7, 0x4]
subs r0, r1, r0
str r0, [sp, 0x24]
movs r4, 0
movs r5, 0
movs r0, 0x4
bl sub_80999E8
mov r9, r5
b _08099604
.align 2, 0
_08099520: .4byte 0xfffffc00
_08099524:
ldr r0, _0809953C
ldrh r1, [r0, 0x2]
ldrh r6, [r0]
movs r0, 0x4
ands r1, r0
cmp r1, 0
beq _08099540
bl sub_80999FC
movs r1, 0x1
mov r9, r1
b _080995AE
.align 2, 0
_0809953C: .4byte gRealInputs
_08099540:
adds r0, r6, 0
bl sub_809CFE8
lsls r0, 24
asrs r1, r0, 24
movs r2, 0x1
negs r2, r2
cmp r1, r2
beq _0809959A
add r0, sp, 0x10
movs r2, 0x80
lsls r2, 1
bl SetVecFromDirectionSpeed
ldr r2, [sp, 0x10]
ldr r3, [sp, 0x14]
movs r0, 0x2
ands r6, r0
cmp r6, 0
beq _0809956A
movs r0, 0x4
_0809956A:
adds r1, r0, 0
muls r1, r2
adds r1, r4
adds r4, r1, 0
muls r0, r3
adds r5, r0
cmp r1, 0
bge _0809957E
movs r4, 0
b _08099588
_0809957E:
ldr r0, [sp, 0x20]
cmp r4, r0
blt _08099588
adds r4, r0, 0
subs r4, 0x1
_08099588:
cmp r5, 0
bge _08099590
movs r5, 0
b _0809959A
_08099590:
ldr r1, [sp, 0x24]
cmp r5, r1
blt _0809959A
adds r5, r1, 0
subs r5, 0x1
_0809959A:
ldr r0, [sp]
adds r0, r4
str r0, [sp, 0x18]
ldr r0, [r7, 0x4]
adds r0, r5
add r1, sp, 0x18
str r0, [r1, 0x4]
movs r0, 0
bl sub_809D158
_080995AE:
bl sub_809D25C
bl sub_80A59DC
bl xxx_draw_string_80144C4
movs r0, 0
movs r1, 0
bl sub_8005838
bl sub_80060EC
ldr r0, _08099620
ldr r0, [r0]
ldrb r0, [r0, 0xA]
bl nullsub_8
bl sub_8005180
bl sub_8099BE4
bl sub_8099744
bl sub_8011860
bl sub_800CB20
bl LoadBufferedInputs
bl nullsub_120
bl sub_80A5E70
bl xxx_call_update_bg_vram
bl CopySpritesToOam
bl sub_8005304
bl sub_8099750
bl sub_8009908
_08099604:
bl xxx_call_update_bg_sound_input
movs r0, 0
bl ResetSprites
mov r2, r9
cmp r2, 0
beq _08099524
bl sub_8099B94
lsls r0, 24
cmp r0, 0
bne _080995AE
b _08099454
.align 2, 0
_08099620: .4byte gGameOptionsRef
_08099624:
movs r0, 0x10
bl FadeOutAllMusic
bl FreeGroundMapAction
bl sub_8099768
bl nullsub_103
add sp, 0x28
pop {r3-r5}
mov r8, r3
mov r9, r4
mov r10, r5
pop {r4-r7}
pop {r0}
bx r0
thumb_func_end sub_80993F0
thumb_func_start sub_8099648
sub_8099648:
push {lr}
bl sub_8003600
bl sub_809965C
pop {r0}
bx r0
thumb_func_end sub_8099648
thumb_func_start nullsub_103
nullsub_103:
bx lr
thumb_func_end nullsub_103
thumb_func_start sub_809965C
sub_809965C:
push {r4,lr}
movs r0, 0
bl sub_8099690
ldr r0, _08099688
ldr r1, _0809968C
bl OpenFileAndGetFileDataPtr
adds r4, r0, 0
movs r0, 0xF8
lsls r0, 1
ldr r1, [r4, 0x4]
movs r2, 0x10
bl sub_800388C
adds r0, r4, 0
bl CloseFile
pop {r4}
pop {r0}
bx r0
.align 2, 0
_08099688: .4byte gUnknown_811601C
_0809968C: .4byte gSystemFileArchive
thumb_func_end sub_809965C
thumb_func_start sub_8099690
sub_8099690:
push {r4-r6,lr}

View File

@ -1,10 +1,24 @@
#ifndef GUARD_CODE_8099360_H
#define GUARD_CODE_8099360_H
// code_8099360.s
extern void sub_80993D8(void);
extern void sub_80993E4(void);
bool8 sub_8099360(u8 *);
u8 sub_8099394(u8 *);
void sub_80993C0(bool8);
void sub_80993D8(void);
void sub_80993E4(void);
// UNUSED
void sub_80993F0(void);
// ------
void sub_8099648(void);
void nullsub_103(void);
void sub_809965C(void);
extern void sub_8099690(u32);
// code_8099360.s
extern void sub_8099A5C(u32, u32, u32);
extern void sub_8099AFC(u32, u32, u32);
extern bool8 sub_8099B94(void);

View File

@ -342,6 +342,7 @@ SECTIONS {
src/ground_main.o(.text);
asm/code_8098BDC.o(.text);
src/code_8099328.o(.text);
src/code_8099360.o(.text);
asm/code_8099360.o(.text);
src/code_809A560.o(.text);
asm/code_809A560.o(.text);

View File

@ -28,6 +28,7 @@
#include "weather.h"
#include "moves.h"
#include "code_8094F88.h"
#include "code_8099360.h"
#include "bg_palette_buffer.h"
#include "exclusive_pokemon.h"
#include "constants/dungeon.h"
@ -337,7 +338,6 @@ extern void sub_80095CC(u32, u32);
extern void sub_8081BF4(u8 *r0, u32 r1);
extern void PrintFieldMessage(u32, const u8 *, u32);
extern bool8 IsLevelResetTo1(u8 dungeon);
extern u8 sub_8099394(u8 *);
extern void sub_8068A84(PokemonStruct1 *pokemon);
extern void sub_807EAA0(u32, u32);
extern void sub_803D4D0(void);

349
src/code_8099360.c Normal file
View File

@ -0,0 +1,349 @@
#include "global.h"
#include "file_system.h"
#include "event_flag.h"
#include "code_80A26CC.h"
extern struct FileArchive gSystemFileArchive;
extern const u8 gUnknown_811601C[];
extern u8 gUnknown_20398B8;
extern void sub_8003600(void);
extern s32 sub_800388C(u16, u8 *, u8);
extern void sub_80A4B38(void);
extern void sub_80A4B54(void);
extern void sub_8099690(u32);
bool8 sub_8099360(u8 *dungeonId) {
s16 script_disc;
DungeonInfo* dungeonInfo;
script_disc = GetScriptVarValue(NULL, DUNGEON_ENTER);
if (script_disc == 0x52) {
script_disc = GetScriptVarValue(NULL, DUNGEON_ENTER_INDEX);
dungeonInfo = (DungeonInfo *)GetDungeonInfo_80A2608(script_disc);
*dungeonId = dungeonInfo->dungeonIndex;
return TRUE;
}
return FALSE;
}
u8 sub_8099394(u8 *param) {
s16 script_disc;
script_disc = GetScriptVarValue(NULL, DUNGEON_ENTER);
if (script_disc == 0x50) {
script_disc = GetScriptVarValue(NULL, DUNGEON_ENTER_INDEX);
*param = script_disc;
return TRUE;
}
return FALSE;
}
void sub_80993C0(bool8 param) {
gUnknown_20398B8 = (param == FALSE);
}
void sub_80993D8(void) {
sub_80A4B38();
}
void sub_80993E4(void) {
sub_80A4B54();
}
/*
TODO: this is a function that is never called
and is very long. I didn't want to split up the
file or spend time decomping so here it is in
asm();
*/
void sub_8099648(void);
NAKED void sub_80993F0(void)
{
asm_unified(" .text\n"
" push {r4-r7,lr}\n"
" mov r7, r10\n"
" mov r6, r9\n"
" mov r5, r8\n"
" push {r5-r7}\n"
" sub sp, 0x28\n"
" movs r0, 0\n"
" mov r10, r0\n"
" bl sub_801180C\n"
" movs r0, 0x10\n"
" bl FadeOutAllMusic\n"
" ldr r1, _0809948C\n"
" ldr r2, _08099490\n"
" adds r0, r2, 0\n"
" strh r0, [r1]\n"
" movs r0, 0\n"
" bl UpdateFadeInTile\n"
" movs r0, 0\n"
" movs r1, 0x14\n"
" bl sub_80095CC\n"
" movs r0, 0\n"
" movs r1, 0x1\n"
" movs r2, 0x1\n"
" bl xxx_call_save_unk_text_struct_800641C\n"
" movs r0, 0\n"
" movs r1, 0x14\n"
" bl sub_8009408\n"
" bl sub_8099648\n"
" bl sub_809975C\n"
" bl sub_809D0AC\n"
" bl sub_8014144\n"
" movs r0, 0\n"
" movs r1, 0\n"
" bl sub_8005838\n"
" bl AllocGroundMapAction\n"
" mov r7, sp\n"
" add r0, sp, 0x8\n"
" mov r8, r0\n"
"_08099454:\n"
" bl sub_801D9E4\n"
" lsls r0, 24\n"
" cmp r0, 0\n"
" beq _0809949C\n"
" mov r0, r10\n"
" bl sub_801DA58\n"
"_08099464:\n"
" movs r0, 0\n"
" movs r1, 0\n"
" bl sub_8005838\n"
" movs r0, 0\n"
" bl sub_8012A18\n"
" bl sub_801DA78\n"
" cmp r0, 0x2\n"
" beq _08099494\n"
" cmp r0, 0x3\n"
" bne _08099464\n"
" bl sub_801DAC0\n"
" lsls r0, 16\n"
" asrs r0, 16\n"
" mov r10, r0\n"
" b _080994A2\n"
" .align 2, 0\n"
"_0809948C: .4byte gUnknown_2026E4E\n"
"_08099490: .4byte 0x00000808\n"
"_08099494:\n"
" movs r1, 0x1\n"
" negs r1, r1\n"
" mov r10, r1\n"
" b _080994A2\n"
"_0809949C:\n"
" movs r2, 0x1\n"
" negs r2, r2\n"
" mov r10, r2\n"
"_080994A2:\n"
" bl sub_801DB0C\n"
" movs r0, 0x1\n"
" negs r0, r0\n"
" cmp r10, r0\n"
" bne _080994B0\n"
" b _08099624\n"
"_080994B0:\n"
" movs r0, 0\n"
" movs r1, 0x1\n"
" movs r2, 0x1\n"
" bl xxx_call_save_unk_text_struct_800641C\n"
" bl GroundMap_Reset\n"
" bl sub_809D0BC\n"
" mov r0, r10\n"
" bl GroundMap_Select\n"
" mov r0, sp\n"
" mov r1, r8\n"
" bl sub_80A579C\n"
" ldr r0, [r7, 0x4]\n"
" movs r1, 0xC0\n"
" lsls r1, 4\n"
" adds r0, r1\n"
" str r0, [r7, 0x4]\n"
" mov r2, r8\n"
" ldr r0, [r2, 0x4]\n"
" adds r0, r1\n"
" str r0, [r2, 0x4]\n"
" ldr r0, [sp]\n"
" ldr r1, _08099520\n"
" adds r0, r1\n"
" str r0, [sp]\n"
" ldr r0, [r7, 0x4]\n"
" adds r0, r1\n"
" str r0, [r7, 0x4]\n"
" ldr r0, [sp, 0x8]\n"
" movs r2, 0x80\n"
" lsls r2, 3\n"
" adds r0, r2\n"
" str r0, [sp, 0x8]\n"
" mov r0, r8\n"
" ldr r1, [r0, 0x4]\n"
" adds r1, r2\n"
" str r1, [r0, 0x4]\n"
" ldr r2, [sp, 0x8]\n"
" ldr r0, [sp]\n"
" subs r0, r2, r0\n"
" str r0, [sp, 0x20]\n"
" ldr r0, [r7, 0x4]\n"
" subs r0, r1, r0\n"
" str r0, [sp, 0x24]\n"
" movs r4, 0\n"
" movs r5, 0\n"
" movs r0, 0x4\n"
" bl sub_80999E8\n"
" mov r9, r5\n"
" b _08099604\n"
" .align 2, 0\n"
"_08099520: .4byte 0xfffffc00\n"
"_08099524:\n"
" ldr r0, _0809953C\n"
" ldrh r1, [r0, 0x2]\n"
" ldrh r6, [r0]\n"
" movs r0, 0x4\n"
" ands r1, r0\n"
" cmp r1, 0\n"
" beq _08099540\n"
" bl sub_80999FC\n"
" movs r1, 0x1\n"
" mov r9, r1\n"
" b _080995AE\n"
" .align 2, 0\n"
"_0809953C: .4byte gRealInputs\n"
"_08099540:\n"
" adds r0, r6, 0\n"
" bl sub_809CFE8\n"
" lsls r0, 24\n"
" asrs r1, r0, 24\n"
" movs r2, 0x1\n"
" negs r2, r2\n"
" cmp r1, r2\n"
" beq _0809959A\n"
" add r0, sp, 0x10\n"
" movs r2, 0x80\n"
" lsls r2, 1\n"
" bl SetVecFromDirectionSpeed\n"
" ldr r2, [sp, 0x10]\n"
" ldr r3, [sp, 0x14]\n"
" movs r0, 0x2\n"
" ands r6, r0\n"
" cmp r6, 0\n"
" beq _0809956A\n"
" movs r0, 0x4\n"
"_0809956A:\n"
" adds r1, r0, 0\n"
" muls r1, r2\n"
" adds r1, r4\n"
" adds r4, r1, 0\n"
" muls r0, r3\n"
" adds r5, r0\n"
" cmp r1, 0\n"
" bge _0809957E\n"
" movs r4, 0\n"
" b _08099588\n"
"_0809957E:\n"
" ldr r0, [sp, 0x20]\n"
" cmp r4, r0\n"
" blt _08099588\n"
" adds r4, r0, 0\n"
" subs r4, 0x1\n"
"_08099588:\n"
" cmp r5, 0\n"
" bge _08099590\n"
" movs r5, 0\n"
" b _0809959A\n"
"_08099590:\n"
" ldr r1, [sp, 0x24]\n"
" cmp r5, r1\n"
" blt _0809959A\n"
" adds r5, r1, 0\n"
" subs r5, 0x1\n"
"_0809959A:\n"
" ldr r0, [sp]\n"
" adds r0, r4\n"
" str r0, [sp, 0x18]\n"
" ldr r0, [r7, 0x4]\n"
" adds r0, r5\n"
" add r1, sp, 0x18\n"
" str r0, [r1, 0x4]\n"
" movs r0, 0\n"
" bl sub_809D158\n"
"_080995AE:\n"
" bl sub_809D25C\n"
" bl sub_80A59DC\n"
" bl xxx_draw_string_80144C4\n"
" movs r0, 0\n"
" movs r1, 0\n"
" bl sub_8005838\n"
" bl sub_80060EC\n"
" ldr r0, _08099620\n"
" ldr r0, [r0]\n"
" ldrb r0, [r0, 0xA]\n"
" bl nullsub_8\n"
" bl sub_8005180\n"
" bl sub_8099BE4\n"
" bl sub_8099744\n"
" bl sub_8011860\n"
" bl sub_800CB20\n"
" bl LoadBufferedInputs\n"
" bl nullsub_120\n"
" bl sub_80A5E70\n"
" bl xxx_call_update_bg_vram\n"
" bl CopySpritesToOam\n"
" bl sub_8005304\n"
" bl sub_8099750\n"
" bl sub_8009908\n"
"_08099604:\n"
" bl xxx_call_update_bg_sound_input\n"
" movs r0, 0\n"
" bl ResetSprites\n"
" mov r2, r9\n"
" cmp r2, 0\n"
" beq _08099524\n"
" bl sub_8099B94\n"
" lsls r0, 24\n"
" cmp r0, 0\n"
" bne _080995AE\n"
" b _08099454\n"
" .align 2, 0\n"
"_08099620: .4byte gGameOptionsRef\n"
"_08099624:\n"
" movs r0, 0x10\n"
" bl FadeOutAllMusic\n"
" bl FreeGroundMapAction\n"
" bl sub_8099768\n"
" bl nullsub_103\n"
" add sp, 0x28\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");
}
void sub_809965C(void);
void sub_8099648(void) {
sub_8003600();
sub_809965C();
}
void nullsub_103(void) {
return;
}
void sub_809965C(void) {
OpenedFile *temp;
sub_8099690(0);
// gUnknown_811601C -> "fontsppa" string
temp = OpenFileAndGetFileDataPtr(gUnknown_811601C, &gSystemFileArchive);
sub_800388C(0x1f0, temp->data, 0x10);
CloseFile(temp);
}

View File

@ -2,6 +2,7 @@
#include "structs/str_3001B64.h"
#include "code_80118A4.h"
#include "code_801D014.h"
#include "code_8099360.h"
#include "credits2.h"
#include "event_flag.h"
#include "flash.h"
@ -16,9 +17,7 @@ void sub_802E918();
u32 sub_80282DC(u8 *r0);
void sub_809927C(u8);
void sub_80282FC(void);
void sub_80993C0(u32);
void sub_8001064(void);
void sub_809965C(void);
void sub_809C39C(void) {
gUnknown_3001B64->unk430 = sub_801D178();

View File

@ -5,6 +5,7 @@
#include "code_8094F88.h"
#include "code_80958E8.h"
#include "code_80972F4.h"
#include "code_8099360.h"
#include "code_80A26CC.h"
#include "constants/mailbox.h"
#include "constants/wonder_mail.h"
@ -25,8 +26,6 @@ static EWRAM_DATA_2 unkStruct_203B330 *sUnknown_203B330 = {0};
// code_8098BDC.s
extern u8 sub_80992E0(s16 *, s16 *);
extern u8 sub_8099360(u8 *);
extern u8 sub_8099394(volatile u8 *);
static void DisplayMissionObjectives(void);
@ -114,7 +113,7 @@ static void DisplayMissionObjectives(void)
switch (sUnknown_203B330->unkC) {
case 1:
sub_8099394(&local_94);
sub_8099394((u8*)&local_94);
mail = GetMailatIndex(local_94);
sub_803B6B0(10, 16, 3, sUnknown_203B330->unk10);
// %dF

View File

@ -5,6 +5,7 @@
#include "code_802F204.h"
#include "code_8094F88.h"
#include "code_8097670.h"
#include "code_8099360.h"
#include "constants/item.h"
#include "constants/wonder_mail.h"
#include "event_flag.h"
@ -47,7 +48,6 @@ static EWRAM_DATA_2 struct unkStruct_203B2C8 *sUnknown_203B2C8 = {0};
extern void sub_80920D8(u8 *buffer);
extern char gUnknown_202E5D8[0x50];
extern char gAvailablePokemonNames[0x50];
extern u8 sub_8099394(u8 *);
extern void sub_802B548(u32);
extern void sub_802B560(void);