-
Notifications
You must be signed in to change notification settings - Fork 1
/
new_game.c
59 lines (55 loc) · 1.76 KB
/
new_game.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#include <save.h>
#include <common.h>
#include <flags.h>
#include <game.h>
#include "checkIds/base.h"
extern const u32 n_starting_items;
extern const u8 starting_items[];
extern const u32 n_starting_flags;
extern const u16 starting_flags[];
extern const u32 n_starting_fusions;
extern const u8 starting_fusions[];
extern const u8 starting_area;
extern const u8 starting_room;
extern const u8 starting_anim_state;
extern const struct{
s16 x;
s16 y;
} starting_pos;
extern u32 GiveItem(u32 item, u32 param_2);
u32 FinalizeSave(void) {
if (gSave.invalid || gSave.initialized != 1) {
gSave.invalid = 0;
gSave.initialized = 1;
gSave.global_progress = 1;
gSave.stats.health = 3*8;
gSave.stats.maxHealth = 3*8;
gSave.saved_status.area_next = starting_area;
gSave.saved_status.room_next = starting_room;
gSave.saved_status.start_anim = starting_anim_state;
gSave.saved_status.spawn_type = PL_SPAWN_DEFAULT;
gSave.saved_status.layer = 1;
gSave.saved_status.start_pos_x = starting_pos.x;
gSave.saved_status.start_pos_y = starting_pos.y;
for (u32 i = 0; i < n_starting_flags; i++)
{
SetGlobalFlag(starting_flags[i]);
}
for (u32 i = 0; i < n_starting_items; i++)
{
int item = starting_items[i];
GiveItem(get_item_id(item), get_item_subvalue(item));
}
for (u32 i = 0; i < n_starting_fusions; i++)
{
if (++gSave.fusedKinstoneCount > 99) {
gSave.didAllFusions = 1;
}
WriteBit(gSave.fusedKinstones, starting_fusions[i]);
}
}
if (gSave.name[0] == 0) {
MemCopy(gUnk_0811E470, &gSave.name, FILENAME_LENGTH - 1);
}
return 1;
}