Digimon World 3 decomp
The European version, SLES_039.36
Loading...
Searching...
No Matches
state.c
Go to the documentation of this file.
1#include "engine/game.h"
2#include "field/field_map.h"
3
4/* Clears the save data and sets up a new game */
5void newGame(void) {
7#if VERSION_US || VERSION_JP
10#elif VERSION_EU
13#endif
15 GAME.countdown[0] = 1;
16 GAME.countdown[1] = 8;
17 GAME.countdown[3] = 60;
18 GAME.modeArg = 0;
19 GAME.countdown[2] = 0;
20 GAME.unusedC = -1;
22 GAME.battleSteps = (RANDOM.next() & 0x1FF) + 0x200;
23}
24
25/* Makes the requested mode current (main calls it before recreating the mode task) */
26void commitMode(void) {
27 s32 prev;
28
29 if (GAME.nextMode != 0) {
30 prev = GAME.mode;
32 GAME.nextMode = 0;
33 GAME.prevMode = prev;
34 }
35}
36
37/* The game mode before the current one */
39 return GAME.prevMode;
40}
41
42/* The current game mode */
43s32 getMode(void) {
44 return GAME.mode;
45}
46
47/* The argument the current mode was requested with */
49 return GAME.modeArg;
50}
51
52/* Asks for a mode change, applied when main recreates the mode task */
53void requestMode(s32 mode, s32 arg) {
54 GAME.nextMode = mode;
55 GAME.modeArg = arg;
56}
57
58/* Whether a mode change was requested */
60 return GAME.nextMode != 0;
61}
62
63/* The save data, the game mode and the methods */
signed int s32
Definition common.h:11
s32 addPartnerEntry(s32 partner, s32 id)
Gives a partner Digimon id at level 1; 0 if it has it already or has no room.
Definition partner.c:74
PartnerStats * getPartnerStats(s32 partner)
A partner's name, stats and Digimon.
Definition partner.c:117
s32 getPartnerSlots(s32 partner, s16 *out)
Copies the ids of the Digimon a partner takes to battle; returns how many there are.
Definition partner.c:19
s32 listPartnerEntries(s32 partner, u16 *out)
Copies the ids of a partner's Digimon, zero-filled; returns how many there are.
Definition partner.c:55
void setPartnerSlots(s32 partner, s16 *ids)
Picks the Digimon a partner takes to battle (-1 for ids it does not have)
Definition partner.c:40
s32 setPartnerEntry(s32 partner, s32 id, PartnerEntry *in)
Overwrites a partner's Digimon id; returns its index, or -1.
Definition partner.c:107
s32 getPartnerEntry(s32 partner, s32 id, PartnerEntry *out)
Copies a partner's Digimon id; returns its index, or -1.
Definition partner.c:97
void newGame(void)
Clears the save data and sets up a new game.
Definition state.c:5
void requestMode(s32 mode, s32 arg)
Asks for a mode change, applied when main recreates the mode task.
Definition state.c:53
s32 getPrevMode(void)
The game mode before the current one.
Definition state.c:38
s32 getMode(void)
The current game mode.
Definition state.c:43
s32 isModeChangePending(void)
Whether a mode change was requested.
Definition state.c:59
void commitMode(void)
Makes the requested mode current (main calls it before recreating the mode task)
Definition state.c:26
GameState GAME
The save data, the game mode and the methods.
Definition state.c:64
s32 getModeArg(void)
The argument the current mode was requested with.
Definition state.c:48
s32 getPartyPartner(u32 index)
The partner id of party member index (its unlocked value - 3), or -1.
Definition stats.c:5
void computeStats(s32 partner, PartnerTotals *out)
A partner's stats with its equipment (and its equipment set bonus) added.
Definition stats.c:65
void addStat(s32 partner, u32 stat, s32 delta)
Adds to a partner's stat, kept within the same limits as setStat.
Definition stats.c:39
void setStat(s32 partner, u32 stat, s16 value)
Sets a partner's stat, kept within 0-99 (level, TP), 0-9999 (HP, MP) or 0-999.
Definition stats.c:13
What the stage overlays and the executable use of FIELDSTG (fieldstg.h has the rest): its layers and ...
#define MODE_COUNTRY_SELECT
CNTY_SEL, where the European version starts.
Definition game_state.h:455
#define GAME_SAVE_SIZE
The saved part of the game state, GAME up to mode: a save's data section (stgmcard....
Definition game_state.h:591
#define MODE_OPENING
STDWTITL's first movie.
Definition game_state.h:439
Heap HEAP
The functions that return what a call left in v0 (allocMemHigh, findTask) and the ones that take othe...
Definition heap.c:184
void addCards(s32 card, s32 count)
Gives count copies of a card (up to CARD_COPIES_MAX) and marks it seen.
Definition party.c:63
void giveStarterDeck(void)
Gives the starter deck's cards and puts them in every deck.
Definition party.c:72
void initNewGameData(void)
The new game's player name, deck names, starter deck and partners.
Definition party.c:5
s32 getPartyMember(u32 index)
The partner index of party member index, or -1.
Definition party.c:42
void setParty(s32 set)
Gives the party STARTER_PARTIES[set], unlocking its partners.
Definition party.c:50
void resetPlayTime(void)
Sets the play time to zero.
Definition play_time.c:5
void updatePlayTime(void)
Turns the vsync-counted frames into seconds, minutes and hours, stopping at 999:59:59.
Definition play_time.c:14
Random RANDOM
Definition random.c:533
The game state (GAME): the first 0x26BC bytes are what newGame clears (the save data),...
Definition game_state.h:491
s32 unusedC
newGame sets it to -1; nothing reads it
Definition game_state.h:498
u8 countdown[4]
Definition game_state.h:572
s32 battleSteps
to the next random battle, which each step lowers
Definition game_state.h:502
u8 digivolveDemo
Definition game_state.h:496
GameFuncs funcs
Definition game_state.h:582
void(* zero)(void *ptr, s32 size)
Definition heap.h:32
s32(* next)(void)
0 to RANDOM_COUNT - 1
Definition random.h:15