This shows you the differences between two versions of the page.
| — |
yoshis_story:overlay_files [2019/10/04 17:14] (current) shygoo created |
||
|---|---|---|---|
| Line 1: | Line 1: | ||
| + | ====== Overlay Files ====== | ||
| + | Yoshi's Story uses overlays to save memory. The structure of an overlay file is as follows: | ||
| + | <code C> | ||
| + | u8 text[textSize] | ||
| + | u8 data[dataSize] | ||
| + | u8 rodata[rodataSize] | ||
| + | meta { | ||
| + | u32 textSize | ||
| + | u32 dataSize | ||
| + | u32 rodataSize | ||
| + | u32 bssSize | ||
| + | u32 numRelocations | ||
| + | u32 relocations[numRelocations] | ||
| + | } | ||
| + | u32 metaSize | ||
| + | </code> | ||
| + | |||
| + | * The position of the meta section is calculated by subtracting metaSize from the total size of the overlay file. | ||
| + | * The .bss section is allocated immediately after the overlay file in memory. | ||
| + | |||
| + | Relocation bitfields: | ||
| + | <code>ss -- rrrr oooooooooooooooooooooooo</code> | ||
| + | |||
| + | ^Bitfield^Description^ | ||
| + | |s|Section (0 = invalid?, 1 = .text, 2 = .data, 3 = .rodata)| | ||
| + | |-|Unused?| | ||
| + | |r|Relocation type (4 = R_MIPS_26, 5 = R_MIPS_HI16, 6 = R_MIPS_LO16)| | ||
| + | |o|Offset| | ||
| + | |||
| + | The dynamic linker routine is located at 0x80081430 in RAM. | ||
| + | <code C>func_80081430(void *overlay_block, void *meta_section);</code> | ||
| + | |||
| + | The game keeps track of active overlays using an array of the following struct at 0x800DA840 in RAM. | ||
| + | <code C> | ||
| + | struct OverlayEntry | ||
| + | { | ||
| + | /*00*/ void *location; // actual location in memory | ||
| + | /*04*/ u16 objectId; // id of the object that this overlay belongs to | ||
| + | u8 _pad[2]; | ||
| + | /*08*/ void *fakeMemStart; // fake start address | ||
| + | /*0C*/ void *fakeMemEnd; // fake end address | ||
| + | }; | ||
| + | </code> | ||