continued work on save functions

This commit is contained in:
Seth Barberee 2024-07-28 21:50:29 -07:00
parent 04b11dc641
commit b7c964388a
3 changed files with 241 additions and 745 deletions

View File

@ -5,692 +5,6 @@
.text
thumb_func_start sub_8081C7C
sub_8081C7C:
push {r4-r7,lr}
mov r7, r10
mov r6, r9
mov r5, r8
push {r5-r7}
adds r7, r0, 0
ldr r1, _08081E20
bl sub_8083018
adds r0, r7, 0
bl sub_80831DC
ldr r4, _08081E24
ldr r1, [r4]
ldr r2, _08081E28
adds r1, r2
strb r0, [r1]
adds r0, r7, 0
bl sub_80831DC
ldr r1, [r4]
ldr r3, _08081E2C
adds r1, r3
strb r0, [r1]
adds r0, r7, 0
bl sub_80831DC
ldr r1, [r4]
ldr r2, _08081E30
adds r1, r2
strb r0, [r1]
adds r0, r7, 0
bl sub_80831DC
ldr r1, [r4]
ldr r3, _08081E34
adds r1, r3
strb r0, [r1]
adds r0, r7, 0
bl sub_8083188
ldr r1, [r4]
ldr r2, _08081E38
adds r1, r2
strb r0, [r1]
adds r0, r7, 0
bl sub_8083188
ldr r1, [r4]
ldr r3, _08081E3C
adds r1, r3
strb r0, [r1]
adds r0, r7, 0
bl sub_8083170
ldr r1, [r4]
ldr r2, _08081E40
adds r1, r2
strh r0, [r1]
adds r0, r7, 0
bl sub_8083170
ldr r1, [r4]
ldr r3, _08081E44
adds r1, r3
strh r0, [r1]
adds r0, r7, 0
bl sub_8083170
ldr r1, [r4]
ldr r2, _08081E48
adds r1, r2
strh r0, [r1]
adds r0, r7, 0
bl sub_8083170
ldr r1, [r4]
ldr r3, _08081E4C
adds r1, r3
strh r0, [r1]
adds r0, r7, 0
bl sub_8083170
ldr r1, [r4]
ldr r2, _08081E50
adds r1, r2
strh r0, [r1]
movs r1, 0
mov r9, r4
_08081D2E:
lsls r0, r1, 2
adds r3, r1, 0x1
mov r8, r3
adds r0, r1
lsls r0, 2
adds r0, r1
lsls r0, 6
ldr r1, _08081E54
adds r6, r0, r1
movs r5, 0
movs r4, 0x37
_08081D44:
mov r2, r9
ldr r1, [r2]
adds r1, r6
adds r1, r5
adds r0, r7, 0
bl sub_8081E7C
adds r5, 0x18
subs r4, 0x1
cmp r4, 0
bge _08081D44
mov r1, r8
cmp r1, 0x1F
ble _08081D2E
ldr r4, _08081E24
ldr r1, [r4]
ldr r3, _08081E58
adds r1, r3
adds r0, r7, 0
bl sub_80831F8
ldr r1, [r4]
ldr r0, _08081E5C
adds r1, r0
adds r0, r7, 0
bl sub_80831F8
ldr r6, _08081E60
movs r5, 0x7
_08081D7E:
ldr r1, [r4]
adds r1, r6
adds r0, r7, 0
bl sub_80831F8
adds r6, 0x4
subs r5, 0x1
cmp r5, 0
bge _08081D7E
ldr r4, _08081E24
ldr r1, [r4]
ldr r2, _08081E64
adds r1, r2
adds r0, r7, 0
bl sub_8083220
ldr r1, [r4]
ldr r3, _08081E68
adds r1, r3
adds r0, r7, 0
bl sub_8083220
ldr r1, [r4]
ldr r0, _08081E6C
adds r1, r0
adds r0, r7, 0
bl sub_8083260
movs r1, 0
mov r10, r4
_08081DBA:
movs r4, 0
adds r2, r1, 0x1
mov r8, r2
lsls r0, r1, 1
lsls r3, r1, 3
mov r9, r3
adds r0, r1
lsls r0, 6
ldr r1, _08081E70
adds r6, r0, r1
movs r5, 0
_08081DD0:
mov r2, r10
ldr r1, [r2]
adds r1, r6
adds r1, r5
adds r0, r7, 0
bl sub_8081E7C
adds r0, r7, 0
bl sub_8083188
mov r3, r10
ldr r1, [r3]
mov r3, r9
adds r2, r4, r3
ldr r3, _08081E74
adds r1, r3
adds r1, r2
strb r0, [r1]
adds r5, 0x18
adds r4, 0x1
cmp r4, 0x7
ble _08081DD0
mov r1, r8
cmp r1, 0x7
ble _08081DBA
ldr r0, _08081E24
ldr r1, [r0]
ldr r0, _08081E78
adds r1, r0
adds r0, r7, 0
bl sub_8081EC0
pop {r3-r5}
mov r8, r3
mov r9, r4
mov r10, r5
pop {r4-r7}
pop {r0}
bx r0
.align 2, 0
_08081E20: .4byte gUnknown_81071E0
_08081E24: .4byte gDungeon
_08081E28: .4byte 0x00003a08
_08081E2C: .4byte 0x00003a09
_08081E30: .4byte 0x00003a0a
_08081E34: .4byte 0x00003a0b
_08081E38: .4byte 0x00003a0c
_08081E3C: .4byte 0x00003a0d
_08081E40: .4byte 0x00003a0e
_08081E44: .4byte 0x00003a10
_08081E48: .4byte 0x00003a12
_08081E4C: .4byte 0x00003a14
_08081E50: .4byte 0x00003a16
_08081E54: .4byte 0x00003a18
_08081E58: .4byte 0x0000e218
_08081E5C: .4byte 0x0000e21c
_08081E60: .4byte 0x0000e220
_08081E64: .4byte 0x0000e240
_08081E68: .4byte 0x0000e250
_08081E6C: .4byte 0x0000e260
_08081E70: .4byte 0x0000e27c
_08081E74: .4byte 0x0000e87c
_08081E78: .4byte 0x0000e264
thumb_func_end sub_8081C7C
thumb_func_start sub_8081E7C
sub_8081E7C:
push {r4-r6,lr}
adds r5, r0, 0
adds r4, r1, 0
adds r0, r4, 0
movs r1, 0
movs r2, 0x18
bl memset
adds r0, r5, 0
bl sub_8083158
movs r6, 0
strh r0, [r4]
adds r0, r5, 0
bl sub_8083158
strh r0, [r4, 0x4]
adds r1, r4, 0
adds r1, 0x9
adds r0, r5, 0
movs r2, 0x1
bl sub_8082FE0
adds r1, r4, 0
adds r1, 0xE
adds r0, r5, 0
movs r2, 0x1
bl sub_8082FE0
str r6, [r4, 0x10]
str r6, [r4, 0x14]
pop {r4-r6}
pop {r0}
bx r0
thumb_func_end sub_8081E7C
thumb_func_start sub_8081EC0
sub_8081EC0:
push {r4-r6,lr}
adds r6, r0, 0
adds r5, r1, 0
adds r0, r5, 0
movs r1, 0
movs r2, 0x18
bl memset
adds r0, r6, 0
adds r1, r5, 0
movs r2, 0x1
bl sub_8082FE0
adds r1, r5, 0x1
adds r0, r6, 0
movs r2, 0x1
bl sub_8082FE0
movs r4, 0
_08081EE6:
adds r0, r6, 0
bl sub_8083188
adds r1, r5, 0x3
adds r1, r4
strb r0, [r1]
adds r0, r6, 0
bl sub_8083188
adds r1, r5, 0
adds r1, 0xB
adds r1, r4
strb r0, [r1]
adds r4, 0x1
cmp r4, 0x7
ble _08081EE6
adds r0, r6, 0
bl sub_8083188
strb r0, [r5, 0x2]
adds r0, r6, 0
bl sub_8083188
strb r0, [r5, 0x13]
adds r0, r6, 0
bl sub_8083188
strb r0, [r5, 0x14]
adds r0, r6, 0
bl sub_80831DC
strb r0, [r5, 0x15]
pop {r4-r6}
pop {r0}
bx r0
thumb_func_end sub_8081EC0
thumb_func_start sub_8081F2C
sub_8081F2C:
push {r4,r5,lr}
adds r5, r0, 0
ldr r1, _08081FE4
bl sub_8083018
ldr r4, _08081FE8
ldr r0, [r4]
ldr r1, _08081FEC
adds r0, r1
movs r1, 0
str r1, [r0]
adds r0, r5, 0
bl sub_8083188
ldr r1, [r4]
ldr r2, _08081FF0
adds r1, r2
strb r0, [r1]
adds r0, r5, 0
bl sub_8083188
ldr r1, [r4]
ldr r2, _08081FF4
adds r1, r2
strb r0, [r1]
adds r0, r5, 0
bl sub_80831DC
ldr r1, [r4]
ldr r2, _08081FF8
adds r1, r2
strb r0, [r1]
adds r0, r5, 0
bl sub_80831DC
ldr r1, [r4]
ldr r2, _08081FFC
adds r1, r2
strb r0, [r1]
adds r0, r5, 0
bl sub_80831DC
ldr r1, [r4]
ldr r2, _08082000
adds r1, r2
strb r0, [r1]
adds r0, r5, 0
bl sub_80831DC
ldr r1, [r4]
ldr r2, _08082004
adds r1, r2
strb r0, [r1]
adds r0, r5, 0
bl sub_80831DC
ldr r1, [r4]
ldr r2, _08082008
adds r1, r2
strb r0, [r1]
adds r0, r5, 0
bl sub_80831DC
ldr r1, [r4]
ldr r2, _0808200C
adds r1, r2
strb r0, [r1]
adds r0, r5, 0
bl sub_80831DC
ldr r1, [r4]
ldr r2, _08082010
adds r1, r2
strb r0, [r1]
adds r0, r5, 0
bl sub_80831DC
ldr r1, [r4]
ldr r2, _08082014
adds r1, r2
strb r0, [r1]
adds r0, r5, 0
bl sub_80831DC
ldr r1, [r4]
ldr r2, _08082018
adds r1, r2
strb r0, [r1]
pop {r4,r5}
pop {r0}
bx r0
.align 2, 0
_08081FE4: .4byte gUnknown_81071E0
_08081FE8: .4byte gDungeon
_08081FEC: .4byte 0x000181f8
_08081FF0: .4byte 0x00018208
_08081FF4: .4byte 0x00018209
_08081FF8: .4byte 0x0001820a
_08081FFC: .4byte 0x0001820b
_08082000: .4byte 0x0001820c
_08082004: .4byte 0x0001820d
_08082008: .4byte 0x0001820e
_0808200C: .4byte 0x0001820f
_08082010: .4byte 0x00018210
_08082014: .4byte 0x00018211
_08082018: .4byte 0x00018213
thumb_func_end sub_8081F2C
thumb_func_start sub_808201C
sub_808201C:
push {r4,r5,lr}
adds r5, r0, 0
bl sub_8083170
ldr r4, _08082050
ldr r1, [r4]
ldr r2, _08082054
adds r1, r2
strh r0, [r1]
adds r0, r5, 0
bl sub_8083170
ldr r1, [r4]
ldr r2, _08082058
adds r1, r2
strh r0, [r1]
adds r0, r5, 0
bl sub_8083170
ldr r1, [r4]
ldr r2, _0808205C
adds r1, r2
strh r0, [r1]
pop {r4,r5}
pop {r0}
bx r0
.align 2, 0
_08082050: .4byte gDungeon
_08082054: .4byte 0x0001ced6
_08082058: .4byte 0x0001ced8
_0808205C: .4byte 0x0001ceda
thumb_func_end sub_808201C
thumb_func_start sub_8082060
sub_8082060:
push {r4-r7,lr}
sub sp, 0x8
adds r5, r0, 0
ldr r1, _080820A4
bl sub_8083018
add r4, sp, 0x4
mov r7, sp
movs r6, 0x3F
_08082072:
adds r0, r5, 0
mov r1, sp
bl sub_80820A8
adds r0, r5, 0
adds r1, r4, 0
bl sub_80831F8
ldrb r1, [r7]
movs r0, 0x1
ands r0, r1
cmp r0, 0
beq _08082096
adds r0, r4, 0
mov r1, sp
movs r2, 0
bl sub_80460F8
_08082096:
subs r6, 0x1
cmp r6, 0
bge _08082072
add sp, 0x8
pop {r4-r7}
pop {r0}
bx r0
.align 2, 0
_080820A4: .4byte gUnknown_81071E0
thumb_func_end sub_8082060
thumb_func_start sub_80820A8
sub_80820A8:
push {r4,r5,lr}
adds r5, r0, 0
adds r4, r1, 0
movs r0, 0
str r0, [r4]
adds r0, r5, 0
movs r2, 0x1
bl sub_8082FE0
adds r1, r4, 0x1
adds r0, r5, 0
movs r2, 0x1
bl sub_8082FE0
adds r4, 0x2
adds r0, r5, 0
adds r1, r4, 0
movs r2, 0x1
bl sub_8082FE0
pop {r4,r5}
pop {r0}
bx r0
thumb_func_end sub_80820A8
thumb_func_start sub_80820D8
sub_80820D8:
push {r4-r7,lr}
mov r7, r10
mov r6, r9
mov r5, r8
push {r5-r7}
sub sp, 0x8
adds r5, r0, 0
ldr r1, _08082178
bl sub_8083018
movs r0, 0x1
add r0, sp
mov r9, r0
add r1, sp, 0x4
mov r8, r1
mov r7, sp
movs r2, 0x3F
mov r10, r2
_080820FC:
movs r0, 0x6
strb r0, [r7]
movs r0, 0
mov r3, sp
strb r0, [r3, 0x1]
adds r0, r5, 0
mov r1, sp
movs r2, 0x1
bl sub_8082FE0
adds r0, r5, 0
mov r1, sp
adds r1, 0x1
movs r2, 0x1
bl sub_8082FE0
adds r0, r5, 0
bl sub_80831DC
lsls r0, 24
lsrs r6, r0, 24
adds r0, r5, 0
add r1, sp, 0x4
bl sub_80831F8
ldrb r0, [r7]
cmp r0, 0xFF
beq _0808215C
mov r1, r8
movs r2, 0
ldrsh r0, [r1, r2]
mov r3, sp
movs r2, 0x6
ldrsh r1, [r3, r2]
bl GetTileSafe
adds r4, r0, 0
ldrb r0, [r7]
mov r3, r9
ldrb r2, [r3]
mov r1, r8
bl sub_8045684
cmp r0, 0
beq _0808215C
str r0, [r4, 0x14]
adds r0, 0x20
strb r6, [r0]
_0808215C:
movs r0, 0x1
negs r0, r0
add r10, r0
mov r1, r10
cmp r1, 0
bge _080820FC
add sp, 0x8
pop {r3-r5}
mov r8, r3
mov r9, r4
mov r10, r5
pop {r4-r7}
pop {r0}
bx r0
.align 2, 0
_08082178: .4byte gUnknown_81071E0
thumb_func_end sub_80820D8
thumb_func_start sub_808217C
sub_808217C:
push {r4,r5,lr}
adds r5, r0, 0
ldr r1, _08082250
bl sub_8083018
adds r0, r5, 0
bl sub_80831A0
ldr r4, _08082254
ldr r1, [r4]
ldr r2, _08082258
adds r1, r2
str r0, [r1]
adds r0, r5, 0
bl sub_80831A0
ldr r1, [r4]
ldr r2, _0808225C
adds r1, r2
str r0, [r1]
adds r0, r5, 0
bl sub_80831DC
ldr r1, [r4]
ldr r2, _08082260
adds r1, r2
strb r0, [r1]
adds r0, r5, 0
bl sub_80831DC
ldr r1, [r4]
ldr r2, _08082264
adds r1, r2
strb r0, [r1]
adds r0, r5, 0
bl sub_80831DC
ldr r1, [r4]
ldr r2, _08082268
adds r1, r2
strb r0, [r1]
adds r0, r5, 0
bl sub_80831DC
ldr r1, [r4]
ldr r2, _0808226C
adds r1, r2
strb r0, [r1]
adds r0, r5, 0
bl sub_80831DC
ldr r1, [r4]
ldr r2, _08082270
adds r1, r2
strb r0, [r1]
adds r0, r5, 0
bl sub_80831DC
ldr r1, [r4]
ldr r2, _08082274
adds r1, r2
strb r0, [r1]
adds r0, r5, 0
bl sub_80831DC
ldr r1, [r4]
ldr r2, _08082278
adds r1, r2
strb r0, [r1]
adds r0, r5, 0
bl sub_80831DC
ldr r1, [r4]
ldr r2, _0808227C
adds r1, r2
strb r0, [r1]
adds r0, r5, 0
bl sub_8083158
ldr r1, [r4]
movs r2, 0xE0
lsls r2, 6
adds r1, r2
strh r0, [r1]
movs r4, 0
_08082226:
adds r0, r5, 0
movs r1, 0x1
adds r2, r4, 0
bl sub_8082280
adds r4, 0x1
cmp r4, 0x3
ble _08082226
movs r4, 0
_08082238:
adds r0, r5, 0
movs r1, 0
adds r2, r4, 0
bl sub_8082280
adds r4, 0x1
cmp r4, 0xF
ble _08082238
pop {r4,r5}
pop {r0}
bx r0
.align 2, 0
_08082250: .4byte gUnknown_81071E0
_08082254: .4byte gDungeon
_08082258: .4byte 0x000037f0
_0808225C: .4byte 0x000037f4
_08082260: .4byte 0x000037f8
_08082264: .4byte 0x000037f9
_08082268: .4byte 0x000037fa
_0808226C: .4byte 0x000037fb
_08082270: .4byte 0x000037fc
_08082274: .4byte 0x000037fd
_08082278: .4byte 0x000037fe
_0808227C: .4byte 0x000037ff
thumb_func_end sub_808217C
thumb_func_start sub_8082280
sub_8082280:
push {r4-r7,lr}
@ -2325,40 +1639,4 @@ _08082FCC:
bx r0
thumb_func_end sub_8082FA8
thumb_func_start sub_8082FD4
sub_8082FD4:
str r1, [r0]
movs r3, 0
str r3, [r0, 0x8]
adds r1, r2
str r1, [r0, 0x4]
bx lr
thumb_func_end sub_8082FD4
thumb_func_start sub_8082FE0
sub_8082FE0:
push {r4,lr}
adds r3, r0, 0
adds r4, r1, 0
cmp r2, 0
beq _08083002
_08082FEA:
ldr r1, [r3]
ldrb r0, [r1]
strb r0, [r4]
adds r1, 0x1
str r1, [r3]
adds r4, 0x1
subs r2, 0x1
ldr r0, [r3, 0x8]
adds r0, 0x1
str r0, [r3, 0x8]
cmp r2, 0
bne _08082FEA
_08083002:
pop {r4}
pop {r0}
bx r0
thumb_func_end sub_8082FE0
.align 2,0

View File

@ -2,9 +2,25 @@
#include "code_8092334.h"
#include "structs/str_position.h"
extern void sub_8082FE0(unkStruct_8094924 *, void *, u32 size);
extern void sub_8082FA8(unkStruct_8094924 *, void *, u32);
void sub_8082FD4(unkStruct_8094924 *param_1, u8 *r1, u32 r2)
{
param_1->unk0 = r1;
param_1->unk8 = 0;
param_1->unk4 = r1 + r2;
}
void sub_8082FE0(unkStruct_8094924 *param_1, u8 *param_2, s32 size) {
while (size != 0) {
*param_2 = *(param_1->unk0);
param_1->unk0++;
param_2++;
size--;
param_1->unk8++;
}
}
void nullsub_98(unkStruct_8094924 *param_1)
{}
@ -106,7 +122,7 @@ u16 sub_8083158(unkStruct_8094924 *param_1)
{
u16 local_8;
sub_8082FE0(param_1,&local_8,2);
sub_8082FE0(param_1,(u8 *)&local_8,2);
return local_8;
}
@ -114,7 +130,7 @@ s16 sub_8083170(unkStruct_8094924 *param_1)
{
s16 local_8;
sub_8082FE0(param_1,&local_8,2);
sub_8082FE0(param_1,(u8 *)&local_8,2);
return local_8;
}
@ -130,7 +146,7 @@ u32 sub_80831A0(unkStruct_8094924 *param_1)
{
u32 local_8;
sub_8082FE0(param_1,&local_8,4);
sub_8082FE0(param_1,(u8 *)&local_8,4);
return local_8;
}
@ -138,7 +154,7 @@ u32 sub_80831B4(unkStruct_8094924 *param_1)
{
u32 local_8;
sub_8082FE0(param_1,&local_8,4);
sub_8082FE0(param_1,(u8 *)&local_8,4);
return local_8;
}
@ -146,7 +162,7 @@ u32 sub_80831C8(unkStruct_8094924 *param_1)
{
u32 local_8;
sub_8082FE0(param_1,&local_8,4);
sub_8082FE0(param_1,(u8 *)&local_8,4);
return local_8;
}
@ -162,8 +178,8 @@ void sub_80831F8(unkStruct_8094924 *param_1,u16 *param_2)
{
param_2[0] = 0;
param_2[1] = 0;
sub_8082FE0(param_1,&param_2[0],1);
sub_8082FE0(param_1,&param_2[1],1);
sub_8082FE0(param_1,(u8 *)&param_2[0],1);
sub_8082FE0(param_1,(u8 *)&param_2[1],1);
}
@ -173,22 +189,22 @@ void sub_8083220(unkStruct_8094924 *param_1,u32 *param_2)
param_2[1] = 0;
param_2[2] = 0;
param_2[3] = 0;
sub_8082FE0(param_1,&param_2[0],1);
sub_8082FE0(param_1,&param_2[1],1);
sub_8082FE0(param_1,&param_2[2],1);
sub_8082FE0(param_1,&param_2[3],1);
sub_8082FE0(param_1,(u8 *)&param_2[0],1);
sub_8082FE0(param_1,(u8 *)&param_2[1],1);
sub_8082FE0(param_1,(u8 *)&param_2[2],1);
sub_8082FE0(param_1,(u8 *)&param_2[3],1);
}
void sub_8083260(unkStruct_8094924 *param_1,u16 *param_2)
{
param_2[0] = 0;
param_2[1] = 0;
sub_8082FE0(param_1,&param_2[0],1);
sub_8082FE0(param_1,&param_2[1],1);
sub_8082FE0(param_1,(u8 *)&param_2[0],1);
sub_8082FE0(param_1,(u8 *)&param_2[1],1);
}
void sub_8083288(unkStruct_8094924 *r0, u16 *r1, u32 size)
{
sub_8082FE0(r0, r1, size);
sub_8082FE0(r0, (u8 *)r1, size);
}

View File

@ -5,6 +5,7 @@
#include "code_803E668.h"
#include "code_806CD90.h"
#include "code_8092334.h"
#include "dungeon_map_access.h"
#include "items.h"
#include "dungeon_util.h"
#include "structs/str_dungeon.h"
@ -75,12 +76,26 @@ extern void sub_8083018(unkStruct_8094924 *, u8 *);
extern void sub_8081C50(unkStruct_8094924 *);
extern void sub_8081C7C(unkStruct_8094924 *);
extern void sub_8081F2C(unkStruct_8094924 *);
extern void sub_808201C(unkStruct_8094924 *);
extern void sub_8082060(unkStruct_8094924 *);
extern void sub_80820D8(unkStruct_8094924 *);
extern void RestoreDungeonMusic(unkStruct_8094924 *);
extern void RestoreItemData(unkStruct_8094924 *);
extern void RestoreTrapData(unkStruct_8094924 *);
extern void sub_808217C(unkStruct_8094924 *);
extern void sub_8082FD4(unkStruct_8094924 *, u32, u32);
extern void sub_8082FD4(unkStruct_8094924 *param_1, u8 *r1, u32 r2);
extern void sub_8082FE0(unkStruct_8094924 *, u32 *, u32);
u8 sub_80831DC(unkStruct_8094924 *r0);
u8 sub_8083188(unkStruct_8094924 *r0);
s16 sub_8083170(unkStruct_8094924 *r0);
void sub_80831F8(unkStruct_8094924 *r0, Position *);
void RestoreDungeonWeather(unkStruct_8094924 *r0, Weather *);
void sub_8083220(unkStruct_8094924 *r0, u32 *);
void sub_8083260(unkStruct_8094924 *r0, u32 *);
void RestoreTile(unkStruct_8094924 *r0, Tile *);
extern u16 sub_8083158(unkStruct_8094924 *param_1);
void sub_80820A8(unkStruct_8094924 *r0, Item *);
void sub_80460F8(Position *, Item *, u32);
Entity *sub_8045684(u8, Position *, u8);
u32 sub_80831A0(unkStruct_8094924 *param_1);
void sub_8082280(unkStruct_8094924 *param_1,bool8 isTeamMember,s32 index);
extern u8 gUnknown_81071D4[];
@ -773,7 +788,7 @@ void SaveDungeonWeather(unkStruct_8094924 *r0, Weather *weather)
sub_80830B4(r0, weather->nullifyWeather);
}
void sub_8081BF4(u32 r0, u32 r1)
void sub_8081BF4(u8 *r0, u32 r1)
{
unkStruct_8094924 uStack_14;
@ -783,9 +798,9 @@ void sub_8081BF4(u32 r0, u32 r1)
sub_8081C50(&uStack_14);
sub_8081C7C(&uStack_14);
sub_8081F2C(&uStack_14);
sub_808201C(&uStack_14);
sub_8082060(&uStack_14);
sub_80820D8(&uStack_14);
RestoreDungeonMusic(&uStack_14);
RestoreItemData(&uStack_14);
RestoreTrapData(&uStack_14);
sub_808217C(&uStack_14);
sub_8083018(&uStack_14, gUnknown_81071D4);
@ -797,3 +812,190 @@ void sub_8081C50(unkStruct_8094924 *r0)
sub_8083018(r0, gUnknown_81071E0);
sub_8082FE0(r0, (u32 *)&gDungeon->dungeonLocation, 0x58);
}
void sub_8081C7C(unkStruct_8094924 *r0)
{
int x;
int y;
s32 iVar7;
sub_8083018(r0,gUnknown_81071E0);
gDungeon->unk3A08 = sub_80831DC(r0);
gDungeon->unk3A09 = sub_80831DC(r0);
gDungeon->unk3A0A = sub_80831DC(r0);
gDungeon->unk3A0B = sub_80831DC(r0);
gDungeon->unk3A0C = sub_8083188(r0);
gDungeon->unk3A0D = sub_8083188(r0);
gDungeon->tileset = sub_8083170(r0);
gDungeon->unk3A10 = sub_8083170(r0);
gDungeon->unk3A12 = sub_8083170(r0);
gDungeon->bossBattleIndex = sub_8083170(r0);
gDungeon->unk3A16 = sub_8083170(r0);
for(y = 0; y < DUNGEON_MAX_SIZE_Y; y++)
{
for(x = 0; x < DUNGEON_MAX_SIZE_X; x++)
{
RestoreTile(r0,&gDungeon->tiles[y][x]);
}
}
sub_80831F8(r0,&gDungeon->unkE218);
sub_80831F8(r0,&gDungeon->unkE21C);
for(iVar7 = 0; iVar7 < 8; iVar7++)
{
sub_80831F8(r0,&gDungeon->unkE220[iVar7]);
}
sub_8083220(r0,&gDungeon->unkE240);
sub_8083220(r0,&gDungeon->unkE240 + 0x4);
sub_8083260(r0,&gDungeon->unkE240 + 0x8);
for(y = 0; y < 8; y++)
{
for(x = 0; x < 8; x++)
{
RestoreTile(r0,&gDungeon->unkE27C[y][x]);
gDungeon->unkE87C[y][x] = sub_8083188(r0);
}
}
RestoreDungeonWeather(r0,&gDungeon->weather);
}
void RestoreTile(unkStruct_8094924 *r0, Tile *tile)
{
memset(tile, 0, sizeof(Tile));
tile->terrainType = sub_8083158(r0);
tile->unk4 = sub_8083158(r0);
sub_8082FE0(r0, (u32 *)&tile->room, 1);
sub_8082FE0(r0, (u32 *)&tile->unkE, 1);
tile->monster = NULL;
tile->object = NULL;
}
void RestoreDungeonWeather(unkStruct_8094924 *r0, Weather *weather)
{
s32 index;
memset(weather, 0, sizeof(Weather));
sub_8082FE0(r0, (u32 *)&weather->weather, 1);
sub_8082FE0(r0, (u32 *)&weather->unkE265, 1);
for(index = 0; index < 8; index++)
{
weather->unkE267[index] = sub_8083188(r0);
weather->naturalWeather[index] = sub_8083188(r0);
}
weather->weatherDamageCounter = sub_8083188(r0);
weather->mudSportTurns = sub_8083188(r0);
weather->waterSportTurns = sub_8083188(r0);
weather->nullifyWeather = sub_80831DC(r0);
}
void sub_8081F2C(unkStruct_8094924 *param_1)
{
sub_8083018(param_1,gUnknown_81071E0);
gDungeon->unk181e8.cameraTarget = NULL;
gDungeon->unk181e8.unk18208 = sub_8083188(param_1);
gDungeon->unk181e8.visibilityRange = sub_8083188(param_1);
gDungeon->unk181e8.blinded = sub_80831DC(param_1);
gDungeon->unk181e8.unk1820B = sub_80831DC(param_1);
gDungeon->unk181e8.unk1820C = sub_80831DC(param_1);
gDungeon->unk181e8.unk1820D = sub_80831DC(param_1);
gDungeon->unk181e8.unk1820E = sub_80831DC(param_1);
gDungeon->unk181e8.unk1820F = sub_80831DC(param_1);
gDungeon->unk181e8.hallucinating = sub_80831DC(param_1);
gDungeon->unk181e8.unk18211 = sub_80831DC(param_1);
gDungeon->unk181e8.unk18213 = sub_80831DC(param_1);
}
void RestoreDungeonMusic(unkStruct_8094924 *r0)
{
gDungeon->musPlayer.songIndex = sub_8083170(r0);
gDungeon->musPlayer.pastSongIndex = sub_8083170(r0);
gDungeon->musPlayer.queuedSongIndex = sub_8083170(r0);
}
void RestoreItemData(unkStruct_8094924 *r0) {
s32 index;
Item item;
Position pos;
sub_8083018(r0, gUnknown_81071E0);
for(index = 0; index < DUNGEON_MAX_ITEMS; index++)
{
sub_80820A8(r0, &item);
sub_80831F8(r0, &pos);
if(item.flags & ITEM_FLAG_EXISTS)
sub_80460F8(&pos, &item, 0);
}
}
void sub_80820A8(unkStruct_8094924 *param_1, Item *item)
{
memset(item, 0, sizeof(Item));
sub_8082FE0(param_1,(u32 *)&item->flags,1);
sub_8082FE0(param_1,(u32 *)&item->quantity,1);
sub_8082FE0(param_1,(u32 *)&item->id,1);
}
void RestoreTrapData(unkStruct_8094924 *param_1)
{
int counter;
Tile *tile;
Entity *entity;
Position pos;
u8 isVisible;
u8 unk1;
u8 trapID;
sub_8083018(param_1, gUnknown_81071E0);
for(counter = 0; counter < DUNGEON_MAX_TRAPS; counter++)
{
trapID = 6;
unk1 = 0;
sub_8082FE0(param_1,(u32 *)&trapID,1);
sub_8082FE0(param_1,(u32 *)&unk1,1);
isVisible = sub_80831DC(param_1);
sub_80831F8(param_1, &pos);
if(trapID != 0xFF)
{
tile = GetTileSafe(pos.x, pos.y);
entity = sub_8045684(trapID, &pos, unk1);
if(entity)
{
tile->object = entity;
entity->isVisible = isVisible;
}
}
}
}
void sub_808217C(unkStruct_8094924 *param_1)
{
s32 counter;
sub_8083018(param_1,gUnknown_81071E0);
gDungeon->unk37F0 = sub_80831A0(param_1);
gDungeon->unk37F4 = sub_80831A0(param_1);
gDungeon->plusIsActive[0] = sub_80831DC(param_1);
gDungeon->plusIsActive[1] = sub_80831DC(param_1);
gDungeon->minusIsActive[0] = sub_80831DC(param_1);
gDungeon->minusIsActive[1] = sub_80831DC(param_1);
gDungeon->decoyActive = sub_80831DC(param_1);
gDungeon->fill37FD = sub_80831DC(param_1);
gDungeon->deoxysDefeat = sub_80831DC(param_1);
gDungeon->fill37FF = sub_80831DC(param_1);
gDungeon->unk3800 = sub_8083158(param_1);
for(counter = 0; counter < MAX_TEAM_MEMBERS; counter++)
{
sub_8082280(param_1, TRUE, counter);
}
for(counter = 0; counter < DUNGEON_MAX_WILD_POKEMON; counter++)
{
sub_8082280(param_1, FALSE, counter);
}
}