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: its pages' tabs, the steps between them and the title; the files
2 it loads; and the panels' openings and moves */
3
4#include "menus/player_name.h"
5
6/* Creates the three tabs at the top (the name, the partners, the confirmation), hidden */
8 s32 i;
9
10 for (i = 0; i < 3; i++) {
11 children->tabs[i] = createTextWindow(screen->layer, 3, STPLNMET_tabX[i], 0x12);
12 children->tabs[i]->setString(children->tabs[i], FILE_CACHE.load(TEXT_FILE(TEXT_ONLINE)), i + 3);
13 children->tabs[i]->setPalette(children->tabs[i], PALETTE_BLUE);
14 children->tabs[i]->setVisible(children->tabs[i], 0);
15 }
16}
17
18/* Shows the tabs, the current page's one highlighted, or hides them */
20 s32 i;
21
22 for (i = 0; i < 3; i++) {
23 children->tabs[i]->setVisible(children->tabs[i], show);
24 if (screen->page == i) {
25 children->tabs[i]->setPalette(children->tabs[i], PALETTE_WHITE);
26 } else {
27 children->tabs[i]->setPalette(children->tabs[i], PALETTE_BLUE);
28 }
29 }
30}
31
32/* The screen's states: starts the sprites and the welcome, then goes through the
33 name, the partners and the confirmation (triangle going back); once
34 confirmed, saves the name in GAME.name, gives the party chosen and ends */
36 switch (screen->substate) {
37 case 0:
38 children->scroll = STPLNMET_createScroll();
39 children->scroll->load(children->scroll, 0x1C0, 0x100);
40 children->scroll->setLayer(children->scroll, screen->layer, 6);
42 children->shine = STPLNMET_createShine();
43 children->dialog = STPLNMET_createWelcome(screen);
44 screen->substate++;
45 break;
46 case 1:
47 if (children->dialog == NULL) {
48 STPLNMET_funcs.startFade(&screen->fade, 1);
50 children->partners = STPLNMET_createChoice(screen);
51 children->confirm = STPLNMET_createConfirm(screen);
52 screen->page = 0;
53 screen->nextSubstate(screen);
54 }
55 break;
56 case 2:
57 switch (screen->step) {
58 case 0:
59 default:
60 if (STPLNMET_funcs.updateFade(&screen->fade) != 0) {
61 STPLNMET_showTabs(screen, children, 1);
62 }
63 if (children->name->substate == 100) {
64 children->name->hide(children->name, 1);
65 children->partners->hide(children->partners, 0);
66 screen->page = 1;
67 STPLNMET_showTabs(screen, children, 1);
68 screen->step++;
69 }
70 break;
71 case 1:
72 if (children->partners->substate == 100) {
73 children->partners->hide(children->partners, 1);
74 children->confirm->choice = children->partners->choice;
75 children->confirm->name = children->name->name;
76 children->confirm->hide(children->confirm, 0);
77 screen->page = 2;
78 STPLNMET_showTabs(screen, children, 1);
79 screen->step++;
80 } else if (children->partners->substate == 200) {
81 children->partners->hide(children->partners, 1);
82 children->name->hide(children->name, 0);
83 screen->page = 0;
84 STPLNMET_showTabs(screen, children, 1);
85 screen->step--;
86 }
87 break;
88 case 2:
89 if (children->confirm->substate == 100) {
90 children->confirm->close(children->confirm);
91 STPLNMET_funcs.startFade(&screen->fade, 0);
92 STPLNMET_showTabs(screen, children, 0);
93 screen->step++;
94 } else if (children->confirm->substate == 200) {
95 children->confirm->hide(children->confirm, 1);
96 children->partners->hide(children->partners, 0);
97 screen->page = 1;
98 STPLNMET_showTabs(screen, children, 1);
99 screen->step--;
100 }
101 break;
102 case 3:
103 if (STPLNMET_funcs.updateFade(&screen->fade) != 0 && children->confirm == NULL) {
104 children->name->getName(children->name, GAME.name);
105 GAME.funcs.setParty(children->partners->choice);
106 screen->state = TASK_KILL;
107 }
108 break;
109 }
110 break;
111 }
112}
113
114/* Draws the page's title, opening and closing with the screen's fade */
116 SpriteDrawer sprite;
117
118 initSpriteDrawer(&sprite);
119 sprite.setTexture(0x280, 0x100);
120 sprite.setLayerId(screen->layer, screen->depth);
121 if (screen->fade.level != 0) {
122 if (screen->fade.level != ONE) {
123 sprite.setScale(screen->fade.level, ONE, ONE);
124 sprite.setPivot(0x18, 0x20);
125 }
126 sprite.draw(FILE_CACHE.getEntry(PLNMET_MENU), screen->page + 12, 0x18, 0x15);
127 }
128}
129
130/* The screen's task: loads its files and sound bank and creates the tabs, then
131 starts its music and runs it; stops the music and returns to the field
132 (mode 0x2D8) when it ends */
134 switch (screen->state) {
135 case TASK_INIT:
136 default:
137 switch (screen->substate) {
138 case 0:
139 default:
141 SOUND.loadBank(0x20);
142 screen->substate++;
143 break;
144 case 1:
145 if (STPLNMET_funcs.filesLoading() == 0) {
146 STPLNMET_createTabs(screen, children);
147 screen->fade.duration = 10;
148 screen->setState(screen, TASK_DONE);
149 }
150 break;
151 }
152 break;
153 case TASK_RUN:
154 STPLNMET_stepScreen(screen, children);
155 STPLNMET_drawTitle(screen);
156 break;
157 case TASK_DONE:
158 if (SOUND.isLoading() == 0) {
160 screen->setState(screen, TASK_RUN);
161 }
162 break;
163 case TASK_KILL:
165 GAME.funcs.requestMode(0x2D8, 0);
166 break;
167 }
168}
169
170/* Creates the player's name screen (task) */
173
174 screen->layer = 0x1001;
175 screen->depth = 5;
176 return screen;
177}
178
179/* Loads the screen's sprites into VRAM and requests its texts and the keyboard */
191
192/* Whether the screen's texts or the keyboard are still loading */
195 return 1;
196 }
198 return 1;
199 }
201 return 1;
202 }
204}
205
NameSparkle * STPLNMET_createShine(void)
Creates the shine (task)
Definition backdrop.c:139
NameSparkle * STPLNMET_createSparkles(void)
Creates the sparkles (task)
Definition backdrop.c:106
NameScroll * STPLNMET_createScroll(void)
Creates the scrolling sprites (task), drawn once their image is loaded.
Definition backdrop.c:64
#define NULL
Definition common.h:17
signed int s32
Definition common.h:11
NameConfirm * STPLNMET_createConfirm(PlayerNameScreen *screen)
Creates the confirmation of the name and the partners (task), hidden.
Definition confirm.c:288
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_ONLINE
NAMEET: the Digimon Online registration.
Definition file.h:220
#define TEXT_DIGIMON_NAMES
DIGNAM.
Definition file.h:211
FileCache FILE_CACHE
The file cache.
Definition file_cache.c:7
PartnerChoice * STPLNMET_createChoice(PlayerNameScreen *screen)
Creates the choice of the partners (task), hidden.
Definition choice.c:171
NameEntry * STPLNMET_createNameEntry(char *name)
Creates the name entry (task) for the player's name, starting from name: up to 8 characters (5 in Jap...
Definition name_entry.c:45
PlayerNameScreen * STPLNMET_createScreen(void)
Creates the player's name screen (task)
Definition screen.c:171
void STPLNMET_drawTitle(PlayerNameScreen *screen)
Draws the page's title, opening and closing with the screen's fade.
Definition screen.c:115
s32 STPLNMET_filesLoading(void)
Whether the screen's texts or the keyboard are still loading.
Definition screen.c:193
void STPLNMET_showTabs(PlayerNameScreen *screen, PlayerNameScreenChildren *children, s32 show)
Shows the tabs, the current page's one highlighted, or hides them.
Definition screen.c:19
void STPLNMET_loadFiles(void)
Loads the screen's sprites into VRAM and requests its texts and the keyboard.
Definition screen.c:180
void STPLNMET_createTabs(PlayerNameScreen *screen, PlayerNameScreenChildren *children)
Creates the three tabs at the top (the name, the partners, the confirmation), hidden.
Definition screen.c:7
void STPLNMET_updateScreen(PlayerNameScreen *screen, PlayerNameScreenChildren *children)
The screen's task: loads its files and sound bank and creates the tabs, then starts its music and run...
Definition screen.c:133
void STPLNMET_stepScreen(PlayerNameScreen *screen, PlayerNameScreenChildren *children)
The screen's states: starts the sprites and the welcome, then goes through the name,...
Definition screen.c:35
STPLNMET.PRO: the player's name entry (MODE_PLAYER_NAME).
#define PLNMET_MENU
sprite bank
Definition player_name.h:36
#define FILE_PLNMET_KEYBOARD
Definition player_name.h:30
#define FILE_PLNMET_SPRITES
The files of the screen.
Definition player_name.h:29
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...
PlayerNameFuncs STPLNMET_funcs
STPLNMET's data (data/stplnmet.c), in its order.
Definition stplnmet.c:841
s32 STPLNMET_tabX[]
The x of the keyboard's three tabs.
Definition stplnmet.c:822
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
void(* requestMode)(s32 mode, s32 arg)
Definition game_state.h:21
void(* setParty)()
Definition game_state.h:25
char name[0x18]
the player's
Definition game_state.h:509
GameFuncs funcs
Definition game_state.h:582
void(* hide)(struct NameConfirm *task, s32 hide)
void(* close)(struct NameConfirm *task)
s32 choice
STPLNMET_funcs.choices.
s32 substate
Definition name_entry.h:96
void(* getName)(NameEntry *task, char *out)
Definition name_entry.h:125
u16 name[12]
Definition name_entry.h:107
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 level
Definition menu.h:21
s32 duration
Definition menu.h:19
void(* hide)(struct PartnerChoice *task, s32 hide)
s32 choice
STPLNMET_funcs.choices.
void(* startFade)(PanelAnim *fade, s32 fadeIn)
void(* loadFiles)(void)
s32(* updateFade)(PanelAnim *fade)
s32(* filesLoading)(void)
struct NameConfirm * confirm
Definition player_name.h:94
TextWindow * tabs[3]
Definition player_name.h:98
struct PartnerChoice * partners
Definition player_name.h:93
struct NameDialog * dialog
Definition player_name.h:91
The main task of the screen (STPLNMET_createScreen)
Definition player_name.h:82
void(* setState)(struct PlayerNameScreen *task, s32 state)
Definition player_name.h:83
s32 page
0 the name, 1 the partners, 2 the confirmation
Definition player_name.h:86
void(* nextSubstate)(struct PlayerNameScreen *task)
Definition player_name.h:83
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(* setPivot)()
(x, y)
Definition gfx.h:250
void(* setScale)()
(x, y, z), ONE = 1.0
Definition gfx.h:248
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
void(* setPalette)(struct TextWindow *obj, u8 arg)
Definition text.h:174
void(* setString)()
Definition text.h:165
void(* setVisible)(struct TextWindow *obj, u8 arg)
Definition text.h:177
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
#define PALETTE_BLUE
a light blue: what is highlighted or current
Definition text.h:113
#define PALETTE_WHITE
The text windows' palettes (TextWindow.palette, setPalette): rows of the font's CLUTs,...
Definition text.h:112
TextWindow * createTextWindow(s16 layerId, s16 style, s16 x, s16 y)
A text window on a layer, in a font style, at (x, y)
void initTimLoader(TimLoader *obj)
Clears a TIM loader, gives it its methods and binds it.
Definition tim_loader.c:119
NameDialog * STPLNMET_createWelcome(PlayerNameScreen *screen)
Creates the welcome (task), the first thing the screen shows.
Definition welcome.c:95