Digimon World 3 decomp
The European version, SLES_039.36
Loading...
Searching...
No Matches
backdrop.c
Go to the documentation of this file.
1/* The screen's backdrop: the scrolling sprites, the sparkles and the shine */
2
3#include "menus/player_name.h"
4
5/* The scrolling sprites' task: once their image is loaded, moves the two
6 sprites diagonally at different speeds, each starting over at its end
7 (STPLNMET_scrollEnds), and draws them with a still one */
9 SpriteDrawer sprite;
10 s32 now;
11 s32 i;
12
13 switch (task->state) {
14 case TASK_INIT:
15 default:
16 if (task->loaded != 0) {
17 task->times[0] = task->times[1] = GFX.funcs.getTime();
18 task->nextState(task);
19 }
20 break;
21 case TASK_RUN:
22 initSpriteDrawer(&sprite);
23 sprite.setTexture(task->vramX, task->vramY);
24 sprite.setLayerId(task->layer, task->depth);
25 now = GFX.funcs.getTime();
26 for (i = 0; i < 2; i++) {
27 if (now - task->times[i] > i + 1) {
28 task->pos[i][0] -= 2;
29 task->pos[i][1]++;
30 if (task->pos[i][0] <= STPLNMET_scrollEnds[i]) {
31 task->pos[i][0] = task->pos[i][1] = 0;
32 }
33 task->times[i] = now;
34 }
35 sprite.draw(FILE_CACHE.getEntry(PLNMET_SCROLL), i, task->pos[i][0], task->pos[i][1]);
36 }
37 sprite.draw(FILE_CACHE.getEntry(PLNMET_SCROLL), 2, 0, 0);
38 break;
39 case TASK_DONE:
40 case TASK_KILL:
41 break;
42 }
43}
44
45/* Loads the scrolling sprites' image into VRAM at (x, y) (scroll->load) */
47 TimLoader loader;
48
49 task->vramX = x;
50 task->vramY = y;
51 initTimLoader(&loader);
52 loader.setImagePos(x, y);
54 task->loaded = 1;
55}
56
57/* Sets the layer and depth the scrolling sprites are drawn in (scroll->setLayer) */
58void STPLNMET_setScrollLayer(NameScroll *task, s32 layer, s32 depth) {
59 task->layer = layer;
60 task->depth = depth;
61}
62
63/* Creates the scrolling sprites (task), drawn once their image is loaded */
71
72/* The sparkles' task: draws five sparkles in place, all on the same looping frame */
74 SpriteDrawer sprite;
75
76 switch (task->state) {
77 case TASK_INIT:
78 default:
79 task->frame = 24;
80 task->nextState(task);
81 break;
82 case TASK_RUN:
83 initSpriteDrawer(&sprite);
84 sprite.setTexture(0x280, 0x100);
85 sprite.setLayerId(0x1001, 6);
86 if (GFX.funcs.getTime() - task->time > 4) {
87 task->time = GFX.funcs.getTime();
88 task->frame++;
89 if (task->frame >= 36) {
90 task->frame = 24;
91 }
92 }
93 sprite.draw(FILE_CACHE.getEntry(PLNMET_MENU), task->frame, 0x33, 0);
94 sprite.draw(FILE_CACHE.getEntry(PLNMET_MENU), task->frame, 0x78, -0x14);
95 sprite.draw(FILE_CACHE.getEntry(PLNMET_MENU), task->frame, 0xA7, -0x58);
96 sprite.draw(FILE_CACHE.getEntry(PLNMET_MENU), task->frame, 0xF8, 0xD);
97 sprite.draw(FILE_CACHE.getEntry(PLNMET_MENU), task->frame, 0x120, 0);
98 break;
99 case TASK_DONE:
100 case TASK_KILL:
101 break;
102 }
103}
104
105/* Creates the sparkles (task) */
109
110/* The shine's task: draws a sprite animated by STPLNMET_sparkleFrames, looping */
112 SpriteDrawer sprite;
113
114 switch (task->state) {
115 case TASK_INIT:
116 default:
117 task->nextState(task);
118 break;
119 case TASK_RUN:
120 initSpriteDrawer(&sprite);
121 sprite.setTexture(0x280, 0x100);
122 sprite.setLayerId(0x1001, 6);
123 if (GFX.funcs.getTime() - task->time > STPLNMET_sparkleFrames[task->frame].delay) {
124 task->time = GFX.funcs.getTime();
125 task->frame++;
126 if (STPLNMET_sparkleFrames[task->frame].sprite == 0) {
127 task->frame = 0;
128 }
129 }
131 break;
132 case TASK_DONE:
133 case TASK_KILL:
134 break;
135 }
136}
137
138/* Creates the shine (task) */
void STPLNMET_updateSparkles(NameSparkle *task)
The sparkles' task: draws five sparkles in place, all on the same looping frame.
Definition backdrop.c:73
void STPLNMET_setScrollLayer(NameScroll *task, s32 layer, s32 depth)
Sets the layer and depth the scrolling sprites are drawn in (scroll->setLayer)
Definition backdrop.c:58
NameSparkle * STPLNMET_createShine(void)
Creates the shine (task)
Definition backdrop.c:139
NameSparkle * STPLNMET_createSparkles(void)
Creates the sparkles (task)
Definition backdrop.c:106
void STPLNMET_updateScroll(NameScroll *task)
The scrolling sprites' task: once their image is loaded, moves the two sprites diagonally at differen...
Definition backdrop.c:8
void STPLNMET_loadScroll(NameScroll *task, s32 x, s32 y)
Loads the scrolling sprites' image into VRAM at (x, y) (scroll->load)
Definition backdrop.c:46
NameScroll * STPLNMET_createScroll(void)
Creates the scrolling sprites (task), drawn once their image is loaded.
Definition backdrop.c:64
void STPLNMET_updateShine(NameSparkle *task)
The shine's task: draws a sprite animated by STPLNMET_sparkleFrames, looping.
Definition backdrop.c:111
signed int s32
Definition common.h:11
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
FileCache FILE_CACHE
The file cache.
Definition file_cache.c:7
STPLNMET.PRO: the player's name entry (MODE_PLAYER_NAME).
#define PLNMET_MENU
sprite bank
Definition player_name.h:36
#define FILE_PLNMET_IMAGE
Definition player_name.h:31
#define PLNMET_SCROLL
Definition player_name.h:38
void initSpriteDrawer(SpriteDrawer *obj)
Clears a sprite drawer to neutral (no scale, gray tint, follows the scroll), gives it its methods and...
s32 STPLNMET_scrollEnds[]
Where each scroll layer starts over (STPLNMET_updateScroll)
Definition stplnmet.c:6
SparkleFrame STPLNMET_sparkleFrames[]
The sparkle's frames (STPLNMET_updateShine): sprite 0 starts over.
Definition stplnmet.c:10
void *(* getEntry)(u32 fileAndIndex)
Definition file.h:96
s32(* getTime)(void)
Definition gfx.h:31
GfxFuncs funcs
Definition gfx.h:77
Two scrolling sprites (STPLNMET_createScroll), once their image is loaded.
Definition player_name.h:41
s32 times[2]
Definition player_name.h:48
void(* nextState)(struct NameScroll *task)
Definition player_name.h:42
void(* load)(struct NameScroll *task, s32 x, s32 y)
Definition player_name.h:50
void(* setLayer)(struct NameScroll *task, s32 layer, s32 depth)
Definition player_name.h:51
s32 pos[2][2]
Definition player_name.h:49
An animated sprite (STPLNMET_updateSparkles, STPLNMET_updateShine)
Definition player_name.h:61
void(* nextState)(struct NameSparkle *task)
Definition player_name.h:62
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
Uploads TIM images to VRAM (initTimLoader); acts on TIM_LOADER.
Definition gfx.h:325
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