Files
water111 4f537d4a71 [jak3] Set up ckernel (#3308)
This sets up the C Kernel for Jak 3, and makes it possible to build and
load code built with `goalc --jak3`.

There's not too much interesting here, other than they switched to a
system where symbol IDs (unique numbers less than 2^14) are generated at
compile time, and those get included in the object file itself.

This is kind of annoying, since it means all tools that produce a GOAL
object file need to work together to assign unique symbol IDs. And since
the symbol IDs can't conflict, and are only a number between 0 and 2^14,
you can't just hash and hope for no collisions.

We work around this by ignoring the IDs and re-assigning our own. I
think this is very similar to what the C Kernel did on early builds of
Jak 3 which supported loading old format level files, which didn't have
the IDs included.

As far as I can tell, this shouldn't cause any problems. It defeats all
of their fancy tricks to save memory by not storing the symbol string,
but we don't care.
2024-01-16 19:24:02 -05:00

60 lines
1.7 KiB
C++

#pragma once
#include "common/common_types.h"
#include "game/kernel/common/Ptr.h"
#include "game/kernel/common/kmalloc.h"
constexpr char FOLDER_PREFIX[] = "";
void fileio_init_globals();
char* strend(char* str);
void kstrcpy(char* dst, const char* src);
char* basename_goal(char* s);
void kstrcpyup(char* dst, const char* src);
void kstrcat(char* dest, const char* src);
char* kstrinsert(char* str, char pad, s32 count);
void kstrncat(char* dest, const char* src, s32 count);
Ptr<u8> FileLoad(char* name, Ptr<kheapinfo> heap, Ptr<u8> memory, u32 malloc_flags, s32* size_out);
extern char buffer_633[512];
// GOAL File Types
enum GoalFileType {
LISTENER_TO_KERNEL_FILE_TYPE = 1,
KERNEL_TO_LISTENER_FILE_TYPE = 2,
CODE_FILE_TYPE = 3,
GAMEPAD_FILE_TYPE = 4,
LISTENER_TO_KERNEL_LOCK_FILE_TYPE = 5,
KERNEL_TO_LISTENER_LOCK_FILE_TYPE = 6,
IOP_MODULE_FILE_TYPE = 8,
DATA_FILE_TYPE = 0x20, // called FINAL in jak2
TX_PAGE_FILE_TYPE = 0x21,
JA_FILE_TYPE = 0x22,
JG_FILE_TYPE = 0x23,
MA_FILE_TYPE = 0x24,
MG_FILE_TYPE = 0x25,
TG_FILE_TYPE = 0x26,
LEVEL_FILE_TYPE = 0x27,
ART_GROUP_FILE_TYPE = 0x30,
VS_FILE_TYPE = 0x31,
TX_FILE_TYPE = 0x32,
VS_BIN_FILE_TYPE = 0x33,
DGO_TXT_FILE_TYPE = 0x34,
LEVEL_WITH_EXTENSION_FILE_TYPE = 0x35,
DATA_DGO_FILE_TYPE = 0x36,
GAME_DGO_FILE_TYPE = 0x37,
DATA_CGO_FILE_TYPE = 0x38,
GAME_CGO_FILE_TYPE = 0x39,
CNT_FILE_TYPE = 0x3a,
RES_FILE_TYPE = 0x3b,
SND_BNK_FILE_TYPE = 0x3c,
MUSIC_BNK_FILE_TYPE = 0x3d,
VAG_FILE_TYPE = 0x3e,
MISC_FILE_TYPE = 0x3f, // jak2 only
MAP_FILE_TYPE = 0x40, // jak2 only
CL_FILE_TYPE = 0x41, // jak 3 cloth animation
REFPLANT_FILE_TYPE = 0x301,
// added this, allows access directly to out/iso from fileio.
ISO_FILE_TYPE = 0x302
};