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 renaming screen's main task; the files it loads; and the panels'
2 openings */
3
5
6/* Runs the renaming screen: the partner menu, then the name entry for the chosen
7 partner, whose new name is stored before going back to the menu; ends once
8 the screen has faded out after leaving the menu */
10 s32 partner;
11
12 switch (task->substate) {
13 case 0:
14 default:
15 if (children->menu == NULL) {
16 children->menu = STDGNAME_createMenu(task);
17 }
18 task->substate++;
19 break;
20 case 1:
21 if (children->menu == NULL) {
22 if (task->choice == -1) {
23 task->substate = 5;
24 break;
25 }
26 task->substate++;
27 }
28 break;
29 case 2:
30 if (children->name == NULL) {
32 children->name = STDGNAME_createNameEntry(GAME.funcs.getPartnerStats(partner)->name, partner);
33 }
34 task->substate++;
35 break;
36 case 3:
37 if (children->name->substate == 100) {
38 children->name->getName(children->name,
40 children->name->close(children->name);
41 task->substate++;
42 }
43 break;
44 case 4:
45 if (children->name->state == TASK_DONE) {
46 children->name->state = TASK_KILL;
47 task->setSubstate(task, 0);
48 }
49 break;
50 case 5:
51 if (children->fade->state == TASK_DONE) {
52 task->setState(task, TASK_KILL);
53 }
54 break;
55 }
56}
57
58/* Draws the screen's background and its scrolling pattern */
60 SpriteDrawer sprite;
61
62 initSpriteDrawer(&sprite);
63 sprite.setLayerId(task->layer, 7);
64 sprite.setTexture(0x280, 0);
65 sprite.draw(FILE_CACHE.getEntry(STDGNAME_SPRITES), 0x31, 0, 0);
66 /* Scroll one pixel every other frame, wrapping at 96 */
67 if (task->bgTick) {
68 task->bgScroll = task->bgScroll++ < 95 ? task->bgScroll : 0;
69 task->bgTick = 0;
70 } else {
71 task->bgTick = 1;
72 }
73 sprite.draw(FILE_CACHE.getEntry(STDGNAME_SPRITES), 0x24, task->bgScroll, task->bgScroll);
74}
75
76/* The renaming screen's task: loads its files, then runs the screen and draws
77 the background; goes back to the field when killed */
79 switch (task->state) {
80 case TASK_INIT:
81 default:
82 switch (task->substate) {
83 case 0:
84 default:
86 task->substate++;
87 break;
88 case 1:
89 if (STDGNAME_funcs.isLoading() == 0) {
90 task->nextState(task);
91 }
92 break;
93 }
94 break;
95 case TASK_RUN:
96 STDGNAME_stepScreen(task, children);
98 break;
99 case TASK_DONE:
100 if (children->awaited == NULL) {
101 task->setState(task, TASK_RUN);
102 }
104 break;
105 case TASK_KILL:
107 break;
108 }
109}
110
111/* Fades the screen out over 30 frames (task->fadeOut), to leave it */
113 ScreenChildren *children = task->children;
114 ScreenFade *fade;
115
116 children->fade = fade = STDGNAME_createFader();
117 fade->start(fade, 0, 30);
118}
119
120/* Creates the renaming screen (task) */
123
125 task->layer = SCREEN_LAYER;
126 return task;
127}
128
129/* Loads the screen's textures and requests the keyboard and the strings; the
130 chosen partner goes back to the first */
142
143/* Whether the keyboard or the strings are still loading */
146 return 1;
147 }
149 return 1;
150 }
152}
153
#define NULL
Definition common.h:17
signed int s32
Definition common.h:11
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_NAME_ENTRY
NAMEDT: the keyboard's.
Definition file.h:219
#define TEXT_FILE(file)
Definition file.h:190
#define TEXT_DIGIMON_NAMING
DGNMET: STDGNAME's.
Definition file.h:209
FileCache FILE_CACHE
The file cache.
Definition file_cache.c:7
#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
PartnerMenuTask * STDGNAME_createMenu(ScreenTask *screen)
Creates the partner menu (task) to pick the partner to rename.
Definition menu.c:223
NameEntry * STDGNAME_createNameEntry(char *name, s32 partner)
Creates the name entry (task) for a partner, starting from the name given; up to 8 characters (5 in l...
Definition name_entry.c:22
ScreenTask * STDGNAME_createScreen(void)
Creates the renaming screen (task)
Definition screen.c:121
void STDGNAME_stepScreen(ScreenTask *task, ScreenChildren *children)
Runs the renaming screen: the partner menu, then the name entry for the chosen partner,...
Definition screen.c:9
void STDGNAME_drawBackground(ScreenTask *task)
Draws the screen's background and its scrolling pattern.
Definition screen.c:59
void STDGNAME_fadeOutScreen(ScreenTask *task)
Fades the screen out over 30 frames (task->fadeOut), to leave it.
Definition screen.c:112
s32 STDGNAME_filesLoading(void)
Whether the keyboard or the strings are still loading.
Definition screen.c:144
void STDGNAME_updateScreen(ScreenTask *task, ScreenChildren *children)
The renaming screen's task: loads its files, then runs the screen and draws the background; goes back...
Definition screen.c:78
void STDGNAME_loadFiles(void)
Loads the screen's textures and requests the keyboard and the strings; the chosen partner goes back t...
Definition screen.c:131
STDGNAME.PRO: the screen where the partners are renamed.
#define STDGNAME_FILE_KEYBOARD
#define STDGNAME_FILE_IMAGES
#define STDGNAME_SPRITES
sprite bank
ScreenFade * STDGNAME_createFader(void)
void initSpriteDrawer(SpriteDrawer *obj)
Clears a sprite drawer to neutral (no scale, gray tint, follows the scroll), gives it its methods and...
ScreenFuncs STDGNAME_funcs
style: the text style of the partners' names in the menu (STDGNAME_showMenuWindow)
Definition stdgname.c:646
s32(* isLoading)(s32 file)
Definition file.h:88
void(* request)(s32 file)
Definition file.h:90
void *(* getEntry)(u32 fileAndIndex)
Definition file.h:96
struct PartnerStats *(* getPartnerStats)(s32 partner)
Definition game_state.h:38
void(* requestMode)(s32 mode, s32 arg)
Definition game_state.h:21
s32(* getPartyMember)(u32 index)
Definition game_state.h:24
s32 fieldMode
where the menu returns to
Definition game_state.h:503
GameFuncs funcs
Definition game_state.h:582
void(* zero)(void *ptr, s32 size)
Definition heap.h:32
void(* close)(NameEntry *task)
Definition name_entry.h:129
s32 substate
Definition name_entry.h:96
void(* getName)(NameEntry *task, char *out)
Definition name_entry.h:125
char name[0x18]
Definition game_state.h:304
NameEntry * name
Task * awaited
never set: the screen would wait in TASK_DONE until it ends
PartnerMenuTask * menu
ScreenFade * fade
Fades the whole screen to black and back with a subtractive rectangle.
Definition gfx.h:361
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)
void(* loadFiles)(void)
The screen's controller.
void * children
void(* fadeOut)(struct ScreenTask *task)
void(* nextState)(struct ScreenTask *task)
void(* setState)(struct ScreenTask *task, s32 state)
void(* setSubstate)(struct ScreenTask *task, s32 substate)
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