Skip to main content
← PSoXide SDK guides and examples · SDK f2fec1c301f1 · All Cargo features enabled; check feature gates before use.

load_chunk

Function load_chunk 

Source
pub fn load_chunk(
    rd: &mut SectorReader,
    pack_lba: u32,
    chunk_id: u32,
    scratch: &mut [u32; 512],
    dst: &mut [u32],
) -> Option<usize>
Expand description

Stream chunk chunk_id from the pack at pack_lba into dst.

Scans the table for the entry (sector-by-sector through scratch, straddle-safe), verifies the payload fits dst, then seeks to the payload and copies it in whole sectors via scratch. Returns the chunk’s exact byte size, or None (no disc / not found / too big / read error). The payload lands at dst[0] still compressed if the writer compressed it; see load_chunk_decompressed.

Reads only as many sectors as byte_size needs: the table’s padded sector_count could be garbage and looping on it would hang the loader.

I_MASK is VBlank-only while the reads run and back to what it was when this returns. No caching; scan cost is linear in the table, so games loading many chunks should keep their own id table (see module doc).