summaryrefslogtreecommitdiff
path: root/include/m_field_make.h
blob: 45cf2829298de91b16997a4406d981a7c13225d6 (plain)
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
#ifndef M_FIELD_MAKE_H
#define M_FIELD_MAKE_H

#include "ultra64.h"
#include "unk.h"
#include "m_collision_bg.h"
#include "m_field_info.h"
#include "other_types.h"

struct Game;

#define BLOCK_X_NUM 7
#define BLOCK_Z_NUM 8
#define BLOCK_TOTAL_NUM (BLOCK_X_NUM * BLOCK_Z_NUM)

#define FG_BLOCK_X_NUM (BLOCK_X_NUM - 2) /* 5 */
#define FG_BLOCK_Z_NUM (BLOCK_Z_NUM - 2) /* 6 */
#define FG_BLOCK_TOTAL_NUM (FG_BLOCK_X_NUM * FG_BLOCK_Z_NUM)

#define UT_BASE_NUM 16
#define UT_X_NUM UT_BASE_NUM /* Spaces per block (acre) in x direction */
#define UT_Z_NUM UT_BASE_NUM /* Spaces per block (acre) in z direction */
#define UT_TOTAL_NUM (UT_X_NUM * UT_Z_NUM)

#define mFM_SOUND_SOURCE_NUM 6
#define mFM_MOVE_ACTOR_NUM 16
#define mFM_HANIWA_STEP_NUM 4

/*
 * Naming convention for `RIVER`/`POOL`: directions indicated are flow of river
 * (e.g. `RIVER_SOUTH` indicates a river that flows south through entire block,
 * `RIVER_WEST_SOUTH` indicates a river that flows west and then south, etc.)
 *
 * Naming convention for `CLIFF`: direction indicated is side with valley
 * (e.g. `CORNER_RIGHT_TOP` indicates the top part of a corner cliff
 * with the valley on the right). However, directions for border cliffs simply
 * indicate the side of the map.
 */
typedef enum FieldMakeBlockType {
    /* 0x00 */ mFM_BLOCK_TYPE_BORDER_CLIFF_TOP,
    /* 0x01 */ mFM_BLOCK_TYPE_BORDER_CLIFF_RIVER,
    /* 0x02 */ mFM_BLOCK_TYPE_BORDER_CLIFF_LEFT,
    /* 0x03 */ mFM_BLOCK_TYPE_3, // Unused (no entries in `data_combi_table`)
    /* 0x04 */ mFM_BLOCK_TYPE_BORDER_CLIFF_RIGHT,
    /* 0x05 */ mFM_BLOCK_TYPE_BORDER_CLIFF_CORNER_TOP_LEFT,
    /* 0x06 */ mFM_BLOCK_TYPE_6, // Unused (no entries in `data_combi_table`)
    /* 0x07 */ mFM_BLOCK_TYPE_7, // Unused (no entries in `data_combi_table`)
    /* 0x08 */ mFM_BLOCK_TYPE_BORDER_CLIFF_CORNER_TOP_RIGHT,
    /* 0x09 */ mFM_BLOCK_TYPE_BORDER_CLIFF_TUNNEL_LEFT,
    /* 0x0A */ mFM_BLOCK_TYPE_BORDER_CLIFF_TUNNEL_RIGHT,
    /* 0x0B */ mFM_BLOCK_TYPE_TRACKS_STATION,
    /* 0x0C */ mFM_BLOCK_TYPE_TRACKS_DUMP,
    /* 0x0D */ mFM_BLOCK_TYPE_TRACKS_RIVER,
    /* 0x0E */ mFM_BLOCK_TYPE_PLAYER_HOUSE,
    /* 0x0F */ mFM_BLOCK_TYPE_CLIFF_HORIZONTAL,
    /* 0x10 */ mFM_BLOCK_TYPE_CLIFF_CORNER_RIGHT_BOTTOM,
    /* 0x11 */ mFM_BLOCK_TYPE_CLIFF_VERTICAL_RIGHT,
    /* 0x12 */ mFM_BLOCK_TYPE_CLIFF_CORNER_RIGHT_TOP,
    /* 0x13 */ mFM_BLOCK_TYPE_CLIFF_CORNER_LEFT_TOP,
    /* 0x14 */ mFM_BLOCK_TYPE_CLIFF_VERTICAL_LEFT,
    /* 0x15 */ mFM_BLOCK_TYPE_CLIFF_CORNER_LEFT_BOTTOM,
    /* 0x16 */ mFM_BLOCK_TYPE_WATERFALL_SOUTH_CLIFF_HORIZONTAL,
    /* 0x17 */ mFM_BLOCK_TYPE_WATERFALL_SOUTH_CLIFF_CORNER_RIGHT_BOTTOM,
    /* 0x18 */ mFM_BLOCK_TYPE_RIVER_SOUTH_CLIFF_VERTICAL_RIGHT,
    /* 0x19 */ mFM_BLOCK_TYPE_RIVER_SOUTH_CLIFF_CORNER_RIGHT_TOP,
    /* 0x1A */ mFM_BLOCK_TYPE_WATERFALL_SOUTH_CLIFF_CORNER_LEFT_TOP,
    /* 0x1B */ mFM_BLOCK_TYPE_RIVER_SOUTH_CLIFF_VERTICAL_LEFT,
    /* 0x1C */ mFM_BLOCK_TYPE_RIVER_SOUTH_CLIFF_CORNER_LEFT_BOTTOM,
    /* 0x1D */ mFM_BLOCK_TYPE_RIVER_EAST_CLIFF_HORIZONTAL, // Correct according to ACSE, should be verified in-game
    /* 0x1E */ mFM_BLOCK_TYPE_WATERFALL_EAST_CLIFF_CORNER_RIGHT_BOTTOM,
    /* 0x1F */ mFM_BLOCK_TYPE_WATERFALL_EAST_CLIFF_VERTICAL_RIGHT,
    /* 0x20 */ mFM_BLOCK_TYPE_RIVER_EAST_CLIFF_CORNER_RIGHT_TOP,
    /* 0x21 */ mFM_BLOCK_TYPE_RIVER_EAST_CLIFF_CORNER_LEFT_TOP,
    /* 0x22 */ mFM_BLOCK_TYPE_RIVER_WEST_CLIFF_HORIZONTAL,
    /* 0x23 */ mFM_BLOCK_TYPE_RIVER_WEST_CLIFF_CORNER_RIGHT_TOP,
    /* 0x24 */ mFM_BLOCK_TYPE_RIVER_WEST_CLIFF_CORNER_LEFT_TOP,
    /* 0x25 */ mFM_BLOCK_TYPE_WATERFALL_WEST_CLIFF_VERTICAL_LEFT,
    /* 0x26 */ mFM_BLOCK_TYPE_WATERFALL_WEST_CLIFF_CORNER_LEFT_BOTTOM,
    /* 0x27 */ mFM_BLOCK_TYPE_FLAT, // Grassy field
    /* 0x28 */ mFM_BLOCK_TYPE_RIVER_SOUTH,
    /* 0x29 */ mFM_BLOCK_TYPE_RIVER_EAST,
    /* 0x2A */ mFM_BLOCK_TYPE_RIVER_WEST,
    /* 0x2B */ mFM_BLOCK_TYPE_RIVER_SOUTH_EAST,
    /* 0x2C */ mFM_BLOCK_TYPE_RIVER_EAST_SOUTH,
    /* 0x2D */ mFM_BLOCK_TYPE_RIVER_SOUTH_WEST,
    /* 0x2E */ mFM_BLOCK_TYPE_RIVER_WEST_SOUTH,
    /* 0x2F */ mFM_BLOCK_TYPE_RIVER_SOUTH_BRIDGE,
    /* 0x30 */ mFM_BLOCK_TYPE_RIVER_EAST_BRIDGE,
    /* 0x31 */ mFM_BLOCK_TYPE_RIVER_WEST_BRIDGE,
    /* 0x32 */ mFM_BLOCK_TYPE_RIVER_SOUTH_EAST_BRIDGE,
    /* 0x33 */ mFM_BLOCK_TYPE_RIVER_EAST_SOUTH_BRIDGE,
    /* 0x34 */ mFM_BLOCK_TYPE_RIVER_SOUTH_WEST_BRIDGE,
    /* 0x35 */ mFM_BLOCK_TYPE_RIVER_WEST_SOUTH_BRIDGE,
    /* 0x36 */ mFM_BLOCK_TYPE_SLOPE_HORIZONTAL,
    /* 0x37 */ mFM_BLOCK_TYPE_SLOPE_CORNER_RIGHT_BOTTOM,
    /* 0x38 */ mFM_BLOCK_TYPE_SLOPE_VERTICAL_RIGHT,
    /* 0x39 */ mFM_BLOCK_TYPE_SLOPE_CORNER_RIGHT_TOP,
    /* 0x3A */ mFM_BLOCK_TYPE_SLOPE_CORNER_LEFT_TOP,
    /* 0x3B */ mFM_BLOCK_TYPE_SLOPE_VERTICAL_LEFT,
    /* 0x3C */ mFM_BLOCK_TYPE_SLOPE_CORNER_LEFT_BOTTOM,
    /* 0x3D */ mFM_BLOCK_TYPE_BORDER_CLIFF_TRANSITION_LEFT,
    /* 0x3E */ mFM_BLOCK_TYPE_BORDER_CLIFF_TRANSITION_RIGHT,
    /* 0x3F */ mFM_BLOCK_TYPE_BEACH,
    /* 0x40 */ mFM_BLOCK_TYPE_BEACH_RIVER,
    /* 0x41 */ mFM_BLOCK_TYPE_SHOP,
    /* 0x42 */ mFM_BLOCK_TYPE_SHRINE,
    /* 0x43 */ mFM_BLOCK_TYPE_POST_OFFICE,
    /* 0x44 */ mFM_BLOCK_TYPE_POLICE_BOX,
    /* 0x45 */ mFM_BLOCK_TYPE_POOL_SOUTH,
    /* 0x46 */ mFM_BLOCK_TYPE_POOL_EAST,
    /* 0x47 */ mFM_BLOCK_TYPE_POOL_WEST,
    /* 0x48 */ mFM_BLOCK_TYPE_POOL_SOUTH_EAST,
    /* 0x49 */ mFM_BLOCK_TYPE_POOL_EAST_SOUTH,
    /* 0x4A */ mFM_BLOCK_TYPE_POOL_SOUTH_WEST,
    /* 0x4B */ mFM_BLOCK_TYPE_POOL_WEST_SOUTH,
    /* 0x4C */ mFM_BLOCK_TYPE_76,
    /* 0x4D */ mFM_BLOCK_TYPE_77,
    /* 0x4E */ mFM_BLOCK_TYPE_78,
    /* 0x4F */ mFM_BLOCK_TYPE_79,
    /* 0x50 */ mFM_BLOCK_TYPE_BORDER_CLIFF_OCEAN_LEFT,
    /* 0x51 */ mFM_BLOCK_TYPE_BORDER_CLIFF_OCEAN_RIGHT,
    /* 0x52 */ mFM_BLOCK_TYPE_BEACH_RIVER_BRIDGE,
    /* 0x53 */ mFM_BLOCK_TYPE_OCEAN,

    /* 0x54 */ mFM_BLOCK_TYPE_NUM,

    /* 0xFF */ mFM_BLOCK_TYPE_NONE = 0xFF
} FieldMakeBlockType;

extern u8* g_block_type_p;
extern u32* g_block_kind_p; // s32 in ac-decomp--if problems arise, try changing type

typedef struct FieldMakeCombination {
    /* 0x0 */ u16 combinationType : 14;  /* acre type index into `data_combi_table` */
    /* 0x0 */ u16 height : 2;            /* 0, 1, 2, or 3 (unused) */
} FieldMakeCombination; // size = 0x2

typedef struct Foreground {
    /* 0x000 */ u16 items[UT_Z_NUM][UT_X_NUM];
} Foreground; // size = 0x200

typedef struct FieldMakeComboInfo {
    /* 0x00 */ u16 bgId; // perhaps should be `bgName`?
    /* 0x02 */ u16 fgId; // perhaps should be `fgName`?
    /* 0x05 */ u8 blockType;
} FieldMakeComboInfo; // size = 0x6

typedef struct FieldMakeMoveActor {
    /* 0x0 */ u16 nameId;
    /* 0x2 */ s8 utX;
    /* 0x3 */ s8 utZ;
    /* 0x4 */ s8 npcId;
    /* 0x6 */ s16 arg;
} FieldMakeMoveActor; // size = 0x8

typedef struct FieldMakeFGData {
    /* 0x000 */ u16 id;
    /* 0x002 */ u16 items[UT_Z_NUM][UT_X_NUM];
    /* 0x202 */ UNK_TYPE1 unk_202[4];
} FieldMakeFGData; // size = 0x206

typedef struct FieldMakeBGSoundSource {
    /* 0x0 */ s16 kind;
    /* 0x4 */ xyz_t pos;
} FieldMakeBGSoundSource; // size = 0x10

typedef struct FieldMakeFGInfo {
    /* 0x00 */ u16 fgId;
    /* 0x04 */ u16* itemsPtr;
    /* 0x08 */ UNK_PTR unk_08; // ac-decomp: u16* deposit_p
    /* 0x0C */ FieldMakeMoveActor moveActors[mFM_MOVE_ACTOR_NUM];
    /* 0x8C */ UNK_TYPE2 unk_08C; // ac-decomp: u16 move_actor_bit_data
    /* 0x8E */ u8 haniwaStep[mFM_HANIWA_STEP_NUM];
} FieldMakeFGInfo; // size = 0x94

// TODO: come up with better names to disambiguate the union `bgId` (which contains height data)
// from the plain u16 `bgId` used in `FieldMakeComboInfo`
typedef struct FieldMakeBGInfo {
    /* 0x000 */ FieldMakeCombination bgId; // stores `bgName` + height of corresponding block type from `data_combi_table`
    /* 0x004 */ UNK_PTR unk_004; // ac-decomp: Gfx* opaque_gfx
    /* 0x008 */ UNK_PTR unk_008; // ac-decomp: Gfx* translucent_gfx
    /* 0x00C */ UNK_PTR unk_00C; // ac-decomp: EvwAnimeData* animation
    /* 0x010 */ UNK_TYPE1 unk_010; // ac-decomp: s8 animation_count
    /* 0x011 */ u8 blockType;
    /* 0x014 */ u32 blockKind;
    /* 0x018 */ RomOffset romStartAddr;
    /* 0x01C */ s32 romSize;
    /* 0x020 */ mCoBG_unkStructUnion collision[UT_Z_NUM][UT_X_NUM];
    /* 0x420 */ u8 unk_420[UT_Z_NUM][UT_X_NUM]; // ac-decomp: u8 keep_h (holds `center` bitfield from corresponding `collision` entries)
    /* 0x520 */ FieldMakeBGSoundSource soundSource[mFM_SOUND_SOURCE_NUM];
} FieldMakeBGInfo; // size = 0x580

typedef struct FieldMakeBlockInfo {
    /* 0x000 */ FieldMakeBGInfo bgInfo;
    /* 0x580 */ FieldMakeFGInfo fgInfo;
} FieldMakeBlockInfo; // size = 0x614

typedef struct FieldMakeInfo {
    /* 0x000 */ u16 fieldId;
    /* 0x002 */ UNK_TYPE1 unk_000[0x146];
    /* 0x148 */ FieldMakeBlockInfo* blockInfo; // length: BLOCK_TOTAL_NUM
    /* 0x14C */ UNK_TYPE1 unk_14C[0x1A];
    /* 0x166 */ u8 blockXMax;
    /* 0x167 */ u8 blockZMax;
} FieldMakeInfo; // size >= 0x168

// void func_80084ED0_jp();
// void func_80084FAC_jp();
// void func_800850E4_jp();
// void func_80085178_jp();
// void func_800851C8_jp();
// void func_800853CC_jp();
// void func_80085490_jp();
// void func_8008557C_jp();
// void func_800855D0_jp();
// void func_80085918_jp();
// void func_800859F4_jp();
// void func_80085A84_jp();
// void func_80085B40_jp();
// void func_80085CC0_jp();
// void func_80085D44_jp();
// void func_80085D64_jp();
// void func_80085D94_jp();
// void func_80085FF0_jp();
// void func_8008609C_jp();
// void func_800862DC_jp();
// void func_8008640C_jp();
// void func_800865D0_jp();
// void func_800867F0_jp();
// void func_80086BD0_jp();
// void func_80086CA4_jp();
// void func_80086D44_jp();
// void func_80086DE0_jp();
// void func_80086E30_jp();
// void func_80086F08_jp();
// void func_80086FA8_jp();
void mFM_SetFieldInitData(s32, s32);
void func_80087004_jp(void);
void func_80087280_jp(void);
// void func_80087380_jp();
void mFM_SetBlockKindLoadCombi(struct Game* game);
void mFM_InitFgCombiSaveData(struct Game* game);
// void func_80087754_jp();
// void func_8008775C_jp();
// void func_80087788_jp();
// void func_800877CC_jp();
void mFM_RenewalReserve(void);
u16 mFM_GetReseveName(s32,s32);

#endif