jabyengine/docs/Features/auto_lba.md

1.5 KiB

Auto LBA

To support the Auto LBA feature changes need to be applied to the source files and the CD configuration file.

In Code

To use the Auto LBA feature the LBAs first need to be defined in either an enum or enum struct. These need to fit a special pattern. The usage of a namespace is recommended.

__jabyengine_start_lba_request needs to be the first entry while __jabyengine_end_lba_request needs to be the last. Each LBA entry needs to be declared with __jabyengine_request_lba_for followed by the name for the enum entry and the file path on the disk.

namespace Assets {
    enum LBA {
        __jabyengine_start_lba_request
        __jabyengine_request_lba_for(SYSTEM_CNF, "SYSTEM.CNF"),
        __jabyengine_end_lba_request
    };
    __declare_lba_header(LBA);

    namespace {
        void load() {
            printf("LBA: %i, Words: %i\n", lba[LBA::SYSTEM_CNF].lba, lba[LBA::SYSTEM_CNF].size_words);
        }    
    }
}

For CD generation

To automatically fill the LBA values psxcdgen_ex needs to be used. The attribute lba_source automatically fills in the values. It can be used with the XML Main and Overlay tag.

<Track>
    <File    name = "SYSTEM.CNF">System.cnf</File>
    <Main    name = "%PSX_BOOT_FILE%" lba_source = "main.cpp">Application.psexe</Main>
    <Overlay name = "OVL.BIN"         lba_source = "state.cpp">Overlay.state</Overlay>
</Track>