Digimon World 3 decomp
The European version, SLES_039.36
Loading...
Searching...
No Matches
cutscene.c
Go to the documentation of this file.
1/* The animations of a cutscene over the field */
2
3#include "field/field_mode.h"
4
5/* A cutscene's animation over the field (FIELDSTG_createCutsceneAnim): kind 0 plays once,
6 kind 1 loops two animations until 160 ticks of frame time pass. The match
7 depends on the if/else around the file calls (not a ?: in their argument). */
9 TimLoader loader;
10 SpriteDrawer drawer;
11 s32 loading;
12
13 switch (task->state) {
14 case TASK_INIT:
15 default:
16 switch (task->substate) {
17 case 0:
18 default:
19 if (task->kind) {
21 } else {
23 }
24 task->nextSubstate(task);
25 /* fallthrough */
26 case 1:
27 if (task->kind) {
29 } else {
31 }
32 if (loading == 0) {
33 initTimLoader(&loader);
36 if (task->kind) {
37 loader.loadArchive(FILE_CACHE.getEntry(((FIELD_ANIM_FILE + 1) << 16) | 1));
39 } else {
42 }
43 task->nextState(task);
44 }
45 break;
46 }
47 break;
48 case TASK_RUN:
49 if (task->kind == 0) {
50 if (task->timer <= 0) {
51 task->index++;
54 } else {
55 task->timer -= GFX.funcs.getFrameTime();
56 }
57 if (task->frame == -1) {
58 task->setState(task, TASK_DONE);
59 }
60 }
61 break;
62 case TASK_DONE:
63 case TASK_KILL:
64 break;
65 }
66
67 if (task->state == TASK_RUN || task->state == TASK_DONE) {
68 if (task->kind) {
69 while (1) {
70 if (task->timer <= 0) {
71 task->index++;
74 } else {
75 task->timer -= GFX.funcs.getFrameTime();
76 }
77 if (task->frame != -1) {
78 break;
79 }
80 task->index = task->timer;
81 task->timer = -1;
82 }
83 while (1) {
84 if (task->timer2 <= 0) {
85 task->index2++;
88 } else {
89 task->timer2 -= GFX.funcs.getFrameTime();
90 }
91 if (task->frame2 != -1) {
92 break;
93 }
94 task->index2 = task->timer2;
95 task->timer2 = -1;
96 }
97 task->counter += GFX.funcs.getFrameTime();
98 if (task->counter > 0xA0) {
99 task->setState(task, TASK_DONE);
100 }
101 }
102 initSpriteDrawer(&drawer);
103 drawer.setFollowScroll(0);
104 drawer.setLayerId(FIELD_LAYER_MAP, 7);
105 drawer.setTexture(FIELD_CUTSCENE_X, 0);
107 if (task->kind) {
108 drawer.draw(FILE_CACHE.getEntry((FIELD_ANIM_FILE + 1) << 16), task->frame, 0, 0);
109 if (task->frame2 != 0) {
110 drawer.draw(FILE_CACHE.getEntry((FIELD_ANIM_FILE + 1) << 16), task->frame2, 0, 0);
111 }
112 } else if (task->state == TASK_RUN) {
113 drawer.draw(FILE_CACHE.getEntry(FIELD_ANIM_FILE << 16), task->frame, 0, 0);
114 }
115 if (task->kind) {
116 drawer.draw(FILE_CACHE.getEntry((FIELD_ANIM_FILE + 1) << 16), 0, 0, 0);
117 } else {
118 drawer.draw(FILE_CACHE.getEntry(FIELD_ANIM_FILE << 16), 10, 0, 0);
119 }
120 }
121}
122
123/* Creates a cutscene animation of a kind */
126
127 task->kind = kind;
128 return task;
129}
signed int s32
Definition common.h:11
void FIELDSTG_playCutsceneAnim(CutsceneAnim *task)
A cutscene's animation over the field (FIELDSTG_createCutsceneAnim): kind 0 plays once,...
Definition cutscene.c:8
CutsceneAnim * FIELDSTG_createCutsceneAnim(s32 kind)
Creates a cutscene animation of a kind.
Definition cutscene.c:124
GfxState GFX
GFX: the graphics state and its methods.
Definition display.c:209
#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
FIELDSTG.PRO: the field mode, where the player walks around the map.
#define SOUND_SUB_DEMO
Definition field_mode.h:48
#define FIELD_ANIM_FILE
The two animations of FIELDSTG_playCutsceneAnim, kind 0's file and kind 1's after it: the discs numbe...
Definition field_mode.h:380
#define FIELD_CUTSCENE_CLUT_Y
Definition field_mode.h:34
#define FIELD_CUTSCENE_X
Definition field_mode.h:33
#define SOUND_DIG_DEMO
The sounds only FIELDSTG plays (SOUND.playSound), by their SOUNDTST names.
Definition field_mode.h:41
AnimFrame FIELDSTG_cutsceneLoopAnim2[]
Definition fieldstg.c:1359
AnimFrame FIELDSTG_cutsceneLoopAnim[]
and kind 1's two
Definition fieldstg.c:1354
AnimFrame FIELDSTG_cutsceneAnim[]
FIELDSTG_playCutsceneAnim's animations: kind 0's,.
Definition fieldstg.c:1347
FileCache FILE_CACHE
The file cache.
Definition file_cache.c:7
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...
s16 frame
Definition gfx.h:297
s16 duration
Definition gfx.h:298
A cutscene's animation over the field (FIELDSTG_createCutsceneAnim)
Definition field_mode.h:364
s32 frame2
kind 1's second animation
Definition field_mode.h:370
void(* setState)(struct CutsceneAnim *task, s32 state)
Definition field_mode.h:365
void(* nextSubstate)(struct CutsceneAnim *task)
Definition field_mode.h:365
void(* nextState)(struct CutsceneAnim *task)
Definition field_mode.h:365
s32 kind
0: file 0x88C (0x87B in the USA), 1: file 0x88D (0x87C)
Definition field_mode.h:366
s32 index
into the animation
Definition field_mode.h:368
s32(* isLoading)(s32 file)
Definition file.h:88
void(* request)(s32 file)
Definition file.h:90
void *(* getEntry)(u32 fileAndIndex)
Definition file.h:96
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(* setAltClut)()
(x, y)
Definition gfx.h:243
void(* setLayerId)()
(id, depth)
Definition gfx.h:244
void(* setFollowScroll)()
(on)
Definition gfx.h:251
void(* draw)()
(sheet, frame, x, y)
Definition gfx.h:246
void(* setTexture)()
(x, y)
Definition gfx.h:242
Uploads TIM images to VRAM (initTimLoader); acts on TIM_LOADER.
Definition gfx.h:325
void(* setClutPos)()
(x, y)
Definition gfx.h:337
void(* setImagePos)()
(x, y)
Definition gfx.h:336
void(* loadArchive)()
(archive): each image 64 halfwords to the right
Definition gfx.h:338
void * createTask(void(*update)(), s32 size, s32 childrenSize)
createTaskWithId for a task nothing needs to find
Definition task.c:105
void initTimLoader(TimLoader *obj)
Clears a TIM loader, gives it its methods and binds it.
Definition tim_loader.c:119