Merge branch 'decompile_touchscreen' into alph_puzzle_data

This commit is contained in:
PikalaxALT 2023-12-30 15:46:18 -05:00
commit 482c31a711
No known key found for this signature in database
GPG Key ID: C7E3D40F3BAC7AEB
9 changed files with 75 additions and 102 deletions

View File

@ -54,7 +54,7 @@ sdk9 sdk7: sdk
main filesystem: | sdk9
sub: | sdk7
main: $(SBIN) $(ELF)
main: $(SBIN) $(ELF)
main_lz: $(SBIN_LZ)
sub: ; @$(MAKE) -C sub
@ -87,7 +87,7 @@ $(BANNER): $(BANNER_SPEC) $(ICON_PNG:%.png=%.nbfp) $(ICON_PNG:%.png=%.nbfc)
# TODO: move to NitroSDK makefile
FX_CONST_H := $(WORK_DIR)/lib/include/nitro/fx/fx_const.h
PROJECT_CLEAN_TARGETS += $(FX_CONST_H)
$(FX_CONST_H): $(TOOLSDIR)/gen_fx_consts/fx_const.csv
$(FX_CONST_H): $(MKFXCONST) $(TOOLSDIR)/gen_fx_consts/fx_const.csv
$(MKFXCONST) $@
sdk: $(FX_CONST_H)
$(WORK_DIR)/include/global.h: $(FX_CONST_H) ;

View File

@ -1,55 +0,0 @@
#include "constants/sndseq.h"
#include "constants/moves.h"
#include "constants/std_script.h"
#include "constants/species.h"
#include "constants/sprites.h"
#include "constants/pokemon.h"
#include "constants/maps.h"
#include "constants/mmodel.h"
#include "constants/items.h"
#include "msgdata/msg/msg_0096_D31R0201.h"
#include "msgdata/msg/msg_0066_D23R0102.h"
.include "asm/macros.inc"
.include "scrcmd_pokemon_misc_data.inc"
.include "global.inc"
.rodata
.public sFriendshipRoomStatuesPositions
sFriendshipRoomStatuesPositions: ; 0x022093B4
.byte 0x04, 0x0A, 0x07, 0x05, 0x0A, 0x0A
.public sSpikyEarPichuMoveset
sSpikyEarPichuMoveset: ; 0x022093BA
.short MOVE_HELPING_HAND
.short MOVE_VOLT_TACKLE
.short MOVE_SWAGGER
.short MOVE_PAIN_SPLIT
.public sStatJudgeBestStatMsgIdxs
sStatJudgeBestStatMsgIdxs: ; 0x022093C2
.short msg_0096_D31R0201_00122
.short msg_0096_D31R0201_00123
.short msg_0096_D31R0201_00124
.short msg_0096_D31R0201_00127
.short msg_0096_D31R0201_00125
.short msg_0096_D31R0201_00126
.public sSlotLuckDistribution
.balign 4, 0
sSlotLuckDistribution:
.word 7, 3
.word 5, 2
.data
.public ov01_02209AE0
.balign 4, 0
ov01_02209AE0: ; 0x02209AE0
.byte 0x5D, 0x00, 0x5E, 0x00, 0x5F, 0x00, 0x60, 0x00, 0x61, 0x00, 0x62, 0x00, 0x63, 0x00, 0x64, 0x00
.byte 0x65, 0x00, 0x00, 0x00

View File

@ -9,4 +9,6 @@ $(PPARK_NARC): %.narc: $(PPARK_JSON) $(PPARK_TEMPLATE)
$(WINE) $(MWCC) $(MWCFLAGS) -c -o $*.o $*.c
$(O2NARC) $*.o $@ -n
$(PPARK_JSON): | $(WORK_DIR)/include/global.h
FS_CLEAN_TARGETS += $(PPARK_NARC)

View File

@ -49,7 +49,7 @@ void CalcMonLevelAndStats(Pokemon *mon);
void CalcMonStats(Pokemon *mon);
u32 GetMonData(Pokemon *mon, int attr, void * ptr);
u32 GetBoxMonData(BoxPokemon *boxMon, int attr, void * ptr);
void SetMonData(Pokemon *mon, int attr, void * ptr);
void SetMonData(Pokemon *mon, int attr, const void * ptr);
void SetBoxMonData(BoxPokemon *boxMon, int attr, void * ptr);
void AddMonData(Pokemon *mon, int attr, int amount);
//void AddBoxMonData(BoxPokemon *boxMon, int attr, int amount);

View File

@ -501,7 +501,6 @@ Overlay field
Object asm/overlay_01_022001E4.o
Object asm/overlay_01_022006A8.o
Object asm/overlay_01_02200858.o
Object asm/scrcmd_pokemon_misc_data.o
Object src/field/scrcmd_pokemon_misc.o
Object src/scrcmd_move_tutor.o
Object src/field/scrcmd_moneybox.o

View File

@ -1656,21 +1656,20 @@ static BOOL ov17_02203C20(BerryPotsAppData *data, BOOL *a1) {
}
static int ov17_02203C78(BerryPotsAppData *data) {
// touch screen coordinates?
TouchscreenHitbox unkArray;
TouchscreenHitbox touchHitbox;
for (int i = 0, xOffsetMaybe = 16; i < MAX_BERRY_POT; xOffsetMaybe += 28, i++) {
unkArray.rect.left = xOffsetMaybe;
unkArray.rect.right = unkArray.rect.left + 22;
touchHitbox.rect.left = xOffsetMaybe;
touchHitbox.rect.right = touchHitbox.rect.left + 22;
if (data->unk20[i].growthStage < BERRY_POT_GROWTH_STAGE_GROWING) {
unkArray.rect.top = 88;
unkArray.rect.bottom = unkArray.rect.top + 24;
touchHitbox.rect.top = 88;
touchHitbox.rect.bottom = touchHitbox.rect.top + 24;
} else {
unkArray.rect.top = 72;
unkArray.rect.bottom = unkArray.rect.top + 32;
touchHitbox.rect.top = 72;
touchHitbox.rect.bottom = touchHitbox.rect.top + 32;
}
if (TouchscreenHitbox_TouchNewIsIn(&unkArray)) {
if (TouchscreenHitbox_TouchNewIsIn(&touchHitbox)) {
return i;
}
}

View File

@ -41,6 +41,8 @@
#include "unk_02037C94.h"
#include "sound_02004A44.h"
#include "constants/map_sections.h"
#include "msgdata/msg.naix"
// #include "application/zukanlist/zukan_data/zukan_data.naix"
typedef struct UnkStructScr_648 {
FieldSystem *fieldSystem;
@ -74,10 +76,10 @@ typedef struct UnkStructScr_648 {
} SCR_648_STRUCT;
static BOOL ov01_02200C6C(ScriptContext *ctx);
static void *ov01_02200C94(HeapID heapId, s32 fileId, u32 *unkPtr);
static void *ov01_02200C94(HeapID heapId, s32 fileId, int *unkPtr);
static void ov01_02200CB4(SCR_648_STRUCT *unkPtr, MsgData *msgdata);
static void ov01_02200CBC(FieldSystem *fieldSystem, SCR_648_STRUCT *unkPtr, u8 x, u8 y, u8 a4, u8 a5, s16 *input, MessageFormat *msgfmt, Window *window, MsgData *msgdata, u16 *cursorPos, u16 *itemsAbove);
static SCR_648_STRUCT *ov01_02200D9C(FieldSystem *fieldSystem, u8 x, u8 y, u8 a3, u8 a4, s16* input, MessageFormat *msgfmt, Window *window, MsgData *msgdata, u16 *cursorPos, u16 *itemsAbove);
static void ov01_02200CBC(FieldSystem *fieldSystem, SCR_648_STRUCT *unkPtr, u8 x, u8 y, u8 a4, u8 a5, u16 *input, MessageFormat *msgfmt, Window *window, MsgData *msgdata, u16 *cursorPos, u16 *itemsAbove);
static SCR_648_STRUCT *ov01_02200D9C(FieldSystem *fieldSystem, u8 x, u8 y, u8 a3, u8 a4, u16* input, MessageFormat *msgfmt, Window *window, MsgData *msgdata, u16 *cursorPos, u16 *itemsAbove);
static void ov01_02200DF8(SCR_648_STRUCT *unkPtr, int strNo, u16 a2, u32 a3);
static void ov01_02200E00(SCR_648_STRUCT *unkPtr);
static void ov01_02200EC8(SCR_648_STRUCT *unkPtr, int strNo, u16 a2, u32 a3);
@ -89,13 +91,24 @@ static void ov01_0220116C(SCR_648_STRUCT *unkPtr);
static void GetHiddenPowerPowerType(Pokemon *mon, s32 *power, s32 *type);
static LocalMapObject *ov01_02201F98(MapObjectManager *mapObjectManager, u8 unkA, u16 species, u16 form, u32 gender, u32 x, u32 y, u32 mapId);
extern u16 ov01_02209AE0[10];
// zukan_data_XXXXX
static u16 ov01_02209AE0[9] = {
93,
94,
95,
96,
97,
98,
99,
100,
101,
};
BOOL ScrCmd_648(ScriptContext *ctx) {
int i;
u32 out_1;
int out_2;
s16 *input;
u16 *input;
u32 unkPtr_2;
MsgData *msgdata2;
@ -146,7 +159,7 @@ BOOL ScrCmd_648(ScriptContext *ctx) {
FreeToHeap(unkG);
}
msgdata2 = NewMsgDataFromNarc(MSGDATA_LOAD_LAZY, NARC_msgdata_msg, 0xbf, HEAP_ID_32);
msgdata2 = NewMsgDataFromNarc(MSGDATA_LOAD_LAZY, NARC_msgdata_msg, NARC_msg_msg_0191_bin, HEAP_ID_32);
ov01_02200CB4(unkPtr, msgdata2);
ov01_02200DF8(unkPtr, 0xd, 0xff, 0xfffe);
@ -166,7 +179,7 @@ static BOOL ov01_02200C6C(ScriptContext *ctx) {
return (*GetVarPointer(ctx->fieldSystem, ctx->data[0]) != 0xEEEE);
}
static void *ov01_02200C94(HeapID heapId, s32 fileId, u32 *unkPtr) {
static void *ov01_02200C94(HeapID heapId, s32 fileId, int *unkPtr) {
u32 size;
void *data = GfGfxLoader_LoadFromNarc_GetSizeOut(NARC_application_zukanlist_zukan_data_zukan_data, fileId, FALSE, heapId, FALSE, &size);
*unkPtr = size/2;
@ -177,7 +190,7 @@ static void ov01_02200CB4(SCR_648_STRUCT *unkPtr, MsgData *msgdata) {
unkPtr->msgdata = msgdata;
}
static void ov01_02200CBC(FieldSystem *fieldSystem, SCR_648_STRUCT *unkPtr, u8 x, u8 y, u8 a4, u8 a5, s16 *input, MessageFormat *msgfmt, Window *window, MsgData *msgdata, u16 *cursorPos, u16 *itemsAbove) {
static void ov01_02200CBC(FieldSystem *fieldSystem, SCR_648_STRUCT *unkPtr, u8 x, u8 y, u8 a4, u8 a5, u16 *input, MessageFormat *msgfmt, Window *window, MsgData *msgdata, u16 *cursorPos, u16 *itemsAbove) {
int i;
unkPtr->msgdata = msgdata;
unkPtr->unk_207 = unkPtr->unk_207 & ~0x2;
@ -210,7 +223,7 @@ static void ov01_02200CBC(FieldSystem *fieldSystem, SCR_648_STRUCT *unkPtr, u8 x
*unkPtr->input = 0xEEEE;
}
static SCR_648_STRUCT *ov01_02200D9C(FieldSystem *fieldSystem, u8 x, u8 y, u8 a3, u8 a4, s16* input, MessageFormat *msgfmt, Window *window, MsgData *msgdata, u16 *cursorPos, u16 *itemsAbove) {
static SCR_648_STRUCT *ov01_02200D9C(FieldSystem *fieldSystem, u8 x, u8 y, u8 a3, u8 a4, u16* input, MessageFormat *msgfmt, Window *window, MsgData *msgdata, u16 *cursorPos, u16 *itemsAbove) {
SCR_648_STRUCT *unkPtr = AllocFromHeap(HEAP_ID_4, sizeof(SCR_648_STRUCT));
if (!unkPtr) {
return NULL;
@ -268,7 +281,7 @@ static void ov01_02200F54(SCR_648_STRUCT *unkPtr) {
unkPtr->listMenuTemplate.fillValue = 15;
unkPtr->listMenuTemplate.cursorShadowPal = 2;
unkPtr->listMenuTemplate.lettersSpacing = 0;
unkPtr->listMenuTemplate.itemVerticalPadding = 16;
unkPtr->listMenuTemplate.itemVerticalPadding = 0;
unkPtr->listMenuTemplate.scrollMultiple = 1;
unkPtr->listMenuTemplate.fontId = 0;
unkPtr->listMenuTemplate.cursorKind = 0;
@ -346,11 +359,18 @@ static void ov01_0220116C(SCR_648_STRUCT *unkPtr) {
FreeToHeap(unkPtr);
}
extern u16 sStatJudgeBestStatMsgIdxs[6];
static const u16 sStatJudgeBestStatMsgIdxs[6] = {
msg_0096_D31R0201_00122,
msg_0096_D31R0201_00123,
msg_0096_D31R0201_00124,
msg_0096_D31R0201_00127,
msg_0096_D31R0201_00125,
msg_0096_D31R0201_00126,
};
BOOL ScrCmd_StatJudge(ScriptContext *ctx) {
u32 ivList[6];
u32 i;
u8 i;
u8 offset;
u8 highestIvValue;
FieldSystem *fieldSystem = ctx->fieldSystem;
@ -369,7 +389,7 @@ BOOL ScrCmd_StatJudge(ScriptContext *ctx) {
highestIvValue = 0;
*ivTotal = 0;
for (i = 0; i < 6; i = (u8)++i) {
for (i = 0; i < 6; ++i) {
*ivTotal += ivList[i];
if (highestIvValue < ivList[i]) {
highestIvValue = ivList[i];
@ -379,7 +399,7 @@ BOOL ScrCmd_StatJudge(ScriptContext *ctx) {
offset = fieldSystem->judgeStatPosition;
*highestIvIndex = offset;
for (i = 0; i < 6; i = (u8)++i) {
for (i = 0; i < 6; ++i) {
if (highestIvValue == ivList[offset]) {
*highestIvIndex = offset;
fieldSystem->judgeStatPosition = (offset + 1) % 6;
@ -502,7 +522,7 @@ BOOL ScrCmd_UpdateRotomForm(ScriptContext *ctx) {
}
BOOL ScrCmd_GetHiddenPowerType(ScriptContext *ctx) {
int power, type;
s32 power, type;
FieldSystem *fieldSystem = ctx->fieldSystem;
int partyIndex = ScriptGetVar(ctx);
u16 *typePtr = ScriptGetVarPointer(ctx);
@ -583,7 +603,7 @@ BOOL ScrCmd_SetFavoriteMon(ScriptContext *ctx) {
BOOL ScrCmd_GetFavoriteMon(ScriptContext *ctx) {
FieldSystem *fieldSystem = ctx->fieldSystem;
u32 sp, form, egg;
int sp, form, egg;
u16 *species = ScriptGetVarPointer(ctx);
u16 *formPtr = ScriptGetVarPointer(ctx);
u16 *isEgg = ScriptGetVarPointer(ctx);
@ -605,7 +625,7 @@ BOOL ScrCmd_GetPartyMonForm(ScriptContext *ctx) {
}
BOOL ScrCmd_699(ScriptContext *ctx) {
u32 unkVar;
int unkVar;
FieldSystem *fieldSystem;
MapObjectManager *mapObjectManager;
LocalMapObject *playerObj;
@ -643,7 +663,7 @@ BOOL ScrCmd_699(ScriptContext *ctx) {
}
BOOL ScrCmd_700(ScriptContext *ctx) {
u32 index = 0;
int index = 0;
FieldSystem *fieldSystem;
MapObjectManager *mapObjectManager;
LocalMapObject *playerObj;
@ -920,7 +940,11 @@ BOOL ScrCmd_743(ScriptContext *ctx) {
return TRUE;
}
extern u8 sFriendshipRoomStatuesPositions[3][2];
static const u8 sFriendshipRoomStatuesPositions[3][2] = {
{ 4, 10 },
{ 7, 5 },
{ 10, 10 },
};
BOOL ScrCmd_CreatePokeathlonFriendshipRoomStatues(ScriptContext *ctx) {
s32 i;
@ -1066,7 +1090,12 @@ BOOL ScrCmd_777(ScriptContext *ctx) {
return FALSE;
}
extern u16 sSpikyEarPichuMoveset[4];
static const u16 sSpikyEarPichuMoveset[4] = {
MOVE_HELPING_HAND,
MOVE_VOLT_TACKLE,
MOVE_SWAGGER,
MOVE_PAIN_SPLIT,
};
BOOL ScrCmd_GiveSpikyEarPichu(ScriptContext *ctx) {
s32 i;
@ -1135,19 +1164,21 @@ BOOL ScrCmd_RadioMusicIsPlaying(ScriptContext *ctx) {
return FALSE;
}
extern s32 sSlotLuckDistribution[2][2];
static const int sSlotLuckDistribution[2][2] = {
{ 7, 3 },
{ 5, 2 },
};
// Return value is unused outside of Japanese copies.
static u32 SlotLuckiness(SaveData *saveData, u8 machineId, u8 city) {
SAV_FRIEND_GRP *friendGroup;
u8 *luckValues;
s32 *dist;
u32 numMachines;
s32 rngSeed;
u8 luckiness;
u8 randIdx;
u32 i;
s32 j;
u8 i;
u8 j;
friendGroup = Save_FriendGroup_Get(saveData);
@ -1167,13 +1198,10 @@ static u32 SlotLuckiness(SaveData *saveData, u8 machineId, u8 city) {
luckValues = AllocFromHeapAtEnd(HEAP_ID_32, numMachines);
MI_CpuFill8(luckValues, 0, numMachines);
i = 0;
dist = sSlotLuckDistribution[city];
for (; i < 2; i = (u8) ++i) { //I swear I couldn't get it to match otherwise
for (j = 0; j < dist[i]; j = (u8) ++j) {
for (i = 0; i < NELEMS(sSlotLuckDistribution[city]); ++i) {
for (j = 0; j < sSlotLuckDistribution[city][i]; ++j) {
do {
randIdx = LCRandom() % (s32) numMachines;
randIdx = LCRandom() % (s32)numMachines; // this cast appears necessary
} while (luckValues[randIdx] != 0);
luckValues[randIdx] = i + 1;
}

View File

@ -889,7 +889,7 @@ static u32 GetBoxMonDataInternal(BoxPokemon *boxMon, int attr, void * dest) {
return ret;
}
void SetMonData(Pokemon *mon, int attr, void * value) {
void SetMonData(Pokemon *mon, int attr, const void * value) {
u32 checksum;
if (!mon->box.party_lock) {
DECRYPT_PTY(mon);

View File

@ -230,9 +230,9 @@ static int ov122_021E9020(Ov122_021E8CFC *a0) {
}
if (a0->memoOpen && a0->unkD != 25 && a0->unkD != 26) {
u32 var3 = TouchscreenHitbox_FindRectAtTouchNew(ov122_021E9A1C);
if (var3 < 8) {
switch (var3) {
u32 whichButton = TouchscreenHitbox_FindRectAtTouchNew(ov122_021E9A1C);
if (whichButton < 8) {
switch (whichButton) {
case 0:
return 5;
case 1: