more documentation of pelipper, mailbox, and job slots

This commit is contained in:
Seth Barberee 2023-01-06 15:28:57 -08:00
parent df6617f0f8
commit 93370c9481
28 changed files with 1891 additions and 2419 deletions

File diff suppressed because it is too large Load Diff

844
asm/code_80958E8_1.s Normal file
View File

@ -0,0 +1,844 @@
#include "asm/constants/gba_constants.inc"
#include "asm/macros.inc"
.syntax unified
.text
thumb_func_start sub_8096078
sub_8096078:
push {r4-r7,lr}
mov r7, r9
mov r6, r8
push {r6,r7}
movs r2, 0
movs r3, 0
ldr r0, _08096090
mov r12, r0
mov r8, r3
movs r4, 0
mov r9, r4
b _080960B6
.align 2, 0
_08096090: .4byte gUnknown_203B490
_08096094:
cmp r2, r3
ble _080960AA
mov r1, r12
ldr r0, [r1]
mov r5, r8
adds r1, r0, r5
adds r0, r4
ldm r0!, {r5-r7}
stm r1!, {r5-r7}
ldm r0!, {r6,r7}
stm r1!, {r6,r7}
_080960AA:
adds r4, 0x14
movs r0, 0x14
add r9, r0
adds r2, 0x1
add r8, r0
adds r3, 0x1
_080960B6:
cmp r2, 0x3
bgt _080960E2
mov r1, r12
ldr r0, [r1]
adds r0, r4
ldrb r0, [r0]
cmp r0, 0
bne _080960E2
ldr r6, _08096110
mov r1, r9
_080960CA:
adds r1, 0x14
adds r4, 0x14
movs r5, 0x14
add r9, r5
adds r2, 0x1
cmp r2, 0x3
bgt _080960E2
ldr r0, [r6]
adds r0, r1
ldrb r0, [r0]
cmp r0, 0
beq _080960CA
_080960E2:
cmp r2, 0x4
bne _08096094
cmp r3, 0x3
bgt _08096102
ldr r4, _08096110
movs r2, 0
lsls r0, r3, 2
adds r0, r3
lsls r1, r0, 2
_080960F4:
ldr r0, [r4]
adds r0, r1
strb r2, [r0]
adds r1, 0x14
adds r3, 0x1
cmp r3, 0x3
ble _080960F4
_08096102:
pop {r3,r4}
mov r8, r3
mov r9, r4
pop {r4-r7}
pop {r0}
bx r0
.align 2, 0
_08096110: .4byte gUnknown_203B490
thumb_func_end sub_8096078
thumb_func_start sub_8096114
sub_8096114:
push {r4-r7,lr}
mov r7, r10
mov r6, r9
mov r5, r8
push {r5-r7}
sub sp, 0x14
movs r1, 0
_08096122:
adds r0, r1, 0x1
mov r10, r0
mov r8, r10
cmp r0, 0x3
bgt _08096198
ldr r2, _080961B0
mov r9, r2
lsls r0, r1, 2
adds r0, r1
lsls r0, 2
mov r12, r0
mov r3, r10
lsls r0, r3, 2
add r0, r10
lsls r4, r0, 2
_08096140:
mov r5, r9
ldr r1, [r5]
adds r3, r1, r4
ldrb r0, [r3]
cmp r0, 0
beq _0809618C
mov r6, r12
adds r2, r1, r6
ldrb r1, [r2, 0x4]
ldrb r0, [r3, 0x4]
cmp r1, r0
bhi _08096164
cmp r1, r0
bne _0809618C
ldrb r0, [r2, 0x5]
ldrb r7, [r3, 0x5]
cmp r0, r7
bls _0809618C
_08096164:
mov r1, sp
adds r0, r2, 0
ldm r0!, {r5-r7}
stm r1!, {r5-r7}
ldm r0!, {r5,r6}
stm r1!, {r5,r6}
adds r1, r2, 0
adds r0, r3, 0
ldm r0!, {r2,r3,r7}
stm r1!, {r2,r3,r7}
ldm r0!, {r5,r6}
stm r1!, {r5,r6}
mov r7, r9
ldr r1, [r7]
adds r1, r4
mov r0, sp
ldm r0!, {r2,r3,r5}
stm r1!, {r2,r3,r5}
ldm r0!, {r6,r7}
stm r1!, {r6,r7}
_0809618C:
adds r4, 0x14
movs r0, 0x1
add r8, r0
mov r1, r8
cmp r1, 0x3
ble _08096140
_08096198:
mov r1, r10
cmp r1, 0x2
ble _08096122
add sp, 0x14
pop {r3-r5}
mov r8, r3
mov r9, r4
mov r10, r5
pop {r4-r7}
pop {r0}
bx r0
.align 2, 0
_080961B0: .4byte gUnknown_203B490
thumb_func_end sub_8096114
thumb_func_start sub_80961B4
sub_80961B4:
push {lr}
bl sub_8096E2C
lsls r0, 24
cmp r0, 0
beq _080961CE
ldr r0, _080961D4
ldr r0, [r0]
movs r1, 0xCA
lsls r1, 2
adds r0, r1
movs r1, 0x1
strb r1, [r0]
_080961CE:
pop {r0}
bx r0
.align 2, 0
_080961D4: .4byte gUnknown_203B490
thumb_func_end sub_80961B4
thumb_func_start sub_80961D8
sub_80961D8:
push {r4-r7,lr}
mov r7, r8
push {r7}
movs r7, 0
bl CountFilledMailboxSlots
adds r6, r0, 0
movs r1, 0x4
bl RandomRange
mov r8, r0
cmp r6, 0x3
bgt _08096202
ldr r4, _08096208
ldr r0, [r4]
movs r2, 0xCA
lsls r2, 2
adds r1, r0, r2
ldrb r0, [r1]
cmp r0, 0
bne _0809620C
_08096202:
movs r0, 0
b _080963A8
.align 2, 0
_08096208: .4byte gUnknown_203B490
_0809620C:
strb r7, [r1]
movs r5, 0x38
movs r0, 0xA
movs r1, 0x31
movs r2, 0x1
bl sub_8001D08
lsls r0, 24
cmp r0, 0
beq _0809623A
ldr r0, [r4]
ldr r1, _08096328
adds r0, r1
ldrb r0, [r0]
cmp r0, 0
bne _0809623A
movs r0, 0x35
bl sub_8096E80
lsls r0, 24
cmp r0, 0
bne _0809623A
movs r5, 0x35
_0809623A:
movs r0, 0xF
bl sub_80023E4
lsls r0, 24
cmp r0, 0
beq _0809629C
ldr r0, _0809632C
ldr r0, [r0]
movs r2, 0xC9
lsls r2, 2
adds r0, r2
ldrb r0, [r0]
cmp r0, 0
bne _08096264
movs r0, 0x34
bl sub_8096E80
lsls r0, 24
cmp r0, 0
bne _08096264
movs r5, 0x34
_08096264:
ldr r0, _0809632C
ldr r0, [r0]
ldr r1, _08096330
adds r0, r1
ldrb r0, [r0]
cmp r0, 0
bne _08096280
movs r0, 0x33
bl sub_8096E80
lsls r0, 24
cmp r0, 0
bne _08096280
movs r5, 0x33
_08096280:
ldr r0, _0809632C
ldr r0, [r0]
ldr r2, _08096334
adds r0, r2
ldrb r0, [r0]
cmp r0, 0
bne _0809629C
movs r0, 0x32
bl sub_8096E80
lsls r0, 24
cmp r0, 0
bne _0809629C
movs r5, 0x32
_0809629C:
bl GetRescueTeamRank
lsls r0, 24
lsrs r0, 24
cmp r0, 0x6
bne _080962C4
ldr r0, _0809632C
ldr r0, [r0]
ldr r1, _08096338
adds r0, r1
ldrb r0, [r0]
cmp r0, 0
bne _080962C4
movs r0, 0x36
bl sub_8096E80
lsls r0, 24
cmp r0, 0
bne _080962C4
movs r5, 0x36
_080962C4:
movs r0, 0x6
bl sub_80023E4
lsls r0, 24
cmp r0, 0
beq _080962EC
ldr r0, _0809632C
ldr r0, [r0]
ldr r2, _0809633C
adds r0, r2
ldrb r0, [r0]
cmp r0, 0
bne _080962EC
movs r0, 0x37
bl sub_8096E80
lsls r0, 24
cmp r0, 0
bne _080962EC
movs r5, 0x37
_080962EC:
cmp r5, 0x38
bne _08096310
cmp r6, r8
bgt _08096392
bl sub_8096E2C
lsls r0, 24
lsrs r5, r0, 24
movs r0, 0xE
bl sub_80023E4
lsls r0, 24
cmp r0, 0
bne _0809630C
cmp r5, 0x2
bhi _0809638E
_0809630C:
cmp r5, 0x31
bhi _0809638E
_08096310:
lsls r0, r6, 24
lsrs r0, 24
bl GetMailboxSlotInfo
adds r4, r0, 0
movs r0, 0x1
strb r0, [r4]
movs r0, 0x62
strb r0, [r4, 0x4]
strb r5, [r4, 0x5]
b _0809638A
.align 2, 0
_08096328: .4byte 0x00000325
_0809632C: .4byte gUnknown_203B490
_08096330: .4byte 0x00000323
_08096334: .4byte 0x00000322
_08096338: .4byte 0x00000326
_0809633C: .4byte 0x00000327
_08096340:
lsls r0, r6, 24
lsrs r0, 24
bl GetMailboxSlotInfo
adds r4, r0, 0
bl sub_8095B28
lsls r0, 24
cmp r0, 0
beq _08096392
bl sub_8095E78
lsls r0, 24
lsrs r5, r0, 24
adds r0, r4, 0x4
ldrb r1, [r4, 0x1]
bl sub_803C1D0
lsls r0, 24
cmp r0, 0
bne _0809636C
movs r5, 0
_0809636C:
movs r0, 0x5
movs r1, 0xA
bl RandomRange
strb r0, [r4, 0x11]
lsls r0, 24
lsrs r0, 24
cmp r0, 0x9
bne _0809638A
cmp r5, 0
bne _08096388
movs r0, 0x5
strb r0, [r4, 0x11]
b _0809638A
_08096388:
strb r5, [r4, 0x13]
_0809638A:
movs r7, 0x1
adds r6, 0x1
_0809638E:
cmp r6, r8
ble _08096340
_08096392:
bl sub_80963B4
lsls r0, 24
cmp r0, 0
beq _0809639E
movs r7, 0x1
_0809639E:
bl sub_8096078
bl sub_8096114
adds r0, r7, 0
_080963A8:
pop {r3}
mov r8, r3
pop {r4-r7}
pop {r1}
bx r1
thumb_func_end sub_80961D8
thumb_func_start sub_80963B4
sub_80963B4:
push {r4-r6,lr}
movs r6, 0
bl sub_8096E2C
lsls r0, 24
lsrs r5, r0, 24
bl CountFilledMailboxSlots
adds r4, r0, 0
cmp r4, 0x3
ble _080963CE
movs r0, 0
b _080963F4
_080963CE:
movs r0, 0xE
bl sub_80023E4
lsls r0, 24
cmp r0, 0
beq _080963F2
cmp r5, 0x31
bhi _080963F2
lsls r0, r4, 24
lsrs r0, 24
bl GetMailboxSlotInfo
movs r1, 0x1
strb r1, [r0]
movs r1, 0x62
strb r1, [r0, 0x4]
strb r5, [r0, 0x5]
movs r6, 0x1
_080963F2:
adds r0, r6, 0
_080963F4:
pop {r4-r6}
pop {r1}
bx r1
thumb_func_end sub_80963B4
thumb_func_start sub_80963FC
sub_80963FC:
push {r4-r6,lr}
movs r6, 0
_08096400:
lsls r0, r6, 24
lsrs r4, r0, 24
adds r0, r4, 0
bl GetMailboxSlotInfo
adds r5, r0, 0
ldrb r0, [r5]
cmp r0, 0x1
beq _08096418
adds r0, r4, 0
bl ResetMailboxSlot
_08096418:
adds r6, 0x1
cmp r6, 0x3
ble _08096400
bl sub_8096078
bl CountFilledMailboxSlots
lsls r0, 24
lsrs r0, 24
bl GetMailboxSlotInfo
adds r5, r0, 0
movs r0, 0
movs r4, 0x5
strb r4, [r5]
strb r0, [r5, 0x1]
strb r0, [r5, 0x2]
movs r0, 0x2
strb r0, [r5, 0x4]
movs r0, 0x3
strb r0, [r5, 0x5]
bl Random
ldr r1, _08096484
ands r1, r0
str r1, [r5, 0x8]
movs r0, 0x10
strh r0, [r5, 0xC]
strh r0, [r5, 0xE]
ldrb r0, [r5, 0x4]
bl sub_8095F28
strb r0, [r5, 0x10]
strb r4, [r5, 0x11]
_0809645C:
ldrb r1, [r5, 0x1]
adds r0, r5, 0x4
adds r2, r5, 0
adds r2, 0x12
bl sub_803C37C
ldrb r0, [r5, 0x10]
ldrb r1, [r5, 0x12]
cmp r0, r1
beq _0809645C
movs r0, 0
strb r0, [r5, 0x13]
bl sub_8096078
bl sub_8096114
pop {r4-r6}
pop {r0}
bx r0
.align 2, 0
_08096484: .4byte 0x00ffffff
thumb_func_end sub_80963FC
thumb_func_start sub_8096488
sub_8096488:
push {r4,lr}
movs r4, 0
_0809648C:
lsls r0, r4, 24
lsrs r0, 24
bl ResetMailboxSlot
adds r4, 0x1
cmp r4, 0x3
ble _0809648C
movs r0, 0
bl GetMailboxSlotInfo
movs r2, 0
movs r1, 0x1
strb r1, [r0]
movs r1, 0x62
strb r1, [r0, 0x4]
strb r2, [r0, 0x5]
pop {r4}
pop {r0}
bx r0
thumb_func_end sub_8096488
thumb_func_start sub_80964B4
sub_80964B4:
push {lr}
ldr r0, _080964D4
ldr r0, [r0]
ldr r1, _080964D8
adds r0, r1
ldrb r0, [r0]
cmp r0, 0
bne _080964DC
movs r0, 0x35
bl sub_8096E80
lsls r0, 24
cmp r0, 0
bne _080964DC
movs r0, 0
b _080964DE
.align 2, 0
_080964D4: .4byte gUnknown_203B490
_080964D8: .4byte 0x00000325
_080964DC:
movs r0, 0x1
_080964DE:
pop {r1}
bx r1
thumb_func_end sub_80964B4
thumb_func_start sub_80964E4
sub_80964E4:
push {lr}
ldr r0, _08096504
ldr r0, [r0]
ldr r1, _08096508
adds r0, r1
ldrb r0, [r0]
cmp r0, 0
bne _0809650C
movs r0, 0x36
bl sub_8096E80
lsls r0, 24
cmp r0, 0
bne _0809650C
movs r0, 0
b _0809650E
.align 2, 0
_08096504: .4byte gUnknown_203B490
_08096508: .4byte 0x00000326
_0809650C:
movs r0, 0x1
_0809650E:
pop {r1}
bx r1
thumb_func_end sub_80964E4
thumb_func_start sub_8096514
sub_8096514:
push {r4,r5,lr}
movs r5, 0
movs r4, 0
_0809651A:
lsls r0, r4, 24
lsrs r0, 24
bl IsPelliperBoardSlotEmpty
lsls r0, 24
cmp r0, 0
bne _0809652A
adds r5, 0x1
_0809652A:
adds r4, 0x1
cmp r4, 0x7
ble _0809651A
adds r0, r5, 0
pop {r4,r5}
pop {r1}
bx r1
thumb_func_end sub_8096514
thumb_func_start sub_8096538
sub_8096538:
push {r4,r5,lr}
adds r4, r0, 0
movs r3, 0
ldr r5, _08096560
movs r2, 0
_08096542:
ldr r0, [r5]
adds r0, r2
adds r1, r0, 0
adds r1, 0x50
ldrb r0, [r1]
cmp r0, 0
bne _08096564
adds r0, r4, 0
ldm r0!, {r2-r4}
stm r1!, {r2-r4}
ldm r0!, {r2,r3}
stm r1!, {r2,r3}
movs r0, 0
b _0809656E
.align 2, 0
_08096560: .4byte gUnknown_203B490
_08096564:
adds r2, 0x14
adds r3, 0x1
cmp r3, 0x7
ble _08096542
movs r0, 0x1
_0809656E:
pop {r4,r5}
pop {r1}
bx r1
thumb_func_end sub_8096538
thumb_func_start GetPelliperBoardSlotInfo
GetPelliperBoardSlotInfo:
lsls r0, 24
lsrs r0, 24
ldr r2, _08096588
lsls r1, r0, 2
adds r1, r0
lsls r1, 2
adds r1, 0x50
ldr r0, [r2]
adds r0, r1
bx lr
.align 2, 0
_08096588: .4byte gUnknown_203B490
thumb_func_end GetPelliperBoardSlotInfo
thumb_func_start IsPelliperBoardSlotEmpty
IsPelliperBoardSlotEmpty:
push {lr}
lsls r0, 24
lsrs r0, 24
ldr r1, _080965AC
ldr r2, [r1]
lsls r1, r0, 2
adds r1, r0
lsls r1, 2
adds r2, r1
adds r2, 0x50
ldrb r0, [r2]
cmp r0, 0
beq _080965B0
movs r0, 0
b _080965B2
.align 2, 0
_080965AC: .4byte gUnknown_203B490
_080965B0:
movs r0, 0x1
_080965B2:
pop {r1}
bx r1
thumb_func_end IsPelliperBoardSlotEmpty
thumb_func_start ResetPelliperBoardSlot
ResetPelliperBoardSlot:
push {r4,lr}
lsls r0, 24
lsrs r0, 24
ldr r4, _080965F0
ldr r1, [r4]
lsls r2, r0, 2
adds r2, r0
lsls r2, 2
adds r1, r2
adds r1, 0x50
movs r3, 0
strb r3, [r1]
ldr r0, [r4]
adds r0, r2
adds r0, 0x54
movs r1, 0x63
strb r1, [r0]
ldr r0, [r4]
adds r0, r2
adds r0, 0x55
strb r3, [r0]
ldr r0, [r4]
adds r0, r2
adds r0, 0x61
strb r3, [r0]
pop {r4}
pop {r0}
bx r0
.align 2, 0
_080965F0: .4byte gUnknown_203B490
thumb_func_end ResetPelliperBoardSlot
thumb_func_start sub_80965F4
sub_80965F4:
push {r4-r7,lr}
mov r7, r9
mov r6, r8
push {r6,r7}
movs r2, 0
movs r3, 0
ldr r0, _0809660C
mov r12, r0
mov r8, r3
movs r4, 0
mov r9, r4
b _08096636
.align 2, 0
_0809660C: .4byte gUnknown_203B490
_08096610:
cmp r2, r3
ble _0809662A
mov r1, r12
ldr r0, [r1]
mov r5, r8
adds r1, r0, r5
adds r0, r4
adds r1, 0x50
adds r0, 0x50
ldm r0!, {r5-r7}
stm r1!, {r5-r7}
ldm r0!, {r6,r7}
stm r1!, {r6,r7}
_0809662A:
adds r4, 0x14
movs r0, 0x14
add r9, r0
adds r2, 0x1
add r8, r0
adds r3, 0x1
_08096636:
cmp r2, 0x7
bgt _08096666
mov r1, r12
ldr r0, [r1]
adds r0, r4
adds r0, 0x50
ldrb r0, [r0]
cmp r0, 0
bne _08096666
ldr r6, _08096694
mov r1, r9
_0809664C:
adds r1, 0x14
adds r4, 0x14
movs r5, 0x14
add r9, r5
adds r2, 0x1
cmp r2, 0x7
bgt _08096666
ldr r0, [r6]
adds r0, r1
adds r0, 0x50
ldrb r0, [r0]
cmp r0, 0
beq _0809664C
_08096666:
cmp r2, 0x8
bne _08096610
cmp r3, 0x7
bgt _08096688
ldr r4, _08096694
movs r2, 0
lsls r0, r3, 2
adds r0, r3
lsls r1, r0, 2
_08096678:
ldr r0, [r4]
adds r0, r1
adds r0, 0x50
strb r2, [r0]
adds r1, 0x14
adds r3, 0x1
cmp r3, 0x7
ble _08096678
_08096688:
pop {r3,r4}
mov r8, r3
mov r9, r4
pop {r4-r7}
pop {r0}
bx r0
.align 2, 0
_08096694: .4byte gUnknown_203B490
thumb_func_end sub_80965F4
.align 2,0

425
asm/code_8096AF8.s Normal file
View File

@ -0,0 +1,425 @@
#include "asm/constants/gba_constants.inc"
#include "asm/macros.inc"
.syntax unified
.text
thumb_func_start sub_8096C80
sub_8096C80:
push {r4-r7,lr}
mov r7, r9
mov r6, r8
push {r6,r7}
movs r2, 0
movs r3, 0
ldr r0, _08096C98
mov r12, r0
mov r8, r3
movs r4, 0
mov r9, r4
b _08096CC2
.align 2, 0
_08096C98: .4byte gUnknown_203B490
_08096C9C:
cmp r2, r3
ble _08096CB6
mov r1, r12
ldr r0, [r1]
mov r5, r8
adds r1, r0, r5
adds r0, r4
adds r1, 0xF0
adds r0, 0xF0
ldm r0!, {r5-r7}
stm r1!, {r5-r7}
ldm r0!, {r6,r7}
stm r1!, {r6,r7}
_08096CB6:
adds r4, 0x14
movs r0, 0x14
add r9, r0
adds r2, 0x1
add r8, r0
adds r3, 0x1
_08096CC2:
cmp r2, 0x7
bgt _08096CF2
mov r1, r12
ldr r0, [r1]
adds r0, r4
adds r0, 0xF0
ldrb r0, [r0]
cmp r0, 0
bne _08096CF2
ldr r6, _08096D20
mov r1, r9
_08096CD8:
adds r1, 0x14
adds r4, 0x14
movs r5, 0x14
add r9, r5
adds r2, 0x1
cmp r2, 0x7
bgt _08096CF2
ldr r0, [r6]
adds r0, r1
adds r0, 0xF0
ldrb r0, [r0]
cmp r0, 0
beq _08096CD8
_08096CF2:
cmp r2, 0x8
bne _08096C9C
cmp r3, 0x7
bgt _08096D14
ldr r4, _08096D20
movs r2, 0
lsls r0, r3, 2
adds r0, r3
lsls r1, r0, 2
_08096D04:
ldr r0, [r4]
adds r0, r1
adds r0, 0xF0
strb r2, [r0]
adds r1, 0x14
adds r3, 0x1
cmp r3, 0x7
ble _08096D04
_08096D14:
pop {r3,r4}
mov r8, r3
mov r9, r4
pop {r4-r7}
pop {r0}
bx r0
.align 2, 0
_08096D20: .4byte gUnknown_203B490
thumb_func_end sub_8096C80
thumb_func_start sub_8096D24
sub_8096D24:
push {r4-r7,lr}
mov r7, r10
mov r6, r9
mov r5, r8
push {r5-r7}
sub sp, 0x18
movs r1, 0
_08096D32:
adds r6, r1, 0x1
mov r10, r6
cmp r6, 0x7
bgt _08096DBC
ldr r0, _08096DD4
mov r8, r0
lsls r0, r1, 2
adds r0, r1
lsls r0, 2
mov r9, r0
lsls r0, r6, 2
adds r0, r6
lsls r4, r0, 2
_08096D4C:
mov r1, r8
ldr r2, [r1]
adds r3, r2, r4
adds r5, r3, 0
adds r5, 0xF0
str r5, [sp, 0x14]
ldrb r0, [r5]
cmp r0, 0
beq _08096DB0
add r2, r9
mov r12, r2
mov r0, r12
adds r0, 0xF4
adds r1, r3, 0
adds r1, 0xF4
ldrb r2, [r0]
ldrb r0, [r1]
cmp r2, r0
bhi _08096D84
cmp r2, r0
bne _08096DB0
mov r0, r12
adds r0, 0xF5
adds r1, 0x1
ldrb r0, [r0]
ldrb r1, [r1]
cmp r0, r1
bls _08096DB0
_08096D84:
mov r2, r12
adds r2, 0xF0
mov r1, sp
adds r0, r2, 0
ldm r0!, {r3,r5,r7}
stm r1!, {r3,r5,r7}
ldm r0!, {r3,r7}
stm r1!, {r3,r7}
ldr r0, [sp, 0x14]
ldm r0!, {r1,r5,r7}
stm r2!, {r1,r5,r7}
ldm r0!, {r3,r5}
stm r2!, {r3,r5}
mov r7, r8
ldr r1, [r7]
adds r1, r4
adds r1, 0xF0
mov r0, sp
ldm r0!, {r2,r3,r5}
stm r1!, {r2,r3,r5}
ldm r0!, {r2,r7}
stm r1!, {r2,r7}
_08096DB0:
adds r4, 0x14
movs r3, 0x1
add r10, r3
mov r5, r10
cmp r5, 0x7
ble _08096D4C
_08096DBC:
adds r1, r6, 0
cmp r1, 0x6
ble _08096D32
add sp, 0x18
pop {r3-r5}
mov r8, r3
mov r9, r4
mov r10, r5
pop {r4-r7}
pop {r0}
bx r0
.align 2, 0
_08096DD4: .4byte gUnknown_203B490
thumb_func_end sub_8096D24
thumb_func_start sub_8096DD8
sub_8096DD8:
ldr r0, _08096DE4
ldr r0, [r0]
movs r1, 0xC8
lsls r1, 1
adds r0, r1
bx lr
.align 2, 0
_08096DE4: .4byte gUnknown_203B490
thumb_func_end sub_8096DD8
thumb_func_start sub_8096DE8
sub_8096DE8:
ldr r0, _08096DF4
ldr r0, [r0]
movs r1, 0xDC
lsls r1, 1
adds r0, r1
bx lr
.align 2, 0
_08096DF4: .4byte gUnknown_203B490
thumb_func_end sub_8096DE8
thumb_func_start ReceivePKMNNews
ReceivePKMNNews:
lsls r0, 24
lsrs r0, 24
ldr r1, _08096E10
ldr r1, [r1]
movs r2, 0xBC
lsls r2, 2
adds r1, r2
adds r1, r0
movs r0, 0x1
strb r0, [r1]
bx lr
.align 2, 0
_08096E10: .4byte gUnknown_203B490
thumb_func_end ReceivePKMNNews
thumb_func_start CheckPKMNNewsSlot
CheckPKMNNewsSlot:
lsls r0, 24
lsrs r0, 24
ldr r1, _08096E28
ldr r1, [r1]
movs r2, 0xBC
lsls r2, 2
adds r1, r2
adds r1, r0
ldrb r0, [r1]
bx lr
.align 2, 0
_08096E28: .4byte gUnknown_203B490
thumb_func_end CheckPKMNNewsSlot
thumb_func_start sub_8096E2C
sub_8096E2C:
push {lr}
movs r3, 0
ldr r0, _08096E70
ldr r1, [r0]
movs r2, 0x3
_08096E36:
ldrb r0, [r1]
cmp r0, 0x1
bne _08096E48
ldrb r0, [r1, 0x5]
cmp r3, r0
bgt _08096E48
cmp r0, 0x31
bhi _08096E48
adds r3, r0, 0x1
_08096E48:
adds r1, 0x14
subs r2, 0x1
cmp r2, 0
bge _08096E36
adds r2, r3, 0
cmp r2, 0x31
bgt _08096E7A
ldr r0, _08096E70
ldr r0, [r0]
movs r3, 0xBC
lsls r3, 2
adds r1, r0, r3
_08096E60:
adds r0, r1, r2
ldrb r0, [r0]
cmp r0, 0
bne _08096E74
lsls r0, r2, 24
lsrs r0, 24
b _08096E7C
.align 2, 0
_08096E70: .4byte gUnknown_203B490
_08096E74:
adds r2, 0x1
cmp r2, 0x31
ble _08096E60
_08096E7A:
movs r0, 0x38
_08096E7C:
pop {r1}
bx r1
thumb_func_end sub_8096E2C
thumb_func_start sub_8096E80
sub_8096E80:
push {lr}
lsls r0, 24
lsrs r3, r0, 24
movs r2, 0
ldr r0, _08096E9C
ldr r1, [r0]
_08096E8C:
ldrb r0, [r1]
cmp r0, 0x1
bne _08096EA0
ldrb r0, [r1, 0x5]
cmp r3, r0
bne _08096EA0
movs r0, 0x1
b _08096EAA
.align 2, 0
_08096E9C: .4byte gUnknown_203B490
_08096EA0:
adds r1, 0x14
adds r2, 0x1
cmp r2, 0x3
ble _08096E8C
movs r0, 0
_08096EAA:
pop {r1}
bx r1
thumb_func_end sub_8096E80
thumb_func_start sub_8096EB0
sub_8096EB0:
ldrb r1, [r0, 0x2]
ldrb r2, [r0, 0x1]
adds r1, r2
ldrb r3, [r0, 0x4]
adds r2, r1, r3
ldrb r1, [r0, 0x5]
adds r2, r1
ldr r1, [r0, 0x8]
lsls r1, 8
adds r2, r1
movs r3, 0xC
ldrsh r1, [r0, r3]
lsls r1, 12
adds r2, r1
movs r3, 0xE
ldrsh r1, [r0, r3]
lsls r1, 16
adds r2, r1
ldrb r1, [r0, 0x10]
lsls r1, 24
adds r1, r2, r1
ldrb r3, [r0, 0x11]
adds r2, r1, r3
ldrb r1, [r0, 0x12]
adds r1, r2, r1
ldrb r0, [r0, 0x13]
adds r2, r1, r0
adds r0, r2, 0
bx lr
thumb_func_end sub_8096EB0
thumb_func_start sub_8096EEC
sub_8096EEC:
push {r4-r7,lr}
mov r7, r8
push {r7}
mov r12, r0
movs r3, 0xF
ldr r5, _08096F4C
mov r8, r5
movs r4, 0x8C
lsls r4, 2
_08096EFE:
mov r0, r8
ldr r2, [r0]
lsls r1, r3, 1
adds r1, r3
lsls r1, 2
adds r1, r2, r1
subs r3, 0x1
lsls r0, r3, 1
adds r0, r3
lsls r0, 2
adds r2, r0
adds r1, r4
adds r2, r4
ldm r2!, {r0,r6,r7}
stm r1!, {r0,r6,r7}
cmp r3, 0
bgt _08096EFE
ldr r2, [r5]
movs r3, 0x8C
lsls r3, 2
adds r2, r3
mov r6, r12
ldr r0, [r6, 0x4]
ldr r1, [r6, 0x8]
str r0, [r2]
str r1, [r2, 0x4]
mov r0, r12
bl sub_8096EB0
ldr r1, [r5]
movs r7, 0x8E
lsls r7, 2
adds r1, r7
str r0, [r1]
pop {r3}
mov r8, r3
pop {r4-r7}
pop {r0}
bx r0
.align 2, 0
_08096F4C: .4byte gUnknown_203B490
thumb_func_end sub_8096EEC
.align 2,0

View File

@ -6868,7 +6868,7 @@ _080A167A:
bl sub_80961D8
b _080A1804
_080A1680:
bl sub_8096028
bl ResetMailbox
bl _080A236A
_080A1688:
bl sub_80963FC

View File

@ -146,7 +146,7 @@ CreateMailActionMenu:
ldr r4, _0802E3F0
ldr r0, [r4]
ldrb r0, [r0, 0x8]
bl sub_8095FE8
bl GetMailboxSlotInfo
adds r7, r0, 0
ldrb r0, [r7]
cmp r0, 0x1

View File

@ -135,7 +135,7 @@ sub_802EC10:
movs r0, 0x4
str r0, [r1]
ldrb r0, [r2, 0x8]
bl sub_8096574
bl GetPelliperBoardSlotInfo
bl sub_80968B0
lsls r0, 24
cmp r0, 0

View File

@ -371,7 +371,7 @@ _0802CD80:
_0802CD88:
ldr r0, [r4]
ldrb r0, [r0, 0xC]
bl sub_8096C3C
bl ResetJobSlot
bl sub_8096C80
bl HasNoAcceptedJobs
lsls r0, 24

View File

@ -1,8 +1,7 @@
struct subStruct_203B490
{
// size: 0xC
u8 dungeon;
u8 unk1;
struct DungeonLocation dungeon;
u32 unk4;
u32 unk8;
};
@ -11,14 +10,14 @@ struct subStruct_203B490
struct unkStruct_203B490
{
// size: 0x330?
struct WonderMail unk0[4];
struct WonderMail unk50[8];
struct WonderMail unkF0[8];
struct WonderMail mailboxSlots[4];
struct WonderMail pelliperBoardJobs[8];
/* 0xF0 */ struct WonderMail jobSlots[8];
u8 unk190[0x28];
u8 unk1B8[0x78];
struct subStruct_203B490 unk230[16];
u8 unk2F0[0x38];
u8 unk328;
u8 PKMNNewsReceived[56];
bool8 unk328;
};
extern struct unkStruct_203B490 *gUnknown_203B490;

View File

@ -44,6 +44,7 @@ enum WonderMailMissionTypes
WONDER_MAIL_MISSION_TYPE_ESCORT_CLIENT = 2,
WONDER_MAIL_MISSION_TYPE_FIND_ITEM = 3,
WONDER_MAIL_MISSION_TYPE_DELIVER_ITEM = 4,
WONDER_MAIL_MISSION_TYPE_UNK6 = 6,
};

View File

@ -10,7 +10,7 @@ struct unkStruct_203B304
// size: 0xB6 << 1
u32 state;
u32 fallbackState;
u8 unk8;
u8 mailboxIndex;
u8 mailIndex;
u8 fillA[0xC - 0xA];
u32 unkC;

View File

@ -32,7 +32,7 @@ struct unkStruct_802C39C
struct unkStruct_803B344
{
// size: 0xB4
struct WonderMail unk0;
struct WonderMail mail;
u8* unk14;
u8* unk18;
u8 fill1C[0x3C - 0x1C];
@ -51,12 +51,12 @@ struct unkStruct_203B2F8
// size: 0x208
s32 state; // state
s32 fallbackState;
u8 unk8;
u8 unk9;
u8 unkA;
u8 wonderMailAccepted;
bool8 unk9;
u8 dungeonIndex;
u8 unkB;
struct unkSubStruct_203B2F8 *unkC;
u8 unk10;
u8 jobSlotIndex;
u8 fill11[0x14 - 0x11];
u32 unk14;
u8 fill18[0x58 - 0x18];

View File

@ -318,6 +318,10 @@ SECTIONS {
src/code_8095824.o(.text);
src/code_80958E8.o(.text);
asm/code_80958E8.o(.text);
src/mailbox_8095F8C.o(.text);
asm/code_80958E8_1.o(.text);
src/code_80958E8_1.o(.text);
asm/code_8096AF8.o(.text);
src/code_80972F4.o(.text);
asm/code_8097318.o(.text);
src/code_809747C.o(.text);

View File

@ -19,9 +19,9 @@ extern bool8 IsNotMoneyOrUsedTMItem(u8);
extern u8 xxx_bit_lut_lookup_8091E50(u8 ,u8 );
extern u32 GetMaxItemCount(u8);
extern bool8 sub_803C0DC(s16);
extern void sub_8096040(u8);
extern void sub_80965B8(u8);
extern void sub_8096C3C(u8);
extern void ResetMailboxSlot(u8);
extern void ResetPelliperBoardSlot(u8);
extern void ResetJobSlot(u8);
extern bool8 ValidateWonderMail(struct WonderMail *);
extern struct unkStruct_203B490 *gUnknown_203B490;
@ -37,34 +37,34 @@ struct unkStruct_203B490 *sub_80958F8(void)
return &gUnknown_2039448;
}
void sub_8095900(void)
void InitializeMailJobsNews(void)
{
s32 iVar2;
for(iVar2 = 0; iVar2 < 4; iVar2++)
s32 index;
for(index = 0; index < 4; index++)
{
sub_8096040(iVar2);
ResetMailboxSlot(index);
}
for(iVar2 = 0; iVar2 < 8; iVar2++)
for(index = 0; index < 8; index++)
{
sub_80965B8(iVar2);
ResetPelliperBoardSlot(index);
}
for(iVar2 = 0; iVar2 < 8; iVar2++)
for(index = 0; index < 8; index++)
{
sub_8096C3C(iVar2);
ResetJobSlot(index);
}
for(iVar2 = 0; iVar2 < 0x38; iVar2++)
for(index = 0; index < 56; index++)
{
gUnknown_203B490->unk2F0[iVar2] = 0;
gUnknown_203B490->PKMNNewsReceived[index] = FALSE;
}
gUnknown_203B490->unk328 = 0;
gUnknown_203B490->unk328 = FALSE;
MemoryClear8(gUnknown_203B490->unk190, sizeof(gUnknown_203B490->unk190));
MemoryClear8(gUnknown_203B490->unk1B8, sizeof(gUnknown_203B490->unk1B8));
for(iVar2 = 0; iVar2 < 16; iVar2++)
for(index = 0; index < 16; index++)
{
gUnknown_203B490->unk230[iVar2].dungeon = 99;
gUnknown_203B490->unk230[iVar2].unk1 = 1;
gUnknown_203B490->unk230[iVar2].unk4 = 0;
gUnknown_203B490->unk230[iVar2].unk8 = 0;
gUnknown_203B490->unk230[index].dungeon.dungeonIndex = 99;
gUnknown_203B490->unk230[index].dungeon.dungeonFloor = 1;
gUnknown_203B490->unk230[index].unk4 = 0;
gUnknown_203B490->unk230[index].unk8 = 0;
}
}

373
src/code_80958E8_1.c Normal file
View File

@ -0,0 +1,373 @@
#include "global.h"
#include "constants/dungeon.h"
#include "constants/wonder_mail.h"
#include "item.h"
#include "wonder_mail.h"
#include "code_80958E8.h"
#include "team_inventory.h"
#include "random.h"
struct unkStruct_8096AF8
{
bool8 unk0;
u16 clientSpecies;
u16 targetSpecies;
};
extern u8 IsJobSlotEmpty(u8);
extern struct WonderMail * GetJobSlotInfo(u8);
extern bool8 IsValidWonderMail(struct WonderMail *WonderMailData);
extern u8 sub_8095E38(struct WonderMail *, u8, u8, bool8);
extern void sub_808CFD0(s32, s16, u8, u8, u32 *, u32);
extern void ResetJobSlot(u8);
extern void sub_8096C80(void);
extern void sub_8096D24(void);
extern void sub_80965F4();
extern void sub_8096698();
extern struct WonderMail *GetPelliperBoardSlotInfo(u8);
u8 sub_8097318(s16 param_1);
extern u8 sub_8095B28(struct WonderMail *);
void sub_8096698(void)
{
s32 index1;
s32 index2;
struct WonderMail mail;
for(index1 = 0; index1 < 7; index1++)
{
for(index2 = index1 + 1; index2 < 8; index2++)
{
if(gUnknown_203B490->pelliperBoardJobs[index2].mailType != 0)
{
if((gUnknown_203B490->pelliperBoardJobs[index1].dungeon.dungeonIndex > gUnknown_203B490->pelliperBoardJobs[index2].dungeon.dungeonIndex) ||
((gUnknown_203B490->pelliperBoardJobs[index1].dungeon.dungeonIndex == gUnknown_203B490->pelliperBoardJobs[index2].dungeon.dungeonIndex) && (gUnknown_203B490->pelliperBoardJobs[index1].dungeon.dungeonFloor > gUnknown_203B490->pelliperBoardJobs[index2].dungeon.dungeonFloor)))
{
mail = gUnknown_203B490->pelliperBoardJobs[index1];
gUnknown_203B490->pelliperBoardJobs[index1] = gUnknown_203B490->pelliperBoardJobs[index2];
gUnknown_203B490->pelliperBoardJobs[index2] = mail;
}
}
}
}
}
void sub_809674C(void)
{
s32 range;
struct WonderMail *mail;
s32 index;
range = RandomRange(4,8);
for(index = 0; index < 8; index++)
{
gUnknown_203B490->pelliperBoardJobs[index].mailType = 0;
}
index = 0;
if (sub_8097318(0xe) != 0) {
mail = GetPelliperBoardSlotInfo(0);
mail->mailType = 2;
mail->missionType = WONDER_MAIL_MISSION_TYPE_UNK6;
mail->unk2 = 1;
mail->dungeon.dungeonIndex = DUNGEON_UPROAR_FOREST;
mail->dungeon.dungeonFloor = 10;
mail->unk8 = Random() & 0xffffff;
mail->clientSpecies = SPECIES_WYNAUT;
mail->targetSpecies = SPECIES_MANKEY;
mail->targetItem = 0;
mail->rewardType = ITEM;
mail->itemReward = ITEM_ID_REVIVER_SEED;
mail->friendAreaReward = 0;
index = 1;
}
if (sub_8097318(0xf) != 0) {
mail = GetPelliperBoardSlotInfo(index);
mail->mailType = 3;
mail->missionType = WONDER_MAIL_MISSION_TYPE_UNK6;
mail->unk2 = 2;
mail->dungeon.dungeonIndex = DUNGEON_HOWLING_FOREST;
mail->dungeon.dungeonFloor = 15;
mail->unk8 = Random() & 0xffffff;
mail->clientSpecies = SPECIES_SMEARGLE;
mail->targetSpecies = SPECIES_SMEARGLE;
mail->targetItem = 0;
mail->rewardType = ITEM;
mail->itemReward = ITEM_ID_REVIVER_SEED;
mail->friendAreaReward = 0;
index++;
}
if (sub_8097318(0x1c) != 0) {
mail = GetPelliperBoardSlotInfo(index);
mail->mailType = 4;
mail->missionType = WONDER_MAIL_MISSION_TYPE_UNK6;
mail->unk2 = 3;
mail->dungeon.dungeonIndex = DUNGEON_WISH_CAVE;
mail->dungeon.dungeonFloor = 20;
mail->unk8 = Random() & 0xffffff;
mail->clientSpecies = SPECIES_MEDICHAM;
mail->targetSpecies = SPECIES_MEDICHAM;
mail->targetItem = 0;
mail->rewardType = ITEM;
mail->itemReward = ITEM_ID_REVIVER_SEED;
mail->friendAreaReward = 0;
index++;
}
for (; index <= range; index++) {
if (sub_8095B28(&gUnknown_203B490->pelliperBoardJobs[index]) == 0) break;
gUnknown_203B490->pelliperBoardJobs[index].rewardType = RandomRange(MONEY, BLANK_4);
}
sub_80965F4();
sub_8096698();
}
bool8 sub_80968B0(struct WonderMail *mail)
{
struct WonderMail *jobSlot;
s32 index;
for(index = 0, jobSlot = &gUnknown_203B490->jobSlots[0]; index < 8; jobSlot++, index++)
{
if(jobSlot->mailType != WONDER_MAIL_TYPE_NONE)
if(mail->missionType == jobSlot->missionType)
if(mail->unk2 == jobSlot->unk2)
if(mail->dungeon.dungeonIndex == jobSlot->dungeon.dungeonIndex)
if(mail->dungeon.dungeonFloor == jobSlot->dungeon.dungeonFloor)
if(mail->unk8 == jobSlot->unk8)
if(mail->clientSpecies == jobSlot->clientSpecies)
if(mail->targetSpecies == jobSlot->targetSpecies)
if(mail->targetItem == jobSlot->targetItem)
if(mail->rewardType == jobSlot->rewardType)
if(mail->itemReward == jobSlot->itemReward)
if(mail->friendAreaReward == jobSlot->friendAreaReward)
return TRUE;
}
return FALSE;
}
bool8 sub_809693C(struct WonderMail *mail)
{
u8 dungeonIndex;
u8 floor;
bool8 escortMission;
s32 index;
dungeonIndex = mail->dungeon.dungeonIndex;
floor = mail->dungeon.dungeonFloor;
escortMission = FALSE;
if (!IsValidWonderMail(mail)) {
return FALSE;
}
else
{
if(mail->missionType == WONDER_MAIL_MISSION_TYPE_ESCORT_CLIENT)
escortMission = TRUE;
for(index = 0; index < 8; index++)
{
if ((gUnknown_203B490->jobSlots[index].mailType == 6) &&
(sub_8095E38(&gUnknown_203B490->jobSlots[index],dungeonIndex,floor,escortMission) != 0))
{
return TRUE;
}
}
}
return FALSE;
}
s32 GetNumAcceptedJobs(void)
{
s32 index;
s32 count;
count = 0;
for(index = 0; index < 8; index++)
{
if (!IsJobSlotEmpty(index)) {
count++;
}
}
return count;
}
s32 CountJobsinDungeon(u8 dungeon)
{
struct WonderMail *mail;
s32 index;
s32 count;
count = 0;
for(index = 0; index < 8; index++)
{
mail = GetJobSlotInfo(index);
if ((mail->dungeon.dungeonIndex == dungeon) &&
(((mail->mailType == 6 || (mail->mailType == 8)) || (mail->mailType == 9)))) {
count++;
}
}
return count;
}
bool8 sub_8096A08(u8 dungeon, s32 param_2)
{
struct WonderMail *mail;
s32 index;
u32 local_14;
s32 temp;
for(index = 0; index < 8; index++)
{
mail = GetJobSlotInfo(index);
if(mail->dungeon.dungeonIndex == dungeon)
if(mail->mailType == 6)
if(mail->missionType == WONDER_MAIL_MISSION_TYPE_ESCORT_CLIENT)
{
temp = 0xffffff00;
local_14 &= temp;
temp = 0x4A;
local_14 |= temp;
temp = 0xffff00ff;
local_14 &= temp;
temp = 0x100;
local_14 |= temp;
sub_808CFD0(param_2,mail->clientSpecies,0,0,&local_14,0);
return TRUE;
}
}
return FALSE;
}
bool8 sub_8096A78(struct WonderMail *mail)
{
s32 index;
for(index = 0; index < 8; index++)
{
if(gUnknown_203B490->jobSlots[index].mailType == WONDER_MAIL_TYPE_NONE)
{
gUnknown_203B490->jobSlots[index] = *mail;
return FALSE;
}
}
return TRUE;
}
struct WonderMail *GetJobSlotInfo(u8 index)
{
return &gUnknown_203B490->jobSlots[index];
}
bool8 IsJobSlotEmpty(u8 index)
{
if(gUnknown_203B490->jobSlots[index].mailType == WONDER_MAIL_TYPE_NONE)
return TRUE;
else
return FALSE;
}
void sub_8096AF8(struct unkStruct_8096AF8 *param_1, u8 slotIndex,u8 dungeon)
{
struct WonderMail *jobSlot;
struct ItemSlot *item;
s32 index;
jobSlot = GetJobSlotInfo(slotIndex);
param_1->unk0 = FALSE;
param_1->clientSpecies = jobSlot->clientSpecies;
param_1->targetSpecies = 0;
if (jobSlot->dungeon.dungeonIndex == dungeon) {
switch(jobSlot->missionType) {
case WONDER_MAIL_MISSION_TYPE_FIND_ITEM:
if (jobSlot->mailType == 6) {
for(index = 0; index < INVENTORY_SIZE; index++)
{
item = &gTeamInventory_203B460->teamItems[index];
if (((item->itemFlags & ITEM_FLAG_EXISTS)) && (item->itemIndex == jobSlot->targetItem)) {
param_1->unk0 = TRUE;
}
}
}
break;
case WONDER_MAIL_MISSION_TYPE_RESCUE_CLIENT:
case WONDER_MAIL_MISSION_TYPE_DELIVER_ITEM:
if (jobSlot->mailType == 9) {
param_1->unk0 = TRUE;
}
break;
case WONDER_MAIL_MISSION_TYPE_RESCUE_TARGET:
case WONDER_MAIL_MISSION_TYPE_ESCORT_CLIENT:
if (jobSlot->mailType == 9) {
param_1->unk0 = TRUE;
param_1->targetSpecies = jobSlot->targetSpecies;
}
break;
}
}
}
// Unused
s16 sub_8096B98(u8 dungeon)
{
struct WonderMail *mail;
s32 index;
for(index = 0; index < 8; index++)
{
mail = GetJobSlotInfo(index);
if(mail->mailType == 6)
if(mail->missionType == WONDER_MAIL_MISSION_TYPE_ESCORT_CLIENT)
if(mail->dungeon.dungeonIndex == dungeon)
return mail->targetSpecies;
}
return 0;
}
void sub_8096BD0(void)
{
s32 index;
struct WonderMail *mail;
for(mail = &gUnknown_203B490->jobSlots[0], index = 0; index < 8; mail++, index++)
{
switch(mail->mailType)
{
case 7:
case 8:
case 9:
ResetJobSlot(index);
break;
}
}
sub_8096C80();
sub_8096D24();
}
bool8 sub_8096C08(u8 *param_1)
{
s32 index;
struct WonderMail *mail;
for(mail = &gUnknown_203B490->jobSlots[0], index = 0; index < 8; mail++, index++)
{
if(mail->mailType > 4 && mail->unk2 == 4)
{
param_1[0] = index;
return TRUE;
}
}
return FALSE;
}
void ResetJobSlot(u8 index)
{
gUnknown_203B490->jobSlots[index].mailType = WONDER_MAIL_TYPE_NONE;
gUnknown_203B490->jobSlots[index].dungeon.dungeonIndex = 99;
gUnknown_203B490->jobSlots[index].dungeon.dungeonFloor = 0;
gUnknown_203B490->jobSlots[index].rewardType = MONEY1;
}

View File

@ -1,33 +1,11 @@
#include "global.h"
#include "pokemon.h"
#include "wonder_mail.h"
struct subStruct_203B490
{
// size: 0xC
struct DungeonLocation dungeon;
u32 unk4;
u32 unk8;
};
struct unkStruct_203B490
{
// size: 0x330?
struct WonderMail unk0[4];
struct WonderMail unk50[8];
struct WonderMail unkF0[8];
u8 unk190[0x28];
u8 unk1B8[0x78];
struct subStruct_203B490 unk230[16];
u8 unk2F0[0x38];
u8 unk328;
};
extern struct unkStruct_203B490 *gUnknown_203B490;
#include "code_80958E8.h"
void SaveWonderMail(struct unkStruct_8094924 *a, struct WonderMail *b);
void RestoreWonderMail(struct unkStruct_8094924 *a, struct WonderMail *b);
extern s32 sub_8096EB0(void);
extern s32 sub_8096EB0(struct WonderMail *);
extern void SaveDungeonLocation(struct unkStruct_8094924*, struct DungeonLocation*);
extern void RestoreDungeonLocation(struct unkStruct_8094924*, struct DungeonLocation*);
extern void sub_80015C0(u32, u32);
@ -35,21 +13,21 @@ extern u32 sub_8001784(u32, u32, u16);
extern void sub_809674C();
extern void sub_800199C(u32, s32, u32, s32);
bool8 sub_8096F50(struct WonderMail *r0)
bool8 sub_8096F50(struct WonderMail *mail)
{
s32 index;
s32 temp2;
struct subStruct_203B490 *temp;
temp2 = sub_8096EB0();
temp2 = sub_8096EB0(mail);
for(index = 0; index < 0x10; index++)
{
temp = &gUnknown_203B490->unk230[index];
if(temp->dungeon.dungeonIndex == r0->dungeon.dungeonIndex)
if(temp->dungeon.dungeonFloor == r0->dungeon.dungeonFloor)
if(temp->unk4 == r0->unk8)
if(temp->dungeon.dungeonIndex == mail->dungeon.dungeonIndex)
if(temp->dungeon.dungeonFloor == mail->dungeon.dungeonFloor)
if(temp->unk4 == mail->unk8)
if(temp->unk8 == temp2)
return TRUE;
}
@ -65,29 +43,29 @@ u32 sub_8096FA0(u8 *r0, u32 size)
xxx_init_struct_8094924_restore_809485C(&backup, r0, size);
for(index = 0; index < 4; index++)
{
RestoreWonderMail(&backup, &gUnknown_203B490->unk0[index]);
RestoreWonderMail(&backup, &gUnknown_203B490->mailboxSlots[index]);
}
for(index = 0; index < 8; index++)
{
RestoreWonderMail(&backup, &gUnknown_203B490->unk50[index]);
RestoreWonderMail(&backup, &gUnknown_203B490->pelliperBoardJobs[index]);
}
for(index = 0; index < 8; index++)
{
RestoreWonderMail(&backup, &gUnknown_203B490->unkF0[index]);
RestoreWonderMail(&backup, &gUnknown_203B490->jobSlots[index]);
}
for(index = 0; index < 0x38; index++)
{
RestoreIntegerBits(&backup, &temp, 1);
if(temp & 1)
gUnknown_203B490->unk2F0[index] = 1;
gUnknown_203B490->PKMNNewsReceived[index] = TRUE;
else
gUnknown_203B490->unk2F0[index] = 0;
gUnknown_203B490->PKMNNewsReceived[index] = FALSE;
}
RestoreIntegerBits(&backup, &temp, 1);
if(temp & 1)
gUnknown_203B490->unk328 = 1;
gUnknown_203B490->unk328 = TRUE;
else
gUnknown_203B490->unk328 = 0;
gUnknown_203B490->unk328 = FALSE;
RestoreIntegerBits(&backup, gUnknown_203B490->unk190, 0x140);
RestoreIntegerBits(&backup, gUnknown_203B490->unk1B8, 0x3C0);
@ -110,25 +88,25 @@ u32 sub_80970D8(u8 *r0, u32 size)
xxx_init_struct_8094924_save_809486C(&backup, r0, size);
for(index = 0; index < 4; index++)
{
SaveWonderMail(&backup, &gUnknown_203B490->unk0[index]);
SaveWonderMail(&backup, &gUnknown_203B490->mailboxSlots[index]);
}
for(index = 0; index < 8; index++)
{
SaveWonderMail(&backup, &gUnknown_203B490->unk50[index]);
SaveWonderMail(&backup, &gUnknown_203B490->pelliperBoardJobs[index]);
}
for(index = 0; index < 8; index++)
{
SaveWonderMail(&backup, &gUnknown_203B490->unkF0[index]);
SaveWonderMail(&backup, &gUnknown_203B490->jobSlots[index]);
}
for(index = 0; index < 0x38; index++)
{
if(gUnknown_203B490->unk2F0[index] != 0)
if(gUnknown_203B490->PKMNNewsReceived[index] != 0)
temp = -1;
else
temp = 0;
SaveIntegerBits(&backup, &temp, 1);
}
if(gUnknown_203B490->unk328 != 0)
if(gUnknown_203B490->unk328)
temp = -1;
else
temp = 0;

View File

@ -4,6 +4,7 @@
#include "menu.h"
#include "input.h"
#include "mailbox.h"
#include "wonder_mail.h"
extern void HandleMailboxMenu(void);
@ -79,8 +80,8 @@ extern void sub_802BD14(u32, u32, u32);
extern void sub_802BE94(u32);
extern void CreateMailMenu(void);
extern void CreateMailAcceptedStatusBox(u32);
extern u32 sub_8095FE8(u32);
extern void sub_803B35C(u32, u32 *);
extern struct WonderMail * GetMailboxSlotInfo(u32);
extern void sub_803B35C(struct WonderMail *, u32 *);
extern void sub_802DE84(u32 *);
extern void sub_802C860(u32);
extern void sub_802B640(u32, u32, u32);
@ -204,7 +205,7 @@ void sub_802E1AC(void)
sub_8012D60(&gUnknown_203B304->unk6C, gUnknown_203B304->unkBC, 0, 0, gUnknown_203B304->unk68, 2);
break;
case 7:
sub_803B35C(sub_8095FE8(gUnknown_203B304->unk8), &gUnknown_203B304->unkC);
sub_803B35C(GetMailboxSlotInfo(gUnknown_203B304->mailboxIndex), &gUnknown_203B304->unkC);
gUnknown_203B304->unkC = 3;
gUnknown_203B304->unk50 = 0;
sub_802DE84(&gUnknown_203B304->unkC);

View File

@ -4,6 +4,7 @@
#include "menu.h"
#include "input.h"
#include "mailbox.h"
#include "wonder_mail.h"
extern struct unkStruct_203B304 *gUnknown_203B304;
@ -24,16 +25,16 @@ extern u32 sub_802C898(void);
extern void sub_802C8F4(void);
extern u32 sub_802DEE0(void);
extern void sub_802DF24(void);
extern u8 *sub_8095FE8(u8);
extern struct WonderMail *GetMailboxSlotInfo(u8);
extern u8 HasNoMailinMailbox(void);
extern u8 sub_8012FD8(u32 *);
extern void sub_8013114(u32 *, s32 *);
extern u32 sub_802BDEC(u32);
extern void sub_8096A78(void);
extern void sub_8096A78(struct WonderMail *);
extern void sub_8096C80(void);
extern void sub_8096D24(void);
extern void sub_8096040(u8);
extern void sub_8096DF8(u8);
extern void ResetMailboxSlot(u8);
extern void ReceivePKMNNews(u8);
extern void sub_8096078(void);
extern void PlayMenuSoundEffect(u32);
extern void PlaySound(u32);
@ -83,21 +84,21 @@ void HandleMailboxMenu(void)
void sub_802E578(void)
{
u8 *return_var;
struct WonderMail *return_var;
switch(sub_802BDEC(1))
{
case 3:
gUnknown_203B304->unk8 = sub_802BE74();
gUnknown_203B304->mailboxIndex = sub_802BE74();
SetMailboxState(6);
break;
case 4:
gUnknown_203B304->unk8 = sub_802BE74();
return_var = sub_8095FE8(gUnknown_203B304->unk8);
if(return_var[0] == 1)
gUnknown_203B304->mailboxIndex = sub_802BE74();
return_var = GetMailboxSlotInfo(gUnknown_203B304->mailboxIndex);
if(return_var->mailType == 1)
{
gUnknown_203B304->mailIndex = return_var[5];
gUnknown_203B304->mailIndex = return_var->dungeon.dungeonFloor;
gUnknown_203B304->fallbackState = 5;
SetMailboxState(0xB);
}
@ -117,7 +118,7 @@ void sub_802E578(void)
void HandleMailActionMenu(void)
{
s32 menuAction = 0;
u8 *return_var;
struct WonderMail *return_var;
sub_802BDEC(0);
@ -134,11 +135,10 @@ void HandleMailActionMenu(void)
break;
case 5:
PlaySound(0x133);
sub_8095FE8(gUnknown_203B304->unk8);
sub_8096A78();
sub_8096A78(GetMailboxSlotInfo(gUnknown_203B304->mailboxIndex));
sub_8096C80();
sub_8096D24();
sub_8096040(gUnknown_203B304->unk8);
ResetMailboxSlot(gUnknown_203B304->mailboxIndex);
sub_8096078();
if(HasNoMailinMailbox())
{
@ -153,9 +153,9 @@ void HandleMailActionMenu(void)
break;
case 6:
PlaySound(0x133);
return_var = sub_8095FE8(gUnknown_203B304->unk8);
sub_8096DF8(return_var[5]);
sub_8096040(gUnknown_203B304->unk8);
return_var = GetMailboxSlotInfo(gUnknown_203B304->mailboxIndex);
ReceivePKMNNews(return_var->dungeon.dungeonFloor);
ResetMailboxSlot(gUnknown_203B304->mailboxIndex);
sub_8096078();
if(HasNoMailinMailbox())
{
@ -167,8 +167,8 @@ void HandleMailActionMenu(void)
break;
case 7:
PlayMenuSoundEffect(0);
return_var = sub_8095FE8(gUnknown_203B304->unk8);
gUnknown_203B304->mailIndex = return_var[5];
return_var = GetMailboxSlotInfo(gUnknown_203B304->mailboxIndex);
gUnknown_203B304->mailIndex = return_var->dungeon.dungeonFloor;
gUnknown_203B304->fallbackState = 5;
SetMailboxState(0xB);
break;

68
src/mailbox_8095F8C.c Normal file
View File

@ -0,0 +1,68 @@
#include "global.h"
#include "wonder_mail.h"
#include "code_80958E8.h"
extern struct unkStruct_203B490 *gUnknown_203B490;
bool8 IsMailSlotEmpty(u8);
void ResetMailboxSlot(u8);
s32 CountFilledMailboxSlots(void)
{
s32 index;
s32 counter;
counter = 0;
for(index = 0; index < 4; index++)
{
if(!IsMailSlotEmpty(index))
counter++;
}
return counter;
}
// Unused
bool8 sub_8095FB0(struct WonderMail *mail)
{
s32 index;
for(index = 0; index < 4; index++)
{
if(gUnknown_203B490->mailboxSlots[index].mailType == WONDER_MAIL_TYPE_NONE)
{
gUnknown_203B490->mailboxSlots[index] = *mail;
return FALSE;
}
}
return TRUE;
}
struct WonderMail *GetMailboxSlotInfo(u8 index)
{
return &gUnknown_203B490->mailboxSlots[index];
}
bool8 IsMailSlotEmpty(u8 index)
{
if(gUnknown_203B490->mailboxSlots[index].mailType == WONDER_MAIL_TYPE_NONE)
return TRUE;
else
return FALSE;
}
void ResetMailbox(void)
{
s32 index;
for(index = 0; index < 4; index++)
{
ResetMailboxSlot(index);
}
}
void ResetMailboxSlot(u8 index)
{
gUnknown_203B490->mailboxSlots[index].mailType = WONDER_MAIL_TYPE_NONE;
gUnknown_203B490->mailboxSlots[index].dungeon.dungeonIndex = 99;
gUnknown_203B490->mailboxSlots[index].dungeon.dungeonFloor = 0;
gUnknown_203B490->mailboxSlots[index].rewardType = MONEY1;
}

View File

@ -10,7 +10,7 @@ struct unkStruct_203B308
// size: 0xB6 << 1
u32 state;
u32 unk4;
u8 unk8;
u8 jobIndex;
u8 fill9[0xC - 9];
u32 unkC;
u8 fill10[0x50 - 0x10];
@ -90,8 +90,8 @@ extern void sub_802C10C(u32, u32, u32);
extern void sub_802C28C(u32);
extern void sub_802C39C(void);
extern void CreatePelipperAcceptedStatusBox(u32);
extern u32 sub_8096574(u32);
extern void sub_803B35C(u32, u32 *);
extern struct WonderMail *GetPelliperBoardSlotInfo(u32);
extern void sub_803B35C(struct WonderMail *, u32 *);
extern void sub_802DE84(u32 *);
extern void sub_802C860(u32);
@ -211,7 +211,7 @@ void sub_802EA58(void)
sub_8012D60(&gUnknown_203B308->unk6C, gUnknown_203B308->unkBC, 0, 0, gUnknown_203B308->unk68, 2);
break;
case 7:
sub_803B35C(sub_8096574(gUnknown_203B308->unk8), &gUnknown_203B308->unkC);
sub_803B35C(GetPelliperBoardSlotInfo(gUnknown_203B308->jobIndex), &gUnknown_203B308->unkC);
gUnknown_203B308->unkC = 3;
gUnknown_203B308->unk50 = 0;
sub_802DE84(&gUnknown_203B308->unkC);

View File

@ -6,13 +6,14 @@
#include "menu.h"
#include "text.h"
#include "team_inventory.h"
#include "wonder_mail.h"
struct unkStruct_203B308
{
// size: 0xB6 << 1
u32 state;
u32 unk4;
u8 unk8;
u8 jobIndex;
u8 fill9[0xC - 9];
u32 unkC;
u8 fill10[0x50 - 0x10];
@ -39,12 +40,12 @@ extern u32 sub_802C898(void);
extern void sub_802C8F4(void);
extern u32 sub_802DEE0(void);
extern void sub_802DF24(void);
extern u8 *sub_8096574(u8);
extern struct WonderMail *GetPelliperBoardSlotInfo(u8);
extern u8 sub_802C4A4(void);
extern void sub_8096C80(void);
extern void sub_8096D24(void);
extern void sub_8096A78(u8 *);
extern void sub_80965B8(u8);
extern void sub_8096A78(struct WonderMail*);
extern void ResetPelliperBoardSlot(u8);
extern void sub_80965F4(void);
extern void sub_802C2D4(void);
extern u8 sub_8012FD8(u32 *);
@ -94,11 +95,11 @@ void sub_802ED4C(void)
switch(sub_802C1E4(1))
{
case 3:
gUnknown_203B308->unk8 = sub_802C26C();
gUnknown_203B308->jobIndex = sub_802C26C();
SetPelipperBoardState(6);
break;
case 4:
gUnknown_203B308->unk8 = sub_802C26C();
gUnknown_203B308->jobIndex = sub_802C26C();
SetPelipperBoardState(7);
break;
case 2:
@ -113,7 +114,7 @@ void sub_802ED4C(void)
void sub_802EDBC(void)
{
u8 *return_var;
struct WonderMail *mail;
s32 menuAction = 0;
sub_802C1E4(0);
@ -126,32 +127,32 @@ void sub_802EDBC(void)
{
case 4:
PlaySound(0x133);
return_var = sub_8096574(gUnknown_203B308->unk8);
switch(*return_var)
mail = GetPelliperBoardSlotInfo(gUnknown_203B308->jobIndex);
switch(mail->mailType)
{
case 2:
gUnknown_203B308->unk4 = 1;
sub_80965B8(gUnknown_203B308->unk8);
ResetPelliperBoardSlot(gUnknown_203B308->jobIndex);
sub_80965F4();
sub_802C2D4();
SetPelipperBoardState(3);
break;
case 3:
gUnknown_203B308->unk4 = 2;
sub_80965B8(gUnknown_203B308->unk8);
ResetPelliperBoardSlot(gUnknown_203B308->jobIndex);
sub_80965F4();
sub_802C2D4();
SetPelipperBoardState(3);
break;
case 4:
gUnknown_203B308->unk4 = 3;
sub_80965B8(gUnknown_203B308->unk8);
ResetPelliperBoardSlot(gUnknown_203B308->jobIndex);
sub_80965F4();
sub_802C2D4();
SetPelipperBoardState(3);
break;
default:
sub_8096A78(return_var);
sub_8096A78(mail);
sub_8096C80();
sub_8096D24();
if(sub_802C4A4())

View File

@ -599,11 +599,11 @@ void DisplayMissionObjectives(void)
s32 jobSlotIdx;
struct unkStruct_203B480 *mail;
struct WonderMail *jobInfo;
u8 auStack248 [100];
u8 buffer [100];
volatile u8 local_94;
u8 auStack144 [100];
short auStack44;
short local_2a;
u8 buffer1 [100];
s16 auStack44;
s16 missionIndex;
u8 local_test;
sub_80073B8(gUnknown_203B330->unk10);
@ -616,11 +616,11 @@ void DisplayMissionObjectives(void)
mail = sub_8095228(local_94);
sub_803B6B0(10,16,3,gUnknown_203B330->unk10);
// %dF
sprintf_2(auStack248,gUnknown_80E1F3C,mail->dungeon.dungeonFloor);
xxx_call_draw_string(0x15,16,auStack248,gUnknown_203B330->unk10,0);
sprintf_2(buffer,gUnknown_80E1F3C,mail->dungeon.dungeonFloor);
xxx_call_draw_string(0x15,16,buffer,gUnknown_203B330->unk10,0);
// Rescue #C6%s#R
sprintf_2(auStack248,gUnknown_80E1F40,GetMonSpecies(mail->clientSpecies));
xxx_call_draw_string(0x28,16,auStack248,gUnknown_203B330->unk10,0);
sprintf_2(buffer,gUnknown_80E1F40,GetMonSpecies(mail->clientSpecies));
xxx_call_draw_string(0x28,16,buffer,gUnknown_203B330->unk10,0);
break;
case 2:
if (CountJobsinDungeon(gUnknown_203B330->dungeonIndex) == 0) {
@ -639,32 +639,32 @@ void DisplayMissionObjectives(void)
) && (jobInfo->mailType != 5)) && (jobInfo->mailType != 7)) {
sub_803B6B0(10,yCoord,3,gUnknown_203B330->unk10);
if (jobInfo->missionType != WONDER_MAIL_MISSION_TYPE_FIND_ITEM) {
sprintf_2(auStack144,gUnknown_80E1F3C,jobInfo->dungeon.dungeonFloor);
xxx_call_draw_string(21,yCoord,auStack144,gUnknown_203B330->unk10,0);
sprintf_2(buffer1,gUnknown_80E1F3C,jobInfo->dungeon.dungeonFloor);
xxx_call_draw_string(21,yCoord,buffer1,gUnknown_203B330->unk10,0);
}
switch(jobInfo->missionType)
{
case WONDER_MAIL_MISSION_TYPE_DELIVER_ITEM:
// Bring #C4%s#R
sub_8090DC4(gUnknown_202DE58,jobInfo->targetItem,0);
sprintf_2(auStack144,gUnknown_80E1F60,gUnknown_202DE58);
xxx_call_draw_string(40,yCoord,auStack144,gUnknown_203B330->unk10,0);
sprintf_2(buffer1,gUnknown_80E1F60,gUnknown_202DE58);
xxx_call_draw_string(40,yCoord,buffer1,gUnknown_203B330->unk10,0);
break;
case WONDER_MAIL_MISSION_TYPE_FIND_ITEM:
// Find #C4%s#R
sub_8090DC4(gUnknown_202DE58,jobInfo->targetItem,0);
sprintf_2(auStack144,gUnknown_80E1F70,gUnknown_202DE58);
xxx_call_draw_string(40,yCoord,auStack144,gUnknown_203B330->unk10,0);
sprintf_2(buffer1,gUnknown_80E1F70,gUnknown_202DE58);
xxx_call_draw_string(40,yCoord,buffer1,gUnknown_203B330->unk10,0);
break;
case WONDER_MAIL_MISSION_TYPE_ESCORT_CLIENT:
// Escort to #C6$s#R
sprintf_2(auStack144,gUnknown_80E1F80,GetMonSpecies(jobInfo->targetSpecies));
xxx_call_draw_string(40,yCoord,auStack144,gUnknown_203B330->unk10,0);
sprintf_2(buffer1,gUnknown_80E1F80,GetMonSpecies(jobInfo->targetSpecies));
xxx_call_draw_string(40,yCoord,buffer1,gUnknown_203B330->unk10,0);
break;
default:
// Rescue #C6%s#R
sprintf_2(auStack144,gUnknown_80E1F40,GetMonSpecies(jobInfo->targetSpecies));
xxx_call_draw_string(40,yCoord,auStack144,gUnknown_203B330->unk10,0);
sprintf_2(buffer1,gUnknown_80E1F40,GetMonSpecies(jobInfo->targetSpecies));
xxx_call_draw_string(40,yCoord,buffer1,gUnknown_203B330->unk10,0);
break;
}
yCoord = yCoord + 12;
@ -675,8 +675,8 @@ void DisplayMissionObjectives(void)
case 3:
case 0:
default:
if (sub_80992E0(&auStack44,&local_2a) != 0)
xxx_call_draw_string(10,16,GetCurrentMissionText(local_2a),gUnknown_203B330->unk10,0);
if (sub_80992E0(&auStack44,&missionIndex) != 0)
xxx_call_draw_string(10,16,GetCurrentMissionText(missionIndex),gUnknown_203B330->unk10,0);
else if (sub_8099360(&local_test) != 0)
xxx_call_draw_string(10,16,sub_80975DC(sub_80A2688(local_test)),gUnknown_203B330->unk10,0);
else

View File

@ -172,7 +172,7 @@ extern void sub_800135C(void);
extern u8 *sub_80950F8(void);
extern void sub_80958E4(u32 *a, u32 b);
extern u32 sub_80958F8(void);
extern void sub_8095900(void);
extern void InitializeMailJobsNews(void);
extern void sub_80972F4(void);
extern u32 sub_8097680(void);
extern u32 *GetDungeonLocationInfo(void);
@ -600,7 +600,7 @@ void InitializePlayerData(void)
InitializeRescueTeamInfo();
sub_80972F4();
sub_8095118();
sub_8095900();
InitializeMailJobsNews();
sub_80974E8();
InitializeGameOptions(TRUE);
InitializeExclusivePokemon();

View File

@ -170,7 +170,7 @@ extern void PlayMenuSoundEffect(u32);
extern void sub_8013660(void *);
extern void sub_8013848(u32 *, s32, u32, u32);
extern void sub_8012D34(struct UnkTextStruct2 *, u32);
extern bool8 sub_809658C(u8);
extern bool8 IsPelliperBoardSlotEmpty(u8);
extern void sub_802C910(u32);
extern void sub_802CC00(void);
extern void sub_802CC70(void);
@ -192,7 +192,7 @@ s32 sub_802C474(void)
s32 counter = 0;
for(index = 0; index < MAX_ACCEPTED_JOBS; index++)
{
if(!sub_809658C(index))
if(!IsPelliperBoardSlotEmpty(index))
{
gUnknown_203B2E0->unk0[counter] = index;
counter++;
@ -206,7 +206,7 @@ bool8 sub_802C4A4(void)
s32 index;
for(index = 0; index < MAX_ACCEPTED_JOBS; index++)
{
if(!sub_809658C(index))
if(!IsPelliperBoardSlotEmpty(index))
return FALSE;
}
return TRUE;

View File

@ -5,6 +5,7 @@
#include "memory.h"
#include "text.h"
#include "pokemon_mail.h"
#include "wonder_mail.h"
bool8 IsMailSlotEmpty(u8);
extern void sub_8013984(void *);
@ -24,10 +25,10 @@ extern void sub_80073B8(u32);
extern void sub_80073E0(u32);
extern s32 sub_8013800(u32 *, s32);
extern u8 *sub_8096574(u32);
extern void sub_803B35C(u8 *, u32 *);
extern struct WonderMail *GetPelliperBoardSlotInfo(u32);
extern void sub_803B35C(struct WonderMail *, u32 *);
extern u8 gBulletinBoardText[];
extern u8 sub_80968B0(u8 *);
extern u8 sub_80968B0(struct WonderMail *);
extern void CreateRescueTitle(void *);
extern void xxx_call_draw_string(s32, s32, u8 *, s32, s32);
extern void sub_8012BC4(s32, s32, s32, s32 ,s32 ,s32);
@ -97,9 +98,7 @@ extern struct UnkTextStruct2 gUnknown_80DFC9C;
extern u16 gUnknown_203B2E4;
extern u8 *sub_8095FE8(u8);
extern u8 sub_80968B0(u8 *);
extern void sub_803B35C(u8 *, u32 *);
extern struct WonderMail *GetMailboxSlotInfo(u8);
extern void CreateRescueTitle(void *);
extern struct PokemonStruct *GetPlayerPokemonStruct(void);
extern u8 gMailboxText[];
@ -109,7 +108,7 @@ extern void sub_803B6B0(u32, u32, u32, u32);
void CreateMailMenu(void)
{
u8 *pcVar2;
struct WonderMail *mail;
s32 y;
s32 iVar5;
struct unkStruct_802C39C local;
@ -121,19 +120,19 @@ void CreateMailMenu(void)
iVar5 = 0;
if (iVar5 < gUnknown_203B2D8->unk1E) {
do {
pcVar2 = sub_8095FE8(gUnknown_203B2D8->unk0[(gUnknown_203B2D8->unk22 * gUnknown_203B2D8->unk20) + iVar5]);
mail = GetMailboxSlotInfo(gUnknown_203B2D8->unk0[(gUnknown_203B2D8->unk22 * gUnknown_203B2D8->unk20) + iVar5]);
local.unk0[0] = gUnknown_203B2D8->unk38;
local.unk4C = sub_8013800(&gUnknown_203B2D8->unk4, iVar5);
if (*pcVar2 == 1) {
if (mail->mailType == 1) {
y = sub_8013800(&gUnknown_203B2D8->unk4, iVar5);
sub_803B6B0(10,y,6,gUnknown_203B2D8->unk38);
PrintPokeNameToBuffer(gAvailablePokemonNames, GetPlayerPokemonStruct());
sprintf_2(buffer, GetPokemonMailHeadline(pcVar2[5]), gAvailablePokemonNames);
sprintf_2(buffer, GetPokemonMailHeadline(mail->dungeon.dungeonFloor), gAvailablePokemonNames);
xxx_call_draw_string(0x15,y,buffer,gUnknown_203B2D8->unk38,0);
}
else {
sub_803B35C(pcVar2,local.unk0);
if (sub_80968B0(pcVar2) != 0) {
sub_803B35C(mail,local.unk0);
if (sub_80968B0(mail) != 0) {
local.unk3C[11] = 2;
}
CreateRescueTitle(&local);
@ -328,7 +327,7 @@ void sub_802C328(void)
void sub_802C39C(void)
{
u32 uVar1;
u8 *uVar3;
struct WonderMail *mail;
s32 iVar4;
s32 x;
s32 iVar6;
@ -349,11 +348,11 @@ void sub_802C39C(void)
do
{
uVar1 = (gUnknown_203B2E0->unk0[gUnknown_203B2E0->unk26 * gUnknown_203B2E0->unk24 + iVar6]);
uVar3 = sub_8096574(uVar1);
mail = GetPelliperBoardSlotInfo(uVar1);
local.unk0[0] = gUnknown_203B2E0->unk3C;
local.unk4C = sub_8013800(&gUnknown_203B2E0->unk8,iVar6);
sub_803B35C(uVar3,local.unk0);
if (sub_80968B0(sub_8096574(uVar1)) != '\0') {
sub_803B35C(mail,local.unk0);
if (sub_80968B0(GetPelliperBoardSlotInfo(uVar1)) != '\0') {
local.unk3C[11] = 2;
}
CreateRescueTitle(&local);

View File

@ -122,8 +122,8 @@ extern void sub_802D1B8();
extern void sub_802D2A8();
extern u8 sub_80968B0(void *);
extern u8 sub_8096F50(void *);
extern u8 sub_80968B0(struct WonderMail *);
extern u8 sub_8096F50(struct WonderMail *);
extern u8 sub_802DAA8(void);
extern u8 sub_802DADC(void);
extern u8 *sub_8096DD8(void);
@ -197,10 +197,10 @@ u32 sub_802D098(struct unkSubStruct_203B2F8 *param_1)
gUnknown_203B2F8->unk70 = 0;
gUnknown_203B2F8->unk74 = 0;
gUnknown_203B2F8->unkC = param_1;
gUnknown_203B2F8->unk8 = 0;
gUnknown_203B2F8->unk9 = sub_8099328(&gUnknown_203B2F8->unkA);
gUnknown_203B2F8->wonderMailAccepted = FALSE;
gUnknown_203B2F8->unk9 = sub_8099328(&gUnknown_203B2F8->dungeonIndex);
if (sub_8011C1C() != 2) {
gUnknown_203B2F8->unk9 = 0;
gUnknown_203B2F8->unk9 = FALSE;
}
sub_802D1A0(0);
return 1;
@ -240,9 +240,9 @@ u32 sub_802D0E0(void)
return 0;
}
u8 sub_802D178(void)
bool8 GetWonderMailAccepted(void)
{
return gUnknown_203B2F8->unk8;
return gUnknown_203B2F8->wonderMailAccepted;
}
void sub_802D184(void)
@ -297,13 +297,13 @@ void sub_802D2A8(void)
switch(gUnknown_203B2F8->state) {
case 0:
if (sub_80968B0(gUnknown_203B2F8->unkC) != 0) {
if (sub_80968B0(&gUnknown_203B2F8->unkC->wonderMail) != 0) {
sub_802D1A0(3);
}
else if (sub_8096F50(gUnknown_203B2F8->unkC) != 0) {
else if (sub_8096F50(&gUnknown_203B2F8->unkC->wonderMail) != 0) {
sub_802D1A0(4);
}
else if ((gUnknown_203B2F8->unkC->wonderMail.unk2 == 4) && (sub_8096C08(&gUnknown_203B2F8->unk10) != 0)) {
else if ((gUnknown_203B2F8->unkC->wonderMail.unk2 == 4) && (sub_8096C08(&gUnknown_203B2F8->jobSlotIndex) != 0)) {
if (sub_802DAA8() != 0) {
sub_802D1A0(9);
}
@ -347,7 +347,7 @@ void sub_802D2A8(void)
sub_80141B4(gUnknown_80E0010,0,0,0x101);
break;
case 8:
gUnknown_203B2F8->unk8 = 1;
gUnknown_203B2F8->wonderMailAccepted = TRUE;
sub_8096A78(gUnknown_203B2F8->unkC);
sub_8096C80();
sub_8096D24();
@ -399,7 +399,7 @@ void sub_802D2A8(void)
sub_8012D60(gUnknown_203B2F8->unkC8,gUnknown_203B2F8->unk158,0,0,4,3);
break;
case 0xf:
sub_803B35C(GetJobSlotInfo(gUnknown_203B2F8->unk10),&gUnknown_203B2F8->unk14);
sub_803B35C(GetJobSlotInfo(gUnknown_203B2F8->jobSlotIndex),&gUnknown_203B2F8->unk14);
gUnknown_203B2F8->unk14 = 3;
sub_802DE84(&gUnknown_203B2F8->unk14);
break;

View File

@ -12,7 +12,7 @@
struct unkStruct_803B344
{
// size: 0xB4
struct WonderMail unk0;
struct WonderMail mail;
u8* unk14;
u8* unk18;
u8 fill1C[0x3C - 0x1C];
@ -119,7 +119,7 @@ extern u32 sub_801B6AC(void);
extern void sub_802F108(void);
extern s32 sub_80144A4(s32 *);
extern void sub_8012CAC(struct UnkTextStruct2 *, struct MenuItem *);
extern void sub_803B35C(void *, u32 *);
extern void sub_803B35C(struct WonderMail*, u32 *);
extern void sub_802DE84(u32 *);
extern void sub_8012D60(u32 *, struct MenuItem *, u32, u16 *, u32, u32);
extern void sub_802CDD4(u32);
@ -364,7 +364,7 @@ void sub_802F088(void)
break;
case 3:
temp = sub_803B344(gUnknown_203B30C->unk4);
sub_803B35C(temp, &gUnknown_203B30C->unk8);
sub_803B35C(&temp->mail, &gUnknown_203B30C->unk8);
gUnknown_203B30C->unk8 = 3;
gUnknown_203B30C->unk4C = 0;
gUnknown_203B30C->unk58 = temp->unk18;

View File

@ -20,7 +20,7 @@ struct unkStruct_203B2FC
s16 unkE;
u8 unk10;
u8 fill11[0x30 - 0x11];
u8 jobSlot;
u8 jobSlotIndex;
struct WonderMail *jobInfo;
struct OpenedFile *faceFile;
u8 *faceData;
@ -128,7 +128,7 @@ extern void sub_8013114(u8 *r0, s32 *r1);
extern u32 sub_802C598(s32);
extern void sub_802C688(void);
extern void sub_8096C80(void);
extern void sub_8096C3C(u8);
extern void ResetJobSlot(u8);
extern u8 sub_802C620(void);
void sub_802DE44(void);
@ -176,7 +176,7 @@ void sub_802D82C(void)
}
switch(menuAction) {
case 3:
sub_8096C3C(gUnknown_203B2F8->unk10);
ResetJobSlot(gUnknown_203B2F8->jobSlotIndex);
sub_8096C80();
sub_802D1A0(8);
break;
@ -205,11 +205,11 @@ void sub_802D8CC(void)
case 1:
break;
case 3:
gUnknown_203B2F8->unk10 = sub_802C620();
gUnknown_203B2F8->jobSlotIndex = sub_802C620();
sub_802D1A0(0xd);
break;
case 4:
gUnknown_203B2F8->unk10 = sub_802C620();
gUnknown_203B2F8->jobSlotIndex = sub_802C620();
gUnknown_203B2F8->fallbackState = 0xc;
sub_802D1A0(0xf);
break;
@ -234,7 +234,7 @@ void sub_802D940(void)
switch(menuAction)
{
case 2:
if ((gUnknown_203B2F8->unk9 != 0) && (((mail = &gUnknown_203B490->unkF0[gUnknown_203B2F8->unk10]), mail->mailType > 5) && (gUnknown_203B2F8->unkA == mail->dungeon.dungeonIndex)))
if ((gUnknown_203B2F8->unk9) && (((mail = &gUnknown_203B490->jobSlots[gUnknown_203B2F8->jobSlotIndex]), mail->mailType > 5) && (gUnknown_203B2F8->dungeonIndex == mail->dungeon.dungeonIndex)))
{
sub_802D1A0(0x7);
}
@ -271,7 +271,7 @@ void sub_802D9F0(void)
break;
case 3:
sub_802C688();
sub_8096C3C(gUnknown_203B2F8->unk10);
ResetJobSlot(gUnknown_203B2F8->jobSlotIndex);
sub_8096C80();
sub_802D1A0(8);
break;
@ -306,12 +306,12 @@ bool8 sub_802DAA8(void)
{
struct WonderMail *mail;
mail = GetJobSlotInfo(gUnknown_203B2F8->unk10);
if (gUnknown_203B2F8->unk9 == 0) {
mail = GetJobSlotInfo(gUnknown_203B2F8->jobSlotIndex);
if (!gUnknown_203B2F8->unk9) {
return TRUE;
}
else {
if ( (mail->mailType != WONDER_MAIL_TYPE_THANK_YOU) && (gUnknown_203B2F8->unkA == mail->dungeon.dungeonIndex)) return FALSE;
if ( (mail->mailType != WONDER_MAIL_TYPE_THANK_YOU) && (gUnknown_203B2F8->dungeonIndex == mail->dungeon.dungeonIndex)) return FALSE;
return TRUE;
}
}
@ -322,16 +322,16 @@ bool8 sub_802DADC(void)
struct WonderMail *mail;
s32 counter;
if (gUnknown_203B2F8->unk9 == 0) {
if (!gUnknown_203B2F8->unk9) {
_0802DAE8:
return TRUE;
}
else {
for( mail = &gUnknown_203B490->unkF0[0], counter = 0; counter < 8; mail++, counter++)
for( mail = &gUnknown_203B490->jobSlots[0], counter = 0; counter < 8; mail++, counter++)
{
mailType = mail->mailType;
if (((mailType == 0) || (mailType == WONDER_MAIL_TYPE_THANK_YOU)) ||
((WONDER_MAIL_TYPE_THANK_YOU < mailType && (gUnknown_203B2F8->unkA != mail->dungeon.dungeonIndex)))) goto _0802DAE8;
((WONDER_MAIL_TYPE_THANK_YOU < mailType && (gUnknown_203B2F8->dungeonIndex != mail->dungeon.dungeonIndex)))) goto _0802DAE8;
}
return FALSE;
}
@ -339,11 +339,11 @@ _0802DAE8:
// TODO: merge above with wonder_mail_3.c
bool8 sub_802DB28(u8 jobSlot, u8 param_2)
bool8 sub_802DB28(u8 jobSlotIndex, u8 dungeon)
{
char local_18 [8];
sub_8096AF8(local_18,jobSlot,param_2);
sub_8096AF8(local_18,jobSlotIndex,dungeon);
if (local_18[0] == '\0') {
return FALSE;
}
@ -351,8 +351,8 @@ bool8 sub_802DB28(u8 jobSlot, u8 param_2)
ResetUnusedInputStruct();
sub_800641C(0,1,1);
gUnknown_203B2FC = MemoryAlloc(sizeof(struct unkStruct_203B2FC),8);
gUnknown_203B2FC->jobSlot = jobSlot;
gUnknown_203B2FC->jobInfo = GetJobSlotInfo(jobSlot);
gUnknown_203B2FC->jobSlotIndex = jobSlotIndex;
gUnknown_203B2FC->jobInfo = GetJobSlotInfo(jobSlotIndex);
sub_8096EEC();
sub_803C21C(gUnknown_203B2FC->jobInfo,&gUnknown_203B2FC->unk8);
gUnknown_203B2FC->faceFile = GetDialogueSpriteDataPtr(gUnknown_203B2FC->jobInfo->clientSpecies);
@ -408,15 +408,15 @@ void sub_802DC28(u32 newState)
void sub_802DC40(void)
{
s32 iVar3;
s32 index;
sub_8006518(gUnknown_203B2FC->unk48);
switch(gUnknown_203B2FC->state)
{
case 0:
case 7:
for(iVar3 = 0; iVar3 < 4; iVar3++)
for(index = 0; index < 4; index++)
{
gUnknown_203B2FC->unk48[iVar3] = gUnknown_80E016C;
gUnknown_203B2FC->unk48[index] = gUnknown_80E016C;
}
break;
}

View File

@ -80,7 +80,7 @@ ALIGNED(4) const char wonder_mail_main_fill2[] = "pksdir0";
struct unkStruct_803B344
{
// size: 0xB4
struct WonderMail unk0;
struct WonderMail mail;
u8* unk14;
u8* unk18;
u8 fill1C[0x3C - 0x1C];
@ -149,7 +149,7 @@ extern struct unkStruct_803B344 *sub_803B344(u8);
extern s32 sub_8037B28(u32);
extern u32 sub_802D0E0();
extern u8 sub_802D178();
extern bool8 GetWonderMailAccepted();
extern void sub_802D184();
extern s32 sub_80154F0();
@ -429,7 +429,7 @@ void HandlePasswordEntryScreen(void)
else {
// Successful password
// Copy the decoded data to another buffer?
gUnknown_203B3E8->unk3C0.unk0 = gUnknown_203B3E8->UNK38.decodedMail;
gUnknown_203B3E8->unk3C0.mail = gUnknown_203B3E8->UNK38.decodedMail;
gUnknown_203B3E8->wonderMailAccepted = TRUE;
SetWonderMailMainMenuState(PASSWORD_SUCCESS);
@ -456,7 +456,7 @@ void AdvanceToPasswordEntryScreen(void)
void HandlePasswordSuccess(void)
{
if (sub_802D0E0() == 3) {
gUnknown_203B3E8->wonderMailAccepted = sub_802D178();
gUnknown_203B3E8->wonderMailAccepted = GetWonderMailAccepted();
sub_802D184();
if (gUnknown_203B3E8->wonderMailAccepted) {
SetWonderMailMainMenuState(PREPARE_SAVE);
@ -552,7 +552,7 @@ void WonderMailMainMenuCallback(void)
sub_8014248(gUnknown_80E7B14,0,3,gReceiveWonderMailMainMenuItems,0,4,0,0,0x101);
break;
case PASSWORD_SUCCESS:
gUnknown_203B3E8->unk474 = gUnknown_203B3E8->unk3C0.unk0;
gUnknown_203B3E8->unk474 = gUnknown_203B3E8->unk3C0.mail;
if(gUnknown_203B3E8->unk474.unk2 == 4)
{
gUnknown_203B3E8->unk488 = &gUnknown_203B3E8->unk3C0.unk14;
@ -615,7 +615,7 @@ void WonderMailMainMenuCallback(void)
MemoryCopy8((u8 *)&gUnknown_203B3E8->unk254.unk14,temp->unk14,0x28);
MemoryCopy8((u8 *)&gUnknown_203B3E8->unk254.unk3C,temp->unk18,0x78);
}
gUnknown_203B3E8->unk254.unk0 = temp->unk0;
gUnknown_203B3E8->unk254.mail = temp->mail;
gUnknown_203B3E8->wonderMailStatus = sub_8037D64(gUnknown_203B3E8->unk24C,&gUnknown_203B3E8->unk254,&gUnknown_203B3E8->unk308);
break;
case 10: