diff --git a/asm/include/scrcmd_9.inc b/asm/include/scrcmd_9.inc deleted file mode 100644 index 1b8146204a..0000000000 --- a/asm/include/scrcmd_9.inc +++ /dev/null @@ -1,116 +0,0 @@ -#include -#pragma once -.public ReadWholeNarcMemberByIdPair -.public AllocAndReadWholeNarcMemberByIdPair -.public NewMsgDataFromNarc -.public DestroyMsgData -.public ReadMsgDataIntoString -.public NewString_ReadMsgData -.public GetSpeciesNameIntoArray -.public MessageFormat_New_Custom -.public BufferString -.public BufferIntegerAsString -.public AllocFromHeap -.public AllocFromHeapAtEnd -.public FreeToHeap -.public LCRandom -.public GF_AssertFail -.public String_New -.public String_Delete -.public CopyStringToU16Array -.public Save_PlayerData_GetProfileAddr -.public PlayerProfile_GetTrainerGender -.public Pokedex_CheckMonSeenFlag -.public Save_Pokedex_Get -.public Save_GameStats_Get -.public GameStats_Add -.public GameStats_GetCapped -.public GameStats_AddSpecial -.public sub_0202D234 -.public sub_0202D284 -.public sub_0202D308 -.public sub_0202D3B0 -.public sub_0202D3DC -.public sub_0202D3E4 -.public FrontierData_BattlePointAction -.public sub_0202D450 -.public sub_0202D488 -.public sub_0202D4B8 -.public sub_0202D4FC -.public sub_0202D57C -.public sub_0202D5C4 -.public sub_0202D5DC -.public sub_0202D7B0 -.public sub_0202D7B8 -.public sub_0202D8D0 -.public sub_0202D908 -.public Save_FrontierData_Get -.public sub_0202D928 -.public sub_0203107C -.public sub_020310BC -.public sub_02031108 -.public sub_0203126C -.public sub_02037030 -.public sub_0203769C -.public sub_02037C0C -.public LocalFieldData_GetDynamicWarp -.public Save_LocalFieldData_Get -.public FieldSystem_GetSaveData -.public SetupNativeScript -.public ScriptReadHalfword -.public FieldSysGetAttrAddr -.public GetVarPointer -.public FieldSystem_VarGet -.public sub_0204A5B0 -.public sub_0204A68C -.public sub_0204A824 -.public sub_0204AA2C -.public sub_0204ABC8 -.public sub_0204AC78 -.public sub_0204AC7C -.public sub_0204AD04 -.public sub_0204AE20 -.public sub_0204AF2C -.public sub_0204B05C -.public sub_0204B068 -.public sub_0204B4D4 -.public sub_0204B510 -.public sub_0204B538 -.public sub_0204B610 -.public sub_0204B66C -.public sub_0204B690 -.public Save_VarsFlags_Get -.public sub_0205C268 -.public sub_0205C298 -.public sub_0205C310 -.public GetPlayerXCoord -.public GetPlayerYCoord -.public SetFlag966 -.public ClearFlag966 -.public Save_VarsFlags_GetVar4052 -.public sub_02067118 -.public sub_02067200 -.public sub_020672A4 -.public sub_020672D8 -.public sub_02067398 -.public sub_020674A4 -.public sub_020674E0 -.public sub_0206751C -.public GetMonData -.public SetMonData -.public GetMonBaseStat -.public GetNatureFromPersonality -.public CalcShininessByOtIdAndPersonality -.public MaskOfFlagNo -.public IsPokemonBannedFromBattleFrontier -.public GetBannedBattleFrontierPokemon -.public Party_GetCount -.public Party_GetMonByIndex -.public SaveArray_Party_Get -.public sub_02096910 -.public OS_ResetSystem -.public MI_CpuFill8 -.public MI_CpuCopy8 -.public _s32_div_f -.public _u32_div_f -.public gGameLanguage diff --git a/asm/scrcmd_9.s b/asm/scrcmd_9.s deleted file mode 100644 index 1fb65ba302..0000000000 --- a/asm/scrcmd_9.s +++ /dev/null @@ -1,4293 +0,0 @@ - .include "asm/macros.inc" - .include "scrcmd_9.inc" - .include "global.inc" - - .rodata - -_020FBF70: - .short 0x008D - .short 0x0091 - .short 0x008E - .short 0x008F - .short 0x0090 - .short 0x0000 -_020FBF7C: - .byte 0x00, 0x08, 0x09, 0x0B - .byte 0x0C, 0x0E, 0x0F, 0x12 -_020FBF84: - .byte 0x00, 0x03, 0x03, 0x04, 0x04, 0x05, 0x05, 0x07 -_020FBF8C: - .byte 0x00, 0x05, 0x04, 0x04 - .byte 0x03, 0x03, 0x02, 0x02, 0x01, 0x01, 0x00, 0x00 -_020FBF98: - .byte 0x00, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09 - .byte 0x0A, 0x0A, 0x0A, 0x00 -_020FBFA4: - .byte 0xD5, 0x00, 0x9D, 0x00, 0xEA, 0x00, 0xD9, 0x00 -_020FBFAC: - .byte 0x00, 0x00 -_020FBFAE: - .byte 0x63, 0x00 - .byte 0x50, 0x00, 0x77, 0x00, 0x64, 0x00, 0x8B, 0x00, 0x78, 0x00, 0x9F, 0x00, 0x8C, 0x00, 0xB3, 0x00 - .byte 0xA0, 0x00, 0xC7, 0x00, 0xB4, 0x00, 0xDB, 0x00, 0xC8, 0x00, 0x2B, 0x01 -_020FBFCC: - .byte 0x64, 0x00 -_020FBFCE: - .byte 0x77, 0x00 - .byte 0x78, 0x00, 0x8B, 0x00, 0x8C, 0x00, 0x9F, 0x00, 0xA0, 0x00, 0xB3, 0x00, 0xB4, 0x00, 0xC7, 0x00 - .byte 0xC8, 0x00, 0xDB, 0x00, 0xDC, 0x00, 0xEF, 0x00, 0xC8, 0x00, 0x2B, 0x01 -_020FBFEC: - .byte 0x5A, 0x00 -_020FBFEE: - .byte 0x8D, 0x00 - .byte 0x5B, 0x00, 0x8E, 0x00, 0x5C, 0x00, 0x8F, 0x00, 0x5D, 0x00, 0x90, 0x00, 0x5E, 0x00, 0x91, 0x00 - .byte 0x02, 0x00, 0x04, 0x00, 0x03, 0x00, 0x06, 0x00, 0x3C, 0x00, 0x03, 0x00, 0x3D, 0x00, 0x08, 0x00 - .byte 0x20, 0x00, 0x3E, 0x00, 0x21, 0x00, 0x3F, 0x00, 0x04, 0x00, 0x34, 0x00, 0x05, 0x00, 0x35, 0x00 - .byte 0x2C, 0x00, 0x01, 0x00, 0x2D, 0x00, 0x02, 0x00, 0x14, 0x00, 0x0F, 0x00, 0x15, 0x00, 0x10, 0x00 - .byte 0x51, 0x00, 0x3B, 0x00, 0x1A, 0x00, 0x3C, 0x00, 0x10, 0x00, 0x09, 0x00, 0x11, 0x00, 0x0C, 0x00 - .byte 0x53, 0x00, 0x17, 0x00, 0x54, 0x00, 0x16, 0x00, 0x47, 0x00, 0x29, 0x00, 0x12, 0x00, 0x2A, 0x00 - .byte 0x0C, 0x00, 0x26, 0x00, 0x0D, 0x00, 0x27, 0x00, 0x0E, 0x00, 0x33, 0x00, 0x0A, 0x00, 0x07, 0x00 - .byte 0x1B, 0x00, 0x11, 0x00, 0x23, 0x00, 0x25, 0x00, 0x31, 0x00, 0x46, 0x00, 0x32, 0x00, 0x46, 0x00 - .byte 0x27, 0x00, 0x0B, 0x00, 0x28, 0x00, 0x0E, 0x00, 0x18, 0x00, 0x0B, 0x00, 0x19, 0x00, 0x0E, 0x00 - .byte 0x35, 0x00, 0x44, 0x00, 0x36, 0x00, 0x45, 0x00, 0x1D, 0x00, 0x0B, 0x00, 0x06, 0x00, 0x05, 0x00 - .byte 0x1C, 0x00, 0x01, 0x00, 0x13, 0x00, 0x2D, 0x00, 0x0B, 0x00, 0x36, 0x00, 0x2E, 0x00, 0x38, 0x00 - .byte 0x09, 0x00, 0x14, 0x00, 0x30, 0x00, 0x32, 0x00, 0x34, 0x00, 0x0A, 0x00, 0x25, 0x00, 0x13, 0x00 - .byte 0x39, 0x00, 0x1F, 0x00, 0x4E, 0x00, 0x1D, 0x00, 0x22, 0x00, 0x24, 0x00, 0x3B, 0x00, 0x28, 0x00 - .byte 0x3A, 0x00, 0x2B, 0x00, 0x26, 0x00, 0x22, 0x00, 0x33, 0x00, 0x3E, 0x00, 0x45, 0x00, 0x0E, 0x00 - .byte 0x50, 0x00, 0x37, 0x00, 0x24, 0x00, 0x0D, 0x00, 0x07, 0x00, 0x0C, 0x00, 0x55, 0x00, 0x23, 0x00 - .byte 0x0F, 0x00, 0x2C, 0x00, 0x16, 0x00, 0x47, 0x00 - - .text - - thumb_func_start ScrCmd_410 -ScrCmd_410: ; 0x02049CA8 - push {r4, r5, r6, lr} - add r5, r0, #0 - bl ScriptReadHalfword - add r4, r0, #0 - add r0, r5, #0 - bl ScriptReadHalfword - add r6, r0, #0 - add r0, r5, #0 - add r0, #0x80 - ldr r0, [r0] - bl FieldSystem_GetSaveData - add r1, r4, #0 - add r2, r6, #0 - bl sub_0204A824 - add r5, #0x80 - ldr r1, [r5] - add r1, #0xa0 - str r0, [r1] - mov r0, #0 - pop {r4, r5, r6, pc} - thumb_func_end ScrCmd_410 - - thumb_func_start ScrCmd_409 -ScrCmd_409: ; 0x02049CD8 - push {r3, lr} - add r0, #0x80 - ldr r0, [r0] - add r0, #0xa0 - bl sub_0204A810 - mov r0, #0 - pop {r3, pc} - thumb_func_end ScrCmd_409 - - thumb_func_start ScrCmd_411 -ScrCmd_411: ; 0x02049CE8 - push {r4, lr} - add r4, r0, #0 - add r0, #0x80 - ldr r0, [r0] - add r0, #0xa0 - ldr r0, [r0] - bl sub_0204AA2C - add r4, #0x80 - ldr r1, [r4] - mov r0, #0 - add r1, #0xa0 - str r0, [r1] - pop {r4, pc} - thumb_func_end ScrCmd_411 - - thumb_func_start ScrCmd_412 -ScrCmd_412: ; 0x02049D04 - push {r3, r4, r5, r6, r7, lr} - sub sp, #8 - add r7, r0, #0 - bl ScriptReadHalfword - str r0, [sp] - add r0, r7, #0 - bl ScriptReadHalfword - add r1, r0, #0 - add r0, r7, #0 - add r0, #0x80 - ldr r0, [r0] - bl FieldSystem_VarGet - add r6, r0, #0 - add r0, r7, #0 - bl ScriptReadHalfword - str r0, [sp, #4] - add r0, r7, #0 - add r0, #0x80 - ldr r0, [r0] - ldr r1, [sp, #4] - bl GetVarPointer - add r4, r0, #0 - add r0, r7, #0 - add r0, #0x80 - ldr r1, [r0] - add r0, r1, #0 - add r0, #0xa0 - ldr r5, [r0] - ldr r0, [sp] - cmp r0, #0x3a - bgt _02049DD2 - cmp r0, #0 - blt _02049DDA - add r0, r0, r0 - add r0, pc - ldrh r0, [r0, #6] - lsl r0, r0, #0x10 - asr r0, r0, #0x10 - add pc, r0 -_02049D5C: ; jump table - .short _02049FB6 - _02049D5C - 2 ; case 0 - .short _02049DDC - _02049D5C - 2 ; case 1 - .short _02049DFC - _02049D5C - 2 ; case 2 - .short _02049E02 - _02049D5C - 2 ; case 3 - .short _02049E0E - _02049D5C - 2 ; case 4 - .short _02049E1C - _02049D5C - 2 ; case 5 - .short _02049E24 - _02049D5C - 2 ; case 6 - .short _02049FB6 - _02049D5C - 2 ; case 7 - .short _02049E2C - _02049D5C - 2 ; case 8 - .short _02049E38 - _02049D5C - 2 ; case 9 - .short _02049E46 - _02049D5C - 2 ; case 10 - .short _02049E54 - _02049D5C - 2 ; case 11 - .short _02049E60 - _02049D5C - 2 ; case 12 - .short _02049FB6 - _02049D5C - 2 ; case 13 - .short _02049E6A - _02049D5C - 2 ; case 14 - .short _02049E74 - _02049D5C - 2 ; case 15 - .short _02049E7E - _02049D5C - 2 ; case 16 - .short _02049FB6 - _02049D5C - 2 ; case 17 - .short _02049FB6 - _02049D5C - 2 ; case 18 - .short _02049FB6 - _02049D5C - 2 ; case 19 - .short _02049FB6 - _02049D5C - 2 ; case 20 - .short _02049FB6 - _02049D5C - 2 ; case 21 - .short _02049FB6 - _02049D5C - 2 ; case 22 - .short _02049FB6 - _02049D5C - 2 ; case 23 - .short _02049FB6 - _02049D5C - 2 ; case 24 - .short _02049FB6 - _02049D5C - 2 ; case 25 - .short _02049FB6 - _02049D5C - 2 ; case 26 - .short _02049FB6 - _02049D5C - 2 ; case 27 - .short _02049FB6 - _02049D5C - 2 ; case 28 - .short _02049FB6 - _02049D5C - 2 ; case 29 - .short _02049E90 - _02049D5C - 2 ; case 30 - .short _02049EA8 - _02049D5C - 2 ; case 31 - .short _02049EC2 - _02049D5C - 2 ; case 32 - .short _02049FB6 - _02049D5C - 2 ; case 33 - .short _02049FB6 - _02049D5C - 2 ; case 34 - .short _02049ECE - _02049D5C - 2 ; case 35 - .short _02049FB6 - _02049D5C - 2 ; case 36 - .short _02049ED8 - _02049D5C - 2 ; case 37 - .short _02049EE2 - _02049D5C - 2 ; case 38 - .short _02049EEC - _02049D5C - 2 ; case 39 - .short _02049FB6 - _02049D5C - 2 ; case 40 - .short _02049EFC - _02049D5C - 2 ; case 41 - .short _02049FB6 - _02049D5C - 2 ; case 42 - .short _02049F08 - _02049D5C - 2 ; case 43 - .short _02049FB6 - _02049D5C - 2 ; case 44 - .short _02049F12 - _02049D5C - 2 ; case 45 - .short _02049FB6 - _02049D5C - 2 ; case 46 - .short _02049F1C - _02049D5C - 2 ; case 47 - .short _02049F26 - _02049D5C - 2 ; case 48 - .short _02049F32 - _02049D5C - 2 ; case 49 - .short _02049F3E - _02049D5C - 2 ; case 50 - .short _02049F52 - _02049D5C - 2 ; case 51 - .short _02049F5C - _02049D5C - 2 ; case 52 - .short _02049F66 - _02049D5C - 2 ; case 53 - .short _02049F70 - _02049D5C - 2 ; case 54 - .short _02049F7E - _02049D5C - 2 ; case 55 - .short _02049EF4 - _02049D5C - 2 ; case 56 - .short _02049F8C - _02049D5C - 2 ; case 57 - .short _02049FA8 - _02049D5C - 2 ; case 58 -_02049DD2: - ldr r0, [sp] - cmp r0, #0x64 - bne _02049DDA - b _02049F98 -_02049DDA: - b _02049FB6 -_02049DDC: - cmp r6, #0 - bne _02049DEE - ldrb r0, [r5, #0xe] - ldr r1, [r1, #0xc] - mov r2, #1 - bl sub_0204A5B0 - strh r0, [r4] - b _02049FBE -_02049DEE: - ldr r1, [r1, #0xc] - add r0, r6, #0 - mov r2, #1 - bl sub_0204A5B0 - strh r0, [r4] - b _02049FBE -_02049DFC: - bl sub_0204A68C - b _02049FBE -_02049E02: - ldr r0, [r1, #0xc] - bl sub_0202D908 - bl sub_0204A698 - b _02049FBE -_02049E0E: - ldr r0, [r1, #0xc] - bl sub_0202D908 - bl sub_0204A6A0 - strh r0, [r4] - b _02049FBE -_02049E1C: - add r0, r1, #0 - bl sub_0204A6A8 - b _02049FBE -_02049E24: - add r0, r1, #0 - bl sub_0204A6E8 - b _02049FBE -_02049E2C: - ldr r0, [r1, #0xc] - add r1, r6, #0 - bl sub_0204A6F8 - strh r0, [r4] - b _02049FBE -_02049E38: - ldr r1, [r1, #0xc] - mov r0, #0 - mov r2, #2 - bl sub_0204B120 - strh r0, [r4] - b _02049FBE -_02049E46: - mov r0, #0 - ldr r1, [r1, #0xc] - add r2, r0, #0 - bl sub_0204B120 - strh r0, [r4] - b _02049FBE -_02049E54: - ldr r0, [r1, #0xc] - lsl r1, r6, #0x18 - lsr r1, r1, #0x18 - bl sub_0204A730 - b _02049FBE -_02049E60: - ldr r0, [r1, #0xc] - bl sub_0204A750 - strh r0, [r4] - b _02049FBE -_02049E6A: - ldr r0, [r1, #0xc] - bl sub_0204A764 - strh r0, [r4] - b _02049FBE -_02049E74: - ldr r0, [r1, #0xc] - bl sub_0204A800 - strh r0, [r4] - b _02049FBE -_02049E7E: - ldrh r3, [r4] - ldr r0, [r7, #0x74] - ldr r2, [sp, #4] - add r1, r6, #0 - bl sub_02067200 - add sp, #8 - mov r0, #1 - pop {r3, r4, r5, r6, r7, pc} -_02049E90: - add r0, r1, #0 - mov r1, #0x14 - bl FieldSysGetAttrAddr - add r2, r0, #0 - ldr r1, [r7, #0x74] - add r0, r5, #0 - bl sub_0204AA58 - add sp, #8 - mov r0, #1 - pop {r3, r4, r5, r6, r7, pc} -_02049EA8: - add r0, r1, #0 - mov r1, #0x14 - bl FieldSysGetAttrAddr - add r7, #0x80 - ldr r2, [r7] - add r1, r0, #0 - ldr r2, [r2, #0xc] - add r0, r5, #0 - bl sub_0204AA78 - strh r0, [r4] - b _02049FBE -_02049EC2: - ldr r1, [r1, #0xc] - add r0, r5, #0 - bl sub_0204AB10 - strh r0, [r4] - b _02049FBE -_02049ECE: - add r0, r5, #0 - bl sub_0204AC7C - strh r0, [r4] - b _02049FBE -_02049ED8: - ldr r1, [r1, #0xc] - add r0, r5, #0 - bl sub_0204AD04 - b _02049FBE -_02049EE2: - ldr r1, [r1, #0xc] - add r0, r5, #0 - bl sub_0204AE20 - b _02049FBE -_02049EEC: - add r0, r5, #0 - bl sub_0204AF2C - b _02049FBE -_02049EF4: - add r0, r5, #0 - bl sub_0204AFE0 - b _02049FBE -_02049EFC: - add r0, r5, #0 - add r1, r6, #0 - bl sub_0204B044 - strh r0, [r4] - b _02049FBE -_02049F08: - add r0, r5, #0 - bl sub_0204B05C - strh r0, [r4] - b _02049FBE -_02049F12: - add r0, r5, #0 - bl sub_0204B060 - strh r0, [r4] - b _02049FBE -_02049F1C: - ldr r1, [r1, #0xc] - add r0, r5, #0 - bl sub_0204B0E0 - b _02049FBE -_02049F26: - ldr r1, [r1, #0xc] - add r0, r5, #0 - bl sub_0204B1CC - strh r0, [r4] - b _02049FBE -_02049F32: - ldr r1, [r1, #0xc] - add r0, r5, #0 - bl sub_0204B204 - strh r0, [r4] - b _02049FBE -_02049F3E: - ldrb r1, [r5, #0x10] - mov r0, #0xe0 - bic r1, r0 - lsl r0, r6, #0x18 - lsr r0, r0, #0x18 - lsl r0, r0, #0x1d - lsr r0, r0, #0x18 - orr r0, r1 - strb r0, [r5, #0x10] - b _02049FBE -_02049F52: - ldrb r0, [r5, #0x10] - lsl r0, r0, #0x18 - lsr r0, r0, #0x1d - strh r0, [r4] - b _02049FBE -_02049F5C: - ldr r1, [r1, #0xc] - add r0, r5, #0 - bl sub_0204ABC8 - b _02049FBE -_02049F66: - add r0, r5, r6 - add r0, #0x2a - ldrb r0, [r0] - strh r0, [r4] - b _02049FBE -_02049F70: - ldr r1, [r1, #0xc] - add r0, r5, #0 - mov r2, #1 - bl sub_0204B120 - strh r0, [r4] - b _02049FBE -_02049F7E: - lsl r1, r6, #0x18 - add r0, r5, #0 - lsr r1, r1, #0x18 - bl sub_0204A2A8 - strh r0, [r4] - b _02049FBE -_02049F8C: - ldr r1, [r1, #0xc] - add r0, r5, #0 - bl sub_0204B258 - strh r0, [r4] - b _02049FBE -_02049F98: - cmp r5, #0 - bne _02049FA2 - mov r0, #1 - strh r0, [r4] - b _02049FBE -_02049FA2: - mov r0, #0 - strh r0, [r4] - b _02049FBE -_02049FA8: - ldr r0, _02049FC4 ; =0x00000884 - mov r1, #0 - add r0, r5, r0 - mov r2, #0x46 - bl MI_CpuFill8 - b _02049FBE -_02049FB6: - bl GF_AssertFail - mov r0, #0 - strh r0, [r4] -_02049FBE: - mov r0, #0 - add sp, #8 - pop {r3, r4, r5, r6, r7, pc} - .balign 4, 0 -_02049FC4: .word 0x00000884 - thumb_func_end ScrCmd_412 - - thumb_func_start ScrCmd_413 -ScrCmd_413: ; 0x02049FC8 - push {r3, r4, r5, r6, r7, lr} - add r5, r0, #0 - add r1, r5, #0 - add r1, #0x80 - ldr r1, [r1] - add r1, #0xa0 - ldr r4, [r1] - bl ScriptReadHalfword - add r1, r0, #0 - add r0, r5, #0 - add r0, #0x80 - ldr r0, [r0] - bl FieldSystem_VarGet - add r6, r0, #0 - add r0, r5, #0 - bl ScriptReadHalfword - add r1, r0, #0 - add r0, r5, #0 - add r0, #0x80 - ldr r0, [r0] - bl FieldSystem_VarGet - add r7, r0, #0 - add r0, r5, #0 - bl ScriptReadHalfword - add r1, r0, #0 - add r0, r5, #0 - add r0, #0x80 - ldr r0, [r0] - bl GetVarPointer - str r0, [sp] - add r0, r5, #0 - bl ScriptReadHalfword - add r5, #0x80 - add r1, r0, #0 - ldr r0, [r5] - bl GetVarPointer - lsl r2, r6, #4 - add r2, r6, r2 - mov r1, #0x38 - lsl r2, r2, #4 - mul r1, r7 - add r2, r4, r2 - add r3, r2, r1 - mov r2, #0xb2 - lsl r2, r2, #2 - ldrh r1, [r3, r2] - lsl r1, r1, #0x15 - lsr r4, r1, #0x15 - ldr r1, [sp] - strh r4, [r1] - add r1, r2, #4 - ldrh r1, [r3, r1] - strh r1, [r0] - mov r0, #0 - pop {r3, r4, r5, r6, r7, pc} - .balign 4, 0 - thumb_func_end ScrCmd_413 - - thumb_func_start ScrCmd_414 -ScrCmd_414: ; 0x0204A048 - push {r3, r4, r5, lr} - add r5, r0, #0 - bl ScriptReadHalfword - add r1, r0, #0 - add r0, r5, #0 - add r0, #0x80 - ldr r0, [r0] - bl GetVarPointer - add r5, #0x80 - add r4, r0, #0 - ldr r0, [r5] - ldr r0, [r0, #0xc] - bl sub_020672D8 - strh r0, [r4] - mov r0, #0 - pop {r3, r4, r5, pc} - .balign 4, 0 - thumb_func_end ScrCmd_414 - - thumb_func_start ScrCmd_415 -ScrCmd_415: ; 0x0204A070 - push {r3, r4, r5, lr} - add r5, r0, #0 - bl ScriptReadHalfword - add r1, r0, #0 - add r0, r5, #0 - add r0, #0x80 - ldr r0, [r0] - bl GetVarPointer - add r5, #0x80 - add r4, r0, #0 - ldr r0, [r5] - ldr r0, [r0, #0xc] - bl sub_02067398 - strh r0, [r4] - mov r0, #0 - pop {r3, r4, r5, pc} - .balign 4, 0 - thumb_func_end ScrCmd_415 - - thumb_func_start ScrCmd_416 -ScrCmd_416: ; 0x0204A098 - push {r3, r4, r5, r6, r7, lr} - sub sp, #8 - add r5, r0, #0 - bl ScriptReadHalfword - add r1, r0, #0 - add r0, r5, #0 - add r0, #0x80 - ldr r0, [r0] - bl FieldSystem_VarGet - add r7, r0, #0 - add r0, r5, #0 - bl ScriptReadHalfword - add r1, r0, #0 - add r0, r5, #0 - add r0, #0x80 - ldr r0, [r0] - bl FieldSystem_VarGet - str r0, [sp, #4] - add r0, r5, #0 - bl ScriptReadHalfword - add r1, r0, #0 - add r0, r5, #0 - add r0, #0x80 - ldr r0, [r0] - bl GetVarPointer - add r4, r0, #0 - add r0, r5, #0 - add r0, #0x80 - ldr r0, [r0] - add r0, #0xa0 - ldr r6, [r0] - mov r0, #0 - strh r0, [r4] - cmp r7, #0 - beq _0204A0F4 - cmp r7, #1 - beq _0204A10C - cmp r7, #2 - beq _0204A120 - b _0204A134 -_0204A0F4: - mov r0, #0x3e - str r0, [sp] - add r0, r5, #0 - add r0, #0x80 - ldr r1, [r0] - add r0, r1, #0 - add r0, #0xa0 - ldr r0, [r0] - ldr r1, [r1, #0xc] - bl sub_0204B6AC - b _0204A134 -_0204A10C: - mov r0, #0x3f - str r0, [sp] - add r0, r5, #0 - add r0, #0x80 - ldr r0, [r0] - add r0, #0xa0 - ldr r0, [r0] - bl sub_0204B708 - b _0204A134 -_0204A120: - mov r0, #0x40 - str r0, [sp] - add r0, r5, #0 - add r0, #0x80 - ldr r0, [r0] - ldr r1, [sp, #4] - add r0, #0xa0 - ldr r0, [r0] - bl sub_0204B720 -_0204A134: - add r5, #0x80 - ldr r0, [r5] - ldr r0, [r0, #0xc] - bl sub_0205C298 - cmp r0, #1 - bne _0204A15E - bl sub_0203769C - ldr r1, _0204A180 ; =0x0000083E - add r1, r6, r1 - bl sub_02037C0C - cmp r0, #1 - bne _0204A158 - mov r0, #1 - strh r0, [r4] - b _0204A178 -_0204A158: - add sp, #8 - mov r0, #1 - pop {r3, r4, r5, r6, r7, pc} -_0204A15E: - add r0, r6, #0 - bl sub_02096910 - ldr r1, _0204A180 ; =0x0000083E - ldr r0, [sp] - add r1, r6, r1 - mov r2, #0x46 - bl sub_02037030 - cmp r0, #1 - bne _0204A178 - mov r0, #1 - strh r0, [r4] -_0204A178: - mov r0, #0 - add sp, #8 - pop {r3, r4, r5, r6, r7, pc} - nop -_0204A180: .word 0x0000083E - thumb_func_end ScrCmd_416 - - thumb_func_start ScrCmd_417 -ScrCmd_417: ; 0x0204A184 - push {r3, r4, r5, r6, r7, lr} - add r5, r0, #0 - add r1, r5, #0 - add r1, #0x80 - ldr r1, [r1] - add r1, #0xa0 - ldr r4, [r1] - bl ScriptReadHalfword - add r1, r0, #0 - add r0, r5, #0 - add r0, #0x80 - ldr r0, [r0] - bl FieldSystem_VarGet - add r6, r0, #0 - add r0, r5, #0 - bl ScriptReadHalfword - add r7, r0, #0 - add r0, r5, #0 - add r0, #0x80 - ldr r0, [r0] - ldr r0, [r0, #0xc] - bl sub_0205C298 - cmp r0, #1 - bne _0204A1CC - add r5, #0x80 - ldr r0, [r5] - add r1, r6, #0 - ldr r0, [r0, #0x10] - add r2, r7, #0 - bl sub_020672A4 - b _0204A1DC -_0204A1CC: - ldr r0, _0204A1E0 ; =0x000008DA - ldr r1, _0204A1E4 ; =sub_0204A1E8 - strh r7, [r4, r0] - sub r0, r0, #5 - strb r6, [r4, r0] - add r0, r5, #0 - bl SetupNativeScript -_0204A1DC: - mov r0, #1 - pop {r3, r4, r5, r6, r7, pc} - .balign 4, 0 -_0204A1E0: .word 0x000008DA -_0204A1E4: .word sub_0204A1E8 - thumb_func_end ScrCmd_417 - - thumb_func_start sub_0204A1E8 -sub_0204A1E8: ; 0x0204A1E8 - push {r4, lr} - add r0, #0x80 - ldr r0, [r0] - add r1, r0, #0 - add r1, #0xa0 - ldr r4, [r1] - ldr r1, _0204A224 ; =0x000008DA - ldrh r1, [r4, r1] - bl GetVarPointer - ldr r1, _0204A228 ; =0x000008D5 - ldrb r1, [r4, r1] - cmp r1, #1 - bne _0204A208 - mov r3, #1 - b _0204A20A -_0204A208: - mov r3, #2 -_0204A20A: - ldr r1, _0204A22C ; =0x000008D4 - ldrb r2, [r4, r1] - cmp r2, r3 - bne _0204A220 - mov r2, #0 - strb r2, [r4, r1] - add r1, r1, #4 - ldrh r1, [r4, r1] - strh r1, [r0] - mov r0, #1 - pop {r4, pc} -_0204A220: - mov r0, #0 - pop {r4, pc} - .balign 4, 0 -_0204A224: .word 0x000008DA -_0204A228: .word 0x000008D5 -_0204A22C: .word 0x000008D4 - thumb_func_end sub_0204A1E8 - - thumb_func_start ScrCmd_418 -ScrCmd_418: ; 0x0204A230 - push {r3, r4, r5, r6, lr} - sub sp, #4 - add r5, r0, #0 - bl ScriptReadHalfword - add r1, r0, #0 - add r0, r5, #0 - add r0, #0x80 - ldr r0, [r0] - bl GetVarPointer - add r4, r0, #0 - add r0, r5, #0 - bl ScriptReadHalfword - add r1, r0, #0 - add r0, r5, #0 - add r0, #0x80 - ldr r0, [r0] - bl GetVarPointer - add r5, #0x80 - add r6, r0, #0 - ldr r0, [r5] - ldr r0, [r0, #0xc] - bl sub_0202D928 - add r1, sp, #0 - bl sub_0202D8D0 - add r0, sp, #0 - ldrb r1, [r0] - strh r1, [r4] - ldrb r0, [r0, #1] - strh r0, [r6] - mov r0, #0 - add sp, #4 - pop {r3, r4, r5, r6, pc} - thumb_func_end ScrCmd_418 - - thumb_func_start ScrCmd_419 -ScrCmd_419: ; 0x0204A27C - push {r3, r4, r5, lr} - add r5, r0, #0 - bl ScriptReadHalfword - add r1, r0, #0 - add r0, r5, #0 - add r0, #0x80 - ldr r0, [r0] - bl GetVarPointer - add r5, #0x80 - add r4, r0, #0 - ldr r0, [r5] - ldr r0, [r0, #0xc] - bl sub_0202D928 - bl sub_0202D7B8 - strh r0, [r4] - mov r0, #0 - pop {r3, r4, r5, pc} - .balign 4, 0 - thumb_func_end ScrCmd_419 - - thumb_func_start sub_0204A2A8 -sub_0204A2A8: ; 0x0204A2A8 - cmp r1, #2 - bne _0204A2B4 - ldrb r0, [r0, #0x10] - lsl r0, r0, #0x18 - lsr r0, r0, #0x1d - bx lr -_0204A2B4: - cmp r1, #1 - bne _0204A2DA - ldrb r1, [r0, #0xf] - cmp r1, #2 - bne _0204A2CC - ldrb r0, [r0, #0x10] - lsl r0, r0, #0x18 - lsr r0, r0, #0x1d - lsl r1, r0, #1 - ldr r0, _0204A2E8 ; =_020FBF70 - ldrh r0, [r0, r1] - bx lr -_0204A2CC: - ldrb r0, [r0, #0x12] - cmp r0, #0 - beq _0204A2D6 - mov r0, #0x61 - bx lr -_0204A2D6: - mov r0, #0 - bx lr -_0204A2DA: - ldrb r0, [r0, #0x11] - cmp r0, #0 - beq _0204A2E4 - mov r0, #0x61 - bx lr -_0204A2E4: - mov r0, #0 - bx lr - .balign 4, 0 -_0204A2E8: .word _020FBF70 - thumb_func_end sub_0204A2A8 - - thumb_func_start ScrCmd_554 -ScrCmd_554: ; 0x0204A2EC - push {r3, r4, r5, lr} - add r5, r0, #0 - add r1, r5, #0 - add r1, #0x80 - ldr r1, [r1] - ldr r4, [r1, #0xc] - bl ScriptReadHalfword - add r5, #0x80 - add r1, r0, #0 - ldr r0, [r5] - bl GetVarPointer - add r5, r0, #0 - add r0, r4, #0 - bl Save_FrontierData_Get - mov r1, #0 - add r2, r1, #0 - bl FrontierData_BattlePointAction - strh r0, [r5] - mov r0, #0 - pop {r3, r4, r5, pc} - thumb_func_end ScrCmd_554 - - thumb_func_start ScrCmd_555 -ScrCmd_555: ; 0x0204A31C - push {r4, r5, r6, lr} - add r5, r0, #0 - add r1, r5, #0 - add r1, #0x80 - ldr r1, [r1] - ldr r4, [r1, #0xc] - bl ScriptReadHalfword - add r1, r0, #0 - add r0, r5, #0 - add r0, #0x80 - ldr r0, [r0] - bl FieldSystem_VarGet - add r5, #0x80 - add r6, r0, #0 - ldr r0, [r5] - ldr r0, [r0, #0xc] - bl Save_GameStats_Get - mov r1, #0x45 - add r2, r6, #0 - bl GameStats_Add - add r0, r4, #0 - bl Save_FrontierData_Get - add r1, r6, #0 - mov r2, #5 - bl FrontierData_BattlePointAction - mov r0, #0 - pop {r4, r5, r6, pc} - .balign 4, 0 - thumb_func_end ScrCmd_555 - - thumb_func_start ScrCmd_556 -ScrCmd_556: ; 0x0204A360 - push {r4, r5, r6, lr} - add r5, r0, #0 - add r1, r5, #0 - add r1, #0x80 - ldr r1, [r1] - ldr r4, [r1, #0xc] - bl ScriptReadHalfword - add r1, r0, #0 - add r0, r5, #0 - add r0, #0x80 - ldr r0, [r0] - bl FieldSystem_VarGet - add r5, #0x80 - add r6, r0, #0 - ldr r0, [r5] - ldr r0, [r0, #0xc] - bl Save_GameStats_Get - mov r1, #0x46 - add r2, r6, #0 - bl GameStats_Add - add r0, r4, #0 - bl Save_FrontierData_Get - add r1, r6, #0 - mov r2, #6 - bl FrontierData_BattlePointAction - mov r0, #0 - pop {r4, r5, r6, pc} - .balign 4, 0 - thumb_func_end ScrCmd_556 - - thumb_func_start ScrCmd_CheckBattlePoints -ScrCmd_CheckBattlePoints: ; 0x0204A3A4 - push {r4, r5, r6, lr} - add r4, r0, #0 - add r1, r4, #0 - add r1, #0x80 - ldr r1, [r1] - ldr r5, [r1, #0xc] - bl ScriptReadHalfword - add r1, r0, #0 - add r0, r4, #0 - add r0, #0x80 - ldr r0, [r0] - bl FieldSystem_VarGet - add r6, r0, #0 - add r0, r4, #0 - bl ScriptReadHalfword - add r4, #0x80 - add r1, r0, #0 - ldr r0, [r4] - bl GetVarPointer - add r4, r0, #0 - add r0, r5, #0 - bl Save_FrontierData_Get - mov r1, #0 - add r2, r1, #0 - bl FrontierData_BattlePointAction - cmp r0, r6 - bhs _0204A3EA - mov r0, #0 - b _0204A3EC -_0204A3EA: - mov r0, #1 -_0204A3EC: - strh r0, [r4] - mov r0, #0 - pop {r4, r5, r6, pc} - .balign 4, 0 - thumb_func_end ScrCmd_CheckBattlePoints - - thumb_func_start sub_0204A3F4 -sub_0204A3F4: ; 0x0204A3F4 - cmp r0, #6 - bhi _0204A41E - add r0, r0, r0 - add r0, pc - ldrh r0, [r0, #6] - lsl r0, r0, #0x10 - asr r0, r0, #0x10 - add pc, r0 -_0204A404: ; jump table - .short _0204A412 - _0204A404 - 2 ; case 0 - .short _0204A416 - _0204A404 - 2 ; case 1 - .short _0204A41A - _0204A404 - 2 ; case 2 - .short _0204A41A - _0204A404 - 2 ; case 3 - .short _0204A412 - _0204A404 - 2 ; case 4 - .short _0204A412 - _0204A404 - 2 ; case 5 - .short _0204A41A - _0204A404 - 2 ; case 6 -_0204A412: - mov r0, #3 - bx lr -_0204A416: - mov r0, #4 - bx lr -_0204A41A: - mov r0, #2 - bx lr -_0204A41E: - mov r0, #0 - bx lr - .balign 4, 0 - thumb_func_end sub_0204A3F4 - - thumb_func_start sub_0204A424 -sub_0204A424: ; 0x0204A424 - push {r4, r5} - mov r5, #0 - cmp r3, #0 - ble _0204A44A -_0204A42C: - ldrh r4, [r0] - cmp r1, r4 - bne _0204A442 - cmp r2, #0 - beq _0204A442 - ldrh r4, [r0, #2] - cmp r2, r4 - bne _0204A442 - mov r0, #1 - pop {r4, r5} - bx lr -_0204A442: - add r5, r5, #1 - add r0, r0, #4 - cmp r5, r3 - blt _0204A42C -_0204A44A: - mov r0, #0 - pop {r4, r5} - bx lr - thumb_func_end sub_0204A424 - - thumb_func_start sub_0204A450 -sub_0204A450: ; 0x0204A450 - push {r3, r4, r5, r6, r7, lr} - add r5, r1, #0 - mov lr, r0 - sub r0, r5, #1 - mov r7, #0 - mov ip, r0 - cmp r0, #0 - ble _0204A49C - mov r3, lr -_0204A462: - add r2, r7, #1 - cmp r2, r5 - bge _0204A492 - ldrh r6, [r3] - lsl r1, r2, #2 - mov r0, lr - add r4, r0, r1 -_0204A470: - ldrh r0, [r4] - cmp r6, r0 - bne _0204A47A - mov r0, #0 - pop {r3, r4, r5, r6, r7, pc} -_0204A47A: - ldrh r1, [r3, #2] - cmp r1, #0 - beq _0204A48A - ldrh r0, [r4, #2] - cmp r1, r0 - bne _0204A48A - mov r0, #0 - pop {r3, r4, r5, r6, r7, pc} -_0204A48A: - add r2, r2, #1 - add r4, r4, #4 - cmp r2, r5 - blt _0204A470 -_0204A492: - add r7, r7, #1 - mov r0, ip - add r3, r3, #4 - cmp r7, r0 - blt _0204A462 -_0204A49C: - mov r0, #1 - pop {r3, r4, r5, r6, r7, pc} - thumb_func_end sub_0204A450 - - thumb_func_start sub_0204A4A0 -sub_0204A4A0: ; 0x0204A4A0 - push {r3, r4, r5, r6, r7, lr} - sub sp, #0x30 - str r0, [sp] - add r7, r1, #0 - add r6, r2, #0 - add r0, sp, #0x20 - mov r1, #0 - mov r2, #0x10 - str r3, [sp, #4] - bl MI_CpuFill8 - mov r0, #0 - str r0, [sp, #0x1c] - ldr r0, [sp, #4] - cmp r0, #0 - ble _0204A5A8 - ldr r0, [sp] - str r0, [sp, #0x10] -_0204A4C4: - ldr r0, [sp, #0x10] - ldrh r1, [r0] - add r0, sp, #0x20 - strh r1, [r0] - ldr r0, [sp, #0x10] - ldrh r1, [r0, #2] - add r0, sp, #0x20 - strh r1, [r0, #2] - ldr r0, [sp, #0x1c] - add r0, r0, #1 - str r0, [sp, #0x18] - cmp r0, r6 - bge _0204A596 - lsl r1, r0, #2 - ldr r0, [sp] - add r0, r0, r1 - str r0, [sp, #0xc] -_0204A4E6: - ldr r0, [sp, #0xc] - cmp r7, #2 - ldrh r1, [r0] - add r0, sp, #0x20 - strh r1, [r0, #4] - ldr r0, [sp, #0xc] - ldrh r1, [r0, #2] - add r0, sp, #0x20 - strh r1, [r0, #6] - bne _0204A50C - add r0, sp, #0x20 - add r1, r7, #0 - bl sub_0204A450 - cmp r0, #0 - beq _0204A586 - add sp, #0x30 - mov r0, #1 - pop {r3, r4, r5, r6, r7, pc} -_0204A50C: - ldr r0, [sp, #0x18] - add r0, r0, #1 - str r0, [sp, #0x14] - cmp r0, r6 - bge _0204A586 - lsl r1, r0, #2 - ldr r0, [sp] - add r0, r0, r1 - str r0, [sp, #8] -_0204A51E: - ldr r0, [sp, #8] - cmp r7, #3 - ldrh r1, [r0] - add r0, sp, #0x20 - strh r1, [r0, #8] - ldr r0, [sp, #8] - ldrh r1, [r0, #2] - add r0, sp, #0x20 - strh r1, [r0, #0xa] - bne _0204A544 - add r0, sp, #0x20 - add r1, r7, #0 - bl sub_0204A450 - cmp r0, #0 - beq _0204A576 - add sp, #0x30 - mov r0, #1 - pop {r3, r4, r5, r6, r7, pc} -_0204A544: - ldr r0, [sp, #0x14] - add r4, r0, #1 - cmp r4, r6 - bge _0204A576 - ldr r0, [sp] - lsl r1, r4, #2 - add r5, r0, r1 -_0204A552: - ldrh r1, [r5] - add r0, sp, #0x20 - strh r1, [r0, #0xc] - ldrh r1, [r5, #2] - strh r1, [r0, #0xe] - add r0, sp, #0x20 - add r1, r7, #0 - bl sub_0204A450 - cmp r0, #0 - beq _0204A56E - add sp, #0x30 - mov r0, #1 - pop {r3, r4, r5, r6, r7, pc} -_0204A56E: - add r4, r4, #1 - add r5, r5, #4 - cmp r4, r6 - blt _0204A552 -_0204A576: - ldr r0, [sp, #8] - add r0, r0, #4 - str r0, [sp, #8] - ldr r0, [sp, #0x14] - add r0, r0, #1 - str r0, [sp, #0x14] - cmp r0, r6 - blt _0204A51E -_0204A586: - ldr r0, [sp, #0xc] - add r0, r0, #4 - str r0, [sp, #0xc] - ldr r0, [sp, #0x18] - add r0, r0, #1 - str r0, [sp, #0x18] - cmp r0, r6 - blt _0204A4E6 -_0204A596: - ldr r0, [sp, #0x10] - add r0, r0, #4 - str r0, [sp, #0x10] - ldr r0, [sp, #0x1c] - add r1, r0, #1 - ldr r0, [sp, #4] - str r1, [sp, #0x1c] - cmp r1, r0 - blt _0204A4C4 -_0204A5A8: - mov r0, #0 - add sp, #0x30 - pop {r3, r4, r5, r6, r7, pc} - .balign 4, 0 - thumb_func_end sub_0204A4A0 - - thumb_func_start sub_0204A5B0 -sub_0204A5B0: ; 0x0204A5B0 - push {r3, r4, r5, r6, r7, lr} - sub sp, #0x30 - str r0, [sp] - add r0, r1, #0 - str r2, [sp, #4] - bl SaveArray_Party_Get - str r0, [sp, #8] - bl Party_GetCount - lsl r0, r0, #0x18 - lsr r1, r0, #0x18 - str r1, [sp, #0x10] - ldr r0, [sp] - cmp r1, r0 - bge _0204A5D6 - add sp, #0x30 - mov r0, #0 - pop {r3, r4, r5, r6, r7, pc} -_0204A5D6: - mov r4, #0 - str r4, [sp, #0x14] - ldr r0, [sp, #0x10] - cmp r0, #0 - bls _0204A66C -_0204A5E0: - ldr r0, [sp, #8] - ldr r1, [sp, #0x14] - bl Party_GetMonByIndex - mov r1, #5 - mov r2, #0 - add r6, r0, #0 - bl GetMonData - lsl r0, r0, #0x10 - lsr r5, r0, #0x10 - add r0, r6, #0 - mov r1, #6 - mov r2, #0 - bl GetMonData - lsl r0, r0, #0x10 - lsr r7, r0, #0x10 - add r0, r6, #0 - mov r1, #0x70 - mov r2, #0 - bl GetMonData - lsl r0, r0, #0x10 - lsr r0, r0, #0x10 - str r0, [sp, #0xc] - ldr r0, [sp, #4] - cmp r0, #0 - bne _0204A61C - mov r7, #0 -_0204A61C: - add r0, r6, #0 - mov r1, #0x4c - mov r2, #0 - bl GetMonData - cmp r0, #0 - bne _0204A65C - ldr r1, [sp, #0xc] - add r0, r5, #0 - bl IsPokemonBannedFromBattleFrontier - cmp r0, #1 - beq _0204A65C - ldr r0, [sp, #4] - cmp r0, #1 - bne _0204A64C - add r0, sp, #0x18 - add r1, r5, #0 - add r2, r7, #0 - add r3, r4, #0 - bl sub_0204A424 - cmp r0, #1 - beq _0204A65C -_0204A64C: - lsl r1, r4, #2 - add r0, sp, #0x18 - add r2, r0, r1 - strh r5, [r0, r1] - add r0, r4, #1 - lsl r0, r0, #0x18 - strh r7, [r2, #2] - lsr r4, r0, #0x18 -_0204A65C: - ldr r0, [sp, #0x14] - add r0, r0, #1 - lsl r0, r0, #0x18 - lsr r1, r0, #0x18 - str r1, [sp, #0x14] - ldr r0, [sp, #0x10] - cmp r1, r0 - blo _0204A5E0 -_0204A66C: - ldr r0, [sp] - cmp r4, r0 - bge _0204A678 - add sp, #0x30 - mov r0, #0 - pop {r3, r4, r5, r6, r7, pc} -_0204A678: - ldr r1, [sp] - add r0, sp, #0x18 - add r3, r1, #0 - sub r3, r4, r3 - add r2, r4, #0 - add r3, r3, #1 - bl sub_0204A4A0 - add sp, #0x30 - pop {r3, r4, r5, r6, r7, pc} - thumb_func_end sub_0204A5B0 - - thumb_func_start sub_0204A68C -sub_0204A68C: ; 0x0204A68C - ldr r3, _0204A694 ; =OS_ResetSystem - mov r0, #0 - bx r3 - nop -_0204A694: .word OS_ResetSystem - thumb_func_end sub_0204A68C - - thumb_func_start sub_0204A698 -sub_0204A698: ; 0x0204A698 - ldr r3, _0204A69C ; =sub_0202D234 - bx r3 - .balign 4, 0 -_0204A69C: .word sub_0202D234 - thumb_func_end sub_0204A698 - - thumb_func_start sub_0204A6A0 -sub_0204A6A0: ; 0x0204A6A0 - ldr r3, _0204A6A4 ; =sub_0202D3DC - bx r3 - .balign 4, 0 -_0204A6A4: .word sub_0202D3DC - thumb_func_end sub_0204A6A0 - - thumb_func_start sub_0204A6A8 -sub_0204A6A8: ; 0x0204A6A8 - push {r4, r5, r6, lr} - add r5, r0, #0 - ldr r0, [r5, #0xc] - bl Save_LocalFieldData_Get - bl LocalFieldData_GetDynamicWarp - add r4, r0, #0 - ldr r0, [r5, #0x40] - bl GetPlayerYCoord - add r6, r0, #0 - ldr r0, [r5, #0x40] - bl GetPlayerXCoord - ldr r1, [r5, #0x20] - ldr r1, [r1] - str r1, [r4] - mov r1, #0 - mvn r1, r1 - str r1, [r4, #4] - str r0, [r4, #8] - str r6, [r4, #0xc] - mov r0, #0 - str r0, [r4, #0x10] - ldr r0, [r5, #0xc] - bl Save_VarsFlags_Get - bl SetFlag966 - pop {r4, r5, r6, pc} - .balign 4, 0 - thumb_func_end sub_0204A6A8 - - thumb_func_start sub_0204A6E8 -sub_0204A6E8: ; 0x0204A6E8 - push {r3, lr} - ldr r0, [r0, #0xc] - bl Save_VarsFlags_Get - bl ClearFlag966 - pop {r3, pc} - .balign 4, 0 - thumb_func_end sub_0204A6E8 - - thumb_func_start sub_0204A6F8 -sub_0204A6F8: ; 0x0204A6F8 - push {r4, lr} - add r4, r1, #0 - cmp r4, #5 - bne _0204A704 - mov r0, #0 - pop {r4, pc} -_0204A704: - cmp r4, #6 - bne _0204A720 - bl sub_0203107C - add r4, r0, #0 - mov r0, #0x71 - bl sub_0205C268 - add r2, r0, #0 - add r0, r4, #0 - mov r1, #0x71 - bl sub_020310BC - pop {r4, pc} -_0204A720: - bl sub_0203107C - lsl r1, r4, #1 - add r1, r1, #1 - mov r2, #0xff - bl sub_020310BC - pop {r4, pc} - thumb_func_end sub_0204A6F8 - - thumb_func_start sub_0204A730 -sub_0204A730: ; 0x0204A730 - push {r4, lr} - add r4, r1, #0 - bl Save_FrontierData_Get - cmp r4, #0 - bne _0204A746 - mov r1, #5 - mov r2, #2 - bl sub_0202D5DC - pop {r4, pc} -_0204A746: - mov r1, #5 - mov r2, #1 - bl sub_0202D5DC - pop {r4, pc} - thumb_func_end sub_0204A730 - - thumb_func_start sub_0204A750 -sub_0204A750: ; 0x0204A750 - push {r3, lr} - bl Save_FrontierData_Get - mov r1, #5 - mov r2, #0 - bl sub_0202D5DC - lsl r0, r0, #0x10 - lsr r0, r0, #0x10 - pop {r3, pc} - thumb_func_end sub_0204A750 - - thumb_func_start sub_0204A764 -sub_0204A764: ; 0x0204A764 - push {r3, r4, r5, r6, r7, lr} - add r5, r0, #0 - bl sub_0202D908 - add r4, r0, #0 - add r0, r5, #0 - bl Save_FrontierData_Get - mov r1, #0 - add r6, r0, #0 - add r0, r4, #0 - add r2, r1, #0 - bl sub_0202D284 - lsl r0, r0, #0x18 - lsr r4, r0, #0x18 - cmp r4, #5 - bne _0204A78C - add r0, r4, #0 - pop {r3, r4, r5, r6, r7, pc} -_0204A78C: - cmp r4, #6 - bne _0204A7AC - add r0, r5, #0 - bl sub_0203107C - add r7, r0, #0 - mov r0, #0x64 - bl sub_0205C268 - add r2, r0, #0 - add r0, r7, #0 - mov r1, #0x64 - mov r3, #0 - bl sub_02031108 - b _0204A7BC -_0204A7AC: - add r1, r4, #0 - add r1, #8 - lsl r1, r1, #0x10 - add r0, r6, #0 - lsr r1, r1, #0x10 - mov r2, #2 - bl sub_0202D5DC -_0204A7BC: - add r0, r6, #0 - add r1, r4, #0 - mov r2, #2 - bl sub_0202D57C - add r0, r5, #0 - bl sub_0203107C - add r6, r0, #0 - add r0, r4, #0 - bl sub_0205C310 - add r7, r0, #0 - add r0, r4, #0 - bl sub_0205C310 - bl sub_0205C268 - add r2, r0, #0 - add r0, r6, #0 - add r1, r7, #0 - mov r3, #0 - bl sub_02031108 - cmp r4, #4 - beq _0204A7FA - cmp r4, #6 - beq _0204A7FA - add r0, r5, #0 - bl sub_020674E0 -_0204A7FA: - add r0, r4, #0 - pop {r3, r4, r5, r6, r7, pc} - .balign 4, 0 - thumb_func_end sub_0204A764 - - thumb_func_start sub_0204A800 -sub_0204A800: ; 0x0204A800 - push {r3, lr} - bl sub_0202D928 - bl sub_0202D7B0 - lsl r0, r0, #0x10 - lsr r0, r0, #0x10 - pop {r3, pc} - thumb_func_end sub_0204A800 - - thumb_func_start sub_0204A810 -sub_0204A810: ; 0x0204A810 - push {r4, lr} - add r4, r0, #0 - ldr r0, [r4] - cmp r0, #0 - beq _0204A81E - bl GF_AssertFail -_0204A81E: - mov r0, #0 - str r0, [r4] - pop {r4, pc} - thumb_func_end sub_0204A810 - - thumb_func_start sub_0204A824 -sub_0204A824: ; 0x0204A824 - push {r4, r5, r6, r7, lr} - sub sp, #0xc - add r5, r1, #0 - add r6, r0, #0 - ldr r1, _0204AA1C ; =0x000008DC - mov r0, #0xb - add r7, r2, #0 - bl AllocFromHeap - ldr r2, _0204AA1C ; =0x000008DC - mov r1, #0 - add r4, r0, #0 - bl MI_CpuFill8 - mov r0, #0xb - str r0, [r4, #4] - add r0, r6, #0 - bl sub_0202D908 - str r0, [r4, #0x70] - add r0, r6, #0 - bl Save_FrontierData_Get - str r0, [r4, #0x74] - ldr r0, _0204AA20 ; =0x12345678 - mov r1, #0 - str r0, [r4] - ldr r0, [r4, #0x70] - bl sub_0202D3E4 - cmp r5, #0 - bne _0204A8B4 - strb r7, [r4, #0xf] - ldrb r0, [r4, #0xf] - bl sub_0204A3F4 - strb r0, [r4, #0xe] - mov r0, #1 - strb r0, [r4, #0xc] - mov r2, #0 - strb r2, [r4, #0xd] - mov r1, #0xff -_0204A878: - add r0, r4, r2 - add r0, #0x2a - strb r1, [r0] - add r0, r2, #1 - lsl r0, r0, #0x10 - lsr r2, r0, #0x10 - cmp r2, #4 - blo _0204A878 - ldr r1, _0204AA24 ; =0x0000FFFF - mov r2, #0 -_0204A88C: - lsl r0, r2, #1 - add r0, r4, r0 - strh r1, [r0, #0x3e] - add r0, r2, #1 - lsl r0, r0, #0x10 - lsr r2, r0, #0x10 - cmp r2, #0xe - blo _0204A88C - ldr r0, [r4, #0x70] - bl sub_0202D234 - ldrb r1, [r4, #0xf] - add r0, sp, #8 - add r2, sp, #8 - strb r1, [r0] - ldr r0, [r4, #0x70] - mov r1, #0 - bl sub_0202D308 - b _0204A972 -_0204A8B4: - mov r1, #0 - ldr r0, [r4, #0x70] - add r2, r1, #0 - bl sub_0202D284 - strb r0, [r4, #0xf] - ldr r0, [r4, #0x70] - mov r1, #1 - mov r2, #0 - bl sub_0202D284 - strb r0, [r4, #0xc] - ldrb r0, [r4, #0xc] - sub r0, r0, #1 - strb r0, [r4, #0xd] - ldrb r0, [r4, #0xf] - bl sub_0204A3F4 - strb r0, [r4, #0xe] - add r2, r4, #0 - ldr r0, [r4, #0x70] - mov r1, #5 - add r2, #0x2a - bl sub_0202D284 - add r2, r4, #0 - ldr r0, [r4, #0x70] - mov r1, #8 - add r2, #0x3e - bl sub_0202D284 - ldr r0, [r4, #0x70] - mov r1, #0xa - mov r2, #0 - bl sub_0202D284 - str r0, [r4, #8] - ldrb r0, [r4, #0xf] - cmp r0, #2 - bne _0204A972 - ldr r0, [r4, #0x70] - mov r1, #9 - mov r2, #0 - bl sub_0202D284 - lsl r0, r0, #0x18 - lsr r0, r0, #0x18 - lsl r0, r0, #0x1d - ldrb r1, [r4, #0x10] - mov r2, #0xe0 - lsr r0, r0, #0x18 - bic r1, r2 - orr r0, r1 - strb r0, [r4, #0x10] - ldrb r3, [r4, #0x10] - ldr r2, _0204AA28 ; =0x000007E8 - ldr r0, [r4, #0x70] - lsl r3, r3, #0x18 - lsr r3, r3, #0x1d - add r2, r4, r2 - lsl r3, r3, #4 - mov r1, #6 - add r2, r2, r3 - bl sub_0202D284 - ldrb r0, [r4, #0x10] - mov r1, #7 - mov r2, #0 - lsl r0, r0, #0x18 - lsr r5, r0, #0x1d - ldr r0, [r4, #0x70] - bl sub_0202D284 - add r3, r0, #0 - ldr r0, _0204AA28 ; =0x000007E8 - mov r1, #0xa6 - lsl r1, r1, #2 - add r0, r4, r0 - lsl r2, r5, #4 - add r0, r0, r2 - add r2, r5, r2 - str r0, [sp] - ldr r0, [r4, #4] - add r1, r4, r1 - lsl r2, r2, #4 - add r1, r1, r2 - mov r2, #0x4b - lsl r2, r2, #2 - add r2, r5, r2 - lsl r2, r2, #0x10 - str r0, [sp, #4] - add r0, r4, #0 - lsr r2, r2, #0x10 - bl sub_0204BA50 -_0204A972: - add r0, r6, #0 - bl Save_PlayerData_GetProfileAddr - bl PlayerProfile_GetTrainerGender - strb r0, [r4, #0x11] - ldrb r0, [r4, #0xf] - cmp r0, #5 - beq _0204A9F8 - add r0, r6, #0 - bl sub_0203107C - add r5, r0, #0 - add r0, r6, #0 - bl Save_GameStats_Get - ldrb r1, [r4, #0xf] - add r7, r0, #0 - cmp r1, #6 - bne _0204A9A6 - add r0, r6, #0 - bl Save_VarsFlags_Get - bl Save_VarsFlags_GetVar4052 - b _0204A9B8 -_0204A9A6: - add r1, #8 - lsl r1, r1, #0x10 - ldr r0, [r4, #0x74] - lsr r1, r1, #0x10 - mov r2, #0 - bl sub_0202D5DC - lsl r0, r0, #0x10 - lsr r0, r0, #0x10 -_0204A9B8: - cmp r0, #0 - beq _0204A9EE - ldrb r1, [r4, #0xf] - cmp r1, #6 - bne _0204A9D4 - mov r0, #0x71 - bl sub_0205C268 - add r2, r0, #0 - add r0, r5, #0 - mov r1, #0x71 - bl sub_020310BC - b _0204A9E0 -_0204A9D4: - lsl r1, r1, #1 - add r0, r5, #0 - add r1, r1, #1 - mov r2, #0xff - bl sub_020310BC -_0204A9E0: - strh r0, [r4, #0x1a] - ldrb r1, [r4, #0xf] - ldr r0, [r4, #0x74] - mov r2, #0 - bl sub_0202D57C - strh r0, [r4, #0x1c] -_0204A9EE: - add r0, r7, #0 - mov r1, #0x1e - bl GameStats_GetCapped - str r0, [r4, #0x20] -_0204A9F8: - ldrb r0, [r4, #0xf] - cmp r0, #6 - bne _0204AA16 - ldrh r0, [r4, #0x1a] - mov r1, #7 - bl _s32_div_f - add r2, r0, #0 - lsl r2, r2, #0x10 - ldr r0, [r4, #0x74] - mov r1, #6 - lsr r2, r2, #0x10 - bl sub_0202D5C4 - strh r0, [r4, #0x1c] -_0204AA16: - add r0, r4, #0 - add sp, #0xc - pop {r4, r5, r6, r7, pc} - .balign 4, 0 -_0204AA1C: .word 0x000008DC -_0204AA20: .word 0x12345678 -_0204AA24: .word 0x0000FFFF -_0204AA28: .word 0x000007E8 - thumb_func_end sub_0204A824 - - thumb_func_start sub_0204AA2C -sub_0204AA2C: ; 0x0204AA2C - push {r4, lr} - add r4, r0, #0 - beq _0204AA4E - ldr r1, [r4] - ldr r0, _0204AA50 ; =0x12345678 - cmp r1, r0 - beq _0204AA3E - bl GF_AssertFail -_0204AA3E: - ldr r2, _0204AA54 ; =0x000008DC - add r0, r4, #0 - mov r1, #0 - bl MI_CpuFill8 - add r0, r4, #0 - bl FreeToHeap -_0204AA4E: - pop {r4, pc} - .balign 4, 0 -_0204AA50: .word 0x12345678 -_0204AA54: .word 0x000008DC - thumb_func_end sub_0204AA2C - - thumb_func_start sub_0204AA58 -sub_0204AA58: ; 0x0204AA58 - push {r3, lr} - sub sp, #0x10 - ldrb r0, [r0, #0xe] - mov r3, #0 - str r0, [sp] - str r0, [sp, #4] - mov r0, #0x64 - str r0, [sp, #8] - add r0, r1, #0 - add r1, r2, #0 - mov r2, #0x11 - str r3, [sp, #0xc] - bl sub_02067118 - add sp, #0x10 - pop {r3, pc} - thumb_func_end sub_0204AA58 - - thumb_func_start sub_0204AA78 -sub_0204AA78: ; 0x0204AA78 - push {r4, r5, r6, r7, lr} - sub sp, #0xc - add r5, r0, #0 - ldr r0, [r1] - str r1, [sp] - str r0, [sp, #4] - add r0, #0x27 - ldrb r0, [r0] - cmp r0, #0 - bne _0204AA96 - ldr r0, [sp, #4] - add r0, #0x26 - ldrb r0, [r0] - cmp r0, #7 - bne _0204AAA6 -_0204AA96: - ldr r0, [sp, #4] - bl FreeToHeap - ldr r1, [sp] - mov r0, #0 - str r0, [r1] - add sp, #0xc - pop {r4, r5, r6, r7, pc} -_0204AAA6: - add r0, r2, #0 - bl SaveArray_Party_Get - str r0, [sp, #8] - ldrb r0, [r5, #0xe] - mov r4, #0 - cmp r0, #0 - ble _0204AAFA -_0204AAB6: - ldr r0, [sp, #4] - add r0, r0, r4 - add r0, #0x30 - ldrb r0, [r0] - sub r1, r0, #1 - add r0, r5, r4 - add r0, #0x2a - strb r1, [r0] - add r1, r5, r4 - add r1, #0x2a - ldrb r1, [r1] - ldr r0, [sp, #8] - bl Party_GetMonByIndex - lsl r1, r4, #1 - add r6, r5, r1 - add r7, r0, #0 - mov r1, #5 - mov r2, #0 - bl GetMonData - strh r0, [r6, #0x2e] - add r0, r7, #0 - mov r1, #6 - mov r2, #0 - bl GetMonData - strh r0, [r6, #0x36] - add r0, r4, #1 - lsl r0, r0, #0x10 - lsr r4, r0, #0x10 - ldrb r0, [r5, #0xe] - cmp r4, r0 - blt _0204AAB6 -_0204AAFA: - ldr r0, [sp] - ldr r0, [r0] - bl FreeToHeap - ldr r0, [sp] - mov r1, #0 - str r1, [r0] - mov r0, #1 - add sp, #0xc - pop {r4, r5, r6, r7, pc} - .balign 4, 0 - thumb_func_end sub_0204AA78 - - thumb_func_start sub_0204AB10 -sub_0204AB10: ; 0x0204AB10 - push {r4, r5, r6, r7, lr} - sub sp, #0x1c - str r0, [sp] - add r0, r1, #0 - bl SaveArray_Party_Get - str r0, [sp, #4] - ldr r0, [sp] - mov r5, #0 - ldrb r0, [r0, #0xe] - cmp r0, #0 - ble _0204AB98 - add r7, sp, #0xc - add r4, sp, #0x14 -_0204AB2C: - ldr r1, [sp] - ldr r0, [sp, #4] - add r1, r1, r5 - add r1, #0x2a - ldrb r1, [r1] - bl Party_GetMonByIndex - str r0, [sp, #8] - lsl r6, r5, #1 - mov r1, #5 - mov r2, #0 - bl GetMonData - strh r0, [r4, r6] - ldr r0, [sp, #8] - mov r1, #6 - mov r2, #0 - bl GetMonData - strh r0, [r7, r6] - cmp r5, #0 - beq _0204AB8A - mov r0, #0 - cmp r5, #0 - bls _0204AB8A - ldrh r1, [r4, r6] - ldrh r2, [r7, r6] -_0204AB62: - lsl r6, r0, #1 - ldrh r3, [r4, r6] - cmp r1, r3 - bne _0204AB70 - add sp, #0x1c - mov r0, #1 - pop {r4, r5, r6, r7, pc} -_0204AB70: - cmp r2, #0 - beq _0204AB80 - ldrh r3, [r7, r6] - cmp r2, r3 - bne _0204AB80 - add sp, #0x1c - mov r0, #2 - pop {r4, r5, r6, r7, pc} -_0204AB80: - add r0, r0, #1 - lsl r0, r0, #0x10 - lsr r0, r0, #0x10 - cmp r0, r5 - blo _0204AB62 -_0204AB8A: - add r0, r5, #1 - lsl r0, r0, #0x10 - lsr r5, r0, #0x10 - ldr r0, [sp] - ldrb r0, [r0, #0xe] - cmp r5, r0 - blt _0204AB2C -_0204AB98: - mov r0, #0 - add sp, #0x1c - pop {r4, r5, r6, r7, pc} - .balign 4, 0 - thumb_func_end sub_0204AB10 - - thumb_func_start sub_0204ABA0 -sub_0204ABA0: ; 0x0204ABA0 - push {r3, r4} - mov r4, #0 - cmp r2, #0 - bls _0204ABC0 -_0204ABA8: - lsl r3, r4, #1 - ldrh r3, [r0, r3] - cmp r1, r3 - bne _0204ABB6 - mov r0, #1 - pop {r3, r4} - bx lr -_0204ABB6: - add r3, r4, #1 - lsl r3, r3, #0x10 - lsr r4, r3, #0x10 - cmp r4, r2 - blo _0204ABA8 -_0204ABC0: - mov r0, #0 - pop {r3, r4} - bx lr - .balign 4, 0 - thumb_func_end sub_0204ABA0 - - thumb_func_start sub_0204ABC8 -sub_0204ABC8: ; 0x0204ABC8 - push {r4, r5, r6, r7, lr} - sub sp, #0xc - add r5, r0, #0 - ldrb r1, [r5, #0xf] - cmp r1, #2 - beq _0204ABDC - cmp r1, #6 - beq _0204ABDC - cmp r1, #3 - bne _0204AC3A -_0204ABDC: - cmp r1, #3 - bne _0204ABE8 - ldrh r2, [r5, #0x14] - ldrh r0, [r5, #0x1c] - cmp r2, r0 - bhi _0204ABF6 -_0204ABE8: - cmp r1, #6 - bne _0204ABF4 - ldrh r2, [r5, #0x14] - ldrh r0, [r5, #0x1c] - cmp r2, r0 - bhi _0204ABF6 -_0204ABF4: - ldrh r2, [r5, #0x1c] -_0204ABF6: - lsl r0, r2, #0x18 - lsr r0, r0, #0x18 - str r0, [sp] - add r0, r5, #0 - str r0, [sp, #4] - add r0, #0x3e - mov r4, #0 - add r6, r5, #0 - str r0, [sp, #4] -_0204AC08: - lsr r2, r4, #0x1f - add r2, r4, r2 - lsl r2, r2, #0x17 - ldrb r3, [r5, #0xf] - ldr r1, [sp] - add r0, r5, #0 - lsr r2, r2, #0x18 - bl sub_0204B73C - add r7, r0, #0 - lsl r2, r4, #0x10 - ldr r0, [sp, #4] - add r1, r7, #0 - lsr r2, r2, #0x10 - bl sub_0204ABA0 - cmp r0, #0 - bne _0204AC08 - add r4, r4, #1 - strh r7, [r6, #0x3e] - add r6, r6, #2 - cmp r4, #0xe - blt _0204AC08 - add sp, #0xc - pop {r4, r5, r6, r7, pc} -_0204AC3A: - str r0, [sp, #8] - add r0, #0x3e - mov r4, #0 - add r6, r5, #0 - str r0, [sp, #8] -_0204AC44: - ldrh r1, [r5, #0x1c] - lsl r2, r4, #0x18 - ldrb r3, [r5, #0xf] - lsl r1, r1, #0x18 - add r0, r5, #0 - lsr r1, r1, #0x18 - lsr r2, r2, #0x18 - bl sub_0204B73C - add r7, r0, #0 - lsl r2, r4, #0x10 - ldr r0, [sp, #8] - add r1, r7, #0 - lsr r2, r2, #0x10 - bl sub_0204ABA0 - cmp r0, #0 - bne _0204AC44 - add r4, r4, #1 - strh r7, [r6, #0x3e] - add r6, r6, #2 - cmp r4, #7 - blt _0204AC44 - add sp, #0xc - pop {r4, r5, r6, r7, pc} - .balign 4, 0 - thumb_func_end sub_0204ABC8 - - thumb_func_start sub_0204AC78 -sub_0204AC78: ; 0x0204AC78 - ldrb r0, [r0, #0xc] - bx lr - thumb_func_end sub_0204AC78 - - thumb_func_start sub_0204AC7C -sub_0204AC7C: ; 0x0204AC7C - ldrb r2, [r0, #0x10] - lsl r1, r2, #0x1f - lsr r1, r1, #0x1f - beq _0204AC88 - mov r0, #1 - bx lr -_0204AC88: - ldrb r1, [r0, #0xc] - cmp r1, #7 - bls _0204AC9C - mov r1, #1 - bic r2, r1 - mov r1, #1 - orr r2, r1 - strb r2, [r0, #0x10] - add r0, r1, #0 - bx lr -_0204AC9C: - mov r0, #0 - bx lr - thumb_func_end sub_0204AC7C - - thumb_func_start sub_0204ACA0 -sub_0204ACA0: ; 0x0204ACA0 - push {r3, r4, lr} - sub sp, #4 - add r4, r0, #0 - ldrb r2, [r4, #0xf] - cmp r2, #0 - beq _0204ACB8 - cmp r2, #1 - beq _0204AD00 - cmp r2, #4 - beq _0204ACC2 - add sp, #4 - pop {r3, r4, pc} -_0204ACB8: - mov r2, #0 - bl sub_0204B470 - add sp, #4 - pop {r3, r4, pc} -_0204ACC2: - mov r2, #1 - bl sub_0204B470 - ldrh r1, [r4, #0x28] - ldrh r2, [r4, #0x24] - ldrh r3, [r4, #0x26] - lsl r1, r1, #0x18 - ldr r0, [r4, #0x70] - lsr r1, r1, #0x18 - bl sub_0202D3B0 - ldrb r1, [r4, #0xf] - add r0, sp, #0 - add r2, sp, #0 - strb r1, [r0] - ldr r0, [r4, #0x70] - mov r1, #0 - bl sub_0202D308 - ldrb r1, [r4, #0xc] - add r0, sp, #0 - add r2, sp, #0 - strb r1, [r0] - ldr r0, [r4, #0x70] - mov r1, #1 - bl sub_0202D308 - ldr r0, [r4, #0x74] - ldr r1, [r4, #0x70] - bl sub_0202D4FC -_0204AD00: - add sp, #4 - pop {r3, r4, pc} - thumb_func_end sub_0204ACA0 - - thumb_func_start sub_0204AD04 -sub_0204AD04: ; 0x0204AD04 - push {r3, r4, r5, r6, r7, lr} - sub sp, #8 - add r7, r1, #0 - add r5, r0, #0 - add r0, r7, #0 - bl Save_GameStats_Get - str r0, [sp, #4] - add r0, r7, #0 - bl sub_0203107C - str r0, [sp] - ldrb r0, [r5, #0xf] - cmp r0, #5 - beq _0204AE16 - cmp r0, #6 - bne _0204AD2A - mov r4, #0x70 - b _0204AD2C -_0204AD2A: - lsl r4, r0, #1 -_0204AD2C: - add r0, r4, #0 - bl sub_0205C268 - add r2, r0, #0 - ldr r0, [sp] - add r1, r4, #0 - bl sub_020310BC - add r0, r4, #0 - bl sub_0205C268 - add r2, r0, #0 - ldrh r6, [r5, #0x1a] - ldrb r3, [r5, #0xd] - ldr r0, [sp] - add r1, r4, #0 - add r3, r6, r3 - lsl r3, r3, #0x10 - lsr r3, r3, #0x10 - bl sub_0203126C - ldrb r1, [r5, #0xf] - cmp r1, #6 - bne _0204AD76 - add r0, r7, #0 - bl sub_0203107C - add r6, r0, #0 - mov r0, #0x64 - bl sub_0205C268 - add r2, r0, #0 - add r0, r6, #0 - mov r1, #0x64 - bl sub_020310BC - b _0204AD84 -_0204AD76: - add r1, #8 - lsl r1, r1, #0x10 - ldr r0, [r5, #0x74] - lsr r1, r1, #0x10 - mov r2, #0 - bl sub_0202D5DC -_0204AD84: - add r0, r4, #1 - bl sub_0205C268 - add r1, r4, #1 - add r2, r0, #0 - ldrh r4, [r5, #0x1a] - ldrb r3, [r5, #0xd] - ldr r0, [sp] - add r3, r4, r3 - lsl r3, r3, #0x10 - lsr r3, r3, #0x10 - bl sub_02031108 - ldrb r1, [r5, #0xf] - add r4, r0, #0 - cmp r1, #6 - bne _0204ADC2 - add r0, r7, #0 - bl sub_0203107C - add r6, r0, #0 - mov r0, #0x64 - bl sub_0205C268 - add r2, r0, #0 - add r0, r6, #0 - mov r1, #0x64 - mov r3, #0 - bl sub_02031108 - b _0204ADD0 -_0204ADC2: - add r1, #8 - lsl r1, r1, #0x10 - ldr r0, [r5, #0x74] - lsr r1, r1, #0x10 - mov r2, #2 - bl sub_0202D5DC -_0204ADD0: - ldrb r2, [r5, #0xd] - ldr r0, [sp, #4] - mov r1, #0x1e - bl GameStats_Add - ldrb r1, [r5, #0xf] - ldr r0, [r5, #0x74] - mov r2, #2 - bl sub_0202D57C - ldrb r0, [r5, #0xf] - cmp r0, #6 - beq _0204ADF8 - add r0, r7, #0 - bl Save_GameStats_Get - mov r1, #0x10 - mov r2, #1 - bl GameStats_Add -_0204ADF8: - add r0, r5, #0 - bl sub_0204B318 - ldr r0, _0204AE1C ; =0x0000270F - add r4, r4, #1 - cmp r4, r0 - bls _0204AE08 - add r4, r0, #0 -_0204AE08: - lsl r3, r4, #0x10 - add r0, r5, #0 - add r1, r7, #0 - mov r2, #0 - lsr r3, r3, #0x10 - bl sub_0204ACA0 -_0204AE16: - add sp, #8 - pop {r3, r4, r5, r6, r7, pc} - nop -_0204AE1C: .word 0x0000270F - thumb_func_end sub_0204AD04 - - thumb_func_start sub_0204AE20 -sub_0204AE20: ; 0x0204AE20 - push {r4, r5, r6, r7, lr} - sub sp, #0xc - add r5, r0, #0 - ldrb r0, [r5, #0xf] - add r7, r1, #0 - cmp r0, #5 - beq _0204AF26 - add r0, r7, #0 - bl Save_GameStats_Get - str r0, [sp, #4] - add r0, r7, #0 - bl sub_0203107C - ldrb r1, [r5, #0xf] - str r0, [sp] - cmp r1, #6 - bne _0204AE48 - mov r4, #0x70 - b _0204AE4A -_0204AE48: - lsl r4, r1, #1 -_0204AE4A: - cmp r1, #6 - bne _0204AE68 - add r0, r7, #0 - bl sub_0203107C - add r6, r0, #0 - mov r0, #0x64 - bl sub_0205C268 - add r2, r0, #0 - add r0, r6, #0 - mov r1, #0x64 - bl sub_020310BC - b _0204AE76 -_0204AE68: - add r1, #8 - lsl r1, r1, #0x10 - ldr r0, [r5, #0x74] - lsr r1, r1, #0x10 - mov r2, #0 - bl sub_0202D5DC -_0204AE76: - add r0, r4, #1 - bl sub_0205C268 - add r2, r0, #0 - ldrh r6, [r5, #0x1a] - ldrb r3, [r5, #0xd] - ldr r0, [sp] - add r1, r4, #1 - add r3, r6, r3 - lsl r3, r3, #0x10 - lsr r3, r3, #0x10 - bl sub_02031108 - ldrb r1, [r5, #0xf] - add r6, r0, #0 - cmp r1, #6 - bne _0204AEB4 - add r0, r7, #0 - bl sub_0203107C - str r0, [sp, #8] - mov r0, #0x64 - bl sub_0205C268 - add r2, r0, #0 - ldr r0, [sp, #8] - mov r1, #0x64 - mov r3, #1 - bl sub_02031108 - b _0204AEC2 -_0204AEB4: - add r1, #8 - lsl r1, r1, #0x10 - ldr r0, [r5, #0x74] - lsr r1, r1, #0x10 - mov r2, #1 - bl sub_0202D5DC -_0204AEC2: - add r0, r4, #0 - bl sub_0205C268 - add r2, r0, #0 - ldr r0, [sp] - add r1, r4, #0 - bl sub_020310BC - add r0, r4, #0 - bl sub_0205C268 - add r2, r0, #0 - lsl r3, r6, #0x10 - ldr r0, [sp] - add r1, r4, #0 - lsr r3, r3, #0x10 - bl sub_0203126C - ldr r0, [sp, #4] - mov r1, #0x1e - mov r2, #7 - bl GameStats_Add - ldrb r1, [r5, #0xf] - ldr r0, [r5, #0x74] - mov r2, #3 - bl sub_0202D57C - ldrb r0, [r5, #0xf] - cmp r0, #6 - beq _0204AF0A - ldr r0, [sp, #4] - mov r1, #0x10 - mov r2, #1 - bl GameStats_Add -_0204AF0A: - ldr r0, [sp, #4] - mov r1, #0xe - bl GameStats_AddSpecial - add r0, r5, #0 - bl sub_0204B318 - lsl r3, r6, #0x10 - add r0, r5, #0 - add r1, r7, #0 - mov r2, #1 - lsr r3, r3, #0x10 - bl sub_0204ACA0 -_0204AF26: - add sp, #0xc - pop {r4, r5, r6, r7, pc} - .balign 4, 0 - thumb_func_end sub_0204AE20 - - thumb_func_start sub_0204AF2C -sub_0204AF2C: ; 0x0204AF2C - push {r3, r4, lr} - sub sp, #4 - add r4, r0, #0 - ldrb r1, [r4, #0xf] - add r0, sp, #0 - add r2, sp, #0 - strb r1, [r0] - ldr r0, [r4, #0x70] - mov r1, #0 - bl sub_0202D308 - ldrb r1, [r4, #0xc] - add r0, sp, #0 - add r2, sp, #0 - strb r1, [r0] - ldr r0, [r4, #0x70] - mov r1, #1 - bl sub_0202D308 - add r2, r4, #0 - ldr r0, [r4, #0x70] - mov r1, #5 - add r2, #0x2a - bl sub_0202D308 - ldrh r1, [r4, #0x28] - ldrh r2, [r4, #0x24] - ldrh r3, [r4, #0x26] - lsl r1, r1, #0x18 - ldr r0, [r4, #0x70] - lsr r1, r1, #0x18 - bl sub_0202D3B0 - add r2, r4, #0 - ldr r0, [r4, #0x70] - mov r1, #8 - add r2, #0x3e - bl sub_0202D308 - add r2, r4, #0 - ldr r0, [r4, #0x70] - mov r1, #0xa - add r2, #8 - bl sub_0202D308 - ldr r0, [r4, #0x70] - mov r1, #1 - bl sub_0202D3E4 - ldrb r0, [r4, #0xf] - cmp r0, #2 - bne _0204AFD2 - ldrb r0, [r4, #0x10] - add r2, sp, #0 - lsl r0, r0, #0x18 - lsr r1, r0, #0x1d - add r0, sp, #0 - strb r1, [r0] - ldr r0, [r4, #0x70] - mov r1, #9 - bl sub_0202D308 - ldrb r3, [r4, #0x10] - ldr r2, _0204AFD8 ; =0x000007E8 - ldr r0, [r4, #0x70] - lsl r3, r3, #0x18 - lsr r3, r3, #0x1d - add r2, r4, r2 - lsl r3, r3, #4 - mov r1, #6 - add r2, r2, r3 - bl sub_0202D308 - ldr r2, _0204AFDC ; =0x00000838 - ldr r0, [r4, #0x70] - add r3, r4, r2 - ldrb r2, [r4, #0x10] - mov r1, #7 - lsl r2, r2, #0x18 - lsr r2, r2, #0x1d - add r2, r3, r2 - bl sub_0202D308 -_0204AFD2: - add sp, #4 - pop {r3, r4, pc} - nop -_0204AFD8: .word 0x000007E8 -_0204AFDC: .word 0x00000838 - thumb_func_end sub_0204AF2C - - thumb_func_start sub_0204AFE0 -sub_0204AFE0: ; 0x0204AFE0 - push {r3, r4, r5, r6, r7, lr} - sub sp, #0x18 - add r5, r0, #0 - ldr r0, _0204B03C ; =0x000007E8 - mov r4, #0 - add r6, r5, r0 - mov r0, #0xa6 - lsl r0, r0, #2 - add r7, r5, r0 - add r0, r5, #0 - str r0, [sp, #0x10] - add r0, #0x2e - str r0, [sp, #0x10] - add r0, r5, #0 - str r0, [sp, #0x14] - add r0, #0x36 - str r0, [sp, #0x14] -_0204B002: - ldr r0, [sp, #0x10] - mov r2, #0x4b - str r0, [sp] - ldr r0, [sp, #0x14] - lsl r2, r2, #2 - str r0, [sp, #4] - str r6, [sp, #8] - ldr r0, [r5, #4] - add r2, r4, r2 - str r0, [sp, #0xc] - lsl r2, r2, #0x10 - ldrb r3, [r5, #0xe] - add r0, r5, #0 - add r1, r7, #0 - lsr r2, r2, #0x10 - bl sub_0204BA04 - add r2, r5, r4 - ldr r1, _0204B040 ; =0x00000838 - add r4, r4, #1 - strb r0, [r2, r1] - mov r0, #0x11 - lsl r0, r0, #4 - add r6, #0x10 - add r7, r7, r0 - cmp r4, #5 - blt _0204B002 - add sp, #0x18 - pop {r3, r4, r5, r6, r7, pc} - .balign 4, 0 -_0204B03C: .word 0x000007E8 -_0204B040: .word 0x00000838 - thumb_func_end sub_0204AFE0 - - thumb_func_start sub_0204B044 -sub_0204B044: ; 0x0204B044 - lsl r2, r1, #4 - add r1, r1, r2 - lsl r1, r1, #4 - add r0, r0, r1 - add r0, #0x7c - ldrh r0, [r0] - ldr r3, _0204B058 ; =sub_0204B5E8 - lsl r0, r0, #0x18 - lsr r0, r0, #0x18 - bx r3 - .balign 4, 0 -_0204B058: .word sub_0204B5E8 - thumb_func_end sub_0204B044 - - thumb_func_start sub_0204B05C -sub_0204B05C: ; 0x0204B05C - ldrb r0, [r0, #0xf] - bx lr - thumb_func_end sub_0204B05C - - thumb_func_start sub_0204B060 -sub_0204B060: ; 0x0204B060 - ldrb r0, [r0, #0x10] - lsl r0, r0, #0x1d - lsr r0, r0, #0x1e - bx lr - thumb_func_end sub_0204B060 - - thumb_func_start sub_0204B068 -sub_0204B068: ; 0x0204B068 - push {r3, r4, r5, lr} - add r4, r0, #0 - ldrb r1, [r4, #0xf] - cmp r1, #5 - bne _0204B076 - mov r0, #0 - pop {r3, r4, r5, pc} -_0204B076: - cmp r1, #4 - bne _0204B088 - ldr r0, [r4, #0x74] - mov r1, #0 - bl sub_0202D488 - ldr r1, _0204B0D4 ; =_020FBF98 - ldrb r5, [r1, r0] - b _0204B0C6 -_0204B088: - cmp r1, #3 - beq _0204B090 - cmp r1, #6 - bne _0204B0A6 -_0204B090: - ldr r0, [r4, #0x74] - mov r2, #0 - bl sub_0202D57C - cmp r0, #7 - blo _0204B0A0 - mov r5, #0x12 - b _0204B0C6 -_0204B0A0: - ldr r1, _0204B0D8 ; =_020FBF7C - ldrb r5, [r1, r0] - b _0204B0C6 -_0204B0A6: - ldr r0, [r4, #0x74] - mov r2, #0 - bl sub_0202D57C - ldrb r1, [r4, #0x10] - lsl r1, r1, #0x1d - lsr r1, r1, #0x1e - beq _0204B0BA - mov r5, #0x14 - b _0204B0C6 -_0204B0BA: - cmp r0, #7 - blo _0204B0C2 - mov r5, #7 - b _0204B0C6 -_0204B0C2: - ldr r1, _0204B0DC ; =_020FBF84 - ldrb r5, [r1, r0] -_0204B0C6: - ldr r0, [r4, #0x74] - add r1, r5, #0 - mov r2, #5 - bl FrontierData_BattlePointAction - add r0, r5, #0 - pop {r3, r4, r5, pc} - .balign 4, 0 -_0204B0D4: .word _020FBF98 -_0204B0D8: .word _020FBF7C -_0204B0DC: .word _020FBF84 - thumb_func_end sub_0204B068 - - thumb_func_start sub_0204B0E0 -sub_0204B0E0: ; 0x0204B0E0 - push {r4, lr} - add r4, r0, #0 - add r0, r1, #0 - ldrb r1, [r4, #0xf] - bl sub_0204A6F8 - cmp r0, #0x32 - bhs _0204B0F4 - mov r0, #0 - pop {r4, pc} -_0204B0F4: - cmp r0, #0x64 - ldr r0, [r4, #0x74] - blo _0204B10A - mov r1, #1 - mov r2, #0 - bl sub_0202D5DC - cmp r0, #0 - beq _0204B11A - mov r0, #0 - pop {r4, pc} -_0204B10A: - mov r1, #0 - add r2, r1, #0 - bl sub_0202D5DC - cmp r0, #0 - beq _0204B11A - mov r0, #0 - pop {r4, pc} -_0204B11A: - mov r0, #1 - pop {r4, pc} - .balign 4, 0 - thumb_func_end sub_0204B0E0 - - thumb_func_start sub_0204B120 -sub_0204B120: ; 0x0204B120 - push {r4, r5, r6, lr} - add r5, r0, #0 - add r0, r1, #0 - add r4, r2, #0 - bl Save_FrontierData_Get - add r6, r0, #0 - cmp r4, #0 - beq _0204B13C - cmp r4, #1 - beq _0204B144 - cmp r4, #2 - beq _0204B180 - b _0204B1C4 -_0204B13C: - mov r1, #0 - bl sub_0202D488 - pop {r4, r5, r6, pc} -_0204B144: - mov r1, #4 - mov r2, #2 - bl sub_0202D5DC - add r0, r6, #0 - mov r1, #0 - bl sub_0202D488 - add r4, r0, #0 - cmp r4, #0xa - bne _0204B166 - ldrb r1, [r5, #0x10] - mov r0, #0x10 - orr r0, r1 - strb r0, [r5, #0x10] - mov r0, #0 - pop {r4, r5, r6, pc} -_0204B166: - add r0, r6, #0 - mov r1, #3 - bl sub_0202D488 - add r0, r4, #1 - cmp r0, #5 - blt _0204B17C - ldrb r1, [r5, #0x10] - mov r0, #0x10 - orr r0, r1 - strb r0, [r5, #0x10] -_0204B17C: - mov r0, #1 - pop {r4, r5, r6, pc} -_0204B180: - mov r1, #3 - bl sub_0202D450 - add r4, r0, #0 - add r0, r6, #0 - mov r1, #0 - bl sub_0202D488 - cmp r0, #1 - bne _0204B198 - mov r0, #0 - pop {r4, r5, r6, pc} -_0204B198: - sub r1, r0, #1 - ldr r0, _0204B1C8 ; =_020FBF8C - ldrb r0, [r0, r1] - cmp r4, r0 - blo _0204B1C0 - add r0, r6, #0 - mov r1, #4 - bl sub_0202D488 - add r0, r6, #0 - mov r1, #2 - bl sub_0202D450 - add r0, r6, #0 - mov r1, #4 - mov r2, #2 - bl sub_0202D5DC - mov r0, #1 - pop {r4, r5, r6, pc} -_0204B1C0: - mov r0, #0 - pop {r4, r5, r6, pc} -_0204B1C4: - mov r0, #0 - pop {r4, r5, r6, pc} - .balign 4, 0 -_0204B1C8: .word _020FBF8C - thumb_func_end sub_0204B120 - - thumb_func_start sub_0204B1CC -sub_0204B1CC: ; 0x0204B1CC - push {r3, lr} - add r2, r0, #0 - ldrb r0, [r2, #0xf] - cmp r0, #0 - beq _0204B1DA - mov r0, #0 - pop {r3, pc} -_0204B1DA: - ldrb r0, [r2, #0x10] - lsl r0, r0, #0x1d - lsr r0, r0, #0x1e - cmp r0, #1 - beq _0204B1EA - cmp r0, #2 - beq _0204B1F4 - b _0204B1FE -_0204B1EA: - add r0, r1, #0 - mov r1, #0x1a - bl sub_0204B2B8 - pop {r3, pc} -_0204B1F4: - add r0, r1, #0 - mov r1, #0x1b - bl sub_0204B2B8 - pop {r3, pc} -_0204B1FE: - mov r0, #0 - pop {r3, pc} - .balign 4, 0 - thumb_func_end sub_0204B1CC - - thumb_func_start sub_0204B204 -sub_0204B204: ; 0x0204B204 - push {r4, lr} - add r2, r0, #0 - ldrb r0, [r2, #0xf] - cmp r0, #5 - bne _0204B212 - mov r0, #0 - pop {r4, pc} -_0204B212: - cmp r0, #6 - bne _0204B21A - mov r0, #0 - pop {r4, pc} -_0204B21A: - ldrb r4, [r2, #0x10] - lsl r4, r4, #0x1b - lsr r4, r4, #0x1f - bne _0204B226 - mov r0, #0 - pop {r4, pc} -_0204B226: - cmp r0, #4 - bhi _0204B24E - add r0, r0, r0 - add r0, pc - ldrh r0, [r0, #6] - lsl r0, r0, #0x10 - asr r0, r0, #0x10 - add pc, r0 -_0204B236: ; jump table - .short _0204B24E - _0204B236 - 2 ; case 0 - .short _0204B240 - _0204B236 - 2 ; case 1 - .short _0204B244 - _0204B236 - 2 ; case 2 - .short _0204B248 - _0204B236 - 2 ; case 3 - .short _0204B24C - _0204B236 - 2 ; case 4 -_0204B240: - mov r3, #0x1c - b _0204B24E -_0204B244: - mov r3, #0x1d - b _0204B24E -_0204B248: - mov r3, #0x1e - b _0204B24E -_0204B24C: - mov r3, #0x1f -_0204B24E: - add r0, r1, #0 - add r1, r3, #0 - bl sub_0204B2B8 - pop {r4, pc} - thumb_func_end sub_0204B204 - - thumb_func_start sub_0204B258 -sub_0204B258: ; 0x0204B258 - push {r4, r5, r6, lr} - add r5, r0, #0 - add r4, r1, #0 - ldrb r1, [r5, #0xf] - cmp r1, #6 - bne _0204B27E - add r0, r4, #0 - bl sub_0203107C - add r6, r0, #0 - mov r0, #0x64 - bl sub_0205C268 - add r2, r0, #0 - add r0, r6, #0 - mov r1, #0x64 - bl sub_020310BC - b _0204B28C -_0204B27E: - add r1, #8 - lsl r1, r1, #0x10 - ldr r0, [r5, #0x74] - lsr r1, r1, #0x10 - mov r2, #0 - bl sub_0202D5DC -_0204B28C: - lsl r0, r0, #0x18 - lsr r0, r0, #0x18 - cmp r0, #0 - bne _0204B29C - add r0, r4, #0 - bl sub_020674E0 - b _0204B2A2 -_0204B29C: - add r0, r4, #0 - bl sub_0206751C -_0204B2A2: - str r0, [r5, #8] - ldr r0, [r5, #8] - ldr r1, _0204B2B4 ; =0x0000FFFF - bl _u32_div_f - lsl r0, r0, #0x10 - lsr r0, r0, #0x10 - pop {r4, r5, r6, pc} - nop -_0204B2B4: .word 0x0000FFFF - thumb_func_end sub_0204B258 - - thumb_func_start sub_0204B2B8 -sub_0204B2B8: ; 0x0204B2B8 - push {r4, r5, r6, r7, lr} - sub sp, #0xc - add r6, r1, #0 - add r5, r2, #0 - mov r2, #1 - add r1, sp, #8 - strb r2, [r1] - bl SaveArray_Party_Get - str r0, [sp] - mov r7, #0 - ldrb r0, [r5, #0xe] - add r4, r7, #0 - cmp r0, #0 - ble _0204B308 -_0204B2D6: - add r1, r5, r4 - add r1, #0x2a - ldrb r1, [r1] - ldr r0, [sp] - bl Party_GetMonByIndex - add r1, r6, #0 - mov r2, #0 - str r0, [sp, #4] - bl GetMonData - cmp r0, #0 - bne _0204B300 - ldr r0, [sp, #4] - add r1, r6, #0 - add r2, sp, #8 - bl SetMonData - add r0, r7, #1 - lsl r0, r0, #0x18 - lsr r7, r0, #0x18 -_0204B300: - ldrb r0, [r5, #0xe] - add r4, r4, #1 - cmp r4, r0 - blt _0204B2D6 -_0204B308: - cmp r7, #0 - bne _0204B312 - add sp, #0xc - mov r0, #0 - pop {r4, r5, r6, r7, pc} -_0204B312: - mov r0, #1 - add sp, #0xc - pop {r4, r5, r6, r7, pc} - thumb_func_end sub_0204B2B8 - - thumb_func_start sub_0204B318 -sub_0204B318: ; 0x0204B318 - ldrb r1, [r0, #0xf] - cmp r1, #5 - beq _0204B32A - cmp r1, #0 - beq _0204B32A - cmp r1, #6 - beq _0204B32A - cmp r1, #4 - bne _0204B32E -_0204B32A: - mov r0, #0 - bx lr -_0204B32E: - ldrh r2, [r0, #0x1a] - ldrb r1, [r0, #0xd] - add r1, r2, r1 - lsl r1, r1, #0x10 - lsr r1, r1, #0x10 - cmp r1, #0x32 - bhs _0204B340 - mov r0, #0 - bx lr -_0204B340: - ldrb r2, [r0, #0x10] - mov r1, #0x10 - orr r1, r2 - strb r1, [r0, #0x10] - mov r0, #1 - bx lr - thumb_func_end sub_0204B318 - - thumb_func_start sub_0204B34C -sub_0204B34C: ; 0x0204B34C - push {r3, r4, r5, r6, r7, lr} - sub sp, #8 - add r5, r1, #0 - str r0, [sp] - add r0, r5, #0 - mov r1, #5 - mov r2, #0 - bl GetMonData - ldr r1, [sp] - lsl r0, r0, #0x10 - ldrh r1, [r1] - ldr r2, _0204B468 ; =0xFFFFF800 - lsr r3, r0, #0x10 - lsr r0, r2, #0x15 - and r1, r2 - and r0, r3 - orr r1, r0 - ldr r0, [sp] - mov r2, #0 - strh r1, [r0] - add r0, r5, #0 - mov r1, #0x70 - bl GetMonData - ldr r1, [sp] - lsl r0, r0, #0x10 - ldrh r2, [r1] - ldr r1, _0204B46C ; =0xFFFF07FF - lsr r0, r0, #0x10 - lsl r0, r0, #0x1b - and r1, r2 - lsr r0, r0, #0x10 - orr r1, r0 - ldr r0, [sp] - mov r2, #0 - strh r1, [r0] - add r0, r5, #0 - mov r1, #6 - bl GetMonData - ldr r1, [sp] - mov r4, #0 - strh r0, [r1, #2] - add r0, r1, #0 - str r0, [sp, #4] - add r0, #0x1e - add r6, r1, #0 - add r7, r4, #0 - str r0, [sp, #4] -_0204B3B0: - add r1, r4, #0 - add r0, r5, #0 - add r1, #0x36 - mov r2, #0 - bl GetMonData - add r1, r4, #0 - strh r0, [r6, #4] - add r0, r5, #0 - add r1, #0x3e - mov r2, #0 - bl GetMonData - ldr r1, [sp, #4] - lsl r0, r7 - ldrb r1, [r1] - add r4, r4, #1 - add r6, r6, #2 - orr r1, r0 - ldr r0, [sp, #4] - add r7, r7, #2 - strb r1, [r0] - cmp r4, #4 - blt _0204B3B0 - add r0, r5, #0 - mov r1, #0xc - mov r2, #0 - bl GetMonData - ldr r1, [sp] - mov r2, #0 - strb r0, [r1, #0x1f] - add r0, r5, #0 - mov r1, #7 - bl GetMonData - ldr r1, [sp] - str r0, [r1, #0xc] - mov r1, #0 - add r0, r5, #0 - add r2, r1, #0 - bl GetMonData - ldr r1, [sp] - mov r2, #0 - str r0, [r1, #0x10] - add r0, r5, #0 - mov r1, #0xaf - bl GetMonData - ldr r1, [sp] - mov r4, #0 - str r0, [r1, #0x14] - add r6, r4, #0 -_0204B41C: - add r1, r4, #0 - add r0, r5, #0 - add r1, #0xd - add r2, r6, #0 - bl GetMonData - ldr r1, [sp] - add r1, r1, r4 - add r4, r4, #1 - strb r0, [r1, #0x18] - cmp r4, #6 - blt _0204B41C - add r0, r5, #0 - mov r1, #0xa - mov r2, #0 - bl GetMonData - ldr r1, [sp] - mov r2, #0 - add r1, #0x20 - strb r0, [r1] - add r0, r5, #0 - mov r1, #9 - bl GetMonData - ldr r1, [sp] - ldr r2, [sp] - add r1, #0x21 - strb r0, [r1] - add r2, #0x22 - add r0, r5, #0 - mov r1, #0x75 - str r2, [sp] - bl GetMonData - add sp, #8 - pop {r3, r4, r5, r6, r7, pc} - nop -_0204B468: .word 0xFFFFF800 -_0204B46C: .word 0xFFFF07FF - thumb_func_end sub_0204B34C - - thumb_func_start sub_0204B470 -sub_0204B470: ; 0x0204B470 - push {r3, r4, r5, r6, r7, lr} - sub sp, #8 - add r6, r0, #0 - ldr r0, [r6, #4] - add r4, r1, #0 - mov r1, #0xa8 - str r2, [sp] - bl AllocFromHeapAtEnd - mov r1, #0 - mov r2, #0xa8 - str r0, [sp, #4] - bl MI_CpuFill8 - add r0, r4, #0 - bl SaveArray_Party_Get - ldr r5, [sp, #4] - add r7, r0, #0 - mov r4, #0 -_0204B498: - add r1, r6, r4 - add r1, #0x2a - ldrb r1, [r1] - add r0, r7, #0 - bl Party_GetMonByIndex - add r1, r0, #0 - add r0, r5, #0 - bl sub_0204B34C - add r4, r4, #1 - add r5, #0x38 - cmp r4, #3 - blt _0204B498 - ldr r0, [r6, #0x74] - ldr r1, [sp] - ldr r2, [sp, #4] - bl sub_0202D4B8 - ldr r0, [sp, #4] - mov r1, #0 - mov r2, #0xa8 - bl MI_CpuFill8 - ldr r0, [sp, #4] - bl FreeToHeap - add sp, #8 - pop {r3, r4, r5, r6, r7, pc} - .balign 4, 0 - thumb_func_end sub_0204B470 - - thumb_func_start sub_0204B4D4 -sub_0204B4D4: ; 0x0204B4D4 - cmp r0, #0x64 - bhs _0204B4DC - mov r0, #3 - bx lr -_0204B4DC: - cmp r0, #0x78 - bhs _0204B4E4 - mov r0, #6 - bx lr -_0204B4E4: - cmp r0, #0x8c - bhs _0204B4EC - mov r0, #9 - bx lr -_0204B4EC: - cmp r0, #0xa0 - bhs _0204B4F4 - mov r0, #0xc - bx lr -_0204B4F4: - cmp r0, #0xb4 - bhs _0204B4FC - mov r0, #0xf - bx lr -_0204B4FC: - cmp r0, #0xc8 - bhs _0204B504 - mov r0, #0x12 - bx lr -_0204B504: - cmp r0, #0xdc - bhs _0204B50C - mov r0, #0x15 - bx lr -_0204B50C: - mov r0, #0x1f - bx lr - thumb_func_end sub_0204B4D4 - - thumb_func_start sub_0204B510 -sub_0204B510: ; 0x0204B510 - push {r4, lr} - add r4, r0, #0 - ldrb r0, [r4, #0xf] - cmp r0, #6 - bne _0204B520 - bl LCRandom - pop {r4, pc} -_0204B520: - ldr r0, [r4, #8] - bl sub_020674A4 - ldr r1, _0204B534 ; =0x0000FFFF - str r0, [r4, #8] - bl _u32_div_f - lsl r0, r0, #0x10 - lsr r0, r0, #0x10 - pop {r4, pc} - .balign 4, 0 -_0204B534: .word 0x0000FFFF - thumb_func_end sub_0204B510 - - thumb_func_start sub_0204B538 -sub_0204B538: ; 0x0204B538 - push {r3, r4, r5, r6, r7, lr} - sub sp, #0x20 - add r4, r0, #0 - add r7, r1, #0 - str r2, [sp, #8] - mov r0, #0xe - mov r1, #4 - str r3, [sp, #0xc] - ldr r5, [sp, #0x38] - bl String_New - add r6, r0, #0 - mov r0, #2 - mov r1, #4 - bl String_New - str r0, [sp, #0x1c] - add r0, r4, #0 - bl Save_Pokedex_Get - str r0, [sp, #0x18] - mov r0, #1 - mov r1, #0x1b - mov r2, #0xed - mov r3, #4 - bl NewMsgDataFromNarc - str r0, [sp, #0x10] - mov r0, #0x13 - mov r1, #0xe - mov r2, #4 - bl MessageFormat_New_Custom - mov r1, #0 - str r1, [sp] - mov r3, #1 - add r2, r7, #0 - str r0, [sp, #0x14] - str r3, [sp, #4] - bl BufferIntegerAsString - mov r4, #0 -_0204B58C: - add r0, r4, #0 - bl GetBannedBattleFrontierPokemon - add r7, r0, #0 - ldr r0, [sp, #0x18] - add r1, r7, #0 - bl Pokedex_CheckMonSeenFlag - cmp r0, #0 - beq _0204B5C6 - ldr r0, [sp, #0x10] - add r1, r7, #0 - add r2, r6, #0 - bl ReadMsgDataIntoString - ldr r0, [sp, #0xc] - add r2, r6, #0 - str r0, [sp] - mov r0, #2 - str r0, [sp, #4] - ldrb r1, [r5] - ldr r0, [sp, #0x14] - ldr r3, [sp, #8] - add r1, r1, #1 - bl BufferString - ldrb r0, [r5] - add r0, r0, #1 - strb r0, [r5] -_0204B5C6: - add r0, r4, #1 - lsl r0, r0, #0x18 - lsr r4, r0, #0x18 - cmp r4, #0x12 - blo _0204B58C - ldr r0, [sp, #0x10] - bl DestroyMsgData - ldr r0, [sp, #0x1c] - bl String_Delete - add r0, r6, #0 - bl String_Delete - ldr r0, [sp, #0x14] - add sp, #0x20 - pop {r3, r4, r5, r6, r7, pc} - thumb_func_end sub_0204B538 - - thumb_func_start sub_0204B5E8 -sub_0204B5E8: ; 0x0204B5E8 - ldr r3, _0204B608 ; =_020FBFEC - mov r2, #0 -_0204B5EC: - ldrh r1, [r3] - cmp r0, r1 - bne _0204B5FA - ldr r0, _0204B60C ; =_020FBFEE - lsl r1, r2, #2 - ldrh r0, [r0, r1] - bx lr -_0204B5FA: - add r2, r2, #1 - add r3, r3, #4 - cmp r2, #0x3f - blo _0204B5EC - mov r0, #3 - bx lr - nop -_0204B608: .word _020FBFEC -_0204B60C: .word _020FBFEE - thumb_func_end sub_0204B5E8 - - thumb_func_start sub_0204B610 -sub_0204B610: ; 0x0204B610 - push {r3, r4} - add r0, #0xa0 - ldr r3, [r0] - ldrh r0, [r1] - mov r2, #0 - strb r0, [r3, #0x12] - ldrh r0, [r1, #2] - strh r0, [r3, #0x16] - ldrh r0, [r1, #4] - strh r0, [r3, #0x18] - ldrh r0, [r1, #6] - mov r1, #0xe0 - strh r0, [r3, #0x14] - ldrb r0, [r3, #0x10] - bic r0, r1 - ldrb r1, [r3, #0x12] - add r1, r1, #5 - lsl r1, r1, #0x18 - lsr r1, r1, #0x18 - lsl r1, r1, #0x1d - lsr r1, r1, #0x18 - orr r0, r1 - strb r0, [r3, #0x10] - ldrh r4, [r3, #0x16] - ldrh r1, [r3, #0x2e] - cmp r1, r4 - beq _0204B64C - ldrh r0, [r3, #0x18] - cmp r1, r0 - bne _0204B652 -_0204B64C: - add r0, r2, #1 - lsl r0, r0, #0x10 - lsr r2, r0, #0x10 -_0204B652: - ldrh r1, [r3, #0x30] - cmp r1, r4 - beq _0204B65E - ldrh r0, [r3, #0x18] - cmp r1, r0 - bne _0204B664 -_0204B65E: - add r0, r2, #2 - lsl r0, r0, #0x10 - lsr r2, r0, #0x10 -_0204B664: - add r0, r2, #0 - pop {r3, r4} - bx lr - .balign 4, 0 - thumb_func_end sub_0204B610 - - thumb_func_start sub_0204B66C -sub_0204B66C: ; 0x0204B66C - push {r3, r4, r5, lr} - add r0, #0xa0 - add r5, r1, #0 - ldr r4, [r0] - bl sub_0203769C - cmp r0, #0 - bne _0204B680 - mov r0, #0 - pop {r3, r4, r5, pc} -_0204B680: - add r4, #0x3e - add r0, r5, #0 - add r1, r4, #0 - mov r2, #0x1c - bl MI_CpuCopy8 - mov r0, #1 - pop {r3, r4, r5, pc} - thumb_func_end sub_0204B66C - - thumb_func_start sub_0204B690 -sub_0204B690: ; 0x0204B690 - add r0, #0xa0 - ldr r0, [r0] - ldrb r0, [r0, #0x10] - lsl r0, r0, #0x1c - lsr r0, r0, #0x1f - bne _0204B6A2 - ldrh r0, [r1] - cmp r0, #0 - beq _0204B6A6 -_0204B6A2: - mov r0, #1 - bx lr -_0204B6A6: - mov r0, #0 - bx lr - .balign 4, 0 - thumb_func_end sub_0204B690 - - thumb_func_start sub_0204B6AC -sub_0204B6AC: ; 0x0204B6AC - push {r3, r4, r5, r6, r7, lr} - add r4, r1, #0 - add r6, r0, #0 - add r0, r4, #0 - bl Save_PlayerData_GetProfileAddr - bl PlayerProfile_GetTrainerGender - ldr r1, _0204B700 ; =0x0000083E - strh r0, [r6, r1] - add r0, r4, #0 - bl SaveArray_Party_Get - add r7, r0, #0 - mov r4, #0 - add r5, r6, #0 -_0204B6CC: - add r1, r6, r4 - add r1, #0x2a - ldrb r1, [r1] - add r0, r7, #0 - bl Party_GetMonByIndex - mov r1, #5 - mov r2, #0 - bl GetMonData - mov r1, #0x21 - lsl r1, r1, #6 - strh r0, [r5, r1] - add r4, r4, #1 - add r5, r5, #2 - cmp r4, #2 - blt _0204B6CC - ldr r0, [r6, #0x74] - mov r1, #3 - mov r2, #0 - bl sub_0202D57C - ldr r1, _0204B704 ; =0x00000844 - strh r0, [r6, r1] - pop {r3, r4, r5, r6, r7, pc} - nop -_0204B700: .word 0x0000083E -_0204B704: .word 0x00000844 - thumb_func_end sub_0204B6AC - - thumb_func_start sub_0204B708 -sub_0204B708: ; 0x0204B708 - ldr r1, _0204B718 ; =0x0000083E - add r2, r0, #0 - add r1, r2, r1 - ldr r3, _0204B71C ; =MI_CpuCopy8 - add r0, #0x3e - mov r2, #0x1c - bx r3 - nop -_0204B718: .word 0x0000083E -_0204B71C: .word MI_CpuCopy8 - thumb_func_end sub_0204B708 - - thumb_func_start sub_0204B720 -sub_0204B720: ; 0x0204B720 - ldrb r3, [r0, #0x10] - mov r2, #8 - bic r3, r2 - lsl r2, r1, #0x18 - lsr r2, r2, #0x18 - lsl r2, r2, #0x1f - lsr r2, r2, #0x1c - orr r2, r3 - strb r2, [r0, #0x10] - ldr r2, _0204B738 ; =0x0000083E - strh r1, [r0, r2] - bx lr - .balign 4, 0 -_0204B738: .word 0x0000083E - thumb_func_end sub_0204B720 - - thumb_func_start sub_0204B73C -sub_0204B73C: ; 0x0204B73C - push {r3, r4, r5, lr} - cmp r3, #0 - bne _0204B75A - cmp r1, #2 - bne _0204B74E - cmp r2, #6 - bne _0204B74E - ldr r0, _0204B7B8 ; =0x00000131 - pop {r3, r4, r5, pc} -_0204B74E: - cmp r1, #6 - bne _0204B75A - cmp r2, #6 - bne _0204B75A - ldr r0, _0204B7BC ; =0x00000132 - pop {r3, r4, r5, pc} -_0204B75A: - cmp r1, #7 - bhs _0204B7A6 - cmp r2, #6 - bne _0204B784 - lsl r5, r1, #2 - ldr r1, _0204B7C0 ; =_020FBFCC - ldrh r4, [r1, r5] - bl sub_0204B510 - ldr r1, _0204B7C4 ; =_020FBFCE - ldrh r1, [r1, r5] - sub r1, r1, r4 - add r1, r1, #1 - lsl r1, r1, #0x10 - lsr r1, r1, #0x10 - bl _s32_div_f - add r0, r4, r1 - lsl r0, r0, #0x10 - lsr r0, r0, #0x10 - pop {r3, r4, r5, pc} -_0204B784: - lsl r4, r1, #2 - ldr r1, _0204B7C8 ; =_020FBFAC - ldrh r5, [r1, r4] - bl sub_0204B510 - ldr r1, _0204B7CC ; =_020FBFAE - ldrh r1, [r1, r4] - sub r1, r1, r5 - add r1, r1, #1 - lsl r1, r1, #0x10 - lsr r1, r1, #0x10 - bl _s32_div_f - add r0, r5, r1 - lsl r0, r0, #0x10 - lsr r0, r0, #0x10 - pop {r3, r4, r5, pc} -_0204B7A6: - bl sub_0204B510 - mov r1, #0x64 - bl _s32_div_f - add r1, #0xc8 - lsl r0, r1, #0x10 - lsr r0, r0, #0x10 - pop {r3, r4, r5, pc} - .balign 4, 0 -_0204B7B8: .word 0x00000131 -_0204B7BC: .word 0x00000132 -_0204B7C0: .word _020FBFCC -_0204B7C4: .word _020FBFCE -_0204B7C8: .word _020FBFAC -_0204B7CC: .word _020FBFAE - thumb_func_end sub_0204B73C - - thumb_func_start sub_0204B7D0 -sub_0204B7D0: ; 0x0204B7D0 - push {r3, r4, r5, r6, r7, lr} - add r4, r1, #0 - add r6, r2, #0 - mov r1, #0x1b - add r5, r0, #0 - mov r0, #1 - add r2, r1, #0 - add r3, r6, #0 - bl NewMsgDataFromNarc - mov r2, #0x11 - add r7, r0, #0 - add r0, r5, #0 - mov r1, #0 - lsl r2, r2, #4 - bl MI_CpuFill8 - add r0, r4, #0 - add r1, r6, #0 - bl sub_0204BC7C - add r6, r0, #0 - ldr r0, _0204B830 ; =0x0000FFFF - str r4, [r5] - strh r0, [r5, #0x18] - lsl r0, r4, #1 - add r0, r4, r0 - strh r0, [r5, #0x1a] - ldrh r0, [r6] - add r1, r4, #0 - strh r0, [r5, #4] - add r0, r7, #0 - bl NewString_ReadMsgData - add r5, #8 - add r4, r0, #0 - add r1, r5, #0 - mov r2, #8 - bl CopyStringToU16Array - add r0, r4, #0 - bl String_Delete - add r0, r7, #0 - bl DestroyMsgData - add r0, r6, #0 - pop {r3, r4, r5, r6, r7, pc} - .balign 4, 0 -_0204B830: .word 0x0000FFFF - thumb_func_end sub_0204B7D0 - - thumb_func_start sub_0204B834 -sub_0204B834: ; 0x0204B834 - push {r3, r4, r5, r6, r7, lr} - sub sp, #0x18 - add r5, r1, #0 - add r4, r0, #0 - add r6, r2, #0 - add r0, r5, #0 - mov r1, #0 - mov r2, #0x38 - str r3, [sp] - bl MI_CpuFill8 - add r0, sp, #8 - add r1, r6, #0 - bl sub_0204BC8C - add r2, sp, #8 - ldrh r0, [r5] - ldr r1, _0204B9DC ; =0xFFFFF800 - ldrh r3, [r2] - and r0, r1 - lsr r1, r1, #0x15 - and r1, r3 - orr r0, r1 - strh r0, [r5] - ldrh r1, [r5] - ldr r0, _0204B9E0 ; =0xFFFF07FF - and r1, r0 - ldrh r0, [r2, #0xe] - lsl r0, r0, #0x1b - lsr r0, r0, #0x10 - orr r0, r1 - strh r0, [r5] - ldr r0, [sp, #0x3c] - cmp r0, #0 - beq _0204B886 - add r0, sp, #0x20 - ldrb r0, [r0, #0x18] - lsl r1, r0, #1 - ldr r0, _0204B9E4 ; =_020FBFA4 - ldrh r0, [r0, r1] - b _0204B888 -_0204B886: - ldrh r0, [r2, #0xc] -_0204B888: - strh r0, [r5, #2] - mov r0, #0xff - str r0, [sp, #4] - mov r0, #0 - add r1, sp, #8 - add r2, r5, #0 - add r3, r0, #0 -_0204B896: - ldrh r6, [r1, #2] - strh r6, [r2, #4] - ldrh r6, [r1, #2] - cmp r6, #0xda - bne _0204B8A2 - str r3, [sp, #4] -_0204B8A2: - add r0, r0, #1 - add r1, r1, #2 - add r2, r2, #2 - cmp r0, #4 - blt _0204B896 - ldr r0, [sp] - ldr r7, [sp, #0x30] - str r0, [r5, #0xc] - cmp r7, #0 - bne _0204B8E8 -_0204B8B6: - add r0, r4, #0 - bl sub_0204B510 - add r6, r0, #0 - add r0, r4, #0 - bl sub_0204B510 - lsl r0, r0, #0x10 - add r7, r6, #0 - orr r7, r0 - add r0, r7, #0 - bl GetNatureFromPersonality - add r1, sp, #8 - ldrb r1, [r1, #0xb] - cmp r1, r0 - bne _0204B8B6 - ldr r0, [sp] - add r1, r7, #0 - bl CalcShininessByOtIdAndPersonality - cmp r0, #1 - beq _0204B8B6 - str r7, [r5, #0x10] - b _0204B8EA -_0204B8E8: - str r7, [r5, #0x10] -_0204B8EA: - add r0, sp, #0x20 - ldrb r1, [r0, #0x14] - ldr r2, [r5, #0x14] - mov r0, #0x1f - bic r2, r0 - mov r0, #0x1f - and r0, r1 - orr r2, r0 - ldr r0, _0204B9E8 ; =0xFFFFFC1F - mov r6, #0 - and r2, r0 - lsl r0, r1, #0x1b - lsr r1, r0, #0x16 - orr r2, r1 - ldr r1, _0204B9EC ; =0xFFFF83FF - add r4, r6, #0 - and r2, r1 - lsr r1, r0, #0x11 - orr r2, r1 - ldr r1, _0204B9F0 ; =0xFFF07FFF - and r2, r1 - lsr r1, r0, #0xc - orr r2, r1 - ldr r1, _0204B9F4 ; =0xFE0FFFFF - and r2, r1 - lsr r1, r0, #7 - orr r2, r1 - ldr r1, _0204B9F8 ; =0xC1FFFFFF - lsr r0, r0, #2 - and r1, r2 - orr r0, r1 - str r0, [r5, #0x14] -_0204B92A: - add r0, r4, #0 - bl MaskOfFlagNo - add r1, sp, #8 - ldrb r1, [r1, #0xa] - tst r0, r1 - beq _0204B93A - add r6, r6, #1 -_0204B93A: - add r4, r4, #1 - cmp r4, #6 - blt _0204B92A - ldr r0, _0204B9FC ; =0x000001FE - add r1, r6, #0 - bl _s32_div_f - cmp r0, #0xff - ble _0204B94E - mov r0, #0xff -_0204B94E: - lsl r0, r0, #0x18 - mov r4, #0 - lsr r6, r0, #0x18 -_0204B954: - add r0, r4, #0 - bl MaskOfFlagNo - add r1, sp, #8 - ldrb r1, [r1, #0xa] - tst r0, r1 - beq _0204B966 - add r0, r5, r4 - strb r6, [r0, #0x18] -_0204B966: - add r4, r4, #1 - cmp r4, #6 - blt _0204B954 - mov r0, #0 - strb r0, [r5, #0x1e] - ldr r0, _0204BA00 ; =gGameLanguage - mov r1, #0x19 - ldrb r0, [r0] - strb r0, [r5, #0x1f] - ldrh r0, [r5] - lsl r0, r0, #0x15 - lsr r0, r0, #0x15 - bl GetMonBaseStat - cmp r0, #0 - beq _0204B9AA - ldr r2, [r5, #0x10] - mov r1, #1 - tst r1, r2 - beq _0204B996 - add r1, r5, #0 - add r1, #0x20 - strb r0, [r1] - b _0204B9BC -_0204B996: - ldrh r0, [r5] - mov r1, #0x18 - lsl r0, r0, #0x15 - lsr r0, r0, #0x15 - bl GetMonBaseStat - add r1, r5, #0 - add r1, #0x20 - strb r0, [r1] - b _0204B9BC -_0204B9AA: - ldrh r0, [r5] - mov r1, #0x18 - lsl r0, r0, #0x15 - lsr r0, r0, #0x15 - bl GetMonBaseStat - add r1, r5, #0 - add r1, #0x20 - strb r0, [r1] -_0204B9BC: - add r1, r5, #0 - ldr r0, [sp, #4] - add r1, #0x21 - strb r0, [r1] - ldrh r0, [r5] - add r5, #0x22 - ldr r1, [sp, #0x40] - lsl r0, r0, #0x15 - lsr r0, r0, #0x15 - add r2, r5, #0 - bl GetSpeciesNameIntoArray - add r0, r7, #0 - add sp, #0x18 - pop {r3, r4, r5, r6, r7, pc} - nop -_0204B9DC: .word 0xFFFFF800 -_0204B9E0: .word 0xFFFF07FF -_0204B9E4: .word _020FBFA4 -_0204B9E8: .word 0xFFFFFC1F -_0204B9EC: .word 0xFFFF83FF -_0204B9F0: .word 0xFFF07FFF -_0204B9F4: .word 0xFE0FFFFF -_0204B9F8: .word 0xC1FFFFFF -_0204B9FC: .word 0x000001FE -_0204BA00: .word gGameLanguage - thumb_func_end sub_0204B834 - - thumb_func_start sub_0204BA04 -sub_0204BA04: ; 0x0204BA04 - push {r3, r4, r5, r6, r7, lr} - sub sp, #0x18 - add r4, r2, #0 - add r5, r1, #0 - str r0, [sp, #0x14] - ldr r2, [sp, #0x3c] - add r6, r3, #0 - add r0, r5, #0 - add r1, r4, #0 - bl sub_0204B7D0 - add r7, r0, #0 - lsl r0, r6, #0x18 - lsr r0, r0, #0x18 - str r0, [sp] - ldr r0, [sp, #0x30] - add r5, #0x30 - str r0, [sp, #4] - ldr r0, [sp, #0x34] - add r1, r7, #0 - str r0, [sp, #8] - ldr r0, [sp, #0x38] - add r2, r4, #0 - str r0, [sp, #0xc] - ldr r0, [sp, #0x3c] - add r3, r5, #0 - str r0, [sp, #0x10] - ldr r0, [sp, #0x14] - bl sub_0204BABC - add r4, r0, #0 - add r0, r7, #0 - bl FreeToHeap - add r0, r4, #0 - add sp, #0x18 - pop {r3, r4, r5, r6, r7, pc} - .balign 4, 0 - thumb_func_end sub_0204BA04 - - thumb_func_start sub_0204BA50 -sub_0204BA50: ; 0x0204BA50 - push {r4, r5, r6, r7, lr} - sub sp, #0x24 - str r0, [sp, #0x14] - ldr r0, [sp, #0x38] - add r5, r1, #0 - str r0, [sp, #0x38] - ldr r0, [sp, #0x3c] - add r4, r2, #0 - str r0, [sp, #0x3c] - ldr r2, [sp, #0x3c] - add r0, r5, #0 - add r1, r4, #0 - str r3, [sp, #0x18] - bl sub_0204B7D0 - str r0, [sp, #0x1c] - add r0, r4, #0 - bl sub_0204B4D4 - ldr r6, [sp, #0x38] - str r0, [sp, #0x20] - mov r7, #0 - add r4, r6, #0 - add r5, #0x30 -_0204BA80: - ldr r0, [r6, #8] - ldr r3, [sp, #0x38] - str r0, [sp] - ldr r0, [sp, #0x20] - add r1, r5, #0 - str r0, [sp, #4] - lsl r0, r7, #0x18 - lsr r0, r0, #0x18 - str r0, [sp, #8] - ldr r0, [sp, #0x18] - str r0, [sp, #0xc] - ldr r0, [sp, #0x3c] - str r0, [sp, #0x10] - ldrh r2, [r4, #4] - ldr r0, [sp, #0x14] - ldr r3, [r3] - bl sub_0204B834 - add r7, r7, #1 - add r6, r6, #4 - add r4, r4, #2 - add r5, #0x38 - cmp r7, #2 - blt _0204BA80 - ldr r0, [sp, #0x1c] - bl FreeToHeap - add sp, #0x24 - pop {r4, r5, r6, r7, pc} - .balign 4, 0 - thumb_func_end sub_0204BA50 - - thumb_func_start sub_0204BABC -sub_0204BABC: ; 0x0204BABC - push {r4, r5, r6, r7, lr} - sub sp, #0x7c - str r0, [sp, #0x14] - ldr r0, [sp, #0x94] - str r2, [sp, #0x1c] - str r0, [sp, #0x94] - ldr r0, [sp, #0x98] - str r1, [sp, #0x18] - str r0, [sp, #0x98] - ldr r0, [sp, #0x9c] - str r3, [sp, #0x20] - str r0, [sp, #0x9c] - ldr r0, [sp, #0xa0] - str r0, [sp, #0xa0] - mov r0, #0 - str r0, [sp, #0x28] - add r0, sp, #0x80 - ldrb r0, [r0, #0x10] - cmp r0, #4 - bls _0204BAE8 - bl GF_AssertFail -_0204BAE8: - add r0, sp, #0x80 - ldrb r6, [r0, #0x10] - mov r4, #0 - str r4, [sp, #0x2c] - cmp r6, #0 - beq _0204BBDA - add r0, sp, #0x6c - str r0, [sp, #0x24] -_0204BAF8: - ldr r0, [sp, #0x14] - bl sub_0204B510 - ldr r1, [sp, #0x18] - ldrh r1, [r1, #2] - bl _s32_div_f - lsl r0, r1, #0x18 - lsr r1, r0, #0x17 - ldr r0, [sp, #0x18] - add r0, r0, r1 - ldrh r0, [r0, #4] - str r0, [sp, #0x30] - ldr r1, [sp, #0x30] - add r0, sp, #0x3c - bl sub_0204BC8C - mov r7, #0 - cmp r4, #0 - ble _0204BB3C - add r5, sp, #0x6c -_0204BB22: - ldr r1, [r5] - add r0, sp, #0x4c - bl sub_0204BC8C - add r0, sp, #0x3c - ldrh r1, [r0, #0x10] - ldrh r0, [r0] - cmp r1, r0 - beq _0204BB3C - add r7, r7, #1 - add r5, r5, #4 - cmp r7, r4 - blt _0204BB22 -_0204BB3C: - cmp r7, r4 - bne _0204BBD6 - ldr r0, [sp, #0x94] - cmp r0, #0 - beq _0204BB64 - mov r3, #0 - cmp r6, #0 - ble _0204BB60 - add r1, r0, #0 - add r0, sp, #0x3c - ldrh r2, [r0] -_0204BB52: - ldrh r0, [r1] - cmp r2, r0 - beq _0204BB60 - add r3, r3, #1 - add r1, r1, #2 - cmp r3, r6 - blt _0204BB52 -_0204BB60: - cmp r3, r6 - bne _0204BBD6 -_0204BB64: - ldr r0, [sp, #0x2c] - cmp r0, #0x32 - bge _0204BBCC - mov r7, #0 - cmp r4, #0 - ble _0204BB90 - add r5, sp, #0x6c -_0204BB72: - ldr r1, [r5] - add r0, sp, #0x4c - bl sub_0204BC8C - add r0, sp, #0x3c - ldrh r1, [r0, #0x1c] - cmp r1, #0 - beq _0204BB88 - ldrh r0, [r0, #0xc] - cmp r1, r0 - beq _0204BB90 -_0204BB88: - add r7, r7, #1 - add r5, r5, #4 - cmp r7, r4 - blt _0204BB72 -_0204BB90: - cmp r7, r4 - beq _0204BB9C - ldr r0, [sp, #0x2c] - add r0, r0, #1 - str r0, [sp, #0x2c] - b _0204BBD6 -_0204BB9C: - ldr r0, [sp, #0x98] - cmp r0, #0 - beq _0204BBCC - mov r3, #0 - cmp r6, #0 - ble _0204BBC0 - add r1, r0, #0 - add r0, sp, #0x3c - ldrh r2, [r0, #0xc] -_0204BBAE: - ldrh r0, [r1] - cmp r2, r0 - bne _0204BBB8 - cmp r0, #0 - bne _0204BBC0 -_0204BBB8: - add r3, r3, #1 - add r1, r1, #2 - cmp r3, r6 - blt _0204BBAE -_0204BBC0: - cmp r3, r6 - beq _0204BBCC - ldr r0, [sp, #0x2c] - add r0, r0, #1 - str r0, [sp, #0x2c] - b _0204BBD6 -_0204BBCC: - ldr r1, [sp, #0x30] - ldr r0, [sp, #0x24] - add r4, r4, #1 - stmia r0!, {r1} - str r0, [sp, #0x24] -_0204BBD6: - cmp r4, r6 - bne _0204BAF8 -_0204BBDA: - ldr r0, [sp, #0x1c] - bl sub_0204B4D4 - str r0, [sp, #0x38] - ldr r0, [sp, #0x14] - bl sub_0204B510 - add r5, r0, #0 - ldr r0, [sp, #0x14] - bl sub_0204B510 - lsl r0, r0, #0x10 - orr r0, r5 - str r0, [sp, #0x34] - ldr r0, [sp, #0x2c] - cmp r0, #0x32 - blt _0204BC00 - mov r0, #1 - str r0, [sp, #0x28] -_0204BC00: - mov r5, #0 - cmp r4, #0 - ble _0204BC40 - add r7, sp, #0x6c - add r6, sp, #0x5c -_0204BC0A: - mov r0, #0 - str r0, [sp] - ldr r0, [sp, #0x38] - ldr r1, [sp, #0x20] - str r0, [sp, #4] - lsl r0, r5, #0x18 - lsr r0, r0, #0x18 - str r0, [sp, #8] - ldr r0, [sp, #0x28] - ldr r3, [sp, #0x34] - str r0, [sp, #0xc] - ldr r0, [sp, #0xa0] - str r0, [sp, #0x10] - ldr r2, [r7] - ldr r0, [sp, #0x14] - lsl r2, r2, #0x10 - lsr r2, r2, #0x10 - bl sub_0204B834 - stmia r6!, {r0} - ldr r0, [sp, #0x20] - add r5, r5, #1 - add r0, #0x38 - add r7, r7, #4 - str r0, [sp, #0x20] - cmp r5, r4 - blt _0204BC0A -_0204BC40: - ldr r0, [sp, #0x9c] - cmp r0, #0 - bne _0204BC4C - ldr r0, [sp, #0x28] - add sp, #0x7c - pop {r4, r5, r6, r7, pc} -_0204BC4C: - ldr r1, [sp, #0x34] - ldr r2, [sp, #0x9c] - str r1, [r0] - mov r3, #0 - add r0, sp, #0x6c - add r1, sp, #0x5c -_0204BC58: - ldr r5, [r0] - ldr r4, [sp, #0x9c] - add r3, r3, #1 - strh r5, [r4, #4] - ldr r4, [r1] - add r0, r0, #4 - str r4, [r2, #8] - ldr r4, [sp, #0x9c] - add r1, r1, #4 - add r4, r4, #2 - add r2, r2, #4 - str r4, [sp, #0x9c] - cmp r3, #2 - blt _0204BC58 - ldr r0, [sp, #0x28] - add sp, #0x7c - pop {r4, r5, r6, r7, pc} - .balign 4, 0 - thumb_func_end sub_0204BABC - - thumb_func_start sub_0204BC7C -sub_0204BC7C: ; 0x0204BC7C - add r3, r0, #0 - add r2, r1, #0 - add r1, r3, #0 - ldr r3, _0204BC88 ; =AllocAndReadWholeNarcMemberByIdPair - mov r0, #0xcc - bx r3 - .balign 4, 0 -_0204BC88: .word AllocAndReadWholeNarcMemberByIdPair - thumb_func_end sub_0204BC7C - - thumb_func_start sub_0204BC8C -sub_0204BC8C: ; 0x0204BC8C - ldr r3, _0204BC94 ; =ReadWholeNarcMemberByIdPair - add r2, r1, #0 - mov r1, #0xcd - bx r3 - .balign 4, 0 -_0204BC94: .word ReadWholeNarcMemberByIdPair - thumb_func_end sub_0204BC8C diff --git a/include/constants/game_stats.h b/include/constants/game_stats.h index d16ed6d210..c43bd07a4d 100644 --- a/include/constants/game_stats.h +++ b/include/constants/game_stats.h @@ -11,12 +11,16 @@ #define GAME_STAT_UNK10 10 #define GAME_STAT_UNK11 11 #define GAME_STAT_UNK12 12 +#define GAME_STAT_UNK14 14 +#define GAME_STAT_UNK16 16 #define GAME_STAT_UNK17 17 #define GAME_STAT_UNK20 20 #define GAME_STAT_UNK21 21 //link battles? #define GAME_STAT_BADGE_GET 22 #define GAME_STAT_UNK26 26 +#define GAME_STAT_UNK30 30 #define GAME_STAT_UNK46 46 #define GAME_STAT_BATTLE_POINTS 69 +#define GAME_STAT_UNK70 70 #endif //POKEHEARTGOLD_CONSTANTS_GAME_STATS_H diff --git a/include/field_system.h b/include/field_system.h index d7492fa2ef..1a2d0211d5 100644 --- a/include/field_system.h +++ b/include/field_system.h @@ -10,6 +10,7 @@ #include "unk_0200E320.h" #include "camera.h" #include "bg_window.h" +#include "scrcmd_9.h" typedef struct FieldSystem FieldSystem; typedef struct TaskManager TaskManager; @@ -145,7 +146,7 @@ struct FieldSystem { void *unk94; u8 filler_98[0x4]; void *unk9C; - void *unkA0; + UnkStruct_Fsys_A0 *unkA0; void * unkA4; u32 *unkA8; u32 unkAC; diff --git a/include/pokemon.h b/include/pokemon.h index c396d7c114..ff77807f8d 100644 --- a/include/pokemon.h +++ b/include/pokemon.h @@ -27,6 +27,8 @@ #define MOVE_APPEND_FULL 0xFFFFu #define MOVE_APPEND_KNOWN 0xFFFEu +#define NUM_BANNED_BATTLE_FRONTIER 18 + extern const s8 gNatureStatMods[NATURE_NUM][NUM_EV_STATS]; void ZeroMonData(Pokemon *mon); diff --git a/include/scrcmd_9.h b/include/scrcmd_9.h index 878a9b5a97..891335df3c 100644 --- a/include/scrcmd_9.h +++ b/include/scrcmd_9.h @@ -1,7 +1,100 @@ #ifndef POKEHEARTGOLD_SCRCMD_9_H #define POKEHEARTGOLD_SCRCMD_9_H -u32 sub_0204A5B0(u32, SaveData*, u32); +#include "frontier_data.h" +#include "save.h" -#endif //POKEHEARTGOLD_SCRCMD_9_H +typedef struct UnkStruct_0204B470 { + u16 species:11; + u16 form:5; + u16 item; + u16 moves[4]; + u32 otId; + u32 pid; + union { + struct { + u32 hpIv:5; + u32 atkIv:5; + u32 defIv:5; + u32 spdIv:5; + u32 spAtkIv:5; + u32 spDefIv:5; + u32 dummy:2; + }; + u32 ivsWord; + }; + u8 evs[6]; + u8 ppUp; + u8 language; + u8 ability; + u8 friendship; + u16 nickname[11]; +} UnkStruct_0204B470; + +typedef struct UnkStruct_0204B7D0 { + u32 unk00; + u16 unk04; + u8 filler06[2]; + u16 unk08[8]; + u16 unk18; + u16 unk1a; + u8 filler1c[0x14]; + UnkStruct_0204B470 unk30[2]; + u8 fillera0[0x70]; +} UnkStruct_0204B7D0; + +typedef struct UnkStruct_0204A824_7E8 { + u32 otId; + u16 unk04[2]; + u32 unk08[2]; +} UnkStruct_0204A824_7E8; +typedef struct UnkStruct_Fsys_A0 { + u32 unk00; + HeapID heapId; + u32 unk08; + u8 unk0c; + u8 unk0d; + u8 unk0e; + u8 unk0f; + u8 unk10_0:1; + u8 unk10_1:2; + u8 unk10_3:1; + u8 unk10_4:1; + u8 unk10_5:3; + u8 unk11; + u8 unk12; + u8 filler13; + u16 unk14; + u16 unk16; + u16 unk18; + u16 unk1a; + u16 unk1c; + u8 filler1e[2]; + u32 unk20; + u16 unk24; + u16 unk26; + u16 unk28; + u8 unk2a[4]; + u16 unk2e[4]; + u16 unk36[4]; + u16 unk3e[0xe]; + u8 filler5a[0x13]; + u32 unk70; + FRONTIERDATA *unk74; + UnkStruct_0204B7D0 unk78[2]; + UnkStruct_0204B7D0 unk298[5]; + UnkStruct_0204A824_7E8 unk7e8[5]; + u8 unk838[5]; + u8 filler83d; + u16 unk83e[0x23]; + u16 unk884[0x23]; + u8 filler8CA[0xa]; + u8 unk8D4; + u8 unk8D5; + u8 filler8D6[2]; + u16 unk8D8; + u16 unk8DA; +} UnkStruct_Fsys_A0; + +#endif //POKEHEARTGOLD_SCRCMD_9_H diff --git a/include/unk_0202D230.h b/include/unk_0202D230.h new file mode 100644 index 0000000000..69c191db78 --- /dev/null +++ b/include/unk_0202D230.h @@ -0,0 +1,26 @@ +#ifndef POKEHEARTGOLD_UNK_0202D230_H +#define POKEHEARTGOLD_UNK_0202D230_H + +#include "save.h" +#include "frontier_data.h" + +void sub_0202D234(u32 a0); +u32 sub_0202D284(u32 a0, u32 a1, void *a2); +void sub_0202D308(u32 a0, u32 a1, void *a2); +void sub_0202D3B0(u32 a0, u8 a1, u32 a2, u32 a3); +u32 sub_0202D3DC(void); +void sub_0202D3E4(u32 a0, u32 a1); +u32 sub_0202D450(FRONTIERDATA *a0, u32 a1); +u32 sub_0202D488(FRONTIERDATA *a0, u32 a1); +void sub_0202D4B8(FRONTIERDATA *a0, u32 a1, void *a2); +void sub_0202D4FC(FRONTIERDATA *a0, u32 a1); +u32 sub_0202D57C(void *a0, u32 a1, u32 a2); +u32 sub_0202D5C4(FRONTIERDATA *a0, u32 a1, u16 a2); +u32 sub_0202D5DC(FRONTIERDATA *a0, u16 a1, u32 a2); +u32 sub_0202D7B0(u32 a0); +u32 sub_0202D7B8(u32 a0); +void sub_0202D8D0(u32 a0, u8 *a1); +u32 sub_0202D908(SaveData *saveData); +u32 sub_0202D928(SaveData *saveData); + +#endif //POKEHEARTGOLD_UNK_0202D230_H diff --git a/include/unk_02030A98.h b/include/unk_02030A98.h index a559f5ceaf..a48b0522db 100644 --- a/include/unk_02030A98.h +++ b/include/unk_02030A98.h @@ -25,7 +25,8 @@ void *sub_0203107C(SaveData *saveData); void sub_020310A0(SaveData *saveData); int sub_020310BC(void*, int, int); void sub_02031084(SaveData *saveData); -void sub_02031108(void*, int, int, int); +u32 sub_02031108(void*, int, int, u16); +void sub_0203126C(void *a0, u32 a1, u32 a2, u16 a3); u32 *sub_020312C4(SaveData *saveData, u32 a1, u32 *out); u32 sub_020312E0(SaveData *saveData, u32 *a1, u32 a2, u32 a3); diff --git a/include/unk_020379A0.h b/include/unk_020379A0.h index a409af9500..303586aa51 100644 --- a/include/unk_020379A0.h +++ b/include/unk_020379A0.h @@ -7,5 +7,6 @@ void sub_020379A0(HeapID heapId); void sub_02037AC0(u8 a0); BOOL sub_02037B38(u8 a0); void sub_02037BEC(void); +u32 sub_02037C0C(u32 a0, u16 *a1); #endif //POKEHEARTGOLD_UNK_020379A0_H diff --git a/include/unk_0204A3F4.h b/include/unk_0204A3F4.h new file mode 100644 index 0000000000..c8c74784b7 --- /dev/null +++ b/include/unk_0204A3F4.h @@ -0,0 +1,43 @@ +#ifndef POKEHEARTGOLD_UNK_0204A3F4_H +#define POKEHEARTGOLD_UNK_0204A3F4_H + +#include "field_system.h" +#include "scrcmd_9.h" + +BOOL sub_0204A5B0(u16 numRequired, SaveData *saveData, BOOL checkDuplicateItems); +void sub_0204A68C(void); +void sub_0204A698(u32 a0); +u32 sub_0204A6A0(u32 a0); +void sub_0204A6A8(FieldSystem *fieldSystem); +void sub_0204A6E8(FieldSystem *fieldSystem); +u32 sub_0204A6F8(SaveData *saveData, u32 a1); +void sub_0204A730(SaveData *saveData, u8 a1); +u16 sub_0204A750(SaveData *saveData); +u32 sub_0204A764(SaveData *saveData); +u16 sub_0204A800(SaveData *saveData); +void sub_0204A810(UnkStruct_Fsys_A0 **a0); +UnkStruct_Fsys_A0 *sub_0204A824(SaveData *saveData, BOOL resumeFromPrevious, u32 a2); +void sub_0204AA2C(UnkStruct_Fsys_A0 *a0); +void sub_0204AA58(UnkStruct_Fsys_A0 *a0, TaskManager *taskManager, void *a2); +BOOL sub_0204AA78(UnkStruct_Fsys_A0 *a0, void **a1, SaveData *saveData); +u32 sub_0204AB10(UnkStruct_Fsys_A0 *a0, SaveData *saveData); +void sub_0204ABC8(UnkStruct_Fsys_A0* a0, SaveData *saveData); +u8 sub_0204AC78(UnkStruct_Fsys_A0 *a0); +BOOL sub_0204AC7C(UnkStruct_Fsys_A0 *a0); +void sub_0204AD04(UnkStruct_Fsys_A0 *a0, SaveData *saveData); +void sub_0204AE20(UnkStruct_Fsys_A0 *a0, SaveData *saveData); +void sub_0204AF2C(UnkStruct_Fsys_A0 *a0); +void sub_0204AFE0(UnkStruct_Fsys_A0 *a0); +u32 sub_0204B044(UnkStruct_Fsys_A0 *a0, u32 a1); +u32 sub_0204B05C(UnkStruct_Fsys_A0 *a0); +u32 sub_0204B060(UnkStruct_Fsys_A0 *a0); +u32 sub_0204B068(UnkStruct_Fsys_A0 *a0); +BOOL sub_0204B0E0(UnkStruct_Fsys_A0 *a0, SaveData *saveData); +u32 sub_0204B120(UnkStruct_Fsys_A0 *a0, SaveData *saveData, u32 a2); +BOOL sub_0204B1CC(UnkStruct_Fsys_A0 *a0, SaveData *saveData); +BOOL sub_0204B204(UnkStruct_Fsys_A0 *a0, SaveData *saveData); +u16 sub_0204B258(UnkStruct_Fsys_A0 *a0, SaveData *saveData); +u8 sub_0204B4D4(u32 a0); +u16 sub_0204B510(UnkStruct_Fsys_A0 *a0); + +#endif //POKEHEARTGOLD_UNK_0204A3F4_H diff --git a/include/unk_0204B538.h b/include/unk_0204B538.h new file mode 100644 index 0000000000..c0287e0667 --- /dev/null +++ b/include/unk_0204B538.h @@ -0,0 +1,19 @@ +#ifndef POKEHEARTGOLD_UNK_0204B538_H +#define POKEHEARTGOLD_UNK_0204B538_H + +#include "message_format.h" +#include "scrcmd_9.h" + +MessageFormat *sub_0204B538(SaveData *saveData, u16 numEligiblePokemon, u16 a2, u8 a3, u8 *numLegendaryPokemonSeen); +u32 sub_0204B5E8(u8 a0); +u16 sub_0204B610(FieldSystem *fieldSystem, u16 *a1); +BOOL sub_0204B66C(FieldSystem *fieldSystem, u16 *a1); +BOOL sub_0204B690(FieldSystem *fieldSystem, u16 *a1); +void sub_0204B6AC(UnkStruct_Fsys_A0 *a0, SaveData *saveData); +void sub_0204B708(UnkStruct_Fsys_A0 *a0); +void sub_0204B720(UnkStruct_Fsys_A0 *a0, u32 a1); +u16 sub_0204B73C(UnkStruct_Fsys_A0 *a0, u8 a1, u8 a2, u32 a3); +u32 sub_0204BA04(UnkStruct_Fsys_A0 *a0, UnkStruct_0204B7D0 *a1, u16 a2, u32 a3, u16 *a4, u16 *a5, UnkStruct_0204A824_7E8 *a6, HeapID heapId); +void sub_0204BA50(UnkStruct_Fsys_A0 *a0, UnkStruct_0204B7D0 *a1, u16 a2, u32 a3, UnkStruct_0204A824_7E8 *a4, HeapID heapId); + +#endif //POKEHEARTGOLD_UNK_0204B538_H diff --git a/include/unk_02066EDC.h b/include/unk_02066EDC.h index f1d1e40e05..d004463771 100644 --- a/include/unk_02066EDC.h +++ b/include/unk_02066EDC.h @@ -3,9 +3,17 @@ #include "script.h" +void sub_02067118(TaskManager *taskManager, void *a1, u32 a2, u32 a3, u32 a4, u32 a5, u32 a6, u32 a7); +void sub_02067200(TaskManager *taskManager, u32 a1, u32 a2, u16 a3); +void sub_020672A4(TaskManager *taskManager, u32 a1, u32 a2); +u32 sub_020672D8(SaveData *saveData); +u32 sub_02067398(SaveData *saveData); void sub_02067484(FieldSystem *fieldSystem, void *); -BOOL sub_02067584(FieldSystem *fieldSystem); +u32 sub_020674A4(u32 a0); void sub_020674BC(SaveData *saveData); +u32 sub_020674E0(SaveData *saveData); +u32 sub_0206751C(SaveData *saveData); +BOOL sub_02067584(FieldSystem *fieldSystem); void sub_0206759C(SaveData *saveData, int a1); #endif //POKEHEARTGOLD_UNK_02066EDC_H diff --git a/main.lsf b/main.lsf index 178e7d78fa..efa6006939 100644 --- a/main.lsf +++ b/main.lsf @@ -169,7 +169,9 @@ Static main Object src/scrcmd_sound.o Object src/scrcmd_battle.o Object src/scrcmd_8.o - Object asm/scrcmd_9.o + Object src/scrcmd_9.o + Object src/unk_0204A3F4.o + Object src/unk_0204B538.o Object src/scrcmd_apricorn.o Object asm/scrcmd_11.o Object src/scrcmd_12.o diff --git a/src/pokemon.c b/src/pokemon.c index c9017fc77f..2686d94bee 100644 --- a/src/pokemon.c +++ b/src/pokemon.c @@ -4045,7 +4045,7 @@ int LowestFlagNo(u32 mask) { return i; } -static const u16 sBattleFrontierBanlist[18] = { +static const u16 sBattleFrontierBanlist[NUM_BANNED_BATTLE_FRONTIER] = { SPECIES_MEWTWO, SPECIES_MEW, SPECIES_LUGIA, @@ -4067,8 +4067,7 @@ static const u16 sBattleFrontierBanlist[18] = { }; BOOL IsPokemonBannedFromBattleFrontier(u16 species, u16 form) { - int i; - for (i = 0; i < NELEMS(sBattleFrontierBanlist); i++) { + for (u32 i = 0; i < NUM_BANNED_BATTLE_FRONTIER; i++) { if (species == sBattleFrontierBanlist[i]) { return TRUE; } @@ -4080,7 +4079,7 @@ BOOL IsPokemonBannedFromBattleFrontier(u16 species, u16 form) { } u16 GetBannedBattleFrontierPokemon(u32 idx) { - if (idx >= NELEMS(sBattleFrontierBanlist)) { + if (idx >= NUM_BANNED_BATTLE_FRONTIER) { idx = 0; } return sBattleFrontierBanlist[idx]; diff --git a/src/scrcmd_9.c b/src/scrcmd_9.c new file mode 100644 index 0000000000..c3e666d850 --- /dev/null +++ b/src/scrcmd_9.c @@ -0,0 +1,344 @@ +#include "global.h" +#include "assert.h" +#include "error_handling.h" +#include "field_player_avatar.h" +#include "field_system.h" +#include "fieldmap.h" +#include "filesystem.h" +#include "frontier_data.h" +#include "game_stats.h" +#include "heap.h" +#include "math_util.h" +#include "message_format.h" +#include "msgdata.h" +#include "party.h" +#include "player_data.h" +#include "pm_string.h" +#include "pokedex.h" +#include "pokemon.h" +#include "save_local_field_data.h" +#include "save_vars_flags.h" +#include "scrcmd.h" +#include "scrcmd_9.h" +#include "script.h" +#include "sys_flags.h" +#include "sys_vars.h" +#include "unk_0202D230.h" +#include "unk_02030A98.h" +#include "unk_02035900.h" +#include "unk_020379A0.h" +#include "unk_0203E348.h" +#include "unk_0204A3F4.h" +#include "unk_0204B538.h" +#include "unk_02066EDC.h" +#include "unk_02096910.h" + +static BOOL sub_0204A1E8(ScriptContext *ctx); +static u32 sub_0204A2A8(UnkStruct_Fsys_A0 *unkStruct, u8 a1); + +static const u16 _020FBF70[] = { 141, 145, 142, 143, 144 }; + +BOOL ScrCmd_410(ScriptContext *ctx) { + u16 unk4 = ScriptReadHalfword(ctx); + u16 unk6 = ScriptReadHalfword(ctx); + ctx->fieldSystem->unkA0 = sub_0204A824(FieldSystem_GetSaveData(ctx->fieldSystem), unk4, unk6); + return FALSE; +} + +BOOL ScrCmd_409(ScriptContext *ctx) { + sub_0204A810(&(ctx->fieldSystem->unkA0)); + return FALSE; +} + +BOOL ScrCmd_411(ScriptContext *ctx) { + sub_0204AA2C(ctx->fieldSystem->unkA0); + ctx->fieldSystem->unkA0 = NULL; + return FALSE; +} + +BOOL ScrCmd_412(ScriptContext *ctx) { + void **unk; + u16 id = ScriptReadHalfword(ctx); + u16 arg = ScriptGetVar(ctx); + u16 resultVarId = ScriptReadHalfword(ctx); + u16 *result = GetVarPointer(ctx->fieldSystem, resultVarId); + UnkStruct_Fsys_A0 *unkStruct = ctx->fieldSystem->unkA0; + switch (id) { + case 1: + if (arg == 0) { + *result = sub_0204A5B0(unkStruct->unk0e, ctx->fieldSystem->saveData, TRUE); + } else { + *result = sub_0204A5B0(arg, ctx->fieldSystem->saveData, TRUE); + } + break; + case 2: + sub_0204A68C(); + break; + case 3: + sub_0204A698(sub_0202D908(ctx->fieldSystem->saveData)); + break; + case 4: + *result = sub_0204A6A0(sub_0202D908(ctx->fieldSystem->saveData)); + break; + case 5: + sub_0204A6A8(ctx->fieldSystem); + break; + case 6: + sub_0204A6E8(ctx->fieldSystem); + break; + case 8: // unused + *result = sub_0204A6F8(ctx->fieldSystem->saveData, arg); + break; + case 9: + *result = sub_0204B120(NULL, ctx->fieldSystem->saveData, 2); + break; + case 10: + *result = sub_0204B120(NULL, ctx->fieldSystem->saveData, 0); + break; + case 11: + sub_0204A730(ctx->fieldSystem->saveData, arg); + break; + case 12: + *result = sub_0204A750(ctx->fieldSystem->saveData); + break; + case 14: + *result = sub_0204A764(ctx->fieldSystem->saveData); + break; + case 15: + *result = sub_0204A800(ctx->fieldSystem->saveData); + break; + case 16: + sub_02067200(ctx->taskman, arg, resultVarId, *result); + return TRUE; + case 30: + unk = FieldSysGetAttrAddr(ctx->fieldSystem, SCRIPTENV_RUNNING_APP_DATA); + sub_0204AA58(unkStruct, ctx->taskman, unk); + return TRUE; + case 31: + unk = FieldSysGetAttrAddr(ctx->fieldSystem, SCRIPTENV_RUNNING_APP_DATA); + *result = sub_0204AA78(unkStruct, unk, ctx->fieldSystem->saveData); + break; + case 32: + *result = sub_0204AB10(unkStruct, ctx->fieldSystem->saveData); + break; + case 35: + *result = sub_0204AC7C(unkStruct); + break; + case 37: // unused + sub_0204AD04(unkStruct, ctx->fieldSystem->saveData); + break; + case 38: // unused + sub_0204AE20(unkStruct, ctx->fieldSystem->saveData); + break; + case 39: + sub_0204AF2C(unkStruct); + break; + case 56: + sub_0204AFE0(unkStruct); + break; + case 41: // unused + *result = sub_0204B044(unkStruct, arg); + break; + case 43: + *result = sub_0204B05C(unkStruct); + break; + case 45: + *result = sub_0204B060(unkStruct); + break; + case 47: // unused + sub_0204B0E0(unkStruct, ctx->fieldSystem->saveData); + break; + case 48: + *result = sub_0204B1CC(unkStruct, ctx->fieldSystem->saveData); + break; + case 49: + *result = sub_0204B204(unkStruct, ctx->fieldSystem->saveData); + break; + case 50: + unkStruct->unk10_5 = arg; + break; + case 51: + *result = unkStruct->unk10_5; + break; + case 52: + sub_0204ABC8(unkStruct, ctx->fieldSystem->saveData); + break; + case 53: + *result = unkStruct->unk2a[arg]; + break; + case 54: + *result = sub_0204B120(unkStruct, ctx->fieldSystem->saveData, 1); + break; + case 55: + *result = sub_0204A2A8(unkStruct, arg); + break; + case 57: + *result = sub_0204B258(unkStruct, ctx->fieldSystem->saveData); + break; + case 100: + if (unkStruct == NULL) { + *result = TRUE; + } else { + *result = FALSE; + } + break; + case 58: + MI_CpuClear8(unkStruct->unk884, sizeof(unkStruct->unk884)); + break; + default: + GF_ASSERT(FALSE); + *result = 0; + break; + } + return FALSE; +} + +BOOL ScrCmd_413(ScriptContext *ctx) { + UnkStruct_Fsys_A0 *unkStruct = ctx->fieldSystem->unkA0; + u16 unk6 = ScriptGetVar(ctx); + u16 unk7 = ScriptGetVar(ctx); + u16 *speciesPtr = ScriptGetVarPointer(ctx); + u16 *movePtr = ScriptGetVarPointer(ctx); + *speciesPtr = unkStruct->unk298[unk6].unk30[unk7].species; + *movePtr = unkStruct->unk298[unk6].unk30[unk7].moves[0]; + return FALSE; +} + +BOOL ScrCmd_414(ScriptContext *ctx) { + u16 *unk = ScriptGetVarPointer(ctx); + *unk = sub_020672D8(ctx->fieldSystem->saveData); + return FALSE; +} + +BOOL ScrCmd_415(ScriptContext *ctx) { + u16 *unk = ScriptGetVarPointer(ctx); + *unk = sub_02067398(ctx->fieldSystem->saveData); + return FALSE; +} + +BOOL ScrCmd_416(ScriptContext *ctx) { + u16 unk7 = ScriptGetVar(ctx); + u16 unk4 = ScriptGetVar(ctx); + u16 *unkPtr = ScriptGetVarPointer(ctx); + UnkStruct_Fsys_A0 *unkStruct = ctx->fieldSystem->unkA0; + *unkPtr = FALSE; + u32 unk0; + switch (unk7) { + case 0: + unk0 = 62; + sub_0204B6AC(ctx->fieldSystem->unkA0, ctx->fieldSystem->saveData); + break; + case 1: + unk0 = 63; + sub_0204B708(ctx->fieldSystem->unkA0); + break; + case 2: + unk0 = 64; + sub_0204B720(ctx->fieldSystem->unkA0, unk4); + break; + } + if (sub_0205C298(ctx->fieldSystem->saveData) == 1) { + if (sub_02037C0C(sub_0203769C(), unkStruct->unk83e) == 1) { + *unkPtr = TRUE; + } else { + return TRUE; + } + } else { + sub_02096910((void*)unkStruct); + if (sub_02037030(unk0, unkStruct->unk83e, sizeof(unkStruct->unk83e)) == 1) { + *unkPtr = TRUE; + } + } + return FALSE; +} + +BOOL ScrCmd_417(ScriptContext *ctx) { + UnkStruct_Fsys_A0 *unkStruct = ctx->fieldSystem->unkA0; + u16 unk6 = ScriptGetVar(ctx); + u16 unk7 = ScriptReadHalfword(ctx); + if (sub_0205C298(ctx->fieldSystem->saveData) == 1) { + sub_020672A4(ctx->fieldSystem->taskman, unk6, unk7); + } else { + unkStruct->unk8DA = unk7; + unkStruct->unk8D5 = unk6; + SetupNativeScript(ctx, sub_0204A1E8); + } + return TRUE; +} + +static BOOL sub_0204A1E8(ScriptContext *ctx) { + UnkStruct_Fsys_A0 *unkStruct = ctx->fieldSystem->unkA0; + u16 *unkPtr = GetVarPointer(ctx->fieldSystem, unkStruct->unk8DA); + u32 unk = unkStruct->unk8D5 == 1 ? 1 : 2; + if (unkStruct->unk8D4 == unk) { + unkStruct->unk8D4 = 0; + *unkPtr = unkStruct->unk8D8; + return TRUE; + } else { + return FALSE; + } +} + +BOOL ScrCmd_418(ScriptContext *ctx) { + u16 *unk4 = ScriptGetVarPointer(ctx); + u16 *unk6 = ScriptGetVarPointer(ctx); + u8 unk[2]; + sub_0202D8D0(sub_0202D928(ctx->fieldSystem->saveData), unk); + *unk4 = unk[0]; + *unk6 = unk[1]; + return FALSE; +} + +BOOL ScrCmd_419(ScriptContext *ctx) { + u16 *unk = ScriptGetVarPointer(ctx); + *unk = sub_0202D7B8(sub_0202D928(ctx->fieldSystem->saveData)); + return FALSE; +} + +static u32 sub_0204A2A8(UnkStruct_Fsys_A0 *unkStruct, u8 a1) { + if (a1 == 2) { + return unkStruct->unk10_5; + } else if (a1 == 1) { + if (unkStruct->unk0f == 2) { + return _020FBF70[unkStruct->unk10_5]; + } + return unkStruct->unk12 ? 97 : 0; + } else { + return unkStruct->unk11 ? 97 : 0; + } +} + +BOOL ScrCmd_554(ScriptContext *ctx) { + SaveData *saveData = ctx->fieldSystem->saveData; + u16 *unk = ScriptGetVarPointer(ctx); + *unk = FrontierData_BattlePointAction(Save_FrontierData_Get(saveData), 0, 0); + return FALSE; +} + +BOOL ScrCmd_555(ScriptContext *ctx) { + SaveData *saveData = ctx->fieldSystem->saveData; + u16 unk = ScriptGetVar(ctx); + GameStats_Add(Save_GameStats_Get(ctx->fieldSystem->saveData), GAME_STAT_BATTLE_POINTS, unk); + FrontierData_BattlePointAction(Save_FrontierData_Get(saveData), unk, 5); + return FALSE; +} + +BOOL ScrCmd_556(ScriptContext *ctx) { + SaveData *saveData = ctx->fieldSystem->saveData; + u16 unk = ScriptGetVar(ctx); + GameStats_Add(Save_GameStats_Get(ctx->fieldSystem->saveData), GAME_STAT_UNK70, unk); + FrontierData_BattlePointAction(Save_FrontierData_Get(saveData), unk, 6); + return FALSE; +} + +BOOL ScrCmd_CheckBattlePoints(ScriptContext *ctx) { + SaveData *saveData = ctx->fieldSystem->saveData; + u16 unk = ScriptGetVar(ctx); + u16 *unkPtr = ScriptGetVarPointer(ctx); + if (FrontierData_BattlePointAction(Save_FrontierData_Get(saveData), 0, 0) < unk) { + *unkPtr = FALSE; + } else { + *unkPtr = TRUE; + } + return FALSE; +} diff --git a/src/scrcmd_battle_arcade.c b/src/scrcmd_battle_arcade.c index d5044085c1..cfb3a34082 100644 --- a/src/scrcmd_battle_arcade.c +++ b/src/scrcmd_battle_arcade.c @@ -15,7 +15,6 @@ #include "save_special_ribbons.h" #include "save.h" #include "scrcmd.h" -#include "scrcmd_9.h" #include "scrcmd_battle_arcade.h" #include "script.h" #include "task.h" @@ -23,6 +22,7 @@ #include "unk_02035900.h" #include "unk_0203DFA4.h" #include "unk_0203E348.h" +#include "unk_0204A3F4.h" #include "unk_0205BB1C.h" #include "unk_0205BFF0.h" #include "unk_02078E30.h" diff --git a/src/scrcmd_battle_castle.c b/src/scrcmd_battle_castle.c index c651f80563..00dbfa32bf 100644 --- a/src/scrcmd_battle_castle.c +++ b/src/scrcmd_battle_castle.c @@ -15,7 +15,6 @@ #include "save_special_ribbons.h" #include "save.h" #include "scrcmd.h" -#include "scrcmd_9.h" #include "scrcmd_battle_castle.h" #include "script.h" #include "task.h" @@ -23,6 +22,7 @@ #include "unk_02035900.h" #include "unk_0203DFA4.h" #include "unk_0203E348.h" +#include "unk_0204A3F4.h" #include "unk_0205BB1C.h" #include "unk_0205BFF0.h" #include "unk_02078E30.h" diff --git a/src/unk_0204A3F4.c b/src/unk_0204A3F4.c new file mode 100644 index 0000000000..a178182168 --- /dev/null +++ b/src/unk_0204A3F4.c @@ -0,0 +1,758 @@ +#include "global.h" +#include "assert.h" +#include "field_player_avatar.h" +#include "frontier_data.h" +#include "game_stats.h" +#include "heap.h" +#include "math_util.h" +#include "party.h" +#include "player_data.h" +#include "pokemon_storage_system.h" +#include "pokemon.h" +#include "save_local_field_data.h" +#include "save_vars_flags.h" +#include "scrcmd_9.h" +#include "sys_flags.h" +#include "sys_vars.h" +#include "unk_0202D230.h" +#include "unk_02030A98.h" +#include "unk_0203E348.h" +#include "unk_0204A3F4.h" +#include "unk_0204B538.h" +#include "unk_02066EDC.h" + +typedef struct SpeciesAndItem { + u16 species; + u16 item; +} SpeciesAndItem; + +static u32 sub_0204B318(UnkStruct_Fsys_A0 *a0); +static void sub_0204B470(UnkStruct_Fsys_A0 *a0, SaveData *saveData, u32 a2); +static BOOL sub_0204B2B8(SaveData *saveData, u32 ribbon, UnkStruct_Fsys_A0 *a2); + +static const u8 _020FBF98[] = { 0, 3, 4, 5, 6, 7, 8, 9, 10, 10, 10, 0 }; +static const u8 _020FBF8C[] = { 0, 5, 4, 4, 3, 3, 2, 2, 1, 1, 0, 0 }; +static const u8 _020FBF84[] = { 0, 3, 3, 4, 4, 5, 5, 7 }; +static const u8 _020FBF7C[] = { 0, 8, 9, 11, 12, 14, 15, 18 }; + +static u32 sub_0204A3F4(u32 a0) { + switch (a0) { + case 0: + case 4: + case 5: + return 3; + case 1: + return 4; + case 2: + case 3: + case 6: + return 2; + default: + return 0; + } +} + +static BOOL sub_0204A424(SpeciesAndItem *validMons, u32 species, u32 item, s32 size) { + for (s32 i = 0; i < size; i++) { + if (species == validMons[i].species + && item != ITEM_NONE + && item == validMons[i].item) { + return TRUE; + } + } + return FALSE; +} + +static BOOL sub_0204A450(SpeciesAndItem *mons, s32 size) { + for (s32 i = 0; i < size - 1; i++) { + for (s32 j = i + 1; j < size; j++) { + if (mons[i].species == mons[j].species) { + return FALSE; + } + if (mons[i].item != ITEM_NONE && mons[i].item == mons[j].item) { + return FALSE; + } + } + } + return TRUE; +} + +static BOOL sub_0204A4A0(SpeciesAndItem* validMons, u32 numRequired, s32 numValid, s32 n) { + // this assumes that numRequired is always either 2, 3, or 4 + SpeciesAndItem mons[4]; + MI_CpuClear8(mons, sizeof(SpeciesAndItem) * NELEMS(mons)); + for (s32 i = 0; i < n; i++) { + mons[0] = validMons[i]; + for (s32 j = i + 1; j < numValid; j++) { + mons[1] = validMons[j]; + if (numRequired == 2) { + if (sub_0204A450(mons, numRequired)) { + return TRUE; + } + continue; + } + for (s32 k = j + 1; k < numValid; k++) { + mons[2] = validMons[k]; + if (numRequired == 3) { + if (sub_0204A450(mons, numRequired)) { + return TRUE; + } + continue; + } + for (s32 l = k + 1; l < numValid; l++) { + mons[3] = validMons[l]; + if (sub_0204A450(mons, numRequired)) { + return TRUE; + } + } + } + } + } + return FALSE; +} + +BOOL sub_0204A5B0(u16 numRequired, SaveData *saveData, BOOL checkDuplicateItems) +{ + u8 i; + u8 partyCount; + u8 numValid; + u16 species, item, form; + Party *party = SaveArray_Party_Get(saveData); + partyCount = Party_GetCount(party); + if (partyCount < numRequired) { + return FALSE; + } + SpeciesAndItem validMons[PARTY_SIZE]; + for (i = 0, numValid = 0; i < partyCount; i++) { + Pokemon *mon = Party_GetMonByIndex(party, i); + species = GetMonData(mon, MON_DATA_SPECIES, NULL); + item = GetMonData(mon, MON_DATA_HELD_ITEM, NULL); + form = GetMonData(mon, MON_DATA_FORM, NULL); + if (!checkDuplicateItems) { + item = ITEM_NONE; + } + if (GetMonData(mon, MON_DATA_IS_EGG, NULL)) { + continue; + } + if (IsPokemonBannedFromBattleFrontier(species, form) == TRUE) { + continue; + } + if (checkDuplicateItems == TRUE && sub_0204A424(validMons, species, item, numValid) == TRUE) { + continue; + } + validMons[numValid].species = species; + validMons[numValid].item = item; + numValid++; + } + if (numValid < numRequired) { + return FALSE; + } + return sub_0204A4A0(validMons, numRequired, numValid, numValid - numRequired + 1); +} + +void sub_0204A68C(void) { + OS_ResetSystem(0); +} + +void sub_0204A698(u32 a0) { + sub_0202D234(a0); +} + +u32 sub_0204A6A0(u32 a0) { + return sub_0202D3DC(); +} + +void sub_0204A6A8(FieldSystem *fieldSystem) { + Location *warp = LocalFieldData_GetDynamicWarp(Save_LocalFieldData_Get(fieldSystem->saveData)); + u32 y = GetPlayerYCoord(fieldSystem->playerAvatar); + u32 x = GetPlayerXCoord(fieldSystem->playerAvatar); + warp->mapId = fieldSystem->location->mapId; + warp->warpId = -1; + warp->x = x; + warp->y = y; + warp->direction = DIR_NORTH; + SetFlag966(Save_VarsFlags_Get(fieldSystem->saveData)); +} + +void sub_0204A6E8(FieldSystem *fieldSystem) { + ClearFlag966(Save_VarsFlags_Get(fieldSystem->saveData)); +} + +u32 sub_0204A6F8(SaveData *saveData, u32 a1) { + if (a1 == 5) { + return FALSE; + } else if (a1 == 6) { + return sub_020310BC(sub_0203107C(saveData), 113, sub_0205C268(113)); + } else { + return sub_020310BC(sub_0203107C(saveData), 2 * a1 + 1, 0xff); + } +} + +void sub_0204A730(SaveData *saveData, u8 a1) { + FRONTIERDATA *frontierData = Save_FrontierData_Get(saveData); + if (a1 == 0) { + sub_0202D5DC(frontierData, 5, 2); + } else { + sub_0202D5DC(frontierData, 5, 1); + } +} + +u16 sub_0204A750(SaveData *saveData) { + return sub_0202D5DC(Save_FrontierData_Get(saveData), 5, 0); +} + +u32 sub_0204A764(SaveData *saveData) { + u32 unk = sub_0202D908(saveData); + FRONTIERDATA *frontierData = Save_FrontierData_Get(saveData); + u8 unk4 = sub_0202D284(unk, 0, 0); + if (unk4 == 5) { + return unk4; + } + if (unk4 == 6) { + sub_02031108(sub_0203107C(saveData), 100, sub_0205C268(100), 0); + } else { + sub_0202D5DC(frontierData, unk4 + 8, 2); + } + sub_0202D57C(frontierData, unk4, 2); + sub_02031108(sub_0203107C(saveData), sub_0205C310(unk4), sub_0205C268(sub_0205C310(unk4)), 0); + if (unk4 != 4 && unk4 != 6) { + sub_020674E0(saveData); + } + return unk4; +} + +u16 sub_0204A800(SaveData *saveData) { + return sub_0202D7B0(sub_0202D928(saveData)); +} + +void sub_0204A810(UnkStruct_Fsys_A0 **a0) { + GF_ASSERT(*a0 == NULL); + *a0 = NULL; +} + +UnkStruct_Fsys_A0 *sub_0204A824(SaveData *saveData, BOOL resumeFromPrevious, u32 a2) { + UnkStruct_Fsys_A0 *unkStruct = AllocFromHeap(HEAP_ID_FIELD, sizeof(UnkStruct_Fsys_A0)); + MI_CpuClear8(unkStruct, sizeof(UnkStruct_Fsys_A0)); + unkStruct->heapId = HEAP_ID_FIELD; + unkStruct->unk70 = sub_0202D908(saveData); + unkStruct->unk74 = Save_FrontierData_Get(saveData); + unkStruct->unk00 = 0x12345678; + sub_0202D3E4(unkStruct->unk70, 0); + if (!resumeFromPrevious) { + unkStruct->unk0f = a2; + unkStruct->unk0e = sub_0204A3F4(unkStruct->unk0f); + unkStruct->unk0c = 1; + unkStruct->unk0d = 0; + for (u16 i = 0; i < 4; i++) { + unkStruct->unk2a[i] = 0xff; + } + for (u16 i = 0; i < 14; i++) { + unkStruct->unk3e[i] = 0xffff; + } + sub_0202D234(unkStruct->unk70); + u8 unk = unkStruct->unk0f; + sub_0202D308(unkStruct->unk70, 0, &unk); + } else { + unkStruct->unk0f = sub_0202D284(unkStruct->unk70, 0, 0); + unkStruct->unk0c = sub_0202D284(unkStruct->unk70, 1, 0); + unkStruct->unk0d = unkStruct->unk0c - 1; + unkStruct->unk0e = sub_0204A3F4(unkStruct->unk0f); + sub_0202D284(unkStruct->unk70, 5, unkStruct->unk2a); + sub_0202D284(unkStruct->unk70, 8, unkStruct->unk3e); + unkStruct->unk08 = sub_0202D284(unkStruct->unk70, 10, 0); + if (unkStruct->unk0f == 2) { + unkStruct->unk10_5 = sub_0202D284(unkStruct->unk70, 9, 0); + sub_0202D284(unkStruct->unk70, 6, &unkStruct->unk7e8[unkStruct->unk10_5]); + sub_0204BA50(unkStruct, + &unkStruct->unk298[unkStruct->unk10_5], + 300 + unkStruct->unk10_5, + sub_0202D284(unkStruct->unk70, 7, 0), + &unkStruct->unk7e8[unkStruct->unk10_5], + unkStruct->heapId); + } + } + unkStruct->unk11 = PlayerProfile_GetTrainerGender(Save_PlayerData_GetProfileAddr(saveData)); + if (unkStruct->unk0f != 5) { + void *unk5 = sub_0203107C(saveData); + GAME_STATS *gameStats = Save_GameStats_Get(saveData); + u16 unk0; + if (unkStruct->unk0f == 6) { + unk0 = Save_VarsFlags_GetVar4052(Save_VarsFlags_Get(saveData)); + } else { + unk0 = sub_0202D5DC(unkStruct->unk74, unkStruct->unk0f + 8, 0); + } + if (unk0 != 0) { + u32 unk0; + if (unkStruct->unk0f == 6) { + unk0 = sub_020310BC(unk5, 113, sub_0205C268(113)); + } else { + unk0 = sub_020310BC(unk5, 2 * unkStruct->unk0f + 1, 0xff); + } + unkStruct->unk1a = unk0; + unkStruct->unk1c = sub_0202D57C(unkStruct->unk74, unkStruct->unk0f, 0); + } + unkStruct->unk20 = GameStats_GetCapped(gameStats, GAME_STAT_UNK30); + } + if (unkStruct->unk0f == 6) { + unkStruct->unk1c = sub_0202D5C4(unkStruct->unk74, 6, unkStruct->unk1a / 7); + } + return unkStruct; +} + +void sub_0204AA2C(UnkStruct_Fsys_A0 *a0) { + if (a0 == NULL) { + return; + } + GF_ASSERT(a0->unk00 == 0x12345678); + MI_CpuClear8(a0, sizeof(UnkStruct_Fsys_A0)); + FreeToHeap(a0); +} + +void sub_0204AA58(UnkStruct_Fsys_A0 *a0, TaskManager *taskManager, void *a2) { + sub_02067118(taskManager, a2, 17, 0, a0->unk0e, a0->unk0e, 100, 0); +} + +BOOL sub_0204AA78(UnkStruct_Fsys_A0 *a0, void **a1, SaveData *saveData) { + Party *party; + u8 *unk = *a1; + if (unk[0x27] != 0 || unk[0x26] == 7) { + FreeToHeap(*a1); + *a1 = NULL; + return FALSE; + } + party = SaveArray_Party_Get(saveData); + for (u16 i = 0; i < a0->unk0e; i++) { + a0->unk2a[i] = unk[0x30 + i] - 1; + Pokemon *mon = Party_GetMonByIndex(party, a0->unk2a[i]); + a0->unk2e[i] = GetMonData(mon, MON_DATA_SPECIES, NULL); + a0->unk36[i] = GetMonData(mon, MON_DATA_HELD_ITEM, NULL); + } + FreeToHeap(*a1); + *a1 = NULL; + return TRUE; +} + +u32 sub_0204AB10(UnkStruct_Fsys_A0 *a0, SaveData *saveData) { + u16 species[4]; + u16 items[4]; + Party *party = SaveArray_Party_Get(saveData); + for (u16 i = 0; i < a0->unk0e; i++) { + Pokemon *mon = Party_GetMonByIndex(party, a0->unk2a[i]); + species[i] = GetMonData(mon, MON_DATA_SPECIES, NULL); + items[i] = GetMonData(mon, MON_DATA_HELD_ITEM, NULL); + if (i == 0) { + continue; + } + for (u16 j = 0; j < i; j++) { + if (species[i] == species[j]) { + return 1; + } + if (items[i] != ITEM_NONE && items[i] == items[j]) { + return 2; + } + } + } + return 0; +} + +static BOOL sub_0204ABA0(u16 *a0, u32 a1, u16 a2) { + for (u16 i = 0; i < a2; i++) { + if (a1 == a0[i]) { + return TRUE; + } + } + return FALSE; +} + +void sub_0204ABC8(UnkStruct_Fsys_A0* a0, SaveData *saveData) { + // saveData is unused + s32 i; + u32 unk; + u8 sp00; + if (a0->unk0f == 2 || a0->unk0f == 6 || a0->unk0f == 3) { + u32 temp; + if ((a0->unk0f == 3 && a0->unk14 > a0->unk1c) + || (a0->unk0f == 6 && a0->unk14 > a0->unk1c)) { + temp = a0->unk14; + } else { + temp = a0->unk1c; + } + sp00 = temp; + for (i = 0; i < 14; i++) { + do { + unk = sub_0204B73C(a0, sp00, i/2, a0->unk0f); + } while (sub_0204ABA0(a0->unk3e, unk, i)); + a0->unk3e[i] = unk; + } + } else { + for (i = 0; i < 7; i++) { + do { + unk = sub_0204B73C(a0, a0->unk1c, i, a0->unk0f); + } while (sub_0204ABA0(a0->unk3e, unk, i)); + a0->unk3e[i] = unk; + } + } +} + +u8 sub_0204AC78(UnkStruct_Fsys_A0 *a0) { + return a0->unk0c; +} + +BOOL sub_0204AC7C(UnkStruct_Fsys_A0 *a0) { + if (a0->unk10_0) { + return TRUE; + } + if (a0->unk0c > 7) { + a0->unk10_0 = TRUE; + return TRUE; + } + return FALSE; +} + +static void sub_0204ACA0(UnkStruct_Fsys_A0 *a0, SaveData *saveData, BOOL a2, u16 a3) { + // a2 and a3 are unused + switch (a0->unk0f) { + case 0: + sub_0204B470(a0, saveData, 0); + break; + case 1: + break; + case 4: + sub_0204B470(a0, saveData, 1); + sub_0202D3B0(a0->unk70, a0->unk28, a0->unk24, a0->unk26); + u8 unk = a0->unk0f; + sub_0202D308(a0->unk70, 0, &unk); + unk = a0->unk0c; + sub_0202D308(a0->unk70, 1, &unk); + sub_0202D4FC(a0->unk74, a0->unk70); + } +} + +void sub_0204AD04(UnkStruct_Fsys_A0 *a0, SaveData *saveData) { + GAME_STATS *gameStats = Save_GameStats_Get(saveData); + void *unk00 = sub_0203107C(saveData); + if (a0->unk0f == 5) { + return; + } + u32 unk4 = a0->unk0f == 6 ? 112 : a0->unk0f * 2; + sub_020310BC(unk00, unk4, sub_0205C268(unk4)); + sub_0203126C(unk00, unk4, sub_0205C268(unk4), a0->unk1a + a0->unk0d); + if (a0->unk0f == 6) { + sub_020310BC(sub_0203107C(saveData), 100, sub_0205C268(100)); + } else { + sub_0202D5DC(a0->unk74, a0->unk0f + 8, 0); + } + u32 unk = sub_02031108(unk00, unk4 + 1, sub_0205C268(unk4 + 1), a0->unk1a + a0->unk0d); + if (a0->unk0f == 6) { + sub_02031108(sub_0203107C(saveData), 100, sub_0205C268(100), 0); + } else { + sub_0202D5DC(a0->unk74, a0->unk0f + 8, 2); + } + GameStats_Add(gameStats, GAME_STAT_UNK30, a0->unk0d); + sub_0202D57C(a0->unk74, a0->unk0f, 2); + if (a0->unk0f != 6) { + GameStats_Add(Save_GameStats_Get(saveData), GAME_STAT_UNK16, 1); + } + sub_0204B318(a0); + unk++; + if (unk > 9999) { + unk = 9999; + } + sub_0204ACA0(a0, saveData, 0, unk); +} + +void sub_0204AE20(UnkStruct_Fsys_A0 *a0, SaveData *saveData) { + if (a0->unk0f == 5) { + return; + } + GAME_STATS *gameStats = Save_GameStats_Get(saveData); + void *unk00 = sub_0203107C(saveData); + u32 unk4 = a0->unk0f == 6 ? 112 : a0->unk0f * 2; + if (a0->unk0f == 6) { + sub_020310BC(sub_0203107C(saveData), 100, sub_0205C268(100)); + } else { + sub_0202D5DC(a0->unk74, a0->unk0f + 8, 0); + } + u32 unk6 = sub_02031108(unk00, unk4 + 1, sub_0205C268(unk4 + 1), a0->unk1a + a0->unk0d); + if (a0->unk0f == 6) { + sub_02031108(sub_0203107C(saveData), 100, sub_0205C268(100), 1); + } else { + sub_0202D5DC(a0->unk74, a0->unk0f + 8, 1); + } + sub_020310BC(unk00, unk4, sub_0205C268(unk4)); + sub_0203126C(unk00, unk4, sub_0205C268(unk4), unk6); + GameStats_Add(gameStats, GAME_STAT_UNK30, 7); + sub_0202D57C(a0->unk74, a0->unk0f, 3); + if (a0->unk0f != 6) { + GameStats_Add(gameStats, GAME_STAT_UNK16, 1); + } + GameStats_AddSpecial(gameStats, GAME_STAT_UNK14); + sub_0204B318(a0); + sub_0204ACA0(a0, saveData, 1, unk6); +} + +void sub_0204AF2C(UnkStruct_Fsys_A0 *a0) { + u8 unk = a0->unk0f; + sub_0202D308(a0->unk70, 0, &unk); + unk = a0->unk0c; + sub_0202D308(a0->unk70, 1, &unk); + sub_0202D308(a0->unk70, 5, a0->unk2a); + sub_0202D3B0(a0->unk70, a0->unk28, a0->unk24, a0->unk26); + sub_0202D308(a0->unk70, 8, a0->unk3e); + sub_0202D308(a0->unk70, 10, &a0->unk08); + sub_0202D3E4(a0->unk70, 1); + if (a0->unk0f == 2) { + unk = a0->unk10_5; + sub_0202D308(a0->unk70, 9, &unk); + sub_0202D308(a0->unk70, 6, &a0->unk7e8[a0->unk10_5]); + sub_0202D308(a0->unk70, 7, &a0->unk838[a0->unk10_5]); + } +} + +void sub_0204AFE0(UnkStruct_Fsys_A0 *a0) { + for (s32 i = 0; i < 5; i++) { + a0->unk838[i] = sub_0204BA04(a0, &a0->unk298[i], 300 + i, a0->unk0e, a0->unk2e, a0->unk36, &a0->unk7e8[i], a0->heapId); + } +} + +u32 sub_0204B044(UnkStruct_Fsys_A0 *a0, u32 a1) { + sub_0204B5E8(a0->unk78[a1].unk04); +} + +u32 sub_0204B05C(UnkStruct_Fsys_A0 *a0) { + return a0->unk0f; +} + +u32 sub_0204B060(UnkStruct_Fsys_A0 *a0) { + return a0->unk10_1; +} + +u32 sub_0204B068(UnkStruct_Fsys_A0 *a0) { + u32 unk; + if (a0->unk0f == 5) { + return 0; + } + if (a0->unk0f == 4) { + unk = _020FBF98[sub_0202D488(a0->unk74, 0)]; + } else { + if (a0->unk0f == 3 || a0->unk0f == 6) { + u32 index = sub_0202D57C(a0->unk74, a0->unk0f, 0); + if (index >= 7) { + unk = 18; + } else { + unk = _020FBF7C[index]; + } + } else { + u32 index = sub_0202D57C(a0->unk74, a0->unk0f, 0); + if (a0->unk10_1) { + unk = 20; + } else if (index >= 7) { + unk = 7; + } else { + unk = _020FBF84[index]; + } + } + } + FrontierData_BattlePointAction(a0->unk74, unk, 5); + return unk; +} + +BOOL sub_0204B0E0(UnkStruct_Fsys_A0 *a0, SaveData *saveData) { + u32 unk = sub_0204A6F8(saveData, a0->unk0f); + if (unk < 50) { + return FALSE; + } else if (unk >= 100) { + if (sub_0202D5DC(a0->unk74, 1, 0)) { + return FALSE; + } + } else if (sub_0202D5DC(a0->unk74, 0, 0)) { + return FALSE; + } + return TRUE; +} + +u32 sub_0204B120(UnkStruct_Fsys_A0 *a0, SaveData *saveData, u32 a2) { + FRONTIERDATA *frontierData = Save_FrontierData_Get(saveData); + switch (a2) { + case 0: + return sub_0202D488(frontierData, 0); + case 1: { + sub_0202D5DC(frontierData, 4, 2); + s32 unk0 = sub_0202D488(frontierData, 0); + if (unk0 == 10) { + a0->unk10_4 = TRUE; + return 0; + } + sub_0202D488(frontierData, 3); + if (unk0 + 1 >= 5) { + a0->unk10_4 = TRUE; + } + return 1; + } + case 2: + u32 unk4 = sub_0202D450(frontierData, 3); + s32 unk0 = sub_0202D488(frontierData, 0); + if (unk0 == 1) { + return 0; + } + u32 index = unk0 - 1; + if (unk4 >= _020FBF8C[index]) { + sub_0202D488(frontierData, 4); + sub_0202D450(frontierData, 2); + sub_0202D5DC(frontierData, 4, 2); + return 1; + } + return 0; + } + return 0; +} + +BOOL sub_0204B1CC(UnkStruct_Fsys_A0 *a0, SaveData *saveData) { + if (a0->unk0f != 0) { + return FALSE; + } + switch (a0->unk10_1) { + case 1: + return sub_0204B2B8(saveData, MON_DATA_ABILITY_RIBBON, a0); + case 2: + return sub_0204B2B8(saveData, MON_DATA_GREAT_ABILITY_RIBBON, a0); + } + return FALSE; +} + +BOOL sub_0204B204(UnkStruct_Fsys_A0 *a0, SaveData *saveData) { + if (a0->unk0f == 5) { + return FALSE; + } + if (a0->unk0f == 6) { + return FALSE; + } + if (!a0->unk10_4) { + return FALSE; + } + u32 ribbon; + switch (a0->unk0f) { + case 1: + ribbon = MON_DATA_DOUBLE_ABILITY_RIBBON; + break; + case 2: + ribbon = MON_DATA_MULTI_ABILITY_RIBBON; + break; + case 3: + ribbon = MON_DATA_PAIR_ABILITY_RIBBON; + break; + case 4: + ribbon = MON_DATA_WORLD_ABILITY_RIBBON; + break; + } + return sub_0204B2B8(saveData, ribbon, a0); +} + +u16 sub_0204B258(UnkStruct_Fsys_A0 *a0, SaveData *saveData) { + u8 unk; + if (a0->unk0f == 6) { + unk = sub_020310BC(sub_0203107C(saveData), 100, sub_0205C268(100)); + } else { + unk = sub_0202D5DC(a0->unk74, a0->unk0f + 8, 0); + } + if (unk == 0) { + a0->unk08 = sub_020674E0(saveData); + } else { + a0->unk08 = sub_0206751C(saveData); + } + return a0->unk08 / 0xffff; +} + +static BOOL sub_0204B2B8(SaveData *saveData, u32 ribbon, UnkStruct_Fsys_A0 *a2) { + u8 value = TRUE; + Party *party = SaveArray_Party_Get(saveData); + u8 count = 0; + for (s32 i = 0; i < a2->unk0e; i++) { + Pokemon *mon = Party_GetMonByIndex(party, a2->unk2a[i]); + if (GetMonData(mon, ribbon, NULL) == FALSE) { + SetMonData(mon, ribbon, &value); + count++; + } + } + if (count == 0) { + return FALSE; + } else { + return TRUE; + } +} + +static u32 sub_0204B318(UnkStruct_Fsys_A0 *a0) { + if (a0->unk0f == 5 || a0->unk0f == 0 || a0->unk0f == 6 || a0->unk0f == 4) { + return FALSE; + } + if ((u16)(a0->unk1a + a0->unk0d) < 50) { + return FALSE; + } + a0->unk10_4 = TRUE; + return TRUE; +} + +static void sub_0204B34C(UnkStruct_0204B470 *a0, Pokemon *mon) { + a0->species = GetMonData(mon, MON_DATA_SPECIES, NULL); + a0->form = GetMonData(mon, MON_DATA_FORM, NULL); + a0->item = GetMonData(mon, MON_DATA_HELD_ITEM, NULL); + for (s32 i = 0; i < MAX_MON_MOVES; i++) { + a0->moves[i] = GetMonData(mon, MON_DATA_MOVE1 + i, NULL); + a0->ppUp |= GetMonData(mon, MON_DATA_MOVE1PPUP + i, NULL) << (i * 2); + } + a0->language = GetMonData(mon, MON_DATA_GAME_LANGUAGE, NULL); + a0->otId = GetMonData(mon, MON_DATA_OTID, NULL); + a0->pid = GetMonData(mon, MON_DATA_PERSONALITY, NULL); + a0->ivsWord = GetMonData(mon, MON_DATA_IVS_WORD, NULL); + for (s32 i = 0; i < NUM_STATS; i++) { + a0->evs[i] = GetMonData(mon, MON_DATA_HP_EV + i, NULL); + } + a0->ability = GetMonData(mon, MON_DATA_ABILITY, NULL); + a0->friendship = GetMonData(mon, MON_DATA_FRIENDSHIP, NULL); + GetMonData(mon, MON_DATA_NICKNAME, a0->nickname); +} + +static void sub_0204B470(UnkStruct_Fsys_A0 *a0, SaveData *saveData, u32 a2) { + UnkStruct_0204B470 *unkStructs = AllocFromHeapAtEnd(a0->heapId, 3 * sizeof(UnkStruct_0204B470)); + MI_CpuClear8(unkStructs, 3 * sizeof(UnkStruct_0204B470)); + Party *party = SaveArray_Party_Get(saveData); + for (s32 i = 0; i < 3; i++) { + sub_0204B34C(&unkStructs[i], Party_GetMonByIndex(party, a0->unk2a[i])); + } + sub_0202D4B8(a0->unk74, a2, unkStructs); + MI_CpuClear8(unkStructs, 3 * sizeof(UnkStruct_0204B470)); + FreeToHeap(unkStructs); +} + +u8 sub_0204B4D4(u32 frontierTrainerIndex) { + if (frontierTrainerIndex < 100) { + return 3; + } + if (frontierTrainerIndex < 120) { + return 6; + } + if (frontierTrainerIndex < 140) { + return 9; + } + if (frontierTrainerIndex < 160) { + return 12; + } + if (frontierTrainerIndex < 180) { + return 15; + } + if (frontierTrainerIndex < 200) { + return 18; + } + if (frontierTrainerIndex < 220) { + return 21; + } + return 31; +} + +u16 sub_0204B510(UnkStruct_Fsys_A0 *a0) { + if (a0->unk0f == 6) { + return LCRandom(); + } + a0->unk08 = sub_020674A4(a0->unk08); + return a0->unk08 / 0xffff; +} diff --git a/src/unk_0204B538.c b/src/unk_0204B538.c new file mode 100644 index 0000000000..966cd4f8f3 --- /dev/null +++ b/src/unk_0204B538.c @@ -0,0 +1,413 @@ +#include "global.h" +#include "assert.h" +#include "heap.h" +#include "message_format.h" +#include "msgdata.h" +#include "party.h" +#include "player_data.h" +#include "pm_string.h" +#include "pokedex.h" +#include "pokemon.h" +#include "scrcmd_9.h" +#include "unk_0202D230.h" +#include "unk_02035900.h" +#include "unk_0204A3F4.h" +#include "unk_0204B538.h" +#include "constants/abilities.h" +#include "constants/items.h" +#include "constants/moves.h" +#include "msgdata/msg.naix" + +typedef struct FrontierMon { + u16 species; + u16 moves[4]; + u8 evs; + u8 nature; + u16 item; + u16 form; +} FrontierMon; + +static u32 sub_0204BABC(UnkStruct_Fsys_A0 *a0, u16 *a1, u16 frontierTrainerIndex, UnkStruct_0204B470 *a3, u8 a4, u16 *a5, u16 *a6, UnkStruct_0204A824_7E8 *a7, HeapID heapId); +static u16 *sub_0204BC7C(u32 frontierTrainerIndex, HeapID heapId); +static void GetFrontierMon(FrontierMon *mon, u32 frontierMonIndex); + +static const u16 _020FBFA4[] = { ITEM_BRIGHTPOWDER, ITEM_LUM_BERRY, ITEM_LEFTOVERS, ITEM_QUICK_CLAW }; +static const u16 _020FBFAC[][2] = { + { 0, 99 }, + { 80, 119 }, + { 100, 139 }, + { 120, 159 }, + { 140, 179 }, + { 160, 199 }, + { 180, 219 }, + { 200, 299 }, +}; +static const u16 _020FBFEC[][2] = { + { 90, 141 }, + { 91, 142 }, + { 92, 143 }, + { 93, 144 }, + { 94, 145 }, + { 2, 4 }, + { 3, 6 }, + { 60, 3 }, + { 61, 8 }, + { 32, 62 }, + { 33, 63 }, + { 4, 52 }, + { 5, 53 }, + { 44, 1 }, + { 45, 2 }, + { 20, 15 }, + { 21, 16 }, + { 81, 59 }, + { 26, 60 }, + { 16, 9 }, + { 17, 12 }, + { 83, 23 }, + { 84, 22 }, + { 71, 41 }, + { 18, 42 }, + { 12, 38 }, + { 13, 39 }, + { 14, 51 }, + { 10, 7 }, + { 27, 17 }, + { 35, 37 }, + { 49, 70 }, + { 50, 70 }, + { 39, 11 }, + { 40, 14 }, + { 24, 11 }, + { 25, 14 }, + { 53, 68 }, + { 54, 69 }, + { 29, 11 }, + { 6, 5 }, + { 28, 1 }, + { 19, 45 }, + { 11, 54 }, + { 46, 56 }, + { 9, 20 }, + { 48, 50 }, + { 52, 10 }, + { 37, 19 }, + { 57, 31 }, + { 78, 29 }, + { 34, 36 }, + { 59, 40 }, + { 58, 43 }, + { 38, 34 }, + { 51, 62 }, + { 69, 14 }, + { 80, 55 }, + { 36, 13 }, + { 7, 12 }, + { 85, 35 }, + { 15, 44 }, + { 22, 71 }, +}; +static const u16 _020FBFCC[][2] = { + { 100, 119 }, + { 120, 139 }, + { 140, 159 }, + { 160, 179 }, + { 180, 199 }, + { 200, 219 }, + { 220, 239 }, + { 200, 299 }, +}; + +MessageFormat *sub_0204B538(SaveData *saveData, u16 numEligiblePokemon, u16 a2, u8 a3, u8 *numLegendaryPokemonSeen) { + String *speciesName, *unused; + Pokedex *pokedex; + MessageFormat *messageFormat; + MsgData *messageData; + speciesName = String_New(14, HEAP_ID_4); + unused = String_New(2, HEAP_ID_4); + pokedex = Save_Pokedex_Get(saveData); + messageData = NewMsgDataFromNarc(MSGDATA_LOAD_LAZY, NARC_msgdata_msg, NARC_msg_msg_0237_bin, HEAP_ID_4); + messageFormat = MessageFormat_New_Custom(19, 14, HEAP_ID_4); + BufferIntegerAsString(messageFormat, 0, numEligiblePokemon, 1, PRINTING_MODE_LEFT_ALIGN, TRUE); + for (u8 i = 0; i < NUM_BANNED_BATTLE_FRONTIER; i++) { + u16 species = GetBannedBattleFrontierPokemon(i); + if (!Pokedex_CheckMonSeenFlag(pokedex, species)) { + continue; + } + ReadMsgDataIntoString(messageData, species, speciesName); + BufferString(messageFormat, *numLegendaryPokemonSeen + 1, speciesName, a2, a3, 2); + (*numLegendaryPokemonSeen)++; + } + DestroyMsgData(messageData); + String_Delete(unused); + String_Delete(speciesName); + return messageFormat; +} + +u32 sub_0204B5E8(u8 a0) { + for (u32 i = 0; i < NELEMS(_020FBFEC); i++) { + if (a0 == _020FBFEC[i][0]) { + return _020FBFEC[i][1]; + } + } + return 3; +} + +u16 sub_0204B610(FieldSystem *fieldSystem, u16 *a1) { + u16 unk = 0; + UnkStruct_Fsys_A0 *unkStruct = fieldSystem->unkA0; + unkStruct->unk12 = a1[0]; + unkStruct->unk16 = a1[1]; + unkStruct->unk18 = a1[2]; + unkStruct->unk14 = a1[3]; + unkStruct->unk10_5 = unkStruct->unk12 + 5; + if (unkStruct->unk2e[0] == unkStruct->unk16 || unkStruct->unk2e[0] == unkStruct->unk18) { + unk++; + } + if (unkStruct->unk2e[1] == unkStruct->unk16 || unkStruct->unk2e[1] == unkStruct->unk18) { + unk += 2; + } + return unk; +} + +BOOL sub_0204B66C(FieldSystem *fieldSystem, u16 *a1) { + UnkStruct_Fsys_A0 *unkStruct = fieldSystem->unkA0; + if (sub_0203769C() == 0) { + return FALSE; + } + MI_CpuCopy8(a1, unkStruct->unk3e, sizeof(unkStruct->unk3e)); + return TRUE; +} + +BOOL sub_0204B690(FieldSystem *fieldSystem, u16 *a1) { + return fieldSystem->unkA0->unk10_3 || a1[0] != 0; +} + +void sub_0204B6AC(UnkStruct_Fsys_A0 *a0, SaveData *saveData) { + a0->unk83e[0] = PlayerProfile_GetTrainerGender(Save_PlayerData_GetProfileAddr(saveData)); + Party *party = SaveArray_Party_Get(saveData); + for (s32 i = 0; i < 2; i++) { + Pokemon *mon = Party_GetMonByIndex(party, a0->unk2a[i]); + a0->unk83e[1 + i] = GetMonData(mon, MON_DATA_SPECIES, NULL); + } + a0->unk83e[3] = sub_0202D57C(a0->unk74, 3, 0); +} + +void sub_0204B708(UnkStruct_Fsys_A0 *a0) { + MI_CpuCopy8(a0->unk3e, a0->unk83e, sizeof(a0->unk3e)); +} + +void sub_0204B720(UnkStruct_Fsys_A0 *a0, u32 a1) { + a0->unk10_3 = a1; + a0->unk83e[0] = a1; +} + +u16 sub_0204B73C(UnkStruct_Fsys_A0 *a0, u8 a1, u8 a2, u32 a3) { + if (a3 == 0) { + if (a1 == 2 && a2 == 6) { + return 305; + } + if (a1 == 6 && a2 == 6) { + return 306; + } + } + if (a1 < 7) { + if (a2 == 6) { + u16 mod = _020FBFCC[a1][1] - _020FBFCC[a1][0] + 1; + return sub_0204B510(a0) % mod + _020FBFCC[a1][0]; + } else { + u16 mod = _020FBFAC[a1][1] - _020FBFAC[a1][0] + 1; + return sub_0204B510(a0) % mod + _020FBFAC[a1][0]; + } + } else { + return sub_0204B510(a0) % 100 + 200; + } +} + +static u16 *sub_0204B7D0(UnkStruct_0204B7D0 *a0, u32 frontierTrainerIndex, HeapID heapId) { + MsgData *messageData = NewMsgDataFromNarc(MSGDATA_LOAD_LAZY, NARC_msgdata_msg, NARC_msg_msg_0027_bin, heapId); + MI_CpuClear8(a0, sizeof(UnkStruct_0204B7D0)); + u16 *unk = sub_0204BC7C(frontierTrainerIndex, heapId); + a0->unk00 = frontierTrainerIndex; + a0->unk18 = 0xffff; + a0->unk1a = frontierTrainerIndex * 3; + a0->unk04 = unk[0]; + String *trainerName = NewString_ReadMsgData(messageData, frontierTrainerIndex); + CopyStringToU16Array(trainerName, a0->unk08, NELEMS(a0->unk08)); + String_Delete(trainerName); + DestroyMsgData(messageData); + return unk; +} + +static u32 sub_0204B834(UnkStruct_Fsys_A0 *a0, UnkStruct_0204B470 *a1, u16 frontierMonIndex, u32 otId, u32 a4, u8 iv, u8 a6, BOOL a7, HeapID heapId) { + s32 i; + FrontierMon frontierMon; + MI_CpuClear8(a1, sizeof(UnkStruct_0204B470)); + GetFrontierMon(&frontierMon, frontierMonIndex); + a1->species = frontierMon.species; + a1->form = frontierMon.form; + a1->item = a7 ? _020FBFA4[a6] : frontierMon.item; + u32 friendship = FRIENDSHIP_MAX; + for (i = 0; i < MAX_MON_MOVES; i++) { + a1->moves[i] = frontierMon.moves[i]; + if (frontierMon.moves[i] == MOVE_FRUSTRATION) { + friendship = 0; + } + } + a1->otId = otId; + u32 pid; + if (a4 == 0) { + do { + pid = sub_0204B510(a0) | sub_0204B510(a0) << 16; + } while (frontierMon.nature != GetNatureFromPersonality(pid) + || CalcShininessByOtIdAndPersonality(otId, pid) == TRUE + ); + a1->pid = pid; + } else { + a1->pid = a4; + pid = a4; + } + a1->hpIv = iv; + a1->atkIv = iv; + a1->defIv = iv; + a1->spdIv = iv; + a1->spAtkIv = iv; + a1->spDefIv = iv; + s32 ev = 0; + for (i = 0; i < NUM_STATS; i++) { + if (frontierMon.evs & MaskOfFlagNo(i)) { + ev++; + } + } + ev = MAX_EV_SUM / ev; + if (ev > 255) { + ev = 255; + } + for (i = 0; i < NUM_STATS; i++) { + if (frontierMon.evs & MaskOfFlagNo(i)) { + a1->evs[i] = ev; + } + } + a1->ppUp = 0; + a1->language = gGameLanguage; + u32 ability = GetMonBaseStat(a1->species, BASE_ABILITY_2); + if (ability != ABILITY_NONE) { + if (a1->pid % 2) { + a1->ability = ability; + } else { + a1->ability = GetMonBaseStat(a1->species, BASE_ABILITY_1); + } + } else { + a1->ability = GetMonBaseStat(a1->species, BASE_ABILITY_1); + } + a1->friendship = friendship; + GetSpeciesNameIntoArray(a1->species, heapId, a1->nickname); + return pid; +} + +u32 sub_0204BA04(UnkStruct_Fsys_A0 *a0, UnkStruct_0204B7D0 *a1, u16 frontierTrainerIndex, u32 a3, u16 *a4, u16 *a5, UnkStruct_0204A824_7E8 *a6, HeapID heapId) { + u16 *unk7 = sub_0204B7D0(a1, frontierTrainerIndex, heapId); + u32 unk4 = sub_0204BABC(a0, unk7, frontierTrainerIndex, a1->unk30, a3, a4, a5, a6, heapId); + FreeToHeap(unk7); + return unk4; +} + +void sub_0204BA50(UnkStruct_Fsys_A0 *a0, UnkStruct_0204B7D0 *a1, u16 frontierTrainerIndex, u32 a3, UnkStruct_0204A824_7E8 *a4, HeapID heapId) { + u8 iv; + u16 *unk = sub_0204B7D0(a1, frontierTrainerIndex, heapId); + iv = sub_0204B4D4(frontierTrainerIndex); + for (s32 i = 0; i < 2; i++) { + sub_0204B834(a0, &a1->unk30[i], a4->unk04[i], a4->otId, a4->unk08[i], iv, i, a3, heapId); + } + FreeToHeap(unk); +} + +static u32 sub_0204BABC(UnkStruct_Fsys_A0 *a0, u16 *a1, u16 frontierTrainerIndex, UnkStruct_0204B470 *a3, u8 a4, u16 *a5, u16 *a6, UnkStruct_0204A824_7E8 *a7, HeapID heapId) { + s32 i; + u8 iv; + u32 otId; + u32 frontierMonIndex; + u32 unk6c[4]; + u32 unk5c[4]; + s32 unk2c; + BOOL unk28 = FALSE; + FrontierMon unk3c; + FrontierMon unk4c; + GF_ASSERT(a4 <= 4); + s32 unk = 0; + unk2c = 0; + while (unk != a4) { + u8 index = sub_0204B510(a0) % a1[1]; + frontierMonIndex = a1[2 + index]; + GetFrontierMon(&unk4c, frontierMonIndex); + for (i = 0; i < unk; i++) { + GetFrontierMon(&unk3c, unk6c[i]); + if (unk3c.species == unk4c.species) { + break; + } + } + if (i != unk) { + continue; + } + if (a5) { + for (i = 0; i < a4; i++) { + if (a5[i] == unk4c.species) { + break; + } + } + if (i != a4) { + continue; + } + } + if (unk2c < 50) { + for (i = 0; i < unk; i++) { + GetFrontierMon(&unk3c, unk6c[i]); + if (unk3c.item && unk3c.item == unk4c.item) { + break; + } + } + if (i != unk) { + unk2c++; + continue; + } + if (a6) { + for (i = 0; i < a4; i++) { + if (a6[i] == unk4c.item && a6[i] != ITEM_NONE) { + break; + } + } + if (i != a4) { + unk2c++; + continue; + } + } + } + unk6c[unk] = frontierMonIndex; + unk++; + } + iv = sub_0204B4D4(frontierTrainerIndex); + otId = sub_0204B510(a0) | sub_0204B510(a0) << 16; + if (unk2c >= 50) { + unk28 = TRUE; + } + for (i = 0; i < unk; i++) { + unk5c[i] = sub_0204B834(a0, &a3[i], unk6c[i], otId, 0, iv, i, unk28, heapId); + } + if (a7 == NULL) { + return unk28; + } + a7->otId = otId; + for (i = 0; i < 2; i++) { + a7->unk04[i] = unk6c[i]; + a7->unk08[i] = unk5c[i]; + } + return unk28; +} + +static u16 *sub_0204BC7C(u32 frontierTrainerIndex, HeapID heapId) { + return AllocAndReadWholeNarcMemberByIdPair(NARC_a_2_0_2, frontierTrainerIndex, heapId); +} + +static void GetFrontierMon(FrontierMon *mon, u32 frontierMonIndex) { + ReadWholeNarcMemberByIdPair(mon, NARC_a_2_0_3, frontierMonIndex); +}