Digimon World 3 decomp
The European version, SLES_039.36
Loading...
Searching...
No Matches
menu.c
Go to the documentation of this file.
1/* The mode's main task, which runs the field menu's screens; the scroll bar;
2 the files it loads; and the panels' openings and moves */
3
4#include "menus/field_menu.h"
5
11#define SCROLL_BAR_DEPTH 0
13
14/* Opens the screen of FIELD_MENU_CHOICE (the item screen when it has none) and,
15 once it closes, the field menu again */
17 Task *(*open)(FieldMenuScreen *, s32);
18
19 switch (menu->substate) {
20 case 0:
21 default:
23 if (open != NULL) {
24 children->screen = open(menu, FIELD_MENU_CHOICE.extra);
25 } else {
27 }
28 menu->substate++;
29 break;
30 case 1:
31 if (children->screen == NULL) {
33 menu->setState(menu, TASK_DONE);
34 }
35 break;
36 }
37}
38
39/* Draws the scrolling background, sprite 0x1D at (bgScroll, bgScroll): it
40 moves one pixel down and right every other frame, back to 0 at 0x60 */
42 SpriteDrawer sprite;
43
44 initSpriteDrawer(&sprite);
45 sprite.setLayerId(menu->layer, 7);
46 sprite.setTexture(0x280, 0x100);
47 if (menu->bgTick != 0) {
48 menu->bgScroll++;
49 menu->bgScroll = menu->bgScroll < 0x60 ? menu->bgScroll : 0;
50 menu->bgTick = 0;
51 } else {
52 menu->bgTick = 1;
53 }
54 sprite.draw(FILE_CACHE.getEntry(FILE_STATUS_SPRITES << 16), 0x1D, menu->bgScroll, menu->bgScroll);
55}
56
57/* The mode's main task: loads the files and the background's textures, then runs
58 the screens (STSTATUS_runScreens); while the field menu is open (TASK_DONE) it
59 waits for it to close */
61 TimLoader loader;
62
63 switch (menu->state) {
64 case TASK_INIT:
65 default:
66 switch (menu->substate) {
67 case 0:
68 default:
70 menu->substate++;
71 break;
72 case 1:
73 if (STSTATUS_data.funcs.filesLoading() == 0 && FILE_CACHE.isLoading(menu->bgFile) == 0 &&
74 FILE_CACHE.isLoading(menu->bgFile2) == 0) {
75 initTimLoader(&loader);
76 loader.setImagePos(0x380, 0x100);
78 loader.setImagePos(0x300, 0x100);
80 loader.setImagePos(0x280, 0);
81 loader.setClutPos(0x140, 0x100);
83 menu->nextState(menu);
84 }
85 break;
86 }
87 break;
88 case TASK_RUN:
89 STSTATUS_runScreens(menu, children);
91 break;
92 case TASK_DONE:
93 if (children->fieldMenu == NULL) {
94 menu->state = TASK_RUN;
95 }
97 break;
98 case TASK_KILL:
99 break;
100 }
101}
102
103/* Creates the mode's main task and requests its background's files, the second
104 half of the game's in the late game */
107
108 menu->layer = SCREEN_LAYER;
110 if (menu->gameHalf == 0) {
111 menu->bgArchive = (FILE_STATUS_BG + 1) << 16;
112 menu->bgFile = FILE_STATUS_BG + 1;
113 menu->bgArchive1 = ((FILE_STATUS_BG + 1) << 16) + 1;
114 menu->bgArchive2 = ((FILE_STATUS_BG + 1) << 16) + 2;
115 menu->bgFile2 = FILE_STATUS_BG;
116 } else {
117 menu->bgArchive = (FILE_STATUS_BG + 3) << 16;
118 menu->bgFile = FILE_STATUS_BG + 3;
119 menu->bgArchive1 = ((FILE_STATUS_BG + 3) << 16) + 1;
120 menu->bgArchive2 = ((FILE_STATUS_BG + 3) << 16) + 2;
121 menu->bgFile2 = FILE_STATUS_BG + 2;
122 }
125 return menu;
126}
127
128/* Loads the menu's textures and requests its strings: the menu's, the items',
129 the Digimon's and the skills' names and descriptions */
144
145/* Whether the menu's strings are still loading */
148 return 1;
149 }
151 return 1;
152 }
154 return 1;
155 }
157 return 1;
158 }
160 return 1;
161 }
163 return 1;
164 }
166}
167
170
171/* Starts moving a value from FROM to TO in FRAMES frames, playing SOUND_MENU_OPEN;
172 nothing when they are the same */
173void STSTATUS_startLerp(MenuLerp *lerp, s32 from, s32 to, s32 frames) {
174 if (from != to) {
176 lerp->duration = frames;
177 lerp->fixed = from << 8;
178 lerp->value = from;
179 lerp->target = to;
180 lerp->active = 1;
181 lerp->step = ((to - from) << 8) / lerp->duration;
182 }
183}
184
#define NULL
Definition common.h:17
signed int s32
Definition common.h:11
#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
FieldMenu * createFieldMenu(s32 layerId, s32 cursor)
Opens the field menu on a layer with the cursor on an option.
Definition field_menu.c:426
STSTATUS.PRO: the field menu's screens.
#define FILE_STATUS_SPRITES
The menu's sprite sheet; the next file is its texture archive.
Definition field_menu.h:20
#define FILE_STATUS_BG
Definition field_menu.h:21
#define TEXT_ITEM_INFO
ITMINF.
Definition file.h:214
#define TEXT_SKILL_NAMES
SKLNAM.
Definition file.h:223
#define TEXT_FILE(file)
Definition file.h:190
#define TEXT_STATUS
STATUS: the field menu's and STSTATUS's.
Definition file.h:225
#define TEXT_DIGIMON_INFO
DIGINF.
Definition file.h:210
#define TEXT_DIGIMON_NAMES
DIGNAM.
Definition file.h:211
#define TEXT_ITEM_NAMES
ITMNAM.
Definition file.h:215
#define TEXT_SKILL_INFO
SKLINF.
Definition file.h:222
FileCache FILE_CACHE
The file cache.
Definition file_cache.c:7
long open(char *name, unsigned long mode)
The kernel's file functions (libapi.h); the sim: device is the PC's.
struct FieldMenuChoice FIELD_MENU_CHOICE
menu/field_menu.c's
Definition game_bss.c:21
#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
StatusAreaFuncs STSTATUS_areaFuncs
Where the game is.
Definition helpers.c:410
Task *(* STSTATUS_screens[2][7])(FieldMenuScreen *menu, s32 extra)
The field menu's screens, by FIELD_MENU_CHOICE.
Definition helpers.c:215
StatusData STSTATUS_data
Definition helpers.c:356
Task * STSTATUS_createItemScreen(FieldMenuScreen *menu, s32 extra)
Creates the field menu's first screen (task), the items.
void STSTATUS_runScreens(FieldMenuScreen *menu, FieldMenuScreenChildren *children)
Opens the screen of FIELD_MENU_CHOICE (the item screen when it has none) and, once it closes,...
Definition menu.c:16
FieldMenuScreen * STSTATUS_createMenu(void)
Creates the mode's main task and requests its background's files, the second half of the game's in th...
Definition menu.c:105
void STSTATUS_drawBackground(FieldMenuScreen *menu)
Draws the scrolling background, sprite 0x1D at (bgScroll, bgScroll): it moves one pixel down and righ...
Definition menu.c:41
void STSTATUS_updateMenu(FieldMenuScreen *menu, FieldMenuScreenChildren *children)
The mode's main task: loads the files and the background's textures, then runs the screens (STSTATUS_...
Definition menu.c:60
void STSTATUS_startLerp(MenuLerp *lerp, s32 from, s32 to, s32 frames)
Starts moving a value from FROM to TO in FRAMES frames, playing SOUND_MENU_OPEN; nothing when they ar...
Definition menu.c:173
void STSTATUS_loadFiles(void)
Loads the menu's textures and requests its strings: the menu's, the items', the Digimon's and the ski...
Definition menu.c:130
s32 STSTATUS_filesLoading(void)
Whether the menu's strings are still loading.
Definition menu.c:146
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 SOUND_MENU_OPEN
SYSTEM03.
Definition sound.h:41
void initSpriteDrawer(SpriteDrawer *obj)
Clears a sprite drawer to neutral (no scale, gray tint, follows the scroll), gives it its methods and...
s32 extra
the list had the extra option: STSTATUS_screens' row
Definition menu.h:132
The mode's main task (STSTATUS_createMenu)
Definition field_menu.h:25
void(* nextState)(struct FieldMenuScreen *task)
Definition field_menu.h:26
void(* setState)(struct FieldMenuScreen *task, s32 state)
Definition field_menu.h:26
s32 gameHalf
STSTATUS_getGameHalf.
Definition field_menu.h:31
s32(* isLoading)(s32 file)
Definition file.h:88
void(* request)(s32 file)
Definition file.h:90
void *(* getEntry)(u32 fileAndIndex)
Definition file.h:96
Moves a value towards a target in fixed point, as the menu overlays' startLerp and updateLerp do.
Definition menu.h:27
s32 active
Definition menu.h:34
s32 target
Definition menu.h:32
s32 value
Definition menu.h:30
s32 fixed
value << 8
Definition menu.h:31
s32 step
Definition menu.h:33
s32 duration
Definition menu.h:28
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
s32(* getGameHalf)(void)
0, 1, or -1 outside of the field
Definition field_menu.h:287
StatusFuncs funcs
Definition field_menu.h:445
s32(* filesLoading)(void)
Definition field_menu.h:274
void(* loadFiles)(void)
Definition field_menu.h:273
Any task, seen through its header.
Definition task.h:62
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