Digimon World 3 decomp
The European version, SLES_039.36
Loading...
Searching...
No Matches
saves.c
Go to the documentation of this file.
1/* The save list: the saves on a memory card, loading and saving them, and the
2 errors */
3
4#include "menus/memory_card.h"
5
6/* Shows the line with the memory card's port number, or hides it */
8 if (show) {
10 win->windows[4]->setNumber(win->windows[4], 1, saves->port + 1);
11 } else {
12 win->windows[4]->setVisible(win->windows[4], 0);
13 }
14}
15
16/* Shows the error of the last card operation (saves->result, made an index of
17 STGMCARD_errorTexts), hiding the choices, the cursor and the panel */
19 saves->substate = 100;
20 saves->choice = 0;
21 saves->result--;
22 if (win->windows[1] != NULL) {
23 win->windows[1]->setVisible(win->windows[1], 0);
24 }
25 if (win->windows[2] != NULL) {
26 win->windows[2]->setVisible(win->windows[2], 0);
27 }
28 if (win->windows[3] != NULL) {
29 win->windows[3]->setVisible(win->windows[3], 0);
30 }
31 if (win->cursor != NULL) {
32 win->cursor->setVisible(win->cursor, 0);
33 }
34 if (win->panel != NULL) {
35 win->panel->reset(win->panel);
36 }
37}
38
39/* Hides the message and panel and closes the slot picker, then shows the error in
40 saves->result */
42 win->windows[1]->setVisible(win->windows[1], 0);
43 win->panel->reset(win->panel);
44 saves->substate = 90;
45 saves->step = 100;
46 win->menu->substate = 0;
47}
48
49/* Fills the details window with the selected save again (saves->refresh) */
51 MemCardSavesWindows *win = saves->children;
52
53 win->info->refresh(win->info);
54}
55
56/* Hides the save list's windows and ends it (TASK_DONE), which makes the main task fade
57 out and leave the screen (saves->hide) */
59 MemCardSavesWindows *win = saves->children;
60
61 if (win->windows[0] != NULL) {
62 win->windows[0]->setVisible(win->windows[0], 0);
63 }
64 if (win->windows[4] != NULL) {
65 win->windows[4]->setVisible(win->windows[4], 0);
66 }
67 if (win->windows[1] != NULL) {
68 win->windows[1]->setVisible(win->windows[1], 0);
69 }
70 if (win->windows[2] != NULL) {
71 win->windows[2]->setVisible(win->windows[2], 0);
72 }
73 if (win->windows[3] != NULL) {
74 win->windows[3]->setVisible(win->windows[3], 0);
75 }
76 if (win->cursor != NULL) {
77 win->cursor->setVisible(win->cursor, 0);
78 }
79 if (win->panel != NULL) {
80 win->panel->reset(win->panel);
81 }
82 saves->setState(saves, TASK_DONE);
83}
84
85/* Starts the save list: titles it for saving or loading and creates the details
86 window */
87static inline void STGMCARD_openSaves(MemCardSaves *saves, MemCardSavesWindows *win) {
88 win->title->setDepth(win->title, 1);
89 if (saves->screen->loading == 0) {
91 } else {
93 }
94 if (win->info == NULL) {
95 win->info = STGMCARD_createInfo(saves);
96 }
97 saves->substate++;
98}
99
100/* Slides the title in, then asks which memory card port to use */
102 if (STGMCARD_funcs.updateLerp(&saves->slide[1]) != 0) {
103 win->windows[0]->setVisible(win->windows[0], 0);
104 if (saves->screen->loading == 0) {
106 } else {
108 }
109 win->windows[1]->setDepth(win->windows[1], 1);
112 win->windows[2]->setNumber(win->windows[2], 1, 1);
114 win->windows[3]->setNumber(win->windows[3], 1, 2);
115 win->cursor->setVisible(win->cursor, 1);
116 win->cursor->setPos(win->cursor, 0xC2, saves->port * 14 + 0xBD);
117 saves->choosing = 1;
118 saves->substate++;
119 }
120 win->title->setPos(win->title, saves->origin[0] + (s16)(saves->slide[0].value + 200), saves->origin[1] + (s16)(saves->slide[1].value + 9));
121}
122
123/* Moves the port cursor: cross starts checking the card in that port, triangle
124 leaves the screen */
125static inline void STGMCARD_pickPort(MemCardSaves *saves, MemCardSavesWindows *win) {
126 s32 prev;
127
128 prev = saves->port;
130 saves->port = 0;
131 } else if (PAD_PRESSED(PAD_DOWN) || PAD_REPEATED(PAD_DOWN)) {
132 saves->port = 1;
133 }
134 if (prev != saves->port) {
135 win->cursor->setPos(win->cursor, 0xC2, saves->port * 14 + 0xBD);
137 }
138 if (PAD_PRESSED(PAD_CROSS)) {
140 STGMCARD_showPort(saves, win, 1);
141 win->windows[1]->setVisible(win->windows[1], 0);
142 win->windows[2]->setVisible(win->windows[2], 0);
143 win->windows[3]->setVisible(win->windows[3], 0);
144 win->cursor->setVisible(win->cursor, 0);
145 if (win->panel == NULL) {
146 win->panel = STGMCARD_createPanel(0xCD, 0xC1, 0x62, 0xA);
147 }
148 win->panel->setTopColor(win->panel, 0x7F, 0x32, 0xF2);
149 win->panel->setBottomColor(win->panel, 0xD1, 0x2F, 0xDE);
150 saves->substate = 10;
152 saves->choosing = 0;
153 } else if (PAD_PRESSED(PAD_TRIANGLE)) {
155 saves->hide(saves);
156 saves->choosing = 0;
157 saves->screen->step = 1;
158 }
159}
160
161/* Waits for the card in the port to answer: a ready card (1 or 4) has its files
162 listed (11), any other answer ends the check (12) */
163static inline void STGMCARD_acceptCard(MemCardSaves *saves, MemCardSavesWindows *win) {
164 s32 status;
165
166 if (win->panel->substate == 0) {
167 win->panel->start(win->panel, 1, 0x4C);
168 }
169 status = saves->result = MEMCARD_SYSTEM.funcs.accept(saves->port);
170 if (status != 0) {
171 if (status == 1 || status - 1 == 3) {
172 saves->substate++;
173 } else {
174 win->panel->start(win->panel, 2, 0x14);
175 saves->substate += 2;
176 }
177 }
178}
179
180/* Lists the card's files, then ends the check (12) */
181static inline void STGMCARD_listCard(MemCardSaves *saves, MemCardSavesWindows *win) {
182 s32 status;
183
184 status = saves->result = MEMCARD_SYSTEM.funcs.list(saves->port);
185 if (status != 0) {
186 win->panel->start(win->panel, 2, 0x14);
187 saves->substate++;
188 }
189}
190
191/* Once the panel is done, goes on to read the info section (20) or shows the
192 card's error */
194 if (win->panel->done != 0) {
195 if (saves->result == 1) {
196 saves->substate = 20;
197 } else {
198 STGMCARD_showError(saves, win);
199 }
200 }
201}
202
203/* Once the panel is done, shows the reading message and restarts the panel */
205 if (win->panel->done != 0) {
207 STGMCARD_showPort(saves, win, 1);
208 win->panel->reset(win->panel);
209 win->panel->start(win->panel, 1, 0x4C);
210 saves->substate++;
211 }
212}
213
214/* Reads the save file's info section (the slots' summaries) */
215static inline void STGMCARD_readInfo(MemCardSaves *saves, MemCardSavesWindows *win) {
216 s32 status;
217
218 status = saves->result = MEMCARD_SYSTEM.funcs.read(saves->port, STGMCARD_funcs.infoBuf, sizeof(MemCardFile), SAVE_SECTION_INFO);
219 if (status != 0) {
220 win->panel->start(win->panel, 2, 0x14);
221 saves->substate++;
222 }
223}
224
225/* Once the panel is done, checks the info section read: one without the magic
226 starts empty, a wrong checksum is error 9, else it is kept with its last slot;
227 then opens the slot picker (30) */
228static inline void STGMCARD_checkInfo(MemCardSaves *saves, MemCardSavesWindows *win) {
229 if (win->panel->done != 0) {
230 if (saves->result == 1) {
235 } else if (MEMCARD_SYSTEM.funcs.computeChecksum(&STGMCARD_funcs.infoBuf->magic, sizeof(MemCardFile) - 4) & ~STGMCARD_funcs.infoBuf->checksum) {
236 saves->result = 9;
237 STGMCARD_showError(saves, win);
238 return;
239 } else {
240 saves->file = *STGMCARD_funcs.infoBuf;
242 }
243 win->windows[0]->setVisible(win->windows[0], 0);
244 win->windows[4]->setVisible(win->windows[4], 0);
245 win->panel->reset(win->panel);
246 saves->substate = 30;
247 } else {
248 STGMCARD_showError(saves, win);
249 }
250 }
251}
252
253/* Hides the messages and shows the slot picker and the details window */
254static inline void STGMCARD_openSlots(MemCardSaves *saves, MemCardSavesWindows *win) {
255 win->windows[0]->setVisible(win->windows[0], 0);
256 win->windows[4]->setVisible(win->windows[4], 0);
257 if (win->menu->slid != 5) {
258 win->menu->reset(win->menu);
259 }
260 if (win->info != NULL) {
261 win->info->show(win->info);
262 }
263 saves->substate++;
264}
265
266/* Slides the picker's header and slots in, then starts the pick at the last
267 slot used */
268static inline void STGMCARD_showSlots(MemCardSaves *saves, MemCardSavesWindows *win) {
269 if (win->menu->substate == 0) {
270 if (win->menu->slid == 0) {
271 win->menu->slideInHeader(win->menu);
272 } else if (win->menu->slid == 1) {
273 win->menu->slideInSlots(win->menu);
274 } else if (win->menu->slid == 2) {
276 saves->substate++;
277 }
278 }
279}
280
281/* Once the picker waits, asks for the slot to save to or load from and shows its
282 details */
283static inline void STGMCARD_promptSlot(MemCardSaves *saves, MemCardSavesWindows *win) {
284 if (win->menu->substate == 6) {
285 if (saves->screen->loading == 0) {
287 } else {
289 }
290 win->info->drawing = 1;
291 win->info->shown = 1;
292 win->info->refresh(win->info);
293 saves->nextSubstate(saves);
294 win->menu->substate = 6;
295 }
296}
297
298/* Waits for the slot: cross saves to it (asking first over a used one) or loads
299 it, triangle closes the picker, and a card that fails its check shows its
300 error */
301static inline void STGMCARD_pickSlot(MemCardSaves *saves, MemCardSavesWindows *win) {
302 s32 status;
303
304 if (win->menu->substate == 6) {
305 if (PAD_PRESSED(PAD_CROSS)) {
307 saves->substate = 400;
308 win->menu->substate = 0;
309 if (saves->screen->loading == 0) {
311 saves->step = 40;
312 saves->choice = 0;
316 win->cursor->setVisible(win->cursor, 1);
317 saves->choosing = 1;
318 win->cursor->setPos(win->cursor, 0xC2, saves->choice * 14 + 0xBD);
319 } else {
320 saves->step = 50;
321 }
322 } else {
323 saves->step = 70;
324 }
325 } else if (PAD_PRESSED(PAD_TRIANGLE)) {
327 win->menu->substate = 0;
328 saves->substate = 90;
329 saves->step = 1;
330 } else {
331 status = MEMCARD_SYSTEM.funcs.check(saves->port);
332 if (status != 0) {
333 if (status != 1) {
334 saves->result = status - 1;
335 STGMCARD_closeMenuForError(saves, win);
336 }
337 }
338 }
339 }
340}
341
342/* Slides the slots and header out, then goes on to saves->step */
343static inline void STGMCARD_closeSlots(MemCardSaves *saves, MemCardSavesWindows *win) {
344 if (win->menu->substate == 0) {
345 switch (win->menu->slid) {
346 case 3:
347 win->menu->slideOutHeader(win->menu);
348 saves->substate = saves->step;
349 saves->step = saves->counter;
350 saves->counter = 0;
351 break;
352 case 2:
353 win->info->hide(win->info);
354 win->menu->slideOutSlots(win->menu);
355 break;
356 }
357 }
358}
359
360/* Slides the slots and header out before leaving the screen (601) */
362 if (win->menu->substate == 0) {
363 if (win->menu->slid == 2) {
364 win->info->hide(win->info);
365 win->menu->slideOutSlots(win->menu);
366 } else if (win->menu->slid == 3) {
367 win->menu->slideOutHeader(win->menu);
368 saves->substate++;
369 }
370 }
371}
372
373/* Loads from the selected slot: an empty one only tells so and goes back to the
374 pick (501), else shows the loading message and starts the panel */
375static inline void STGMCARD_startLoad(MemCardSaves *saves, MemCardSavesWindows *win) {
378 saves->prompting = 1;
379 saves->substate = 501;
380 saves->step = 32;
381 saves->backToPick = 1;
382 } else {
384 win->panel->start(win->panel, 1, MEMCARD_LOAD_FRAMES);
385 saves->substate++;
386 }
387}
388
389/* Reads the selected slot's save into the game: a wrong checksum, or another
390 save version while loading, is error 8, and a failed read shows its error */
391static inline void STGMCARD_loadSave(MemCardSaves *saves, MemCardSavesWindows *win) {
392 s32 status;
393
394 status = saves->result = MEMCARD_SYSTEM.funcs.read(saves->port, STGMCARD_funcs.dataBuf, sizeof(GameSave), STGMCARD_funcs.slot + SAVE_SECTION_DATA);
395 if (status != 0) {
396 if (status == 1) {
397 if (MEMCARD_SYSTEM.funcs.computeChecksum(&STGMCARD_funcs.dataBuf->bytes[SAVE_CHECKED], sizeof(GameSave) - SAVE_CHECKED) &
399 saves->result = 8;
400 STGMCARD_closeMenuForError(saves, win);
401 } else if (STGMCARD_funcs.dataBuf->game.version != MEMCARD_SAVE_VERSION && saves->screen->loading != 0) {
402 saves->result = 8;
403 STGMCARD_closeMenuForError(saves, win);
404 } else {
406 win->panel->start(win->panel, 2, 0x14);
407 saves->substate = 500;
408 win->menu->substate = 0;
409 saves->backToPick = 0;
410 }
411 } else {
412 saves->result = status - 1;
413 STGMCARD_closeMenuForError(saves, win);
414 }
415 }
416}
417
418/* Hides the two choices and their cursor */
420 win->windows[2]->setVisible(win->windows[2], 0);
421 win->windows[3]->setVisible(win->windows[3], 0);
422 win->cursor->setVisible(win->cursor, 0);
423}
424
425/* Moves the cursor between the two choices (saves->choice) */
427 s32 prev;
428
429 prev = saves->choice;
431 saves->choice = 0;
432 } else if (PAD_PRESSED(PAD_DOWN) || PAD_REPEATED(PAD_DOWN)) {
433 saves->choice = 1;
434 }
435 if (prev != saves->choice) {
436 win->cursor->setPos(win->cursor, 0xC2, saves->choice * 14 + 0xBD);
438 }
439}
440
441/* Yes to saving over the slot saves the game there (50), no goes back to the pick */
443 if (saves->choice == 0) {
444 saves->step = 50;
445 } else {
446 saves->step = 32;
447 win->menu->substate = 6;
448 }
449}
450
451/* Without cross on the question to save over the slot: triangle goes back to the
452 pick, and a card that fails its check shows its error */
454 s32 result;
455
459 saves->substate = 400;
460 saves->choosing = 0;
461 saves->step = 32;
462 win->menu->substate = 6;
463 } else {
464 result = MEMCARD_SYSTEM.funcs.check(saves->port);
465 if (result != 0) {
466 if (result != 1) {
468 saves->choosing = 0;
469 saves->result = result - 1;
470 STGMCARD_closeMenuForError(saves, win);
471 }
472 }
473 }
474}
475
476/* Shows the saving message and starts the panel */
477static inline void STGMCARD_startSave(MemCardSaves *saves, MemCardSavesWindows *win) {
479 win->panel->start(win->panel, 1, MEMCARD_SAVE_FRAMES);
480 saves->substate++;
481}
482
483/* Copies the game to the save buffer with its checksum, fills the slot's summary
484 (name, place, money, play time and the party's levels and partners), and
485 makes it the last slot */
486static inline void STGMCARD_fillSave(MemCardSaves *saves) {
487 MemCardSave *save;
488 s32 i;
489 s32 member;
490
494 MEMCARD_SYSTEM.funcs.computeChecksum(&STGMCARD_funcs.dataBuf->bytes[SAVE_CHECKED], sizeof(GameSave) - SAVE_CHECKED);
497 save->area = saves->screen->area;
498 save->place = saves->screen->place;
501 for (i = 0; i < 3; i++) {
502 member = GAME.funcs.getPartyMember(i);
505 }
507 STGMCARD_funcs.infoBuf->checksum = MEMCARD_SYSTEM.funcs.computeChecksum(&STGMCARD_funcs.infoBuf->magic, sizeof(MemCardFile) - 4);
508 saves->substate++;
509}
510
511/* Writes the info section with the slot's new summary */
512static inline void STGMCARD_writeInfo(MemCardSaves *saves, MemCardSavesWindows *win) {
513 s32 status;
514
515 status = saves->result = MEMCARD_SYSTEM.funcs.write(saves->port, STGMCARD_funcs.infoBuf, sizeof(MemCardFile), SAVE_SECTION_INFO);
516 if (status != 0) {
517 if (status == 1) {
518 saves->substate++;
519 } else {
520 saves->result = status - 1;
521 STGMCARD_closeMenuForError(saves, win);
522 }
523 }
524}
525
526/* Saves the game to the selected slot's section, then ends the panel (500) */
527static inline void STGMCARD_writeSave(MemCardSaves *saves, MemCardSavesWindows *win) {
528 s32 status;
529
530 status = saves->result = MEMCARD_SYSTEM.funcs.write(saves->port, STGMCARD_funcs.dataBuf, sizeof(GameSave), STGMCARD_funcs.slot + SAVE_SECTION_DATA);
531 if (status != 0) {
532 if (status == 1) {
533 win->panel->start(win->panel, 2, 0x14);
534 saves->substate = 500;
535 } else {
536 saves->result = status - 1;
537 STGMCARD_closeMenuForError(saves, win);
538 }
539 }
540}
541
542/* Once the panel is done, tells that the game was saved (501) or loaded (502) */
543static inline void STGMCARD_showDone(MemCardSaves *saves, MemCardSavesWindows *win) {
544 if (win->panel->done != 0) {
545 if (saves->screen->loading == 0) {
546 saves->file = *STGMCARD_funcs.infoBuf;
547 saves->refresh(saves);
549 saves->step = 32;
550 } else {
552 saves->step = 400;
553 saves->substate++;
554 }
555 saves->substate++;
556 win->panel->reset(win->panel);
557 saves->prompting = 1;
558 }
559}
560
561/* Waits for cross on the message (saved, or an empty slot to load): goes back
562 to the pick, or after loading on to leaving (600); a card that fails its
563 check shows error 1 */
565 s32 check;
566
567 if (PAD_PRESSED(PAD_CROSS)) {
569 saves->prompting = 0;
570 saves->substate = saves->step;
571 if (saves->screen->loading == 0) {
572 saves->setStep(saves, 0);
573 win->menu->substate = 6;
574 } else {
575 win->windows[1]->setVisible(win->windows[1], 0);
576 saves->step = 600;
577 if (saves->backToPick != 0) {
578 win->menu->substate = 6;
579 } else {
580 win->menu->substate = 0;
581 }
582 }
583 } else {
584 check = MEMCARD_SYSTEM.funcs.check(saves->port);
585 if (check != 0) {
586 if (check != 1) {
587 saves->prompting = 0;
588 saves->result = 1;
589 STGMCARD_closeMenuForError(saves, win);
590 }
591 }
592 }
593}
594
595/* Waits for cross on the loaded message, then waits for the card (400) and leaves
596 the screen (600) */
598 if (PAD_PRESSED(PAD_CROSS)) {
600 saves->prompting = 0;
601 saves->substate = saves->step;
602 win->windows[1]->setVisible(win->windows[1], 0);
603 saves->step = 600;
604 win->menu->substate = 0;
605 }
606}
607
608/* Shows the error STGMCARD_errorTexts[result] with the port: when saving, an
609 unformatted card (4) asks to format it and a card without the save file (5)
610 asks to create it, unless the card lacks the room for it (7); other errors
611 wait for cross */
612static inline void STGMCARD_askError(MemCardSaves *saves, MemCardSavesWindows *win) {
613 s32 blocks;
614 s32 j;
615 s32 ask;
616
618 STGMCARD_showPort(saves, win, 1);
619 if (saves->screen->loading == 0) {
620 if (saves->result == CARD_ERR_UNFORMATTED) {
621 saves->choice = 1;
622 ask = 1;
623 } else if (saves->result == CARD_ERR_NO_FILE) {
624 if (MEMCARD.fileCount != 0) {
625 for (j = 0, blocks = 0; j < MEMCARD.fileCount; j++) {
626 blocks += MEMCARD.files[j].size / 0x2000;
627 }
628 if (blocks + 4 >= 16) {
629 win->windows[0]->setVisible(win->windows[0], 0);
630 saves->result = CARD_ERR_FULL;
631 saves->substate = 100;
632 return;
633 }
634 }
635 ask = 1;
636 } else {
637 saves->prompting = 1;
638 ask = 0;
639 if (saves->result == CARD_ERR_FULL) {
640 win->windows[0]->setNumber(win->windows[0], 1, 4);
641 }
642 }
643 if (ask) {
644 if (saves->result == CARD_ERR_UNFORMATTED) {
646 } else {
648 }
651 win->cursor->setVisible(win->cursor, 1);
652 saves->choosing = 1;
653 win->cursor->setPos(win->cursor, 0xC2, saves->choice * 14 + 0xBD);
654 }
655 } else {
656 saves->prompting = 1;
657 }
658 saves->substate++;
659}
660
661/* Waits for the answer to the error: yes formats the card (110) or creates the
662 save file (120), no or triangle goes back to the port pick, and a card that
663 fails its check shows its error; other errors wait for cross */
664static inline void STGMCARD_answerError(MemCardSaves *saves, MemCardSavesWindows *win) {
665 s32 prev;
666 s32 status;
667
668 if (saves->screen->loading == 0 && (saves->result == CARD_ERR_UNFORMATTED || saves->result == CARD_ERR_NO_FILE)) {
669 prev = saves->choice;
671 saves->choice = 0;
672 } else if (PAD_PRESSED(PAD_DOWN) || PAD_REPEATED(PAD_DOWN)) {
673 saves->choice = 1;
674 }
675 if (prev != saves->choice) {
677 win->cursor->setPos(win->cursor, 0xC2, saves->choice * 14 + 0xBD);
678 }
679 if (PAD_PRESSED(PAD_CROSS)) {
681 win->windows[0]->setVisible(win->windows[0], 0);
682 win->windows[4]->setVisible(win->windows[4], 0);
683 win->windows[1]->setVisible(win->windows[1], 0);
684 win->windows[2]->setVisible(win->windows[2], 0);
685 win->windows[3]->setVisible(win->windows[3], 0);
686 win->cursor->setVisible(win->cursor, 0);
687 saves->substate = 400;
688 saves->choosing = 0;
689 if (saves->result == CARD_ERR_UNFORMATTED) {
690 if (saves->choice == 0) {
691 saves->step = 110;
693 STGMCARD_showPort(saves, win, 1);
694 win->panel->start(win->panel, 1, 0x90);
695 } else {
696 saves->step = 1;
697 win->panel->reset(win->panel);
698 }
699 } else if (saves->choice == 0) {
700 saves->step = 120;
702 STGMCARD_showPort(saves, win, 1);
703 win->panel->start(win->panel, 1, 0x90);
704 } else {
705 saves->step = 1;
706 win->panel->reset(win->panel);
707 }
708 } else if (PAD_PRESSED(PAD_TRIANGLE)) {
710 win->windows[0]->setVisible(win->windows[0], 0);
711 win->windows[4]->setVisible(win->windows[4], 0);
712 win->windows[1]->setVisible(win->windows[1], 0);
713 win->windows[2]->setVisible(win->windows[2], 0);
714 win->windows[3]->setVisible(win->windows[3], 0);
715 win->cursor->setVisible(win->cursor, 0);
716 saves->substate = 400;
717 saves->choosing = 0;
718 saves->step = 1;
719 win->panel->reset(win->panel);
720 }
721 status = MEMCARD_SYSTEM.funcs.check(saves->port);
722 if (status != 0) {
723 if (status != 1) {
724 saves->result = status;
725 saves->choosing = 0;
726 STGMCARD_showError(saves, win);
727 }
728 }
729 } else if (PAD_PRESSED(PAD_CROSS)) {
731 saves->substate = 400;
732 saves->prompting = 0;
733 saves->step = 1;
734 }
735}
736
737/* Shows the error of a card that failed its check, then goes on to saves->step */
738static inline void STGMCARD_endWaitCard(MemCardSaves *saves, MemCardSavesWindows *win) {
739 if (saves->result != 1) {
740 STGMCARD_showError(saves, win);
741 }
742 saves->substate = saves->step;
743 saves->step = saves->counter;
744 saves->counter = 0;
745}
746
747/* Formats the card, then ends the panel (111) */
748static inline void STGMCARD_formatCard(MemCardSaves *saves, MemCardSavesWindows *win) {
749 s32 status;
750
751 status = saves->result = MEMCARD_SYSTEM.funcs.format(saves->port);
752 if (status != 0) {
753 if (status == 1) {
754 win->panel->start(win->panel, 2, 0x14);
755 saves->substate++;
756 } else {
757 STGMCARD_showError(saves, win);
758 }
759 }
760}
761
762/* Once the panel is done, asks to create the save file (error 5) */
763static inline void STGMCARD_endFormat(MemCardSaves *saves, MemCardSavesWindows *win) {
764 if (win->panel->done != 0) {
765 STGMCARD_showError(saves, win);
766 saves->result = 5;
767 }
768}
769
770/* Creates the save file on the card */
771static inline void STGMCARD_createFile(MemCardSaves *saves, MemCardSavesWindows *win) {
772 s32 status;
773
774 status = saves->result = MEMCARD_SYSTEM.funcs.create(saves->port);
775 if (status != 0) {
776 if (status == 1) {
777 saves->substate++;
778 } else {
779 STGMCARD_showError(saves, win);
780 }
781 }
782}
783
784/* Writes the new save file's header; a wrong icon count is error 3 */
785static inline void STGMCARD_writeHeader(MemCardSaves *saves, MemCardSavesWindows *win) {
786 s32 status;
787
788 status = saves->result = MEMCARD_SYSTEM.funcs.write(saves->port, &MEMCARD.header, sizeof(CardHeader), SAVE_SECTION_HEADER);
789 if (status != 0) {
790 if (status == 1) {
792 saves->result = 3;
793 STGMCARD_showError(saves, win);
794 } else {
795 MEMCARD.iconIndex = 0;
796 saves->substate++;
797 }
798 } else {
799 saves->result = 10;
800 STGMCARD_showError(saves, win);
801 }
802 }
803}
804
805/* Writes the new save file's icon frames, one per call, then makes its empty
806 info section */
807static inline void STGMCARD_writeIcons(MemCardSaves *saves, MemCardSavesWindows *win) {
808 s32 status;
809
810 /* each icon frame is the sector after the header's or the frame before's,
811 at the offset in bits 8 and up */
813 if (status != 0) {
814 if (status == 1) {
820 STGMCARD_funcs.infoBuf->checksum = MEMCARD_SYSTEM.funcs.computeChecksum(&STGMCARD_funcs.infoBuf->magic, sizeof(MemCardFile) - 4);
821 saves->file = *STGMCARD_funcs.infoBuf;
823 saves->substate++;
824 }
825 } else {
826 saves->result = 11;
827 STGMCARD_showError(saves, win);
828 }
829 }
830}
831
832/* Writes the new save file's info section, then ends the panel (125) */
834 s32 status;
835
836 status = saves->result = MEMCARD_SYSTEM.funcs.write(saves->port, STGMCARD_funcs.infoBuf, sizeof(MemCardFile), SAVE_SECTION_INFO);
837 if (status != 0) {
838 win->panel->start(win->panel, 2, 0x14);
839 saves->substate++;
840 }
841}
842
843/* Once the panel is done, opens the slot picker (30) or shows the error */
844static inline void STGMCARD_endCreate(MemCardSaves *saves, MemCardSavesWindows *win) {
845 if (win->panel->done != 0) {
846 win->panel->reset(win->panel);
847 if (saves->result == 1) {
848 saves->substate = 30;
849 } else {
850 STGMCARD_showError(saves, win);
851 }
852 }
853}
854
855/*
856 * The save list's states (saves->substate): picks the port, reads the card's
857 * info section, lets the menu pick a slot, then loads or saves it. A failed
858 * operation leaves its error in saves->result and goes to 100, which shows
859 * STGMCARD_errorTexts[result] and can format the card (110) or create the save
860 * file (120). 400 waits for the card and goes on to step.
861 * Match depends on status, which 40 and 400 share.
862 */
864 s32 status;
865
866 switch (saves->substate) {
867 case 0:
868 default:
869 STGMCARD_openSaves(saves, win);
870 /* fallthrough */
871 case 1:
872 STGMCARD_slideInTitle(saves, win);
873 break;
874 case 2:
875 STGMCARD_pickPort(saves, win);
876 break;
877 case 10:
878 STGMCARD_acceptCard(saves, win);
879 break;
880 case 11:
881 STGMCARD_listCard(saves, win);
882 break;
883 case 12:
884 STGMCARD_endCardCheck(saves, win);
885 break;
886 case 20:
887 STGMCARD_startInfoRead(saves, win);
888 /* fallthrough */
889 case 21:
890 STGMCARD_readInfo(saves, win);
891 break;
892 case 22:
893 STGMCARD_checkInfo(saves, win);
894 break;
895 case 30:
896 STGMCARD_openSlots(saves, win);
897 break;
898 case 31:
899 STGMCARD_showSlots(saves, win);
900 break;
901 case 32:
902 STGMCARD_promptSlot(saves, win);
903 break;
904 case 33:
905 STGMCARD_pickSlot(saves, win);
906 break;
907 case 90:
908 STGMCARD_closeSlots(saves, win);
909 break;
910 case 600:
911 STGMCARD_closeSlotsToLeave(saves, win);
912 break;
913 case 601:
914 saves->hide(saves);
915 break;
916 case 70:
917 STGMCARD_startLoad(saves, win);
918 break;
919 case 71:
920 STGMCARD_loadSave(saves, win);
921 break;
922 case 40:
923 STGMCARD_moveChoiceCursor(saves, win);
924 if (PAD_PRESSED(PAD_CROSS)) {
927 /* match depends on the 400 going through status */
928 status = 400;
929 saves->choosing = 0;
930 saves->substate = status;
931 STGMCARD_answerOverwrite(saves, win);
932 } else {
933 STGMCARD_cancelOverwrite(saves, win);
934 }
935 break;
936 case 50:
937 STGMCARD_startSave(saves, win);
938 break;
939 case 51:
940 STGMCARD_fillSave(saves);
941 break;
942 case 52:
943 STGMCARD_writeInfo(saves, win);
944 break;
945 case 53:
946 STGMCARD_writeSave(saves, win);
947 break;
948 case 500:
949 STGMCARD_showDone(saves, win);
950 break;
951 case 501:
952 STGMCARD_confirmMessage(saves, win);
953 break;
954 case 502:
955 STGMCARD_waitLoadedMessage(saves, win);
956 break;
957 case 100:
958 STGMCARD_askError(saves, win);
959 break;
960 case 101:
961 STGMCARD_answerError(saves, win);
962 break;
963 case 400:
964 status = saves->result = MEMCARD_SYSTEM.funcs.check(saves->port);
965 if (status != 0) {
966 saves->substate++;
967 }
968 break;
969 case 401:
970 STGMCARD_endWaitCard(saves, win);
971 break;
972 case 110:
973 STGMCARD_formatCard(saves, win);
974 break;
975 case 111:
976 STGMCARD_endFormat(saves, win);
977 break;
978 case 120:
979 saves->substate = 121;
980 break;
981 case 121:
982 STGMCARD_createFile(saves, win);
983 break;
984 case 122:
985 STGMCARD_writeHeader(saves, win);
986 break;
987 case 123:
988 STGMCARD_writeIcons(saves, win);
989 break;
990 case 124:
991 STGMCARD_writeNewInfo(saves, win);
992 break;
993 case 125:
994 STGMCARD_endCreate(saves, win);
995 break;
996 }
997}
998
999/* Draws the save list's sprites: the blinking cross button while a message
1000 waits for it, the list's frame and the box of the cursor's two choices */
1002 SpriteDrawer sprite;
1003
1004 initSpriteDrawer(&sprite);
1005 sprite.setLayerId(saves->layer, 2);
1006 sprite.setTexture(0x140, 0);
1007 if (saves->prompting != 0) {
1008 if ((GFX.funcs.getTime() - saves->blinkTime) / 3 != 0) {
1009 saves->blinkTime = GFX.funcs.getTime();
1010 saves->blinkFrame++;
1011 if (saves->blinkFrame >= 5) {
1012 saves->blinkFrame = 0;
1013 }
1014 }
1015 sprite.setClutRow(saves->blinkFrame);
1016 sprite.draw(FILE_CACHE.getEntry(FILE_MENU_SPRITES << 16), 10, 294, 208);
1017 }
1018 sprite.setTexture(0x280, 0);
1019 sprite.setClutRow(0);
1020 sprite.draw(FILE_CACHE.getEntry(FILE_GMCARD_SHEET << 16), 33, saves->origin[0] + saves->slide[0].value, saves->origin[1] + saves->slide[1].value);
1021 if (saves->choosing != 0) {
1022 sprite.setLayerId(saves->layer, 1);
1023 sprite.draw(FILE_CACHE.getEntry(FILE_GMCARD_SHEET << 16), 29, 188, 185);
1024 }
1025}
1026
1027/* The save list's task: creates its windows, then runs it */
1029 switch (saves->state) {
1030 case TASK_INIT:
1031 default:
1032 saves->nextState(saves);
1033 saves->origin[0] = 5;
1034 saves->origin[1] = 89;
1035 STGMCARD_funcs.startLerp(&saves->slide[1], 151, 0, 10);
1036 win->title = createTextWindow(saves->layer, 1, saves->origin[0] + 200, saves->origin[1] + (s16)(saves->slide[1].value + 9));
1037 win->windows[4] = createTextWindow(saves->layer, 1, saves->origin[0] + 15, saves->origin[1] + 24);
1038 win->windows[0] = createTextWindow(saves->layer, 1, saves->origin[0] + 15, saves->origin[1] + 40);
1039 win->windows[0]->setLines(win->windows[0], 5);
1040 win->windows[0]->setDepth(win->windows[0], 1);
1041 win->windows[1] = createTextWindow(saves->layer, 1, saves->origin[0] + 15, saves->origin[1] + 103);
1042 win->windows[1]->setLines(win->windows[1], 2);
1043 win->windows[2] = createTextWindow(saves->layer, 1, 207, 189);
1044 win->windows[3] = createTextWindow(saves->layer, 1, 207, 203);
1045 win->cursor = createCursor(saves->layer, 0, 207, 189);
1046 win->cursor->setVisible(win->cursor, 0);
1047 win->menu = STGMCARD_createMenu(saves);
1048 break;
1049 case TASK_RUN:
1050 STGMCARD_runSaves(saves, win);
1051 STGMCARD_drawSaves(saves);
1052 break;
1053 case TASK_DONE:
1054 switch (saves->substate) {
1055 case 0:
1056 default:
1057 win->title->setVisible(win->title, 0);
1058 saves->substate++;
1059 break;
1060 case 1:
1061 break;
1062 }
1063 STGMCARD_drawSaves(saves);
1064 break;
1065 case TASK_KILL:
1066 break;
1067 }
1068}
1069
1070/* Creates the save list (task) of the main task */
1073
1075 saves->hide = STGMCARD_hideSaves;
1076 saves->screen = screen;
1077 saves->layer = SCREEN_LAYER;
1078 return saves;
1079}
#define NULL
Definition common.h:17
signed int s32
Definition common.h:11
signed short s16
Definition common.h:9
GfxState GFX
GFX: the graphics state and its methods.
Definition display.c:209
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
Cursor * createCursor(s16 layerId, s32 depth, s16 x, s16 y)
A menu cursor on a layer at (x, y)
Definition cursor.c:92
#define TEXT_MEMORY_CARD
MEMCRD.
Definition file.h:217
#define TEXT_FILE(file)
Definition file.h:190
#define FILE_MENU_SPRITES
Files the engine loads by number.
Definition file.h:188
FileCache FILE_CACHE
The file cache.
Definition file_cache.c:7
char * strcpy(char *dst, const char *src)
#define STAT_LEVEL
Indices of a partner's stats (PartnerStats.stats, computeStats, setStat)
Definition game_state.h:279
#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
MemCard MEMCARD
Definition memcard.c:466
@ SAVE_SECTION_INFO
Definition memcard.h:51
@ SAVE_SECTION_HEADER
Definition memcard.h:51
@ SAVE_SECTION_DATA
Definition memcard.h:51
#define CARD_SECTOR_SIZE
The bytes the card reads or writes at once: one sector.
Definition memcard.h:12
#define CARD_ERR_NO_FILE
McErrFileNotExist: "File cannot be found".
Definition memcard.h:35
#define CARD_ERR_FULL
McErrBlockFull: "There are not enough blocks".
Definition memcard.h:37
#define CARD_ERR_UNFORMATTED
Definition memcard.h:34
#define SAVE_MAX_ICONS
The icon frames a save may have.
Definition memcard.h:18
MemCardInfo * STGMCARD_createInfo(MemCardSaves *saves)
Creates the details window (task) of the save list.
Definition info.c:202
STGMCARD.PRO: the memory card screen (MODE_CONTINUE).
#define MEMCARD_LOAD_FRAMES
The durations of the panels shown while loading and saving.
#define FILE_GMCARD_SHEET
Definition memory_card.h:19
#define MEMCARD_SAVE_FRAMES
#define SAVE_CHECKED
#define GAME_SAVE
GAME's saved part, which a load overwrites and a save copies: GameState (game_state....
#define MEMCARD_SYSTEM
#define MEMCARD_SAVE_VERSION
A save's data section is GAME's first GAME_SAVE_SIZE bytes (SaveData).
#define MEMCARD_FILE_MAGIC
Definition memory_card.h:92
MemCardMenu * STGMCARD_createMenu(MemCardSaves *saves)
Creates the slot picker (task) of the save list.
Definition menu.c:187
#define PAD_CROSS
Definition pad.h:31
#define PAD_DOWN
Definition pad.h:24
#define PAD_TRIANGLE
Definition pad.h:32
#define PAD_PRESSED(button)
One button of pad 1: newly pressed, auto-repeated while held, or held.
Definition pad.h:140
#define PAD_UP
Definition pad.h:22
#define PAD_REPEATED(button)
Definition pad.h:141
MemCardPanel * STGMCARD_createPanel(s32 x, s32 y, s32 w, s32 h)
Creates a gradient panel (task) at x, y, w by h, empty until started.
Definition panel.c:147
static void STGMCARD_cancelOverwrite(MemCardSaves *saves, MemCardSavesWindows *win)
Without cross on the question to save over the slot: triangle goes back to the pick,...
Definition saves.c:453
static void STGMCARD_endFormat(MemCardSaves *saves, MemCardSavesWindows *win)
Once the panel is done, asks to create the save file (error 5)
Definition saves.c:763
static void STGMCARD_closeSlots(MemCardSaves *saves, MemCardSavesWindows *win)
Slides the slots and header out, then goes on to saves->step.
Definition saves.c:343
static void STGMCARD_writeNewInfo(MemCardSaves *saves, MemCardSavesWindows *win)
Writes the new save file's info section, then ends the panel (125)
Definition saves.c:833
static void STGMCARD_waitLoadedMessage(MemCardSaves *saves, MemCardSavesWindows *win)
Waits for cross on the loaded message, then waits for the card (400) and leaves the screen (600)
Definition saves.c:597
void STGMCARD_updateSaves(MemCardSaves *saves, MemCardSavesWindows *win)
The save list's task: creates its windows, then runs it.
Definition saves.c:1028
static void STGMCARD_answerError(MemCardSaves *saves, MemCardSavesWindows *win)
Waits for the answer to the error: yes formats the card (110) or creates the save file (120),...
Definition saves.c:664
static void STGMCARD_formatCard(MemCardSaves *saves, MemCardSavesWindows *win)
Formats the card, then ends the panel (111)
Definition saves.c:748
static void STGMCARD_endCardCheck(MemCardSaves *saves, MemCardSavesWindows *win)
Once the panel is done, goes on to read the info section (20) or shows the card's error.
Definition saves.c:193
static void STGMCARD_writeInfo(MemCardSaves *saves, MemCardSavesWindows *win)
Writes the info section with the slot's new summary.
Definition saves.c:512
static void STGMCARD_pickPort(MemCardSaves *saves, MemCardSavesWindows *win)
Moves the port cursor: cross starts checking the card in that port, triangle leaves the screen.
Definition saves.c:125
static void STGMCARD_writeSave(MemCardSaves *saves, MemCardSavesWindows *win)
Saves the game to the selected slot's section, then ends the panel (500)
Definition saves.c:527
MemCardSaves * STGMCARD_createSaves(MemCardScreen *screen)
Creates the save list (task) of the main task.
Definition saves.c:1071
void STGMCARD_closeMenuForError(MemCardSaves *saves, MemCardSavesWindows *win)
Hides the message and panel and closes the slot picker, then shows the error in saves->result.
Definition saves.c:41
static void STGMCARD_endWaitCard(MemCardSaves *saves, MemCardSavesWindows *win)
Shows the error of a card that failed its check, then goes on to saves->step.
Definition saves.c:738
void STGMCARD_hideSaves(MemCardSaves *saves)
Hides the save list's windows and ends it (TASK_DONE), which makes the main task fade out and leave t...
Definition saves.c:58
static void STGMCARD_askError(MemCardSaves *saves, MemCardSavesWindows *win)
Shows the error STGMCARD_errorTexts[result] with the port: when saving, an unformatted card (4) asks ...
Definition saves.c:612
static void STGMCARD_startSave(MemCardSaves *saves, MemCardSavesWindows *win)
Shows the saving message and starts the panel.
Definition saves.c:477
static void STGMCARD_confirmMessage(MemCardSaves *saves, MemCardSavesWindows *win)
Waits for cross on the message (saved, or an empty slot to load): goes back to the pick,...
Definition saves.c:564
void STGMCARD_runSaves(MemCardSaves *saves, MemCardSavesWindows *win)
The save list's states (saves->substate): picks the port, reads the card's info section,...
Definition saves.c:863
static void STGMCARD_acceptCard(MemCardSaves *saves, MemCardSavesWindows *win)
Waits for the card in the port to answer: a ready card (1 or 4) has its files listed (11),...
Definition saves.c:163
static void STGMCARD_closeSlotsToLeave(MemCardSaves *saves, MemCardSavesWindows *win)
Slides the slots and header out before leaving the screen (601)
Definition saves.c:361
static void STGMCARD_createFile(MemCardSaves *saves, MemCardSavesWindows *win)
Creates the save file on the card.
Definition saves.c:771
static void STGMCARD_showSlots(MemCardSaves *saves, MemCardSavesWindows *win)
Slides the picker's header and slots in, then starts the pick at the last slot used.
Definition saves.c:268
static void STGMCARD_endCreate(MemCardSaves *saves, MemCardSavesWindows *win)
Once the panel is done, opens the slot picker (30) or shows the error.
Definition saves.c:844
static void STGMCARD_listCard(MemCardSaves *saves, MemCardSavesWindows *win)
Lists the card's files, then ends the check (12)
Definition saves.c:181
void STGMCARD_showError(MemCardSaves *saves, MemCardSavesWindows *win)
Shows the error of the last card operation (saves->result, made an index of STGMCARD_errorTexts),...
Definition saves.c:18
static void STGMCARD_openSaves(MemCardSaves *saves, MemCardSavesWindows *win)
Starts the save list: titles it for saving or loading and creates the details window.
Definition saves.c:87
static void STGMCARD_startLoad(MemCardSaves *saves, MemCardSavesWindows *win)
Loads from the selected slot: an empty one only tells so and goes back to the pick (501),...
Definition saves.c:375
void STGMCARD_drawSaves(MemCardSaves *saves)
Draws the save list's sprites: the blinking cross button while a message waits for it,...
Definition saves.c:1001
void STGMCARD_showPort(MemCardSaves *saves, MemCardSavesWindows *win, s32 show)
Shows the line with the memory card's port number, or hides it.
Definition saves.c:7
void STGMCARD_refreshSaves(MemCardSaves *saves)
Fills the details window with the selected save again (saves->refresh)
Definition saves.c:50
static void STGMCARD_promptSlot(MemCardSaves *saves, MemCardSavesWindows *win)
Once the picker waits, asks for the slot to save to or load from and shows its details.
Definition saves.c:283
static void STGMCARD_checkInfo(MemCardSaves *saves, MemCardSavesWindows *win)
Once the panel is done, checks the info section read: one without the magic starts empty,...
Definition saves.c:228
static void STGMCARD_loadSave(MemCardSaves *saves, MemCardSavesWindows *win)
Reads the selected slot's save into the game: a wrong checksum, or another save version while loading...
Definition saves.c:391
static void STGMCARD_fillSave(MemCardSaves *saves)
Copies the game to the save buffer with its checksum, fills the slot's summary (name,...
Definition saves.c:486
static void STGMCARD_answerOverwrite(MemCardSaves *saves, MemCardSavesWindows *win)
Yes to saving over the slot saves the game there (50), no goes back to the pick.
Definition saves.c:442
static void STGMCARD_openSlots(MemCardSaves *saves, MemCardSavesWindows *win)
Hides the messages and shows the slot picker and the details window.
Definition saves.c:254
static void STGMCARD_pickSlot(MemCardSaves *saves, MemCardSavesWindows *win)
Waits for the slot: cross saves to it (asking first over a used one) or loads it, triangle closes the...
Definition saves.c:301
static void STGMCARD_slideInTitle(MemCardSaves *saves, MemCardSavesWindows *win)
Slides the title in, then asks which memory card port to use.
Definition saves.c:101
static void STGMCARD_hideChoices(MemCardSavesWindows *win)
Hides the two choices and their cursor.
Definition saves.c:419
static void STGMCARD_readInfo(MemCardSaves *saves, MemCardSavesWindows *win)
Reads the save file's info section (the slots' summaries)
Definition saves.c:215
static void STGMCARD_showDone(MemCardSaves *saves, MemCardSavesWindows *win)
Once the panel is done, tells that the game was saved (501) or loaded (502)
Definition saves.c:543
static void STGMCARD_startInfoRead(MemCardSaves *saves, MemCardSavesWindows *win)
Once the panel is done, shows the reading message and restarts the panel.
Definition saves.c:204
static void STGMCARD_moveChoiceCursor(MemCardSaves *saves, MemCardSavesWindows *win)
Moves the cursor between the two choices (saves->choice)
Definition saves.c:426
static void STGMCARD_writeHeader(MemCardSaves *saves, MemCardSavesWindows *win)
Writes the new save file's header; a wrong icon count is error 3.
Definition saves.c:785
static void STGMCARD_writeIcons(MemCardSaves *saves, MemCardSavesWindows *win)
Writes the new save file's icon frames, one per call, then makes its empty info section.
Definition saves.c:807
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_CONFIRM
SYSTEM07.
Definition sound.h:44
#define SOUND_SELECT
Sounds the overlays share, with SOUNDTST's names.
Definition sound.h:38
#define SOUND_MENU_CANCEL
SYSTEM01.
Definition sound.h:39
#define SOUND_CURSOR
SYSTEM02: a cursor moves.
Definition sound.h:40
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
s32 STGMCARD_errorTexts[]
the texts of the errors, by result
Definition stgmcard.c:48
void(* setPos)()
(cursor, x, y)
Definition text.h:34
void(* setVisible)()
(cursor, visible)
Definition text.h:33
void *(* load)(u32 file)
Definition file.h:92
void *(* getEntry)(u32 fileAndIndex)
Definition file.h:96
s32(* getPartyMember)(u32 index)
Definition game_state.h:24
The saved part of the game state, to copy it whole.
u8 checksum
a save's, of its bytes from 0x4 (STGMCARD_runSaves)
Definition game_state.h:492
char name[0x18]
the player's
Definition game_state.h:509
Partner partners[PARTNER_COUNT]
Definition game_state.h:517
PlayTime playTime
Definition game_state.h:508
u8 version
a save's MEMCARD_SAVE_VERSION (stgmcard.h)
Definition game_state.h:494
GameFuncs funcs
Definition game_state.h:582
s32(* getTime)(void)
Definition gfx.h:31
GfxFuncs funcs
Definition gfx.h:77
void(* zero)(void *ptr, s32 size)
Definition heap.h:32
The memory card's info section: the three slots' saves, as the list shows them (STGMCARD_funcs....
Definition memory_card.h:84
u8 version
MEMCARD_SAVE_VERSION.
Definition memory_card.h:87
u8 checksum
of the rest, from magic
Definition memory_card.h:85
s32 magic
"DMW3"
Definition memory_card.h:88
MemCardSave saves[3]
Definition memory_card.h:89
u8 last
the slot last saved to
Definition memory_card.h:86
void(* hide)(struct MemCardInfo *info)
void(* refresh)(struct MemCardInfo *info)
s32 drawing
the partners and frame are drawn
void(* show)(struct MemCardInfo *info)
s32 slid
the last slide done: 1 header in, 2 slots in, 3 slots out
void(* slideInSlots)(struct MemCardMenu *menu)
void(* slideInHeader)(struct MemCardMenu *menu)
void(* slideOutSlots)(struct MemCardMenu *menu)
void(* reset)(struct MemCardMenu *menu)
void(* slideOutHeader)(struct MemCardMenu *menu)
void(* startPick)(struct MemCardMenu *menu, s32 slot)
void(* setBottomColor)(struct MemCardPanel *panel, u8 r, u8 g, u8 b)
void(* start)(struct MemCardPanel *panel, s32 substate, s32 duration)
void(* reset)(struct MemCardPanel *panel)
void(* setTopColor)(struct MemCardPanel *panel, u8 r, u8 g, u8 b)
A save of the memory card, as the list shows it.
Definition memory_card.h:71
u8 name[0x18]
empty for a free slot
Definition memory_card.h:72
s16 levels[3]
Definition memory_card.h:79
PlayTime time
Definition memory_card.h:76
s32 area
MemCardScreen's.
Definition memory_card.h:73
s32 partners[3]
3 and up: a partner, whose animation the details show
Definition memory_card.h:77
The children of the save list.
Definition memory_card.h:61
struct MemCardInfo * info
Definition memory_card.h:67
TextWindow * title
save or load
Definition memory_card.h:62
TextWindow * windows[5]
Definition memory_card.h:63
struct MemCardMenu * menu
Definition memory_card.h:66
struct MemCardPanel * panel
Definition memory_card.h:65
The saves of a memory card (STGMCARD_updateSaves)
s32 choice
of a yes/no question, 0 for yes; 0x2804 in the European version, as all below
void(* hide)(struct MemCardSaves *saves)
void(* nextState)(struct MemCardSaves *task)
s32 choosing
the cursor's two choices are shown
void(* nextSubstate)(struct MemCardSaves *task)
s32 result
of the last card operation, then the error (STGMCARD_errorTexts)
s32 prompting
a message waits for the cross button
MemCardFile file
the card's
void(* refresh)(struct MemCardSaves *saves)
MenuLerp slide[2]
the list's x and y offsets
s32 origin[3]
x and y of the list's windows
void(* setStep)(struct MemCardSaves *task, s32 step)
void * children
void(* setState)(struct MemCardSaves *task, s32 state)
MemCardScreen * screen
s32 backToPick
the message returns to the slot picker
void(* startLerp)(MenuLerp *lerp, s32 from, s32 to, s32 frames)
SaveData * dataBuf
the saved part of the game state
MemCardFile * infoBuf
s32 slot
the selected one
s32 lastSlot
the card's last saved one
s32(* updateLerp)(MenuLerp *lerp)
The main task of the screen (STGMCARD_createScreen)
Definition memory_card.h:37
s32 place
a string of TEXT_SHOP_NAMES (STGMCARD_places)
Definition memory_card.h:46
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
s32 iconIndex
the icon a save is writing (STGMCARD_runSaves)
Definition memcard.h:105
long fileCount
long: MemCardGetDirentry writes it
Definition memcard.h:96
void * icons[3]
each frame's image (setSaveHeader)
Definition memcard.h:104
CardDirEntry files[15]
Definition memcard.h:97
s32 iconCount
Definition memcard.h:103
CardHeader header
Definition memcard.h:90
s32 value
Definition menu.h:30
s16 stats[19]
Definition game_state.h:306
PartnerStats info
Definition game_state.h:349
s32 unlocked
partner id + 3, 0 while locked
Definition game_state.h:347
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(* setClutRow)()
(row)
Definition gfx.h:247
void(* draw)()
(sheet, frame, x, y)
Definition gfx.h:246
void(* setTexture)()
(x, y)
Definition gfx.h:242
void(* setDepth)()
Definition text.h:183
void(* setLines)()
no prototype: callers would truncate u8 args
Definition text.h:184
void(* setNumber)()
Definition text.h:166
void(* setPos)(struct TextWindow *obj, s16 x, s16 y)
Definition text.h:173
void(* setString)()
Definition text.h:165
void(* setVisible)(struct TextWindow *obj, u8 arg)
Definition text.h:177
void * createTask(void(*update)(), s32 size, s32 childrenSize)
createTaskWithId for a task nothing needs to find
Definition task.c:105
TextWindow * createTextWindow(s16 layerId, s16 style, s16 x, s16 y)
A text window on a layer, in a font style, at (x, y)
u8 bytes[0x26C4]
GameSave save
GameState game