create seperate core2/file.h header

This commit is contained in:
Banjo Kazooie
2024-09-13 19:34:27 -05:00
parent c566cadd6f
commit d55a8d829d
15 changed files with 86 additions and 53 deletions

10
include/bool.h Normal file
View File

@@ -0,0 +1,10 @@
#include <ultra64.h>
#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

55
include/core2/file.h Normal file
View File

@@ -0,0 +1,55 @@
#ifndef LOCAL_FILE_H
#define LOCAL_FILE_H
#include <ultra64.h>
#include <bool.h> // for bool
#include <enums.h> // 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

View File

@@ -4798,12 +4798,6 @@ enum marker_collision_func_type_e {
MARKER_COLLISION_FUNC_2_DIE 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 #endif

View File

@@ -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_clear(enum misc_flag_e arg0);
extern void miscFlag_toggle(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 #endif

View File

@@ -5,14 +5,12 @@
#include "model.h" #include "model.h"
#include "core2/vla.h" #include "core2/vla.h"
#include "enums.h" #include "enums.h"
#include "bool.h"
#define MERGE(a, b) a ## b #define MERGE(a, b) a ## b
#define UNK_TYPE(t) t #define UNK_TYPE(t) t
typedef int bool;
#define NOT(boolean) ((boolean) ^ 1)
#define BOOL(boolean) ((boolean) ? TRUE : FALSE)
typedef struct{ typedef struct{
f32 x; f32 x;
@@ -551,17 +549,6 @@ typedef struct {
//Struct60s moved to top //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 { typedef struct {
s16 unk0; s16 unk0;

View File

@@ -2,7 +2,7 @@
#include "functions.h" #include "functions.h"
#include "variables.h" #include "variables.h"
#include <core2/file.h>
void func_802BA23C(s32 *arg0, s32 arg1); void func_802BA23C(s32 *arg0, s32 arg1);

View File

@@ -2,6 +2,8 @@
#include "functions.h" #include "functions.h"
#include "variables.h" #include "variables.h"
#include <core2/file.h>
typedef struct{ typedef struct{
f32 unk0[3]; f32 unk0[3];
f32 unkC; f32 unkC;

View File

@@ -1,4 +1,7 @@
#include <ultra64.h> #include <ultra64.h>
#include <core2/file.h>
#include "functions.h" #include "functions.h"
#include "variables.h" #include "variables.h"

View File

@@ -2,6 +2,7 @@
#include "functions.h" #include "functions.h"
#include "variables.h" #include "variables.h"
#include <core2/file.h>
typedef struct { typedef struct {
f32 position[3]; f32 position[3];

View File

@@ -2,6 +2,7 @@
#include "functions.h" #include "functions.h"
#include "variables.h" #include "variables.h"
#include <core2/file.h>
#include "prop.h" #include "prop.h"
#define SQ(x) ((x) * (x)) #define SQ(x) ((x) * (x))

View File

@@ -3,6 +3,8 @@
#include "variables.h" #include "variables.h"
#include "enums.h" #include "enums.h"
#include <core2/file.h>
#define AssetCacheSize 0x3D5 #define AssetCacheSize 0x3D5
extern int func_802E74A0(f32[3], f32, s32, s32); extern int func_802E74A0(f32[3], f32, s32, s32);

View File

@@ -2,6 +2,7 @@
#include "functions.h" #include "functions.h"
#include "variables.h" #include "variables.h"
#include <core2/file.h>
extern void func_80252CC4(f32[3], f32[3], f32, f32[3]); extern void func_80252CC4(f32[3], f32[3], f32, f32[3]);
extern f32 vtxList_getGlobalNorm(BKVertexList *arg0); extern f32 vtxList_getGlobalNorm(BKVertexList *arg0);

View File

@@ -1,4 +1,7 @@
#include <ultra64.h> #include <ultra64.h>
#include <core2/file.h>
#include "functions.h" #include "functions.h"
#include "variables.h" #include "variables.h"
#include "core2/particle.h" #include "core2/particle.h"

View File

@@ -1,11 +1,10 @@
#include <ultra64.h> #include <core2/file.h>
#include "functions.h" #include "functions.h"
#include "variables.h" #include "variables.h"
#define FILE_DEFAULT_SIZE 0x20 #define FILE_DEFAULT_SIZE 0x20
void file_read(File *file, void *arg1, s32 arg2); void file_read(File *file, void *arg1, s32 arg2);
void file_close(File *file) { void file_close(File *file) {
@@ -62,7 +61,7 @@ File *file_openFromMem(void *ptr, s32 size) {
return this; return this;
} }
File *file_allocNew() { File *file_allocNew(void) {
File *this; File *this;
this = (File *) malloc(sizeof(File)); this = (File *) malloc(sizeof(File));

View File

@@ -2,6 +2,8 @@
#include "functions.h" #include "functions.h"
#include "variables.h" #include "variables.h"
#include <core2/file.h>
#define NC_CAMERA_NODE_LIST_CAPACITY 0x46 #define NC_CAMERA_NODE_LIST_CAPACITY 0x46
typedef struct { typedef struct {