From 499022b5af6f2e1d0f5eb9452e265e2121dd4e65 Mon Sep 17 00:00:00 2001 From: red031000 Date: Tue, 30 May 2023 15:55:23 +0100 Subject: [PATCH] ScrCmd_ShowPokemonPic --- arm9/asm/scrcmd_asm.s | 73 ++-------------------------------------- arm9/asm/unk_02038C78.s | 2 +- arm9/global.inc | 2 +- arm9/src/render_window.c | 47 +++++++++----------------- arm9/src/scrcmd.c | 11 ++++++ include/render_window.h | 17 ++++------ include/scrcmd.h | 1 + 7 files changed, 40 insertions(+), 113 deletions(-) diff --git a/arm9/asm/scrcmd_asm.s b/arm9/asm/scrcmd_asm.s index 1650e4e5c..9698e3175 100644 --- a/arm9/asm/scrcmd_asm.s +++ b/arm9/asm/scrcmd_asm.s @@ -13,73 +13,6 @@ .text - thumb_func_start ScrCmd_Unk0208 -ScrCmd_Unk0208: ; 0x0203BD28 - push {r4-r7, lr} - sub sp, #0x14 - add r5, r0, #0x0 - add r0, #0x80 - ldr r0, [r0, #0x0] - mov r1, #0x14 - bl FieldSysGetAttrAddr - 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 - bl ScriptReadHalfword - add r1, r0, #0x0 - add r0, r5, #0x0 - add r0, #0x80 - ldr r0, [r0, #0x0] - bl VarGet - add r7, r0, #0x0 - mov r0, #0x0 - str r0, [sp, #0x0] - mov r0, #0x4 - str r0, [sp, #0x4] - add r0, r5, #0x0 - add r0, #0x80 - ldr r0, [r0, #0x0] - ldr r2, _0203BDB4 ; =0x000003D9 - ldr r0, [r0, #0x8] - mov r1, #0x3 - mov r3, #0xb - bl LoadUserFrameGfx1 - mov r0, #0xb - str r0, [sp, #0x0] - ldr r0, _0203BDB4 ; =0x000003D9 - mov r1, #0x3 - str r0, [sp, #0x4] - lsl r0, r7, #0x18 - str r4, [sp, #0x8] - lsr r0, r0, #0x18 - str r0, [sp, #0xc] - mov r0, #0x4 - str r0, [sp, #0x10] - add r0, r5, #0x0 - add r0, #0x80 - ldr r0, [r0, #0x0] - mov r2, #0xa - ldr r0, [r0, #0x8] - mov r3, #0x5 - bl FUN_0200DC4C - add r5, #0x80 - str r0, [r6, #0x0] - ldr r0, [r5, #0x0] - add r1, r4, #0x0 - bl FUN_0203ED2C - mov r0, #0x0 - add sp, #0x14 - pop {r4-r7, pc} - .balign 4 -_0203BDB4: .word 0x000003D9 - thumb_func_start ScrCmd_Unk028C ScrCmd_Unk028C: ; 0x0203BDB8 push {r4-r6, lr} @@ -143,7 +76,7 @@ ScrCmd_Unk028C: ; 0x0203BDB8 lsl r1, r1, #0x10 ldr r0, [r5, #0x0] lsr r1, r1, #0x10 - bl FUN_0203ED2C + bl Script_SetMonSeenFlagBySpecies mov r0, #0x0 add sp, #0x10 pop {r4-r6, pc} @@ -5967,8 +5900,8 @@ ScrCmd_Unk024D: ; 0x0203ED10 pop {r3, pc} .balign 4 - thumb_func_start FUN_0203ED2C -FUN_0203ED2C: ; 0x0203ED2C + thumb_func_start Script_SetMonSeenFlagBySpecies +Script_SetMonSeenFlagBySpecies: ; 0x0203ED2C push {r4-r6, lr} sub sp, #0x10 ldr r0, [r0, #0xc] diff --git a/arm9/asm/unk_02038C78.s b/arm9/asm/unk_02038C78.s index 892eb8d05..d0fb1c457 100644 --- a/arm9/asm/unk_02038C78.s +++ b/arm9/asm/unk_02038C78.s @@ -669,7 +669,7 @@ gScriptCmdTable: ; 0x020F355C .word ScrCmd_Unk0205 .word ScrCmd_Unk0206 .word ScrCmd_Unk0207 - .word ScrCmd_Unk0208 + .word ScrCmd_ShowPokemonPic .word ScrCmd_Unk0209 .word ScrCmd_Unk020A .word ScrCmd_Unk020B diff --git a/arm9/global.inc b/arm9/global.inc index b67e06fb2..7f766e88a 100644 --- a/arm9/global.inc +++ b/arm9/global.inc @@ -2831,7 +2831,7 @@ .extern ScrCmd_Unk00A3 .extern ScrCmd_Unk00A4 .extern ScrCmd_Unk0207 -.extern ScrCmd_Unk0208 +.extern ScrCmd_ShowPokemonPic .extern ScrCmd_Unk028C .extern ScrCmd_Unk0209 .extern ScrCmd_Unk028D diff --git a/arm9/src/render_window.c b/arm9/src/render_window.c index 75eb23b60..f21725e33 100644 --- a/arm9/src/render_window.c +++ b/arm9/src/render_window.c @@ -687,51 +687,36 @@ THUMB_FUNC void FUN_0200DC24(WaitingIcon *waitingIcon) { waitingIcon->unk488 = 2; } -THUMB_FUNC u8 *FUN_0200DC4C(struct BgConfig *bg_config, - u8 bg_id, - u8 param2, - u8 param3, - u8 param4, - u16 param5, - u16 param6, - u8 param7, - s32 param8) +THUMB_FUNC PokepicManager *FUN_0200DC4C(struct BgConfig *bg_config, u8 bg_id, u8 param2, u8 param3, u8 param4, u16 numTiles, u16 species, u8 gender, s32 heapId) //DrawPokemonPicFromSpecies? { - struct UnkStruct_0200CABC_2 *r4 = FUN_0200DD70(bg_config, bg_id, param2, param3, (u32)param8); - FUN_0200DDAC(r4, (u32)param8); + struct UnkStruct_0200CABC_2 *r4 = FUN_0200DD70(bg_config, bg_id, param2, param3, heapId); + FUN_0200DDAC(r4, heapId); FUN_0200DDD8(r4); FUN_0200DE30(r4, param2, param3); - FUN_0200DE80(r4, param6, param7); - DrawFramed10x10Square(r4, param4, param5); + FUN_0200DE80(r4, species, gender); + DrawFramed10x10Square(r4, param4, numTiles); BgCommitTilemapBufferToVram(bg_config, bg_id); - return &r4->unk16f; + return &r4->pokepicManager; } -THUMB_FUNC u8 *FUN_0200DCA4(struct BgConfig *bg_config, - u8 bg_id, - u8 param2, - u8 param3, - u8 param4, - u16 param5, - struct Pokemon *param6, - s32 param7) +THUMB_FUNC PokepicManager *FUN_0200DCA4(struct BgConfig *bg_config, u8 bg_id, u8 param2, u8 param3, u8 param4, u16 numTiles, struct Pokemon *mon, s32 heapId) //DrawPokemonPicFromMon? { - struct UnkStruct_0200CABC_2 *r4 = FUN_0200DD70(bg_config, bg_id, param2, param3, (u32)param7); - FUN_0200DDAC(r4, (u32)param7); + struct UnkStruct_0200CABC_2 *r4 = FUN_0200DD70(bg_config, bg_id, param2, param3, heapId); + FUN_0200DDAC(r4, heapId); FUN_0200DDD8(r4); FUN_0200DE30(r4, param2, param3); - FUN_0200DEC0(r4, param6); - DrawFramed10x10Square(r4, param4, param5); + FUN_0200DEC0(r4, mon); + DrawFramed10x10Square(r4, param4, numTiles); BgCommitTilemapBufferToVram(bg_config, bg_id); - return &r4->unk16f; + return &r4->pokepicManager; } THUMB_FUNC void FUN_0200DCF8(u32 param0, void *param1) { struct UnkStruct_0200CABC_2 *unk = (struct UnkStruct_0200CABC_2 *)param1; - switch (unk->unk16f) + switch (unk->pokepicManager.unk00) { case 1: ClearFramed10x10Square(unk); @@ -740,13 +725,13 @@ THUMB_FUNC void FUN_0200DCF8(u32 param0, void *param1) FUN_0200621C((s32)param0); return; case 2: - unk->unk16f = 3; + unk->pokepicManager.unk00 = 3; FUN_02020130(*unk->unk164, 1); break; case 3: if (FUN_0202022C(*unk->unk164) == 6) { - unk->unk16f = 0; + unk->pokepicManager.unk00 = 0; } } @@ -759,7 +744,7 @@ THUMB_FUNC struct UnkStruct_0200CABC_2 *FUN_0200DD70( { struct UnkStruct_0200CABC_2 *res = FUN_0201B6C8(FUN_020061E8(FUN_0200DCF8, 0x170, 0, param4)); - res->unk16f = 0; + res->pokepicManager.unk00 = 0; res->bgConfig = bg_config; res->bgId = bg_id; res->x = param2; diff --git a/arm9/src/scrcmd.c b/arm9/src/scrcmd.c index 3dbbd4e94..aabd8165c 100644 --- a/arm9/src/scrcmd.c +++ b/arm9/src/scrcmd.c @@ -112,6 +112,7 @@ extern BOOL FUN_020270B4(SaveFashionData *fashionData, u32 param1); extern void MOD05_021F02C4(struct FieldSystem *fieldSystem); extern void FUN_0206F3B8(struct TaskManager *taskManager); extern u16 FUN_02031190(void); +extern void Script_SetMonSeenFlagBySpecies(struct FieldSystem *fieldSystem, u16 species); u8 UNK_021C5A0C[4]; @@ -2003,3 +2004,13 @@ THUMB_FUNC BOOL ScrCmd_Unk0207(ScriptContext *ctx) { //0207 *ptr = FUN_02031190(); return TRUE; } + +THUMB_FUNC BOOL ScrCmd_ShowPokemonPic(ScriptContext *ctx) { //0208 + PokepicManager **pokepicManager = FieldSysGetAttrAddr(ctx->fieldSystem, SCRIPTENV_MISC_DATA_PTR); + u16 species = ScriptGetVar(ctx); + u16 gender = ScriptGetVar(ctx); + LoadUserFrameGfx1(ctx->fieldSystem->bgConfig, GF_BG_LYR_MAIN_3, 0x3D9, 11, 0, 4); + *pokepicManager = FUN_0200DC4C(ctx->fieldSystem->bgConfig, GF_BG_LYR_MAIN_3, 10, 5, 11, 0x3D9, species, gender, 4); + Script_SetMonSeenFlagBySpecies(ctx->fieldSystem, species); + return FALSE; +} diff --git a/include/render_window.h b/include/render_window.h index f3a2b18f1..afa492397 100644 --- a/include/render_window.h +++ b/include/render_window.h @@ -6,6 +6,10 @@ #include "pokemon.h" #include "unk_02008DEC.h" +typedef struct PokepicManager { + u8 unk00; +} PokepicManager; //todo: fill out + typedef struct WaitingIcon { struct Window *window; u8 unk004[9][0x80]; @@ -28,7 +32,7 @@ struct UnkStruct_0200CABC_2 u8 bgId; u8 x; u8 y; - u8 unk16f; + PokepicManager pokepicManager; }; struct UnkStruct_0200CABC_3 @@ -106,15 +110,8 @@ void FUN_0200DB7C(u32 param0, void *param1); void FUN_0200DBE8(u32 param0, void *param1); void FUN_0200DBFC(WaitingIcon *waitingIcon); void FUN_0200DC24(WaitingIcon *waitingIcon); -u8 *FUN_0200DC4C(struct BgConfig *bg_config, u8 bg_id, u8 param2, u8 param3, u8 param4, u16 param5, u16 param6, u8 param7, s32 param8); -u8 *FUN_0200DCA4(struct BgConfig *bg_config, - u8 bg_id, - u8 param2, - u8 param3, - u8 param4, - u16 param5, - struct Pokemon *param6, - s32 param7); +PokepicManager *FUN_0200DC4C(struct BgConfig *bg_config, u8 bg_id, u8 param2, u8 param3, u8 param4, u16 numTiles, u16 species, u8 gender, s32 heapId); +PokepicManager *FUN_0200DCA4(struct BgConfig *bg_config, u8 bg_id, u8 param2, u8 param3, u8 param4, u16 numTiles, struct Pokemon *mon, s32 heapId); void FUN_0200DCF8(u32 param0, void *param1); struct UnkStruct_0200CABC_2 *FUN_0200DD70(struct BgConfig *bg_config, u8 bg_id, u8 param2, u8 param3, u32 param4); void FUN_0200DDAC(struct UnkStruct_0200CABC_2 *param0, u32 param1); diff --git a/include/scrcmd.h b/include/scrcmd.h index d0ea314ce..9ea348927 100644 --- a/include/scrcmd.h +++ b/include/scrcmd.h @@ -167,6 +167,7 @@ BOOL ScrCmd_Unk00A2(ScriptContext *ctx); BOOL ScrCmd_Unk00A3(ScriptContext *ctx); BOOL ScrCmd_Unk00A4(ScriptContext *ctx); BOOL ScrCmd_Unk0207(ScriptContext *ctx); +BOOL ScrCmd_ShowPokemonPic(ScriptContext *ctx); // scrcmd_mart.c BOOL ScrCmd_NormalMart(struct ScriptContext * ctx);