mirror of
https://github.com/open-goal/jak-project
synced 2026-05-24 15:21:12 -04:00
4f537d4a71
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.
35 lines
1.1 KiB
C++
35 lines
1.1 KiB
C++
#pragma once
|
|
|
|
#include "common/common_types.h"
|
|
|
|
//! Toggle to use more memory. To simulate the original game's memory layout, set this to false.
|
|
// Make sure this matches the const in gcommon.gc.
|
|
constexpr bool BIG_MEMORY = true;
|
|
|
|
//! How much space to leave for the stack when creating the debug heap
|
|
// In the game, it's 16 kB, but we increase it to 64 kB.
|
|
// ASAN builds + fmt stuff uses a _ton_ of stack when no optimizations are on and we
|
|
// need more.
|
|
constexpr u32 DEBUG_HEAP_SPACE_FOR_STACK = 0x10000;
|
|
|
|
//! First free address for the GOAL heap
|
|
constexpr u32 HEAP_START = 0x13fd20;
|
|
|
|
//! Where to end the global heap so it doesn't overlap with the stack.
|
|
constexpr u32 GLOBAL_HEAP_END = 0x1ffc000 + (BIG_MEMORY ? (0x1ffc000 - HEAP_START) : 0); // doubled
|
|
|
|
//! Location of kglobalheap, kdebugheap kheapinfo structures.
|
|
constexpr u32 GLOBAL_HEAP_INFO_ADDR = 0x13AD00;
|
|
constexpr u32 DEBUG_HEAP_INFO_ADDR = 0x13AD10;
|
|
constexpr u32 LINK_CONTROL_NAME_ADDR = 0x13AD80;
|
|
|
|
//! Where to place the debug heap
|
|
constexpr u32 DEBUG_HEAP_START = 0x5000000;
|
|
|
|
namespace jak2 {
|
|
constexpr u32 DEBUG_HEAP_SIZE = 0x2f00000;
|
|
}
|
|
|
|
namespace jak3 {
|
|
constexpr u32 DEBUG_HEAP_SIZE = 0x2f00000;
|
|
} |