Digimon World 3 decomp
The European version, SLES_039.36
Loading...
Searching...
No Matches
actor_icon.c
Go to the documentation of this file.
1/* The icon over the player's head */
2
3#include "field/field_mode.h"
4
5/* The icon over the player's head: plays the animation of its substate
6 (FIELDSTG_iconAnims) and follows its climbs along FIELDSTG_iconPath */
8 SpriteDrawer sprite;
9 Vec2 pos;
10 u8 (*anim)[2];
11 Actor *actor;
12 s32 step;
13 s32 time;
14
15 switch (task->state) {
16 default:
17 case TASK_INIT:
18 task->nextState(task);
19 /* fallthrough */
20 case TASK_RUN:
21 if (task->step == 0) {
22 task->anim = FIELDSTG_iconAnims[task->substate];
23 task->animStep = 0;
24 task->animTime = 0;
25 switch (task->substate) {
26 case 1:
27 case 3:
29 break;
30 }
31 task->nextStep(task);
32 }
33 if (task->actor != NULL && task->actor->state == TASK_RUN) {
34 step = task->animStep;
35 time = task->animTime;
36 time += GFX.funcs.getFrameTime();
37 anim = task->anim;
38 if (anim[step][1] < time) {
39 time -= anim[step][1];
40 step++;
41 if (anim[step][0] == 0xFF) {
42 step = anim[step][1];
43 }
44 task->frame = anim[step][0];
45 task->animStep = step;
46 }
47 task->animTime = time;
48 actor = task->actor;
49 switch (actor->substate) {
51 if (actor->climbSide != 0) {
53 } else {
55 }
59 }
60 break;
62 if (FIELDSTG_iconPathStep == 0) {
64 }
65 if (actor->climbSide != 0) {
67 } else {
69 }
71 if (FIELDSTG_iconPathStep != 1) {
73 }
74 break;
75 default:
76 pos.x = actor->tile.x;
78 pos.y = actor->tile.y;
79 break;
80 }
81 initSpriteDrawer(&sprite);
83 sprite.setLayerId(FIELD_LAYER_MAP, 2);
84 sprite.draw(FILE_CACHE.getEntry(FIELD_SPRITES_FILE << 16), task->frame, pos.x, pos.y);
85 }
86 break;
87 case TASK_DONE:
88 case TASK_KILL:
89 break;
90 }
91}
92
93/* Creates the player's icon, in the modes before MODE_NEW_GAME only */
95 ActorIcon *task;
96
99 task->actor = actor;
100 return task;
101 }
102 return NULL;
103}
void FIELDSTG_updateActorIcon(ActorIcon *task)
The icon over the player's head: plays the animation of its substate (FIELDSTG_iconAnims) and follows...
Definition actor_icon.c:7
ActorIcon * FIELDSTG_createActorIcon(Actor *actor)
Creates the player's icon, in the modes before MODE_NEW_GAME only.
Definition actor_icon.c:94
#define NULL
Definition common.h:17
signed int s32
Definition common.h:11
unsigned char u8
Definition common.h:8
GfxState GFX
GFX: the graphics state and its methods.
Definition display.c:209
GameState GAME
The save data, the game mode and the methods.
Definition state.c:64
#define TASK_RUN
Definition task.h:35
#define TASK_KILL
Definition task.h:37
#define TASK_INIT
Tasks: every game object is a task, a heap block that starts with this header and is updated once per...
Definition task.h:34
#define TASK_DONE
Definition task.h:36
#define FIELD_LAYER_MAP
the map, its objects and characters, and the menus
Definition field_map.h:20
#define ACTOR_CLIMB_OFF_TOP
Definition field_map.h:316
#define ACTOR_GET_OVER_EDGE
onto the wall from above (FIELDSTG_startClimbDown)
Definition field_map.h:315
#define FIELD_TASK_ICON
the icon over the player's head
Definition field_map.h:31
FIELDSTG.PRO: the field mode, where the player walks around the map.
#define FIELD_SPRITES_X
Where the field keeps its textures in VRAM: the two images of FIELD_SPRITES_FILE (its entries 2 and 3...
Definition field_mode.h:27
#define FIELD_SPRITES_FILE
The field's effect sprites (FIELDSTG_drawSpotEffect): the discs number their files differently.
Definition field_mode.h:591
#define SOUND_ITEM_GET
Definition field_mode.h:45
#define FIELD_SPRITES_Y
Definition field_mode.h:29
IconOffset FIELDSTG_iconPath[]
up to (0, 0)
Definition fieldstg.c:1839
u8(*[] FIELDSTG_iconAnims)[2]
FIELDSTG_updateActorIcon's animation of each substate.
Definition fieldstg.c:1836
s32 FIELDSTG_iconPathStep
the step in FIELDSTG_iconPath
Definition fieldstg.c:1845
FileCache FILE_CACHE
The file cache.
Definition file_cache.c:7
#define MODE_NEW_GAME
Game modes (GameState: mode >> 8 is the overlay) that more than their own overlay asks for.
Definition game_state.h:429
SoundState SOUND
rsin and rcos (libgte) read rsin_tbl[a - 0x800] and the like: their addresses before the table fall i...
Definition sound.c:180
void initSpriteDrawer(SpriteDrawer *obj)
Clears a sprite drawer to neutral (no scale, gray tint, follows the scroll), gives it its methods and...
The player's icon (FIELD_TASK_ICON, FIELDSTG_createActorIcon): the field commands FIELD_COMMAND_ICON1...
Definition field_mode.h:160
void(* nextStep)(struct ActorIcon *task)
Definition field_mode.h:161
Actor * actor
Definition field_mode.h:162
u8(* anim)[2]
(frame, time) pairs; 0xFF loops to a step
Definition field_mode.h:166
void(* nextState)(struct ActorIcon *task)
Definition field_mode.h:161
A character on the field (FIELDSTG_createActor): the player (kind 0) and the other characters.
Definition field_map.h:334
s32 climbSide
a climb shifts it a tile right (1) or left (0)
Definition field_map.h:349
s32 substate
Definition field_map.h:335
Vec2 tile
Definition field_map.h:337
s32 state
Definition field_map.h:335
void *(* getEntry)(u32 fileAndIndex)
Definition file.h:96
s32(* getMode)(void)
Definition game_state.h:19
GameFuncs funcs
Definition game_state.h:582
s32(* getFrameTime)(void)
Definition gfx.h:32
GfxFuncs funcs
Definition gfx.h:77
short(* playSound)(s32 id)
returns the voice of a key-on
Definition sound.h:187
Draws sprites from a sprite sheet (such as file 0x277, the menu graphics): a sheet has a table of fra...
Definition gfx.h:223
void(* setLayerId)()
(id, depth)
Definition gfx.h:244
void(* draw)()
(sheet, frame, x, y)
Definition gfx.h:246
void(* setTexture)()
(x, y)
Definition gfx.h:242
Definition gfx.h:352
s32 y
Definition gfx.h:354
s32 x
Definition gfx.h:353
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.
Definition task.c:80