diff options
Diffstat (limited to 'arm9')
| -rw-r--r-- | arm9/asm/scrcmd_24.s | 316 | ||||
| -rw-r--r-- | arm9/asm/unk_02038C78.s | 20 | ||||
| -rw-r--r-- | arm9/global.inc | 20 | ||||
| -rw-r--r-- | arm9/src/scrcmd_24.c | 276 | 
4 files changed, 296 insertions, 336 deletions
| diff --git a/arm9/asm/scrcmd_24.s b/arm9/asm/scrcmd_24.s deleted file mode 100644 index b9569382..00000000 --- a/arm9/asm/scrcmd_24.s +++ /dev/null @@ -1,316 +0,0 @@ -    .include "asm/macros.inc" -    .include "global.inc" - -	.text - -	thumb_func_start FUN_02045D88 -FUN_02045D88: ; 0x02045D88 -	push {r4-r6, lr} -	add r5, r0, #0x0 -	bl ScriptReadHalfword -	add r1, r0, #0x0 -	add r0, r5, #0x0 -	add r0, #0x80 -	ldr r0, [r0, #0x0] -	bl VarGet -	add r4, r0, #0x0 -	add r0, r5, #0x0 -	add r0, #0x80 -	ldr r0, [r0, #0x0] -	mov r1, #0x13 -	bl FUN_02039438 -	add r1, r5, #0x0 -	add r1, #0x80 -	lsl r2, r4, #0x18 -	add r6, r0, #0x0 -	ldr r1, [r1, #0x0] -	mov r0, #0x20 -	lsr r2, r2, #0x18 -	bl FUN_02037CF0 -	str r0, [r6, #0x0] -	ldr r1, _02045DCC ; =FUN_0203BC04 -	add r0, r5, #0x0 -	bl SetupNativeScript -	mov r0, #0x1 -	pop {r4-r6, pc} -	nop -_02045DCC: .word FUN_0203BC04 - -	thumb_func_start FUN_02045DD0 -FUN_02045DD0: ; 0x02045DD0 -	push {r3-r5, lr} -	add r4, r0, #0x0 -	bl ScriptReadHalfword -	add r1, r0, #0x0 -	add r0, r4, #0x0 -	add r0, #0x80 -	ldr r0, [r0, #0x0] -	bl GetVarPointer -	add r4, #0x80 -	add r5, r0, #0x0 -	ldr r0, [r4, #0x0] -	mov r1, #0x13 -	bl FUN_02039438 -	add r4, r0, #0x0 -	ldr r0, [r4, #0x0] -	cmp r0, #0x0 -	bne _02045DFC -	bl ErrorHandling -_02045DFC: -	ldr r0, [r4, #0x0] -	bl FUN_02037D5C -	strh r0, [r5, #0x0] -	ldrh r0, [r5, #0x0] -	cmp r0, #0x4 -	bne _02045E0E -	mov r0, #0xff -	strh r0, [r5, #0x0] -_02045E0E: -	ldr r0, [r4, #0x0] -	bl FreeToHeap -	mov r0, #0x0 -	str r0, [r4, #0x0] -	pop {r3-r5, pc} -	.balign 4 - -	thumb_func_start FUN_02045E1C -FUN_02045E1C: ; 0x02045E1C -	mov r0, #0x0 -	bx lr - -	thumb_func_start FUN_02045E20 -FUN_02045E20: ; 0x02045E20 -	push {r4-r6, lr} -	add r5, r0, #0x0 -	bl ScriptReadHalfword -	add r1, r0, #0x0 -	add r0, r5, #0x0 -	add r0, #0x80 -	ldr r0, [r0, #0x0] -	bl GetVarPointer -	add r4, r0, #0x0 -	add r0, r5, #0x0 -	bl ScriptReadHalfword -	add r1, r0, #0x0 -	add r0, r5, #0x0 -	add r0, #0x80 -	ldr r0, [r0, #0x0] -	bl VarGet -	add r5, #0x80 -	add r6, r0, #0x0 -	ldr r0, [r5, #0x0] -	ldr r0, [r0, #0xc] -	bl SavArray_PlayerParty_get -	add r1, r6, #0x0 -	bl GetPartyMonByIndex -	mov r1, #0x20 -	bl FUN_02088DF8 -	add r5, r0, #0x0 -	bl FUN_02088EF8 -	strh r0, [r4, #0x0] -	add r0, r5, #0x0 -	bl FreeToHeap -	mov r0, #0x0 -	pop {r4-r6, pc} -	.balign 4 - -	thumb_func_start FUN_02045E74 -FUN_02045E74: ; 0x02045E74 -	push {r3-r7, lr} -	sub sp, #0x8 -	add r5, r0, #0x0 -	add r0, #0x80 -	add r7, r1, #0x0 -	ldr r0, [r0, #0x0] -	mov r1, #0x13 -	str r2, [sp, #0x0] -	add r6, r3, #0x0 -	bl FUN_02039438 -	str r0, [sp, #0x4] -	mov r0, #0x20 -	bl FUN_02088DD8 -	add r4, r0, #0x0 -	ldr r0, [sp, #0x4] -	str r4, [r0, #0x0] -	ldr r0, [sp, #0x0] -	str r0, [r4, #0x0] -	add r0, r5, #0x0 -	add r0, #0x80 -	ldr r0, [r0, #0x0] -	bl ScriptEnvironment_GetSav2Ptr -	bl Sav2_PlayerData_GetProfileAddr -	str r0, [r4, #0x4] -	add r0, r5, #0x0 -	add r0, #0x80 -	ldr r0, [r0, #0x0] -	ldr r0, [r0, #0xc] -	bl Sav2_PlayerData_GetOptionsAddr -	str r0, [r4, #0x8] -	str r6, [r4, #0xc] -	add r0, r5, #0x0 -	strb r7, [r4, #0x15] -	add r0, #0x80 -	ldr r0, [r0, #0x0] -	add r1, r4, #0x0 -	bl FUN_02038864 -	ldr r1, _02045EDC ; =FUN_0203BC04 -	add r0, r5, #0x0 -	bl SetupNativeScript -	add r0, r6, #0x0 -	bl FreeToHeap -	add sp, #0x8 -	pop {r3-r7, pc} -	.balign 4 -_02045EDC: .word FUN_0203BC04 - -	thumb_func_start FUN_02045EE0 -FUN_02045EE0: ; 0x02045EE0 -	mov r0, #0x1 -	bx lr - -	thumb_func_start FUN_02045EE4 -FUN_02045EE4: ; 0x02045EE4 -	push {r3-r5, lr} -	add r5, r0, #0x0 -	bl ScriptReadHalfword -	add r1, r0, #0x0 -	add r0, r5, #0x0 -	add r0, #0x80 -	ldr r0, [r0, #0x0] -	bl VarGet -	add r4, r0, #0x0 -	add r0, r5, #0x0 -	add r0, #0x80 -	ldr r0, [r0, #0x0] -	ldr r0, [r0, #0xc] -	bl SavArray_PlayerParty_get -	add r1, r4, #0x0 -	bl GetPartyMonByIndex -	add r4, r0, #0x0 -	mov r1, #0x20 -	bl FUN_02088DF8 -	add r3, r0, #0x0 -	add r0, r5, #0x0 -	mov r1, #0x1 -	add r2, r4, #0x0 -	bl FUN_02045E74 -	mov r0, #0x1 -	pop {r3-r5, pc} - -	thumb_func_start FUN_02045F24 -FUN_02045F24: ; 0x02045F24 -	push {r4-r6, lr} -	add r5, r0, #0x0 -	bl ScriptReadHalfword -	add r1, r0, #0x0 -	add r0, r5, #0x0 -	add r0, #0x80 -	ldr r0, [r0, #0x0] -	bl VarGet -	add r6, r0, #0x0 -	add r0, r5, #0x0 -	bl ScriptReadHalfword -	add r1, r0, #0x0 -	add r0, r5, #0x0 -	add r0, #0x80 -	ldr r0, [r0, #0x0] -	bl VarGet -	add r4, r0, #0x0 -	add r0, r5, #0x0 -	add r0, #0x80 -	ldr r0, [r0, #0x0] -	ldr r0, [r0, #0xc] -	bl SavArray_PlayerParty_get -	add r1, r6, #0x0 -	bl GetPartyMonByIndex -	add r6, r0, #0x0 -	mov r0, #0x20 -	mov r1, #0x4 -	bl AllocFromHeap -	add r3, r0, #0x0 -	ldr r0, _02045F80 ; =0x0000FFFF -	strh r4, [r3, #0x0] -	strh r0, [r3, #0x2] -	add r0, r5, #0x0 -	mov r1, #0x0 -	add r2, r6, #0x0 -	bl FUN_02045E74 -	mov r0, #0x1 -	pop {r4-r6, pc} -	.balign 4 -_02045F80: .word 0x0000FFFF - -	thumb_func_start FUN_02045F84 -FUN_02045F84: ; 0x02045F84 -	mov r0, #0x0 -	bx lr - -	thumb_func_start FUN_02045F88 -FUN_02045F88: ; 0x02045F88 -	push {r3-r5, lr} -	add r4, r0, #0x0 -	bl ScriptReadHalfword -	add r1, r0, #0x0 -	add r0, r4, #0x0 -	add r0, #0x80 -	ldr r0, [r0, #0x0] -	bl GetVarPointer -	add r4, #0x80 -	add r5, r0, #0x0 -	ldr r0, [r4, #0x0] -	mov r1, #0x13 -	bl FUN_02039438 -	ldr r4, [r0, #0x0] -	cmp r4, #0x0 -	bne _02045FB2 -	bl ErrorHandling -_02045FB2: -	ldrb r0, [r4, #0x16] -	cmp r0, #0x0 -	bne _02045FBC -	mov r0, #0x0 -	b _02045FBE -_02045FBC: -	mov r0, #0xff -_02045FBE: -	strh r0, [r5, #0x0] -	add r0, r4, #0x0 -	bl FUN_02088DF0 -	mov r0, #0x0 -	pop {r3-r5, pc} -	.balign 4 - -	thumb_func_start FUN_02045FCC -FUN_02045FCC: ; 0x02045FCC -	push {r3-r5, lr} -	add r4, r0, #0x0 -	bl ScriptReadHalfword -	add r1, r0, #0x0 -	add r0, r4, #0x0 -	add r0, #0x80 -	ldr r0, [r0, #0x0] -	bl GetVarPointer -	add r4, #0x80 -	add r5, r0, #0x0 -	ldr r0, [r4, #0x0] -	mov r1, #0x13 -	bl FUN_02039438 -	ldr r4, [r0, #0x0] -	cmp r4, #0x0 -	bne _02045FF6 -	bl ErrorHandling -_02045FF6: -	ldrb r0, [r4, #0x16] -	cmp r0, #0x0 -	bne _02046000 -	mov r0, #0x0 -	b _02046002 -_02046000: -	mov r0, #0xff -_02046002: -	strh r0, [r5, #0x0] -	add r0, r4, #0x0 -	bl FUN_02088DF0 -	mov r0, #0x0 -	pop {r3-r5, pc} -	.balign 4 diff --git a/arm9/asm/unk_02038C78.s b/arm9/asm/unk_02038C78.s index 3369ec2e..b60088a5 100644 --- a/arm9/asm/unk_02038C78.s +++ b/arm9/asm/unk_02038C78.s @@ -603,8 +603,8 @@ gScriptCmdTable: ; 0x020F355C      .word FUN_0203E078      .word FUN_0203E0CC      .word FUN_0203E120 -    .word FUN_02045D88 -    .word FUN_02045DD0 +    .word ScrCmd_Unk01C6 +    .word ScrCmd_Unk01C7      .word FUN_02044D8C      .word FUN_02044E34      .word FUN_02044E78 @@ -691,14 +691,14 @@ gScriptCmdTable: ; 0x020F355C      .word FUN_0203E848      .word FUN_0203E858      .word ScrCmd_Unk021D -    .word FUN_02045E1C -    .word FUN_02045E20 -    .word FUN_02045EE0 -    .word FUN_02045EE4 -    .word FUN_02045F84 -    .word FUN_02045F88 -    .word FUN_02045F24 -    .word FUN_02045FCC +    .word ScrCmd_Unk021E +    .word ScrCmd_Unk021F +    .word ScrCmd_Unk0220 +    .word ScrCmd_Unk0221 +    .word ScrCmd_Unk0222 +    .word ScrCmd_Unk0223 +    .word ScrCmd_Unk0224 +    .word ScrCmd_Unk0225      .word FUN_0203E870      .word FUN_0203E894      .word FUN_0203E8C4 diff --git a/arm9/global.inc b/arm9/global.inc index 2a318a97..71b29db9 100644 --- a/arm9/global.inc +++ b/arm9/global.inc @@ -3402,16 +3402,16 @@  .extern ScrCmd_Unk0090  .extern ScrCmd_Unk0091  .extern ScrCmd_Unk0092 -.extern FUN_02045D88 -.extern FUN_02045DD0 -.extern FUN_02045E1C -.extern FUN_02045E20 -.extern FUN_02045EE0 -.extern FUN_02045EE4 -.extern FUN_02045F24 -.extern FUN_02045F84 -.extern FUN_02045F88 -.extern FUN_02045FCC +.extern ScrCmd_Unk01C6 +.extern ScrCmd_Unk01C7 +.extern ScrCmd_Unk021E +.extern ScrCmd_Unk021F +.extern ScrCmd_Unk0220 +.extern ScrCmd_Unk0221 +.extern ScrCmd_Unk0224 +.extern ScrCmd_Unk0222 +.extern ScrCmd_Unk0223 +.extern ScrCmd_Unk0225  .extern ScrCmd_Unk023F  .extern ScrCmd_Unk0240  .extern ScrCmd_Unk0241 diff --git a/arm9/src/scrcmd_24.c b/arm9/src/scrcmd_24.c new file mode 100644 index 00000000..d3f955d0 --- /dev/null +++ b/arm9/src/scrcmd_24.c @@ -0,0 +1,276 @@ +#include "scrcmd.h" +#include "heap.h" +#include "party.h" +#include "unk_020377F0.h" +#include "unk_02088DD8.h" + +extern void* FUN_02039438(struct UnkSavStruct80*, int idx); + +extern struct UnkStruct_02037CF0* FUN_02037CF0(u32 heap_id, struct UnkSavStruct80*, u8); +extern u8 FUN_02037D5C(struct UnkStruct_02037CF0*); +extern void FUN_02038864(struct UnkSavStruct80*, struct UnkStruct_02088DD8*); +extern BOOL FUN_0203BC04(struct ScriptContext* ctx); +extern struct UnkStruct_02088DD8* FUN_02088DD8(u32 heap_id); +extern void FUN_02088DF0(struct UnkStruct_02037CF0*); +extern void* FUN_02088DF8(struct Pokemon* pokemon, u32 heap_id); +extern BOOL FUN_02088EF8(void*); + +THUMB_FUNC BOOL ScrCmd_Unk01C6(struct ScriptContext* ctx) +{ +    u16 unk = VarGet(ctx->unk80, ScriptReadHalfword(ctx)); +    struct UnkStruct_02037CF0** unk_ret_ptr = FUN_02039438(ctx->unk80, 19); +    *unk_ret_ptr = FUN_02037CF0(32, ctx->unk80, (u8)unk); + +    SetupNativeScript(ctx, FUN_0203BC04); +    return TRUE; +} + +#ifdef NONMATCHING +THUMB_FUNC BOOL ScrCmd_Unk01C7(struct ScriptContext* ctx) +{ +    u16* ret_ptr = GetVarPointer(ctx->unk80, ScriptReadHalfword(ctx)); +    struct UnkStruct_02037CF0** unk_ptr = FUN_02039438(ctx->unk80, 19); +    GF_ASSERT(*unk_ptr != NULL); + +    *ret_ptr = FUN_02037D5C(*unk_ptr); +    if (*ret_ptr == 4) +    { +        *ret_ptr = 0xFF; +    } + +    FreeToHeap(*unk_ptr); +    *unk_ptr = NULL; +    return FALSE; +} +#else +THUMB_FUNC asm BOOL ScrCmd_Unk01C7(struct ScriptContext* ctx) +{ +    push {r3-r5, lr} +    add r4, r0, #0x0 +    bl ScriptReadHalfword +    add r1, r0, #0x0 +    add r0, r4, #0x0 +    add r0, #0x80 +    ldr r0, [r0, #0x0] +    bl GetVarPointer +    add r4, #0x80 +    add r5, r0, #0x0 +    ldr r0, [r4, #0x0] +    mov r1, #0x13 +    bl FUN_02039438 +    add r4, r0, #0x0 +    ldr r0, [r4, #0x0] +    cmp r0, #0x0 +    bne _02045DFC +    bl ErrorHandling +_02045DFC: +    ldr r0, [r4, #0x0] +    bl FUN_02037D5C +    strh r0, [r5, #0x0] +    ldrh r0, [r5, #0x0] +    cmp r0, #0x4 +    bne _02045E0E +    mov r0, #0xff +    strh r0, [r5, #0x0] +_02045E0E: +    ldr r0, [r4, #0x0] +    bl FreeToHeap +    mov r0, #0x0 +    str r0, [r4, #0x0] +    pop {r3-r5, pc} +} +#endif + +THUMB_FUNC BOOL ScrCmd_Unk021E(struct ScriptContext* ctx) +{ +#pragma unused(ctx) +    return FALSE; +} + +THUMB_FUNC BOOL ScrCmd_Unk021F(struct ScriptContext* ctx) +{ +    u16* ret_ptr = GetVarPointer(ctx->unk80, ScriptReadHalfword(ctx)); +    u16 mon_idx = VarGet(ctx->unk80, ScriptReadHalfword(ctx)); +    struct PlayerParty* party = SavArray_PlayerParty_get(ctx->unk80->saveBlock2); +    struct Pokemon* pokemon = GetPartyMonByIndex(party, mon_idx); +    void* unk_ptr = FUN_02088DF8(pokemon, 32); + +    *ret_ptr = (u16)FUN_02088EF8(unk_ptr); +    FreeToHeap(unk_ptr); + +    return FALSE; +} + +THUMB_FUNC void FUN_02045E74(struct ScriptContext* ctx, u8 a1, struct Pokemon* pokemon, void* a3) +{ +    struct UnkStruct_02088DD8** unk = FUN_02039438(ctx->unk80, 19); +    struct UnkStruct_02088DD8* unk2 = FUN_02088DD8(32); +    *unk = unk2; + +    unk2->pokemon = pokemon; + +    struct SaveBlock2* sav2 = ScriptEnvironment_GetSav2Ptr(ctx->unk80); +    unk2->player = Sav2_PlayerData_GetProfileAddr(sav2); + +    unk2->options = Sav2_PlayerData_GetOptionsAddr(ctx->unk80->saveBlock2); +    unk2->unkC = a3; +    unk2->unk15 = a1; +    FUN_02038864(ctx->unk80, unk2); + +    SetupNativeScript(ctx, FUN_0203BC04); +    FreeToHeap(a3); +} + +THUMB_FUNC BOOL ScrCmd_Unk0220(struct ScriptContext* ctx) +{ +#pragma unused(ctx) +    return TRUE; +} + +THUMB_FUNC BOOL ScrCmd_Unk0221(struct ScriptContext* ctx) +{ +    u16 mon_idx = VarGet(ctx->unk80, ScriptReadHalfword(ctx)); +    struct PlayerParty* party = SavArray_PlayerParty_get(ctx->unk80->saveBlock2); +    struct Pokemon* pokemon = GetPartyMonByIndex(party, mon_idx); +    void* unk_ptr = FUN_02088DF8(pokemon, 32); + +    FUN_02045E74(ctx, 1, pokemon, unk_ptr); +    return TRUE; +} + +THUMB_FUNC BOOL ScrCmd_Unk0224(struct ScriptContext* ctx) +{ +    u16 mon_idx = VarGet(ctx->unk80, ScriptReadHalfword(ctx)); +    u16 unk2 = VarGet(ctx->unk80, ScriptReadHalfword(ctx)); +    struct PlayerParty* party = SavArray_PlayerParty_get(ctx->unk80->saveBlock2); +    struct Pokemon* pokemon = GetPartyMonByIndex(party, mon_idx); + +    u16* unk_array = AllocFromHeap(32, 2 * sizeof(u16)); +    unk_array[0] = unk2; +    unk_array[1] = 0xFFFF; + +    FUN_02045E74(ctx, 0, pokemon, unk_array); +    return TRUE; +} + +THUMB_FUNC BOOL ScrCmd_Unk0222(struct ScriptContext* ctx) +{ +#pragma unused(ctx) +    return FALSE; +} + +#ifdef NONMATCHING +THUMB_FUNC BOOL ScrCmd_Unk0223(struct ScriptContext* ctx) +{ +    u16* ret_ptr = GetVarPointer(ctx->unk80, ScriptReadHalfword(ctx)); +    struct UnkStruct_02037CF0** unk = FUN_02039438(ctx->unk80, 19); +    struct UnkStruct_02037CF0* unk_sub = *unk; + +    GF_ASSERT(unk_sub != NULL); + +    if (unk_sub->unk16 == 0) +    { +        *ret_ptr = 0; +    } +    else +    { +        *ret_ptr = 0xFF; +    } + +    FUN_02088DF0(unk_sub); +    return FALSE; +} +#else +THUMB_FUNC asm BOOL ScrCmd_Unk0223(struct ScriptContext* ctx) +{ +    push {r3-r5, lr} +    add r4, r0, #0x0 +    bl ScriptReadHalfword +    add r1, r0, #0x0 +    add r0, r4, #0x0 +    add r0, #0x80 +    ldr r0, [r0, #0x0] +    bl GetVarPointer +    add r4, #0x80 +    add r5, r0, #0x0 +    ldr r0, [r4, #0x0] +    mov r1, #0x13 +    bl FUN_02039438 +    ldr r4, [r0, #0x0] +    cmp r4, #0x0 +    bne _02045FB2 +    bl ErrorHandling +_02045FB2: +    ldrb r0, [r4, #0x16] +    cmp r0, #0x0 +    bne _02045FBC +    mov r0, #0x0 +    b _02045FBE +_02045FBC: +    mov r0, #0xff +_02045FBE: +    strh r0, [r5, #0x0] +    add r0, r4, #0x0 +    bl FUN_02088DF0 +    mov r0, #0x0 +    pop {r3-r5, pc} +} +#endif + +#ifdef NONMATCHING +THUMB_FUNC BOOL ScrCmd_Unk0225(struct ScriptContext* ctx) +{ +    u16* ret_ptr = GetVarPointer(ctx->unk80, ScriptReadHalfword(ctx)); +    struct UnkStruct_02037CF0** unk = FUN_02039438(ctx->unk80, 19); +    struct UnkStruct_02037CF0* unk_sub = *unk; + +    GF_ASSERT(unk_sub != NULL); + +    if (unk_sub->unk16 == 0) +    { +        *ret_ptr = 0; +    } +    else +    { +        *ret_ptr = 0xFF; +    } + +    FUN_02088DF0(unk_sub); +    return FALSE; +} +#else +THUMB_FUNC asm BOOL ScrCmd_Unk0225(struct ScriptContext* ctx) +{ +    push {r3-r5, lr} +    add r4, r0, #0x0 +    bl ScriptReadHalfword +    add r1, r0, #0x0 +    add r0, r4, #0x0 +    add r0, #0x80 +    ldr r0, [r0, #0x0] +    bl GetVarPointer +    add r4, #0x80 +    add r5, r0, #0x0 +    ldr r0, [r4, #0x0] +    mov r1, #0x13 +    bl FUN_02039438 +    ldr r4, [r0, #0x0] +    cmp r4, #0x0 +    bne _02045FB2 +    bl ErrorHandling +_02045FB2: +    ldrb r0, [r4, #0x16] +    cmp r0, #0x0 +    bne _02045FBC +    mov r0, #0x0 +    b _02045FBE +_02045FBC: +    mov r0, #0xff +_02045FBE: +    strh r0, [r5, #0x0] +    add r0, r4, #0x0 +    bl FUN_02088DF0 +    mov r0, #0x0 +    pop {r3-r5, pc} +} +#endif | 
