diff options
| author | Derek Hensley <hensley.derek58@gmail.com> | 2023-06-23 21:26:36 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-06-24 14:26:36 +1000 |
| commit | 5619dc5b5e3a1507feb7828ccfd70fe67268ece4 (patch) | |
| tree | fbe6c35e740d095b949a809c11f32ea662b6d51b /include | |
| parent | aa9e368561ae13106daa14da4e2bf0656bfc70da (diff) | |
Load Docs (#1222)
* Sync with OoT
* Macro cleanup
* Some cleanup/rename load system name to Fragment
* Format
* bss
* Some clarifying comments regarding fragments
* PR suggestions
* size_t and numRelocations
Diffstat (limited to 'include')
| -rw-r--r-- | include/color.h | 4 | ||||
| -rw-r--r-- | include/loadfragment.h | 42 | ||||
| -rw-r--r-- | include/macros.h | 7 | ||||
| -rw-r--r-- | include/variables.h | 3 | ||||
| -rw-r--r-- | include/z64load.h | 31 |
5 files changed, 46 insertions, 41 deletions
diff --git a/include/color.h b/include/color.h index b49ab8d78..def50caa8 100644 --- a/include/color.h +++ b/include/color.h @@ -73,4 +73,8 @@ typedef union{ #define RGBA8(r, g, b, a) ((((r) & 0xFF) << 24) | (((g) & 0xFF) << 16) | (((b) & 0xFF) << 8) | (((a) & 0xFF) << 0)) +#define RGBA16_GET_R(pixel) (((pixel) >> 11) & 0x1F) +#define RGBA16_GET_G(pixel) (((pixel) >> 6) & 0x1F) +#define RGBA16_GET_B(pixel) (((pixel) >> 1) & 0x1F) + #endif diff --git a/include/loadfragment.h b/include/loadfragment.h new file mode 100644 index 000000000..db1f3a322 --- /dev/null +++ b/include/loadfragment.h @@ -0,0 +1,42 @@ +#ifndef LOADFRAGMENT_H +#define LOADFRAGMENT_H + +#include "PR/ultratypes.h" +#include "libc/stdint.h" +#include "libc/stddef.h" + +extern s32 gOverlayLogSeverity; + +#define RELOC_SECTION(reloc) ((reloc) >> 30) +#define RELOC_OFFSET(reloc) ((reloc) & 0xFFFFFF) +#define RELOC_TYPE_MASK(reloc) ((reloc) & 0x3F000000) +#define RELOC_TYPE_SHIFT 24 + +/* MIPS Relocation Types */ +#define R_MIPS_32 2 +#define R_MIPS_26 4 +#define R_MIPS_HI16 5 +#define R_MIPS_LO16 6 + +typedef enum { + /* 0 */ RELOC_SECTION_NULL, + /* 1 */ RELOC_SECTION_TEXT, + /* 2 */ RELOC_SECTION_DATA, + /* 3 */ RELOC_SECTION_RODATA, + /* 4 */ RELOC_SECTION_MAX +} RelocSectionId; + +typedef struct OverlayRelocationSection { + /* 0x00 */ size_t textSize; + /* 0x04 */ size_t dataSize; + /* 0x08 */ size_t rodataSize; + /* 0x0C */ size_t bssSize; + /* 0x10 */ u32 numRelocations; + /* 0x14 */ u32 relocations[1]; // array count is numRelocations +} OverlayRelocationSection; // size >= 0x18 + +// Fragment overlay load functions +size_t Overlay_Load(uintptr_t vromStart, uintptr_t vromEnd, uintptr_t vramStart, uintptr_t vramEnd, void* allocatedRamAddr); +void* Overlay_AllocateAndLoad(uintptr_t vromStart, uintptr_t vromEnd, uintptr_t vramStart, uintptr_t vramEnd); + +#endif diff --git a/include/macros.h b/include/macros.h index 7924066b6..1755a398c 100644 --- a/include/macros.h +++ b/include/macros.h @@ -104,10 +104,6 @@ #define CLAMP_MAX(x, max) ((x) > (max) ? (max) : (x)) #define CLAMP_MIN(x, min) ((x) < (min) ? (min) : (x)) -#define RGBA16_GET_R(pixel) (((pixel) >> 11) & 0x1F) -#define RGBA16_GET_G(pixel) (((pixel) >> 6) & 0x1F) -#define RGBA16_GET_B(pixel) (((pixel) >> 1) & 0x1F) - #define ROUND(x) (s32)(((x) >= 0.0) ? ((x) + 0.5) : ((x) - 0.5)) #define SWAP(type, a, b) \ @@ -118,7 +114,4 @@ } \ (void)0 -#define OVERLAY_RELOCATION_OFFSET(overlayEntry) ((uintptr_t)((overlayEntry)->vramStart) - (uintptr_t)((overlayEntry)->loadedRamAddr)) -#define VRAM_PTR_SIZE(entry) ((uintptr_t)((entry)->vramEnd) - (uintptr_t)((entry)->vramStart)) - #endif // MACROS_H diff --git a/include/variables.h b/include/variables.h index 9882fa0f4..a5d05901f 100644 --- a/include/variables.h +++ b/include/variables.h @@ -35,9 +35,6 @@ extern const char* sCpuExceptions[18]; extern const char* sFpuExceptions[6]; extern FaultDrawer* sFaultDrawContext; extern FaultDrawer sFaultDrawerDefault; -extern s32 gLoadLogSeverity; -extern s32 gLoad2LogSeverity; - // extern UNK_TYPE1 sGfxPrintFontTLUT; // extern UNK_TYPE1 sGfxPrintRainbowTLUT; // extern UNK_TYPE1 sGfxPrintRainbowData; diff --git a/include/z64load.h b/include/z64load.h deleted file mode 100644 index 8570faf25..000000000 --- a/include/z64load.h +++ /dev/null @@ -1,31 +0,0 @@ -#ifndef Z64LOAD_H -#define Z64LOAD_H - -#include "PR/ultratypes.h" - -#define RELOCATE_ADDR(addr, vRamStart, allocu32) ((addr) - (vRamStart) + (allocu32)) - -#define RELOC_SECTION(reloc) ((reloc) >> 30) -#define RELOC_OFFSET(reloc) ((reloc) & 0xFFFFFF) -#define RELOC_TYPE_MASK(reloc) ((reloc) & 0x3F000000) -#define RELOC_TYPE_SHIFT 24 - -/* MIPS Relocation Types */ -#define R_MIPS_32 2 -#define R_MIPS_26 4 -#define R_MIPS_HI16 5 -#define R_MIPS_LO16 6 - -typedef struct { - /* 0x00 */ u32 textSize; - /* 0x04 */ u32 dataSize; - /* 0x08 */ u32 rodataSize; - /* 0x0C */ u32 bssSize; - /* 0x10 */ u32 nRelocations; - /* 0x14 */ u32 relocations[1]; -} OverlayRelocationSection; // size >= 0x18 - -size_t Load2_LoadOverlay(uintptr_t vRomStart, uintptr_t vRomEnd, uintptr_t vRamStart, uintptr_t vRamEnd, void* allocatedVRamAddr); -void* Load2_AllocateAndLoad(uintptr_t vRomStart, uintptr_t vRomEnd, uintptr_t vRamStart, uintptr_t vRamEnd); - -#endif |
