scrcmd + documentation

This commit is contained in:
red031000
2023-06-08 20:11:13 +01:00
parent e2ca23e51d
commit 5ef7784eae
13 changed files with 114 additions and 189 deletions

View File

@@ -629,7 +629,7 @@ FUN_02042324: ; 0x02042324
ldr r0, [r0, #0xc]
bl Save_FashionData_Get
mov r1, #0x0
bl FUN_02027098
bl CheckPortraitSlotFull
pop {r3, pc}
thumb_func_start FUN_02042334

View File

@@ -8,152 +8,9 @@
.extern FUN_0203BB90
.extern FUN_0203BBBC
.extern FUN_0203BC04
.extern FUN_0203BC3C
.text
thumb_func_start ScrCmd_Unk012E
ScrCmd_Unk012E: ; 0x0203C054
push {r4-r6, lr}
add r5, r0, #0x0
bl ScriptReadHalfword
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 GetVarPointer
add r5, #0x80
add r4, r0, #0x0
ldr r0, [r5, #0x0]
mov r1, #0x0
add r2, r6, #0x0
bl FUN_0203BC3C
cmp r0, #0x1
bne _0203C088
mov r0, #0x1
strh r0, [r4, #0x0]
pop {r4-r6, pc}
_0203C088:
mov r0, #0x0
strh r0, [r4, #0x0]
mov r0, #0x1
pop {r4-r6, pc}
thumb_func_start ScrCmd_Unk012F
ScrCmd_Unk012F: ; 0x0203C090
push {r4-r6, lr}
add r5, r0, #0x0
bl ScriptReadHalfword
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 GetVarPointer
add r5, #0x80
add r4, r0, #0x0
ldr r0, [r5, #0x0]
mov r1, #0x1
add r2, r6, #0x0
bl FUN_0203BC3C
cmp r0, #0x1
bne _0203C0C4
mov r0, #0x1
strh r0, [r4, #0x0]
pop {r4-r6, pc}
_0203C0C4:
mov r0, #0x0
strh r0, [r4, #0x0]
mov r0, #0x1
pop {r4-r6, pc}
thumb_func_start ScrCmd_Unk0130
ScrCmd_Unk0130: ; 0x0203C0CC
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 r5, #0x80
add r4, r0, #0x0
ldr r0, [r5, #0x0]
ldr r0, [r0, #0xc]
bl Save_FashionData_Get
mov r1, #0x0
bl FUN_02027008
add r1, r4, #0x0
bl FUN_02027478
mov r0, #0x1
pop {r3-r5, pc}
thumb_func_start ScrCmd_Unk0205
ScrCmd_Unk0205: ; 0x0203C0FC
push {r4, lr}
add r4, r0, #0x0
add r0, #0x80
ldr r0, [r0, #0x0]
bl FUN_02038804
ldr r1, _0203C114 ; =FUN_0203BC04
add r0, r4, #0x0
bl SetupNativeScript
mov r0, #0x1
pop {r4, pc}
.balign 4
_0203C114: .word FUN_0203BC04
thumb_func_start ScrCmd_Unk00A9
ScrCmd_Unk00A9: ; 0x0203C118
push {r3, lr}
add r1, r0, #0x0
ldr r0, [r1, #0x74]
add r1, #0x80
ldr r1, [r1, #0x0]
ldr r1, [r1, #0xc]
bl FUN_02085F48
mov r0, #0x1
pop {r3, pc}
thumb_func_start ScrCmd_Unk00AA
ScrCmd_Unk00AA: ; 0x0203C12C
push {r3-r5, lr}
add r5, r0, #0x0
add r0, #0x80
ldr r0, [r0, #0x0]
mov r1, #0x13
bl FieldSysGetAttrAddr
mov r1, #0x5
add r4, r0, #0x0
mov r0, #0xb
lsl r1, r1, #0x6
bl AllocFromHeap
str r0, [r4, #0x0]
add r0, r5, #0x0
add r0, #0x80
ldr r0, [r0, #0x0]
ldr r1, [r4, #0x0]
mov r2, #0x2
bl FUN_0205F7A0
add r0, r5, #0x0
add r0, #0x80
ldr r0, [r0, #0x0]
ldr r1, [r4, #0x0]
bl FUN_02037E90
ldr r1, _0203C170 ; =FUN_0203BB90
add r0, r5, #0x0
bl SetupNativeScript
mov r0, #0x1
pop {r3-r5, pc}
nop
_0203C170: .word FUN_0203BB90
thumb_func_start ScrCmd_Unk01D7
ScrCmd_Unk01D7: ; 0x0203C174
push {r3-r5, lr}

View File

@@ -535,8 +535,8 @@ FUN_0202708C: ; 0x0202708C
nop
_02027094: .word 0x000007F4
thumb_func_start FUN_02027098
FUN_02027098: ; 0x02027098
thumb_func_start CheckPortraitSlotFull
CheckPortraitSlotFull: ; 0x02027098
push {r3-r5, lr}
add r4, r1, #0x0
add r5, r0, #0x0
@@ -551,8 +551,8 @@ _020270A6:
pop {r3-r5, pc}
.balign 4
thumb_func_start FUN_020270B4
FUN_020270B4: ; 0x020270B4
thumb_func_start CheckContestPortraitSlotFull
CheckContestPortraitSlotFull: ; 0x020270B4
push {r3-r5, lr}
add r4, r1, #0x0
add r5, r0, #0x0

View File

@@ -2226,8 +2226,8 @@ FUN_02038790: ; 0x02038790
.balign 4
_02038800: .word UNK_020F2C74
thumb_func_start FUN_02038804
FUN_02038804: ; 0x02038804
thumb_func_start ShowGeonetScreen
ShowGeonetScreen: ; 0x02038804
ldr r3, _0203880C ; =FUN_020373D4
ldr r1, _02038810 ; =UNK_020F2D14
ldr r2, [r0, #0xc]

View File

@@ -318,8 +318,8 @@ gScriptCmdTable: ; 0x020F355C
.word ScrCmd_DressupPokemon
.word ScrCmd_ShowDressedPokemon
.word ScrCmd_ShowContestPokemon
.word ScrCmd_Unk00A9
.word ScrCmd_Unk00AA
.word ScrCmd_ShowSealCapsuleEditor
.word ScrCmd_ShowTownMapScreen
.word ScrCmd_MonStoragePC
.word ScrCmd_Unk00AC
.word ScrCmd_Unk00AD
@@ -451,8 +451,8 @@ gScriptCmdTable: ; 0x020F355C
.word ScrCmd_Unk012B
.word ScrCmd_Unk012C
.word ScrCmd_Unk012D
.word ScrCmd_Unk012E
.word ScrCmd_Unk012F
.word ScrCmd_CheckPortraitSlot
.word ScrCmd_CheckContestPortraitSlot
.word ScrCmd_Unk0130
.word ScrCmd_Unk0131
.word ScrCmd_Unk0132
@@ -666,7 +666,7 @@ gScriptCmdTable: ; 0x020F355C
.word ScrCmd_Unk0202
.word ScrCmd_Unk0203
.word ScrCmd_Unk0204
.word ScrCmd_Unk0205
.word ScrCmd_ShowGeonetScreen
.word ScrCmd_Unk0206
.word ScrCmd_Unk0207
.word ScrCmd_ShowPokemonPic

View File

@@ -3312,7 +3312,7 @@ FUN_0206250C: ; 0x0206250C
_02062514:
add r0, r6, #0x0
add r1, r4, #0x0
bl FUN_02027098
bl CheckPortraitSlotFull
cmp r0, #0x1
bne _02062522
add r5, r5, #0x1
@@ -3347,7 +3347,7 @@ _02062554:
_02062556:
add r0, r6, #0x0
add r1, r4, #0x0
bl FUN_02027098
bl CheckPortraitSlotFull
cmp r0, #0x1
bne _0206256C
cmp r5, #0x0

View File

@@ -821,8 +821,8 @@ _02085F38:
_02085F40: .word UNK_020FCAD8
_02085F44: .word UNK_020F96DC
thumb_func_start FUN_02085F48
FUN_02085F48: ; 0x02085F48
thumb_func_start ShowSealCapsuleEditor
ShowSealCapsuleEditor: ; 0x02085F48
push {r4-r6, lr}
add r6, r0, #0x0
add r5, r1, #0x0

View File

@@ -1782,8 +1782,8 @@
.extern FUN_02027008
.extern FUN_02027044
.extern FUN_0202708C
.extern FUN_02027098
.extern FUN_020270B4
.extern CheckPortraitSlotFull
.extern CheckContestPortraitSlotFull
.extern FUN_020270D8
.extern FUN_02027100
.extern FUN_02027114
@@ -2660,7 +2660,7 @@
.extern FUN_020386B4
.extern FUN_020386E0
.extern FUN_02038790
.extern FUN_02038804
.extern ShowGeonetScreen
.extern FUN_02038814
.extern FUN_02038824
.extern FUN_02038854
@@ -2842,12 +2842,12 @@
.extern ScrCmd_DressupPokemon
.extern ScrCmd_ShowDressedPokemon
.extern ScrCmd_ShowContestPokemon
.extern ScrCmd_Unk012E
.extern ScrCmd_Unk012F
.extern ScrCmd_CheckPortraitSlot
.extern ScrCmd_CheckContestPortraitSlot
.extern ScrCmd_Unk0130
.extern ScrCmd_Unk0205
.extern ScrCmd_Unk00A9
.extern ScrCmd_Unk00AA
.extern ScrCmd_ShowGeonetScreen
.extern ScrCmd_ShowSealCapsuleEditor
.extern ScrCmd_ShowTownMapScreen
.extern ScrCmd_Unk01D7
.extern ScrCmd_Unk01D8
.extern ScrCmd_Unk01D9
@@ -5351,7 +5351,7 @@
.extern FUN_02085BB0
.extern FUN_02085C08
.extern FUN_02085D9C
.extern FUN_02085F48
.extern ShowSealCapsuleEditor
.extern FUN_02085FAC
.extern FUN_02085FD0
.extern FUN_02085FF4

View File

@@ -108,8 +108,8 @@ extern u32 FUN_02029048(u32 param0);
extern void FUN_02028AD4(u32 *param0, u32 param1, u32 param2);
extern void FUN_0204AF3C(struct TaskManager *taskManager);
extern SaveFashionData *Save_FashionData_Get(struct SaveBlock2 *save);
extern BOOL FUN_02027098(SaveFashionData *fashionData, u32 param1);
extern BOOL FUN_020270B4(SaveFashionData *fashionData, u32 param1);
extern BOOL CheckPortraitSlotFull(SaveFashionData *fashionData, u32 portraitSlot);
extern BOOL CheckContestPortraitSlotFull(SaveFashionData *fashionData, u32 portraitSlot);
extern void MOD05_021F02C4(struct FieldSystem *fieldSystem);
extern void FUN_0206F3B8(struct TaskManager *taskManager);
extern u16 FUN_02031190(void);
@@ -119,6 +119,12 @@ extern void MOD05_021E1994(FieldSystem *fieldSystem, LocalMapObject *lastInterac
extern void FUN_0208A338(struct TaskManager *taskManager);
extern void FUN_020380CC(struct TaskManager *taskManager, u16 *param1, struct SaveBlock2 *save, u16 partyPos, u16 param4);
extern void FUN_02038130(FieldSystem *fieldSystem, FashionAppData *fashionData);
extern u32 FUN_02027008(SaveFashionData *fashionData, u32 param1);
extern void FUN_02027478(u32 param0, u16 param1);
extern void ShowGeonetScreen(FieldSystem *fieldSystem);
extern void ShowSealCapsuleEditor(TaskManager *taskManager, struct SaveBlock2 *save);
extern void FUN_0205F7A0(FieldSystem *fieldSystem, TownMapAppData *townMap, u32 param2); //TownMap_Init?
extern void FUN_02037E90(FieldSystem *fieldSystem, TownMapAppData *townMap); //ShowTownMap?
u8 UNK_021C5A0C[4];
@@ -147,8 +153,8 @@ static BOOL FUN_0203B218(struct ScriptContext *ctx);
/*static*/ BOOL FUN_0203BB90(ScriptContext *ctx);
/*static*/ BOOL FUN_0203BBBC(ScriptContext *ctx);
/*static*/ BOOL FUN_0203BC04(ScriptContext *ctx);
/*static*/ BOOL FUN_0203BC3C(struct FieldSystem *fieldSystem, u32 param1, u32 param2);
static FashionAppData *FUN_0203BC6C(u32 heapId, struct FieldSystem *fieldSystem, u32 param2, u32 portraitSlot);
static BOOL CheckPortraitSlotFullInternal(struct FieldSystem *fieldSystem, BOOL isContest, u32 portraitSlot);
static FashionAppData *FUN_0203BC6C(u32 heapId, struct FieldSystem *fieldSystem, BOOL isContest, u32 portraitSlot);
static BOOL FUN_0203BE9C(ScriptContext *ctx);
extern u8 sScriptConditionTable[6][3];
@@ -1961,29 +1967,29 @@ BOOL ScrCmd_TerminateOverworldProcess(ScriptContext *ctx) { //01F8
return TRUE;
}
/*static*/ BOOL FUN_0203BC3C(struct FieldSystem *fieldSystem, u32 param1, u32 param2) {
static BOOL CheckPortraitSlotFullInternal(struct FieldSystem *fieldSystem, BOOL isContest, u32 portraitSlot) {
SaveFashionData *fashionData = Save_FashionData_Get(fieldSystem->saveBlock2);
if (param1 == 0) {
if (!FUN_02027098(fashionData, param2)) {
if (!isContest) {
if (!CheckPortraitSlotFull(fashionData, portraitSlot)) {
return FALSE;
}
} else {
if (!FUN_020270B4(fashionData, param2)) {
if (!CheckContestPortraitSlotFull(fashionData, portraitSlot)) {
return FALSE;
}
}
return TRUE;
}
static FashionAppData *FUN_0203BC6C(u32 heapId, struct FieldSystem *fieldSystem, u32 param2, u32 portraitSlot) {
static FashionAppData *FUN_0203BC6C(u32 heapId, struct FieldSystem *fieldSystem, BOOL isContest, u32 portraitSlot) {
SaveFashionData *fashionData = Save_FashionData_Get(fieldSystem->saveBlock2);
if (!FUN_0203BC3C(fieldSystem, param2, portraitSlot)) {
if (!CheckPortraitSlotFullInternal(fieldSystem, isContest, portraitSlot)) {
return NULL;
}
FashionAppData *appData = AllocFromHeap(heapId, sizeof(FashionAppData));
__builtin__clear(appData, sizeof(FashionAppData));
appData->fashionData = fashionData;
appData->unk08 = param2;
appData->isContest = isContest;
appData->portraitSlot = portraitSlot;
return appData;
}
@@ -2090,7 +2096,7 @@ BOOL ScrCmd_ShowDressedPokemon(ScriptContext *ctx) { //00A7
FashionAppData **fashionAppData = FieldSysGetAttrAddr(ctx->fieldSystem, SCRIPTENV_RUNNING_APP_DATA);
u16 portraitSlot = ScriptReadHalfword(ctx);
u16 *var = ScriptGetVarPointer(ctx);
*fashionAppData = FUN_0203BC6C(11, ctx->fieldSystem, 0, portraitSlot);
*fashionAppData = FUN_0203BC6C(11, ctx->fieldSystem, FALSE, portraitSlot);
if (*fashionAppData == NULL) {
*var = 1;
return TRUE;
@@ -2105,7 +2111,7 @@ BOOL ScrCmd_ShowContestPokemon(ScriptContext *ctx) { //00A8
FashionAppData **fashionAppData = FieldSysGetAttrAddr(ctx->fieldSystem, SCRIPTENV_RUNNING_APP_DATA);
u16 portraitSlot = ScriptReadHalfword(ctx);
u16 *var = ScriptGetVarPointer(ctx);
*fashionAppData = FUN_0203BC6C(11, ctx->fieldSystem, 1, portraitSlot);
*fashionAppData = FUN_0203BC6C(11, ctx->fieldSystem, TRUE, portraitSlot);
if (*fashionAppData == NULL) {
*var = 1;
return TRUE;
@@ -2115,3 +2121,52 @@ BOOL ScrCmd_ShowContestPokemon(ScriptContext *ctx) { //00A8
SetupNativeScript(ctx, FUN_0203BB90);
return TRUE;
}
BOOL ScrCmd_CheckPortraitSlot(ScriptContext *ctx) { //012E
u16 portraitSlot = ScriptReadHalfword(ctx);
u16 *var = ScriptGetVarPointer(ctx);
if (CheckPortraitSlotFullInternal(ctx->fieldSystem, FALSE, portraitSlot) == TRUE) {
*var = TRUE;
return TRUE;
}
*var = FALSE;
return TRUE;
}
BOOL ScrCmd_CheckContestPortraitSlot(ScriptContext *ctx) { //012F
u16 portraitSlot = ScriptReadHalfword(ctx);
u16 *var = ScriptGetVarPointer(ctx);
if (CheckPortraitSlotFullInternal(ctx->fieldSystem, TRUE, portraitSlot) == TRUE) {
*var = TRUE;
return TRUE;
}
*var = FALSE;
return TRUE;
}
BOOL ScrCmd_Unk0130(ScriptContext *ctx) { //0130
u16 unk0 = ScriptGetVar(ctx);
SaveFashionData *fashionData = Save_FashionData_Get(ctx->fieldSystem->saveBlock2);
FUN_02027478(FUN_02027008(fashionData, 0), unk0);
return TRUE;
}
BOOL ScrCmd_ShowGeonetScreen(ScriptContext *ctx) { //0205
ShowGeonetScreen(ctx->fieldSystem);
SetupNativeScript(ctx, FUN_0203BC04);
return TRUE;
}
BOOL ScrCmd_ShowSealCapsuleEditor(ScriptContext *ctx) { //00A9
ShowSealCapsuleEditor(ctx->taskManager, ctx->fieldSystem->saveBlock2);
return TRUE;
}
BOOL ScrCmd_ShowTownMapScreen(ScriptContext *ctx) { //00AA
TownMapAppData **townMap = FieldSysGetAttrAddr(ctx->fieldSystem, SCRIPTENV_RUNNING_APP_DATA);
*townMap = AllocFromHeap(11, sizeof(TownMapAppData));
FUN_0205F7A0(ctx->fieldSystem, *townMap, 2); //TownMap_Init?
FUN_02037E90(ctx->fieldSystem, *townMap); //ShowTownMap?
SetupNativeScript(ctx, FUN_0203BB90);
return TRUE;
}

View File

@@ -1,5 +1,6 @@
#include "global.h"
#include "task.h"
#include "script.h"
#include "heap.h"
struct TaskManager *FieldSys_CreateTask(struct FieldSystem * fieldSystem, TaskFunc taskFunc, void *env)

View File

@@ -178,6 +178,12 @@ BOOL ScrCmd_Unk00A5(ScriptContext *ctx);
BOOL ScrCmd_DressupPokemon(ScriptContext *ctx);
BOOL ScrCmd_ShowDressedPokemon(ScriptContext *ctx);
BOOL ScrCmd_ShowContestPokemon(ScriptContext *ctx);
BOOL ScrCmd_CheckPortraitSlot(ScriptContext *ctx);
BOOL ScrCmd_CheckContestPortraitSlot(ScriptContext *ctx);
BOOL ScrCmd_Unk0130(ScriptContext *ctx);
BOOL ScrCmd_ShowGeonetScreen(ScriptContext *ctx);
BOOL ScrCmd_ShowSealCapsuleEditor(ScriptContext *ctx);
BOOL ScrCmd_ShowTownMapScreen(ScriptContext *ctx);
// scrcmd_mart.c
BOOL ScrCmd_NormalMart(struct ScriptContext * ctx);

View File

@@ -41,18 +41,22 @@ typedef struct PCBoxAppData {
} PCBoxAppData; //todo move to own file
typedef struct FashionAppData {
struct SaveFashionData *fashionData;
SaveFashionData *fashionData;
u32 portraitSlot;
u32 unk08;
BOOL isContest;
} FashionAppData;
typedef struct TownMapAppData { //todo fill out
u8 padding[0x140];
} TownMapAppData; //todo move to own file
typedef struct FieldSystem //todo move to field_system.c
{
u32 *unk00;
u8 padding[0x4];
struct BgConfig *bgConfig;
struct SaveBlock2 *saveBlock2; //0xC
struct TaskManager *taskManager;
TaskManager *taskManager;
u8 padding2[0x8];
u32 *mapId; //0x1C
struct Camera *camera;
@@ -81,10 +85,10 @@ typedef struct ScriptContext
ScrCmdFunc *cmdTable;
u32 cmdCount;
u32 data[4];
struct TaskManager *taskManager;
TaskManager *taskManager;
struct MsgData *msgData;
u8 *mapScripts;
struct FieldSystem *fieldSystem;
FieldSystem *fieldSystem;
} ScriptContext;
typedef enum ScriptEnvField {

View File

@@ -1,12 +1,14 @@
#ifndef POKEDIAMOND_TASK_H
#define POKEDIAMOND_TASK_H
#include "script.h"
//#include "script.h" - dirty hack while FieldSystem is still in script.h
#include "main.h"
struct TaskManager;
typedef struct TaskManager TaskManager;
typedef BOOL (*TaskFunc)(struct TaskManager *taskManager);
typedef BOOL (*TaskFunc)(TaskManager *taskManager);
struct FieldSystem; //FIXME: dirty hack
struct TaskManager
{