PAT file

PAT files contain structured data to patch already loaded Z80 code. They're used to replace sound samples address tables originally loaded from Z80 files when different PCM files are loaded.


 * Maximum file size: 2048 bytes ?
 * Type code: 5
 * Loaded into: Z80 code RAM

=Format=

Blocks of 5 word (16 bit) values:


 * Patch address in bytes. $0000 means end of file. All the $0001~$FFFF range seems to work.


 * First data word is (/2), byteswapped and written to address
 * Second data word is (/2)-1, byteswapped written to address + 2
 * Third (optional) data word is (/2), byteswapped and written to address + 5
 * Fourth (optional) data word is (/2)-1, byteswapped written to address + 7

If the third data word is $0000, both the third and fourth patches are skipped.

=Offset=

When loading a PAT file (see loading files) the bank number and destination address parameters can be used to add an offset to all the patched values. This allows PCM data associated with a PAT file to be loaded into different regions of PCM DRAM without the need of multiple PAT files.

Code snippet from the TOP-SP1 system ROM which handles this: