-
Notifications
You must be signed in to change notification settings - Fork 6
2. Memory
ROM space distribution is configured in config-memmap.h
Address | Size | Usage |
---|---|---|
0x00E8414 | 0x785A8 | Kernel text section (in-BL range) |
0x0B2A604 | 0xD5DFC | Kernel data section |
0x0EFB2E0 | 0xE4D20 | Font |
0x1000000 | --- | reserved for DEMO |
To improve program performance, the kernel use in-BL range space (start from 0xE8414
) for text section, which is quite different from the custom modifications.
For other data and contants, we mainly use free-space starting from 0xB2A604
.
In order to collaborate with FEBuilderGBA and make DEMO based on kernel, we also need to define some important data at these fixed locations:
A serial of characters is set at the head of kernel free-space (0xB2A604
), which we can use as an identifier for FEBuilder patch.
There is a pointer list after the magic pattern, starting at 0xB2A614
with size = 0x400
. Both wizard C-hacks and FEBuilder patches can find the data via this list, so that you can expand the data via FEB.
TextTable is repointed at a fixed location behind the pointer list, 0xB2AA14 (the very beginning of main space) with size = 0x2000 * sizeof(uintptr_t)
free space allocated. If you want to make DEMO based on kernel, it is recommanded to directly use the kernel allocated text table rather than re-repoint it by such operations:
#include "fe8-kernel-dev.ref.event" // auto generated by kernel
#define TextTable NewTextTable
#include "Tools/Tool Helpers.txt" // EventAssembler helper
Free space at 0x0EFB2E0
is used to insert font data for further multi-language support, which is also a reserved space.
RAM space distribution is configured in config-memmap.s
Address | Size | Usage |
---|---|---|
0x02026E30 | 0x2028 | Kernel |
0x0203F000 | 0x1000 | reserved for DEMO |
Since the entire source code is compiled at once, CHAX can offer a better Free-RAM-Space control method.
Free-RAM-Space (unused memory) from vanilla that has been previously identified by other wizards, can now can be referenced in StanH's DOC. Here we mainly use space starting at 0x02026E30
with size 0x2028
, which is the debug print buffer in vanilla (and unused).
In the kernel, free-RAM space is allocated from the bottom to the top:
0x02026E30, FreeRamSpaceTop
<--- gKernelUsedFreeRamSpaceTop
<------------
<!used kernel space>
0x02028E58, FreeRamSpaceBottom
Developers should ensure that used free-RAM space does not overflow, which means asseration (gKernelUsedFreeRamSpaceTop > FreeRamSpaceTop)
should be valid. We have also added detection for RAM space overflows, CHAX will auto detect an overflow error on game-init.
Here is an example to allocate RAM space in the kernel:
Suppose you want a 4 Byte RAM space (u8 NewAlloc4Bytes[4]
)
- Get intoconfig-memmap.s
- Insert new allocation
_kernel_malloc NewAlloc4Bytes, 4
Warning
Make sure that the allocated space is 32 bits aligned
- Declare the variable in your own C file,
extern u8 NewAlloc4Bytes[4];