Digimon World 3 decomp
The European version, SLES_039.36
Loading...
Searching...
No Matches
task.h File Reference

The task system and its registry (task/) More...

#include "common.h"
#include <sys/types.h>
#include <libgte.h>
#include <libgpu.h>
Include dependency graph for task.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  TaskFuncs
 The task registry's methods (TASK_REGISTRY.funcs) More...
 
struct  Task
 Any task, seen through its header. More...
 
struct  TaskRegistry
 Tasks created with an id, so that other code can find them. More...
 

Macros

#define TASK_INIT   0
 Tasks: every game object is a task, a heap block that starts with this header and is updated once per frame (createTask).
 
#define TASK_RUN   1
 
#define TASK_DONE   2
 
#define TASK_KILL   3
 
#define TASK_HEADER(Type)
 
#define TASK_REGISTRY_SIZE   100
 The tasks the registry holds at most.
 

Functions

void * createTask (void(*update)(), s32 size, s32 childrenSize)
 createTaskWithId for a task nothing needs to find
 
void taskSetState (Task *task, s32 state)
 Task method: goes to state state, from substate 0.
 
void taskSetSubstate (Task *task, s32 substate)
 Task method: goes to substate substate, from step 0.
 
void taskSetStep (Task *task, s32 step)
 Task method: goes to step step, with its counter at 0.
 
void taskSetCounter (Task *task, s32 counter)
 Task method: sets the counter.
 
void taskNextState (Task *task)
 Task method: goes to the next state, from substate 0.
 
void taskNextSubstate (Task *task)
 Task method: goes to the next substate, from step 0.
 
void taskNextStep (Task *task)
 Task method: goes to the next step, with its counter at 0.
 
void taskTickCounter (Task *task)
 Task method: counts one more.
 
void destroyTask (Task *task)
 Default destructor: kills the children, then frees the task.
 
void * createTaskWithId (void(*update)(), s32 size, s32 childrenSize, s32 id)
 Allocates a zeroed task of size bytes (header included) with room for childrenSize / 4 child tasks.
 
struct Task * executeTask (struct Task *task)
 One frame of a task and its children; returns NULL once the task is gone.
 
void runChildTasks (Task *task)
 Runs a frame of each child of a task, dropping the ones that end.
 
Task * runTask (Task *task)
 Runs a frame of a task and its children; returns it, or NULL once it is gone.
 
void killTask (Task *task)
 Ends a task now: its last update and destroy run at once.
 
void clearTaskRegistry (void)
 Forgets every registered task.
 
void registerTask (Task *task)
 Adds a task to the first free entry of the registry (ignored when it is full)
 
void unregisterTask (Task *task)
 Removes a task from the registry.
 
void * findNextTask (void)
 The next registered task that matches findTask's id and keys (-1 matches anything), or NULL.
 
void * findTask (s32 id, s32 key1, s32 key2)
 The first registered task that matches (-1 matches anything), or NULL.
 

Variables

TaskRegistry TASK_REGISTRY
 

Detailed Description

The task system and its registry (task/)

Definition in file task.h.

Macro Definition Documentation

◆ TASK_INIT

#define TASK_INIT   0

Tasks: every game object is a task, a heap block that starts with this header and is updated once per frame (createTask).

A task owns an array of child tasks (windows, cursors...), which run right after it, and it gets that array as the second argument of its update. The state machine is driven through the header: TASK_INIT runs once (usually just nextState), TASK_RUN is the normal state, and TASK_KILL frees the task (and kills its children) after its last update.

Definition at line 34 of file task.h.

◆ TASK_RUN

#define TASK_RUN   1

Definition at line 35 of file task.h.

◆ TASK_DONE

#define TASK_DONE   2

Definition at line 36 of file task.h.

◆ TASK_KILL

#define TASK_KILL   3

Definition at line 37 of file task.h.

◆ TASK_HEADER

#define TASK_HEADER (   Type)
Value:
/* 0x00 */ s32 id; /* registered tasks only: findTask matches these */ \
/* 0x04 */ s32 key1; \
/* 0x08 */ s32 key2; \
/* 0x0C */ s32 state; \
/* 0x10 */ s32 substate; \
/* 0x14 */ s32 step; \
/* 0x18 */ s32 counter; \
/* 0x1C */ s32 paused; /* in TASK_RUN: skip the update and children */ \
/* 0x20 */ s32 childCount; \
/* 0x24 */ void *children; \
/* 0x28 */ void (*setState)(struct Type *task, s32 state); \
/* 0x2C */ void (*setSubstate)(struct Type *task, s32 substate); \
/* 0x30 */ void (*setStep)(struct Type *task, s32 step); \
/* 0x34 */ void (*setCounter)(struct Type *task, s32 counter); \
/* 0x38 */ void (*nextState)(struct Type *task); \
/* 0x3C */ void (*nextSubstate)(struct Type *task); \
/* 0x40 */ void (*nextStep)(struct Type *task); \
/* 0x44 */ void (*tickCounter)(struct Type *task); \
/* 0x48 */ void (*update)(); /* (task, children) */ \
/* 0x4C */ void (*destroy)(struct Type *task)
signed int s32
Definition common.h:11

Definition at line 39 of file task.h.

◆ TASK_REGISTRY_SIZE

#define TASK_REGISTRY_SIZE   100

The tasks the registry holds at most.

Definition at line 67 of file task.h.

Function Documentation

◆ createTask()

void * createTask ( void(*)()  update,
s32  size,
s32  childrenSize 
)

createTaskWithId for a task nothing needs to find

Definition at line 105 of file task.c.

Referenced by CARDGAME_createBattle(), CARDGAME_createDeckWindow(), CARDGAME_createFader(), CARDGAME_createMarker(), CARDGAME_createScreen(), CARDGAME_start(), CARDGAME_startPreloader(), CNTY_SEL_start(), CNTY_SEL_startBackgroundTask(), CNTY_SEL_startCursorTask(), CNTY_SEL_startLeftPanelTask(), CNTY_SEL_startMenuTask(), CNTY_SEL_startRightPanelTask(), CNTY_SEL_startTopPanelTask(), createBackground(), createClutTileTask(), createCursor(), createDecompressor(), createEffect(), createEffect(), createEffectSet(), createFader(), createFarSprites(), createFieldMenu(), createFloater(), createFlyer(), createInn(), createMessageBox(), createMessageBoxFrame(), createModeTask(), createScreenFade(), createScrollBar(), createSpriteField(), createSpritePair(), createStillTileTask(), createTalkBox(), createTalkBoxFrame(), createTextWindow(), createTileAnims(), createTileAt(), createTileCursors(), createTileDuoTask(), createTileEffect(), createTileEffectTask(), createTileLoop2(), createTilePair16Done(), createTilePairDone(), createTilePairNDone(), createTileSet(), createTileSix(), createTileSixW(), createTileSoloTask(), createTimer(), createWandererTask(), createWanderPairTask(), createZoomBox(), FIELDSTG_createCutsceneAnim(), FIELDSTG_createEffect(), FIELDSTG_createFileLoader(), FIELDSTG_createGauge(), FIELDSTG_createLaunch(), FIELDSTG_createMapObjects(), FIELDSTG_createSpeech(), FIELDSTG_createSpotEffect(), FIELDSTG_createSpotHint(), FIELDSTG_createStoryEvents(), FIELDSTG_createStream(), FIELDSTG_createTalk(), FIELDSTG_createTriggers(), FIELDSTG_start(), FIELDSTG_startEvent(), FIGHTSTG_createBattleScript(), FIGHTSTG_createCamera(), FIGHTSTG_createCommandMenu(), FIGHTSTG_createConfusedMenu(), FIGHTSTG_createCursor(), FIGHTSTG_createDigivolveMenu(), FIGHTSTG_createFace(), FIGHTSTG_createFader(), FIGHTSTG_createHud(), FIGHTSTG_createItemMenu(), FIGHTSTG_createMesh(), FIGHTSTG_createMessage(), FIGHTSTG_createPartnerInfo(), FIGHTSTG_createPartnerView(), FIGHTSTG_createShotCamera(), FIGHTSTG_createSpriteAnim(), FIGHTSTG_createSwitchInMenu(), FIGHTSTG_createSwitchMenu(), FIGHTSTG_createTechMenu(), FIGHTSTG_playBattleSound(), FIGHTSTG_start(), FIGHTSTG_startActionEvents(), FIGHTSTG_startCameraShots(), FIGHTSTG_startCameraTurn(), FIGHTSTG_startCounterattack(), FIGHTSTG_startDigimonChange(), FIGHTSTG_startEffectModel(), FIGHTSTG_startEnemyAttack(), FIGHTSTG_startEnemyTurn(), FIGHTSTG_startEntrance(), FIGHTSTG_startFirstTech(), FIGHTSTG_startHitEffect(), FIGHTSTG_startItem(), FIGHTSTG_startJump(), FIGHTSTG_startMove(), FIGHTSTG_startOneHpTurn(), FIGHTSTG_startSpriteEffect(), FIGHTSTG_startTechAction(), FIGHTSTG_startWhiteFlash(), SHOCKTST_createEditor(), SHOCKTST_createLoader(), SOUNDTST_createSoundTest(), SOUNDTST_start(), STAGSLCT_createStageSelect(), STAGSLCT_start(), start(), startEvent1510(), startEvent1512(), startEvent1514(), startEvent1516(), startEvent1518(), startEvent1520(), startEvent1522(), startEvent1602(), startEvent1604(), startEvent1616(), startEvent1618(), startEvent8(), startEvent9(), startEvents9000To9015(), startStage(), STCRDABM_createAlbum(), STCRDABM_createGrid(), STCRDDEK_createDeckCards(), STCRDDEK_createEditor(), STCRDDEK_createIdle(), STCRDDEK_createNameEntry(), STCRDDEK_createScreen(), STCRDSHP_createBuy(), STCRDSHP_createGrid(), STCRDSHP_createPackOpen(), STCRDSHP_createShop(), STDGNAME_createMenu(), STDGNAME_createNameEntry(), STDGNAME_createScreen(), STDGNAME_start(), STDWTITL_start(), STDWTITL_startBackgroundTask(), STDWTITL_startEdgeFadeTask(), STDWTITL_startGlintAltTask(), STDWTITL_startGlintTask(), STDWTITL_startLogoTask(), STDWTITL_startMenuTask(), STDWTITL_startMoviePlayerTask(), STDWTITL_startMovieTask(), STDWTITL_startSplashLoaderTask(), STDWTITL_startSplashTask(), STDWTITL_startTitle0AltTask(), STDWTITL_startTitle0Task(), STDWTITL_startTitle1AltTask(), STDWTITL_startTitle1Task(), STDWTITL_startTitleLoaderTask(), STDWTITL_startTitleTask(), STFGTREP_createPartner(), STFGTREP_createScreen(), STFGTREP_start(), STGDGLAB_createEntryList(), STGDGLAB_createEntryPanel(), STGDGLAB_createLab(), STGDGLAB_createMenu(), STGDGLAB_createPartyScreen(), STGDGLAB_createRecipeScreen(), STGDGLAB_createScene(), STGDGLAB_createSkillPanel(), STGDGLAB_createSlotScreen(), STGMCARD_createInfo(), STGMCARD_createMenu(), STGMCARD_createPanel(), STGMCARD_createSaves(), STGMCARD_createScreen(), STGTRAIN_createActor(), STGTRAIN_createIdle(), STGTRAIN_createMenu(), STGTRAIN_createResult(), STGTRAIN_createScreen(), STGTRAIN_createSession(), STGTRAIN_createSprite(), STGTRAIN_start(), STITSHOP_createBuy(), STITSHOP_createInfo(), STITSHOP_createItemList(), STITSHOP_createSell(), STITSHOP_createShop(), STPLNMET_createChoice(), STPLNMET_createConfirm(), STPLNMET_createNameEntry(), STPLNMET_createScreen(), STPLNMET_createScroll(), STPLNMET_createShine(), STPLNMET_createSparkles(), STPLNMET_createWelcome(), STPLNMET_start(), STSTATUS_createCardScreen(), STSTATUS_createDemoScreen(), STSTATUS_createDigivolvePanel(), STSTATUS_createEquipPanel(), STSTATUS_createItemList(), STSTATUS_createItemScreen(), STSTATUS_createMapScreen(), STSTATUS_createMenu(), STSTATUS_createSortScreen(), STSTATUS_createStatusScreen(), STSTATUS_createTechScreen(), WFIGHTMN_createLoader(), WFIGHTTS_createCameraList(), WFIGHTTS_createFighterList(), and WFIGHTTS_createStageList().

Here is the call graph for this function:

◆ taskSetState()

void taskSetState ( Task *  task,
s32  state 
)

Task method: goes to state state, from substate 0.

Definition at line 7 of file task.c.

Referenced by createTaskWithId().

Here is the caller graph for this function:

◆ taskSetSubstate()

void taskSetSubstate ( Task *  task,
s32  substate 
)

Task method: goes to substate substate, from step 0.

Definition at line 15 of file task.c.

Referenced by createTaskWithId().

Here is the caller graph for this function:

◆ taskSetStep()

void taskSetStep ( Task *  task,
s32  step 
)

Task method: goes to step step, with its counter at 0.

Definition at line 22 of file task.c.

Referenced by createTaskWithId().

Here is the caller graph for this function:

◆ taskSetCounter()

void taskSetCounter ( Task *  task,
s32  counter 
)

Task method: sets the counter.

Definition at line 28 of file task.c.

Referenced by createTaskWithId().

Here is the caller graph for this function:

◆ taskNextState()

void taskNextState ( Task *  task)

Task method: goes to the next state, from substate 0.

Definition at line 33 of file task.c.

Referenced by createTaskWithId().

Here is the caller graph for this function:

◆ taskNextSubstate()

void taskNextSubstate ( Task *  task)

Task method: goes to the next substate, from step 0.

Definition at line 41 of file task.c.

Referenced by createTaskWithId().

Here is the caller graph for this function:

◆ taskNextStep()

void taskNextStep ( Task *  task)

Task method: goes to the next step, with its counter at 0.

Definition at line 48 of file task.c.

Referenced by createTaskWithId().

Here is the caller graph for this function:

◆ taskTickCounter()

void taskTickCounter ( Task *  task)

Task method: counts one more.

Definition at line 54 of file task.c.

Referenced by createTaskWithId().

Here is the caller graph for this function:

◆ destroyTask()

void destroyTask ( Task *  task)

Default destructor: kills the children, then frees the task.

Definition at line 59 of file task.c.

Referenced by createTaskWithId().

Here is the caller graph for this function:

◆ createTaskWithId()

void * createTaskWithId ( void(*)()  update,
s32  size,
s32  childrenSize,
s32  id 
)

Allocates a zeroed task of size bytes (header included) with room for childrenSize / 4 child tasks.

A nonzero id also registers it (findTask).

< the current mode's: freed by main whenever the mode task ends

< the current mode's: freed by main whenever the mode task ends

Definition at line 80 of file task.c.

Referenced by createClutTile(), createCommand800(), createCommand801(), createCommand802(), createCommand807(), createCommand808(), createCommand809(), createCommand810(), createCommand811(), createCommand814(), createCommand815(), createCommand827(), createCommand828(), createCommand829(), createCommand830(), createCommand831(), createCommand832(), createCommand833(), createCommand834(), createCommand835(), createCommand838(), createCommand839(), createCommand848(), createCommand849(), createCommand852(), createCommand853(), createCommand854(), createCommand855(), createDarkness(), createFaller(), createFloaterChain(), createMover(), createScroller(), createSoundTile(), createStageEffect(), createStageEffectWithId(), createStillTile(), createTask(), createTileDuo(), createTileEffect(), createTileLift(), createTilePair(), createTilePair16(), createTilePairN(), createTileQuad(), createTileSeqs(), createTileSixWithId(), createTileSixWWithId(), createTileSolo(), createTileTask(), createWanderer(), createWanderPair(), FIELDSTG_createActor(), FIELDSTG_createActorIcon(), FIELDSTG_createBalloon(), FIELDSTG_createBanner(), FIELDSTG_createCamera(), FIELDSTG_createField(), FIELDSTG_createHiddenSpots(), FIELDSTG_createLift(), FIELDSTG_createMapStreamer(), FIELDSTG_startCommandTask(), FIGHTSTG_createBattleCamera(), FIGHTSTG_createLights(), FIGHTSTG_createModel(), FIGHTSTG_createModels(), FIGHTSTG_createStage(), FIGHTSTG_startPlayerTurn(), startStage(), WFIGHTMN_start(), WFIGHTTS_createEffectList(), WFIGHTTS_createMotionList(), and WFIGHTTS_start().

Here is the call graph for this function:

◆ executeTask()

struct Task * executeTask ( struct Task *  task)

One frame of a task and its children; returns NULL once the task is gone.

Definition at line 70 of file registry.c.

Referenced by runChildTasks(), and runTask().

Here is the caller graph for this function:

◆ runChildTasks()

void runChildTasks ( Task *  task)

Runs a frame of each child of a task, dropping the ones that end.

Definition at line 94 of file registry.c.

Here is the call graph for this function:

◆ runTask()

Task * runTask ( Task *  task)

Runs a frame of a task and its children; returns it, or NULL once it is gone.

Definition at line 107 of file registry.c.

Here is the call graph for this function:

◆ killTask()

void killTask ( Task *  task)

Ends a task now: its last update and destroy run at once.

Definition at line 115 of file registry.c.

◆ clearTaskRegistry()

void clearTaskRegistry ( void  )

Forgets every registered task.

Definition at line 4 of file registry.c.

◆ registerTask()

void registerTask ( Task *  task)

Adds a task to the first free entry of the registry (ignored when it is full)

Definition at line 13 of file registry.c.

◆ unregisterTask()

void unregisterTask ( Task *  task)

Removes a task from the registry.

Definition at line 26 of file registry.c.

◆ findNextTask()

void * findNextTask ( void  )

The next registered task that matches findTask's id and keys (-1 matches anything), or NULL.

Definition at line 39 of file registry.c.

Referenced by findTask().

Here is the caller graph for this function:

◆ findTask()

void * findTask ( s32  id,
s32  key1,
s32  key2 
)

The first registered task that matches (-1 matches anything), or NULL.

Definition at line 56 of file registry.c.

Here is the call graph for this function:

Variable Documentation

◆ TASK_REGISTRY

TaskRegistry TASK_REGISTRY
extern

Definition at line 122 of file registry.c.

Referenced by addModel(), clearTaskRegistry(), createTaskWithId(), destroyTask(), endBattleOnKnockOut(), executeTask(), fadeInStageLights(), FIELDSTG_balloonCommand(), FIELDSTG_closeField(), FIELDSTG_countBattleSteps(), FIELDSTG_drainTrail(), FIELDSTG_findActor(), FIELDSTG_findActorAt(), FIELDSTG_findHiddenSpot(), FIELDSTG_followLeader(), FIELDSTG_followWithCamera(), FIELDSTG_haltPartners(), FIELDSTG_handleFieldCommand(), FIELDSTG_isTileFree(), FIELDSTG_leaveFieldAfter(), FIELDSTG_openInn(), FIELDSTG_pickViewTiles(), FIELDSTG_pointCamera(), FIELDSTG_resumePartners(), FIELDSTG_runEvent(), FIELDSTG_runLaunch(), FIELDSTG_scrollCamera(), FIELDSTG_searchEventSpot(), FIELDSTG_setEventPose(), FIELDSTG_shakeCamera(), FIELDSTG_startActorGauge(), FIELDSTG_startAreaBattle(), FIELDSTG_startEncounter(), FIELDSTG_startEvent(), FIELDSTG_startListedEvent(), FIELDSTG_startWarp(), FIELDSTG_talkToActorAt(), FIELDSTG_updateBalloon(), FIELDSTG_updateCamera(), FIELDSTG_updateLift(), FIELDSTG_updateSpotEffect(), FIELDSTG_updateTriggers(), FIGHTSTG_getEnemyView(), FIGHTSTG_getFighterView(), FIGHTSTG_isPlayerChoosing(), FIGHTSTG_runScriptCamera(), FIGHTSTG_runScriptStage(), FIGHTSTG_setPlayerTurnStep(), FIGHTSTG_updateBattleScript(), FIGHTSTG_updateCameraShots(), FIGHTSTG_updateCameraTurn(), FIGHTSTG_updateDigimonChange(), FIGHTSTG_updateEntrance(), FIGHTSTG_updateHitEffect(), FIGHTSTG_updatePartnerView(), FIGHTSTG_updateShotCamera(), fillEffectLists(), findNextTask(), findTask(), handleCommand807(), handleCommand814(), killTask(), main(), registerTask(), removeModel(), showActorIcon(), startEvent8000(), startEvent8001(), startEvent8002(), unregisterTask(), updateEvent9015(), updateRisers(), updateTileLift(), updateTileTimer(), WFIGHTMN_blast(), WFIGHTMN_setIdleMotion(), and WFIGHTTS_motionList().