PAT file: Difference between revisions

From NeoGeo Development Wiki
Jump to navigation Jump to search
(Updated incorrect information.)
 
(One intermediate revision by one other user not shown)
Line 1: Line 1:
PAT files contain structured data to patch already loaded [[Z80]] code. They're used to replace [[YM2610#ADPCM|sound samples]] addresses originally loaded from [[Z80 file]]s when different [[PCM file]]s are used.
PAT files contain structured data to patch already loaded [[Z80]] code. They're used to replace [[YM2610#ADPCM|sound samples]] address tables originally loaded from [[Z80 file]]s when different [[PCM file]]s are loaded.


*Maximum file size: ?
* Maximum file size: 2048 bytes ?
*Type code: 5
* Type code: 5
*Loaded into: [[68k]] program [[DRAM]]. Bios then decodes and patches into [[Z80]] RAM
* Loaded into: Z80 code RAM
*Banks: 0


=Format=


=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.


Blocks of 5, 16bit values:
=Offset=


*Patch address (in bytes, all the $0000~$FFFF range seems to work)
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.
*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+4
*Fourth (optional) data word is (/2)-1, byteswapped written to address+6
If third data word is 0x0000 both the third and forth patches are skipped.


When loading a PAT file (see [[Loading files]]) the bank number and destination address vars can be used to alter all data words that are patched. This allows PCM data associated with a PAT file to be loaded into different regions of PCM RAM without the need of multiple PAT files. Code snippet from TOP-SP1 bios that handles this below.
Code snippet from the TOP-SP1 [[system ROM]] which handles this:


<syntaxhighlight>
<syntaxhighlight>
C0BFAE  MOVEQ    #0x0,D0       <-- Clear D0
C0BFAE  MOVEQ    #0x0,D0         Clear D0                 00000000
C0BFB0  MOVE.B  (0x7EDB,A5),D0 <-- Bank number byte to D0
C0BFB0  MOVE.B  (0x7EDB,A5),D0   Bank number byte to D0   000000bb
C0BFB4  SWAP    D0             <-- shift left 16   
C0BFB4  SWAP    D0                                       00bb0000 
C0BFB6  LSL.L    #4,D0         <-- shift left 4
C0BFB6  LSL.L    #4,D0                                     0bb00000
C0BFB8  OR.L    (0x7EF4,A5),D0 <-- 'Logical OR 32bit' Destination address to D0
C0BFB8  OR.L    (0x7EF4,A5),D0   Insert destination addr. 0bbddddd
C0BFBC  LSR.L    #8,D0         <-- shift right 8
C0BFBC  LSR.L    #8,D0                                     000bbddd
C0BFBE  MOVE.W  D0,(0x7736,A5) <-- This word value added to all data words to be patched.
C0BFBE  MOVE.W  D0,(0x7736,A5)   Offset will be:              bddd
</syntaxhighlight>
</syntaxhighlight>


[[Category:CD systems]]
[[Category:CD systems]]

Latest revision as of 16:27, 6 November 2018

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:

C0BFAE  MOVEQ    #0x0,D0          Clear D0                 00000000
C0BFB0  MOVE.B   (0x7EDB,A5),D0   Bank number byte to D0   000000bb
C0BFB4  SWAP     D0                                        00bb0000  
C0BFB6  LSL.L    #4,D0                                     0bb00000
C0BFB8  OR.L     (0x7EF4,A5),D0   Insert destination addr. 0bbddddd
C0BFBC  LSR.L    #8,D0                                     000bbddd
C0BFBE  MOVE.W   D0,(0x7736,A5)   Offset will be:              bddd