diff --git a/include/bool.h b/include/bool.h new file mode 100644 index 00000000..35b78285 --- /dev/null +++ b/include/bool.h @@ -0,0 +1,10 @@ +#include + +#ifndef BANJO_KAZOOIE_BOOL_H +#define BANJO_KAZOOIE_BOOL_H + +typedef int bool; +#define NOT(boolean) ((boolean) ^ 1) +#define BOOL(boolean) ((boolean) ? TRUE : FALSE) + +#endif diff --git a/include/core2/file.h b/include/core2/file.h new file mode 100644 index 00000000..5bf70304 --- /dev/null +++ b/include/core2/file.h @@ -0,0 +1,55 @@ +#ifndef LOCAL_FILE_H +#define LOCAL_FILE_H + +#include +#include // for bool +#include // for enum asset_e, enum map_e + +enum file_mode_e { + FILE_MODE_0_UNKNOWN, + FILE_MODE_1_UNKNOWN, + FILE_MODE_2_FROM_ASSET, + FILE_MODE_3_FROM_MEMORY, + FILE_MODE_4_ALLOCATED +}; + +typedef struct file_s { + void *asset_base_ptr; + void *asset_current_ptr; + void *base_ptr; + void *current_ptr; + void *end_ptr; + enum file_mode_e mode; + u8 pad18[0x64]; + s32 last_expected; // used in file_isNextByteExpected + s32 unk80; // always set to -1 and never used +} File; + +void file_close(File* file); +File *file_open(enum asset_e asset_id); +File *file_openMap(enum map_e map_id); +File *file_openWithBaseIndex(s32 indx, enum asset_e base_indx); +File *file_openFromMem(void *ptr, s32 size); +File *file_allocNew(void); +void file_realloc(File *file, void **arg1, s32 *size); +void file_getByte(File *file, u8 *dst); +void file_getNBytes(File *file, u8 *dst, s32 cnt); +void file_getFloat(File *file, f32 *dst); +void file_getNFloat(File *file, f32 *dst, s32 cnt); +void file_getWord(File *file, s32 *dst); +void file_getNWords(File *file, s32 *dst, s32 cnt); +void file_read(File *file, void *dst, s32 len); +void file_getShort(File *file, s16 *dst); +void file_getNShorts(File *file, s16 *dst, s32 cnt); +bool file_isNextByteExpected(File *file, s32 expected); +bool file_getByte_ifExpected(File *file, s32 expected, u8 *dst); +bool file_getNBytes_ifExpected(File *file, s32 expected, u8 *dst, s32 cnt); +bool file_getFloat_ifExpected(File *file, s32 expected, f32 *dst); +bool file_getNFloats_ifExpected(File *file, s32 expected, f32 *dst, s32 cnt); +bool file_getWord_ifExpected(File *file, s32 expected, s32 *dst); +bool file_getNWords_ifExpected(File *file, s32 expected, s32 *dst, s32 cnt); +bool file_get_ifExpected(File *file, s32 expected, void *dst, s32 len); +bool file_getShort_ifExpected(File *file, s32 expected, s16 *dst); +bool file_getNShorts_ifExpected(File *file, s32 expected, s16 *dst, s32 cnt); + +#endif diff --git a/include/enums.h b/include/enums.h index 28f32d80..ac239745 100644 --- a/include/enums.h +++ b/include/enums.h @@ -4798,12 +4798,6 @@ enum marker_collision_func_type_e { MARKER_COLLISION_FUNC_2_DIE }; -enum file_mode_e { - FILE_MODE_0_UNKNOWN, - FILE_MODE_1_UNKNOWN, - FILE_MODE_2_FROM_ASSET, - FILE_MODE_3_FROM_MEMORY, - FILE_MODE_4_ALLOCATED -}; + #endif diff --git a/include/functions.h b/include/functions.h index d79d4464..6926257a 100644 --- a/include/functions.h +++ b/include/functions.h @@ -581,31 +581,4 @@ extern void miscFlag_set(enum misc_flag_e arg0); extern void miscFlag_clear(enum misc_flag_e arg0); extern void miscFlag_toggle(enum misc_flag_e arg0); -extern void file_close(File* file); -extern File *file_open(enum asset_e asset_id); -extern File *file_openMap(enum map_e map_id); -extern File *file_openWithBaseIndex(s32 indx, enum asset_e base_indx); -extern File *file_openFromMem(void *ptr, s32 size); -extern File *file_allocNew(); -extern void file_realloc(File *file, void **arg1, s32 *size); -extern void file_getByte(File *file, u8 *dst); -extern void file_getNBytes(File *file, u8 *dst, s32 cnt); -extern void file_getFloat(File *file, f32 *dst); -extern void file_getNFloat(File *file, f32 *dst, s32 cnt); -extern void file_getWord(File *file, s32 *dst); -extern void file_getNWords(File *file, s32 *dst, s32 cnt); -extern void file_read(File *file, void *dst, s32 len); -extern void file_getShort(File *file, s16 *dst); -extern void file_getNShorts(File *file, s16 *dst, s32 cnt); -extern bool file_isNextByteExpected(File *file, s32 expected); -extern bool file_getByte_ifExpected(File *file, s32 expected, u8 *dst); -extern bool file_getNBytes_ifExpected(File *file, s32 expected, u8 *dst, s32 cnt); -extern bool file_getFloat_ifExpected(File *file, s32 expected, f32 *dst); -extern bool file_getNFloats_ifExpected(File *file, s32 expected, f32 *dst, s32 cnt); -extern bool file_getWord_ifExpected(File *file, s32 expected, s32 *dst); -extern bool file_getNWords_ifExpected(File *file, s32 expected, s32 *dst, s32 cnt); -extern bool file_get_ifExpected(File *file, s32 expected, void *dst, s32 len); -extern bool file_getShort_ifExpected(File *file, s32 expected, s16 *dst); -extern bool file_getNShorts_ifExpected(File *file, s32 expected, s16 *dst, s32 cnt); - #endif diff --git a/include/structs.h b/include/structs.h index 35ecd7f2..7b1c12ce 100644 --- a/include/structs.h +++ b/include/structs.h @@ -5,14 +5,12 @@ #include "model.h" #include "core2/vla.h" #include "enums.h" +#include "bool.h" #define MERGE(a, b) a ## b #define UNK_TYPE(t) t -typedef int bool; -#define NOT(boolean) ((boolean) ^ 1) -#define BOOL(boolean) ((boolean) ? TRUE : FALSE) typedef struct{ f32 x; @@ -551,17 +549,6 @@ typedef struct { //Struct60s moved to top -typedef struct file_s { - void *asset_base_ptr; - void *asset_current_ptr; - void *base_ptr; - void *current_ptr; - void *end_ptr; - enum file_mode_e mode; - u8 pad18[0x64]; - s32 last_expected; // used in file_isNextByteExpected - s32 unk80; // always set to -1 and never used -} File; typedef struct { s16 unk0; diff --git a/src/core2/code_33250.c b/src/core2/code_33250.c index 9e7104ba..56d1d3c5 100644 --- a/src/core2/code_33250.c +++ b/src/core2/code_33250.c @@ -2,7 +2,7 @@ #include "functions.h" #include "variables.h" - +#include void func_802BA23C(s32 *arg0, s32 arg1); diff --git a/src/core2/code_33310.c b/src/core2/code_33310.c index 916598ed..8290ac87 100644 --- a/src/core2/code_33310.c +++ b/src/core2/code_33310.c @@ -2,6 +2,8 @@ #include "functions.h" #include "variables.h" +#include + typedef struct{ f32 unk0[3]; f32 unkC; diff --git a/src/core2/code_336F0.c b/src/core2/code_336F0.c index 9f22de4f..8ab4922b 100644 --- a/src/core2/code_336F0.c +++ b/src/core2/code_336F0.c @@ -1,4 +1,7 @@ #include + +#include + #include "functions.h" #include "variables.h" diff --git a/src/core2/code_33AB0.c b/src/core2/code_33AB0.c index 4e38f894..85ed8322 100644 --- a/src/core2/code_33AB0.c +++ b/src/core2/code_33AB0.c @@ -2,6 +2,7 @@ #include "functions.h" #include "variables.h" +#include typedef struct { f32 position[3]; diff --git a/src/core2/code_7AF80.c b/src/core2/code_7AF80.c index 223411ee..d650d37b 100644 --- a/src/core2/code_7AF80.c +++ b/src/core2/code_7AF80.c @@ -2,6 +2,7 @@ #include "functions.h" #include "variables.h" +#include #include "prop.h" #define SQ(x) ((x) * (x)) diff --git a/src/core2/code_A5BC0.c b/src/core2/code_A5BC0.c index 2de1af31..6a3318c5 100644 --- a/src/core2/code_A5BC0.c +++ b/src/core2/code_A5BC0.c @@ -3,6 +3,8 @@ #include "variables.h" #include "enums.h" +#include + #define AssetCacheSize 0x3D5 extern int func_802E74A0(f32[3], f32, s32, s32); diff --git a/src/core2/code_AC520.c b/src/core2/code_AC520.c index c132ff0e..1235d1fd 100644 --- a/src/core2/code_AC520.c +++ b/src/core2/code_AC520.c @@ -2,6 +2,7 @@ #include "functions.h" #include "variables.h" +#include extern void func_80252CC4(f32[3], f32[3], f32, f32[3]); extern f32 vtxList_getGlobalNorm(BKVertexList *arg0); diff --git a/src/core2/code_AD5B0.c b/src/core2/code_AD5B0.c index b89b8129..fcf34814 100644 --- a/src/core2/code_AD5B0.c +++ b/src/core2/code_AD5B0.c @@ -1,4 +1,7 @@ #include + +#include + #include "functions.h" #include "variables.h" #include "core2/particle.h" diff --git a/src/core2/file.c b/src/core2/file.c index bd8aee84..310b2d18 100644 --- a/src/core2/file.c +++ b/src/core2/file.c @@ -1,11 +1,10 @@ -#include +#include + #include "functions.h" #include "variables.h" #define FILE_DEFAULT_SIZE 0x20 - - void file_read(File *file, void *arg1, s32 arg2); void file_close(File *file) { @@ -62,7 +61,7 @@ File *file_openFromMem(void *ptr, s32 size) { return this; } -File *file_allocNew() { +File *file_allocNew(void) { File *this; this = (File *) malloc(sizeof(File)); diff --git a/src/core2/nc/cameranodelist.c b/src/core2/nc/cameranodelist.c index fc9b721b..03b6e2ee 100644 --- a/src/core2/nc/cameranodelist.c +++ b/src/core2/nc/cameranodelist.c @@ -2,6 +2,8 @@ #include "functions.h" #include "variables.h" +#include + #define NC_CAMERA_NODE_LIST_CAPACITY 0x46 typedef struct {