Digimon World 3 decomp
The European version, SLES_039.36
Loading...
Searching...
No Matches
screen.c
Go to the documentation of this file.
1/* The screen's main task; the files it loads; and the panels' openings and
2 moves */
3
4#include "menus/memory_card.h"
5
6/* The main task: loads the files, runs the save list, then fades out and
7 requests the next mode */
9 SpriteDrawer sprite;
10
11 switch (screen->state) {
12 case TASK_INIT:
13 default:
14 switch (screen->substate) {
15 case 0:
16 default:
18 screen->substate++;
19 break;
20 case 1:
21 if (STGMCARD_funcs.filesLoading() == 0 && SOUND.isLoading() == 0) {
23 screen->nextState(screen);
24 }
25 break;
26 }
27 break;
28 case TASK_RUN:
29 switch (screen->substate) {
30 case 0:
31 default:
32 if (tasks->saves == NULL) {
33 tasks->saves = STGMCARD_createSaves(screen);
34 }
35 screen->nextSubstate(screen);
36 break;
37 case 1:
38 if (tasks->saves->state == 2) {
39 tasks->fade = STGMCARD_createFader();
40 tasks->fade->start(tasks->fade, 0, 30);
41 screen->substate++;
42 }
43 break;
44 case 2:
45 if (tasks->fade->state == 2) {
46 screen->state = TASK_KILL;
47 }
48 break;
49 }
50 initSpriteDrawer(&sprite);
51 sprite.setLayerId(screen->layer, 3);
52 sprite.setTexture(0x280, 0);
53 sprite.draw(FILE_CACHE.getEntry(FILE_GMCARD_SHEET << 16), 31, 25, 0);
54 if (screen->bgTick != 0) {
55 screen->bgScroll++;
56 screen->bgScroll = screen->bgScroll < 96 ? screen->bgScroll : 0;
57 screen->bgTick = 0;
58 } else {
59 screen->bgTick = 1;
60 }
61 sprite.draw(FILE_CACHE.getEntry(FILE_GMCARD_SHEET << 16), 30, screen->bgScroll, screen->bgScroll);
62 break;
63 case TASK_DONE:
64 break;
65 case TASK_KILL:
67 if (screen->step != 0) {
68 if (screen->loading == 0) {
70 } else {
72 }
73 } else {
75 }
77 break;
78 }
79}
80
81/* Creates the screen's main task, with what it needs from the mode it was
82 opened from and the one it was opened for */
85 s32 mode;
86 s32 prev;
87 s32 i;
88
89 screen->layer = SCREEN_LAYER;
90 mode = GAME.funcs.getMode() & 0xFF;
91 screen->loading = (u32)GAME.funcs.getModeArg() >> 31 ^ 1;
92 prev = GAME.funcs.getPrevMode();
93 for (i = 0; STGMCARD_prevModes[i].mode != 0; i++) {
94 if (STGMCARD_prevModes[i].mode == prev) {
95 screen->area = STGMCARD_prevModes[i].area;
96 }
97 }
98 screen->place = STGMCARD_places[mode];
99 SOUND.loadBank(0x20);
100 return screen;
101}
102
103/* Loads the screen's images, gives the memory card's save file its title and icon,
104 allocates the buffers of a save and of the card's info section, and requests the
105 strings */
107 TimLoader loader;
108 TextTools conv;
109 char title[0x48];
110 void *frames[3];
111 CardClut *clut;
112
113 initTimLoader(&loader);
114 loader.setImagePos(0x280, 0);
116 HEAP.zero(title, 0x41);
117 initTextTools(&conv);
118 conv.convert(title, conv.getString(FILE_CACHE.load(TEXT_FILE(TEXT_MEMORY_CARD)), 0x27), 0);
119 clut = STGMCARD_saveIcon.clut;
120 frames[0] = STGMCARD_saveIcon.frames[0];
121 frames[1] = STGMCARD_saveIcon.frames[1];
122 frames[2] = STGMCARD_saveIcon.frames[2];
123 MEMCARD_FUNCS.setHeader(title, clut, 3, frames);
124 if (STGMCARD_funcs.dataBuf != NULL) {
126 }
127 STGMCARD_funcs.dataSize = 0x2780;
128 STGMCARD_funcs.dataBuf = HEAP.alloc(0x2780, 2);
129 if (STGMCARD_funcs.infoBuf != NULL) {
131 }
132 STGMCARD_funcs.infoSize = 0x180;
133 STGMCARD_funcs.infoBuf = HEAP.alloc(0x180, 2);
137}
138
139/* Whether the screen's strings are still loading */
142 return 1;
143 }
145 return 1;
146 }
148}
149
150/* Frees the buffers of a save and of the card's info section, when leaving the screen */
159
#define NULL
Definition common.h:17
signed int s32
Definition common.h:11
unsigned int u32
Definition common.h:12
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 TEXT_MEMORY_CARD
MEMCRD.
Definition file.h:217
#define TEXT_AREA_NAMES
STAREA.
Definition file.h:224
#define TEXT_FILE(file)
Definition file.h:190
#define TEXT_SHOP_NAMES
SHPNAM.
Definition file.h:221
FileCache FILE_CACHE
The file cache.
Definition file_cache.c:7
#define MODE_TITLE
STDWTITL's title screen; its movies follow.
Definition game_state.h:438
#define SCREEN_LAYER
The layer over the whole screen that most modes create first and draw their menus on (FIELDSTG and ST...
Definition gfx.h:45
Heap HEAP
The functions that return what a call left in v0 (allocMemHigh, findTask) and the ones that take othe...
Definition heap.c:184
MemCardFuncs MEMCARD_FUNCS
Definition memcard.c:468
STGMCARD.PRO: the memory card screen (MODE_CONTINUE).
ScreenFade * STGMCARD_createFader(void)
#define FILE_GMCARD_SHEET
Definition memory_card.h:19
#define FILE_GMCARD_SPRITES
The sprite archive of the screen.
Definition memory_card.h:18
void STGMCARD_freeBuffers(void)
Frees the buffers of a save and of the card's info section, when leaving the screen.
Definition screen.c:151
void STGMCARD_loadFiles(void)
Loads the screen's images, gives the memory card's save file its title and icon, allocates the buffer...
Definition screen.c:106
void STGMCARD_updateScreen(MemCardScreen *screen, MemCardScreenTasks *tasks)
The main task: loads the files, runs the save list, then fades out and requests the next mode.
Definition screen.c:8
s32 STGMCARD_filesLoading(void)
Whether the screen's strings are still loading.
Definition screen.c:140
MemCardScreen * STGMCARD_createScreen(void)
Creates the screen's main task, with what it needs from the mode it was opened from and the one it wa...
Definition screen.c:83
MemCardSaves * STGMCARD_createSaves(MemCardScreen *screen)
Creates the save list (task) of the main task.
Definition saves.c:1071
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
#define MUSIC_MEMORY_CARD
BGM_0030: the memory card screen and the player's name entry.
Definition sound.h:106
void initSpriteDrawer(SpriteDrawer *obj)
Clears a sprite drawer to neutral (no scale, gray tint, follows the scroll), gives it its methods and...
MemCardScreenFuncs STGMCARD_funcs
STGMCARD's data (data/stgmcard.c)
Definition stgmcard.c:127
SaveIcon STGMCARD_saveIcon
Definition stgmcard.c:196
MemCardModeEntry STGMCARD_prevModes[]
Definition stgmcard.c:64
s32 STGMCARD_places[]
the place a save shows (a string of TEXT_SHOP_NAMES), by the low byte of the game mode: the save poin...
Definition stgmcard.c:55
Memory card save header (first CARD_SECTOR_SIZE bytes of a save)
Definition memcard.h:57
void *(* load)(u32 file)
Definition file.h:92
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(* getMode)(void)
Definition game_state.h:19
s32(* getModeArg)()
Definition game_state.h:20
void(* requestMode)(s32 mode, s32 arg)
Definition game_state.h:21
s32(* getPrevMode)()
Definition game_state.h:23
s32 fieldMode
where the menu returns to
Definition game_state.h:503
GameFuncs funcs
Definition game_state.h:582
void *(* alloc)(s32 size, s32 tag)
Definition heap.h:29
void(* zero)(void *ptr, s32 size)
Definition heap.h:32
void(* free)(void *ptr)
Definition heap.h:27
void(* setHeader)(char *title, CardClut *clut, s32 count, void **icons)
Definition memcard.h:113
u8 area
a string of TEXT_AREA_NAMES
Definition memory_card.h:31
SaveData * dataBuf
the saved part of the game state
s32(* filesLoading)(void)
MemCardFile * infoBuf
void(* freeBuffers)(void)
void(* loadFiles)(void)
The children of the main task.
Definition memory_card.h:55
ScreenFade * fade
Definition memory_card.h:57
struct MemCardSaves * saves
Definition memory_card.h:56
The main task of the screen (STGMCARD_createScreen)
Definition memory_card.h:37
s32 bgScroll
the background's offset, 0 to 95
Definition memory_card.h:42
s32 place
a string of TEXT_SHOP_NAMES (STGMCARD_places)
Definition memory_card.h:46
void(* nextState)(struct MemCardScreen *task)
Definition memory_card.h:38
void(* nextSubstate)(struct MemCardScreen *task)
Definition memory_card.h:38
s32 bgTick
it moves every other frame
Definition memory_card.h:43
s32 area
a string of TEXT_AREA_NAMES, from the previous mode
Definition memory_card.h:45
s32 loading
opened from the title screen: the game mode's argument is not negative (saving: negative)
Definition memory_card.h:39
CardClut * clut
SaveIconFrame * frames[3]
void(* start)(struct ScreenFade *fade, s32 fadeIn, s32 frames)
TASK_DONE when done.
Definition gfx.h:368
s32 state
Definition gfx.h:362
s32(* isLoading)(void)
Definition sound.h:193
void(* stopSound)(s32 id)
Definition sound.h:195
void(* loadBank)(s32 id)
Definition sound.h:190
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
Text helpers (initTextTools)
Definition text.h:93
char *(* getString)()
(table, index)
Definition text.h:94
void(* convert)()
(dst, src, mode): font codes <-> Shift-JIS
Definition text.h:96
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 initTextTools(TextTools *obj)
Clears a text tools object, gives it its methods and binds it.
Definition text_tools.c:193
void initTimLoader(TimLoader *obj)
Clears a TIM loader, gives it its methods and binds it.
Definition tim_loader.c:119