This commit is contained in:
TheSylphIsIn
2025-02-15 22:24:59 -05:00
parent 394c4e8274
commit 160efbbfe5
5 changed files with 33 additions and 30 deletions

View File

@@ -6,7 +6,7 @@
typedef struct PoketchTask {
u32 taskId;
SysTaskFunc taskFunc;
u32 unk_08;
u32 extraDataSize;
} PoketchTask;
typedef struct PoketchTaskManager {

View File

@@ -29,7 +29,7 @@ typedef struct PlayerPartyStatus {
u32 touchY;
} PlayerPartyStatus;
typedef struct PoketchPartyStatusGraphics PoketchPartyStatusGraphics; // MonIconBounceAnim and PoketchPartyStatusGraphics contain each other, so this is necessary
typedef struct PoketchPartyStatusGraphics PoketchPartyStatusGraphics;
typedef struct MonIconBounceAnim {
PoketchPartyStatusGraphics *graphicsDataPtr;
@@ -60,11 +60,17 @@ struct PoketchPartyStatusGraphics {
u8 iconSpriteBuffer[640];
};
enum PartyStatusTask {
TASK_DRAW_SCREEN = 0,
TASK_UNLOAD_AND_FREE,
TASK_REDRAW_ON_TAP,
};
#include "bg_window.h"
BOOL PartyStatusGraphics_New(PoketchPartyStatusGraphics **dest, const PlayerPartyStatus *playerParty, BgConfig *bgConfig);
void PartyStatusGraphics_UnloadAndFree(PoketchPartyStatusGraphics *param0);
void PartyStatus_StartTaskById(PoketchPartyStatusGraphics *appData, u32 taskId);
void PartyStatus_StartTaskById(PoketchPartyStatusGraphics *appData, enum PartyStatusTask taskId);
BOOL PartyStatus_TaskIsNotActive(PoketchPartyStatusGraphics *appData, u32 taskId);
BOOL PartyStatus_AllTasksDone(PoketchPartyStatusGraphics *appData);
u32 PoketchPartyStatus_CheckTouchingPartySlot(u32 touchX, u32 touchY, u32 partyCount);

View File

@@ -90,11 +90,11 @@ void PoketchTask_Start(const PoketchTask *appTasks, u32 taskId, void *taskData,
PoketchTaskManager *poketchTaskMan;
u32 size;
size = sizeof(PoketchTaskManager) + appTasks[i].unk_08;
size = sizeof(PoketchTaskManager) + appTasks[i].extraDataSize;
poketchTaskMan = Heap_AllocFromHeap(heapId, size);
if (poketchTaskMan != NULL) {
if (appTasks[i].unk_08 != 0) {
if (appTasks[i].extraDataSize != 0) {
poketchTaskMan->extraData = ((u8 *)poketchTaskMan) + sizeof(PoketchTaskManager);
} else {
poketchTaskMan->extraData = NULL;

View File

@@ -46,11 +46,10 @@ static BOOL PoketchPartyStatus_New(void **appData, PoketchSystem *poketchSys, Bg
PoketchPartyStatus *partyStatusData = (PoketchPartyStatus *)Heap_AllocFromHeap(HEAP_ID_POKETCH_APP, sizeof(PoketchPartyStatus));
if (partyStatusData != NULL) {
if (PoketchPartyStatus_Init(partyStatusData, poketchSys, bgConfig, unused)) {
if (SysTask_Start(Task_PartyStatusMain, partyStatusData, 1) != NULL) {
*appData = partyStatusData;
return TRUE;
}
if (PoketchPartyStatus_Init(partyStatusData, poketchSys, bgConfig, unused)
&& SysTask_Start(Task_PartyStatusMain, partyStatusData, 1) != NULL) {
*appData = partyStatusData;
return TRUE;
}
Heap_FreeToHeap(partyStatusData);
@@ -107,7 +106,7 @@ static void Task_PartyStatusMain(SysTask *task, void *appData)
static void PoketchPartyStatus_Exit(void *appData)
{
((PoketchPartyStatus *)appData)->shouldExit = 1;
((PoketchPartyStatus *)appData)->shouldExit = TRUE;
}
static void SetTaskState(PoketchPartyStatus *appData, u32 state)
@@ -125,7 +124,7 @@ static BOOL Task_PartyStatusLoadAndWait(PoketchPartyStatus *appData)
{
switch (appData->taskFuncState) {
case 0:
PartyStatus_StartTaskById(appData->graphicsData, 0);
PartyStatus_StartTaskById(appData->graphicsData, TASK_DRAW_SCREEN);
appData->taskFuncState++;
break;
case 1:
@@ -157,7 +156,7 @@ static BOOL Task_PartyStatusTryUpdateOnTap(PoketchPartyStatus *appData)
if (touchedSlot >= appData->playerParty.partyCount) { // Tapped the screen but not any mon icons
InitPlayerPartyMons(&appData->playerParty, Party_GetFromSavedata(PoketchSystem_GetSaveData(appData->poketchSys)));
PartyStatus_StartTaskById(appData->graphicsData, 2);
PartyStatus_StartTaskById(appData->graphicsData, TASK_REDRAW_ON_TAP);
}
}
@@ -167,7 +166,7 @@ static BOOL Task_PartyStatusTryUpdateOnTap(PoketchPartyStatus *appData)
appData->playerParty.touchX = 0;
appData->playerParty.touchY = 0;
appData->playerParty.screenTapped = 0;
appData->playerParty.screenTapped = FALSE;
return FALSE;
}
@@ -176,7 +175,7 @@ static BOOL Task_PartyStatusUnloadAndWait(PoketchPartyStatus *appData)
{
switch (appData->taskFuncState) {
case 0:
PartyStatus_StartTaskById(appData->graphicsData, 1);
PartyStatus_StartTaskById(appData->graphicsData, TASK_UNLOAD_AND_FREE);
appData->taskFuncState++;
break;
case 1:

View File

@@ -48,8 +48,6 @@ BOOL PartyStatusGraphics_New(PoketchPartyStatusGraphics **dest, const PlayerPart
PoketchPartyStatusGraphics *graphicsData = (PoketchPartyStatusGraphics *)Heap_AllocFromHeap(HEAP_ID_POKETCH_APP, sizeof(PoketchPartyStatusGraphics));
if (graphicsData != NULL) {
int i;
PoketchTask_InitActiveTaskList(graphicsData->activeTaskIds, 8);
graphicsData->playerParty = playerParty;
@@ -58,7 +56,7 @@ BOOL PartyStatusGraphics_New(PoketchPartyStatusGraphics **dest, const PlayerPart
graphicsData->partyCount = 0;
graphicsData->bounceAnimTask = NULL;
for (i = 0; i < MAX_PARTY_SIZE; i++) {
for (int i = 0; i < MAX_PARTY_SIZE; i++) {
Window_Init(&(graphicsData->hpBarWindows[i]));
graphicsData->unk_9C[i] = NULL;
graphicsData->unk_B4[i] = NULL;
@@ -89,13 +87,13 @@ void PartyStatusGraphics_UnloadAndFree(PoketchPartyStatusGraphics *graphicsData)
}
static const PoketchTask sPartyStatusTasks[] = {
{ 0x0, DrawAppScreen, 0x0 },
{ 0x1, FreeAppScreen, 0x0 },
{ 0x2, RedrawAppScreen, 0x0 },
{ 0x0, NULL, 0x0 }
{ TASK_DRAW_SCREEN, DrawAppScreen, 0 },
{ TASK_UNLOAD_AND_FREE, FreeAppScreen, 0 },
{ TASK_REDRAW_ON_TAP, RedrawAppScreen, 0 },
{ 0, NULL, 0 }
};
void PartyStatus_StartTaskById(PoketchPartyStatusGraphics *appData, u32 taskId)
void PartyStatus_StartTaskById(PoketchPartyStatusGraphics *appData, enum PartyStatusTask taskId)
{
PoketchTask_Start(sPartyStatusTasks, taskId, appData, appData->playerParty, appData->activeTaskIds, 2, HEAP_ID_POKETCH_APP);
}
@@ -140,8 +138,8 @@ static void DrawAppScreen(SysTask *param0, void *param1)
v2 = PoketchTask_GetTaskData(param1);
Bg_InitFromTemplate(v2->bgConfig, 6, &v0, 0);
v3 = Graphics_LoadTilesToBgLayer(12, 106, v2->bgConfig, 6, 0, 0, 1, 8);
v3 /= 0x20;
v3 = Graphics_LoadTilesToBgLayer(NARC_INDEX_GRAPHIC__POKETCH, 106, v2->bgConfig, BG_LAYER_SUB_2, 0, 0, TRUE, HEAP_ID_POKETCH_APP);
v3 /= TILE_SIZE_4BPP;
Bg_FillTilemapRect(v2->bgConfig, 6, 0x5, 0, 0, 32, 24, 0);
ov25_022546B8(0, 0);
@@ -241,7 +239,7 @@ static void ov32_02256898(PoketchPartyStatusGraphics *param0, const PlayerPartyS
int v0;
UnkStruct_ov25_02255810 v1;
Graphics_LoadObjectTiles(NARC_INDEX_GRAPHIC__POKETCH, 109, 1, 0 * 0x20, 0, TRUE, HEAP_ID_POKETCH_APP);
Graphics_LoadObjectTiles(NARC_INDEX_GRAPHIC__POKETCH, 109, DS_SCREEN_SUB, 0 * TILE_SIZE_4BPP, 0, TRUE, HEAP_ID_POKETCH_APP);
v1.unk_0A = 0;
v1.unk_0B = 2;
@@ -277,11 +275,11 @@ static void ov32_0225692C(PoketchPartyStatusGraphics *param0, const PlayerPartyS
v1.unk_0D = 1;
for (v3 = 0; v3 < param1->partyCount; v3++) {
NARC_ReadFromMember(v0, param1->mons[v3].iconSpriteIndex, 0, ((16 * 0x20) + 0x80), param0->iconSpriteBuffer);
NARC_ReadFromMember(v0, param1->mons[v3].iconSpriteIndex, 0, ((16 * TILE_SIZE_4BPP) + 0x80), param0->iconSpriteBuffer);
NNS_G2dGetUnpackedCharacterData(param0->iconSpriteBuffer, &v2);
DC_FlushRange(v2->pRawData, (16 * 0x20));
GXS_LoadOBJ(v2->pRawData, (0 + 8) * 0x20 + (16 * 0x20) * v3, (16 * 0x20));
DC_FlushRange(v2->pRawData, (16 * TILE_SIZE_4BPP));
GXS_LoadOBJ(v2->pRawData, (0 + 8) * TILE_SIZE_4BPP + (16 * TILE_SIZE_4BPP) * v3, (16 * TILE_SIZE_4BPP));
v1.unk_00.x = ((sMonIconCoords[v3].x) << FX32_SHIFT);
v1.unk_00.y = ((sMonIconCoords[v3].y) << FX32_SHIFT);
@@ -386,7 +384,7 @@ u32 PoketchPartyStatus_CheckTouchingPartySlot(u32 touchX, u32 touchY, u32 partyC
// Creates a bounding box around the party icon and checks if the tapped coordinates are within it.
// Since the Poketch mon icons are double-sized, this box does not necessarily contain the whole sprite.
if (((u32)(touchX - upperBoundX) < (u32)(lowerBoundX - upperBoundX)) & ((u32)(touchY - upperBoundY) < (u32)(lowerBoundY - upperBoundY))) {
if (((touchX - upperBoundX) < (lowerBoundX - upperBoundX)) & ((touchY - upperBoundY) < (lowerBoundY - upperBoundY))) {
return i;
}
}