| Contents |
| Memory Map |
KUSEG KSEG0 KSEG1
00000000h 80000000h A0000000h 2048K Main RAM (first 64K reserved for BIOS)
1F000000h 9F000000h BF000000h 8192K Expansion Region 1 (ROM/RAM)
1F800000h 9F800000h -- 1K Scratchpad (D-Cache used as Fast RAM)
1F801000h 9F801000h BF801000h 8K I/O Ports
1F802000h 9F802000h BF802000h 8K Expansion Region 2 (I/O Ports)
1FA00000h 9FA00000h BFA00000h 2048K Expansion Region 3 (whatever purpose)
1FC00000h 9FC00000h BFC00000h 512K BIOS ROM (Kernel) (4096K max)
FFFE0000h (KSEG2) 0.5K I/O Ports (Cache Control)
|
1024K VRAM (Framebuffers, Textures, Palettes) (plus 2.5KB GPU Cache) 512K Sound RAM (Capture Buffers, ADPCM Data, Reverb Workspace) 0.5K CDROM controller RAM (see CDROM Test commands) 16.5K CDROM controller ROM (Firmware and Bootstrap for MC68HC05 cpu) 32K CDROM Buffer (IC303) (32Kx8) (BUG: only two sectors accessible?) 128K External Memory Card(s) (EEPROMs) |
Address Name Size Privilege Code-Cache Data-Cache 00000000h KUSEG 2048M Kernel/User Yes (Scratchpad) 80000000h KSEG0 512M Kernel Yes (Scratchpad) A0000000h KSEG1 512M Kernel No No C0000000h KSEG2 1024M Kernel (No code) No |
2MB RAM can be mirrored to the first 8MB (strangely, enabled by default) 512K BIOS ROM can be mirrored to the last 4MB (disabled by default) Expansion hardware (if any) may be mirrored within expansion region The seven DMA Control Registers at 1F8010x8h are mirrored to 1F8010xCh |
Memory Error ------> Misalignments
(and probably also KSEG access in User mode)
Bus Error ------> Unused Memory Regions (including Gaps in I/O Region)
(unless RAM/BIOS/Expansion mirrors are mapped to "unused" area)
|
| I/O Map |
1F000000h 80000h Expansion Region (default 512 Kbytes, max 8 MBytes) 1F000000h 100h Expansion ROM Header (IDs and Entrypoints) |
1F800000h 400h Scratchpad (1K Fast RAM) (Data Cache mapped to fixed address) |
1F801000h 4 Expansion 1 Base Address (usually 1F000000h) 1F801004h 4 Expansion 2 Base Address (usually 1F802000h) 1F801008h 4 Expansion 1 Delay/Size (usually 0013243Fh; 512Kbytes 8bit-bus) 1F80100Ch 4 Expansion 3 Delay/Size (usually 00003022h; 1 byte) 1F801010h 4 BIOS ROM Delay/Size (usually 0013243Fh; 512Kbytes 8bit-bus) 1F801014h 4 SPU_DELAY Delay/Size (usually 200931E1h) 1F801018h 4 CDROM_DELAY Delay/Size (usually 00020843h or 00020943h) 1F80101Ch 4 Expansion 2 Delay/Size (usually 00070777h; 128-bytes 8bit-bus) 1F801020h 4 COM_DELAY / COMMON_DELAY (00031125h or 0000132Ch or 00001325h) |
1F801040h 1/4 JOY_DATA Joypad/Memory Card Data (R/W) 1F801044h 4 JOY_STAT Joypad/Memory Card Status (R) 1F801048h 2 JOY_MODE Joypad/Memory Card Mode (R/W) 1F80104Ah 2 JOY_CTRL Joypad/Memory Card Control (R/W) 1F80104Eh 2 JOY_BAUD Joypad/Memory Card Baudrate (R/W) 1F801050h 1/4 SIO_DATA Serial Port Data (R/W) 1F801054h 4 SIO_STAT Serial Port Status (R) 1F801058h 2 SIO_MODE Serial Port Mode (R/W) 1F80105Ah 2 SIO_CTRL Serial Port Control (R/W) 1F80105Ch 2 SIO_MISC Serial Port Internal Register (R/W) 1F80105Eh 2 SIO_BAUD Serial Port Baudrate (R/W) |
1F801060h 4/2 RAM_SIZE (usually 00000B88h; 2MB RAM mirrored in first 8MB) |
1F801070h 2 I_STAT - Interrupt status register 1F801074h 2 I_MASK - Interrupt mask register |
1F80108xh DMA0 channel 0 - MDECin 1F80109xh DMA1 channel 1 - MDECout 1F8010Axh DMA2 channel 2 - GPU (lists + image data) 1F8010Bxh DMA3 channel 3 - CDROM 1F8010Cxh DMA4 channel 4 - SPU 1F8010Dxh DMA5 channel 5 - PIO (Expansion Port) 1F8010Exh DMA6 channel 6 - OTC (reverse clear OT) (GPU related) 1F8010F0h DPCR - DMA Control register 1F8010F4h DICR - DMA Interrupt register 1F8010F8h unknown 1F8010FCh unknown |
1F801100h 2 Timer 0 Current Counter Value (R/W) ;\ 1F801104h 2 Timer 0 Counter Mode (R/W) ; Dotclock 1F801108h 2 Timer 0 Counter Target Value (R/W) ;/ 1F801110h 2 Timer 1 Current Counter Value (R/W) ;\ 1F801114h 2 Timer 1 Counter Mode (R/W) ; Horizontal Retrace 1F801118h 2 Timer 1 Counter Target Value (R/W) ;/ 1F801120h 2 Timer 2 Current Counter Value (R/W) ;\ 1F801124h 2 Timer 2 Counter Mode (R/W) ; 1/8 system clock 1F801128h 2 Timer 2 Counter Target Value (R/W) ;/ |
1F801800h.x.x 1 CD Index/Status Register (Bit0-1 R/W, Bit2-7 Read Only) 1F801801h.R.x 1 CD Response Fifo (R) (usually with Index1) 1F801802h.R.x 1/2 CD Data Fifo - 8bit/16bit (R) (usually with Index0..1) 1F801803h.R.0 1 CD Interrupt Enable Register (R) 1F801803h.R.1 1 CD Interrupt Flag Register (R/W) 1F801803h.R.2 1 CD Interrupt Enable Register (R) (Mirror) 1F801803h.R.3 1 CD Interrupt Flag Register (R/W) (Mirror) 1F801801h.W.0 1 CD Command Register (W) 1F801802h.W.0 1 CD Parameter Fifo (W) 1F801803h.W.0 1 CD Request Register (W) 1F801801h.W.1 1 Unknown/unused 1F801802h.W.1 1 CD Interrupt Enable Register (W) 1F801803h.W.1 1 CD Interrupt Flag Register (R/W) 1F801801h.W.2 1 Unknown/unused 1F801802h.W.2 1 CD Audio Volume for Left-CD-Out to Left-SPU-Input (W) 1F801803h.W.2 1 CD Audio Volume for Left-CD-Out to Right-SPU-Input (W) 1F801801h.W.3 1 CD Audio Volume for Right-CD-Out to Right-SPU-Input (W) 1F801802h.W.3 1 CD Audio Volume for Right-CD-Out to Left-SPU-Input (W) 1F801803h.W.3 1 CD Audio Volume Apply Changes (by writing bit5=1) |
1F801810h.Write 4 GP0 Send GP0 Commands/Packets (Rendering and VRAM Access) 1F801814h.Write 4 GP1 Send GP1 Commands (Display Control) 1F801810h.Read 4 GPUREAD Read responses to GP0(C0h) and GP1(10h) commands 1F801814h.Read 4 GPUSTAT Read GPU Status Register |
1F801820h.Write 4 MDEC Command/Parameter Register (W) 1F801820h.Read 4 MDEC Data/Response Register (R) 1F801824h.Write 4 MDEC Control/Reset Register (W) 1F801824h.Read 4 MDEC Status Register (R) |
1F801C00h+N*10h 2 Voice 0..23 Volume Left 1F801C02h+N*10h 2 Voice 0..23 Volume Right 1F801C04h+N*10h 2 Voice 0..23 ADPCM Sample Rate 1F801C06h+N*10h 2 Voice 0..23 ADPCM Start Address 1F801C08h+N*10h 2+2 Voice 0..23 ADSR Attack/Decay/Sustain/Release 1F801C0Ch+N*10h 2 Voice 0..23 ADSR Current Volume 1F801C0Eh+N*10h 2 Voice 0..23 ADPCM Repeat Address |
1F801D80h 2 Main Volume Left 1F801D82h 2 Main Volume Right 1F801D84h 2+2 Reverb Output Volume Left/Right 1F801D88h 2+2 Voice 0..23 Key ON (Start Attack/Decay/Sustain) (W) 1F801D8Ch 2+2 Voice 0..23 Key OFF (Start Release) (W) 1F801D90h 2+2 Voice 0..23 Channel FM (pitch lfo) mode (R/W) 1F801D94h 2+2 Voice 0..23 Channel Noise mode (R/W) 1F801D98h 2+2 Voice 0..23 Channel Reverb mode (R/W) 1F801D9Ch 2+2 Voice 0..23 Channel ON/OFF (status) (R) 1F801DA0h 2 Unknown? (R) or (W) 1F801DA2h 2 Sound RAM Reverb Work Area Start Address 1F801DA4h 2 Sound RAM IRQ Address 1F801DA6h 2 Sound RAM Data Transfer Address 1F801DA8h 2 Sound RAM Data Transfer Fifo 1F801DAAh 2 SPU Control Register (SPUCNT) 1F801DACh 2 Sound RAM Data Transfer Control 1F801DAEh 2 SPU Status Register (SPUSTAT) (R) 1F801DB0h 2+2 CD Volume Left/Right 1F801DB4h 2+2 Extern Volume Left/Right 1F801DB8h 2+2 Current Main Volume Left/Right 1F801DBCh 2+2 Unknown? (R/W) |
1F801DC0h 2 dAPF1 Reverb APF Offset 1 1F801DC2h 2 dAPF2 Reverb APF Offset 2 1F801DC4h 2 vIIR Reverb Reflection Volume 1 1F801DC6h 2 vCOMB1 Reverb Comb Volume 1 1F801DC8h 2 vCOMB2 Reverb Comb Volume 2 1F801DCAh 2 vCOMB3 Reverb Comb Volume 3 1F801DCCh 2 vCOMB4 Reverb Comb Volume 4 1F801DCEh 2 vWALL Reverb Reflection Volume 2 1F801DD0h 2 vAPF1 Reverb APF Volume 1 1F801DD2h 2 vAPF2 Reverb APF Volume 2 1F801DD4h 4 mSAME Reverb Same Side Reflection Address 1 Left/Right 1F801DD8h 4 mCOMB1 Reverb Comb Address 1 Left/Right 1F801DDCh 4 mCOMB2 Reverb Comb Address 2 Left/Right 1F801DE0h 4 dSAME Reverb Same Side Reflection Address 2 Left/Right 1F801DE4h 4 mDIFF Reverb Different Side Reflection Address 1 Left/Right 1F801DE8h 4 mCOMB3 Reverb Comb Address 3 Left/Right 1F801DECh 4 mCOMB4 Reverb Comb Address 4 Left/Right 1F801DF0h 4 dDIFF Reverb Different Side Reflection Address 2 Left/Right 1F801DF4h 4 mAPF1 Reverb APF Address 1 Left/Right 1F801DF8h 4 mAPF2 Reverb APF Address 2 Left/Right 1F801DFCh 4 vIN Reverb Input Volume Left/Right |
1F801E00h+N*04h 4 Voice 0..23 Current Volume Left/Right 1F801E60h 20h Unknown? (R/W) 1F801E80h 180h Unknown? (Read: FFh-filled) (Unused or Write only?) |
1F802000h 80h Expansion Region (8bit data bus, crashes on 16bit access?) |
1F802020h/1st DUART Mode Register 1.A (R/W) 1F802020h/2nd DUART Mode Register 2.A (R/W) 1F802021h/Read DUART Status Register A (R) 1F802021h/Write DUART Clock Select Register A (W) 1F802022h/Read DUART Toggle Baud Rate Generator Test Mode (Read=Strobe) 1F802022h/Write DUART Command Register A (W) 1F802023h/Read DUART Rx Holding Register A (FIFO) (R) 1F802023h/Write DUART Tx Holding Register A (W) 1F802024h/Read DUART Input Port Change Register (R) 1F802024h/Write DUART Aux. Control Register (W) 1F802025h/Read DUART Interrupt Status Register (R) 1F802025h/Write DUART Interrupt Mask Register (W) 1F802026h/Read DUART Counter/Timer Current Value, Upper/Bit15-8 (R) 1F802026h/Write DUART Counter/Timer Reload Value, Upper/Bit15-8 (W) 1F802027h/Read DUART Counter/Timer Current Value, Lower/Bit7-0 (R) 1F802027h/Write DUART Counter/Timer Reload Value, Lower/Bit7-0 (W) 1F802028h/1st DUART Mode Register 1.B (R/W) 1F802028h/2nd DUART Mode Register 2.B (R/W) 1F802029h/Read DUART Status Register B (R) 1F802029h/Write DUART Clock Select Register B (W) 1F80202Ah/Read DUART Toggle 1X/16X Test Mode (Read=Strobe) 1F80202Ah/Write DUART Command Register B (W) 1F80202Bh/Read DUART Rx Holding Register B (FIFO) (R) 1F80202Bh/Write DUART Tx Holding Register B (W) 1F80202Ch/None DUART Reserved Register (neither R nor W) 1F80202Dh/Read DUART Input Port (R) 1F80202Dh/Write DUART Output Port Configuration Register (W) 1F80202Eh/Read DUART Start Counter Command (Read=Strobe) 1F80202Eh/Write DUART Set Output Port Bits Command (Set means Out=LOW) 1F80202Fh/Read DUART Stop Counter Command (Read=Strobe) 1F80202Fh/Write DUART Reset Output Port Bits Command (Reset means Out=HIGH) |
1F802000h 1 DTL-H2000: ATCONS STAT (R) 1F802002h 1 DTL-H2000: ATCONS DATA (R and W) 1F802004h 2 DTL-H2000: Whatever 16bit data ? 1F802030h 1/4 DTL-H2000: Secondary IRQ10 Flags 1F802032h 1 DTL-H2000: Whatever IRQ Control ? 1F802040h 1 DTL-H2000: Bootmode "Dip switches" (R) 1F802041h 1 PSX: POST (external 7 segment display, indicate BIOS boot status) 1F802042h 1 DTL-H2000: POST/LED (similar to POST) (other addr, 2-digit wide) 1F802070h 1 PS2: POST2 (similar to POST, but PS2 BIOS uses this address) |
1F802060h Emu-Expansion ID1 "E" (R) 1F802061h Emu-Expansion ID2 "X" (R) 1F802062h Emu-Expansion ID3 "P" (R) 1F802063h Emu-Expansion Version (01h) (R) 1F802064h Emu-Expansion Enable1 "O" (R/W) 1F802065h Emu-Expansion Enable2 "N" (R/W) 1F802066h Emu-Expansion Halt (R) 1F802067h Emu-Expansion Turbo Mode Flags (R/W) |
1FA00000h - Not used by BIOS or any PSX games 1FA00000h - POST3 (similar to POST, but PS2 BIOS uses this address) |
1FC00000h 80000h BIOS ROM (512Kbytes) (Reset Entrypoint at BFC00000h) |
FFFE0130h 4 Cache Control |
COP0 System Control Coprocessor - 32 registers (not all used) COP1 N/A COP2 Geometry Transformation Engine (GTE) - 64 registers (most are used) COP3 N/A |
| Graphics Processing Unit (GPU) |
| GPU I/O Ports, DMA Channels, Commands, VRAM |
Port Name Expl. 1F801810h-Write GP0 Send GP0 Commands/Packets (Rendering and VRAM Access) 1F801814h-Write GP1 Send GP1 Commands (Display Control) (and DMA Control) 1F801810h-Read GPUREAD Receive responses to GP0(C0h) and GP1(10h) commands 1F801814h-Read GPUSTAT Receive GPU Status Register |
Channel Recommended for DMA2 in Linked Mode - Sending rendering commands ;GP0(20h..7Fh,E1h..E6h) DMA2 in Continous Mode - VRAM transfers to/from GPU ;GP0(A0h,C0h) DMA6 - Initializing the Link List ;Main RAM |
GP0(00h) - Nop? GP0(01h,02h,80h,A0h,C0h) - Direct VRAM Access GP0(03h) - Timing Control GP0(1Fh) - Interrupt Request (IRQ1) GP0(20h..3Fh) - Render Polygons GP0(40h..5Fh) - Render Lines GP0(60h..7Fh) - Render Rectangles GP0(E1h..E6h) - Rendering Attributes GP1(00h..09h,10h,20h) - Display Control (these via GP1 register) |
Framebuffer(s) ;Usually 2 buffers (Drawing Area, and Display Area) Texture Page(s) ;Required when using Textures Texture Palette(s) ;Required when using 4bit/8bit Textures |
Unit = 4bit 8bit 16bit 24bit Halfwords | Unit = Lines Width = 4096 2048 1024 682.66 1024 | Height = 512 |
| GPU Render Polygon Commands |
1st Color+Command (CcBbGgRrh) 2nd Vertex1 (YyyyXxxxh) 3rd Vertex2 (YyyyXxxxh) 4th Vertex3 (YyyyXxxxh) (5th) Vertex4 (YyyyXxxxh) (if any) |
1st Color+Command (CcBbGgRrh) (color is ignored for raw-textures) 2nd Vertex1 (YyyyXxxxh) 3rd Texcoord1+Palette (ClutYyXxh) 4th Vertex2 (YyyyXxxxh) 5th Texcoord2+Texpage (PageYyXxh) 6th Vertex3 (YyyyXxxxh) 7th Texcoord3 (0000YyXxh) (8th) Vertex4 (YyyyXxxxh) (if any) (9th) Texcoord4 (0000YyXxh) (if any) |
1st Color1+Command (CcBbGgRrh) 2nd Vertex1 (YyyyXxxxh) 3rd Color2 (00BbGgRrh) 4th Vertex2 (YyyyXxxxh) 5th Color3 (00BbGgRrh) 6th Vertex3 (YyyyXxxxh) (7th) Color4 (00BbGgRrh) (if any) (8th) Vertex4 (YyyyXxxxh) (if any) |
1st Color1+Command (CcBbGgRrh) 2nd Vertex1 (YyyyXxxxh) 3rd Texcoord1+Palette (ClutYyXxh) 4th Color2 (00BbGgRrh) 5th Vertex2 (YyyyXxxxh) 6th Texcoord2+Texpage (PageYyXxh) 7th Color3 (00BbGgRrh) 8th Vertex3 (YyyyXxxxh) 9th Texcoord3 (0000YyXxh) (10th) Color4 (00BbGgRrh) (if any) (11th) Vertex4 (YyyyXxxxh) (if any) (12th) Texcoord4 (0000YyXxh) (if any) |
| GPU Render Line Commands |
1st Color+Command (CcBbGgRrh) 2nd Vertex1 (YyyyXxxxh) 3rd Vertex2 (YyyyXxxxh) (...) VertexN (YyyyXxxxh) (poly-line only) (Last) Termination Code (55555555h) (poly-line only) |
1st Color1+Command (CcBbGgRrh) 2nd Vertex1 (YyyyXxxxh) 3rd Color2 (00BbGgRrh) 4th Vertex2 (YyyyXxxxh) (...) ColorN (00BbGgRrh) (poly-line only) (...) VertexN (YyyyXxxxh) (poly-line only) (Last) Termination Code (55555555h) (poly-line only) |
| GPU Render Rectangle Commands |
1st Color+Command (CcBbGgRrh) 2nd Vertex (YyyyXxxxh) (3rd) Width+Height (YsizXsizh) (variable size only) (max 1023x511) |
1st Color+Command (CcBbGgRrh) (color is ignored for raw-textures) 2nd Vertex (YyyyXxxxh) (upper-left edge of the rectangle) 3rd Texcoord+Palette (ClutYyXxh) (see bug on odd/even Texcoord.X values) (4th) Width+Height (YsizXsizh) (variable size only) (max 1023x511) |
if 15bpp then tex_error_mask=3, else tex_error_mask=7 ;4bpp/8bpp/15bpp
if (tex.x AND tex_error_mask)=0 then
tex.x=(tex.x-1) ;1st error
tex.x=(tex.x AND texwindow.mask) OR texwindow.offset ;window
if 4bpp AND (tex.x AND 8)=0 then tex.x=(tex.x+1) AND FFh ;2nd error
else ;no error...
tex.x=(tex.x AND texwindow.mask) OR texwindow.offset ;window
|
| GPU Rendering Attributes |
0-10 X-coordinate (signed, -1024..+1023) 11-15 Not used (usually sign-extension, but ignored by hardware) 16-26 Y-coordinate (signed, -1024..+1023) 26-31 Not used (usually sign-extension, but ignored by hardware) |
0-7 Red (0..FFh) 8-15 Green (0..FFh) 16-23 Blue (0..FFh) 24-31 Command (in first parameter) (don't care in further parameters) |
0-8 Same as GP0(E1h).Bit0-8 (see there) 9-10 Unused (does NOT change GP0(E1h).Bit9-10) 11 Same as GP0(E1h).Bit11 (see there) 12-13 Unused (does NOT change GP0(E1h).Bit12-13) 14-15 Unused (should be 0) |
0-5 CLUT X coordinate bit4-9 (in 16-halfword steps) 6-14 CLUT Y coordinate bit0-8 (in 1-line steps) 15 CLUT Y coordinate bit9 (0=Normal, 1=Upper Mbyte, Open Bus) |
0-3 Texture page X.bit6-9 (N*64) (ie. in 64-halfword steps) ;GPUSTAT.0-3 4 Texture page Y.bit8 (N*256) (ie. 0 or 256) ;GPUSTAT.4 5-6 Semi Transparency (0=B/2+F/2, 1=B+F, 2=B-F, 3=B+F/4) ;GPUSTAT.5-6 7-8 Texture page colors (0=4bit, 1=8bit, 2=15bit, 3=Reserved);GPUSTAT.7-8 9 Dither 24bit to 15bit (0=Off/strip LSBs, 1=Dither Enabled) ;GPUSTAT.9 10 Interlace Drawing (0=All Lines, 1=Inactive Lines) ;GPUSTAT.10 11 Texture page Y.bit9 (0=Normal, 1=Upper Mbyte, Open Bus) ;GPUSTAT.15 12 Textured Rectangle X-Flip (BIOS does set this bit on power-up...?) 13 Textured Rectangle Y-Flip (BIOS does set it equal to GPUSTAT.13...?) 14-23 Not used (should be 0) 24-31 Command (E1h) |
0-4 Texture window Mask X (in 8 pixel steps) 5-9 Texture window Mask Y (in 8 pixel steps) 10-14 Texture window Offset X (in 8 pixel steps) 15-19 Texture window Offset Y (in 8 pixel steps) 20-23 Not used (zero) 24-31 Command (E2h) |
Texcoord = (Texcoord AND (NOT (Mask*8))) OR ((Offset AND Mask)*8) |
0-9 X-coordinate (0..1023) 10-18 Y-coordinate (0..511) ;\on Old 160pin GPU (max 1MB VRAM) 19-23 Not used (zero) ;/ 10-19 Y-coordinate (0..1023) ;\on New 208pin GPU (max 2MB VRAM) 20-23 Not used (zero) ;/(retail consoles have only 1MB though) 24-31 Command (Exh) |
0-10 X-offset (-1024..+1023) (usually within X1,X2 of Drawing Area) 11-21 Y-offset (-1024..+1023) (usually within Y1,Y2 of Drawing Area) 22-23 Not used (zero) 24-31 Command (E5h) |
0 Set mask while drawing (0=TextureBit15, 1=ForceBit15=1) ;GPUSTAT.11 1 Check mask before draw (0=Draw Always, 1=Draw if Bit15=0) ;GPUSTAT.12 2-23 Not used (zero) 24-31 Command (E6h) |
| GPU Memory Transfer Commands |
1st Command (Cc000000h) |
1st Color+Command (CcBbGgRrh) ;24bit RGB value (see note) 2nd Top Left Corner (YyyyXxxxh) ;Xpos counted in halfwords, steps of 10h 3rd Width+Height (YsizXsizh) ;Xsiz counted in halfwords, steps of 10h |
1st Command (Cc000000h) 2nd Source Coord (YyyyXxxxh) ;Xpos counted in halfwords 3rd Destination Coord (YyyyXxxxh) ;Xpos counted in halfwords 4th Width+Height (YsizXsizh) ;Xsiz counted in halfwords |
1st Command (Cc000000h) 2nd Destination Coord (YyyyXxxxh) ;Xpos counted in halfwords 3rd Width+Height (YsizXsizh) ;Xsiz counted in halfwords ... Data (...) <--- usually transferred via DMA |
1st Command (Cc000000h) ;\ 2nd Source Coord (YyyyXxxxh) ; write to GP0 port (as usually) 3rd Width+Height (YsizXsizh) ;/ ... Data (...) ;<--- read from GPUREAD port (or via DMA) |
Xpos=(Xpos AND 3F0h) ;range 0..3F0h, in steps of 10h Ypos=(Ypos AND 1FFh) ;range 0..1FFh Xsiz=((Xsiz AND 3FFh)+0Fh) AND (NOT 0Fh) ;range 0..400h, in steps of 10h Ysiz=((Ysiz AND 1FFh)) ;range 0..1FFh |
Xpos=(Xpos AND 3FFh) ;range 0..3FFh Ypos=(Ypos AND 1FFh) ;range 0..1FFh Xsiz=((Xsiz-1) AND 3FFh)+1 ;range 1..400h Ysiz=((Ysiz-1) AND 1FFh)+1 ;range 1..200h |
| GPU Other Commands |
1st Command (Cc000000h) ;GPUSTAT.24 |
1st Command (Cc00000xh) |
Still unknown details... - measure clock cycles and try to determine any relation to pixels/texels - scope test memory access signals - verify if default is 00h/01h |
| GPU Display Control Commands (GP1) |
0-23 Not used (zero) |
GP1(01h) ;clear fifo GP1(02h) ;ack irq (0) GP1(03h) ;display off (1) GP1(04h) ;dma off (0) GP1(05h) ;display address (0) GP1(06h) ;display x1,x2 (x1=200h, x2=200h+256*10) GP1(07h) ;display y1,y2 (y1=010h, y2=010h+240) GP1(08h) ;display mode 320x200 NTSC (0) GP0(E1h..E6h) ;rendering attributes (0) ... XXX probably also GP0(01h) clear cache? |
0-23 Not used (zero) |
0-23 Not used (zero) ;GPUSTAT.24 |
0 Display On/Off (0=On, 1=Off, show black pixels) ;GPUSTAT.23 1-23 Not used (zero) |
0-1 DMA Direction / Data Request mode (0..3) ;GPUSTAT.29-30 2-23 Not used (zero) |
0 = Off (bit25 is always 0=No DRQ) 1 = To GPU, drq when FIFO at least galf empty 2 = To GPU, drq when FIFO empty ;Same as GPUSTAT.28 3 = From GPU ;Same as GPUSTAT.27 |
0-9 X (0-1023) (halfword address in VRAM) (relative to begin of VRAM) 10-18 Y (0-511) (scanline number in VRAM) (relative to begin of VRAM) 19-23 Not used (zero) |
0-11 X1 (260h+0) ;12bit ;\counted in 53.222400MHz units, 12-23 X2 (260h+320*8) ;12bit ;/relative to HSYNC |
0-9 Y1 (NTSC=88h-(224/2), (PAL=A3h-(264/2)) ;\scanline numbers on screen, 10-19 Y2 (NTSC=88h+(224/2), (PAL=A3h+(264/2)) ;/relative to VSYNC 20-23 Not used (zero) |
0-1 Horizontal Resolution 1 (0=256, 1=320, 2=512, 3=640) ;GPUSTAT.17-18 2 Vertical Resolution (0=240, 1=480, when Bit5=1) ;GPUSTAT.19 3 Video Mode (0=NTSC/60Hz, 1=PAL/50Hz) ;GPUSTAT.20 4 Display Area Color Depth (0=15bit, 1=24bit) ;GPUSTAT.21 5 Vertical Interlace (0=Off, 1=On) ;GPUSTAT.22 6 Horizontal Resolution 2 (0=256/320/512/640, 1=368) ;GPUSTAT.16 7 "Reverseflag" (0=Normal, 1=Distorted) ;GPUSTAT.14 8-23 Not used (zero) |
0-23 Select Information which is to be retrieved (via following GPUREAD) |
00h-01h = Returns Nothing (old value in GPUREAD remains unchanged) 02h = Read Texture Window setting ;GP0(E2h) ;20bit/MSBs=Nothing 03h = Read Draw area top left ;GP0(E3h) ;19bit/MSBs=Nothing 04h = Read Draw area bottom right ;GP0(E4h) ;19bit/MSBs=Nothing 05h = Read Draw offset ;GP0(E5h) ;22bit 06h-07h = Returns Nothing (old value in GPUREAD remains unchanged) 08h-FFFFFFh = Mirrors of 00h..07h |
00h-01h = Returns Nothing (old value in GPUREAD remains unchanged) 02h = Read Texture Window setting ;GP0(E2h) ;20bit/MSBs=Nothing 03h = Read Draw area top left ;GP0(E3h) ;20bit/MSBs=Nothing 04h = Read Draw area bottom right ;GP0(E4h) ;20bit/MSBs=Nothing 05h = Read Draw offset ;GP0(E5h) ;22bit 06h = Returns Nothing (old value in GPUREAD remains unchanged) 07h = Read GPU Type (usually 2) ;see "GPU Versions" chapter 08h = Unknown (Returns 00000000h) (lightgun on some GPUs?) 09h-0Fh = Returns Nothing (old value in GPUREAD remains unchanged) 10h-FFFFFFh = Mirrors of 00h..0Fh |
0 VRAM Size (0=1MByte/normal, 1=2MByte/upper half is open bus) 1-23 Unknown/unused |
0-23 VRAM Size? (501h=Normal, 504h=2MByte Mode, or so?) |
0-10 Unknown (GPU crashes after a while when set to 274h..7FFh) 11-23 Unknown (seems to have no effect) |
| GPU Status Register |
0-3 Texture page X.bit6-9 (N*64) ;GP0(E1h).0-3
4 Texture page Y.bit8 (N*256) (ie. 0 or 256) ;GP0(E1h).4
5-6 Semi Transparency (0=B/2+F/2, 1=B+F, 2=B-F, 3=B+F/4) ;GP0(E1h).5-6
7-8 Texture page colors (0=4bit, 1=8bit, 2=15bit, 3=Reserved)GP0(E1h).7-8
9 Dither 24bit to 15bit (0=Off/strip LSBs, 1=Dither Enabled);GP0(E1h).9
10 Interlace Drawing (0=All Lines, 1=Inactive Lines) ;GP0(E1h).10
11 Set Mask-bit when drawing pixels (0=No, 1=Yes/Mask) ;GP0(E6h).0
12 Draw Pixels (0=Always, 1=Not to Masked areas) ;GP0(E6h).1
13 Interlace Field (or, always 1 when GP1(08h).5=0)
14 "Reverseflag" (0=Normal, 1=Distorted) ;GP1(08h).7
15 Texture page Y.bit9 (0=Normal, 1=Upper Mbyte, Open Bus) ;GP0(E1h).11
16 Horizontal Resolution 2 (0=256/320/512/640, 1=368) ;GP1(08h).6
17-18 Horizontal Resolution 1 (0=256, 1=320, 2=512, 3=640) ;GP1(08h).0-1
19 Vertical Resolution (0=240, 1=480, when Bit22=1) ;GP1(08h).2
20 Video Mode (0=NTSC/60Hz, 1=PAL/50Hz) ;GP1(08h).3
21 Display Area Color Depth (0=15bit, 1=24bit) ;GP1(08h).4
22 Vertical Interlace (0=Off, 1=On) ;GP1(08h).5
23 Display Enable (0=Enabled, 1=Disabled) ;GP1(03h).0
24 Interrupt Request (IRQ1) (0=Off, 1=IRQ) ;GP0(1Fh)/GP1(02h)
25 DMA / Data Request (0=No DRQ, 1=DRQ)
Meaning of the DRQ bit depends on GP1(04h) DMA Direction:
When GP1(04h)=0 ---> Off (bit25 is always 0=No DRQ)
When GP1(04h)=1 ---> To GPU, drq when FIFO at least galf empty
When GP1(04h)=2 ---> To GPU, drq when FIFO empty ;Same as GPUSTAT.28
When GP1(04h)=3 ---> From GPU ;Same as GPUSTAT.27
26 Ready to receive Cmd Word (0=No, 1=Ready) ;GP0(...) ;via GP0
27 Read FIFO data available (0=No, 1=Yes) ;GP0(C0h) ;via GPUREAD
28 Write FIFO empty (0=No, 1=Empty) ;GP0(...) ;via GP0
29-30 DMA Direction (0=Off, 1=?, 2=CPUtoGP0, 3=GPUREADtoCPU) ;GP1(04h).0-1
31 Drawing even/odd lines in interlace mode (0=Even or Vblank, 1=Odd)
|
Bit28: Write FIFO empty Bit27: Data available for reading Bit26: Ready to receive Cmd Word Bit25: DRQ (when GP1(04h)=1 --> Write FIFO not more than half full) |
XXX basically: Bit28 seems to be just "FIFO Empty"
(and the above corner cases rely on which commands are removing
data from fifo "befure/during/after" command execution)
|
| GPU Versions |
Differences... Old 160pin GPU New 208pin GPU GPU Chip CXD8514Q CXD8561Q/BQ/CQ/CXD9500Q Mainboard EARLY-PU-8 and below LATE-PU-8 and up Memory Type Dual-ported VRAM Normal DRAM Write Buffer None (1 halfword) Yes (18 halfwords) Write Speed Slow (with pauses) Fast (continous) GPUSTAT.13 when interlace=off Always 0 Always 1 GPUSTAT.14 Always 0 Reverseflag GPUSTAT.15 Always 0 Texture page Y.bit9 GP1(10h:index3..4) 19bit (1MB VRAM) 20bit (2MB VRAM) GP1(10h:index7) N/A 00000002h version GP1(10h:index8) Mirror of index0 00000000h zero GP1(10h:index9..F) Mirror of index1..7 N/A GP1(20h) Whatever? used for detecting old gpu GP0(E1h).bit12/13 without x/y-flip with x/y-flip GP0(03h) N/A not stored in fifo Timing control Shaded Textures ((color/8)*texel)/2 (color*texel)/16 GP0(02h) FillVram xpos.bit0-3=0Fh=bugged xpos.bit0-3=ignored dma-to-vram: doesn't work with blksiz>10h (new gpu works with blksiz=8C0h!) dma-to-vram: MAYBE also needs extra software-handshake to confirm DMA done? 320*224 pix = 11800h pix = 8C00h words GP0(80h) VramToVram works Freeze on large moves? |
[1F801814h]=10000004h ;GP1(10h).index4 (latch draw area bottom right) [1F801814h]=10000007h ;GP1(10h).index7 (latch GPU version, if any) if ([1F801810h] AND 00FFFFFFh)=00000002h then goto @@gpu_v2 [1F801810h]=([1F801814h] AND 3FFFh) OR E1001000h ;change GPUSTAT via GP0(E1h) dummy=[1F801810h] ;dummy read (unknown purpose) if ([1F801814h] AND 00001000h) then goto @@gpu_v1 else goto @@gpu_v0 ;--- @@gpu_v0: ;Old 160pin GPU (EARLY-PU-8) return 0 ;--- @@gpu_v1: ;unknown GPU type, maybe some custom arcade/prototype version ? if want_2mbyte_vram then [1F801814h]=20000504h ;GP1(20h) return 1 ;--- @@gpu_v2: ;New 208pin GPU (LATE-PU-8 and up) if want_2mbyte_vram then [1F801814h]=09000001h ;GP1(09h) return 2 |
0h 10h 20h 30h 40h
| | | | |
################################ ;\x=00h..0Eh
################################ ; and, x=0Fh
################################ ; on NEW GPU
################################ ;/
# # # # # # # ################## # # # # # # # ;\
# # # # # # # ################## # # # # # # # ; x=0Fh
# # # # # # # ################## # # # # # # # ; on OLD GPU
# # # # # # # ################## # # # # # # # ;/
################################ ;\x=10h..1Eh
################################ ; and, x=1Fh
################################ ; on NEW GPU
################################ ;/
# # # # # # # ################## # # # # # # # ;\
# # # # # # # ################## # # # # # # # ; x=1Fh
# # # # # # # ################## # # # # # # # ; on OLD GPU
# # # # # # # ################## # # # # # # # ;/
|
IC21 - 208pin - "SONY CXD8538Q" ;seen on GP-11 (namco System 11) boards IC103 - 208pin - "SONY CXD8654Q" ;seen on GP-15 (namco System 12) boards |
| GPU Depth Ordering |
DPCR - enable bits ;Example=x8xxxxxxh D6_MADR - pointer to the LAST table entry ;Example=8012300Ch D6_BCR - number of list entries ;Example=00000004h D6_CHCR - control bits (should be 11000002h) ;Example=11000002h |
[80123000h]=00FFFFFFh ;1st entry, points to end code (xxFFFFFFh) [80123004h]=00123000h ;2nd entry, points to 1st entry [80123008h]=00123004h ;3rd entry, points to 2nd entry [8012300Ch]=00123008h ;last entry, points to 3rd entry (table entrypoint) |
[PacketAddr+0] = [80123000h+OTZ*4] + (N SHL 24) <--internal link chain [PacketAddr+4..N*4] = GP0 Command(s) and Parameters <--data (send to GP0) [80123000h+OTZ*4] = PacketAddr AND FFFFFFh <--internal link chain |
1 - Wait until GPU is ready to receive commands ;GPUSTAT.28 2 - Enable DMA channel 2 ;DPCR 3 - Set GPU to DMA cpu->gpu mode ;[GP1]=04000002h aka GP1(04h) 3 - Set D2_MADR to the start of the list ;(LAST Entry) ;Example=80123010h 4 - Set D2_BCR to zero ;(length unused, end at END-CODE) 5 - Set D2_CHCR to link mode, mem->GPU and dma enable ;=01000401h |
| GPU Video Memory (VRAM) |
Resolution 16bit 24bit | Resolution 16bit 24bit 256x240 120Kbytes 180Kbytes | 256x480 240Kbytes 360Kbytes 320x240 150Kbytes 225Kbytes | 320x480 300Kbytes 450Kbytes 368x240 xx0Kbytes xx0Kbytes | 368x480 xx0Kbytes xx0Kbytes 512x240 240Kbytes 360Kbytes | 512x480 480Kbytes 720Kbytes 640x240 300Kbytes 450Kbytes | 640x480 600Kbytes 900Kbytes |
15bit Direct Display (default) (works with polygons, lines, rectangles) 0-4 Red (0..31) 5-9 Green (0..31) 10-14 Blue (0..31) 15 Mask flag (0=Normal, 1=Do not allow to overwrite this pixel) 24bit Direct Display (works ONLY with direct vram transfers) 0-7 Red (0..255) 8-15 Green (0..255) 16-23 Blue (0..255) |
16bit Texture (Direct Color) ;(One 256x256 page = 128Kbytes) 0-4 Red (0..31) ;\Color 0000h = Fully-Transparent 5-9 Green (0..31) ; Color 0001h..7FFFh = Non-Transparent 10-14 Blue (0..31) ; Color 8000h..FFFFh = Semi-Transparent (*) 15 Semi Transparency Flag ;/(*) or Non-Transparent for opaque commands 8bit Texture (256 Color Palette) ;(One 256x256 page = 64Kbytes) 0-7 Palette index for 1st pixel (left) 8-15 Palette index for 2nd pixel (right) 4bit Texture (16 Color Palette) ;(One 256x256 page = 32Kbytes) 0-3 Palette index for 1st pixel (left) 4-7 Palette index for 2nd pixel (middle/left) 8-11 Palette index for 3rd pixel (middle/right) 12-15 Palette index for 4th pixel (right) |
0-4 Red (0..31) ;\Color 0000h = Fully-Transparent 5-9 Green (0..31) ; Color 0001h..7FFFh = Non-Transparent 10-14 Blue (0..31) ; Color 8000h..FFFFh = Semi-Transparent (*) 15 Semi Transparency Flag ;/(*) or Non-Transparent for opaque commands |
opaque command, eg. GP0(24h) --> 8000h = Non-Transparent Black semi-transp command, eg. GP0(26h) --> 8000h = Semi-Transparent Black |
Intensity PC PSX Minimum 0 0 Medium (circa) 16 8 Maximum 31 31 |
| GPU (MISC) |
0-23 Color for (first) Vertex (Not for Raw-Texture) 24 Texture Mode (0=Blended, 1=Raw) (Textured-Polygon/Rect only) 25 Semi Transparency (0=Off, 1=On) (All Render Types) 26 Texture Mapping (0=Off, 1=On) (Polygon/Rectangle only) 27-28 Rect Size (0=Var, 1=1x1, 2=8x8, 3=16x16) (Rectangle only) 27 Num Vertices (0=Triple, 1=Quad) (Polygon only) 27 Num Lines (0=Single, 1=Poly) (Line only) 28 Shading (0=Flat, 1=Gouroud) (Polygon/Line only) 29-31 Primitive Type (1=Polygon, 2=Line, 3=Rectangle) |
PSX (triangles) Better (real quad) Best (perspective) Unrotated
_. _. _.
_.-' | _.-' | _.-' |
_.-: | _.-: | _.-' |
.-' | | .-' | | .-' | | ____ ____
| | | | | | | | | | | |
| _.-:-._ | | | | | | | | | |
:-' | '-: :-----+-----: :---+-------: :----+----:
| | | | | | | | | | | |
| | | | | | | | | |____|____|
'-._ | | '-._ | | '-._| |
'-:_ | '-:_ | '-._ |
'-._| '-._| '-._|
|
-4 +0 -3 +1 ;\dither offsets for first two scanlines +2 -2 +3 -1 ;/ -3 +1 -4 +0 ;\dither offsets for next two scanlines +3 -1 +2 -2 ;/(same as above, but shifted two pixels horizontally) |
B=Back (the old pixel read from the image in the frame buffer)
F=Front (the new halftransparent pixel)
0.5 x B + 0.5 x F ;aka B/2+F/2
1.0 x B + 1.0 x F ;aka B+F
1.0 x B - 1.0 x F ;aka B-F
1.0 x B +0.25 x F ;aka B+F/4
|
| GPU FIFO |
fifo_rd_index = (rd_ptr) AND 0Fh ;\4bit range fifo_wr_index = (wr_ptr) AND 0Fh ;/ fifo_size = (wr_ptr-rd_ptr) AND 1Fh ;-5bit range fifo_not_more_than_half_full = cleared when fifo_size=09h..1Fh ;\drq flags fifo_empty = cleared when fifo_size=01h..1Fh ;/ |
NOP,INVALID,DRAWBASE,DRAWAREA,MASKBITS 1 word (and executed right away) TEXPAGE,TEXWINDOW,FLUSHCACHE,IRQ,REFRESH 1 word (but not yet executed) POLY, LINE 0 words (none) RECT (fixed size, without texture) 1 words (not all parameters) RECT (variable size, or with texture) 2 words (not all parameters) VRAM FILL 2 words (not all parameters) VRAM-to-VRAM, CPU-to-VRAM, VRAM-to-CPU 1 word (not all parameters) |
RECT ;-GPU gets busy NOP ;\ NOP ; these are (almost) immediately REMOVED from FIFO NOP ; (even when RECT is still busy) NOP ;/ TEXPAGE ;-removed from FIFO, but not executed until RECT is done NOP ;\ NOP ; these are KEPT in FIFO NOP ; (until RECT is done, and TEXPAGE is executed) NOP ;/ |
| GPU Texture Caching |
One line with 16 halfwords (shared for 4bpp/8bpp color 00h..0Fh) One line with 240 halfwords (solely used for 8bpp color 10h..FFh) |
Updates whole 16 or 256 colors even when drawing tiny 1x1 pix RECTs Updates even if the RECT isn't drawn because outside of the Drawing Area |
15bpp 32x32 pixels ;\arranged as 32x32 halfwords (shared cache mode) 8bpp 64x32 pixels ;/ 4bpp 64x64 pixels ;-arranged as 16x64 halfwords (other cache mode) |
8bpp/15bpp: Line = X AND 1Ch, Y AND 1Fh 4bpp: Line = X AND 0Ch, Y AND 3Fh Accordingly, coordinates 0,0 and 20h,0 are using the same cache line (and thus cannot be cached simultaneously). |
Executing any VRAM COPY command: GP0(80h,A0h,C0h) (but not VRAM FILL command) Changing TexPage Base X,Y Changing TexPage between 4bpp and Non-4bpp mode |
For lines with EVEN screen.vertex.x: At begin of scanline store 16+1 halfwords in write buffer, drain 16 halfwords In middle of scanline store 16 new halfwords, drain 16 halfwords At end of scanline store remaining N halfwords, drain N+1 halfwords For lines with ODD screen.vertex.x: At begin of scanline store 16+1 halfwords in write buffer, drain 15 halfwords In middle of scanline store 16 new halfwords, drain 16 halfwords At end of scanline store remaining N halfwords, drain N+1(+1) halfwords |
| GPU Display Timings |
CPU Clock = 33.868800MHz (44100Hz*300h) Video Clock = 53.222400MHz (44100Hz*300h*11/7) |
PAL: 314 scanlines per frame (13Ah) NTSC: 263 scanlines per frame (107h) |
PAL: 3406 video cycles per scanline (or 3406.1 or so?) NTSC: 3413 video cycles per scanline (or 3413.6 or so?) |
PSX.256-pix Dotclock = 5.322240MHz (44100Hz*300h*11/7/10) PSX.320-pix Dotclock = 6.652800MHz (44100Hz*300h*11/7/8) PSX.368-pix Dotclock = 7.603200MHz (44100Hz*300h*11/7/7) PSX.512-pix Dotclock = 10.644480MHz (44100Hz*300h*11/7/5) PSX.640-pix Dotclock = 13.305600MHz (44100Hz*300h*11/7/4) Namco GunCon 385-pix = 8.000000MHz (from 8.00MHz on lightgun PCB) |
320pix/PAL: 3406/8 = 425.75 dots 320pix/NTSC: 3413/8 = 426.625 dots 640pix/PAL: 3406/4 = 851.5 dots 640pix/NTSC: 3413/4 = 853.25 dots 256pix/PAL: 3406/10 = 340.6 dots 256pix/NTSC: 3413/10 = 341.3 dots 512pix/PAL: 3406/5 = 681.2 dots 512pix/NTSC: 3413/5 = 682.6 dots 368pix/PAL: 3406/7 = 486.5714 dots 368pix/NTSC: 3413/7 = 487.5714 dots |
PAL: 53.222400MHz/314/3406 = ca. 49.76 Hz (ie. almost 50Hz) NTSC: 53.222400MHz/263/3413 = ca. 59.29 Hz (ie. almost 60Hz) |
| GPU Rendering Timings |
_________________________________ Rectangles _________________________________ |
1.00 clks per any-scanline (even if outside of draw area y1,y2) 5.00 clks per scanline ;\ 0.50 clks per pixel, when non-fully-transp ;\without ; 0.25 clks per pixel, when fully-transp ;/semi-transp ; Old GPU 1.00 clks per pixel-read, when non-fully-transp ;\with ; 0.00 clks per pixel-read, when fully-transp ; semi ; 0.50 clks per pixel-write ;/ ;/ 3.50 clks per scanline, when width=1 ;\ ;\ 2.50 clks per scanline, when width=2..3 ; without ; 2.00 clks per scanline, when width=4..5 ; semi-transp ; New GPU 1.50 clks per scanline, when width=6..7 ; ; 1.00 clks per scanline, when width>=8 ;/ ; 6.00 clks per scanline ;\with ; 3.75 clks per 16pix chunk ;/semi-transp ; 0.50 clks per pixel, when non-fully-transp ; 0.25 clks per pixel, when fully-transp (color 0000h) ;/ and... extra time per cache-misses (when textured) |
__________________________________ Polygons __________________________________ |
3-point Poly (one triangle) --> precalc + render 4-point Poly (two triangles) --> precalc + render + precalc + render |
10.00 clks per triangle, base cycles ;\ 90.00 clks per triangle, extra cycles when textured ; precalc 150.00 clks per triangle, extra cycles when gouraud shaded ;/ 1.00 clks per any-scanline (even if outside of draw area y1,y2) 4.75 clks per scanline, without semi ;\ 5.50 clks per scanline, with semi ; 3.00 clks per pixel, with semi, with gouraud/texture ; Old GPU 1.50 clks per pixel, with semi, without gouraud/texture ; 1.00 clks per pixel, without semi, with gouraud/texture ; 0.50 clks per pixel, without semi, without gouraud/texture;/ 1.00 clks per scanline, without semi ;\ 2.00 clks per scanline, with semi, with gouraud/texture ; 5.25 clks per scanline, with semi, without gouraud/texture; New GPU 2.00 clks per scanline, when width=1 ;\ ; 1.50 clks per scanline, when width=2 ; without ; 1.25 clks per scanline, when width=3 ; semi-transp, ; 0.75 clks per scanline, when width=4..5 ; and without ; 0.50 clks per scanline, when width=6..7 ; gouraud/tex ; 0.00 clks per scanline, when width>=8 ;/ ; 3.75 clks per 16pix chunk, with semi, without gouraud/tex ; 1.00 clks per pixel, with gouraud/texture ; 0.50 clks per pixel, without gouraud/texture ;/ and... extra time per cache-misses (when textured) |
___________________________________ Lines ____________________________________ |
40.00 clks per line segment, base cycles ;\precalc 60.00 clks per line segment, extra cycles when gouraud shaded ;/ 1.00 clks per pixel, base time for horizontal lines ;\ 2.00 clks per pixel, base time for non-horizontal lines ; pixels 2.00 clks per pixel, extra when Old GPU with semi-transp ;/ 0.00 clks per offscreen-scanline (outside of draw area y1,y2) 0.00 clks per scanline, when 0..5' (flat) ;\ ?? clks per scanline, when 5..44' ; Old GPU 5.00 clks per scanline, when 45..90' (steep) ;/ 2.00 clks per scanline, when 0..30' (flat) ;\ 2.00 clks per scanline, when 40' without semi-transp ; ?? clks per scanline, when 40' with semi-transp ; New GPU 2.50 clks per scanline, when 45..90' (steep) without semi ; 5.50 clks per scanline, when 45..90' (steep) with semi-transp ;/ |
______________________________ Memory Transfers ______________________________ |
1.00 clks per 16 pixels 7.00 clks per scanline, when xsiz>0, on Old GPU 5.00 clks per scanline, when xsiz>0, on New GPU 1.00 clks per scanline, when xsiz=0, should never happen in practice |
1.50 clks per pixel, without Mask Check ;\ 2.50 clks per pixel, with Mask Check ; Old GPU 2.50 clks per scanline ;/ 1.25 clks per pixel, without Mask Check ;\ 1.50 clks per pixel, with Mask Check, when width<16 ; 1.00 clks per pixel, with Mask Check, when width>=16 ; New GPU 19.50 clks per scanline, without Mask Check ; 22.25 clks per scanline, with Mask Check, when width<16 ; 25.50 clks per 16pix chunk, with Mask Check, when width>=16 ;/ |
1.00 clks per pixel, without Mask Check ;\Old GPU 1.50 clks per pixel, with Mask Check ;/ 1.00 clks per pixel, with/without Mask Check ;-New GPU plus some overload per scanline/chunk |
1.50 clks per pixel ;-Old GPU 1.00 clks per pixel ;-New GPU plus some overload per scanline/chunk (especially on New GPU) |
____________________________ Additional Overload _____________________________ |
16.00 clks when loading 16-color CLUT (color 00h..0Fh) 256.00 clks when loading 256-color CLUT (color 00h..FFh) |
8.25 clks for 16bpp, with/without semi-transparency ;-without CLUT 10.00 clks for 4bpp/8bpp, without semi-transparency ;\with CLUT 11.00 clks for 4bpp/8bpp, with semi-transparency ;/ |
Rect 3x128 rendering with GP0(03h)=0Fh is about 4x slower than GP0(03h)=0 Rect 512x128 rendering time is constant, no matter of GP0(03h) (in the latter case, refresh probably occurs inbetween write buffer draining) |
XXX Todo: add some examples for Rects/Polys at different resolutions |
___________________________________ Notes ____________________________________ |
| Geometry Transformation Engine (GTE) |
| GTE Overview |
mov cop0r12,rt ;-enable/disable COP2 (GTE) via COP0 status register mov cop2r0-63,rt ;\write parameters to GTE registers mov cop2r0-31,[rs+imm] ;/ mov cop2cmd,imm25 ;-issue GTE command mov rt,cop2r0-63 ;\read results from GTE registers mov [rs+imm],cop2r0-31 ;/ jt cop2flg,dest ;-jump never ;\implemented (no exception), but, jf cop2flg,dest ;-jump always ;/flag seems to be always "false" |
- Delay slots of jumps and branches - Event handlers or interrupts (sounds like nonsense?) (need push/pop though) |
31-25 Must be 0100101b for "COP2 imm25" instructions 20-24 Fake GTE Command Number (00h..1Fh) (ignored by hardware) 19 sf - Shift Fraction in IR registers (0=No fraction, 1=12bit fraction) 17-18 MVMVA Multiply Matrix (0=Rotation. 1=Light, 2=Color, 3=Reserved) 15-16 MVMVA Multiply Vector (0=V0, 1=V1, 2=V2, 3=IR/long) 13-14 MVMVA Translation Vector (0=TR, 1=BK, 2=FC/Bugged, 3=None) 11-12 Always zero (ignored by hardware) 10 lm - Saturate IR1,IR2,IR3 result (0=To -8000h..+7FFFh, 1=To 0..+7FFFh) 6-9 Always zero (ignored by hardware) 0-5 Real GTE Command Number (00h..3Fh) (used by hardware) |
cop2r0-1 3xS16 VXY0,VZ0 Vector 0 (X,Y,Z) cop2r2-3 3xS16 VXY1,VZ1 Vector 1 (X,Y,Z) cop2r4-5 3xS16 VXY2,VZ2 Vector 2 (X,Y,Z) cop2r6 4xU8 RGBC Color/code value cop2r7 1xU16 OTZ Average Z value (for Ordering Table) cop2r8 1xS16 IR0 16bit Accumulator (Interpolate) cop2r9-11 3xS16 IR1,IR2,IR3 16bit Accumulator (Vector) cop2r12-15 6xS16 SXY0,SXY1,SXY2,SXYP Screen XY-coordinate FIFO (3 stages) cop2r16-19 4xU16 SZ0,SZ1,SZ2,SZ3 Screen Z-coordinate FIFO (4 stages) cop2r20-22 12xU8 RGB0,RGB1,RGB2 Color CRGB-code/color FIFO (3 stages) cop2r23 4xU8 (RES1) Prohibited cop2r24 1xS32 MAC0 32bit Maths Accumulators (Value) cop2r25-27 3xS32 MAC1,MAC2,MAC3 32bit Maths Accumulators (Vector) cop2r28-29 1xU15 IRGB,ORGB Convert RGB Color (48bit vs 15bit) cop2r30-31 2xS32 LZCS,LZCR Count Leading-Zeroes/Ones (sign bits) |
cop2r32-36 9xS16 RT11RT12,..,RT33 Rotation matrix (3x3) ;cnt0-4 cop2r37-39 3x 32 TRX,TRY,TRZ Translation vector (X,Y,Z) ;cnt5-7 cop2r40-44 9xS16 L11L12,..,L33 Light source matrix (3x3) ;cnt8-12 cop2r45-47 3x 32 RBK,GBK,BBK Background color (R,G,B) ;cnt13-15 cop2r48-52 9xS16 LR1LR2,..,LB3 Light color matrix source (3x3) ;cnt16-20 cop2r53-55 3x 32 RFC,GFC,BFC Far color (R,G,B) ;cnt21-23 cop2r56-57 2x 32 OFX,OFY Screen offset (X,Y) ;cnt24-25 cop2r58 BuggyU16 H Projection plane distance. ;cnt26 cop2r59 S16 DQA Depth queing parameter A (coeff) ;cnt27 cop2r60 32 DQB Depth queing parameter B (offset);cnt28 cop2r61-62 2xS16 ZSF3,ZSF4 Average Z scale factors ;cnt29-30 cop2r63 U20 FLAG Returns any calculation errors ;cnt31 |
| GTE Registers |
Rotation matrix (RT) Light matrix (LLM) Light Color matrix (LCM) cop2r32.lsbs=RT11 cop2r40.lsbs=L11 cop2r48.lsbs=LR1 cop2r32.msbs=RT12 cop2r40.msbs=L12 cop2r48.msbs=LR2 cop2r33.lsbs=RT13 cop2r41.lsbs=L13 cop2r49.lsbs=LR3 cop2r33.msbs=RT21 cop2r41.msbs=L21 cop2r49.msbs=LG1 cop2r34.lsbs=RT22 cop2r42.lsbs=L22 cop2r50.lsbs=LG2 cop2r34.msbs=RT23 cop2r42.msbs=L23 cop2r50.msbs=LG3 cop2r35.lsbs=RT31 cop2r43.lsbs=L31 cop2r51.lsbs=LB1 cop2r35.msbs=RT32 cop2r43.msbs=L32 cop2r51.msbs=LB2 cop2r36 =RT33 cop2r44 =L33 cop2r52 =LB3 |
cop2r37 (cnt5) - TRX - Translation vector X (R/W?) cop2r38 (cnt6) - TRY - Translation vector Y (R/W?) cop2r39 (cnt7) - TRZ - Translation vector Z (R/W?) |
cop2r45 (cnt13) - RBK - Background color red component cop2r46 (cnt14) - GBK - Background color green component cop2r47 (cnt15) - BBK - Background color blue component |
cop2r53 (cnt21) - RFC - Far color red component cop2r54 (cnt22) - GFC - Far color green component cop2r55 (cnt23) - BFC - Far color blue component |
cop2r56 (cnt24) - OFX - Screen offset X cop2r57 (cnt25) - OFY - Screen offset Y cop2r58 (cnt26) - H - Projection plane distance cop2r59 (cnt27) - DQA - Depth queing parameter A.(coeff.) cop2r60 (cnt28) - DQB - Depth queing parameter B.(offset.) |
cop2r61 (cnt29) ZSF3 | 0|ZSF3 1,3,12| Z3 average scale factor (normally 1/3) cop2r62 (cnt30) ZSF4 | 0|ZSF4 1,3,12| Z4 average scale factor (normally 1/4) cop2r7 OTZ (R) | |OTZ 0,15, 0| Average Z value (for Ordering Table) |
cop2r12 - SXY0 rw|SY0 1,15, 0|SX0 1,15, 0| Screen XY fifo (older) cop2r13 - SXY1 rw|SY1 1,15, 0|SX1 1,15, 0| Screen XY fifo (old) cop2r14 - SXY2 rw|SY2 1,15, 0|SX2 1,15, 0| Screen XY fifo (new) cop2r15 - SXYP rw|SYP 1,15, 0|SXP 1,15, 0| SXY2-mirror with move-on-write cop2r16 - SZ0 rw| 0|SZ0 0,16, 0| Screen Z fifo (oldest) cop2r17 - SZ1 rw| 0|SZ1 0,16, 0| Screen Z fifo (older) cop2r18 - SZ2 rw| 0|SZ2 0,16, 0| Screen Z fifo (old) cop2r19 - SZ3 rw| 0|SZ3 0,16, 0| Screen Z fifo (new) |
Vector 0 (V0) Vector 1 (V1) Vector 2 (V2) Vector 3 (IR) cop2r0.lsbs - VX0 cop2r2.lsbs - VX1 cop2r4.lsbs - VX2 cop2r9 - IR1 cop2r0.msbs - VY0 cop2r2.msbs - VY1 cop2r4.msbs - VY2 cop2r10 - IR2 cop2r1 - VZ0 cop2r3 - VZ1 cop2r5 - VZ2 cop2r11 - IR3 |
cop2r6 - RGBC rw|CODE |B |G |R | Color/code cop2r20 - RGB0 rw|CD0 |B0 |G0 |R0 | Characteristic color fifo. cop2r21 - RGB1 rw|CD1 |B1 |G1 |R1 | cop2r22 - RGB2 rw|CD2 |B2 |G2 |R2 | cop2r23 - (RES1) | | Prohibited |
cop2r8 IR0 rw|Sign |IR0 1, 3,12| Intermediate value 0. |
cop2r24 MAC0 rw|MAC0 1,31,0 | Sum of products value 0 |
cop2r25 MAC1 rw|MAC1 1,31,0 | Sum of products value 1 cop2r26 MAC2 rw|MAC2 1,31,0 | Sum of products value 2 cop2r27 MAC3 rw|MAC3 1,31,0 | Sum of products value 3 |
0-4 Red (0..1Fh) (R/W) ;multiplied by 80h, and written to IR1 5-9 Green (0..1Fh) (R/W) ;multiplied by 80h, and written to IR2 10-14 Blue (0..1Fh) (R/W) ;multiplied by 80h, and written to IR3 15-31 Not used (always zero) (Read only) |
0-4 Red (0..1Fh) (R) ;IR1 divided by 80h, saturated to +00h..+1Fh 5-9 Green (0..1Fh) (R) ;IR2 divided by 80h, saturated to +00h..+1Fh 10-14 Blue (0..1Fh) (R) ;IR3 divided by 80h, saturated to +00h..+1Fh 15-31 Not used (always zero) (Read only) |
| GTE Saturation |
31 Error Flag (Bit30..23, and 18..13 ORed together) (Read only) 30 MAC1 Result positive 44bit overflow (max +7FFFFFFFFFFh) ;\triggered 29 MAC2 Result positive 44bit overflow (max +7FFFFFFFFFFh) ; during 28 MAC3 Result positive 44bit overflow (max +7FFFFFFFFFFh) ; calculations 27 MAC1 Result negative 44bit overflow (min -80000000000h) ; 26 MAC2 Result negative 44bit overflow (min -80000000000h) ; 25 MAC3 Result negative 44bit overflow (min -80000000000h) ;/ 24 IR1 saturated to +0000h..+7FFFh (lm=1) or to -8000h..+7FFFh (lm=0) 23 IR2 saturated to +0000h..+7FFFh (lm=1) or to -8000h..+7FFFh (lm=0) 22 IR3 saturated to +0000h..+7FFFh (lm=1) or to -8000h..+7FFFh (lm=0) 21 Color-FIFO-R saturated to +00h..+FFh 20 Color-FIFO-G saturated to +00h..+FFh 19 Color-FIFO-B saturated to +00h..+FFh 18 SZ3 or OTZ saturated to +0000h..+FFFFh 17 Divide overflow. RTPS/RTPT division result saturated to max=1FFFFh 16 MAC0 Result positive 32bit overflow (max +7FFFFFFFh) ;\triggered on 15 MAC0 Result negative 32bit overflow (min -80000000h) ;/final result 14 SX2 saturated to -0400h..+03FFh 13 SY2 saturated to -0400h..+03FFh 12 IR0 saturated to +0000h..+1000h 0-11 Not used (always zero) (Read only) |
| GTE Opcode Summary |
Opc Name Clk Expl. 00h - N/A (modifies similar registers than RTPS...) 01h RTPS 15 Perspective Transformation single 0xh - N/A 06h NCLIP 8 Normal clipping 0xh - N/A 0Ch OP(sf) 6 Outer product of 2 vectors 0xh - N/A 10h DPCS 8 Depth Cueing single 11h INTPL 8 Interpolation of a vector and far color vector 12h MVMVA(..) 8 Multiply vector by matrix and add vector (see below) 13h NCDS 19 Normal color depth cue single vector 14h CDP 13 Color Depth Que 15h - N/A 16h NCDT 44 Normal color depth cue triple vectors 1xh - N/A 1Bh NCCS 17 Normal Color Color single vector 1Ch CC 11 Color Color 1Dh - N/A 1Eh NCS 14 Normal color single 1Fh - N/A 20h NCT 30 Normal color triple 2xh - N/A 28h SQR(sf) 5 Square of vector IR 29h DCPL 8 Depth Cue Color light 2Ah DPCT 17 Depth Cueing triple (should be fake=08h, but isn't) 2xh - N/A 2Dh AVSZ3 5 Average of three Z values 2Eh AVSZ4 6 Average of four Z values 2Fh - N/A 30h RTPT 23 Perspective Transformation triple 3xh - N/A 3Dh GPF(sf) 5 General purpose interpolation 3Eh GPL(sf) 5 General purpose interpolation with base 3Fh NCCT 39 Normal Color Color triple vector |
Fake Name Clk Expl. 00h - N/A 01h RTPS 15 Perspective Transformation single 02h RTPT 23 Perspective Transformation triple 03h - N/A 04h MVMVA(..) 8 Multiply vector by matrix and add vector (see below) 05h - N/A 06h DCPL 8 Depth Cue Color light 07h DPCS 8 Depth Cueing single 08h DPCT 17 Depth Cueing triple (should be fake=08h, but isn't) 09h INTPL 8 Interpolation of a vector and far color vector 0Ah SQR(sf) 5 Square of vector IR 0Bh - N/A 0Ch NCS 14 Normal color single 0Dh NCT 30 Normal color triple 0Eh NCDS 19 Normal color depth cue single vector 0Fh NCDT 44 Normal color depth cue triple vectors 10h NCCS 17 Normal Color Color single vector 11h NCCT 39 Normal Color Color triple vector 12h CDP 13 Color Depth Que 13h CC 11 Color Color 14h NCLIP 8 Normal clipping 15h AVSZ3 5 Average of three Z values 16h AVSZ4 6 Average of four Z values 17h OP(sf) 6 Outer product of 2 vectors 18h - N/A 19h GPF(sf) 5 General purpose interpolation 1Ah GPL(sf) 5 General purpose interpolation with base 1Bh - N/A 1Ch - N/A 1Dh - N/A 1Eh - N/A 1Fh - N/A |
RTPS macro dw $0000007f (01x40) RTPT macro dw $000000bf (02x40) DCPL macro dw $00000dff (37x40) DPCS macro dw $00000e3f (38x40) DPCT macro dw $00000e7f (39x40) INTPL macro dw $00000ebf (3Ax40) NCS macro dw $00000f7f (3Dx40) NCT macro dw $00000fbf (3Ex40) NCDS macro dw $00000fff (3Fx40) NCDT macro dw $0000103f (40x40) NCCS macro dw $0000107f (41x40) NCCT macro dw $000010bf (42x40) CDP macro dw $000010ff (43x40) CC macro dw $0000113f (44x40) NCLIP macro dw $0000117f (45x40) AVSZ3 macro dw $000011bf (46x40) AVSZ4 macro dw $000011ff (47x40) MVMVA macro sf,mx,v,cv,lm dw $000013bf|sf<<25|mx<<23|v<<21|cv<<19|lm<<18 SQR macro sf dw $000013ff|sf<<25 (4Fx40) OP macro sf dw $0000143f|sf<<25 (50x40) GPF macro sf dw $0000147f|sf<<25 (51x40) GPL macro sf dw $000014bf|sf<<25 (52x40) |
| GTE Coordinate Calculation Commands |
IR1 = MAC1 = (TRX*1000h + RT11*VX0 + RT12*VY0 + RT13*VZ0) SAR (sf*12) IR2 = MAC2 = (TRY*1000h + RT21*VX0 + RT22*VY0 + RT23*VZ0) SAR (sf*12) IR3 = MAC3 = (TRZ*1000h + RT31*VX0 + RT32*VY0 + RT33*VZ0) SAR (sf*12) SZ3 = MAC3 SAR ((1-sf)*12) ;ScreenZ FIFO 0..+FFFFh MAC0=(((H*20000h/SZ3)+1)/2)*IR1+OFX, SX2=MAC0/10000h ;ScrX FIFO -400h..+3FFh MAC0=(((H*20000h/SZ3)+1)/2)*IR2+OFY, SY2=MAC0/10000h ;ScrY FIFO -400h..+3FFh MAC0=(((H*20000h/SZ3)+1)/2)*DQA+DQB, IR0=MAC0/1000h ;Depth cueing 0..+1000h |
IR1,IR2,IR3 are saturated according to lm, but without setting FLAG.22 on IR3 FLAG.22 is set when SZ3 exceeds -8000h..+7FFFh FLAG.18 is set when SZ3 exceeds 0000h..+FFFFh (and SZ3 is staturate as so). For RTPT, the DQA,DQB,IR0 calculation is done ONLY for 3rd vertex (V2) FLAG.12 is thus set only on last vertex (ie for RTPT: on V2) |
MAC0 = SX0*SY1 + SX1*SY2 + SX2*SY0 - SX0*SY2 - SX1*SY0 - SX2*SY1 ;slow |
MAC0 = SX0*(SY1-SY2) + SX1*(SY2-SY0) + SX2*(SY0-SY1) ;fast |
MAC0 = ZSF3*(SZ1+SZ2+SZ3) ;for AVSZ3 MAC0 = ZSF4*(SZ0+SZ1+SZ2+SZ3) ;for AVSZ4 OTZ = MAC0/1000h ;for both (saturated to 0..FFFFh) |
| GTE General Purpose Calculation Commands |
Mx = matrix specified by mx ;RT/LLM/LCM - Rotation, light or color matrix Vx = vector specified by v ;V0, V1, V2, or [IR1,IR2,IR3] Tx = translation vector specified by cv ;TR or BK or Bugged/FC, or None |
MAC1 = (Tx1*1000h + Mx11*Vx1 + Mx12*Vx2 + Mx13*Vx3) SAR (sf*12) MAC2 = (Tx2*1000h + Mx21*Vx1 + Mx22*Vx2 + Mx23*Vx3) SAR (sf*12) MAC3 = (Tx3*1000h + Mx31*Vx1 + Mx32*Vx2 + Mx33*Vx3) SAR (sf*12) [IR1,IR2,IR3] = [MAC1,MAC2,MAC3] |
IR1 = MAC1 = (Tx1*1000h + Mx11*Vx1) SAR (sf*12) ;part1, saturate as if lm=0 IR1 = MAC1 = (Mx12*Vx2 + Mx13*Vx3) SAR (sf*12) ;part2, saturate by lm |
[MAC1,MAC2,MAC3] = [IR1*IR1,IR2*IR2,IR3*IR3] SHR (sf*12) [IR1,IR2,IR3] = [MAC1,MAC2,MAC3] ;IR1,IR2,IR3 saturated to max 7FFFh |
[MAC1,MAC2,MAC3] = [IR3*D2-IR2*D3, IR1*D3-IR3*D1, IR2*D1-IR1*D2] SAR (sf*12) [IR1,IR2,IR3] = [MAC1,MAC2,MAC3] ;copy result |
| GTE Color Calculation Commands |
[IR1,IR2,IR3] = [MAC1,MAC2,MAC3] = (LLM*V0) SAR (sf*12) [IR1,IR2,IR3] = [MAC1,MAC2,MAC3] = (BK*1000h + LCM*IR) SAR (sf*12) [MAC1,MAC2,MAC3] = [R*IR1,G*IR2,B*IR3] SHL 4 ;<--- for NCDx/NCCx [MAC1,MAC2,MAC3] = MAC+(FC-MAC)*IR0 ;<--- for NCDx only [MAC1,MAC2,MAC3] = [MAC1,MAC2,MAC3] SAR (sf*12) ;<--- for NCDx/NCCx Color FIFO = [MAC1/16,MAC2/16,MAC3/16,CODE], [IR1,IR2,IR3] = [MAC1,MAC2,MAC3] |
[IR1,IR2,IR3] = [MAC1,MAC2,MAC3] = (BK*1000h + LCM*IR) SAR (sf*12) [MAC1,MAC2,MAC3] = [R*IR1,G*IR2,B*IR3] SHL 4 [MAC1,MAC2,MAC3] = MAC+(FC-MAC)*IR0 ;<--- for CDP only [MAC1,MAC2,MAC3] = [MAC1,MAC2,MAC3] SAR (sf*12) Color FIFO = [MAC1/16,MAC2/16,MAC3/16,CODE], [IR1,IR2,IR3] = [MAC1,MAC2,MAC3] |
[MAC1,MAC2,MAC3] = [R*IR1,G*IR2,B*IR3] SHL 4 ;<--- for DCPL only [MAC1,MAC2,MAC3] = [IR1,IR2,IR3] SHL 12 ;<--- for INTPL only [MAC1,MAC2,MAC3] = [R,G,B] SHL 16 ;<--- for DPCS/DPCT [MAC1,MAC2,MAC3] = MAC+(FC-MAC)*IR0 [MAC1,MAC2,MAC3] = [MAC1,MAC2,MAC3] SAR (sf*12) Color FIFO = [MAC1/16,MAC2/16,MAC3/16,CODE], [IR1,IR2,IR3] = [MAC1,MAC2,MAC3] |
[MAC1,MAC2,MAC3] = [0,0,0] ;<--- for GPF only [MAC1,MAC2,MAC3] = [MAC1,MAC2,MAC3] SHL (sf*12) ;<--- for GPL only [MAC1,MAC2,MAC3] = (([IR1,IR2,IR3] * IR0) + [MAC1,MAC2,MAC3]) SAR (sf*12) Color FIFO = [MAC1/16,MAC2/16,MAC3/16,CODE], [IR1,IR2,IR3] = [MAC1,MAC2,MAC3] |
[IR1,IR2,IR3] = (([RFC,GFC,BFC] SHL 12) - [MAC1,MAC2,MAC3]) SAR (sf*12) [MAC1,MAC2,MAC3] = (([IR1,IR2,IR3] * IR0) + [MAC1,MAC2,MAC3]) |
| GTE Division Inaccuracy |
n = (((H*20000h/SZ3)+1)/2) |
n = ((H*10000h+SZ3/2)/SZ3) |
if n>1FFFFh or division_by_zero then n=1FFFFh, FLAG.Bit17=1, FLAG.Bit31=1 |
if (H < SZ3*2) then ;check if overflow
z = count_leading_zeroes(SZ3) ;z=0..0Fh (for 16bit SZ3)
n = (H SHL z) ;n=0..7FFF8000h
d = (SZ3 SHL z) ;d=8000h..FFFFh
u = unr_table[(d-7FC0h) SHR 7] + 101h ;u=200h..101h
d = ((2000080h - (d * u)) SHR 8) ;d=10000h..0FF01h
d = ((0000080h + (d * u)) SHR 8) ;d=20000h..10000h
n = min(1FFFFh, (((n*d) + 8000h) SHR 16)) ;n=0..1FFFFh
else n = 1FFFFh, FLAG.Bit17=1, FLAG.Bit31=1 ;n=1FFFFh plus overflow flag
|
FFh,FDh,FBh,F9h,F7h,F5h,F3h,F1h,EFh,EEh,ECh,EAh,E8h,E6h,E4h,E3h ;\ E1h,DFh,DDh,DCh,DAh,D8h,D6h,D5h,D3h,D1h,D0h,CEh,CDh,CBh,C9h,C8h ; 00h..3Fh C6h,C5h,C3h,C1h,C0h,BEh,BDh,BBh,BAh,B8h,B7h,B5h,B4h,B2h,B1h,B0h ; AEh,ADh,ABh,AAh,A9h,A7h,A6h,A4h,A3h,A2h,A0h,9Fh,9Eh,9Ch,9Bh,9Ah ;/ 99h,97h,96h,95h,94h,92h,91h,90h,8Fh,8Dh,8Ch,8Bh,8Ah,89h,87h,86h ;\ 85h,84h,83h,82h,81h,7Fh,7Eh,7Dh,7Ch,7Bh,7Ah,79h,78h,77h,75h,74h ; 40h..7Fh 73h,72h,71h,70h,6Fh,6Eh,6Dh,6Ch,6Bh,6Ah,69h,68h,67h,66h,65h,64h ; 63h,62h,61h,60h,5Fh,5Eh,5Dh,5Dh,5Ch,5Bh,5Ah,59h,58h,57h,56h,55h ;/ 54h,53h,53h,52h,51h,50h,4Fh,4Eh,4Dh,4Dh,4Ch,4Bh,4Ah,49h,48h,48h ;\ 47h,46h,45h,44h,43h,43h,42h,41h,40h,3Fh,3Fh,3Eh,3Dh,3Ch,3Ch,3Bh ; 80h..BFh 3Ah,39h,39h,38h,37h,36h,36h,35h,34h,33h,33h,32h,31h,31h,30h,2Fh ; 2Eh,2Eh,2Dh,2Ch,2Ch,2Bh,2Ah,2Ah,29h,28h,28h,27h,26h,26h,25h,24h ;/ 24h,23h,22h,22h,21h,20h,20h,1Fh,1Eh,1Eh,1Dh,1Dh,1Ch,1Bh,1Bh,1Ah ;\ 19h,19h,18h,18h,17h,16h,16h,15h,15h,14h,14h,13h,12h,12h,11h,11h ; C0h..FFh 10h,0Fh,0Fh,0Eh,0Eh,0Dh,0Dh,0Ch,0Ch,0Bh,0Ah,0Ah,09h,09h,08h,08h ; 07h,07h,06h,06h,05h,05h,04h,04h,03h,03h,02h,02h,01h,01h,00h,00h ;/ 00h ;<-- one extra table entry (for "(d-7FC0h)/80h"=100h) ;-100h |
| Macroblock Decoder (MDEC) |
| MDEC I/O Ports |
31-0 Command or Parameters |
31-0 Macroblock Data (or Garbage if there's no data available) |
31 Data-Out Fifo Empty (0=No, 1=Empty) 30 Data-In Fifo Full (0=No, 1=Full, or Last word received) 29 Command Busy (0=Ready, 1=Busy receiving or processing parameters) 28 Data-In Request (set when DMA0 enabled and ready to receive data) 27 Data-Out Request (set when DMA1 enabled and ready to send data) 26-25 Data Output Depth (0=4bit, 1=8bit, 2=24bit, 3=15bit) ;CMD.28-27 24 Data Output Signed (0=Unsigned, 1=Signed) ;CMD.26 23 Data Output Bit15 (0=Clear, 1=Set) (for 15bit depth only) ;CMD.25 22-19 Not used (seems to be always zero) 18-16 Current Block (0..3=Y1..Y4, 4=Cr, 5=Cb) (or for mono: always 4=Y) 15-0 Number of Parameter Words remaining minus 1 (FFFFh=None) ;CMD.Bit0-15 |
31 Reset MDEC (0=No change, 1=Abort any command, and set status=80040000h) 30 Enable Data-In Request (0=Disable, 1=Enable DMA0 and Status.bit28) 29 Enable Data-Out Request (0=Disable, 1=Enable DMA1 and Status.bit27) 28-0 Unknown/Not used - usually zero |
1) DMA3 (CDROM) to send Huffman compressed data from CDROM to RAM 2) CPU (MIPS) to convert Huffman bitstream to 16bit MDEC RLE values 3) DMA0 (MDEC.In) to send MDEC compressed data from RAM to MDEC 4) DMA1 (MDEC.Out) to send uncompressed macroblocks from MDEC to RAM 5) DMA2 (GPU) to send uncompressed macroblocks from RAM to GPU |
| MDEC Commands |
31-29 Command (1=decode_macroblock) 28-27 Data Output Depth (0=4bit, 1=8bit, 2=24bit, 3=15bit) ;STAT.26-25 26 Data Output Signed (0=Unsigned, 1=Signed) ;STAT.24 25 Data Output Bit15 (0=Clear, 1=Set) (for 15bit depth only) ;STAT.23 24-16 Not used (should be zero) 15-0 Number of Parameter Words (size of compressed data) |
31-29 Command (2=set_iqtab) 28-1 Not used (should be zero) ;Bit25-28 are copied to STAT.23-26 though 0 Color (0=Luminance only, 1=Luminance and Color) |
31-29 Command (3=set_scale) 28-0 Not used (should be zero) ;Bit25-28 are copied to STAT.23-26 though |
| MDEC Decompression |
rl_decode_block(Crblk,src,iq_uv) ;Cr (low resolution) rl_decode_block(Cbblk,src,iq_uv) ;Cb (low resolution) rl_decode_block(Yblk,src,iq_y), yuv_to_rgb(0,0) ;Y1 (and upper-left Cr,Cb) rl_decode_block(Yblk,src,iq_y), yuv_to_rgb(0,8) ;Y2 (and upper-right Cr,Cb) rl_decode_block(Yblk,src,iq_y), yuv_to_rgb(8,0) ;Y3 (and lower-left Cr,Cb) rl_decode_block(Yblk,src,iq_y), yuv_to_rgb(8,8) ;Y4 (and lower-right Cr,Cb) |
rl_decode_block(Yblk,src,iq_y), y_to_mono ;Y |
for i=0 to 63, blk[i]=0, next i ;initially zerofill all entries (for skip) @@skip: n=[src], src=src+2, k=0 ;get first entry, init dest addr k=0 if n=FE00h then @@skip ;ignore padding (FE00h as first halfword) q_scale=(n SHR 10) AND 3Fh ;contains scale value (not "skip" value) val=signed10bit(n AND 3FFh)*qt[k] ;calc first value (without q_scale/8) (?) @@lop: if q_scale=0 then val=signed10bit(n AND 3FFh)*2 ;special mode without qt[k] val=minmax(val,-400h,+3FFh) ;saturate to signed 11bit range val=val*scalezag[i] ;<-- for "fast_idct_core" only if q_scale>0 then blk[zagzig[k]]=val ;store entry (normal case) if q_scale=0 then blk[k]=val ;store entry (special, no zigzag) n=[src], src=src+2 ;get next entry (or FE00h end code) k=k+((n SHR 10) AND 3Fh)+1 ;skip zerofilled entries val=(signed10bit(n AND 3FFh)*qt[k]*q_scale+4)/8 ;calc value for next entry if k<=63 then jump @@lop ;should end with n=FE00h (that sets k>63) idct_core(blk) return (with "src" address advanced) |
src=blk, dst=temp_buffer
for pass=0 to 1
for i=0 to 7
if src[(1..7)*8+i]=0 then ;when src[(1..7)*8+i] are all zero:
dst[i*8+(0..7)]=src[0*8+i] ;quick fill by src[0*8+i]
else
z10=src[0*8+i]+src[4*8+i], z11=src[0*8+i]-src[4*8+i]
z13=src[2*8+i]+src[6*8+i], z12=src[2*8+i]-src[6*8+i]
z12=(1.414213562*z12)-z13 ;=sqrt(2)
tmp0=z10+z13, tmp3=z10-z13, tmp1=z11+z12, tmp2=z11-z12
z13=src[3*8+i]+src[5*8+i], z10=src[3*8+i]-src[5*8+i]
z11=src[1*8+i]+src[7*8+i], z12=src[1*8+i]-src[7*8+i]
z5 =(1.847759065*(z12-z10)) ;=sqrt(2)*scalefactor[2]
tmp7=z11+z13
tmp6=(2.613125930*(z10))+z5-tmp7 ;=scalefactor[2]*2
tmp5=(1.414213562*(z11-z13))-tmp6 ;=sqrt(2)
tmp4=(1.082392200*(z12))-z5+tmp5 ;=sqrt(2)/scalefactor[2]
dst[i*8+0]=tmp0+tmp7, dst[i*8+7]=tmp0-tmp7
dst[i*8+1]=tmp1+tmp6, dst[i*8+6]=tmp1-tmp6
dst[i*8+2]=tmp2+tmp5, dst[i*8+5]=tmp2-tmp5
dst[i*8+4]=tmp3+tmp4, dst[i*8+3]=tmp3-tmp4
endif
next i
swap(src,dst)
next pass
|
src=blk, dst=temp_buffer
for pass=0 to 1
for x=0 to 7
for y=0 to 7
sum=0
for z=0 to 7
sum=sum+src[y+z*8]*(scaletable[x+z*8]/8)
next z
dst[x+y*8]=(sum+0fffh)/2000h ;<-- or so?
next y
next x
swap(src,dst)
next pass
|
for y=0 to 7
for x=0 to 7
R=[Crblk+((x+xx)/2)+((y+yy)/2)*8], B=[Cbblk+((x+xx)/2)+((y+yy)/2)*8]
G=(-0.3437*B)+(-0.7143*R), R=(1.402*R), B=(1.772*B)
Y=[Yblk+(x)+(y)*8]
R=MinMax(-128,127,(Y+R))
G=MinMax(-128,127,(Y+G))
B=MinMax(-128,127,(Y+B))
if unsigned then BGR=BGR xor 808080h ;aka add 128 to the R,G,B values
dst[(x+xx)+(y+yy)*16]=BGR
next x
next y
|
for i=0 to 63
Y=[Yblk+i]
Y=Y AND 1FFh ;clip to signed 9bit range
Y=MinMax(-128,127,Y) ;saturate from 9bit to signed 8bit range
if unsigned then Y=Y xor 80h ;aka add 128 to the Y value
dst[i]=Y
next i
|
iqtab_core(iq_y,src), src=src+64 ;luminance quant table
if command_word.bit0=1
iqtab_core(iq_uv,src), src=src+64 ;color quant table (optional)
endif
|
for i=0 to 63, iq[i]=src[i], next i |
1.000000000, 1.387039845, 1.306562965, 1.175875602, 1.000000000, 0.785694958, 0.541196100, 0.275899379 |
0 ,1 ,5 ,6 ,14,15,27,28, 2 ,4 ,7 ,13,16,26,29,42, 3 ,8 ,12,17,25,30,41,43, 9 ,11,18,24,31,40,44,53, 10,19,23,32,39,45,52,54, 20,22,33,38,46,51,55,60, 21,34,37,47,50,56,59,61, 35,36,48,49,57,58,62,63 |
for y=0 to 7
for x=0 to 7
scalezag[zigzag[x+y*8]] = scalefactor[x] * scalefactor[y] / 8
next x
next y
|
for i=0 to 63, zagzig[zigzag[i]]=i, next i |
02h,10h,10h,13h,10h,13h,16h,16h 16h,16h,16h,16h,1Ah,18h,1Ah,1Bh 1Bh,1Bh,1Ah,1Ah,1Ah,1Ah,1Bh,1Bh 1Bh,1Dh,1Dh,1Dh,22h,22h,22h,1Dh 1Dh,1Dh,1Bh,1Bh,1Dh,1Dh,20h,20h 22h,22h,25h,26h,25h,23h,23h,22h 23h,26h,26h,28h,28h,28h,30h,30h 2Eh,2Eh,38h,38h,3Ah,45h,45h,53h |
5A82 5A82 5A82 5A82 5A82 5A82 5A82 5A82 7D8A 6A6D 471C 18F8 E707 B8E3 9592 8275 7641 30FB CF04 89BE 89BE CF04 30FB 7641 6A6D E707 8275 B8E3 471C 7D8A 18F8 9592 5A82 A57D A57D 5A82 5A82 A57D A57D 5A82 471C 8275 18F8 6A6D 9592 E707 7D8A B8E3 30FB 89BE 7641 CF04 CF04 7641 89BE 30FB 18F8 B8E3 6A6D 8275 7D8A 9592 471C E707 |
+s0 +s0 +s0 +s0 +s0 +s0 +s0 +s0 +s1 +s3 +s5 +s7 -s7 -s5 -s3 -s1 +s2 +s6 -s6 -s2 -s2 -s6 +s6 +s2 +s3 -s7 -s1 -s5 +s5 +s1 +s7 -s3 +s4 -s4 -s4 +s4 +s4 -s4 -s4 +s4 +s5 -s1 +s7 +s3 -s3 -s7 +s1 -s5 +s6 -s2 +s2 -s6 -s6 +s2 -s2 +s6 +s7 -s5 +s3 -s1 +s1 -s3 +s5 -s7 |
| MDEC Data Format |
.-----. .-----. .-----. .-----. | | | | |Y1|Y2| | | | Cr | + | Cb | + |--+--| ----> | RGB | | | | | |Y3|Y4| | | '-----' '-----' '-----' '-----' |
.--. .--. |Y | ----> |Y | '--' '--' |
DCT ;1 halfword RLE,RLE,RLE,etc. ;0..63 halfwords EOB ;1 halfword |
15-10 Q Quantization factor (6 bits, unsigned) 9-0 DC Direct Current reference (10 bits, signed) |
15-10 LEN Number of zero AC values to be inserted (6 bits, unsigned) 9-0 AC Relative AC value (10 bits, signed) |
15-0 End-code (Fixed, FE00h) |
| Sound Processing Unit (SPU) |
| SPU Overview |
1F801C00h..1F801D7Fh - Voice 0..23 Registers (eight 16bit regs per voice) 1F801D80h..1F801D87h - SPU Control (volume) 1F801D88h..1F801D9Fh - Voice 0..23 Flags (six 1bit flags per voice) 1F801DA2h..1F801DBFh - SPU Control (memory, control, etc.) 1F801DC0h..1F801DFFh - Reverb configuration area 1F801E00h..1F801E5Fh - Voice 0..23 Internal Registers 1F801E60h..1F801E7Fh - Unknown? 1F801E80h..1F801FFFh - Unused? |
00000h-003FFh CD Audio left (1Kbyte) ;\CD Audio before Volume processing 00400h-007FFh CD Audio right (1Kbyte) ;/signed 16bit samples at 44.1kHz 00800h-00BFFh Voice 1 mono (1Kbyte) ;\Voice 1 and 3 after ADSR processing 00C00h-00FFFh Voice 3 mono (1Kbyte) ;/signed 16bit samples at 44.1kHz 01000h-xxxxxh ADPCM Samples (first 16bytes usually contain a Sine wave) xxxxxh-7FFFFh Reverb work area |
| SPU ADPCM Samples |
15-0 Startaddress of sound in Sound buffer (in 8-byte units) |
15-0 Address sample loops to at end (in 8-byte units) |
00h Shift/Filter (reportedly same as for CDROM XA-ADPCM) (see there) 01h Flag Bits (see below) 02h Compressed Data (LSBs=1st Sample, MSBs=2nd Sample) 03h Compressed Data (LSBs=3rd Sample, MSBs=4th Sample) 04h Compressed Data (LSBs=5th Sample, MSBs=6th Sample) ... ... 0Fh Compressed Data (LSBs=27th Sample, MSBs=28th Sample) |
0 Loop End (0=No change, 1=Set ENDX flag and Jump to [1F801C0Eh+N*10h]) 1 Loop Repeat (0=Force Release and set ADSR Level to Zero; only if Bit0=1) 2 Loop Start (0=No change, 1=Copy current address to [1F801C0Eh+N*10h]) 3-7 Unknown (usually 0) |
Code 0 = Normal (continue at next 16-byte block) Code 1 = End+Mute (jump to Loop-address, set ENDX flag, Release, Env=0000h) Code 2 = Ignored (same as Code 0) Code 3 = End+Repeat (jump to Loop-address, set ENDX flag) |
| SPU ADPCM Pitch |
0-15 Sample rate (0=stop, 4000h=fastest, 4001h..FFFFh=usually same as 4000h) |
0 Unknown... Unused? 1-23 Flags for Voice 1..23 (0=Normal, 1=Modulate by Voice 0..22) 24-31 Not used |
Step = VxPitch ;range +0000h..+FFFFh (0...705.6 kHz)
IF PMON.Bit(x)=1 AND (x>0) ;pitch modulation enable
Factor = VxOUTX(x-1) ;range -8000h..+7FFFh (prev voice amplitude)
Factor = Factor+8000h ;range +0000h..+FFFFh (factor = 0.00 .. 1.99)
Step=SignExpand16to32(Step) ;hardware glitch on VxPitch>7FFFh, make sign
Step = (Step * Factor) SAR 15 ;range 0..1FFFFh (glitchy if VxPitch>7FFFh)
Step=Step AND 0000FFFFh ;hardware glitch on VxPitch>7FFFh, kill sign
IF Step>3FFFh then Step=4000h ;range +0000h..+3FFFh (0.. 176.4kHz)
Counter = Counter + Step
|
out = ((gauss[0FFh-i] * oldest) SAR 15) out = out + ((gauss[1FFh-i] * older) SAR 15) out = out + ((gauss[100h+i] * old) SAR 15) out = out + ((gauss[000h+i] * new) SAR 15) |
-001h,-001h,-001h,-001h,-001h,-001h,-001h,-001h ;\ -001h,-001h,-001h,-001h,-001h,-001h,-001h,-001h ; 0000h,0000h,0000h,0000h,0000h,0000h,0000h,0001h ; 0001h,0001h,0001h,0002h,0002h,0002h,0003h,0003h ; 0003h,0004h,0004h,0005h,0005h,0006h,0007h,0007h ; 0008h,0009h,0009h,000Ah,000Bh,000Ch,000Dh,000Eh ; 000Fh,0010h,0011h,0012h,0013h,0015h,0016h,0018h ; entry 0019h,001Bh,001Ch,001Eh,0020h,0021h,0023h,0025h ; 000h..07Fh 0027h,0029h,002Ch,002Eh,0030h,0033h,0035h,0038h ; 003Ah,003Dh,0040h,0043h,0046h,0049h,004Dh,0050h ; 0054h,0057h,005Bh,005Fh,0063h,0067h,006Bh,006Fh ; 0074h,0078h,007Dh,0082h,0087h,008Ch,0091h,0096h ; 009Ch,00A1h,00A7h,00ADh,00B3h,00BAh,00C0h,00C7h ; 00CDh,00D4h,00DBh,00E3h,00EAh,00F2h,00FAh,0101h ; 010Ah,0112h,011Bh,0123h,012Ch,0135h,013Fh,0148h ; 0152h,015Ch,0166h,0171h,017Bh,0186h,0191h,019Ch ;/ 01A8h,01B4h,01C0h,01CCh,01D9h,01E5h,01F2h,0200h ;\ 020Dh,021Bh,0229h,0237h,0246h,0255h,0264h,0273h ; 0283h,0293h,02A3h,02B4h,02C4h,02D6h,02E7h,02F9h ; 030Bh,031Dh,0330h,0343h,0356h,036Ah,037Eh,0392h ; 03A7h,03BCh,03D1h,03E7h,03FCh,0413h,042Ah,0441h ; 0458h,0470h,0488h,04A0h,04B9h,04D2h,04ECh,0506h ; 0520h,053Bh,0556h,0572h,058Eh,05AAh,05C7h,05E4h ; entry 0601h,061Fh,063Eh,065Ch,067Ch,069Bh,06BBh,06DCh ; 080h..0FFh 06FDh,071Eh,0740h,0762h,0784h,07A7h,07CBh,07EFh ; 0813h,0838h,085Dh,0883h,08A9h,08D0h,08F7h,091Eh ; 0946h,096Fh,0998h,09C1h,09EBh,0A16h,0A40h,0A6Ch ; 0A98h,0AC4h,0AF1h,0B1Eh,0B4Ch,0B7Ah,0BA9h,0BD8h ; 0C07h,0C38h,0C68h,0C99h,0CCBh,0CFDh,0D30h,0D63h ; 0D97h,0DCBh,0E00h,0E35h,0E6Bh,0EA1h,0ED7h,0F0Fh ; 0F46h,0F7Fh,0FB7h,0FF1h,102Ah,1065h,109Fh,10DBh ; 1116h,1153h,118Fh,11CDh,120Bh,1249h,1288h,12C7h ;/ 1307h,1347h,1388h,13C9h,140Bh,144Dh,1490h,14D4h ;\ 1517h,155Ch,15A0h,15E6h,162Ch,1672h,16B9h,1700h ; 1747h,1790h,17D8h,1821h,186Bh,18B5h,1900h,194Bh ; 1996h,19E2h,1A2Eh,1A7Bh,1AC8h,1B16h,1B64h,1BB3h ; 1C02h,1C51h,1CA1h,1CF1h,1D42h,1D93h,1DE5h,1E37h ; 1E89h,1EDCh,1F2Fh,1F82h,1FD6h,202Ah,207Fh,20D4h ; 2129h,217Fh,21D5h,222Ch,2282h,22DAh,2331h,2389h ; entry 23E1h,2439h,2492h,24EBh,2545h,259Eh,25F8h,2653h ; 100h..17Fh 26ADh,2708h,2763h,27BEh,281Ah,2876h,28D2h,292Eh ; 298Bh,29E7h,2A44h,2AA1h,2AFFh,2B5Ch,2BBAh,2C18h ; 2C76h,2CD4h,2D33h,2D91h,2DF0h,2E4Fh,2EAEh,2F0Dh ; 2F6Ch,2FCCh,302Bh,308Bh,30EAh,314Ah,31AAh,3209h ; 3269h,32C9h,3329h,3389h,33E9h,3449h,34A9h,3509h ; 3569h,35C9h,3629h,3689h,36E8h,3748h,37A8h,3807h ; 3867h,38C6h,3926h,3985h,39E4h,3A43h,3AA2h,3B00h ; 3B5Fh,3BBDh,3C1Bh,3C79h,3CD7h,3D35h,3D92h,3DEFh ;/ 3E4Ch,3EA9h,3F05h,3F62h,3FBDh,4019h,4074h,40D0h ;\ 412Ah,4185h,41DFh,4239h,4292h,42EBh,4344h,439Ch ; 43F4h,444Ch,44A3h,44FAh,4550h,45A6h,45FCh,4651h ; 46A6h,46FAh,474Eh,47A1h,47F4h,4846h,4898h,48E9h ; 493Ah,498Ah,49D9h,4A29h,4A77h,4AC5h,4B13h,4B5Fh ; 4BACh,4BF7h,4C42h,4C8Dh,4CD7h,4D20h,4D68h,4DB0h ; 4DF7h,4E3Eh,4E84h,4EC9h,4F0Eh,4F52h,4F95h,4FD7h ; entry 5019h,505Ah,509Ah,50DAh,5118h,5156h,5194h,51D0h ; 180h..1FFh 520Ch,5247h,5281h,52BAh,52F3h,532Ah,5361h,5397h ; 53CCh,5401h,5434h,5467h,5499h,54CAh,54FAh,5529h ; 5558h,5585h,55B2h,55DEh,5609h,5632h,565Bh,5684h ; 56ABh,56D1h,56F6h,571Bh,573Eh,5761h,5782h,57A3h ; 57C3h,57E2h,57FFh,581Ch,5838h,5853h,586Dh,5886h ; 589Eh,58B5h,58CBh,58E0h,58F4h,5907h,5919h,592Ah ; 593Ah,5949h,5958h,5965h,5971h,597Ch,5986h,598Fh ; 5997h,599Eh,59A4h,59A9h,59ADh,59B0h,59B2h,59B3h ;/ |
Incoming ADPCM Data ---> Interpolated Data _ _ _ _ | | | | | | | | . . . . Nibbles=79797979, Filter=0 | | | | | | | | ---> / \ / \ / \ / \ HALF-volume ZIGZAG-wave | |_| |_| |_| |_ ' ' ' ' ___ ___ | | | | .'. .'. Nibbles=77997799, Filter=0 | | | | ---> / \ / \ FULL-volume SINE-wave | |___| |___ ' '.' '. _______ ___ | | .' '. Nibbles=77779999, Filter=0 | | ---> / \ SQUARE wave (with rounded edges) | |_______ ' '.____ _____ _ __ | |_ _| .' ''. .' Nibbles=7777CC44, Filter=0 | |___| ---> / '..' CUSTOM wave-form | ' ___ __ | |___| | _ \ ! / . \ ! / Nibbles=77DE9HZK, Filter=V |_ ____| _| ---> - + - + - + - SOLAR STORM wave-form __| |______|___ / ! \ ' / ! \ |
| SPU Volume and ADSR Generator |
____lower 16bit (at 1F801C08h+N*10h)___________________________________ 15 Attack Mode (0=Linear, 1=Exponential) - Attack Direction (Fixed, always Increase) (until Level 7FFFh) 14-10 Attack Shift (0..1Fh = Fast..Slow) 9-8 Attack Step (0..3 = "+7,+6,+5,+4") - Decay Mode (Fixed, always Exponential) - Decay Direction (Fixed, always Decrease) (until Sustain Level) 7-4 Decay Shift (0..0Fh = Fast..Slow) - Decay Step (Fixed, always "-8") 3-0 Sustain Level (0..0Fh) ;Level=(N+1)*800h ____upper 16bit (at 1F801C0Ah+N*10h)___________________________________ 31 Sustain Mode (0=Linear, 1=Exponential) 30 Sustain Direction (0=Increase, 1=Decrease) (until Key OFF flag) 29 Not used? (should be zero) 28-24 Sustain Shift (0..1Fh = Fast..Slow) 23-22 Sustain Step (0..3 = "+7,+6,+5,+4" or "-8,-7,-6,-5") (inc/dec) 21 Release Mode (0=Linear, 1=Exponential) - Release Direction (Fixed, always Decrease) (until Level 0000h) 20-16 Release Shift (0..1Fh = Fast..Slow) - Release Step (Fixed, always "-8") |
Typical ADSR Shape
A D S R Volume
/\____ Loud (7FFFh)
/ \_ Med (4000h)
__/ ""--....____ Mute (0000h)
|
15 Must be zero (0=Volume Mode) 0-14 Voice volume/2 (-4000h..+3FFFh = Volume -8000h..+7FFEh) |
15 Must be set (1=Sweep Mode) 14 Sweep Mode (0=Linear, 1=Exponential) 13 Sweep Direction (0=Increase, 1=Decrease) 12 Sweep Phase (0=Positive, 1=Negative) 7-11 Not used? (should be zero) 6-2 Sweep Shift (0..1Fh = Fast..Slow) 1-0 Sweep Step (0..3 = "+7,+6,+5,+4" or "-8,-7,-6,-5") (inc/dec) |
0-15 Volume (-8000h..+7FFFh) |
AdsrCycles = 1 SHL Max(0,ShiftValue-11) AdsrStep = StepValue SHL Max(0,11-ShiftValue) IF exponential AND increase AND AdsrLevel>6000h THEN AdsrCycles=AdsrCycles*4 IF exponential AND decrease THEN AdsrStep=AdsrStep*AdsrLevel/8000h Wait(AdsrCycles) ;cycles counted at 44.1kHz clock AdsrLevel=AdsrLevel+AdsrStep ;saturated to 0..+7FFFh |
15-0 Current ADSR Volume (0..+7FFFh) (or -8000h..+7FFFh on manual write) |
0-15 Current Volume (-8000h..+7FFFh) |
| SPU Voice Flags |
0-23 Voice 0..23 On (0=No change, 1=Start Attack/Decay/Sustain) 24-31 Not used |
0-23 Voice 0..23 Off (0=No change, 1=Start Release) 24-31 Not used |
0-23 Voice 0..23 Status (0=Newly Keyed On, 1=Reached LOOP-END) 24-31 Not used |
| SPU Noise Generator |
0-23 Voice 0..23 Noise (0=ADPCM, 1=Noise) 24-31 Not used |
Wait(1 cycle) ;at 44.1kHz clock Timer=Timer-NoiseStep ;subtract Step (4..7) ParityBit = NoiseLevel.Bit15 xor Bit12 xor Bit11 xor Bit10 xor 1 IF Timer<0 then NoiseLevel = NoiseLevel*2 + ParityBit IF Timer<0 then Timer=Timer+(20000h SHR NoiseShift) ;reload timer once IF Timer<0 then Timer=Timer+(20000h SHR NoiseShift) ;reload again if needed |
| SPU Control and Status Register |
15 SPU Soft Reset (0=Reset/KeyOff, 1=Normal) ;\Don't care 14 Mute SPU (0=Mute, 1=Unmute) ;/for CD Audio) 13-10 Noise Frequency Shift (0..0Fh = Low .. High Frequency) 9-8 Noise Frequency Step (0..03h = Step "4,5,6,7") 7 Reverb Master Enable (0=Disabled, 1=Enabled) 6 IRQ9 Enable (0=Disabled/Acknowledge, 1=Enabled; only when Bit15=1) 5-4 Sound RAM Transfer Mode (0=Stop, 1=ManualWrite, 2=DMAwrite, 3=DMAread) 3 External Audio Reverb (0=Off, 1=On) 2 CD Audio Reverb (0=Off, 1=On) (for CD-DA and XA-ADPCM) 1 External Audio Enable (0=Off, 1=On) 0 CD Audio Enable (0=Off, 1=On) (for CD-DA and XA-ADPCM) |
15-12 Unknown/Unused (seems to be usually zero) 11 Writing to First/Second half of Capture Buffers (0=First, 1=Second) 10 Data Transfer Busy Flag (0=Ready, 1=Busy) 9 Data Transfer DMA Read Request (0=No, 1=Yes) 8 Data Transfer DMA Write Request (0=No, 1=Yes) 7 Data Transfer DMA Read/Write Request ;seems to be same as SPUCNT.Bit5 6 IRQ9 Flag (0=No, 1=Interrupt Request) 5-0 Current SPU Mode (same as SPUCNT.Bit5-0, but, applied a bit delayed) |
| SPU Memory Access |
15-0 Address in sound buffer divided by eight |
15-0 Data (max 32 halfwords) |
15-4 Unknown/no effect? (should be zero) 3-1 Sound RAM Data Transfer Type (see below) (should be 2) 0 Unknown/no effect? (should be zero) |
__Transfer Type___Halfwords in Fifo________Halfwords written to SPU RAM__ 0,1,6,7 Fill A,B,C,D,E,F,G,H,...,X X,X,X,X,X,X,X,X,... 2 Normal A,B,C,D,E,F,G,H,...,X A,B,C,D,E,F,G,H,... 3 Rep2 A,B,C,D,E,F,G,H,...,X A,A,C,C,E,E,G,G,... 4 Rep4 A,B,C,D,E,F,G,H,...,X A,A,A,A,E,E,E,E,... 5 Rep8 A,B,C,D,E,F,G,H,...,X H,H,H,H,H,H,H,H,... |
Below problems (and workarounds) apply ONLY if [1F801014h].bit24-27 = zero. Ie. below info describes what happens when [1F801014h] is mis-initialized. Normally one should set [1F801014h]=220931E1h (and can ignore below info). |
1st block: FFFFh, halfwords[00h..1Eh] 2nd block: FFFFh, halfwords[20h..3Eh] etc. |
1st block: FFFFh, halfwords[00h..1Eh], twice halfword[1Fh] 2nd block: FFFFh, halfwords[20h..3Eh], twice halfword[3Fh] etc. |
1st block: FFFFh, halfwords[00h,00h,..0Eh,0Eh], triple halfword[0Fh] 2nd block: FFFFh, halfwords[10h,10h,..1Eh,1Eh], triple halfword[1Fh] etc. |
| SPU Interrupt |
15-0 Address in sound buffer divided by eight |
| SPU Reverb Registers |
Port Reg Name Type Expl. 1F801D84h spu vLOUT volume Reverb Output Volume Left 1F801D86h spu vROUT volume Reverb Output Volume Right 1F801DA2h spu mBASE base Reverb Work Area Start Address in Sound RAM 1F801DC0h rev00 dAPF1 disp Reverb APF Offset 1 1F801DC2h rev01 dAPF2 disp Reverb APF Offset 2 1F801DC4h rev02 vIIR volume Reverb Reflection Volume 1 1F801DC6h rev03 vCOMB1 volume Reverb Comb Volume 1 1F801DC8h rev04 vCOMB2 volume Reverb Comb Volume 2 1F801DCAh rev05 vCOMB3 volume Reverb Comb Volume 3 1F801DCCh rev06 vCOMB4 volume Reverb Comb Volume 4 1F801DCEh rev07 vWALL volume Reverb Reflection Volume 2 1F801DD0h rev08 vAPF1 volume Reverb APF Volume 1 1F801DD2h rev09 vAPF2 volume Reverb APF Volume 2 1F801DD4h rev0A mLSAME src/dst Reverb Same Side Reflection Address 1 Left 1F801DD6h rev0B mRSAME src/dst Reverb Same Side Reflection Address 1 Right 1F801DD8h rev0C mLCOMB1 src Reverb Comb Address 1 Left 1F801DDAh rev0D mRCOMB1 src Reverb Comb Address 1 Right 1F801DDCh rev0E mLCOMB2 src Reverb Comb Address 2 Left 1F801DDEh rev0F mRCOMB2 src Reverb Comb Address 2 Right 1F801DE0h rev10 dLSAME src Reverb Same Side Reflection Address 2 Left 1F801DE2h rev11 dRSAME src Reverb Same Side Reflection Address 2 Right 1F801DE4h rev12 mLDIFF src/dst Reverb Different Side Reflect Address 1 Left 1F801DE6h rev13 mRDIFF src/dst Reverb Different Side Reflect Address 1 Right 1F801DE8h rev14 mLCOMB3 src Reverb Comb Address 3 Left 1F801DEAh rev15 mRCOMB3 src Reverb Comb Address 3 Right 1F801DECh rev16 mLCOMB4 src Reverb Comb Address 4 Left 1F801DEEh rev17 mRCOMB4 src Reverb Comb Address 4 Right 1F801DF0h rev18 dLDIFF src Reverb Different Side Reflect Address 2 Left 1F801DF2h rev19 dRDIFF src Reverb Different Side Reflect Address 2 Right 1F801DF4h rev1A mLAPF1 src/dst Reverb APF Address 1 Left 1F801DF6h rev1B mRAPF1 src/dst Reverb APF Address 1 Right 1F801DF8h rev1C mLAPF2 src/dst Reverb APF Address 2 Left 1F801DFAh rev1D mRAPF2 src/dst Reverb APF Address 2 Right 1F801DFCh rev1E vLIN volume Reverb Input Volume Left 1F801DFEh rev1F vRIN volume Reverb Input Volume Right |
0-23 Voice 0..23 Destination (0=To Mixer, 1=To Mixer and to Reverb) 24-31 Not used |
| SPU Reverb Formula |
___Input from Mixer (Input volume multiplied with incoming data)_____________ Lin = vLIN * LeftInput ;from any channels that have Reverb enabled Rin = vRIN * RightInput ;from any channels that have Reverb enabled ____Same Side Reflection (left-to-left and right-to-right)___________________ [mLSAME] = (Lin + [dLSAME]*vWALL - [mLSAME-2])*vIIR + [mLSAME-2] ;L-to-L [mRSAME] = (Rin + [dRSAME]*vWALL - [mRSAME-2])*vIIR + [mRSAME-2] ;R-to-R ___Different Side Reflection (left-to-right and right-to-left)_______________ [mLDIFF] = (Lin + [dRDIFF]*vWALL - [mLDIFF-2])*vIIR + [mLDIFF-2] ;R-to-L [mRDIFF] = (Rin + [dLDIFF]*vWALL - [mRDIFF-2])*vIIR + [mRDIFF-2] ;L-to-R ___Early Echo (Comb Filter, with input from buffer)__________________________ Lout=vCOMB1*[mLCOMB1]+vCOMB2*[mLCOMB2]+vCOMB3*[mLCOMB3]+vCOMB4*[mLCOMB4] Rout=vCOMB1*[mRCOMB1]+vCOMB2*[mRCOMB2]+vCOMB3*[mRCOMB3]+vCOMB4*[mRCOMB4] ___Late Reverb APF1 (All Pass Filter 1, with input from COMB)________________ Lout=Lout-vAPF1*[mLAPF1-dAPF1], [mLAPF1]=Lout, Lout=Lout*vAPF1+[mLAPF1-dAPF1] Rout=Rout-vAPF1*[mRAPF1-dAPF1], [mRAPF1]=Rout, Rout=Rout*vAPF1+[mRAPF1-dAPF1] ___Late Reverb APF2 (All Pass Filter 2, with input from APF1)________________ Lout=Lout-vAPF2*[mLAPF2-dAPF2], [mLAPF2]=Lout, Lout=Lout*vAPF2+[mLAPF2-dAPF2] Rout=Rout-vAPF2*[mRAPF2-dAPF2], [mRAPF2]=Rout, Rout=Rout*vAPF2+[mRAPF2-dAPF2] ___Output to Mixer (Output volume multiplied with input from APF2)___________ LeftOutput = Lout*vLOUT RightOutput = Rout*vROUT ___Finally, before repeating the above steps_________________________________ BufferAddress = MAX(mBASE, (BufferAddress+2) AND 7FFFEh) Wait one 22050Hz cycle, then repeat the above stuff |
Caution
That wrapping mechanism seems to work only in the upper portion of SPU RAM,
but does somehow go wrong if mBASE is too small (it does then accidentally
wrap to addresses outside of the mBASE..7FFFEh region, where it could
trigger unintended voice IRQs or the like). Some examples:
mBASE>=60000h should be safe to use
mBASE>=48000h might work (SEEMS to be stable, at least with current tests)
mBASE=45000h bad (does mis-trigger IRQs, sometimes, at SOME IRQ locations)
mBASE=44000h bad (does mis-trigger IRQs, every some seconds)
mBASE=40000h bad (does mis-trigger IRQs, MANY times per second)
mBASE=10000h bad (does mis-trigger IRQs, every some seconds)
|
| SPU Reverb Examples |
dAPF1 dAPF2 vIIR vCOMB1 vCOMB2 vCOMB3 vCOMB4 vWALL ;1F801DC0h..CEh vAPF1 vAPF2 mLSAME mRSAME mLCOMB1 mRCOMB1 mLCOMB2 mRCOMB2 ;1F801DD0h..DEh dLSAME dRSAME mLDIFF mRDIFF mLCOMB3 mRCOMB3 mLCOMB4 mRCOMB4 ;1F801DE0h..EEh dLDIFF dRDIFF mLAPF1 mRAPF1 mLAPF2 mRAPF2 vLIN vRIN ;1F801DF0h..FEh |
007Dh,005Bh,6D80h,54B8h,BED0h,0000h,0000h,BA80h 5800h,5300h,04D6h,0333h,03F0h,0227h,0374h,01EFh 0334h,01B5h,0000h,0000h,0000h,0000h,0000h,0000h 0000h,0000h,01B4h,0136h,00B8h,005Ch,8000h,8000h |
0033h,0025h,70F0h,4FA8h,BCE0h,4410h,C0F0h,9C00h 5280h,4EC0h,03E4h,031Bh,03A4h,02AFh,0372h,0266h 031Ch,025Dh,025Ch,018Eh,022Fh,0135h,01D2h,00B7h 018Fh,00B5h,00B4h,0080h,004Ch,0026h,8000h,8000h |
00B1h,007Fh,70F0h,4FA8h,BCE0h,4510h,BEF0h,B4C0h 5280h,4EC0h,0904h,076Bh,0824h,065Fh,07A2h,0616h 076Ch,05EDh,05ECh,042Eh,050Fh,0305h,0462h,02B7h 042Fh,0265h,0264h,01B2h,0100h,0080h,8000h,8000h |
00E3h,00A9h,6F60h,4FA8h,BCE0h,4510h,BEF0h,A680h 5680h,52C0h,0DFBh,0B58h,0D09h,0A3Ch,0BD9h,0973h 0B59h,08DAh,08D9h,05E9h,07ECh,04B0h,06EFh,03D2h 05EAh,031Dh,031Ch,0238h,0154h,00AAh,8000h,8000h |
01A5h,0139h,6000h,5000h,4C00h,B800h,BC00h,C000h 6000h,5C00h,15BAh,11BBh,14C2h,10BDh,11BCh,0DC1h 11C0h,0DC3h,0DC0h,09C1h,0BC4h,07C1h,0A00h,06CDh 09C2h,05C1h,05C0h,041Ah,0274h,013Ah,8000h,8000h |
0017h,0013h,70F0h,4FA8h,BCE0h,4510h,BEF0h,8500h 5F80h,54C0h,0371h,02AFh,02E5h,01DFh,02B0h,01D7h 0358h,026Ah,01D6h,011Eh,012Dh,00B1h,011Fh,0059h 01A0h,00E3h,0058h,0040h,0028h,0014h,8000h,8000h |
033Dh,0231h,7E00h,5000h,B400h,B000h,4C00h,B000h 6000h,5400h,1ED6h,1A31h,1D14h,183Bh,1BC2h,16B2h 1A32h,15EFh,15EEh,1055h,1334h,0F2Dh,11F6h,0C5Dh 1056h,0AE1h,0AE0h,07A2h,0464h,0232h,8000h,8000h |
0001h,0001h,7FFFh,7FFFh,0000h,0000h,0000h,8100h 0000h,0000h,1FFFh,0FFFh,1005h,0005h,0000h,0000h 1005h,0005h,0000h,0000h,0000h,0000h,0000h,0000h 0000h,0000h,1004h,1002h,0004h,0002h,8000h,8000h |
0001h,0001h,7FFFh,7FFFh,0000h,0000h,0000h,0000h 0000h,0000h,1FFFh,0FFFh,1005h,0005h,0000h,0000h 1005h,0005h,0000h,0000h,0000h,0000h,0000h,0000h 0000h,0000h,1004h,1002h,0004h,0002h,8000h,8000h |
0000h,0000h,0000h,0000h,0000h,0000h,0000h,0000h 0000h,0000h,0001h,0001h,0001h,0001h,0001h,0001h 0000h,0000h,0001h,0001h,0001h,0001h,0001h,0001h 0000h,0000h,0001h,0001h,0001h,0001h,0000h,0000h |
| SPU Unknown Registers |
0-15 Unknown? |
80 21 4B DF |
.. 31 .. .. |
7E 61 A9 96 47 39 F9 1E E1 E1 80 DD E8 17 7F FB FB BF 1D 6C 8F EC F3 04 06 23 89 45 C1 6D 31 82 |
.. .. .. .. .. .. .. .. .. .. .. .. .. .. 7B .. .. .. .. .. .. .. .. .. 04 .. .. .. .. .. .. 86 |
| Interrupts |
0 IRQ0 VBLANK (PAL=50Hz, NTSC=60Hz) 1 IRQ1 GPU Can be requested via GP0(1Fh) command (rarely used) 2 IRQ2 CDROM 3 IRQ3 DMA 4 IRQ4 TMR0 Timer 0 aka Root Counter 0 (Sysclk or Dotclk) 5 IRQ5 TMR1 Timer 1 aka Root Counter 1 (Sysclk or H-blank) 6 IRQ6 TMR2 Timer 2 aka Root Counter 2 (Sysclk or Sysclk/8) 7 IRQ7 Controller and Memory Card - Byte Received Interrupt 8 IRQ8 SIO 9 IRQ9 SPU 10 IRQ10 Controller - Lightpen Interrupt (reportedly also PIO...?) 11-15 Not used (always zero) 16-31 Garbage |
First, acknowledge I_STAT (eg. I_STAT.bit7=0) Then, acknowledge corresponding I/O port (eg. JOY_CTRL.bit4=1) |
| DMA Channels |
1F80108xh DMA0 channel 0 MDECin (RAM to MDEC) 1F80109xh DMA1 channel 1 MDECout (MDEC to RAM) 1F8010Axh DMA2 channel 2 GPU (lists + image data) 1F8010Bxh DMA3 channel 3 CDROM (CDROM to RAM) 1F8010Cxh DMA4 channel 4 SPU 1F8010Dxh DMA5 channel 5 PIO (Expansion Port) 1F8010Exh DMA6 channel 6 OTC (reverse clear OT) (GPU related) 1F8010F0h DPCR - DMA Control register 1F8010F4h DICR - DMA Interrupt register |
0-23 Memory Address where the DMA will start reading from/writing to 24-31 Not used (always zero) |
0-15 BC Number of words (0001h..FFFFh) (or 0=10000h words)
16-31 0 Not used (usually 0 for OTC, or 1 ("one block") for CDROM)
|
0-15 BS Blocksize (words) ;for GPU/SPU max 10h, for MDEC max 20h 16-31 BA Amount of blocks ;ie. total length = BS*BA words |
0-31 0 Not used (should be zero) (transfer ends at END-CODE in list) |
0 Transfer Direction (0=To Main RAM, 1=From Main RAM)
1 Memory Address Step (0=Forward;+4, 1=Backward;-4)
2-7 Not used (always zero)
8 Chopping Enable (0=Normal, 1=Chopping; run CPU during DMA gaps)
9-10 SyncMode, Transfer Synchronisation/Mode (0-3):
0 Start immediately and transfer all at once (used for CDROM, OTC)
1 Sync blocks to DMA requests (used for MDEC, SPU, and GPU-data)
2 Linked-List mode (used for GPU-command-lists)
3 Reserved (not used)
11-15 Not used (always zero)
16-18 Chopping DMA Window Size (1 SHL N words)
19 Not used (always zero)
20-22 Chopping CPU Window Size (1 SHL N clks)
23 Not used (always zero)
24 Start/Busy (0=Stopped/Completed, 1=Start/Enable/Busy)
25-27 Not used (always zero)
28 Start/Trigger (0=Normal, 1=Manual Start; use for SyncMode=0)
29 Unknown (R/W) Pause? (0=No, 1=Pause?) (For SyncMode=0 only?)
30 Unknown (R/W)
31 Not used (always zero)
|
0-2 DMA0, MDECin Priority (0..7; 0=Highest, 7=Lowest) 3 DMA0, MDECin Master Enable (0=Disable, 1=Enable) 4-6 DMA1, MDECout Priority (0..7; 0=Highest, 7=Lowest) 7 DMA1, MDECout Master Enable (0=Disable, 1=Enable) 8-10 DMA2, GPU Priority (0..7; 0=Highest, 7=Lowest) 11 DMA2, GPU Master Enable (0=Disable, 1=Enable) 12-14 DMA3, CDROM Priority (0..7; 0=Highest, 7=Lowest) 15 DMA3, CDROM Master Enable (0=Disable, 1=Enable) 16-18 DMA4, SPU Priority (0..7; 0=Highest, 7=Lowest) 19 DMA4, SPU Master Enable (0=Disable, 1=Enable) 20-22 DMA5, PIO Priority (0..7; 0=Highest, 7=Lowest) 23 DMA5, PIO Master Enable (0=Disable, 1=Enable) 24-26 DMA6, OTC Priority (0..7; 0=Highest, 7=Lowest) 27 DMA6, OTC Master Enable (0=Disable, 1=Enable) 28-30 Unknown, Priority Offset or so? (R/W) 31 Unknown, no effect? (R/W) |
0-5 Unknown (read/write-able) 6-14 Not used (always zero) 15 Force IRQ (sets bit31) (0=None, 1=Force Bit31=1) 16-22 IRQ Enable setting bit24-30 upon DMA0..DMA6 (0=None, 1=Enable) 23 IRQ Enable setting bit31 when bit24-30=nonzero (0=None, 1=Enable) 24-30 IRQ Flags for DMA0..DMA6 (Write 1 to reset) (0=None, 1=IRQ) 31 IRQ Signal (0-to-1 triggers 1F801070h.bit3) (0=None, 1=IRQ) (R) |
IF bit15=1 OR (bit23=1 AND bit(24-30)>0) THEN bit31=1 ELSE bit31=0 |
(changes to 7FE358D1h after DMA transfer)
|
(stays so even after DMA transfer)
|
DMA0 MDEC.IN 01000201h (always) DMA1 MDEC.OUT 01000200h (always) DMA2 GPU 01000200h (VramRead), 01000201h (VramWrite), 01000401h (List) DMA3 CDROM 11000000h (normal), 11400100h (chopped, rarely used) DMA4 SPU 01000201h (write), 01000200h (read, rarely used) DMA5 PIO N/A (not used by any known games) DMA6 OTC 11000002h (always) |
DMA0 MDEC.IN 1 clk/word ;0110h clks per 100h words ;\plus whatever DMA1 MDEC.OUT 1 clk/word ;0110h clks per 100h words ;/decompression time DMA2 GPU 1 clk/word ;0110h clks per 100h words ;-plus ... DMA3 CDROM/BIOS 24 clks/word ;1800h clks per 100h words ;\plus single/double DMA3 CDROM/GAMES 40 clks/word ;2800h clks per 100h words ;/speed sector rate DMA4 SPU 4 clks/word ;0420h clks per 100h words ;-plus ... DMA5 PIO 20 clks/word ;1400h clks per 100h words ;-not actually used DMA6 OTC 1 clk/word ;0110h clks per 100h words ;-plus nothing |
| Timers |
0-15 Current Counter value (incrementing) 16-31 Garbage |
0 Synchronization Enable (0=Free Run, 1=Synchronize via Bit1-2)
1-2 Synchronization Mode (0-3, see lists below)
Synchronization Modes for Counter 0:
0 = Pause counter during Hblank(s)
1 = Reset counter to 0000h at Hblank(s)
2 = Reset counter to 0000h at Hblank(s) and pause outside of Hblank
3 = Pause until Hblank occurs once, then switch to Free Run
Synchronization Modes for Counter 1:
Same as above, but using Vblank instead of Hblank
Synchronization Modes for Counter 2:
0 or 3 = Stop counter at current value (forever, no h/v-blank start)
1 or 2 = Free Run (same as when Synchronization Disabled)
3 Reset counter to 0000h (0=After Counter=FFFFh, 1=After Counter=Target)
4 IRQ when Counter=Target (0=Disable, 1=Enable)
5 IRQ when Counter=FFFFh (0=Disable, 1=Enable)
6 IRQ Once/Repeat Mode (0=One-shot, 1=Repeatedly)
7 IRQ Pulse/Toggle Mode (0=Short Bit10=0 Pulse, 1=Toggle Bit10 on/off)
8-9 Clock Source (0-3, see list below)
Counter 0: 0 or 2 = System Clock, 1 or 3 = Dotclock
Counter 1: 0 or 2 = System Clock, 1 or 3 = Hblank
Counter 2: 0 or 1 = System Clock, 2 or 3 = System Clock/8
10 Interrupt Request (0=Yes, 1=No) (Set after Writing) (W=1) (R)
11 Reached Target Value (0=No, 1=Yes) (Reset after Reading) (R)
12 Reached FFFFh Value (0=No, 1=Yes) (Reset after Reading) (R)
13-15 Unknown (seems to be always zero)
16-31 Garbage (next opcode)
|
0-15 Counter Target value 16-31 Garbage |
| CDROM Drive |
| CDROM Controller I/O Ports |
0-1 Index Port 1F801801h-1F801803h index (0..3 = Index0..Index3) (R/W) 2 ADPBUSY XA-ADPCM fifo empty (0=Empty) ;set when playing XA-ADPCM sound 3 PRMEMPT Parameter fifo empty (1=Empty) ;triggered before writing 1st byte 4 PRMWRDY Parameter fifo full (0=Full) ;triggered after writing 16 bytes 5 RSLRRDY Response fifo empty (0=Empty) ;triggered after reading LAST byte 6 DRQSTS Data fifo empty (0=Empty) ;triggered after reading LAST byte 7 BUSYSTS Command/parameter transmission busy (1=Busy) |
0-7 Command Byte |
0-7 Parameter Byte(s) to be used for next Command |
0-4 0 Not used (should be zero) 5 SMEN Want Command Start Interrupt on Next Command (0=No change, 1=Yes) 6 BFWR ... 7 BFRD Want Data (0=No/Reset Data Fifo, 1=Yes/Load Data Fifo) |
0-7 Data 8bit (one byte), or alternately, 0-15 Data 16bit (LSB=First byte, MSB=Second byte) |
0-7 Response Byte(s) received after sending a Command |
0-4 Interrupt Enable Bits (usually all set, ie. 1Fh=Enable All IRQs) 5-7 Unknown/unused (write: should be zero) (read: usually all bits set) |
0-2 Read: Response Received Write: 7=Acknowledge ;INT1..INT7 3 Read: Unknown (usually 0) Write: 1=Acknowledge ;INT8 ;XXX CLRBFEMPT 4 Read: Command Start Write: 1=Acknowledge ;INT10h;XXX CLRBFWRDY 5 Read: Always 1 ;XXX "_" Write: 1=Unknown ;XXX SMADPCLR 6 Read: Always 1 ;XXX "_" Write: 1=Reset Parameter Fifo ;XXX CLRPRM 7 Read: Always 1 ;XXX "_" Write: 1=Unknown ;XXX CHPRST |
INT0 No response received (no interrupt request)
INT1 Received SECOND (or further) response to ReadS/ReadN (and Play+Report)
INT2 Received SECOND response (to various commands)
INT3 Received FIRST response (to any command)
INT4 DataEnd (when Play/Forward reaches end of disk) (maybe also for Read?)
INT5 Received error-code (in FIRST or SECOND response)
INT5 also occurs on SECOND GetID response, on unlicensed disks
INT5 also occurs when opening the drive door (even if no command
was sent, ie. even if no read-command or other command is active)
INT6 N/A
INT7 N/A
|
INT8 Unknown (never seen that bit set yet) INT10h Command Start (when INT10h requested via 1F801803h.Index0.Bit5) |
0 ----------> 3 ;99.9% normal case INT3's 0 ----------> 5 ;99% normal case INT5's 0 ---> 1 ---> 3 ;0.1% glitch: occurs about once per thousands of INT3's 0 ---> 4 ---> 5 ;1% glitch: occurs about once per hundreds of INT5's |
@@polling_lop: irq_flags = [1F801803h] AND 07h ;<-- 1st read (may be still unstable) if irq_flags = 00h then goto @@polling_lop irq_flags = [1F801803h] AND 07h ;<-- 2nd read (should be stable now) handle irq_flags and acknowledge them |
0-7 Volume Level (00h..FFh) (00h=Off, FFh=Max/Double, 80h=Default/Normal) |
0 ADPMUTE Mute ADPCM (0=Normal, 1=Mute) 1-4 - Unused (should be zero) 5 CHNGATV Apply Audio Volume changes (0=No change, 1=Apply) 6-7 - Unused (should be zero) |
0-7 Data |
0 Mono/Stereo (0=Mono, 1=Stereo) 1 Reserved (0) 2 Sample Rate (0=37800Hz, 1=18900Hz) 3 Reserved (0) 4 Bits per Sample (0=4bit, 1=8bit) 5 Reserved (0) 6 Emphasis (0=Off, 1=Emphasis) 7 Reserved (0) |
============================================================================= |
0=Ready to send a new command 1=Busy sending a command/parameters |
-Flush all IRQs
-1F801803h.Index0=0
-Com_Delay=4901 (=1325h) (Port 1F801020h) (means 16bit or 32bit write?)
(the write seems to be 32bit, clearing the upper16bit of the register)
-Send two Getstat commands
-Send Command 0Ah (Init)
-Demute
|
SPU: Init Master Volume Left/Right (Port 1F801D80h/1F801D82h) SPU: Init CD Audio Volume Left/Right (Port 1F801DB0h/1F801DB2h) SPU: Enable CD Audio (Port 1F801DAAh.Bit0=1) CDROM/CMD: send Stop command (probably better to avoid conflicts) CDROM/CMD: send Demute command (if muted) (but works only if disc inserted) CDROM/HOST: init Codinginfo (Port 1F801801h.Index2) CDROM/HOST: enable ADPCM (Port 1F801803h.Index3.Bit0=0) ;probably needed? ... set dummy addr/len with DISHXFRC=1 ? <-- NOT required ! ... set SMEN ... and dummy BFWR? <-- BOTH bits required ? ... maybe SMADPCLR (1F801803h.Index1.bit5) does clear SoundMap ADPCM buf? transfer 900h bytes (same format as ADPCM sectors) (Port 1F801801h.Index1) Note: Before sending a byte, one should wait for DRQs (1F801801h.Bit6=1) Note: ADPCM output doesn't start until the last (900h'th) byte is transferred |
| CDROM Controller Command Summary |
Command Parameters Response(s) 00h - - INT5(11h,40h) ;reportedly "Sync" uh? 01h Getstat - INT3(stat) 02h Setloc E amm,ass,asect INT3(stat) 03h Play E (track) INT3(stat), optional INT1(report bytes) 04h Forward E - INT3(stat), optional INT1(report bytes) 05h Backward E - INT3(stat), optional INT1(report bytes) 06h ReadN E - INT3(stat), INT1(stat), datablock 07h MotorOn E - INT3(stat), INT2(stat) 08h Stop E - INT3(stat), INT2(stat) 09h Pause E - INT3(stat), INT2(stat) 0Ah Init - INT3(late-stat), INT2(stat) 0Bh Mute E - INT3(stat) 0Ch Demute E - INT3(stat) 0Dh Setfilter E file,channel INT3(stat) 0Eh Setmode mode INT3(stat) 0Fh Getparam - INT3(stat,mode,null,file,channel) 10h GetlocL E - INT3(amm,ass,asect,mode,file,channel,sm,ci) 11h GetlocP E - INT3(track,index,mm,ss,sect,amm,ass,asect) 12h SetSession E session INT3(stat), INT2(stat) 13h GetTN E - INT3(stat,first,last) ;BCD 14h GetTD E track (BCD) INT3(stat,mm,ss) ;BCD 15h SeekL E - INT3(stat), INT2(stat) ;\use prior Setloc 16h SeekP E - INT3(stat), INT2(stat) ;/to set target 17h - - INT5(11h,40h) ;reportedly "SetClock" uh? 18h - - INT5(11h,40h) ;reportedly "GetClock" uh? 19h Test sub_function depends on sub_function (see below) 1Ah GetID E - INT3(stat), INT2/5(stat,flg,typ,atip,"SCEx") 1Bh ReadS E?- INT3(stat), INT1(stat), datablock 1Ch Reset - INT3(stat), Delay ;-not DTL-H2000 1Dh GetQ E adr,point INT3(stat), INT2(10bytesSubQ,peak_lo) ;\not 1Eh ReadTOC - INT3(late-stat), INT2(stat) ;/vC0 1Fh VideoCD sub,a,b,c,d,e INT3(stat,a,b,c,d,e) ;<-- SCPH-5903 only 1Fh..4Fh - - INT5(11h,40h) ;-Unused/invalid 50h Secret 1 - INT5(11h,40h) ;\ 51h Secret 2 "Licensed by" INT5(11h,40h) ; 52h Secret 3 "Sony" INT5(11h,40h) ; Secret Unlock Commands 53h Secret 4 "Computer" INT5(11h,40h) ; (not in version vC0, and, 54h Secret 5 "Entertainment" INT5(11h,40h) ; nonfunctional in japan) 55h Secret 6 "<region>" INT5(11h,40h) ; 56h Secret 7 - INT5(11h,40h) ;/ 57h SecretLock - INT5(11h,40h) ;-Secret Lock Command 58h..5Fh Crash - Crashes the HC05 (jumps into a data area) 6Fh..FFh - - INT5(11h,40h) ;-Unused/invalid |
sub params response ;Effect
00h - INT3(stat) ;Force motor on, clockwise, even if door open
01h - INT3(stat) ;Force motor on, anti-clockwise, super-fast
02h - INT3(stat) ;Force motor on, anti-clockwise, super-fast
03h - INT3(stat) ;Force motor off (ignored during spin-up)
04h - INT3(stat) ;Start SCEx reading and reset counters
05h - INT3(total,success);Stop SCEx reading and get counters
06h * n INT3(old) ;\early ;Adjust balance in RAM, send CX(30+n XOR 7)
07h * n INT3(old) ; PSX ;Adjust gain in RAM, send CX(38+n XOR 7)
08h * n INT3(old) ;/only ;Adjust balance in RAM only
06h..0Fh - INT5(11h,10h) ;N/A (11h,20h when NONZERO number of params)
10h - INT3(stat) ;CX(..) ;Force motor on, anti-clockwise, super-fast
11h - INT3(stat) ;CX(03) ;Move Lens Up (leave parking position)
12h - INT3(stat) ;CX(02) ;Move Lens Down (enter parking position)
13h - INT3(stat) ;CX(28) ;Move Lens Outwards
14h - INT3(stat) ;CX(2C) ;Move Lens Inwards
15h - INT3(stat) ;CX(22) ;If motor on: Move outwards,inwards,motor off
16h - INT3(stat) ;CX(23) ;No effect?
17h - INT3(stat) ;CX(E8) ;Force motor on, clockwise, super-fast
18h - INT3(stat) ;CX(EA) ;Force motor on, anti-clockwise, super-fast
19h - INT3(stat) ;CX(25) ;No effect?
1Ah - INT3(stat) ;CX(21) ;No effect?
1Bh..1Fh - INT5(11h,10h) ;N/A (11h,20h when NONZERO number of params)
20h - INT3(yy,mm,dd,ver) ;Get cdrom BIOS date/version (yy,mm,dd,ver)
21h - INT3(n) ;Get Drive Switches (bit0=POS0, bit1=DOOR)
22h *** - INT3("for ...") ;Get Region ID String
23h *** - INT3("CXD...") ;Get Chip ID String for Servo Amplifier
24h *** - INT3("CXD...") ;Get Chip ID String for Signal Processor
25h *** - INT3("CXD...") ;Get Chip ID String for Decoder/FIFO
26h..2Fh - INT5(11h,10h) ;N/A (11h,20h when NONZERO number of params)
30h * i,x,y INT3(stat) ;Prototype/Debug stuff ;\supported on
31h * x,y INT3(stat) ;Prototype/Debug stuff ; early PSX only
4xh * i INT3(x,y) ;Prototype/Debug stuff ;/
30h..4Fh .. INT5(11h,10h) ;N/A always 11h,10h (no matter of params)
50h a[,b[,c]] INT3(stat) ;Servo/Signal send CX(a:b:c)
51h ** 39h,xx INT3(stat,hi,lo) ;Servo/Signal send CX(39xx) with response
51h..5Fh - INT5(11h,10h) ;N/A
60h lo,hi INT3(databyte) ;HC05 SUB-CPU read RAM and I/O ports
61h..70h - INT5(11h,10h) ;N/A
71h *** adr INT3(databyte) ;Decoder Read one register
72h *** adr,dat INT3(stat) ;Decoder Write one register
73h *** adr,len INT3(databytes..);Decoder Read multiple registers, bugged
74h *** adr,len,..INT3(stat) ;Decoder Write multiple registers, bugged
75h *** - INT3(lo,hi,lo,hi);Decoder Get Host Xfer Info Remain/Addr
76h *** a,b,c,d INT3(stat) ;Decoder Prepare Transfer to/from SRAM
77h..FFh - INT5(11h,10h) ;N/A
80h..8Fh a,b ? ;seem to do something on PS2
|
| CDROM - Control Commands |
7 Speed (0=Normal speed, 1=Double speed) 6 XA-ADPCM (0=Off, 1=Send XA-ADPCM sectors to SPU Audio Input) 5 Sector Size (0=800h=DataOnly, 1=924h=WholeSectorExceptSyncBytes) 4 Ignore Bit (0=Normal, 1=Ignore Sector Size and Setloc position) 3 XA-Filter (0=Off, 1=Process only XA-ADPCM sectors that match Setfilter) 2 Report (0=Off, 1=Enable Report-Interrupts for Audio Play) 1 AutoPause (0=Off, 1=Auto Pause upon End of Track) ;for Audio Play 0 CDDA (0=Off, 1=Allow to Read CD-DA Sectors; ignore missing EDC) |
Caution: Not supported on DTL-H2000 (v01) |
try_deliver_as_adpcm_sector: reject if CD-DA AUDIO format reject if sector isn't MODE2 format reject if adpcm_disabled(setmode.6) reject if filter_enabled(setmode.3) AND selected file/channel doesn't match reject if submode isn't audio+realtime (bit2 and bit6 must be both set) deliver: send sector to xa-adpcm decoder when passing above cases try_deliver_as_data_sector: reject data-delivery if "try_deliver_as_adpcm_sector" did do adpcm-delivery reject if filter_enabled(setmode.3) AND submode is audio+realtime (bit2+bit6) 1st delivery attempt: send INT1+data, unless there's another INT pending delay, and retry at later time... but this time with file/channel checking! reject if filter_enabled(setmode.3) AND selected file/channel doesn't match 2nd delivery attempt: send INT1+data, unless there's another INT pending |
| CDROM - Seek Commands |
___Errors___ session = 00h causes error code 10h. ;INT5(03h,10h), no 2nd/3rd response ___On a non-multisession-disk___ session = 01h passes okay. ;INT3(stat), and once INT2(stat) session = 02h or higher cause seek error ;INT3(stat), and twice INT5(06h,40h) ___On a multisession-disk with N sessions___ session = 01h..N+1 passes okay ;where N+1 moves to the END of LAST session session = N+2 or higher cause seek error ;2nd response = INT5(06h,20h) |
XXX a nonzero ATIP byte in GetID may indicate a multisession disc |
XXX but GetTD is only MM:SS (not MM:SS:FF)
so must either assume sessions to start at FF=00
or, scan MM:SS upwards (and search for ISO descriptors)
|
| CDROM - Read Commands |
;Read occasionally returns 11h,40h ..? when TOC isn't loaded?
|
[1F801800h]=00h 00h=[1F801800h] [1F801803h]=00h 00h=[1F801803h] [1F801800h]=00h [1F801803h]=80h |
[1F801018h]=00020943h ;cdrom_delay [1F801020h]=0000132Ch ;com_delay |
x=[1F8010F4h] AND 00FFFFFFh ;result is 00840000h [1F8010F4h] = x OR 00880000h [1F8010F0h] = [1F8010F0h] OR 00008000h [1F8010B0h] = A0010000h ;addr [1F8010B4h] = 00010200h ;LSBs=num words, MSBs=ignored/bullshit [1F8010B4h] = 11000000h ;DMA control |
[1F801800h]=01h [1F801803h]=40h ;reset parameter fifo [0]=00000000h [0]=00000001h [0]=00000002h [0]=00000003h [1F801800h]=00h [1F801801h]=09h ;command9 (pause) |
Wait for Interrupt Request (INT1) ;indicates that data is available Send Data Request (1F801803h.Index0.Bit7=1);accept data Acknowledge INT1 ; Copy Data to Main RAM (via I/O or DMA) ;read data |
Caution: Supported only in BIOS version vC1 and up. Not supported in vC0. |
Setloc, Read, Pause |
| CDROM - Status Commands |
7 Play Playing CD-DA ;\only ONE of these bits can be set 6 Seek Seeking ; at a time (ie. Read/Play won't get 5 Read Reading data sectors ;/set until after Seek completion) 4 ShellOpen Once shell open (0=Closed, 1=Is/was Open) 3 IdError (0=Okay, 1=GetID denied) (also set when Setmode.Bit4=1) 2 SeekError (0=Okay, 1=Seek error) (followed by Error Byte) 1 Spindle Motor (0=Motor off, or in spin-up phase, 1=Motor on) 0 Error Invalid Command/parameters (followed by Error Byte) |
___These values appear in the FIRST response; with stat.bit0 set___
10h - Invalid Sub_function (for command 19h), or invalid parameter value
20h - Wrong number of parameters
40h - Invalid command
80h - Cannot respond yet (eg. required info was not yet read from disk yet)
(namely, TOC not-yet-read or so)
(also appears if no disk inserted at all)
___These values appear in the SECOND response; with stat.bit2 set___
04h - Seek failed (when trying to use SeekL on Audio CDs)
___These values appear even if no command was sent; with stat.bit2 set___
08h - Drive door became opened
|
track: track number (AAh=Lead-out area) (FFh=unknown, toc, none?) index: index number (Usually 01h) mm: minute number within track (00h and up) ss: second number within track (00h to 59h) sect: sector number within track (00h to 74h) amm: minute number on entire disk (00h and up) ass: second number on entire disk (00h to 59h) asect: sector number on entire disk (00h to 74h) |
Caution: Supported only in BIOS version vC1 and up. Not supported in vC0. Caution: When unsupported, Parameter Fifo isn't cleared after the command. |
Drive Status 1st Response 2nd Response Door Open INT5(11h,80h) N/A Spin-up INT5(01h,80h) N/A Detect busy INT5(03h,80h) N/A No Disk INT3(stat) INT5(08h,40h, 00h,00h, 00h,00h,00h,00h) Audio Disk INT3(stat) INT5(0Ah,90h, 00h,00h, 00h,00h,00h,00h) Unlicensed:Mode1 INT3(stat) INT5(0Ah,80h, 00h,00h, 00h,00h,00h,00h) Unlicensed:Mode2 INT3(stat) INT5(0Ah,80h, 20h,00h, 00h,00h,00h,00h) Unlicensed:Mode2+Audio INT3(stat) INT5(0Ah,90h, 20h,00h, 00h,00h,00h,00h) Debug/Yaroze:Mode2 INT3(stat) INT2(02h,00h, 20h,00h, 20h,20h,20h,20h) Licensed:Mode2 INT3(stat) INT2(02h,00h, 20h,00h, 53h,43h,45h,4xh) Modchip:Audio/Mode1 INT3(stat) INT2(02h,00h, 00h,00h, 53h,43h,45h,4xh) |
1st byte: stat (as usually, but with bit3 same as bit7 in 2nd byte)
2nd byte: flags (bit7=denied, bit4=audio... or reportedly import, uh?)
bit7: Licensed (0=Licensed Data CD, 1=Denied Data CD or Audio CD)
bit6: Missing (0=Disk Present, 1=Disk Missing)
bit4: Audio CD (0=Data CD, 1=Audio CD) (always 0 when Modchip installed)
3rd byte: Disk type (from TOC Point=A0h) (eg. 00h=Audio or Mode1, 20h=Mode2)
4th byte: Usually 00h (or 8bit ATIP from Point=C0h, if session info exists)
that 8bit ATIP value is taken form the middle 8bit of the 24bit ATIP value
5th-8th byte: SCEx region (eg. ASCII "SCEE" = Europe) (0,0,0,0 = Unlicensed)
|
| CDROM - CD Audio Commands |
amm/ass/asect are returned on asect=00h,20h,40h,60h ;-absolute time mm/ss+80h/sect are returned on asect=10h,30h,50h,70h ;-within current track (or, in case of read errors, report may be returned on other asect's) |
Setmode.bit1=1: AutoPause=On --> Issue INT4(stat) and PAUSE at end of TRACK Setmode.bit1=0: AutoPause=Off --> Issue INT4(stat) and STOP at end of DISC |
| CDROM - Test Commands |
| CDROM - Test Commands - Version, Switches, Region, Chipset, SCEx |
(unknown) ;DTL-H2000 (with SPC700 instead HC05) 94h,09h,19h,C0h ;PSX (PU-7) 19 Sep 1994, version vC0 (a) 94h,11h,18h,C0h ;PSX (PU-7) 18 Nov 1994, version vC0 (b) 94h,11h,28h,01h ;PSX (DTL-H2000) 28 Nov 1994, version v01 (debug) 95h,05h,16h,C1h ;PSX (LATE-PU-8) 16 May 1995, version vC1 (a) 95h,07h,24h,C1h ;PSX (LATE-PU-8) 24 Jul 1995, version vC1 (b) 95h,07h,24h,D1h ;PSX (LATE-PU-8,debug ver)24 Jul 1995, version vD1 (debug) 96h,08h,15h,C2h ;PSX (PU-16, Video CD) 15 Aug 1996, version vC2 (VCD) 96h,08h,18h,C1h ;PSX (LATE-PU-8,yaroze) 18 Aug 1996, version vC1 (yaroze) 96h,09h,12h,C2h ;PSX (PU-18) (japan) 12 Sep 1996, version vC2 (a.jap) 97h,01h,10h,C2h ;PSX (PU-18) (us/eur) 10 Jan 1997, version vC2 (a) 97h,08h,14h,C2h ;PSX (PU-20) 14 Aug 1997, version vC2 (b) 98h,06h,10h,C3h ;PSX (PU-22) 10 Jun 1998, version vC3 (a) 99h,02h,01h,C3h ;PSX/PSone (PU-23, PM-41) 01 Feb 1999, version vC3 (b) A1h,03h,06h,C3h ;PSone/late (PM-41(2)) 06 Jun 2001, version vC3 (c) (unknown) ;PS2, xx xxx xxxx, late PS2 models...? |
Bit0 = HeadIsAtPos0 (0=No, 1=Pos0) Bit1 = DoorIsOpen (0=No, 1=Open) Bit2 = EjectButtonOrOutSwOrSo? (DTL-H2000 only) (always 0 on retail) Bit3-7 = AlwaysZero |
Caution: Supported only in BIOS version vC1 and up. Not supported in vC0. |
INT5(11h,10h) --> NTSC, Japan (vC0) --> requires "SCEI" discs
INT3("for Europe") --> PAL, Europe --> requires "SCEE" discs
INT3("for U/C") --> NTSC, North America --> requires "SCEA" discs
INT3("for Japan") --> NTSC, Japan / NTSC, Asia --> requires "SCEI" discs
INT3("for NETNA") --> Region-free yaroze version--> requires "SCEx" discs
INT3("for US/AEP") --> Region-free debug version --> accepts unlicensed CDRs
|
Caution: Supported only in BIOS version vC1 and up. Not supported in vC0. |
| CDROM - Test Commands - Test Drive Mechanics |
1 byte --> send CX(Xx) ;short 8bit command 2 bytes --> send CX(Xxxx) ;longer 16bit command 3 bytes --> send CX(Xxxxxx) ;full 24bit command 4 bytes --> send CX(Xxxxxxxx) ;extended 32bit command (BIOS vC3 only) 4..15 bytes: acts same as max (3 or 4 bytes) (extra bytes are ignored) 0 bytes or more than 15 bytes: generates an error |
| CDROM - Test Commands - Prototype Debug Transmission |
| CDROM - Test Commands - Read/Write Decoder RAM and I/O Ports |
index value 00h 04h ;04h=empty, 8Eh=licensed, 24h=audio 01h [0B1h] ;DCh=empty/licensed, DDh=audio 02h 00h 03h 00h ;or variable when disk inserted 04h 00h 05h 80h ;or 86h or 89h when disk inserted 06h C0h 07h 02h 08h 8Ah 09h C0h 0Ah 00h 0Bh C0h 0Ch [1F2h] 0Dh [1F3h] 0Eh 00h ;or 8Eh or E6h when disk inserted ;D4h/audio 0Fh 00h ;or sometimes 01h when disk inserted ;50h/audio 10h C0h 11h E0h 12h 71h 13h stat 14h FFh 15h..1Fh C0h-filled ;or 17h --> DEh |
;other response on param xx16h,xx18h with xx>00h |
The first bytes are NOT affected by: destroying [1F0h] via too-many-parameters in command-buffer, changes to [1F1h] which may occur after read command (eg. may be 20h) |
| CDROM - Test Commands - Read HC05 SUB-CPU RAM and I/O Ports |
000h 4 FF 7B 00 FF (other when disk inserted) 004h 5 11 00 20 20 0C 009h 1 00 (when disk inserted: changes between 00 or 80) 00Ah 2 71 00 00Ch 1 00 (when disk inserted: changes between 00 or 80) 00Dh 3 20 20 20 010h 8 02 80 00 60 00 00 99(orBB) 98 018h 4 changes randomly (even when no disk inserted) 01Ch 3 40 00 41 01Fh 1 changes randomly (even when no disk inserted) 020h 30 20h-filled 03Eh 2 82h 20h |
040h 4 08 00 00 00 ;or 98 07 xx 0B when disk inserted ;[40].Bit1=MUTE
044h 4 00h-filled
048h 3 40 20 00 ;or 58 71 0F when disk inserted
04Bh 1 changes randomly (nodisk: 00 or 80 / disk: BFh)
04Ch 1 Zero (or C0h)
04Dh 3 MM:SS:FF (begin of current track MM:SS:00h) (or increasing addr)
050h 10 Subchannel Q (adjusted position values)
05Ah 2 ...
05Ch 1 00h (or 64h)
05Dh 3 MM:SS:FF (current read address) (sticky address during pause)
060h 1 increments at circa 16Hz or so (or other rate when spinning)
061h 12 00h-filled ;or else when disk inserted
06Dh 1 01 ;or 0C when disk inserted
06Eh 2 SetFilter setting (file,channel)
070h 16 00h-filled ;or else when disk inserted
080h 8 00h-filled
088h 3 03:SS:FF (three, second, fraction)
08Bh 3 03:SS:FF (three, second, fraction)
08Eh 2 01 FF (or other values)
090h 1 00h (or 91h when disk inserted + spinning)
091h 13 Zero
09Eh 1 00h (or 01h when disk inserted + spinning)
09Fh 1 Zero
0A0h 1 Always 23h
0A1h 1 09h (5Dh when disk inserted)
0A2h 7 00h-filled
0A9h 1 40
0AAh 4 00h-filled
0AEh 1 00 (no disk) or 01 (disk) or so
0AFh 1 00 ;or 06 when disk inserted
0B0h 7 00 DC 00 02 00 E0 08 ;\or else when disk inserted
0B7h 1 20 ;Bit6+7=MUTE ;
0B8h 3 DE 00 00 ;/
0BBh 1 SetMode setting (mode)
0BCh 1 GetStat setting (stat)
0BDh 3 00h-filled
0C0h 6 FFh-filled ;stack... ;\
0C6h 1 Usually DFh ;sometimes [0EBh and up] are non-FFh, too
0C7h 15 FFh-filled ;(depending on disk or commands or so)
0D6h 1 Usually FDh (or FFh) ; ;
0D7h 24 FFh-filled ; stack
0EFh 4 on power-up FFh-filled, other once when disk read ;
0F3h 7 changes randomly (even when no disk inserted) ;
0FAh 6 2E 3C 2A D6 10 95 ;/
100h 2x99 TOC Entries for Start of Track 1..99 (MM:SS)
1C6h 1 TOC First Track number (usually 01h)
1C7h 1 TOC Last Track number (usually 01h or higher)
1C8h 3 TOC Entry for Start of Lead-Out (MM:SS:FF)
1CBh 2 Zero
1CDh 1 Depends on disk (01 or 02 or 06) (or 00 when no disk)
1CEh 1 Zero
1CFh 1 Depends on disk (NULL minus N*6) (or 00 when no disk)
(maybe reflection level / laser intensity or so)
[1CDh..1CFh]
01 00 E8 --> licensed/metalgear/kain
01 00 EE --> licensed/alone2
06 00 E2 or 00 00 02 00 E8 --> licensed/wipeout
02 00 DC --> unlicensed/elo
02 00 D6 --> unlicensed/driver
00 00 EE --> audio/lola
00 00 FA --> audio/marilyn
00 00 F4 --> audio/westen
00 00 00 --> disk missing
last byte is always in steps of 6
1D0h 4 SCEx String
1D4h 4 Zero
1D8h 2 SCEx Counters (total,success) ;for command 19h,05h
1DAh 6 00h-filled (or ... SS:FF)
1E0h 6 Command Buffer (usually 19h,60h,E2h,01h = Read RAM Command)
1E6h 7 00h-filled (unless destroyed by more-than-6-byte-commands)
1EDh 3 Setloc setting (MM:SS:FF)
1F0h 1 00h (unless destroyed by more-than-6-byte-commands)
1F1h 3 C0h 00h 00h ;or 20h,0Ch,50h or C0h,0Ch,08h ;for command(19h,75h)
;or 00h,00h,00h for audio
;or 80h,00h,00h for disk missing
1F4h 4 00h-filled ... or SCEx string
1F8h 1 00h
1F9h 1 Selected Target (parameter from Play and SetSession commands)
1FAh 5 00h-filled ;01 01 00 8B 00 00 ;or 01 02 8B 00 00
01 00 8B 00 00 -- audio/unlicensed
01 01 00 00 00 -- licensed
1FFh 1 00h-on power up, changes when disk inserted ;or 01 = Playing
1FDh 3 MM:SS:FF (only during command 19h,00h) (MM=98..99=TOC)
200h 10 Subchannel Q (real values)
20Ah 2 whatever
20Ch 1 Zero
20Dh 1 Desired Session (from SetSession command)
20Eh 1 Current Session (actual location of drive head)
20Fh 1 Zero
210h 10 Subchannel Q (adjusted position values)
21Ah 6 00h-filled
220h 4 Data Sector Header (MM:SS:FF:Mode)
224h 4 Data Sector CD-XA Subheader (file,channel,sm,ci)
228h 1 00h
229h 1 Usually 00h (shortly other value on power-up, and maybe on seek)
22Ah 1 10h (or 00h when no disk)
22Bh 3 00h-filled
22Eh 2 01,03 or 0A,00 or 03,01 (or else for other disk)
230h 3 00h-filled (or other during spin-up / read-toc or so)
233h 0Dh 00h-filled (unused RAM)
|
240h..2FFh - Invalid (00h-filled) (no ROM, RAM, or I/O mapped here) 300h..3FFh - Mirror of 200h..2FFh ;\the BIOS is doing that 400h..FFFFh - Mirrors of 000h..3FFh ;/mirroring by software |
000h..0DFh RAM Part 1 (C0h bytes) 0E0h..0FFh I/O Area 100h..1DFh RAM Part 2 (C0h bytes) 1E0h..1FFh I/O Area 200h..2DFh RAM Part 3 (100h bytes) 2E0h..7FFFh Unknown 8000h-BFFFh Unknown (lower 16K of 32K EPROM) (or unused?) C000h-FFFFh Firmware (upper 16K of 32K EPROM) |
| CDROM - Secret Unlock Commands |
Caution: Supported only in BIOS version vC1 and up. Not supported in vC0. Caution: Supported only in Europe/USA. Nonfunctional in Japan/Asia. Caution: When unsupported, Parameter Fifo isn't cleared after the command. |
"of America" ;for NTSC/US ;\ "(Europe)" ;for PAL/Europe ; handled, and actually working "World wide" ;for Yaroze ;/ "Inc." ;for NTSC/JP ;-non-functional |
| CDROM - Video CD Commands |
Caution: Supported only on SCPH-5903, not supported on any other consoles. Caution: When unsupported, Parameter Fifo isn't cleared after the command. |
1Fh VideoCD sub,a,b,c,d,e INT3(stat,a,b,c,d,e) ;<-- SCPH-5903 only 1Fh..4Fh - - INT5(11h,40h) ;-Unused/invalid |
0 Drive Door (0=Open) (from CDROM stat bit4) ;Open 1 Button /\ (0=Pressed) (from PSX pad bit12) ;N/A ;PBC: Back/LevelUp 2 Button [] (0=Pressed) (from PSX pad bit15) ;Enter Menu 3 Button () (0=Pressed) (from PSX pad bit13) ;Leave Menu ;PBC: Confirm 4 Button >< (0=Pressed) (from PSX pad bit14) ;N/A 5 Start (0=Pressed) (from PSX pad bit3) ;Play/Pause 6 Select (0=Pressed) (from PSX pad bit0) ;Stop (prompt restart/resume) 7 Always 0 (0) (fixed) ;N/A 8 DPAD Up (0=Pressed) (from PSX pad bit4) ;Menu Up ;PBC: +1 9 DPAD Right (0=Pressed) (from PSX pad bit5) ;Menu Right/change ;PBC: +10 10 DPAD Down (0=Pressed) (from PSX pad bit6) ;Menu Down ;PBC: -1 11 DPAD Left (0=Pressed) (from PSX pad bit7) ;Menu Left/change ;PBC: -10 12 Button R1 (0=Pressed) (from PSX pad bit11) ;Prev Track/Restart Track 13 Button R2 (0=Pressed) (from PSX pad bit9) ;Fast Forward (slowly) 14 Button L1 (0=Pressed) (from PSX pad bit10) ;Next Track (if any) 15 Button L2 (0=Pressed) (from PSX pad bit8) ;Fast Backward (slowly) |
00h Motor Off (or spin-up) (when stat.bit1=0) 01h Playing (when stat.bit7=1) 02h Paused (and not seeking) (when stat.bit6=0) (note: State remains unchanged when seeking) |
00h = Confirms that "Tocread" (aka setsession 1) request was processed 01h = Detect VCD Disc (used on power-up, and after door open) (after spin-up) 02h = Handshake (request ack response) 0Ah = Door opened during play (int5/door error) 80h = No disc FFh = No change (nop) |
00h Normal (no special event occured and no action requested) 01h Request CD to Seek_and_play (using mm:ss:ff response parameter bytes) 02h Request CD to Pause ;cmd(09h) -->int3(stat),int2(stat) 03h Request CD to Stop ;cmd(08h) -->int3(stat),int2(stat) 04h Request CD to Tocread (setsession1);cmd(12h,01h)-->int3(stat),int2(stat) 05h Handshake Command was processed, and this is the "ack" response 06h Request CD to Fast Forward ;cmd(04h) -->int3(stat) 07h Request CD to Fast Backward ;cmd(05h) -->int3(stat) 80h Detect Command was processed, and disc was detected as VCD 81h Detect Command was processed, and disc was detected as Non-VCD |
00h = Normal PSX Mode (PortF.3=LOW) (Audio/Video from GPU/SPU chips) 01h..FFh = Special VCD Mode (PortF.3=HIGH) (Audio/Video from MDEC/OSD chips) |
x = don't care/garbage
v = toggle state (00h=normal=PortF.3=LOW, 01h..FFh=special=PortF.3=HIGH)
(toggle gpu vs mpeg maybe?)
a,b,c,d,e = five bytes sent serially, and five bytes response received
serially (send/receive done simultaneously)
|
Port F.Bit0 = Serial Data In Port F.Bit1 = Serial Data Out Port F.Bit2 = Serial Clock Out Port F.Bit3 = Toggle (0=Normal, 1=Special) |
| CDROM - Mainloop/Responses |
check for incoming sectors (from CDROM decoder) check for incoming commands (from Main CPU) do maintenance stuff on the drive mechanics |
Main CPU has sent a command, AND, there is no INT pending (if an INT is pending, then the command won't be executed yet, but will be executed in following mainloop cycles; once when INT got acknowledged) (even if no INT is pending, the mainloop may generate INT1/INT2 before executing the command, if so, as said above, the command won't execute yet) |
07h MotorOn E - INT3(stat), INT2(stat) 08h Stop E - INT3(stat), INT2(stat) 09h Pause E - INT3(stat), INT2(stat) 0Ah Init - INT3(late-stat), INT2(stat) 12h SetSession E session INT3(stat), INT2(stat) 15h SeekL E - INT3(stat), INT2(stat) ;\use prior Setloc 16h SeekP E - INT3(stat), INT2(stat) ;/to set target 1Ah GetID E - INT3(stat), INT2/5(stat,flg,typ,atip,"SCEx") 1Dh GetQ E adr,point INT3(stat), INT2(10bytesSubQ,peak_lo) 1Eh ReadTOC - INT3(late-stat), INT2(stat) |
03h Play E (track) INT3(stat), optional INT1(report bytes) 04h Forward E - INT3(stat), optional INT1(report bytes) 05h Backward E - INT3(stat), optional INT1(report bytes) 06h ReadN E - INT3(stat), INT1(stat), datablock 1Bh ReadS E?- INT3(stat), INT1(stat), datablock |
| CDROM - Response Timings |
Command Average Min Max GetStat (normal) 000c4e1h 0004a73h..003115bh GetStat (when stopped) 0005cf4h 000483bh..00093f2h |
Init 0013cceh 000f820h..00xxxxxh |
Command Average Min Max GetID 0004a00h 0004922h..0004c2bh Pause (single speed) 021181ch 020eaefh..0216e3ch ;\time equal to Pause (double speed) 010bd93h 010477Ah..011B302h ;/about 5 sectors Pause (when paused) 0001df2h 0001d25h..0001f22h Stop (single speed) 0d38acah 0c3bc41h..0da554dh Stop (double speed) 18a6076h 184476bh..192b306h Stop (when stopped) 0001d7bh 0001ce8h..0001eefh |
Command Average Min Max Read (single speed) 006e1cdh 00686dah..0072732h Read (double speed) 0036cd2h 00322dfh..003ab2bh |
| CDROM - Response/Data Queueing |
Setloc(0:2:0)+Read Process INT1 --> receives sector header for 0:2:0 Process INT1 --> receives sector header for 0:2:1 Process INT1 --> receives sector header for 0:2:2 Process INT1 --> receives sector header for 0:2:3 |
Setloc(0:2:0)+Read Process INT1 --> receives sector header for 0:2:0 delay(1) Process INT1 --> receives sector header for 0:2:1 (oldest sector) Process INT1 --> receives sector header for 0:2:6 (newest sector) Process INT1 --> receives sector header for 0:2:7 (next sector) |
Setloc(0:2:0)+Read Process INT1 --> receives sector header for 0:2:0 delay(2) Process INT1 --> receives sector header for 0:2:9 (oldest/overwritten) Process INT1 --> receives sector header for 0:2:11 (newest sector) Process INT1 --> receives sector header for 0:2:12 (next sector) |
Setloc(0:2:0)+Read Process INT1 --> receives sector header for 0:2:0 delay(3) Process INT1 --> receives sector header for 0:2:17 (currently received) Process INT1 --> receives sector header for 0:2:16 (newest full sector) Process INT1 --> receives sector header for 0:2:17 (next sector) Process INT1 --> receives sector header for 0:2:18 (next sector) |
Setloc(0:2:0)+Read Process INT1 --> receives sector header for 0:2:0 GetlocL Process INT3 --> receives getloc info for 0:2:0 Process INT1 --> receives sector header for 0:2:1 Process INT1 --> receives sector header for 0:2:2 Process INT1 --> receives sector header for 0:2:3 |
Setloc(0:2:0)+Read Process INT1 --> receives sector header for 0:2:0 Delay(1) GetlocL Process INT1 --> receives sector header for 0:2:1 Process INT3 --> receives getloc info for 0:2:6 Process INT1 --> receives sector header for 0:2:6 Process INT1 --> receives sector header for 0:2:7 |
Setloc(0:2:0)+Read Process INT1 --> receives sector header for 0:2:0 GetlocL Delay(1) Process INT3 --> receives getloc info for 0:2:0 Process INT1 --> receives sector header for 0:2:5 Process INT1 --> receives sector header for 0:2:6 Process INT1 --> receives sector header for 0:2:7 |
Setloc(0:2:0)+Read Process INT1 --> receives sector header for 0:2:0 Delay(1) GetlocL Delay(1) Process INT1 --> receives sector header for 0:2:9 Process INT1 --> receives sector header for 0:2:11 Process INT3 --> receives getloc info for 0:2:12 Process INT1 --> receives sector header for 0:2:12 Process INT1 --> receives sector header for 0:2:13 |
Setloc(0:2:0)+Read Process INT1 --> receives sector header for 0:2:0 Pause Process INT3 --> receives stat=22h (first pause response) Process INT2 --> receives stat=02h (second pause response) |
Setloc(0:2:0)+Read Process INT1 --> receives sector header for 0:2:0 Delay(1) Pause Process INT1 --> receives sector header for 0:2:1 (oldest) Process INT3 --> receives stat=22h (first pause response) Process INT2 --> receives stat=02h (second pause response) |
Setloc(0:2:0)+Read Process INT1 --> receives sector header for 0:2:0 Pause Delay(1) Process INT3 --> receives stat=22h (first pause response) Process INT2 --> receives stat=02h (second pause response) |
Setloc(0:2:0)+Read Process INT1 --> receives sector header for 0:2:0 Delay(1) Pause Delay(1) Process INT1 --> receives sector header for 0:2:9 (oldest/overwritten) Process INT3 --> receives stat=22h (first pause response) Process INT2 --> receives stat=02h (second pause response) |
Setloc(0:2:0)+Read Process INT1 --> receives sector header for 0:2:0 GetlocL Pause Process INT3 --> receives stat=22h (first pause response) Process INT2 --> receives stat=02h (second pause response) |
Setloc(0:2:0)+Read Process INT1 --> receives sector header for 0:2:0 Delay(1) GetlocL Pause Process INT1 --> receives sector header for 0:2:1 Process INT1 --> receives sector header for 0:2:6 Process INT3 --> receives stat=22h (first pause response) Process INT2 --> receives stat=02h (second pause response) |
Setloc(0:2:0)+Read Process INT1 --> receives sector header for 0:2:0 GetlocL Delay(1) Pause Process INT3 --> receives getloc info for 0:2:0 (first getloc response) Process INT3 --> receives stat=22h (first pause response) Process INT2 --> receives stat=02h (second pause response) |
Setloc(0:2:0)+Read Process INT1 --> receives sector header for 0:2:0 Delay(1) GetlocL Delay(1) Pause Process INT1 --> receives sector header for 0:2:9 (oldest/overwritten) Process INT3 --> receives stat=22h (first pause response) Process INT2 --> receives stat=02h (second pause response) |
Setloc(0:2:0)+Read Process INT1 --> receives sector header for 0:2:0 Pause GetlocL Process INT3 --> receives getloc info for 0:2:0 (first getloc response) Process INT1 --> receives sector header for 0:2:1 Process INT1 --> receives sector header for 0:2:2 Process INT1 --> receives sector header for 0:2:3 |
Setloc(0:2:0)+Read Process INT1 --> receives sector header for 0:2:0 Delay(1) Pause GetlocL Process INT1 --> receives sector header for 0:2:1 Process INT3 --> receives getloc info for 0:2:6 (first getloc response) Process INT1 --> receives sector header for 0:2:6 Process INT1 --> receives sector header for 0:2:7 |
Setloc(0:2:0)+Read Process INT1 --> receives sector header for 0:2:0 Pause Delay(1) GetlocL Process INT3 --> receives stat=22h (first pause response) Process INT3 --> receives getloc info for 0:2:6 (first getloc response) (No further INT's, ie. read is paused, but second-pause-response is lost). |
Setloc(0:2:0)+Read Process INT1 --> receives sector header for 0:2:0 Pause Delay(1) GetlocL Delay(1) Process INT3 --> receives stat=22h (first pause response) Process INT3 --> receives getloc info for 0:2:6 (first getloc response) Process INT2 --> receives stat=02h (second pause response) |
Setloc(0:2:0)+Read Process INT1 --> receives sector header for 0:2:0 Delay(1) Pause Delay(1) GetlocL Process INT1 --> receives sector header for 0:2:9 Process INT1 --> receives sector header for 0:2:11 Process INT3 --> receives getloc info for 0:2:12 (first getloc response) Process INT1 --> receives sector header for 0:2:12 Process INT1 --> receives sector header for 0:2:13 |
| CDROM Disk Format |
Originally intended for Mode1 Sectors (but is also used for CD-XA Mode2) Supports "FILENAME.EXT;VERSION" filenames (version is usually "1") Supports all-uppercase filenames and directory names (0-9, A-Z, underscore) For PSX: Max 8-character filenames with max 3-character extensions For PSX: Max 8-character directory names, without extension For PSX: Max one sector per directory (?) (but Resident Evil 2 has bigger??) For PSX: Max one sector (or less?) per path table (?) |
Uses Mode2 Sectors (see Sector Encoding chapter) Allows 800h or 914h byte data per sector (with/without error correction) Allows to break interleaved data into separate files/channels Supports XA-ADPCM compressed audio data Stores "CD-XA001" at 400h Primary Volume Descriptor (?) Stores 14 extra bytes in System Use area (LEN_SU) of Directory Entries |
Defines physical metrics of the CDROM and Audio disks Defines Sub-channels and Track.Index and Minute.Second.Fraction numbering Defines 14bit-per-byte encoding, and splits sectors into frames Defines ECC and EDC (error correction and error detection codes) |
sessions one or more sessions per disk tracks 99 tracks per disk (01h..99h) (usually only 01h on Data Disks) index 99 indices per track (01h..99h) (rarely used, usually always 01h) minutes 74 minutes per disk (00h..73h) (or more, with some restrictions) seconds 60 seconds per minute (00h..59h) sectors 75 sectors per second (00h..74h) frames 98 frames per sector bytes 33 bytes per frame (24+1+8 = data + subchannel + error correction) bits 14 bits per byte (256 valid combinations, and many invalid ones) |
| CDROM Subchannels |
Bits Expl. 2 Sub-channel synchronization field 8 ADR/Control (see below) 72 Data (content depends on ADR) 16 CRC-16-CCITT error detection code (big-endian: bytes ordered MSB, LSB) |
Bit0-3 ADR (0=No data, 1..3=see below, 4..0Fh=Reserved) Bit4 Audio Preemphasis (0=No, 1=Yes) (Audio only, must be 0 for Data) Bit5 Digital Copy (0=Prohibited, 1=Allowed) Bit6 Data (0=Audio, 1=Data) Bit7 Four-Channel Audio (0=Stereo, 1=Quad) (Audio only, must be 0 for Data) |
8 Track number (fixed, must be 00h=Lead-in)
8 Point (01h..99h or A0h..A2h, see last three bytes for more info)
24 MSF address (incrementing address within the Lead-in area)
Note: On some disks, these values are choosen so that the lead-in
<starts> at 00:00:00, on other disks so that it <ends> at 99:59:74.
8 Reserved (00h)
|
24 MSF address (absolute address, start address of the "Point" track) |
8 First Track number (BCD) 8 Disk Type Byte (00h=CD-DA or CD-ROM, 10h=CD-I, 20h=CD-ROM-XA) 8 Reserved (00h) |
8 Last Track number (BCD) 16 Reserved (0000h) |
8 Track number (01h..99h=Track 1..99) 8 Index number (00h=Pause, 01h..99h=Index within Track) 24 Track relative MSF address (decreasing during Pause) 8 Reserved (00h) 24 Absolute MSF address |
8 Track number (fixed, must be AAh=Lead-Out) 8 Index number (fixed, must be 01h) (there's no Index=00h in Lead-Out) 24 Track relative MSF address (increasing, 00:00:00 and up) 8 Reserved (00h) 24 Absolute MSF address |
52 EAN-13 barcode number (13-digit BCD) 12 Reserved (000h) 8 Absolute Sector number (BCD, 00h..74h) (always 00h during Lead-in) |
12 Country Code (two 6bit characters) (ASCII minus 30h) ;eg. "US" 18 Owner Code (three 6bit characters) (ASCII minus 30h) 2 Reserved (zero) 8 Year of recording (2-digit BCD) ;eg. 82h for 1982 20 Serial number (5-digit BCD) ;usually increments by 1 or 10 per track 4 Reserved (zero) 8 Absolute Sector number (BCD, 00h..74h) (always 00h during Lead-in) |
8 Track number (fixed, must be 00h=Lead-in)
8 POINT = B0h (multi-session disc)
24 MM:SS:FF = the start time for the next possible session's program area,
a final session is indicated by FFh:FFh:FFh,
or when the ADR=5 / Point=B0h is absent.
8 Number of different Mode-5 pointers present.
24 MM:SS:FF = the maximum possible start time of the outermost Lead-out
|
8 Track number (fixed, must be 00h=Lead-in) 8 POINT = C0h (Identifies a Multisession disc, together with POINT=B0h) 24 ATIP values from Special Information 1, ID=101 8 Reserved (must be 00h) 24 MM:SS:FF = Start time of the first Lead-in area of the disc |
8 Track number (fixed, must be 00h=Lead-in) 8 POINT=C1h 8x7 Copy of information from A1 point in ATIP |
8 Track number (fixed, must be AAh=Lead-out) 8 POINT = D1h (Identifies a Multisession lead-out) 24 Usually zero (or maybe ATIP as in Lead-In with Point=C0h...?) 8 Seems to be the session number? 24 MM:SS:FF = Absolute address of the First data sector of the session |
8 Track number (fixed, must be 00h=Lead-in) 8 POINT=01h..40h (This identifies a specific playback skip interval) 24 MM:SS:FF Skip interval stop time in 6 BCD digits 8 Reserved (must be 00h) 24 MM:SS:FF Skip interval start time in 6 BCD digits |
8 Track number (fixed, must be 00h=Lead-in) 8 POINT=B1h (Audio only: This identifies the presence of skip intervals) 8x4 Reserved (must be 00h,00h,00h,00h) 8 the number of skip interval pointers in POINT=01h..40h 8 the number of skip track assignments in POINT=B2h..B4h 8 Reserved (must be 00h) |
8 Track number (fixed, must be 00h=Lead-in) 8 POINT=B2h,B3h,B4h (This identifies tracks that should be skipped) 8 1st Track number to skip upon playback (01h..99h, must be nonzero) 8 2nd Track number to skip upon playback (01h..99h, or 00h=None) 8 3rd Track number to skip upon playback (01h..99h, or 00h=None) 8 Reserved (must be 00h)... unclear... OR... 4th (of 7) skip info's...? 8 4th Track number to skip upon playback (01h..99h, or 00h=None) 8 5th Track number to skip upon playback (01h..99h, or 00h=None) 8 6th Track number to skip upon playback (01h..99h, or 00h=None) |
CD-TEXT in the Lead-In area (see below) CD-TEXT in the Data area (rarely used) CD plus Graphics (CD+G) (rarely used) |
00h 1 Header Field ID1: Pack Type Indicator 01h 1 Header Field ID2: Track Number 02h 1 Header Field ID3: Sequence Number 03h 1 Header Field ID4: Block Number and Character Position Indicator 04h 12 Text/Data Field 10h 2 CRC-16-CCITT (big-endian) (across bytes 00h..0Fh) |
80h Titel (TEXT) 81h Performer (TEXT) 82h Songwriter (TEXT) 83h Composer (TEXT) 84h Arranger (TEXT) 85h Message (TEXT) 86h Disc ID (TEXT?) (content/format/purpose unknown?) 87h Genre (BINARY) (ID codes unknown?) 88h TOC (BINARY) (content/format/purpose unknown?) 89h TOC2 (BINARY) (content/format/purpose unknown?) 8Ah Reserved for future 8Bh Reserved for future 8Ch Reserved for future 8Dh Reserved for "content provider" aka "closed information" 8Eh UPC/EAN and ISRC Codes (TEXT) (content/format/purpose unknown?) 8Fh Blocksize (BINARY) (see below) |
00h Title/Performer/etc. for the Disc 01h..63h Title/Performer/etc. for Track 1..99 (Non-BCD) (Bit7=Extension) |
00h..FFh Incrementing Number (00h=First 18-byte fragment, 01h=Second, etc.) |
Bit7 Character Set (0=8bit, 1=16bit) Bit6-4 Block Number (0..7 = Language number, as set by "Blocksize") Bit3-0 Character Position (0..0Eh=Position, 0Fh=Append to prev fragment) |
ID TR SQ CH <------------Text/Data------------> -CRC- <---Text---> 80 00 00 00 54 65 73 74 44 69 73 6B 54 69 74 6C E2 22 TestDiskTitl 80 00 01 0C 65 00 54 65 73 74 54 72 61 63 6B 54 C9 1B e.TestTrackT 80 01 02 0A 69 74 6C 65 31 00 54 65 73 74 54 72 40 3A itle1.TestTr 80 02 03 06 61 63 6B 54 69 74 6C 65 32 00 00 00 80 E3 ackTitle2... 81 00 04 00 54 65 73 74 44 69 73 6B 50 65 72 66 03 DF TestDiskPerf 81 00 05 0C 6F 72 6D 65 72 00 54 65 73 74 54 72 12 A5 ormer.TestTr 81 01 06 06 61 63 6B 50 65 72 66 6F 72 6D 65 72 BC 5B ackPerformer 81 01 07 0F 31 00 54 65 73 74 54 72 61 63 6B 50 AC 41 1.TestTrackP 81 02 08 0A 65 72 66 6F 72 6D 65 72 32 00 00 00 64 1A erformer2... 8F 00 09 00 01 01 02 00 04 05 00 00 00 00 00 00 6D E2 ............ 8F 01 0A 00 00 00 00 00 00 00 00 03 0B 00 00 00 CD 0C ............ 8F 02 0B 00 00 00 00 00 09 00 00 00 00 00 00 00 FC 8C ............ 00 ;<--- for some reason, CDRWIN stores an ending 00h byte in .CDT files |
00h 1 Character set (00h,01h,80h,81h,82h = see below) 01h 1 First track number (usually/always 01h) 02h 1 Last track number (01h..63h) 03h 1 1bit-cd-text-in-data-area-flag, 7bit-copy-protection-flags 04h 16 Number of 18-byte packs for ID1=80h..8Fh 14h 8 Last sequence number of block 0..7 (or 00h=none) 1Ch 8 Language codes for block 0..7 (definitions are unknown) |
00h ISO 8859-1 01h ISO 646, ASCII 80h MS-JIS 81h Korean character code 82h Mandarin (standard) Chinese character code Other = reserved |
lsb=00h, msb=00h ;-initial value (zero for both CD-TEXT and Sub-Q)
for i=0 to len-1 ;-len (10h for CD-TEXT, 0Ah for Sub-Q)
x = [addr+i] xor msb
x = x xor (x shr 4)
msb = lsb xor (x shr 3) xor (x shl 4)
lsb = x xor (x shl 5)
next i
[addr+len+0]=msb xor FFh, [addr+len+1]=lsb xor FFh ;inverted / big-endian
|
| CDROM Sector Encoding |
000h 930h Audio Data (2352 bytes) (LeftLsb,LeftMsb,RightLsb,RightMsb) |
000h 0Ch Sync (00h,FFh,FFh,FFh,FFh,FFh,FFh,FFh,FFh,FFh,FFh,00h) 00Ch 4 Header (Minute,Second,Sector,Mode=00h) 010h 920h Zerofilled |
000h 0Ch Sync (00h,FFh,FFh,FFh,FFh,FFh,FFh,FFh,FFh,FFh,FFh,00h) 00Ch 4 Header (Minute,Second,Sector,Mode=01h) 010h 800h Data (2048 bytes) 810h 4 EDC (checksum across [000h..80Fh]) 814h 8 Zerofilled 81Ch 114h ECC (error correction codes) |
000h 0Ch Sync (00h,FFh,FFh,FFh,FFh,FFh,FFh,FFh,FFh,FFh,FFh,00h) 00Ch 4 Header (Minute,Second,Sector,Mode=02h) 010h 4 Sub-Header (File, Channel, Submode AND DFh, Codinginfo) 014h 4 Copy of Sub-Header 018h 800h Data (2048 bytes) 818h 4 EDC (checksum across [010h..817h]) 81Ch 114h ECC (error correction codes) |
000h 0Ch Sync (00h,FFh,FFh,FFh,FFh,FFh,FFh,FFh,FFh,FFh,FFh,00h) 00Ch 4 Header (Minute,Second,Sector,Mode=02h) 010h 4 Sub-Header (File, Channel, Submode OR 20h, Codinginfo) 014h 4 Copy of Sub-Header 018h 914h Data (2324 bytes) 92Ch 4 EDC (checksum across [010h..92Bh]) (or 00000000h if no EDC) |
sector[000h]=00h,FFh,FFh,FFh,FFh,FFh,FFh,FFh,FFh,FFh,FFh,00h
sector[00ch]=bcd(adr/75/60) ;0..7x
sector[00dh]=bcd(adr/75 MOD 60) ;0..59
sector[00eh]=bcd(adr MOD 75) ;0..74
sector[00fh]=mode
if mode=00h then
sector[010h..92Fh]=zerofilled
if mode=01h then
adjust_edc(sector+0, 800h+10h)
sector[814h..817h]=00h,00h,00h,00h,00h,00h,00h,00h
calc_p_parity(sector)
calc_q_parity(sector)
if mode=02h and form=1
sector[012h]=sector[012h] AND (NOT 20h) ;indicate not form2
sector[014h..017h]=sector[010h..013h] ;copy of sub-header
adjust_edc(sector+10h,800h+8)
push sector[00ch] ;\temporarily clear header
sector[00ch]=00000000h ;/
calc_p_parity(sector)
calc_q_parity(sector)
pop sector[00ch] ;-restore header
if mode=02h and form=2
sector[012h]=sector[012h] OR 20h ;indicate form2
sector[014h..017h]=sector[010h..013h] ;copy of sub-header
adjust_edc(sector+10h,914h+8) ;edc is optional for form2
|
src=00ch, dst=81ch+offs, srcmax=dst
for i=0 to len-1
base=src, x=0000h, y=0000h
for j=j0 to 42
x=x xor GF8_PRODUCT[j,sector[src+0]]
y=y xor GF8_PRODUCT[j,sector[src+1]]
src=src+step1, if (step1=2*44) and (src>=srcmax) then src=src-2*1118
sector[dst+2*len+0]=x AND 0FFh, [dst+0]=x SHR 8
sector[dst+2*len+1]=y AND 0FFh, [dst+1]=y SHR 8
dst=dst+2, src=base+step2
|
x=00000000h
for i=0 to len-1
x=x xor byte[addr+i], x=(x shr 8) xor edc_table[x and FFh]
word[addr+len]=x ;append EDC value (little endian)
|
for i=0 to FFh
x=i, for j=0 to 7, x=x shr 1, if carry then x=x xor D8018001h
edc_table[i]=x
GF8_LOG[00h]=00h, GF8_ILOG[FFh]=00h, x=01h
for i=00h to FEh
GF8_LOG[x]=i, GF8_ILOG[i]=x
x=x SHL 1, if carry8bit then x=x xor 1dh
for j=0 to 42
xx=GF8_ILOG[44-j], yy=subfunc(xx xor 1,19h)
xx=subfunc(xx,01h), xx=subfunc(xx xor 1,18h)
xx=GF8_LOG[xx], yy = GF8_LOG[yy]
GF8_PRODUCT[j,0]=0000h
for i=01h to FFh
x=xx+GF8_LOG[i], if x>=255 then x=x-255
y=yy+GF8_LOG[i], if y>=255 then y=y-255
GF8_PRODUCT[j,i]=GF8_ILOG[x]+(GF8_ILOG[y] shl 8)
|
if a>0 then
a=GF8_LOG[a]-b, if a<0 then a=a+255
a=GF8_ILOG[a]
return(a)
|
| CDROM Scrambling |
poly=0001h ;init 15bit polynomial counter
for i=0 to 924h-1
scramble_table[i]=poly AND FFh
poly=(((poly XOR poly/2) AND 0FFh)*80h) XOR (poly/100h)
next i
|
01h,80h,00h,60h,00h,28h,00h,1Eh,80h,08h,60h,06h,A8h,02h,FEh,81h, 80h,60h,60h,28h,28h,1Eh,9Eh,88h,68h,66h,AEh,AAh,FCh,7Fh,01h,E0h, etc. |
| CDROM XA Subheader, File, Channel, Interleave |
0-7 File Number (00h..FFh) (for Audio/Video Interleave, see below) |
0-4 Channel Number (00h..1Fh) (for Audio/Video Interleave, see below) 5-7 Should be always zero |
0 End of Record (EOR) (all Volume Descriptors, and all sectors with EOF) 1 Video ;\Sector Type (usually ONE of these bits should be set) 2 Audio ; Note: PSX .STR files are declared as Data (not as Video) 3 Data ;/Note: VCD videos start with empty sectors, all 3 bits cleared 4 Trigger (for application use) 5 Form2 (0=Form1/800h-byte data, 1=Form2, 914h-byte data) 6 Real Time (RT) 7 End of File (EOF) (or end of Directory/PathTable/VolumeTerminator) |
0-7 Reserved (00h) |
0-1 Mono/Stereo (0=Mono, 1=Stereo, 2-3=Reserved) 2-2 Sample Rate (0=37800Hz, 1=18900Hz, 2-3=Reserved) 4-5 Bits per Sample (0=Normal/4bit, 1=8bit, 2-3=Reserved) 6 Emphasis (0=Normal/Off, 1=Emphasis) 7 Reserved (0) |
Interleave Data Format 1/1 (none) 44100Hz Stereo CD Audio at normal speed 1/8 37800Hz Stereo ADPCM compressed Audio at double speed 1/16 18900Hz Stereo ADPCM compressed Audio at double speed 1/16 37800Hz Mono ADPCM compressed Audio at double speed 1/32 18900Hz Mono ADPCM compressed Audio at double speed 7/8 15fps 320x224 pixel MDEC compressed Videos at double speed Unknown if 1/16 and 1/32 interleaves are actually possible (the PSX cdrom controller seems to overwrite the IC303 sector buffer entries once every eight sectors, so ADPCM data may get destroyed on interleaves above 1/8). (Crash Team Racing uses 37800Hz Mono at Double speed, so 1/16 must work). |
one file with eight 1/8 audio channels one file with one 1/8 audio channels, plus one 7/8 video channel (*) one file with one 1/8 audio channels, plus 7 unused channels eight different files with one 1/8 audio channel each etc. |
Subheader bytes: 01h,FFh,64h,01h ;Ace Combat 3 Electrosphere Subheader bytes: 01h,00h,00h,00h ;Misadventures of Tron Bonne (XA\*.XA) |
| CDROM XA Audio ADPCM Compression |
00h..03h Copy of below 4 bytes (at 04h..07h) 04h Header for 1st Block/Mono, or 1st Block/Left 05h Header for 2nd Block/Mono, or 1st Block/Right 06h Header for 3rd Block/Mono, or 2nd Block/Left 07h Header for 4th Block/Mono, or 2nd Block/Right 08h Header for 5th Block/Mono, or 3rd Block/Left ;\unknown/unused 09h Header for 6th Block/Mono, or 3rd Block/Right ; for 8bit ADPCM 0Ah Header for 7th Block/Mono, or 4th Block/Left ; (maybe 0, or maybe 0Bh Header for 8th Block/Mono, or 4th Block/Right ;/copy of above) 0Ch..0Fh Copy of above 4 bytes (at 08h..0Bh) |
10h..13h 1st Data Word (packed 1st samples for 2-8 blocks) 14h..17h 2nd Data Word (packed 2nd samples for 2-8 blocks) 18h..1Bh 3rd Data Word (packed 3rd samples for 2-8 blocks) ... Nth Data Word (packed Nth samples for 2-8 blocks) 7Ch..7Fh 28th Data Word (packed 28th samples for 2-8 blocks) |
0-3 Shift (0..12) (0=Loudest) (13..15=Reserved/Same as 9) 4-5 Filter (0..3) (only four filters, unlike SPU-ADPCM which has five) 6-7 Unused (should be 0) |
0-3 Nibble for 1st Block/Mono, or 1st Block/Left (-8h..+7h) 4-7 Nibble for 2nd Block/Mono, or 1st Block/Right (-8h..+7h) 8-11 Nibble for 3rd Block/Mono, or 2nd Block/Left (-8h..+7h) 12-15 Nibble for 4th Block/Mono, or 2nd Block/Right (-8h..+7h) 16-19 Nibble for 5th Block/Mono, or 3rd Block/Left (-8h..+7h) 20-23 Nibble for 6th Block/Mono, or 3rd Block/Right (-8h..+7h) 24-27 Nibble for 7th Block/Mono, or 4th Block/Left (-8h..+7h) 28-31 Nibble for 8th Block/Mono, or 4th Block/Right (-8h..+7h) |
0-7 Byte for 1st Block/Mono, or 1st Block/Left (-80h..+7Fh) 8-15 Byte for 2nd Block/Mono, or 1st Block/Right (-80h..+7Fh) 16-23 Byte for 3rd Block/Mono, or 2nd Block/Left (-80h..+7Fh) 24-31 Byte for 4th Block/Mono, or 2nd Block/Right (-80h..+7Fh) |
src=src+12+4+8 ;skip sync,header,subheader
for i=0 to 11h
for blk=0 to 3
IF stereo ;left-samples (LO-nibbles), plus right-samples (HI-nibbles)
decode_28_nibbles(src,blk,0,dst_left,old_left,older_left)
decode_28_nibbles(src,blk,1,dst_right,old_right,older_right)
ELSE ;first 28 samples (LO-nibbles), plus next 28 samples (HI-nibbles)
decode_28_nibbles(src,blk,0,dst_mono,old_mono,older_mono)
decode_28_nibbles(src,blk,1,dst_mono,old_mono,older_mono)
ENDIF
next blk
src=src+128
next i
src=src+14h+4 ;skip padding,edc
|
shift = 12 - (src[4+blk*2+nibble] AND 0Fh)
filter = (src[4+blk*2+nibble] AND 30h) SHR 4
f0 = pos_xa_adpcm_table[filter]
f1 = neg_xa_adpcm_table[filter]
for j=0 to 27
t = signed4bit((src[16+blk+j*4] SHR (nibble*4)) AND 0Fh)
s = (t SHL shift) + ((old*f0 + older*f1+32)/64)
s = MinMax(s,-8000h,+7FFFh)
halfword[dst]=s, dst=dst+2, older=old, old=s
next j
|
pos_xa_adpcm_table[0..4] = (0, +60, +115, +98, +122) neg_xa_adpcm_table[0..4] = (0, 0, -52, -55, -60) |
. .
.--------------. | | | |
| | .'.'.'----'.'.'.
| | | | | |
| | | |
| Decompressed | | Final |
| XA-ADPCM | | XA-ADPCM |
| Waveform | | Output |
| | | | | |
| | ---.'.'.' '.'.'.---
--------' '-------- | | | |
' '
|
Output37800Hz(sample):
ringbuf[p AND 1Fh]=sample, p=p+1, sixstep=sixstep-1
if sixstep=0
sixstep=6
Ouput44100Hz(ZigZagInterpolate(p,Table1))
Ouput44100Hz(ZigZagInterpolate(p,Table2))
Ouput44100Hz(ZigZagInterpolate(p,Table3))
Ouput44100Hz(ZigZagInterpolate(p,Table4))
Ouput44100Hz(ZigZagInterpolate(p,Table5))
Ouput44100Hz(ZigZagInterpolate(p,Table6))
Ouput44100Hz(ZigZagInterpolate(p,Table7))
endif
ZigZagInterpolate(p,TableX):
sum=0
for i=1 to 29, sum=sum+(ringbuf[(p-i) AND 1Fh]*TableX[i])/8000h, next i
return MinMax(sum,-8000h,+7FFFh)
Table1, Table2, Table3, Table4, Table5, Table6, Table7 ;Index
0 , 0 , 0 , 0 , -0001h, +0002h, -0005h ;1
0 , 0 , 0 , -0001h, +0003h, -0008h, +0011h ;2
0 , 0 , -0001h, +0003h, -0008h, +0010h, -0023h ;3
0 , -0002h, +0003h, -0008h, +0011h, -0023h, +0046h ;4
0 , 0 , -0002h, +0006h, -0010h, +002Bh, -0017h ;5
-0002h, +0003h, -0005h, +0005h, +000Ah, +001Ah, -0044h ;6
+000Ah, -0013h, +001Fh, -001Bh, +006Bh, -00EBh, +015Bh ;7
-0022h, +003Ch, -004Ah, +00A6h, -016Dh, +027Bh, -0347h ;8
+0041h, -004Bh, +00B3h, -01A8h, +0350h, -0548h, +080Eh ;9
-0054h, +00A2h, -0192h, +0372h, -0623h, +0AFAh, -1249h ;10
+0034h, -00E3h, +02B1h, -05BFh, +0BCDh, -16FAh, +3C07h ;11
+0009h, +0132h, -039Eh, +09B8h, -1780h, +53E0h, +53E0h ;12
-010Ah, -0043h, +04F8h, -11B4h, +6794h, +3C07h, -16FAh ;13
+0400h, -0267h, -05A6h, +74BBh, +234Ch, -1249h, +0AFAh ;14
-0A78h, +0C9Dh, +7939h, +0C9Dh, -0A78h, +080Eh, -0548h ;15
+234Ch, +74BBh, -05A6h, -0267h, +0400h, -0347h, +027Bh ;16
+6794h, -11B4h, +04F8h, -0043h, -010Ah, +015Bh, -00EBh ;17
-1780h, +09B8h, -039Eh, +0132h, +0009h, -0044h, +001Ah ;18
+0BCDh, -05BFh, +02B1h, -00E3h, +0034h, -0017h, +002Bh ;19
-0623h, +0372h, -0192h, +00A2h, -0054h, +0046h, -0023h ;20
+0350h, -01A8h, +00B3h, -004Bh, +0041h, -0023h, +0010h ;21
-016Dh, +00A6h, -004Ah, +003Ch, -0022h, +0011h, -0008h ;22
+006Bh, -001Bh, +001Fh, -0013h, +000Ah, -0005h, +0002h ;23
+000Ah, +0005h, -0005h, +0003h, -0001h, 0 , 0 ;24
-0010h, +0006h, -0002h, 0 , 0 , 0 , 0 ;25
+0011h, -0008h, +0003h, -0002h, +0001h, 0 , 0 ;26
-0008h, +0003h, -0001h, 0 , 0 , 0 , 0 ;27
+0003h, -0001h, 0 , 0 , 0 , 0 , 0 ;28
-0001h, 0 , 0 , 0 , 0 , 0 , 0 ;29
|
.------------. ....-----.
| | .'' |
| Raw | .' XA |
| ADPCM | | Emphasis '.
| Waveform | | Output '..
--------' '---------- --------' ''''---
|
00h 4 "RIFF" 04h 4 Total Filesize (minus 8) 08h 8 "CDXAfmt " 10h 4 Size of below stuff (10h) 14h 14 Stuff (looks like the "LEN_SU" region from XA-Directory Record) 22h 2 Zero (probably just dummy padding for 32bit alignment) 24h 4 "data" 28h 4 Size of following data (usually N*930h) |
| CDROM ISO Volume Descriptors |
Sector 0..3 - Zerofilled (Mode2/Form1, 4x800h bytes, plus ECC/EDC) Sector 4 - Licence String Sector 5..11 - Playstation Logo (3278h bytes) (remaining bytes FFh-filled) Sector 12..15 - Zerofilled (Mode2/Form2, 4x914h bytes, plus EDC) |
000h 32 Line 1 (" Licensed by ")
020h 32+6 Line 2 (EU) ("Sony Computer Entertainment Euro"," pe ") ;\either
020h 32+1 Line 2 (JP) ("Sony Computer Entertainment Inc.",0Ah) ; one of
020h 32+6 Line 2 (US) ("Sony Computer Entertainment Amer"," ica ") ;/these
041h 1983 Empty (JP) (filled by repeating pattern 62x30h,1x0Ah, 1x30h)
046h 1978 Empty (EU/US) (filled by 00h-bytes)
|
0000h .. 41h,00h,00h,00h,00h,00h,00h,00h,01h,00h,00h,00h,1Ch,23h,00h,00h 0010h .. 51h,01h,00h,00h,A4h,2Dh,00h,00h,99h,00h,00h,00h,1Ch,00h,00h,00h 0020h .. ... 3278h 588h FF-filled (remaining bytes on sector 11) |
Sector 16 - Primary Volume Descriptor Sector 17 - Volume Descriptor Set Terminator |
000h 1 Volume Descriptor Type (01h=Primary Volume Descriptor)
001h 5 Standard Identifier ("CD001")
006h 1 Volume Descriptor Version (01h=Standard)
007h 1 Reserved (00h)
008h 32 System Identifier (a-characters) ("PLAYSTATION")
028h 32 Volume Identifier (d-characters) (max 8 chars for PSX?)
048h 8 Reserved (00h)
050h 8 Volume Space Size (2x32bit, number of logical blocks)
058h 32 Reserved (00h)
078h 4 Volume Set Size (2x16bit) (usually 0001h)
07Ch 4 Volume Sequence Number (2x16bit) (usually 0001h)
080h 4 Logical Block Size in Bytes (2x16bit) (usually 0800h) (1 sector)
084h 8 Path Table Size in Bytes (2x32bit) (max 800h for PSX)
08Ch 4 Path Table 1 Block Number (32bit little-endian)
090h 4 Path Table 2 Block Number (32bit little-endian) (or 0=None)
094h 4 Path Table 3 Block Number (32bit big-endian)
098h 4 Path Table 4 Block Number (32bit big-endian) (or 0=None)
09Ch 34 Root Directory Record (see next chapter)
0BEh 128 Volume Set Identifier (d-characters) (usually empty)
13Eh 128 Publisher Identifier (a-characters) (company name)
1BEh 128 Data Preparer Identifier (a-characters) (empty or other)
23Eh 128 Application Identifier (a-characters) ("PLAYSTATION")
2BEh 37 Copyright Filename ("FILENAME.EXT;VER") (empty or text)
2E3h 37 Abstract Filename ("FILENAME.EXT;VER") (empty)
308h 37 Bibliographic Filename ("FILENAME.EXT;VER") (empty)
32Dh 17 Volume Creation Timestamp ("YYYYMMDDHHMMSSFF",timezone)
33Eh 17 Volume Modification Timestamp ("0000000000000000",00h)
34Fh 17 Volume Expiration Timestamp ("0000000000000000",00h)
360h 17 Volume Effective Timestamp ("0000000000000000",00h)
371h 1 File Structure Version (01h=Standard)
372h 1 Reserved for future (00h-filled)
373h 141 Application Use Area (00h-filled for PSX and VCD)
400h 8 CD-XA Identifying Signature ("CD-XA001" for PSX and VCD)
408h 2 CD-XA Flags (unknown purpose) (00h-filled for PSX and VCD)
40Ah 8 CD-XA Startup Directory (00h-filled for PSX and VCD)
412h 8 CD-XA Reserved (00h-filled for PSX and VCD)
41Ah 345 Application Use Area (00h-filled for PSX and VCD)
573h 653 Reserved for future (00h-filled)
|
000h 1 Volume Descriptor Type (FFh=Terminator)
001h 5 Standard Identifier ("CD001")
006h 1 Terminator Version (01h=Standard)
007h 2041 Reserved (00h-filled)
|
000h 1 Volume Descriptor Type (00h=Boot Record)
001h 5 Standard Identifier ("CD001")
006h 1 Boot Record Version (01h=Standard)
007h 32 Boot System Identifier (a-characters)
027h 32 Boot Identifier (a-characters)
047h 1977 Boot System Use (not specified content)
|
000h 1 Volume Descriptor Type (02h=Supplementary Volume Descriptor) 001h .. Same as for Primary Volume Descriptor (see there) 007h 1 Volume Flags (8bit) 008h .. Same as for Primary Volume Descriptor (see there) 058h 32 Escape Sequences (32 bytes) 078h .. Same as for Primary Volume Descriptor (see there) |
000h 1 Volume Descriptor Type (03h=Volume Partition Descriptor)
001h 5 Standard Identifier ("CD001")
006h 1 Volume Partition Version (01h=Standard)
007h 1 Reserved (00h)
008h 32 System Identifier (a-characters) (32 bytes)
028h 32 Volume Partition Identifier (d-characters) (32 bytes)
048h 8 Volume Partition Location (2x32bit) Logical Block Number
050h 8 Volume Partition Size (2x32bit) Number of Logical Blocks
058h 1960 System Use (not specified content)
|
000h 1 Volume Descriptor Type (04h..FEh=Reserved, don't use) 001h 2047 Reserved (don't use) |
| CDROM ISO File and Directory Descriptors |
00h 1 Length of Directory Record (LEN_DR) (33+LEN_FI+pad+LEN_SU) (0=Pad)
01h 1 Extended Attribute Record Length (usually 00h)
02h 8 Data Logical Block Number (2x32bit)
0Ah 8 Data Size in Bytes (2x32bit)
12h 7 Recording Timestamp (yy-1900,mm,dd,hh,mm,ss,timezone)
19h 1 File Flags 8 bits (usually 00h=File, or 02h=Directory)
1Ah 1 File Unit Size (usually 00h)
1Bh 1 Interleave Gap Size (usually 00h)
1Ch 4 Volume Sequence Number (2x16bit, usually 0001h)
20h 1 Length of Name (LEN_FI)
21h LEN_FI File/Directory Name ("FILENAME.EXT;1" or "DIR_NAME" or 00h or 01h)
xxh 0..1 Padding Field (00h) (only if LEN_FI is even)
xxh LEN_SU System Use (LEN_SU bytes) (see below for CD-XA disks)
|
00h 2 Owner ID Group (whatever, usually 0000h, big endian)
02h 2 Owner ID User (whatever, usually 0000h, big endian)
04h 2 File Attributes (big endian):
0 Owner Read (usually 1)
1 Reserved (0)
2 Owner Execute (usually 1)
3 Reserved (0)
4 Group Read (usually 1)
5 Reserved (0)
6 Group Execute (usually 1)
7 Reserved (0)
8 World Read (usually 1)
9 Reserved (0)
10 World Execute (usually 1)
11 IS_MODE2 (0=MODE1 or CD-DA, 1=MODE2)
12 IS_MODE2_FORM2 (0=FORM1, 1=FORM2)
13 IS_INTERLEAVED (0=No, 1=Yes...?) (by file and/or channel?)
14 IS_CDDA (0=Data or ADPCM, 1=CD-DA Audio Track)
15 IS_DIRECTORY (0=File or CD-DA, 1=Directory Record)
Commonly used Attributes are:
0D55h=Normal Binary File (with 800h-byte sectors)
1555h=VCD movie or Junk (fade to black .DPS and .XA files)
2555h=Uncommon (wipeout .AV files) (MODE1 ??)
4555h=CD-DA Audio Track (wipeout .SWP files, alone .WAV file)
3D55h=Streaming File (ADPCM and/or MDEC or so)
8D55h=Directory Record (parent-, current-, or sub-directory)
06h 2 Signature ("XA")
08h 1 File Number (Must match Subheader's File Number)
09h 5 Reserved (00h-filled)
|
- Directory sizes are always rounded up to N*800h-bytes. - Directory entries should not cross 800h-byte sector boundaries. There may be further directory entries on the next sector after the padding. To deal with that, skip 00h-bytes until finding a nonzero LEN_DR value (or slightly faster, upon a 00h-byte, directly jump to next sector instead of doing a slow byte-by-byte skip). Note: Padding between sectors does rarely happen on PSX discs because the PSX kernel supports max 800h bytes per directory (one exception is PSX Hot Shots Golf 2, which has an ISO directory with more than 800h bytes; it does use a lookup file instead of actually parsing the whole ISO directory). |
00h 1 Length of Directory Name (LEN_DI) (01h..08h for PSX) 01h 1 Extended Attribute Record Length (usually 00h) 02h 4 Directory Logical Block Number (LBA) 06h 2 Parent Directory Number (0001h and up) 08h LEN_DI Directory Name (d-characters, d1-characters) (or 00h for Root) xxh 0..1 Padding Field (00h) (only if LEN_FI is odd) |
00h 4 Owner Identification (numerical value) ;\used only if
04h 4 Group Identification (numerical value) ; File Flags Bit4=1
08h 2 Permission Flags (16bit, little-endian) ;/
0Ah 17 File Creation Timestamp ("YYYYMMDDHHMMSSFF",timezone)
1Bh 17 File Modification Timestamp ("0000000000000000",00h)
2Ch 17 File Expiration Timestamp ("0000000000000000",00h)
3Dh 17 File Effective Timestamp ("0000000000000000",00h)
4Eh 1 Record Format (numerical value)
4Fh 1 Record Attributes (numerical value)
50h 4 Record Length (numerical value)
54h 32 System Identifier (a-characters, a1-characters)
74h 64 System Use (not specified content)
B4h 1 Extended Attribute Record Version (numerical value)
B5h 1 Length of Escape Sequences (LEN_ESC)
B6h 64 Reserved for future standardization (00h-filled)
F6h 4 Length of Application Use (LEN_AU)
FAh LEN_AU Application Use
xxh LEN_ESC Escape Sequences
|
| CDROM ISO Misc |
2x16bit value 1234h ---> stored as 34h,12h,12h,34h 2x32bit value 12345678h ---> stored as 78h,56h,34h,12h,12h,34h,56h,78h |
"0..9", "A..Z", and "_" |
"0..9", "A..Z", SPACE, "!"%&'()*+,-./:;<=>?_" |
"YYYYMMDDHHMMSSFF",timezone "0000000000000000",00h ;empty timestamp |
year-1900,month,day,hour,minute,second,timezone 00h,00h,00h,00h,00h,00h,00h ;empty timestamp |
0 Existence (0=Normal, 1=Hidden)
1 Directory (0=File, 1=Directory)
2 Associated File (0=Not an Associated File, 1=Associated File)
3 Record
If set to ZERO, shall mean that the structure of the information in
the file is not specified by the Record Format field of any associated
Extended Attribute Record (see 9.5.8).
If set to ONE, shall mean that the structure of the information in
the file has a record format specified by a number other than zero in
the Record Format Field of the Extended Attribute Record (see 9.5.8).
4 Restrictions (0=None, 1=Restricted via Permission Flags)
5 Reserved (0)
6 Reserved (0)
7 Multi-Extent (0=Final Directory Record for the file, 1=Not final)
|
0-3 Permissions for upper-class owners 4-7 Permissions for normal owners 8-11 Permissions for upper-class users 12-15 Permissions for normal users |
Bit0 Permission to read the file (0=Yes, 1=No) Bit1 Must be set (1) Bit2 Permission to execute the file (0=Yes, 1=No) Bit3 Must be set (1) |
| CDROM Extension Joliet |
Sector 16 - Primary Volume Descriptor (with 8bit uppercase ASCII ISO names) Sector 17 - Secondary Volume Descriptor (with 16bit Unicode Joliet names) Sector 18 - Volume Descriptor Set Terminator Sector .. - Path Tables and Directory Records (for ISO) Sector .. - Path Tables and Directory Records (for Joliet) Sector .. - File Data Sectors (shared for ISO and Joliet) |
000h 1 Volume Descriptor Type (02h=Supplementary instead of 01h=Primary) 007h 1 Volume Flags (whatever, instead of Reserved) 008h 2x32 Identifier Strings (16-char Unicode instead 32-char ASCII) 058h 32 Escape Sequences (see below, instead of Reserved) 08Ch 4x4 Path Tables (point to new tables with Unicode chars) 09Ch 34 Root Directory Record (point to root with Unicode chars) 0BEh 4x128 Identifier Strings (64-char Unicode instead 128-char ASCII) 2BEh 3x37 Filename Strings (18-char Unicode instead 37-char ASCII) |
%/@ UCS-2 Level 1 %/C UCS-2 Level 2 %/E UCS-2 Level 3 |
max 64 chars according to original Joliet specs from 1995 max 110 chars (on standard CDROMs, with LEN_SU=0) max 103 chars (on CD-XA discs, with LEN_SU=14) |
http://littlesvr.ca/isomaster/resources/JolietSpecification.html |
| CDROM Problems and Repair |
- A PSX game disc (for the correct region) - A regular Audio disc to check if the drive can read anything at all |
| CDROM File Formats |
| CDROM File Official Sony File Formats |
File Formats
(c) 1998 Sony Computer Entertainment Inc.
Publication date: November 1998
Chapter 1: Streaming Audio and Video Data
STR: Streaming (Movie) Data 1-3
BS: MDEC Bitstream Data 1-8
XA: CD-ROM Voice Data 1-31
Chapter 2: 3D Graphics
RSD: 3D Model Data [RSD,PLY,MAT,GRP,MSH,PVT,COD,MOT,OGP] 2-3
TMD: Modeling Data for OS Library 2-24
PMD: High-Speed Modeling Data 2-35
TOD: Animation Data 2-40
HMD: Hierarchical 3D Model, Animation and Other Data 2-49
Chapter 3: 2D Graphics
TIM: Screen Image Data 3-3
SDF: Sprite Editor Project File 3-8
PXL: Pixel Image Data 3-11
CLT: Palette Data 3-14
ANM: Animation Information 3-16
TSQ: Animation Time Sequence 3-22
CEL: Cell Data 3-23
BGD: BG Map Data 3-27
Chapter 4: Sound
SEQ: PS Sequence Data 4-3
SEP: PS Multi-Track Sequence Data 4-3
VAG: PS Single Waveform Data 4-5
VAB: PS Sound Source Data [VAB and VH/VB] 4-5
DA: CD-DA Data 4-7
Chapter 5: PDA and Memory Card
FAT: Memory Card File System Specification 5-3
|
| CDROM File Playstation EXE and SYSTEM.CNF |
BOOT = cdrom:\abcd_123.45;1 arg ;boot exe (drive:\path\name.ext;version) TCB = 4 ;HEX (=4 decimal) ;max number of threads EVENT = 10 ;HEX (=16 decimal) ;max number of events STACK = 801FFF00 ;HEX (=memtop-256) |
000h-007h ASCII ID "PS-X EXE"
008h-00Fh Zerofilled
010h Initial PC (usually 80010000h, or higher)
014h Initial GP/R28 (usually 0)
018h Destination Address in RAM (usually 80010000h, or higher)
01Ch Filesize (must be N*800h) (excluding 800h-byte header)
020h Unknown/Unused ;Addr (usually 0) ;\optional overlay?
024h Unknown/Unused ;Size (usually 0) ;/(not auto-loaded)
028h Memfill Start Address (usually 0) (when below Size=None)
02Ch Memfill Size in bytes (usually 0) (0=None)
030h Initial SP/R29 & FP/R30 Base (usually 801FFFF0h) (or 0=None)
034h Initial SP/R29 & FP/R30 Offs (usually 0, added to above Base)
038h-04Bh Reserved for A(43h) Function (should be zerofilled in exefile)
04Ch-xxxh ASCII marker
"Sony Computer Entertainment Inc. for Japan area" ;NTSC
"Sony Computer Entertainment Inc. for Europe area" ;PAL
"Sony Computer Entertainment Inc. for North America area" ;NTSC
(or often zerofilled in some homebrew files)
(the BIOS doesn't verify this string, and boots fine without it)
xxxh-7FFh Zerofilled
800h... Code/Data (loaded to entry[018h] and up)
|
| CDROM File PsyQ .CPE Files (Debug Executables) |
00h 4 File ID (01455043h aka "CPE",01h) |
00h 1 Chunk ID (00h) |
00h 1 Chunk ID (01h) 01h 4 Address (usually 80010000h and up) 05h 4 Size (LEN) 09h LEN Data (binary EXE code/data) |
00h 1 Chunk ID (02h) 01h 4 Address |
00h 1 Chunk ID (03h..06h) 01h 2 Register (usually 0090h=Initial PC, aka Entrypoint) 03h LEN Value (8bit..32bit) |
00h 1 Chunk ID (07h) 01h 4 Workspace number (usually 00000000h) |
00h 1 Chunk ID (08h) 01h 1 Unit (usually 00h) |
0000h 4 File ID ("CPE",01h)
0004h 2 Select Unit 0 (08h,00h)
0006h 7 Set Entrypoint 8001731Ch (03h,0090h,8001731Ch)
000Dh 0Dh Load (01h,800195F8h,00000004h,0,0,0,0)
001Ah .. Load (01h,80010000h,0000002Bh,...)
004Eh .. Load (01h,8001065Ch,00000120h,...)
0177h ... Load (01h,8001077Ch,0000012Ch,...)
02ACh ... Load (01h,800108A8h,000000A4h,...)
... ... Load (...)
98F4h ... Load (01h,800195F0h,00000008h,...)
9905h 1 End (00h)
|
| CDROM File PsyQ .SYM Files (Debug Information) |
Legacy of Kain PAL version (\DEGUG\NTSC\KAIN2.SYM+MAP+CPE) RC Revenge (\RELEASE.SYM) Twisted Metal: Small Brawl (MagDemo54: TMSB\TM.SYM) Jackie Chan Stuntmaster (GAME_REL.SYM+CPE) SnoCross Championship Racing (MagDemo37: SNOCROSS\SNOW.TOC\SNOW.MAP) Sled Storm (MagDemo24: DEBUG\MAIN.MAP) E.T. Interplanetary Mission (MagDemo54: MEGA\MEGA.CSH\* has SYM+CPE+MAP) |
00h 4 File ID ("MND",01h)
04h 4 Whatever (0,0,0,0) ;TOMB5: 0,02h,0,0
08h .. Chunks (see below)
|
_______________________________ Symbol Chunks ________________________________ |
00h 4 Address/Value 04h 1 Chunk ID (01h/02h/05h/06h) 05h 1 Symbol Length (LEN) 06h LEN Symbol (eg. "VSync") |
__________________________ Source Code Line Chunks ___________________________ |
00h 4 Address (for 1 line, starting at current line) 04h 1 Chunk ID (80h) |
00h 4 Address (for N lines, starting at current line) 04h 1 Chunk ID (82h) 05h 1 Number of Lines (00h=None, or 02h and up?) |
00h 4 Address (for N lines, starting at current line) 04h 1 Chunk ID (84h) 05h 2 Number of Lines (?) |
00h 4 Address (for 1 line, starting at newly assigned current line) 04h 1 Chunk ID (84h) 05h 4 Absolute Line Number (rather than number of lines) (?) |
00h 4 Address (start address) 04h 1 Chunk ID (88h=Filename) 05h 4 First Line Number (after comments/definitions) (32bit?) 09h 1 Filename Length (LEN) 0Ah LEN Filename (eg. "C:\path\main.c") |
00h 4 Address (end address) 04h 1 Chunk ID (8Ah) |
__________________________ Internal Function Chunks __________________________ |
00h 4 Address 04h 1 Chunk ID (8Ch) 05h 4 Whatever (1Eh,00h,20h,00h) ;or 1Eh,00h,18h,00h 09h 4 Whatever (00h,00h,1Fh,00h) 0Dh 4 Whatever (00h,00h,00h,C0h) 11h 4 Whatever (FCh,FFh,FFh,FFh) ;mask? neg.offset? 15h 4 Whatever (10h,00h,00h,00h) <-- line number (32bit?) 19h 1 Filename Length (LEN1) 1Ah LEN1 Filename (eg. "C:\path\main.c") xxh 1 Symbol Length (LEN2) xxh LEN2 Symbol (eg. "VSync") |
00h 4 Address 04h 1 Chunk ID (8Eh) 05h 4 Line Number <-- line number (32bit?) |
00h 4 Address 04h 1 Chunk ID (90h/92h) 05h 4 Whatever (1Fh,00h,00h,00h) <-- line number relative to main.start? |
_____________________________ Class/Type Chunks ______________________________ |
00h 4 Offset (when used within a structure, or stack-N, or otherwise zero) 04h 1 Chunk ID (94h) 05h 2 Class (000Dh=Type.alias, 000Ah=Address, 0001h=Stack, 0002h=Addr) 07h 2 Type (XX = 8bit,16bit,signed,etc.?) 09h 4 Zero, or Size in Bytes (for "memblocks") 0xh 1 Symbol Name Length (LEN) 0xh LEN Symbol Name (eg. "size_t") |
00h 4 Offset (when used within a structure, otherwise zero) 04h 1 Chunk ID (96h) 05h 2 Class (02h=Array,08h=RefToStruct,0Dh=DefineAlias,66h=StructEnd) 07h 2 Type (0xh=Small, 3xh=WithArrayStuff?) (same/similar as in chunk 94h) 09h 4 Struct Size in Bytes 0Dh 2 Array Dimensions (DIM) (0=none) ;eg. [3][4] --> 0002h 0Fh DIM*4 Array Entries per Dimension ;eg. [3][4] --> 00000003h,00000004h xxh 1 Internal Fake Name Length (LEN1) (0=none) xxh LEN1 Internal Fake Name (eg. ".1fake") xxh 1 Symbol Name Length (LEN2) xxh LEN2 Symbol Name (eg. "r") |
______________________________ Class/Type Values _____________________________ |
0001h = Local variable (with Offset = negative stack offset) 0002h = Global variable or Function (with Offset = address) 0008h = Item in Structure (with Offser = offset within struct) 0009h = Incoming Function param (with Offset = index; 0,4,8,etc.) 000Ah = Type address / struc start? (with Offset = zero) 000Dh = Type alias (with Offset = zero) |
0000h = 0001h = 0002h = 0003h = (16bit signed?) 0004h = int (32bit signed?) 0005h = 0006h = 0007h = 0008h = (address) (32bit unsigned?) (with Definition=000Ah) 0009h = 000Ah = 000Bh = 000Ch = u_char (8bit unsigned?) 000Dh = u_short,ushort (16bit unsigned?) 000Eh = u_int (32bit unsigned?) 000Fh = u_long (64bit unsigned?) (or rather SAME as above?) 0021h = function with 0 params, and/or return="nothing"? 0024h = main function with 2 params, and/or return="int"? 0052h = argv (string maybe?) 0038h = GsOT (huh?) 00F8h = GsOT_TAG (huh?) 00FCh = PACKET (huh?) ?? = float,bool,string,ptr,packet,(un-)signed8/16/32/64bit,etc ?? = custom type/struct (using value 000xh plus "fake" name, or so?) |
__________________________________ .MAP File _________________________________ |
Start Stop Length Obj Group Section name
80010000 80012D5B 00002D5C 80010000 text .rdata
80012D5C 800C8417 000B56BC 80012D5C text .text
800C8418 800CDAB7 000056A0 800C8418 text .data
800CDAB8 800CFB63 000020AC 800CDAB8 text .sdata
800CFB64 800D5C07 000060A4 800CFB64 bss .sbss
800D5C08 800DD33F 00007738 800D5C08 bss .bss
|
Address Names alphabetically 800CFE80 ACE_amount 800CFB94 AIMenu 800CDE5C AXIS_LENGTH 8005E28C AddClippedTri 8005DFEC AddVertex ... |
Address Names in address order 00000000 _cinemax_obj 00000000 _cinemax_header_org 00000000 _cinemax_org 00000000 _mcardx_sbss_size 00000000 _mcardx_org ... |
| CDROM File COFF Files (Executable/Object with Debug/Linking Information) |
PSX-SDK (PSYQ\BIN\CLEANMEM and PFLASH) ;ECOFF little-endian PSX-SDK (3RDPARTY\METROWER\SCELIB*\LIB\*.O) ;ECOFF big-endian !! PSX-SDK (PSYQ\BIN\EMU387) ;for i386 ;COFF (not a playstation binary) PSX Net Yaroze (DATA\*\*.FPC\*) ;ECOFF with TargetID=0162h PSX Net Yaroze (DATA\EDGE\*.FPC\OUT.COF) ;ECOFF corrupt TargetID=0000h PSX Net Yaroze (DATA\JAPAN\TERRAI.FPC\*.EXE) ;ECOFF corrupt lacks symtab |
| CDROM File COFF Files - Overview, Endianness, Detection |
At begin of File File Header After File Header Optional A.OUT Header After Optional A.OUT Header Section Header At location(s) stored in Section Header entries Section Data At location(s) stored in Section Header entries Relocation At location(s) stored in Section Header entries Line Numbers At location stored in File Header Symbol Table After Symbol Table String Table |
| CDROM File COFF Files - File Header and Target Machine IDs |
000h 2 Target Machine ID (see below list) 002h 2 Number of Sections 004h 4 Timestamp (seconds since 1970) 008h 4 Symbol Table Offset (0=None) 00Ch 4 Symbol Table Number of Entries (0=None) 010h 2 Optional A.OUT Header Size (usually 001Ch) 012h 2 Flags |
000h 08h Same as standard COFF File Header (see above) 008h 4 Symbol Table Offset (same as COFF, but uses different format) 00Ch 4 Symbol Table Header Size (0=None, 60h=ECOFF32) (not Num Entries!) 010h 2 Optional A.OUT Header Size (usually 38h=ECOFF32, xxh=ECOFF64) 012h 2 Flags |
000h 2 TICOFF ID (00C1h=TICOFF1, or 00C2h=TICOFF2) 002h 12h Same as standard COFF File Header (see above) 014h 2 Target Machine ID (located here, instead at [000h]) |
0000h pe.h Unknown (Net Yaroze Demo Disc DATA\EDGE\*.FPC\OUT.COF) 0088h m68k.h Motorola 68K? M68 (0210 octal) 0089h m68k.h Motorola 68K? M68TV (0211 octal) 0097h spraao8 Texas Instruments TMS470 0098h tic54x.h Texas Instruments TMS320C5400 TMS320C54X 0099h spraao8 Texas Instruments TMS320C6000 009Ch spraao8 Texas Instruments TMS320C5500 009Dh spraao8 Texas Instruments TMS320C2800 00A0h maxq.h MAXQ (whatever that is) 00A0h spraao8 Texas Instruments MSP430 00A1h spraao8 Texas Instruments TMS320C5500+ 00A4h psxspx COFF Xpert Teak DSP (used in Nintendo DSi Sound) 00C1h ti.h Texas Instruments TICOFF1 (with TargetID in FileHdr[14h]) 00C2h ti.h Texas Instruments TICOFF2 (with TargetID in FileHdr[14h]) 0093h tic4x.h Texas Instruments TMS320C4X/C3X 0095h tic80.h Texas Instruments TMS320C80 (MVP) 010Dh *.h Lynx all-platform (i386.h, m68k.h, sparc.h) (0415 octal) 0140h ecoff.h ECOFF32 MIPS ISA level 3 big-endian 0142h ecoff.h ECOFF32 MIPS ISA level 3 little-endian 014Ch i386.h Intel i386 (386/486) (pe.h) 014Dh i860.h Intel i860 (with AOUTSZ=32) 0150h m68k.h Motorola 68K MC68KWR (0520 octal) writeable text segments 0151h m68k.h Motorola 68K MC68KRO (0521 octal) readonly shareable text seg 0152h m68k.h Motorola 68K MC68KPG (0522 octal) demand paged text segments 0154h i386.h Intel 386/486 (I386PTX) 0156h m68k.h Motorola 68K MC68KBCS Bull dpx/2 (0526 octal) 0160h i960.h Intel 80960 read-only text segments (with AOUTHDRSZ=32) 0160h m88k.h Motorola 88k - 88k BCS executable (0540 octal) 0160h sparc.h Sparc (0540 octal) 0160h ecoff.h ECOFF32 MIPS R3000 big-endian 0161h i960.h Intel 80960 read/write text segments (with AOUTHDRSZ=32) 0161h m88k.h Motorola 88k - DG/UX executable (0541 octal) 0162h ecoff.h ECOFF32 MIPS R3000 little-endian (pe.h, PSX-SDK, Net Yaroze) 0163h ecoff.h ECOFF32 MIPS R4000 ISA level 2 big-endian 0166h ecoff.h ECOFF32 MIPS R4000 ISA level 2 little-endian (pe.h, mipspe.h) 0168h pe.h ECOFF?? MIPS R10000 ? 0169h pe.h ECOFF?? MIPS WCE v2 ? 016Dh m88k.h Motorola 88k - Object file (0555 octal) 0170h we32k.h we32k without transfer vector 0171h we32k.h we32k with transfer vector 0172h we32k.h we32k reserved 0175h i386.h Intel 386/486 (I386AIX) 017Ah a29k.h AMD Am29000 (Byte 0 is MSB) (0572 octal) (a29k.h, or32.h) 017Bh a29k.h AMD Am29000 (Byte 0 is LSB) (0573 octal) (a29k.h, or32.h) 0180h ecoff.h ECOFF?? MIPS ? 0183h ecoff.h ECOFF64 Alpha (0603 octal)(Tru64) 0184h magdir ECOFF?? Alpha 32-bit (pe.h) 0185h ecoff.h ECOFF64 Alpha BSD 0188h ecoff.h ECOFF64 Alpha compressed by DEC's tools (0610 octal)(Tru64) 018Fh tru64 ECOFF?? Alpha Ucode object file, obsolete (0617 octal)(Tru64) 0197h apollo.h Apollo M68K (0627 octal) 01A2h sh.h Hitachi SH3 (little-endian Windows CE) (pe.h) 01A3h magdir Hitachi SH3 DSP (pe.h) 01A4h magdir Hitachi SH4E (pe.h) 01A6h magdir Hitachi SH4 (pe.h) 01A8h magdir Hitachi SH5 (pe.h) 01C0h arm.h ARMv4 (without THUMB) (pe.h) 01C2h arm.h ARMv4T (with THUMB) (pe.h) 01C4h magdir ARMv7 01D3h magdir Matsushita AM33 (pe.h) 01D8h rs6000.h XCOFF IBM RS/6000 writeable text segments **chh**(0730 octal) 01DDh rs6000.h XCOFF IBM RS/6000 readonly sharable text segments(0735 octal) 01DFh rs6000.h XCOFF IBM RS/6000 readonly text segments and TOC (0737 octal) 01EFh rs6k64.h XCOFF Aix 4.3 64-bit ;AOUTHDRSZ=72, AOUTSZ=120 (0757 octal) 01F0h pe.h PowerPC 32-bit, little-endian 01F1h pe.h PowerPC 32-bit, little-endian, with FPU 01F2h magdir PowerPC 64-bit, big-endian 01F7h rs6k64.h XCOFF AIX 5+ 64-bit ;AOUTHDRSZ=72, AOUTSZ=120 (0767 octal) 0200h ia64.h Intel/HP Itanium IA-64 https://bdsmovement.net/boycott-hp 0266h magdir MIPS16 (pe.h) 0268h magdir Motorola 68000 (pe.h) 0284h magdir Alpha 64-bit (pe.h) 0290h magdir PA-RISC 0366h magdir MIPS with FPU (pe.h) 0466h magdir MIPS16 with FPU (pe.h) 0500h sh.h Hitachi SH (big-endian) 0520h pe.h Tricore 0550h sh.h Hitachi SH (little-endian) 0601h magdir PowerPC 32-bit (big-endian) 0CEFh magdir Windows CE Common Executable Format (pe.h) 0EBCh magdir EFI byte code (pe.h) 3A64h magdir ARM64 (i386 ABI) 5032h magdir RISC-V 32-bit 5064h magdir RISC-V 64-bit 5128h magdir RISC-V 128-bit 6232h magdir LoongArch 32-bit 6264h magdir LoongArch 64-bit 6500h w65.h WDC 65816 8000h z8k.h Zilog Z800N 8300h h8300.h Hitachi/Renesas H8/300 8301h h8300.h Hitachi/Renesas H8/300-H 8302h h8300.h Hitachi/Renesas H8/300-S 8303h h8300.h Hitachi/Renesas H8/300-HN 8304h h8300.h Hitachi/Renesas H8/300-SN 8500h h8500.h Hitachi/Renesas H8/500 8664h magdir x86-64, AMD64 (pe.h) 9041h magdir Mitsubishi M32R (pe.h) A641h magdir ARM64 (x86-64 ABI) A64Eh magdir ARM64 (classic + x86-64 ABI) AA64h magdir ARM64 ACE1h magdir OMNI VM (omniprox.dll) C000h tic30.h Texas Instruments TMS320C3X (hmm, maybe endian-swap = 00C0h?) C0EEh magdir COM+ Execution Engine CEE (in object files) (pe.h) - xcoff.h XCOFF - mcore.h Motorola MCore stub go32.h PC running go32 (with 2048-byte stub before COFF hdr) |
| CDROM File COFF Files - Optional A.OUT Header |
000h 2 Aout Type ID (see below) 002h 2 Version stamp 004h 4 CODE Size (text size) 008h 4 DATA Size (initialized data size) 00Ch 4 BSS Size (uninitialized data size) 010h 4 Entrypoint Address 014h 4 CODE Start Address 018h 4 DATA Start Address |
000h 2 Aout Type ID (see below) ;\ 002h 2 Version stamp ; 004h 4 CODE Size (text size) ; same as COFF 008h 4 DATA Size (initialized data size) ; 00Ch 4 BSS Size (uninitialized data size) ; 010h 4 Entrypoint Address ; 014h 4 CODE Start Address ; 018h 4 DATA Start Address ;/ 01Ch 4 BSS Start Address ;\ 020h 4 coff_uint gpr mask A000077Eh ; extra stuff 024h 4 coff_word cpr mask cop 0 00000000h ; (including flags for general 028h 4 coff_word cpr mask cop 1 00000000h ; purpose CPU registers and 02Ch 4 coff_word cpr mask cop 2 00000000h ; coprocessor registers) 030h 4 coff_word cpr mask cop 3 00000000h ; 034h 4 coff_long gp value 001080D0h ;/ <-- what for? |
000h 2 Aout Type ID (see below) ;\same as COFF 002h 2 Version stamp ;/ 004h 2 Revision (bldrev) ;\extra stuff 006h 2 Unused (padding) ;/ 008h 8 CODE Size (text size) ;\ 010h 8 DATA Size (initialized data size) ; 018h 8 ...coff_long size ;or bss_size? ; as ECOFF32, but 64bit wide 020h 8 Entrypoint Address ; 028h 8 CODE Start Address ; 030h 8 DATA Start Address ; 038h 8 BSS Start Address ;/ 040h 4 coff_uint gprmask (CPU registers) ;\as ECOFF32, but only 1 copro 044h ? coff_word fprmask (FPU registers) ;/ 048h 8 coff_long gp_value ;-as ECOFF32, but 64bit wide |
0101h (0401 octal) ARM/SPARC target shlib (arm.h, sparc.h) 0104h (0404 octal) ARM/SPARC object files (arm.h, sparc.h) 0107h (0407 octal) Impure (not demand paged) (*.h) 0108h (0410 octal) Pure (also TICOFF) (*.h) 010Bh (0413 octal) Demand paged (*.h) 0111h (0421 octal) Standalone (*.h) 0123h (0443 octal) target shared lib (m68k.h), host shlib (arm.h, sparc.h) 020Bh (1103 octal) 32-bit image inside 64-bit address space (ia64.h) 0901h (4401 octal) Whatever (in Nintendo DSi Sound) |
| CDROM File COFF Files - Section, Relocation, Line Numbers, Strings |
000h 8 Section Name (max 8 chars, or reference to String Table) 008h 4 Physical address, aliased s_nlib 00Ch 4 Virtual address 010h 4 Section size 014h 4 File ptr to raw data for section 018h 4 File ptr to relocation 01Ch 4 File ptr to line numbers 020h 2 Number of relocation entries 022h 2 Number of line number entries 024h 4 Flags |
000h 4 Address of relocation 004h 4 Symbol we're adjusting for 008h 2 Type of relocation (6=ADDR32, 20=REL32) |
000h 4 Function name symbol index (when lnno=0) ... to Symbol Table?
Address of line number (when lnno=1..N)
004h 2 Line number within function (or 0=see above)
|
000h 4 Size of string table (N) 004h N-4 String(s), terminated by 00h each |
Name[0..3]=00000000h, with Name[4..7]=32bit Index in String Table, or Name[0..7]="/NNN",zeropadding (ASCII, with NNN=Decimal Index in String Table) |
| CDROM File COFF Files - Symbol Table |
000h 8 Symbol Name (max 8 chars, or reference to String Table)
008h 4 Symbol Value (depends of Type, eg. the address, if it's a label)
00Ch 2 Section Number (1..N) (or special values)
0000h Undefined (extern) Symbol
0001h..N Symbol belongs to Section 1..N
FFFEh Debugging Symbol ;\blah
FFFFh Absolute Symbol (a constant, not an address) ;/
00Eh 2 e_type
010h 1 e_sclass
011h 1 e_numaux
|
Type Bits Meaning T_NULL ---- 0000 00h No symbol T_VOID ---- 0001 01h void function argument (not used) T_CHAR ---- 0010 02h character T_SHORT ---- 0011 03h short integer T_INT ---- 0100 04h integer T_LONG ---- 0101 05h long integer T_FLOAT ---- 0110 06h floating point T_DOUBLE ---- 0111 07h double precision float T_STRUCT ---- 1000 08h structure T_UNION ---- 1001 09h union T_ENUM ---- 1010 0Ah enumeration T_MOE ---- 1011 0Bh member of enumeration T_UCHAR ---- 1100 0Ch unsigned character T_USHORT ---- 1101 0Dh unsigned short T_UINT ---- 1110 0Eh unsigned integer T_ULONG ---- 1111 0Fh unsigned long T_LNGDBL ---1 0000 10h long double (special case bit pattern) DT_NON --00 ---- 0xh No derived type DT_PTR --01 ---- 1xh pointer to T ;aka T=Type ? DT_FCN --10 ---- 2xh function returning T ;aka T=Type ? DT_ARY --11 ---- 3xh array of T ;aka T=Type ? |
e_type = base + derived << N_BTSHIFT; |
Value Class Meaning 00h 0 C_NULL No entry 01h 1 C_AUTO Automatic variable 02h 2 C_EXT External (public) symbol - this covers globals and externs 03h 3 C_STAT static (private) symbol 04h 4 C_REG register variable 05h 5 C_EXTDEF External definition 06h 6 C_LABEL label 07h 7 C_ULABEL undefined label 08h 8 C_MOS member of structure 09h 9 C_ARG function argument 0Ah 10 C_STRTAG structure tag 0Bh 11 C_MOU member of union 0Ch 12 C_UNTAG union tag 0Dh 13 C_TPDEF type definition 0Eh 14 C_USTATIC undefined static 0Fh 15 C_ENTAG enumaration tag 10h 16 C_MOE member of enumeration 11h 17 C_REGPARM register parameter 12h 18 C_FIELD bit field 13h 19 C_AUTOARG auto argument ;-blah 14h 20 C_LASTENT dummy entry (end of block) 62h 98 blah "func_start_@@@_3_xxx" ;\ 63h 99 blah "func_end_@@@_3_xxx" ; 64h 100 C_BLOCK ".bb" or ".eb" - beginning or end of block ; 65h 101 C_FCN ".bf" or ".ef" - beginning or end of function ; 66h 102 C_EOS end of structure ; blah 67h 103 C_FILE file name ; 68h 104 C_LINE line number, reformatted as symbol ; 69h 105 C_ALIAS duplicate tag ; 6Ah 106 C_HIDDEN ext symbol in dmert public lib ; 6Bh..70h blah ".ar" ; FFh 255 C_EFCN physical end of function ;/ |
.x_sym.x_misc.x_lnsz.x_size ;size in bytes (size*count) |
.x_sym.x_tagndx ;syment index for list of tags (will point
; to C_STRTAG, C_UNTAG, or C_ENTAG)
.x_sym.x_misc.x_lnsz.x_size ;size in bytes (size*count)
|
.x_scn.x_scnlen ;section length (bytes) .x_scn.x_nreloc ;number of relocation entries (ushort) .x_scn.x_nlinno ;number of line numbers (ushort) |
.x_sym.x_x_misc.x_lnsz.x_size ;the size of the struct/union/enum .x_sym.x_fcnary.x_fcn.x_endndx ;the symbol index after our list |
.x_sym.x_misc.x_lnsz.x_size ;the size of the struct/union/enum .x_sym.x_tagndx ;the symbol index of the start of our list |
.x_sym.x_x_misc.x_lnsz.x_size ;the number of bits |
.x_sym.x_misc.x_lnsz.x_lnno ;starting line number .x_sym.x_fcnary.x_fcn.x_endndx ;the symbol index after our block (if .bb) |
.x_sym.x_misc.x_lnsz.x_lnno ;starting line number .x_sym.x_misc.x_lnsz.x_size ;size in bytes |
.x_file.x_fname .x_file.x_n.x_zeroes .x_file.x_n.x_offset |
SClass Meaning of the Value C_AUTO,C_ARG Address of the variable, relative to %ebp C_EXT,C_STAT,others The address of the symbol C_REG The register number assigned to this variable C_MOS Offset of the member from the beginning of the structure C_MOE The value of this enum member C_FIELD The mask for this field C_EOS size of struct/union/enum |
| CDROM File COFF Files - References |
COFF http://fileformats.archiveteam.org/wiki/COFF ECOFF http://web.archive.org/web/2/http://en.wikipedia.org/wiki/ECOFF |
COFF http://www.delorie.com/djgpp/doc/coff/ TICOFF http://www.ti.com/lit/an/spraao8/spraao8.pdf ECOFF64 http://web.archive.org/web/20160305114748/http://h41361.www4.hp.com /docs/base_doc/DOCUMENTATION/V50A_ACRO_SUP/OBJSPEC.PDF XCOFF http://web.archive.org/web/2/https://www.ibm.com/docs/en/aix /7.1?topic=formats-xcoff-object-file-format |
https://opensource.apple.com/source/gdb/gdb-1708/src/include/coff/ (see *.h) |
ecoff.h ECOFF general structures, excluding symtab sym.h ECOFF symtab structures symconst.h ECOFF symtab constants alpha.h ECOFF64 structures and constants |
https://raw.githubusercontent.com/file/file/master/magic/Magdir/coff https://opensource.apple.com/source/gdb/gdb-1708/src/include/coff/ (see *.h) |
| CDROM File Video Texture Image TIM/PXL/CLT (Sony) |
.TIM contains Pixel data, and (optional) CLUT data ;-all in one file .PXL contains Pixel data only ;\in two separate files .CLT contains CLUT data only (if any) ;/ |
000h 1 File ID (always 10h=TIM) 001h 1 Version (always 00h) 002h 2 Reserved (always 0000h) (or 1 or 2 for Compressed TIM, see below) 004h 4 Flags (bit0-2=Type; see below, bit3=HasCLUT, bit4-31=Reserved/zero) ... .. Data Section for CLUT (Palette), only exists if Flags.bit3=1, HasCLUT ... .. Data Section for Pixels (Bitmap/Texture) |
000h 4 Size of Data Section (Xsiz*2*Ysiz+0Ch) ;maybe rounded to 4-byte? 004h 4 Destination Coord (YyyyXxxxh) ;Xpos counted in halfwords 008h 4 Width+Height (YsizXsizh) ;Xsiz counted in halfwords 00Ch .. VRAM Data (to be DMAed to frame buffer) |
000h 1 File ID (always 11h=CLT) (although Sony's doc says 12h) 001h 1 Version (always 00h) 002h 2 Reserved (always 0000h) 004h 4 Flags (bit0-1=Type=2; bit2-31=Reserved/zero) ... .. Data Section for CLUT (Palette) |
000h 1 File ID (always 12h=PXL) (although Sony's doc says 11h) 001h 1 Version (always 00h) 002h 2 Reserved (always 0000h) 004h 4 Flags (bit0-?=Type; see below, bit?-31=Reserved/zero) ... .. Data Section for Pixels (Bitmap/Texture) |
_______________________________ Compressed TIM _______________________________ |
______________________________ Malformed Files _______________________________ |
Used by Legacy of Kain: Soul Reaver (eg. BIGFILE.DAT\folder04h\file13h) Used by Gex - Enter the Gecko (eg. BIGFILE.DAT\file0Fh\LZcompressed) |
10 00 00 00 02 00 00 00 04 00 08 00 00 02 00 00 00 02 00 02 ;<-- this 10 00 00 00 02 00 00 00 04 00 08 00 00 00 00 00 00 02 00 02 ;<-- or this |
[04h]=Type should indicated the color depth, but it's always 02h=16bpp. [08h]=Width*2*Height+0Ch should be 8000Ch, but malformed is 80004h. Total filesize should be 80014h, but Gecko files are often MUCH smaller. |
Used by Pong (MagDemo24: LES02020\*\*.TIM) Used by Alien Resurrection (MOVIE\LANGSEL.BIN, PACK.BIN\FEGRUK*.TIM) |
10 00 00 00 02 00 00 00 0E 00 08 00 C0 01 00 00 00 02 00 02 ;Pong *.TIM 10 00 00 00 02 00 00 00 0E 00 07 00 00 02 00 00 C0 01 00 02 ;Pong WORLD.TIM 10 00 00 00 02 00 00 00 0E 80 03 00 00 02 00 01 C0 01 00 01 ;Pong ZONE*.TIM 10 00 00 00 02 00 00 00 0E 00 02 00 00 00 00 01 00 01 00 01 ;Alien LANGSEL 10 00 00 00 02 00 00 00 0E 00 02 00 00 03 00 01 00 01 00 01 ;Alien FEGRUK* |
Bloody Roar 1 (CMN\INIT.DAT\000Eh) Bloody Roar 2 (CMN\SE00.DAT, CMD\SEL00.DAT\0030h and CMN\VS\VS.DAT\0000h) |
13 00 00 00 02 00 00 00 0C 20 00 00 00 00 F8 01 00 01 10 00 ;Bloody Roar 1 13 00 00 00 02 00 00 00 0C 20 00 00 00 00 00 00 00 01 10 00 ;Bloody Roar 2 |
Used by Secret of Mana, WM\WEFF\*.CLT |
| CDROM File Video Texture/Bitmap (Other) |
.BS used by several games (and also in most .STR videos) .GIF used by Lightspan Online Connection CD .JPG used by Lightspan Online Connection CD .GIF used by Keitai Henshuu (CompactNetFront browser) (I-Mode) .BMP with RLE4 used by Lightspan Online Connection CD (MONOFONT, PROPFONT) .BMP with RLE8+Delta also used by Online Connection CD (PROPFONT\ARIA6.BMP) .PCX with RLE used by Jampack Vol. 1 (MDK\CD.HED\*.pcx) |
.BMP .BMP used by Mat Hoffman's Pro BMX (MagDemo39: BMX\BMXCD.HED\*) .BMP used by Mat Hoffman's Pro BMX (MagDemo48: MHPB\BMXCD.HED\*) .BMP used by Thrasher: Skate and Destroy (MagDemo27: SKATE\ASSETS\*.ZAL) .BMP used by Dave Mirra Freestyle BMX (MagDemo36,46: BMX\ASSETS\*.ZAL) .VRM .IMG .TEX .TIM .RAW .256 .COL .4B .15B .R16 .TPG - raw VRAM data "SC" memory card icons |
000h 10h Name 1 ("FILENAME.BMP", zeropadded)
010h 10h Name 2 ("FILENAME.PSI", zeropadded)
020h 4 Bits per pixel (usually 4, 8, or 16)
024h 2 Bitmap VRAM Dest.X ?
026h 2 Bitmap VRAM Dest.Y ?
028h 2 Bitmap Width in pixels
02Ah 2 Bitmap Height in pixels
02Ch 2 Palette VRAM Dest.X ? ;\zero for 16bpp
02Eh 2 Palette VRAM Dest.Y ? ;/
030h 2 Bitmap Width in Halfwords (PixelWidth*bpp/16)
032h 2 Palette Size in Halfwords (0, 10h, 100h for 16bpp,4npp,8bpp)
034h 4 Maybe Bitmap present flag (always 1)
038h 4 Maybe Palette present flag (0=16bpp, 1=4bpp/8bpp)
03Ch .. Bitmap pixels
... .. Palette (if any, for 4bpp: 16x16bit, for 8bpp: 256x16bit)
|
000h 4 Total Filesize (Width*Height+20Ch) 004h 2 Bitmap Width 006h 2 Bitmap Height 008h 4 Unknown, always 1 (maybe 1=8bpp?) In .DAT files (512x192 or 256x64 pix), palette first: 00Ch 200h Palette data 20Ch .. Bitmap data In .PSX files (64x64 pix), bitmap first: 00Ch .. Bitmap data ... 200h Palette data |
Filename extension is ".DAT" Bitmap Width<>Height (non-square) [00Ch..20Bh] has AllMSBs>=80h, and SomeLSBs<80h |
000h 2 Width (W) ;\usually 320x240 (or 512x240 or 80x13) 002h 2 Height (H) ;/ 004h .. Bitmap 16bpp (W*H*2 bytes) |
000h 2 Width (W) (140h) 002h 2 Height (H) (F0h) 004h 4 Type (0=15bpp, 1=24bpp) 008h .. Bitmap 15bpp/24bpp (W*H*2 or W*H*3 bytes) ... 4 Checksum (all bytes above added together) |
000h 4 ID "RAWP" (this variant has BIG-ENDIAN width/height!) 004h 2 Width (usually 280h=640pix or 140h=320pix) (big-endian!!!) 006h 2 Height (usually 1E0h=480pix or F0h=240pix) (big-endian!!!) 008h .. Bitmap data, 16bpp (width*height*2 bytes) |
000h 2 VRAM.X (X) (0..3FFh) 002h 2 VRAM.Y (Y) (0..1FFh) 004h 2 Width in halfwords (W) (1..400h) 006h 2 Height (H) (1..200h) 008h .. Bitmap or Palette data (W*H*2 bytes) |
000h 2 Bitmap Width (min 2) 002h 2 Bitmap Height (min 1) 004h 2 Hotspot X (signed) 006h 2 Hotspot Y (signed) 008h 08h Zerofilled 010h 4 Bitmap Size (Width*Height*bpp/8, or less when compressed) 014h 2 Color Depth (1=8bpp, 2=16bpp) 016h 2 Compression Method (0=None, 1=LZ+RLE+DELTA, 2=LZSS.32, 3=LZSS.8) 018h .. Bitmap pixels |
0000h 200h Palette ;\upper half 0200h 1000h Bitmap (16x256x8bpp) ;/ 1200h 200h Palette ;\lower half 1400h 1000h Bitmap (16x256x8bpp) ;/ |
000h 2 Hotspot X (signed) (usually 0) 002h 2 Hotspot Y (signed) (usually 0) 004h 2 Width in bytes 006h 2 Height 008h .. Bitmap 8bpp (Width*Height bytes) |
000h 2 Width 002h 2 Height 004h 100h*3 Palette 24bit RGB888 304h .. Bitmap 8bpp (Width*Height bytes) .. (1700h) Unknown (only in SMLMAPS\*.BOB, not in GFX\*.BOB) |
000h 4 Format 1 (0=8bpp, 1=16bpp) 004h 4 Format 2 (1=8bpp, 2=16bpp) 008h 4 Width in pixels 00Ch 4 Height in pixels 010h .. Bitmap Data ... (300h) Palette 18bit RGB666 (R,G,B range 00h..3Fh) (only if format 8bpp) |
000h 4 Unknown (always 1) 004h 4 Unknown (always 8) 008h 4 Unknown (always 2) (maybe 2=16bpp?) 00Ch 4 Width in pixels (3Ah, 140h, or 280h) 010h 4 Height (3Ah, or F0h) 014h .. Bitmap 16bpp (Width*Height*2 bytes) |
000h 2 Number if Files (N) 002h 2 Number of VRAM.Slots (less or equal than Number of Files) 004h 4 ID "BLK0" 008h N*10h File List ... .. 1st File Bitmap ... .. 1st File Palette (20h/200h/0 bytes for 4bpp/8bpp/16bpp) ... .. 2nd File Bitmap ... .. 2nd File Palette (only if PaletteID=FileNo=1) ... .. 3rd File Bitmap ... .. 3rd File Palette (only if PaletteID=FileNo=2) ... .. etc. |
000h 2 VRAM.X in halfwords (0..1Fh, +bit15=Blank) ;\within current 002h 2 VRAM.Y (0..3Fh) ;/VRAM.Slot 004h 2 Width in pixels (max 80h/40h/20h for 4bpp/8bpp/16bpp) 006h 2 Height (max 40h) 008h 2 VRAM.Slot (0,1,2,3,...,NumSlots-1) 00Ah 2 Unknown (0,1,2,4 in *.vck, 4 in sect*.bin) 00Ch 2 Color Depth (0=4bpp, 1=8bpp, 2=16bpp) 00Eh 2 Palette ID (0..FileNo-1=Old, FileNo=New, FFFFh=None/16bpp) NumFiles-1, or ID of already used palette) |
Apocalypse (MagDemo16: APOC\CD.HED\*.RLE and *.BMR) Spider-Man 1 older version (MagDemo31: SPIDEY\CD.HED\*.RLE) Spider-Man 1 newer version (MagDemo40: SPIDEY\CD.HED\*.RLE and .BMR) Spider-Man 2 (MagDemo50: HARNESS\CD.HED\*.RLE) Tony Hawk's Pro Skater (MagDemo22: PROSKATE\CD.HED\*.BMR) |
33408h bytes --> 512x205pix, 16bpp (Apocalypse warning.rle) 3C008h bytes --> 512x240pix, 16bpp (most common) 96008h bytes --> 640x480pix, 16bpp (tony hawk's pro skater) |
000h 2 Unknown (FFA0h) (ID for files with valid headers?) 002h 2 Dest.Y (usually 0) (11h=(240-205)/2 in Apocalypse warning.rle) 004h 2 Width (usually 200h=512pix) 006h 2 Height (usually F0h=240pix) (CDh=205pix in Apocalypse warning.rle) 008h .. Bitmap data, 16bpp (width*height*2 bytes) |
000h .. Bitmap data, 16bpp (width*height*2 bytes) .. 8 Unused (garbage or extra pixels, not transferred to VRAM) |
150h bytes = 12x14x16bpp ;Potter/Chamber ;\ 25800h bytes = 320x240x16bpp ;Croc 1 (retail version) ; 34800h bytes = 448x240x16bpp ;Potter/Chamber ; 16bpp 38000h bytes = 448x256x16bpp ;Potter/Philosopher ; 3C000h bytes = 512x240x16bpp ;common ; 40000h bytes = 512x256x16bpp ;Potter/Philosopher ; 96000h bytes = 640x480x16bpp ;common ;/ |
600h bytes = 32x32x8bpp ;Potter/Philosopher ;\ 1A00h bytes = 96x64x8bpp ;Potter/Chamber ; 2600h bytes = 96x96x8bpp ;Potter/Chamber ; 8bpp, with 5200h bytes = 256x80x8bpp ;Potter/Philosopher ; leading 200h 6200h bytes = 128x192x8bpp ;Potter/Philosopher ; byte clut 7A00h bytes = 320x96x8bpp ;Potter/Chamber ; C200h bytes = 128x384x8bpp ;Potter/Philosopher ; A734h bytes = 218x194x8bpp ;Potter/Philosopher ; 11A00h bytes = 448x160x8bpp ;Potter/Philosopher ; 1E200h bytes = 513x240x8bpp ;Potter/Philosopher ; 20200h bytes = 512x256x8bpp ;Potter/Philosopher ; 20300h bytes = 513x256x8bpp ;Potter/Philosopher ;/ 120h bytes = 32x16x4bpp ;Potter/Chamber ;\4bpp, with 260h bytes = 48x24x4bpp ;Potter/Chamber ; leading 20h 340h bytes = 40x40x4bpp ;Potter/Chamber ; byte clut 820h bytes = 128x32x4bpp ;Potter/Chamber ;/ 1020h bytes = 128x64x4bpp ;Potter/Philosopher+Chamber |
000h 2 Bits per pixel (4 or 8) 002h 2 Bitmap Width in pixels 004h 2 Bitmap Height in pixels 006h 2 Zero 008h N*2 Palette (with N=(1 SHL bpp)) ... .. Bitmap (with Width*Height*bpp/8 bytes) ... (..) Zeropadding to 4-byte boundary (old version only) |
000h 2 Type (0=4bpp, 1=8bpp, 2=16bpp) 002h 2 Unknown (usually 0000h, or sometimes CCCCh) 004h 2 Bitmap Width in pixels 006h 2 Bitmap Height in pixels 008h 200h Palette (always 200h-byte, even for 4bpp or 16bpp) 208h .. Bitmap (Width*Height*bpp/8 bytes) |
000h 4 Offset to TIM (1Ch) (Hdr size) (1Ch) ;\ 004h 4 Offset to Footer (Hdr+TIM size)(123Ch,1A3Ch,1830h) ; 008h 2 Bitmap Width in pixels (40h or 60h or 30h) ; 00Ah 2 Bitmap Height in pixels (40h) ; 00Ch 4 Unknown, always 01h (01h) ; Header 010h 4 Unknown, always 23h (23h) ; 1Ch bytes 014h 2 Unknown, always 0101h (101h) ; 016h 1 Bitmap Width in pixels (40h or 60h or 30h) ; 017h 1 Bitmap Height in pixels (40h) ; 018h 4 Unknown, always 00h (0) ;/ 01Ch .. TIM (Texture, can be 4bpp, 8bpp, 16bpp) ;-TIM ... 4 Unknown, always C0000222h (C0000222h) ;\ ... 2 Unknown, always 0001h (0001h) ; ... 1 Bitmap Width in pixels (40h or 60h or 30h) ; Footer ... 1 Bitmap Height in pixels (40h) ; 12h bytes ... 4 Unknown, always 78000000h (78000000h) ; ... 6 Unknown (0,0,80h,0,0,0) ;/ |
Madden NFL '98 (MagDemo02: TIBURON\PORTRAIT.DAT) (48x64, 16bpp) Madden NFL 2000 (MagDemo27: MADN00\PORTRAIT.DAT) (96x64, 8bpp plus palette) Madden NFL 2001 (MagDemo39: MADN01\PORTRAIT.DAT) (64x64, 8bpp plus palette) |
000h 0Ch ID "TEX PSX ",01h,00h,00h,00h ;used in 989 Sports games 00Ch 4 Number of Textures 010h 4 Total Filesize 014h 4 Common Palette Size (0=200h, 1=None, 2=20h) 018h (..) Common Palette, if any (0,20h,200h bytes) ... .. Texture(s) Texture format: 000h 10h Filename (eg. "light1", max 16 chars, zeropadded if shorter) 010h 4 Width in pixels (eg. 40h) 014h 4 Height (eg. 20h or 40h) 018h 4 Unknown (always 0) 01Ch 4 Number of Colors (eg. 10h, 20h or 100h) 020h .. Bitmap (4bpp when NumColors<=10h, 8bpp when NumColors>10h) ... (..) Palette (NumColors*2 bytes, only present if Common Palette=None) |
000h 4 ID "SHPP"
004h 4 Total Filesize (or Filesize-0Ch, eg. FIFA'98 ZLEG*.PSH)
008h 4 Number of Textures (N)
00Ch 4 ID "GIMX"
010h N*8 File List
... .. Data (each File contains a Bitmap chunk, and Palette chunk, if any)
File List entries:
000h 4 Name (ascii) (Mipmaps use the same name for each mipmap level)
004h 4 Offset from begin of archive to first Chunk of file
Caution: Most PSH files do have the above offsets sorted in increasing order,
but some have UNSORTED offsets, eg. Sled Storm (MagDemo24: ART3\LOAD1.PSH),
so one cannot easily compute sizes as NextOffset-CurrOffset.
Note: Mipmap textures consist of two files with same name and different
resolution, eg. in Sled Storm (MagDemo24: ART\WORLD0x.PSH)
Bitmap Chunk:
000h 1 Chunk Type (40h=PSX/4bpp, 41h=PSX/8bpp, 42h=PSX/16bpp)
001h 3 Offset from current chunk to next chunk (000000h=None)
004h 2 Bitmap Width in pixels (can be odd, pad lines to 2-byte boundary)
006h 2 Bitmap Height
008h 2 Center X (whatever that is)
00Ah 2 Center Y (whatever that is)
00Ch 2 Position X (whatever that is, plus bit12-15=flags?)
00Eh 2 Position Y (whatever that is, plus bit12-15=flags?)
010h .. Bitmap data (each scanline is padded to 2-byte boundary)
... .. Padding to 8-byte boundary
Compressed Bitmap Chunk:
000h 1 Chunk Type (C0h=PSX/4bpp, C1h=PSX/8bpp, and probably C2h=PSX/16bpp)
001h 0Fh Same as in Chunk 40h/41h/42h (see there)
010h .. Compressed Bitmap data (usually/always with Method=10FBh)
... .. Padding to 8-byte boundary
Palette Chunk (if any) (only for 4bpp/8bpp bitmaps, not for 16bpp):
000h 1 Chunk Type (23h=PSX/Palette)
001h 3 Offset from current chunk to next chunk (000000h=None)
004h 2 Palette Width in halfwords (10h or 100h)
006h 2 Palette Height (1)
008h 2 Unknown (usually same as Width) (or 80D0h or 9240h)
00Ah 2 Unknown (usually 0000h) (or 0001h or 0002h)
00Ch 2 Unknown (usually 0000h)
00Eh 2 Unknown (usually 00F0h)
010h .. Palette data (16bit per color)
Note: The odd 80D0h,0001h values occur in Sled Storm ART\WORKD00.PSH\TBR1)
Unknown Chunk (eg. ReBoot (DATA\AREA15.PSH\sp*))
000h 1 Chunk Type (6Bh)
001h 3 Offset from current chunk to next chunk (000000h=None)
004h 8 Unknown (2C,00,00,3C,03,00,00,00)
00Ch - For whatever reason, there is no 8-byte padding here
Comment Chunk (eg. Sled Storm (MagDemo24: ART\WORLD0x.PSH))
000h 1 Chunk Type (6Fh=PSX/Comment)
001h 3 Offset from current chunk to next chunk (000000h=None)
004h .. Comment ("Saved in Photoshop Plugin made by PEE00751@...",00h)
... .. Zeropadding to 8-byte boundary
Unknown Chunk (eg. Sled Storm (MagDemo24: ART\WORLD09.PSH\ADAA))
000h 1 Chunk Type (7Ch)
001h 3 Offset from current chunk to next chunk (000000h=None)
004h 2Ch Unknown (reportedly Hot spot / Pix region, but differs on PSX?)
|
000h 2 ID "BC" ;\ 002h 1 Color Depth (1=4bpp, 2=8bpp, 4=16bpp) ; Header 003h 1 Type (40h=Bitmap, C0h=Font) ;/ ... (2) Palette Unknown (0 or 1) ;\only if Bitmap ... (2) Palette Unknown (1) ; 4bpp or 8bpp ... (..) Palette data (20h or 200h bytes for 4bpp/8bpp) ;/ ... 2 Bitmap Number of Bitmaps-1 (N-1) ;\ ... 2 Bitmap Width in pixels ; ... 2 Bitmap Height in pixels ; Bitmap(s) ... N*1 Bitmap Tilenumbers (eg. "ABCDEFG..." for Fonts); ... N*1 Bitmap Proportional Font widths? (0xh or FFh) ; ... N*BMP Bitmap(s) for all characters ;/ ... (20h) Palette Data (20h bytes for 4bpp) ;-only if Font/4bpp |
INGAME1\BOWL2.PTH\SPRITES.PTH\ST.SPR 30x10x4bpp: 15 --> 16 bytes/line INGAME1\BOWL2.PTH\SPRITES.PTH\STOPW.SPR 75x40x4bpp: 37.5 --> 38 bytes/line |
000h 2 ID ("FB") ;\File Header
002h 2 Always 1 (version? 4bpp? num entries?) ;/
004h 2 Palette VRAM Dest X (eg. 300h) ;\
006h 2 Palette VRAM Dest Y (eg. 1CCh,1EDh,1FFh) ; Palette Header
008h 2 Palette Width in halfwords (eg. 100h) ; (all zero when unused)
00Ah 2 Palette Height (eg. 1 or 0Dh) ;/
00Ch 2 Bitmap VRAM Dest X (eg. 140h or 200h) ;\
00Eh 2 Bitmap VRAM Dest Y (eg. 0 or 100h) ; Bitmap Header
010h 2 Bitmap Width in halfwords ;
012h 2 Bitmap Height ;/
... .. Palette Data (if any) ;-Palette Data
... .. Bitmap Data ;-Bitmap Data
|
000h 2 Always 302h 002h 2 Number of Texture Slices (N) 004h 4 Number of 1-byte Footer entries (F1) (0..6xxh) 008h 4 Total Size of Footer (F1+F2*10h+F3*4) 00Ch 2 Unknown (0 or 1) 00Eh 2 Number of 10h-byte Footer entries (F2) (0..7Eh) 010h 2 Number of 4-byte Footer entries (F3) (0..25h) 012h 2 Zero (or does below list already start here?) 014h N*8 Texture Slice Dest Coords (4x16bit: 0,X,Y,0)? ... .. Zeropadding to 800h-byte boundary 800h N*8000h Texture Slice Data (64x256 halfwords each) ... F1*1 Footer 1-byte entries (unknown content) ... F2*10h Footer 10h-byte entries (unknown content) ... F3*4 Footer 4-byte entries (unknown content) |
| CDROM File Video Texture/Bitmap (TGA) |
000h 1 Image ID Size (00h..FFh, usually 0=None) ;0 001h 1 Palette Present Flag (0=None, 1=Present) ;0 iv=1 002h 1 Data Type code (0,1,2,3,9,10,11,32,33) ;NEBULA=2 iv=1 003h 2 Palette First Color (usually 0) ;0 iv=0 005h 2 Palette Number of Colors (usually 100h) ;0 iv=100h 007h 1 Palette Bits per Color (16,24,32, usually 24) ;0 iv=18h 008h 2 Bitmap X origin (usually 0) ;0 00Ah 2 Bitmap Y origin (usually 0) ;0 00Ch 2 Bitmap Width ;NEBULA=20h LOGO=142h 00Eh 2 Bitmap Height ;NEBULA=20h 010h 1 Bitmap Bits per Pixel (8,16,24,32 exist?) ;NEBULA=18h iv=8 011h 1 Image Descriptor (usually 0) ;0 012h .. Image ID Data (if any, len=[00h], usually 0=None) ... .. Palette ... .. Bitmap ... 1Ah Footer (8x00h, "TRUEVISION-XFILE.", 00h) (not present in iview) |
00h = No image data included ;-Unknown purpose 01h = Color-mapped image ;\ 02h = RGB image ; Uncompressed 03h = Black and white image ;/ 09h = Color-mapped image ;\Runlength 0Ah = RGB image ;/ 0Bh = Black and white image ;-Unknown compression method 20h = Color-mapped image ;-Huffman+Delta+Runlength 21h = Color-mapped image ;-Huffman+Delta+Runlength+FourPassQuadTree |
Type 01h and 09h lack details on supported bits per pixel (8bpp with 100h
colors does exist; unknown if less (or more) than 8bpp are supported,
and if so, in which bit order.
Type 02h and 0Ah are more or less well documented.
Type 03h has unknown bit-order, also unknown if/how it differs from type
01h with 1bpp.
Type 0Bh, 20h, 21h lack any details on the compression method.
|
16bpp: Tomb Raider 2 (MagDemo01: TOMBRAID\*.RAW) 24bpp: Tomb Raider 2 (MagDemo05: TOMB2\*.TGA) 24bpp: Colony Wars Venegance (MagDemo14: CWV\GAME.RSC\NEBULA*.TGA, *SKY.TGA) 24bpp: Colony Wars Red Sun (MagDemo31: CWREDSUN\GAME.RSC\000A\*) 16bpp: Colony Wars Venegance (MagDemo14: CWV\GAME.RSC\LOGO.DAT) 16bpp: X-Men: Mutant Academy (MagDemo50: XMEN2\*) 16bpp: Disney's Tarzan (MagDemo42: TARZAN\*) 8bpp+Wrong8bitAttr: SnoCross Championship Racing (MagDemo37: SNOCROSS\*.TGA) 16bpp+WrongYflip: SnoCross Championship Racing (MagDemo37: SNOCROSS\*.TGA) |
32bpp: 3DS AR Games (RomFS:\i_ar\tex\hm*.lz77 |
| CDROM File Video Texture/Bitmap (PCX) |
000h 1 File ID (always 0Ah=PCX/ZSoft) 001h 1 Version (0,2,3,4,5) 002h 1 Compression (always 01h=RLE) (or inofficial: 00h=Uncompressed) 003h 1 Bits per Pixel (per Plane) (1, 2, 4, or 8) 004h 2 Window X1 ;\ 006h 2 Window Y1 ; Width = X2+1-X1 008h 2 Window X2 ; Height = Y2+1-Y1 00Ah 2 Window Y2 ;/ 00Ch 2 Horizontal Resolution in DPI ;\often square, but can be also zero, 00Eh 2 Vertical Resolution in DPI ;/or screen size, or other values 010h 30h EGA/VGA Palette (16 colors, 3-byte per color = R,G,B) (or garbage) 010h 1 CGA: Bit7-4=Background Color (supposedly IRGB1111 ?) 013h 1 CGA: Bit7:0=Color,1=Mono,Bit6:0=Yellow,1=White,Bit5:0=Dim,1=Bright 014h 1 Paintbrush IV: New CGA Color1 Green ;\weird new way to encode CGA 015h 1 Paintbrush IV: New CGA Color1 Red ;/palette in these two bytes 040h 1 Reserved (00h) (but is 96h in animals.pcx) 041h 1 Number of color planes (1=Palette, 3=RGB, or 4=RGBI) 042h 2 Bytes per Line (per plane) (must be N*2) (=(Width*Bits+15)/16*2) 044h 2 PaletteInfo? (0000h/xxxxh=Normal, 0001h=Color/BW, 0002h=Grayscale) 046h 2 Horizontal screen size in pixels ;\New fields, found only 048h 2 Vertical screen size in pixels ;/in Paintbrush IV/IV Plus 04Ah 36h Reserved (zerofilled) (or garbage in older files, custom in MGS) 080h .. Bitmap data (RLE compressed) ... 1 VGA Palette ID (0Ch=256 colors) ;\when 8bpp .. 300h VGA Palette (256 colors, 3-byte per color = R,G,B) ;/ |
00h = Version 2.5 whatever ancient stuff 02h = Version 2.8 with custom 16-color palette 03h = Version 2.8 without palette (uses fixed CGA/EGA palette) 04h = Version ?.? without palette (uses fixed CGA/EGA palette) 05h = Version 3.0 with custom 16-color or 256-color palette or truecolor |
planes=1, bits=1 P1 ;1bit, HGC 2 color (iview and paint shop pro 2) planes=1, bits=2 P2 ;2bit, CGA 4 color (with old/new palette info) planes=3, bits=1 RGB111 ;3bit, EGA 8 color (official samples) ;\version planes=4, bits=1 IRGB1111 ;4bit, EGA 16 color (paint shop pro 2) ;/03h..04h planes=1, bits=4 P4 ;4bit, BMP 16 color (iview) planes=1, bits=8 P8 ;8bit, VGA 256 color palette planes=1, bits=8 I8 ;8bit, VGA 256 level grayscale (gmarbles.pcx) planes=3, bits=8 BGR888 ;24bit, truecolor (this is official 24bit format) ;planes=1, bits=24 BGR888 ? ;24bit, reportedly exists? poor compression ;planes=4, bits=4 ABGR4444 ;16bit, wikipedia-myth? unlikely to exist ;planes=4, bits=8 ABGR8888 ;32bit, truecolor+alpha (used in abydos.dcx\*) |
Width = X2+1-X1 ;width for normal files Height = Y2+1-Y1 ;height for normal files |
Width = X2-X1 ;width for bugged files Height = Y2-Y1 ;height for bugged files |
(Width*Bits+15)/16*2) > BytesPerLine |
BeginOfLastScanline >= Filesize (or Filesize-301h for files with palette) |
plane0 = red ;\ plane1 = green ; this is WRONG, NONSENSE, does NOT exist plane2 = blue ; plane3 = intensity ;/ |
color0=black color1=white |
color0=[10h].bit7-4 ;(Color0 IRGB) ;CGA Port 3D9h.bit3-0 (usually 0=black)
bright=[13h].bit5 ;CGA Port 3D9h.bit4 ;\
palette=[13h].bit6 ;CGA Port 3D9h.bit5 ; old method
if [13h].bit7 then palette=2 ;CGA Port 3D8h.bit2 ;/
if [01h]=05h and [44h]=0001h then ;\new "smart"
if [14h]>200 or [15h]>200 then bright=1, else bright=0 ; method used in
if [14h]>[15h] then palette=0 else palette=1 :/Paintbrush IV
if palette=0 and bright=0 then color1..3=02h,04h,06h ;\green-red-yellow
if palette=0 and bright=1 then color1..3=0Ah,0Ch,0Eh ;/
if palette=1 and bright=0 then color1..3=03h,05h,07h ;\cyan-magenta-white
if palette=1 and bright=1 then color1..3=0Bh,0Dh,0Fh ;/
if palette=2 and bright=0 then color1..3=03h,04h,07h ;\cyan-red-white
if palette=2 and bright=1 then color1..3=0Bh,0Ch,0Fh ;/
|
[01h]=version=05h, and [44h]=0002h=grayscale |
Color Name IRGB1111 RGB222 RGB888 Windows 00h dark black 0000 000 000000 000000 01h dark blue 0001 002 0000AA 000080 02h dark green 0010 020 00AA00 008000 03h dark cyan 0011 022 00AAAA 008080 04h dark red 0100 200 AA0000 800000 05h dark magenta 0101 202 AA00AA 800080 06h dark yellow (brown) 0110 210!! AA5500!! 808000 07h dark white (light gray) 0111 222 AAAAAA C0C0C0!! 08h bright black (dark gray) 1000 111 555555 808080!! 09h bright blue 1001 113 5555FF 0000FF 0Ah bright green 1010 131 55FF55 00FF00 0Bh bright cyan 1011 133 55FFFF 00FFFF 0Ch bright red 1100 311 FF5555 FF0000 0Dh bright magenta 1101 313 FF55FF FF00FF 0Eh bright yellow 1110 331 FFFF55 FFFF00 0Fh bright white 1111 333 FFFFFF FFFFFF |
CGA supports 16 colors in text mode (but only max 4 colors in graphics mode). EGA supports the same 16 colors as CGA in both text and graphics mode. EGA-with-special-EGA-monitor supports 64 colors (but only max 16 at once). VGA supports much colors (but can mimmick CGA/EGA colors, or similar colors) |
.PCX with RLE used by Jampack Vol. 1 (MDK\CD.HED\*.pcx) .PCX with RLE used by Hot Wheels Extreme Racing (MagDemo52: US_01293\MISC\*) .PCX with RLE used by Metal Gear Solid (slightly corrupted PCX files) |
04Ah 2 Custom MGS ID (always 3039h) 04Ch 2 Display Mode? (08h/18h=4bit, 09h/19h=8bit) 04Eh 2 Bitmap X-coordinate in VRAM (reportedly "divided by 2" ???) 050h 2 Bitmap Y-coordinate in VRAM 052h 2 Palette X-coordinate in VRAM 054h 2 Palette Y-coordinate in VRAM 056h 2 Palette number of actually used colors (can be less than 16/256) 058h 28h Reserved (zerofilled) 080h .. Bitmap data (RLE compressed) ... 1 VGA Palette ID (0Ch=256 colors) ;\when 8bpp .. 300h VGA Palette (256 colors, 3-byte per color = R,G,B) ;/ .. .. Padding to 4-byte boundary, ie. palette isn't at filesize-301h !!! |
0000h 4 ID (3ADE68B1h) (987654321 decimal) 0004h 4000h File List (32bit offsets) (max 1023 files, plus 0=End of List) 1004h .. File Data area (PCX files) |
| CDROM File Video 2D Graphics CEL/BGD/TSQ/ANM/SDF (Sony) |
000h 1 File ID (22h) 001h 1 Version (3) 002h 2 Flag (bit15=WithAttr, bit14=AttrDataSize:0=8bit,1=16bit, bit13-0=0) 004h 2 Number of cell data items (in cell units) (N) 006h 1 Sprite Editor Display Window Width (in cell units) 007h 1 Sprite Editor Display Window Height (in cell units) 008h .. Cell Data[N] (64bit entries) ... .. Cell Attr[N] (0bit/8bit/16bit user data? depending on Flag) |
0-7 Tex Coord X (8bit) 8-15 Tex Coord Y (8bit) 16-21 Clut X (6bit) 22-30 Clut X (9bit) 31 Semi-transparency enable ;-only in Version>=3 32 Vertical Reversal (Y-Flip) ;\only in Version=0 and Version>=2 33 Horizontal Reversal (X-Flip) ;/ 34-47 Unused 48-52 Texture Page (5bit) 53-54 Semi Transparency (0=B/2+F/2, 1=B+F, 2=B-F, 3=B+F/4) 55-56 Texture page colors (0=4bit, 1=8bit, 2=15bit, 3=Reserved) 57-60 Sprite Editor Color Set Number ;\ 61 Unused ; only in Version>=3 62-63 Sprite Editor TIM Bank ;/ XXX else hardcoded? |
000h 1 File ID (22h) ;\same as in official CEL version 001h 1 Version (3) ;/ 002h 2 Flag (...unknown meaning in this case...?) ;<-- ? 004h 2 Number of cell data items (in cell units) (N) 006h 2 Sprite Editor Display Window Width (in cell units) ;<-- 16bit! 008h 2 Sprite Editor Display Window Height (in cell units) ;<-- 16bit! 00Ah .. Cell Data[N] (64bit entries) ... .. Cell Attr[N] (16bit/192bit user data, depending on Flag or so...?) |
000h 1 File ID (23h) 001h 1 Version (0) 002h 2 Flag (bit15=WithAttr, bit14=AttrDataSize:0=8bit,1=16bit, bit13-0=0) 004h 1 BG Map Width (in cell units) (W) 005h 1 BG Map Height (in cell units) (H) 006h 1 Cell Width (in pixels) 007h 1 Cell Height (in pixels) 008h .. BG Map Data[W*H] (16bit cell numbers) ... .. BG Map Attr[W*H] (0bit/8bit/16bit user data? depending on Flag) |
000h 1 File ID (23h) ;\same as in official BGD version 001h 1 Version (0) ;/ 002h 2 Flag (bit15=WithAttr, bit14=AttrDataSize:0=8bit,1=16bit, bit13-0=0) 004h 2 BG Map Width (in cell units) (W) ;<-- 16bit! 006h 2 BG Map Height (in cell units) (H) ;<-- 16bit! 008h 2 Cell Width (in pixels) ;<-- 16bit! 00Ah 2 Cell Height (in pixels) ;<-- 16bit! 00Ch .. BG Map Data[W*H] (16bit cell numbers) ... .. BG Map Attr[W*H] (0bit/8bit/16bit user data? depending on Flag) ... .. FFh-padding (in case being stored in R-Types' DOT1 archives) |
000h 1 File ID (24h) 001h 1 Version (1=normal) (but see below notes on older versions) 002h 2 Number of Sequence data entries (N) 004h N*8 Sequence Data (64bit per entry) |
000h 2 Sprite Group Number to be displayed 002h 1 Display Time (can be 0) 003h 1 Attribute/unused (bit0-3=Zero, bit4-7=User defined; version>=1 only) 004h 2 Hotspot X Coordinate (usually 0, or maybe can be +/-NNN ?) 006h 2 Hotspot Y Coordinate (usually 0, or maybe can be +/-NNN ?) |
000h 1 File ID (21h)
001h 1 Version (3=normal) (but see below notes on older versions)
002h 2 Flag (bit0-1=TPF, bit2-11=0, bit12-15=CLT)
0-1 TPF PixFmt (0=4bpp, 1=8bpp, 2/3=Reserved) ;version>=2 only
2-11 - Reserved (0)
12-15 CLT Number of CLUT Groups, for color animation
004h 2 Number of Sprites Groups
006h 2 Number of Sequences (N) (can be 0=None)
008h N*8 Sequence(s) (64bit per entry) ;Num=[004h]
... .. Sprite Group(s) ;Num=[006h]
... .. CLUT Group(s) ;Num=[002h].bit12-15
|
000h 2 Sprite Group Number to be displayed (range 0..AnimHdr[004h]-1) 002h 1 Display Time (can be 00h or 0Ah or whatever) 003h 1 Attribute/unused (bit0-3=Zero, bit4-7=User defined; version>=3 only) 004h 2 Hotspot X Coordinate (usually 0, or maybe can be +/-NNN ?) 006h 2 Hotspot Y Coordinate (usually 0, or maybe can be +/-NNN ?) |
000h 4 Number of Sprites in this Sprite Group ("sprites per metatile")
004h .. Sprite(s), 10h or 14h bytes each (see below)
Sprites:
000h 1 Tex Coord X (8bit)
001h 1 Tex Coord Y (8bit)
002h 1 Offset X from Hotspot within frame (maybe vertex x ?)
003h 1 Offset Y from Hotspot within frame (maybe vertex y ?)
004h 2 CBA Clut Base (bit0-5=ClutX, Bit6-14=ClutY, bit15=SemiTransp)
006h 2 FLAGs (bit0-4, bit5-6, bit7-8, bit9, bit10, bit11, bit12-15)
0-4 TPN Texture Page Number
5-6 ABR Semi-Transparency Rate
7-8 TPF Pixel depth (0=4bpp, 1=8bpp, 2=16bpp)
9 - Reserved
10 RSZ Scaling (0=No, 1=Scaled)
11 ROT Rotation (0=No, 1=Rotated)
12-15 THW Texture Width/Height div8 (or 0=Custom Width/Height)
008h (2) Custom Texture Width ;\only present if
... (2) Custom Texture Height ;/FLAGs.bit12-15=0=CustomSize
... 2 Angle of Rotation (in what units?)
... 2 Sprite Editor info (bit0-7=0..1?, bit8-13=ClutNo, bit14-15=TimBank)
... 2 Scaling X (for Vertex?) (as whatever fixed point number) (eg. 1000h)
... 2 Scaling Y (for Vertex?) (as whatever fixed point number) (eg. 1000h)
|
000h 4 CLUT size in bytes (Width*Height*2+0Ch) 004h 2 Clut X Coordinate 006h 2 Clut Y Coordinate 008h 2 Clut Width 00Ah 2 Clut Height 00Ch .. CLUT entries (16bit per entry, Width*Height*2 bytes) |
TIM0 file0.tim ;\ TIM1 file1.pxl file1.clt ; four TIM banks (with TIM or PXL/CLT files) TIM2 ; (or no filename for empty banks) TIM3 ;/ CEL0 file0.cel ;-one CEL (with CEL, or no filename if none) MAP0 file0.bgd ;\ MAP1 file1.bgd ; four BG MAP banks (with BGD filenames) MAP2 ; (or no filename for empty banks) MAP3 ;/ ANM0 file0.anm ;-one ANM (with ANM, or no filename if none) DISPLAY n ;0-3=256/320/512/640x240, 4-7=256/320/512/640x480 COLOR n ;0=4bpp, 1=8bpp ;docs are unclear, is it COLORn or COLOR n? ADDR0 texX texY clutX clutY numColorSets ;\ ADDR1 texX texY clutX clutY numColorSets ; four texture/palette offsets ADDR2 texX texY clutX clutY numColorSets ; for the corresponding TIM banks ADDR3 texX texY clutX clutY numColorSets ;/ (or whatever for empty banks?) |
| CDROM File Video 3D Graphics TMD/PMD/TOD/HMD/RSD (Sony) |
____________________________________ TMD _____________________________________ |
000h 4 ID (00000041h) 004h 4 Flags (bit0=FIXP, bit1-31=Reserved/zero) 008h 4 Number of Objects (N) ;"integral value" uh? 00Ch N*1Ch Object List (1Ch-byte per entry) ... .. Data (Vertices, Normals, Primitives) |
000h 4 Start address of a Vertex ;\Address values depend on the 004h 4 Number of Vertices ; file header's FIXP flag: 008h 4 Start address of a Normal ; FIXP=0 Addr from begin of Object 00Ch 4 Number of Normals ; FIXP=1 Addr from begin of TMD File 010h 4 Start address of a Primitive ; 014h 4 Number of Primitives ;/ 018h 4 Scale (signed shift value, Pos=SHL, Neg=SHR) (not used by LIBGS) |
000h 2 Vertex X (signed 16bit) 002h 2 Vertex Y (signed 16bit) 004h 2 Vertex Z (signed 16bit) 006h 2 Unused |
000h 2 Normal X (fixed point 1.3.12) 002h 2 Normal Y (fixed point 1.3.12) 004h 2 Normal Z (fixed point 1.3.12) 006h 2 Unused |
000h 1 Output Size/4 of the GPU command (after GTE conversion)
001h 1 Input Size/4 of the Packet Data in the TMD file
002h 1 Flag
0 Light source calculation (0=On, 1=Off)
1 Clip Back (0=Clip, 1=Don't clip) (for Polygons only)
2 Shading (0=Flat, 1=Gouraud)
(Valid only for the polygon not textured,
subjected to light source calculation)
3-7 Reserved (0)
003h 1 Mode (20h..7Fh) (same as GP0(20h..7Fh) command value in packet)
004h .. Packet Data
|
000h 4 GPU Command+Color for that packet (CcBbGgRrh), see GP0(20h..3Fh) ... (4) Texcoord1+Palette (ClutYyXxh) ;\ ... (4) Texcoord2+Texpage (PageYyXxh) ; only if Mode.bit2=1 ... (4) Texcoord3 (0000YyXxh) ; ... (4) Texcoord4 (0000YyXxh) ;-quad only ;/ ... (4) Color2 (00BbGgRrh) ;\ ... (4) Color3 (00BbGgRrh) ; only if Flag.bit2=1 ... (4) Color4 (00BbGgRrh) ;-quad only ;/ ... (2) Normal1 (index in Normal list?) ;always, unless Flag.bit0=1 ... 2 Vertex1 (index in Vertex list?) ... (2) Normal2 (index in Normal list?) ;-only if Mode.bit4=1 ... 2 Vertex2 (index in Vertex list?) ... (2) Normal3 (index in Normal list?) ;-only if Mode.bit4=1 ... 2 Vertex3 (index in Vertex list?) ... (2) Normal4 (index in Normal list?) ;\quad only ;-only if Mode.bit4=1 ... 2 Vertex4 (index in Vertex list?) ;/ ... (2) Unused zeropadding (to 4-byte boundary) |
000h 4 GPU Command+Color for that packet (CcBbGgRrh), see GP0(40h,50h) ... (4) Color2 (00BbGgRrh) ;-only if Mode.bit4=1 ... 2 Vertex1 (index in Vertex list?) ... 2 Vertex2 (index in Vertex list?) |
000h 4 GPU Command+Color for that packet (CcBbGgRrh), see GP0(60h..7Fh)
... .. Unknown, reportedy "with 3-D coordinates and the drawing
content is the same as a normal sprite."
|
____________________________________ PMD _____________________________________ |
000h 4 ID (00000042h) 004h 4 Offset to Primitives 008h 4 Offset to Shared Vertices (or 0=None) 00Ch 4 Number of Objects 010h .. Objects (4+N*4 bytes each, with offsets to Primitives) ... .. Primitives ... .. Shared Vertices (8-bytes each, if any) |
000h 2 Vertex X (signed 16bit) 002h 2 Vertex Y (signed 16bit) 004h 2 Vertex Z (signed 16bit) 006h 2 Unused |
000h 4 Number of Primitives 004h N*4 Offsets to Primitives ... maybe relative to hdr[004h] ? |
000h 2 Number of Packets
002h 2 Type flags
0 Polygon (0=Triangle, 1=Quadrilateral)
1 Shading (0=Flat, 1=Gouraud) ;uh, with ONE color?
2 Texture (0=Texture-On, 1=Texture-Off) ;uh, withoutTexCoord?
3 Shared (0=Independent vertex, 1=Shared vertex)
4 Light source calculation (0=Off, 1=On) ;uh, withoutNormal?
5 Clip (0=Back clip, 1=No back clip)
6-15 Reserved for system
004h ... Packet(s)
|
000h 4 GPU Command+Color for that packet (CcBbGgRrh), see GP0(20h..7Fh) 004h 8 Vertex1 (Xxxxh,Yyyyh,Zzzzh,0000h) 00Ch 8 Vertex2 (Xxxxh,Yyyyh,Zzzzh,0000h) 014h 8 Vertex3 (Xxxxh,Yyyyh,Zzzzh,0000h) 01Ch (8) Vertex4 (Xxxxh,Yyyyh,Zzzzh,0000h) ;<-- only when Type.bit0=1 (quad) |
000h 4 GPU Command+Color for that packet (CcBbGgRrh), see GP0(20h..7Fh) 004h 4 Offset to Shared Vertex1 ;offsets are 008h 4 Offset to Shared Vertex2 ;"from the start of a row" 00Ch 4 Offset to Shared Vertex3 ;aka from "Packet+04h" ? 010h (4) Offset to Shared Vertex4 ;<-- only when Type.bit0=1(quad) |
Cool Boarders 2 (MagDemo02: CB2\DATA3\*.PMD) Cardinal Syn (MagDemo03,09: SYN\*\*.WAD\*.PMD) (4-byte hdr plus PMD file) Sesame Streets Sports (MagDemo52: SSS\LV*\*MRG\*) (4-byte hdr plus PMD file) PSX-SDK: Programmer Tool CDROM (PSX\SAMPLE\GRAPHICS\PMD\*.PMD) |
____________________________________ TOD _____________________________________ |
000h 1 ID (50h) 001h 1 Version (0) 002h 2 Resolution (time per frame in 60Hz units, can be 0) (60Hz on PAL?) 004h 4 Number of Frames 008h .. Frame1 ... .. Frame2 ... .. Frame3 ... .. etc. |
000h 2 Frame Size in words (ie. size/4) 002h 2 Number of Packets (can be 0=None, ie. do nothing this frame) 004h 4 Frame Number (increasing 0,1,2,3,..) 008h ... Packet(s) |
000h 2 Object ID
002h 1 Type/Flag (bit0-3=Type, bit4-7=Flags)
003h 1 Packet Size ("in words (4 bytes)")
004h ... Packet Data
|
____________________________________ HMD _____________________________________ |
000h 4 ID (00000050h) ;same as in TOD, which CAN ALSO have MSBs=zero(!) 004h 4 MAP FLAG (0 or 1, set when mapped via GsMapUnit() function) 008h 4 Primitive Header Section pointer (whut?) 00Ch 4 Number of Blocks 010h 4*N Pointers to Blocks ... Primitive Header section (required) ... Coordinate section (optional) ... Primitive section (required) |
____________________________________ RSD _____________________________________ |
.RSD Main project file .PLY Polygon Vertices (Vertices, Normals, Polygons) .MAT Polygon Material (Color, Blending, Texture) .GRP Polygon Grouping .MSH Polygon Linking ;\ .PVT Pivot Rotation center offsets ; New Extended .COD Vertex Coordinate Attributes ; (since RSD version 3) .MOT Animation Information ;/ .OGP Vertex Object Grouping ;-Sub-extended |
RSD/GRP/MAT/PLY (and DXF=whatever?) used on Yaroze disc (DTL-S3035) |
| CDROM File Video STR Streaming and BS Picture Compression (Sony) |
v1/v2/v3/ea/iki --> first bit in bit15 of first halfword (good for psx) v0 --> first bit in bit7 of first byte (not so good for psx) (to use the same decoder for all version: swap each 2 bytes in v0) |
| CDROM File Video Streaming STR (Sony) |
000h 2 StStatus (0160h) (RV6Rh; R=Reserved=0, V=Version=1, 6=Fixed ID) 002h 2 StType (0000h..7FFFh=User Defined, 8000h..FFFFh=System; 8001h=MDEC) 004h 2 StSectorOffset (Sector number in the frame, 0=First) 006h 2 StSectorSize (Number of sectors in the frame) (eg. 4 or 5) 008h 4 StFrameNo (Frame number, 1=First) (except Viewpoint=0) 00Ch 4 StFrameSize (in bytes, in this frame, excluding headers/padding) When StType=0000h..7FFFh: 010h 10h StUser (user defined data) 020h 7E0h User data (more user defined data) When StType=8001h=MDEC (the only system defined type) (with StStatus=0160h): 010h 2 StMovieWidth (eg. 0140h) 012h 2 StMovieHeight (eg. 00F0h) 014h 4 StHeadM (reserved for system) (eg. 38000720h) ;\same as [020h-027h] 018h 4 StHeadV (reserved for system) (eg. 00020001h) ;/from 1st STR sector 01Ch 4 Unspecified (eg. 00000000h) (except Viewpoint<>0) 020h 7E0h Data (in BS format) (or padding, when image is smaller than frame) |
See "CDROM File Video BS Compression" chapters |
Height=260 (104h) in Star Wars Rebel Assault II, NTSC (S1\L01_PLAY.STR) Height=200 (0C8h) in Perfect Assassin (DATA.JFS\CDV\*.STR) Height=40 (028h) in Gran Turismo 1 (TITLE.DAT\*, MagDemo10 and MagDemo15) Width=232 (0E8h) in Gran Turismo 1 (TITLE.DAT\*, MagDemo10 only) |
| CDROM File Video Streaming STR Variants |
2-byte 0160h ;Standard STR header 1-byte 01h ;Ace Combat 3 Electrosphere 4-byte "SMJ",01h ;Final Fantasy 8, Video 4-byte "SMN",01h ;Final Fantasy 8, Audio/left 4-byte "SMR",01h ;Final Fantasy 8, Audio/righ 4-byte 0000000xh ;Judge Dredd 4-byte DDCCBBAAh ;Electronic Arts v2/v3 4-byte 08895574h ;Chunk header in 1st sector only, Best Sports (demo) 4-byte "Ad10" ;Chunk header in 1st sector only, Electronic Arts v1 4-byte "VLC0" ;Chunk header in 1st sector only, Electronic Arts v4 4-byte "VMNK" ;Chunk header in 1st sector only, Policenauts 4-byte 01h,"XSP" ;Sentient header in 1st sector only N-byre zero(es) ;Polygons? (in last 150Mbyte of PANEKIT.STR) |
0000h..7FFFh=User Defined 8000h..FFFFh=System (with 8001h=MDEC being the only officially defined type) |
0000h=Polygon Video, Wacwac as Polygon Stream 0000h=Polygon Video?, Army Men Air Attack 2 (MagDemo40: AMAA2\*.PMB) 0000h=MDEC Video, Alice in Cyberland 0001h=MDEC Video, Ridge Racer Type 4 (PAL version, 320x176 pix) 0001h=Whatever extra data for XA-ADPCM streams (Bits Laboratory games) 0001h=Whatever non-audio waverform? (3D Baseball) 0001h=Subtitles, Metal Gear Solid MGS\ZMOVIE.STR 0002h=Software-rendered video (without using MDEC/GTE) (Cyberia) 0002h=MDEC Video, Wacwac with IntroTableSet 0003h=MDEC Video, Wacwac with EndingTableSet 0004h=MDEC Video, Final Fantasy 9 (MODE2/FORM2) 0008h=SPU-ADPCM, AKAO audio (Final Fantasy 9) 0000h=SPU-ADPCM, AKAO audio (Chrono Cross Disc 1, Legend of Mana) 0001h=SPU-ADPCM, AKAO audio (Chrono Cross Disc 1, Legend of Mana) 0100h=SPU-ADPCM, AKAO audio (Chrono Cross Disc 2) 0101h=SPU-ADPCM, AKAO audio (Chrono Cross Disc 2) 0000h=Whatever special, channel 0 header (Nightmare Project: Yakata) 0400h=Whatever special, channel 1 header (Nightmare Project: Yakata) 0001h=Whatever special, channel 0 data (Nightmare Project: Yakata) 0401h=Whatever special, channel 1 data (Nightmare Project: Yakata) 5349h=MDEC Video, Gran Turismo 1 and 2 (with BS iki) 0078h=MDEC Ending Dummy (Mat Hoffman's Pro BMX (MagDemo48: MHPB\SHORT.STR) 5673h=MDEC Leading Dummy (Mat Hoffman's Pro BMX (MagDemo48: MHPB\SHORT.STR) 8001h=MDEC Video, Standard MDEC (most common type value) 8001h=Polygon Video (Ape Escape) (same ID as standard MDEC) 8001h=Eagle One: Harrier Attack various types (MDEC and other data) 8001h=Dance series SPU-ADPCM streaming (with STR[1Ch]=DDCCBBAAh) 8101h=MDEC Video, Standard MDEC plus bit8=FlagDisc2 (Chrono Cross Disc 2) 8x01h=Whatever ;\i-mode mo Issho - Doko Demo Issho Tsuika Disc (*.STR) 9x01h=Whatever ;/contains XA-ADPCM, and odd STR headers, with x=0h,4h,8h,Ch |
______________________________________________________________________________ |
Ace Combat 3 Electrosphere (*.SPB) Alice in Cyber Land (*.STR) Judge Dredd (*.IXA) ;and very small 4-byte STR header ReBoot (MOVIES\*.WXA) |
EA videos ;\ Crusader ; chunks Policenauts ;/ AKAO videos |
000h 4 Number of entries (4) 004h N*8 File List ... .. Zerofilled |
000h 2 Unknown... decreasing values? 002h 2 Number of Frames (same as last frame number in STR header) 004h 4 Offset/800h (to begin of STR movie, with subtiltes in 1st sector) |
04 00 00 00 ED 97 9E 01 01 00 00 00 ;num sectors=1439h ;div19Eh=C.81h ;97EDh-6137h=36B6h 37 61 86 01 3A 14 00 00 ;num sectors=0F41h ;div186h=A.03h ;6137h-38D0h=2867h D0 38 10 03 7B 23 00 00 ;num sectors=1EA1h ;div310h=A.00h ;38D0h-2302h=15CEh 02 23 73 02 1C 42 00 00 ;num sectors=1881h ;div273h=A.01h ;2302h-0000h=2302h |
000h 2 STR ID (0160h) ;\ 002h 2 STR Type (0001h=Subtitles) ; 004h 2 Sector number within Subtitles (0) ; STR 006h 2 Number of Sectors with Subtitles (1) ; header 008h 4 Frame number (1) ; 00Ch 4 Data size counted in 4-byte units (same as [02Ch]/4) ; 010h 10h Zerofilled ;/ 020h 4 Unknown (2) ;\ 024h 4 Unknown (1AAh, 141h, or 204h) ; Data 028h 4 Unknown (00100000h) ; part 02Ch 4 Size of all Subtitle entries in bytes plus 10h ; 030h .. Subtitle entries ;/ ... .. Zeropadding to 800h-byte boundary ;-padding |
000h 4 Offset from current subtitle to next subtitle (or 0=Last subtitle) 004h 4 First Frame number when to display the subtitle? 008h 4 Number of frames when to display the subtitle? 00Ch 4 Zero 010h .. Text string, terminated by 00h ... .. Zeropadding to 4-byte boundary |
________________________ STR with extra Header/Footer ________________________ |
0000h 1 sector DPS Header ;\header
0800h 4 sectors Zerofilled ;/
2800h many sectors STR video (interleaved with XA-ADPCM audio) ;\video
... some sectors Zerofilled (interleaved with XA-ADPCM audio) ;/
... 10 sectors END markers ;-footer
DPS Header (in first sector):
000h 4 File ID ("DPS",00h)
004h 0Ch Zerofilled
010h 2 Width (140h) ;\same as in
012h 2 Height (0A0h or 0D0h) (and maybe other for NTSC?) ;/STR headers
014h 08h Zerofilled
01Ch 4 Number of video frames
020h 7E0h Zerofilled
End Marker (repeated in last 10 sectors):
000h 2 STR ID (0160h)
002h 2 STR Type (8001h, same as MDEC)
004h 0Ch Zerofilled
010h 4 End ID ("END",00h)
014h 7ECh Zerofilled
|
________________________ Customized STR Video Headers ________________________ |
008h 4 Frame number (0=First) ;<-- instead of 1=First 01Ch 2 Unknown (always D351h) ;<-- instead of zero 01Eh 2 Number of Frames in this STR file ;<-- instead of zero |
01Ch 4 Sector number of 1st sector of current frame ;<-- instead of zero |
002h 2 STR Type (8101h=Disc 2) ;<-- instead of 8001h |
014h 4 Number of Frames (..excluding last some frames?) ;-instead BS[0..3] 018h 4 Unlike the above modified entry, this is normal ;-copy of BS[4..7] |
014h 2 Type (0000h=Normal, 01FFh=Empty frames at end of video) 016h 2 Number of Frames (excluding empty ones at end of video) 018h 8 Zerofilled |
002h 2 STR Type (5349h) ("IS") ;-special (instead 8001h)
010h 2 Total number of frames in video ;-special (instead width)
012h 2 Flags (bit15=1st, bit14=last) ;-special (instead height)
014h 8 Zero ;-special (instead BS header copy)
020h 7E0h Data (in BS iki format) ;-BS iki header (with width/height)
|
Namely, flags in [012h] are toggled on first/last sector of each frame, and of course [04h] does also increase per sector. |
00Ch 4 Frame Size-8 (ie. excluding 8-byte BS header) ;instead of Size-0 |
ZZBUFFER\SPY256.STR [14h..1Fh]=normal copy of 8-byte BS v2 header and zero ZZBUFFER\SPYGLASS.STR [14h..1Fh]=zerofilled ;\BS v1 ZZBUFFER\SPYTEST.STR [14h..1Fh]=00 00 10 00 00 00 00 09 00 00 07 EE ;/ ZZBUFFER\BIGSPY.STR Used in PGA Tour 98 (instead of above three files) |
STR Sector Header: 002h 2 STR Type (0000h=Alice in Cyber Land video) ;-special 008h 4 Frame number (1=First) (bit15 set in last frame, or FFFFh) 010h 10h Zerofilled (instead width/height and BS header copy) ;-special 020h 7E0h Data (in BS v2 format) |
014h 8 Copy of decrypted BS header (instead of encrypted BS header) |
016h 2 Copy of BS ID, 3000h in most frames (instead of 3800h) 020h 7E0h Data (in BS format, also with BS ID 3000h, instead of 3800h) |
00Ch 4 Frame Size in bytes (=size of ExtraHeader + BsData + ExtraData) 014h 4 Copy of Extra Header ;instead of BS[0..3] 018h 4 Copy of BS[0..3] ;instead of BS[4..7] 020h 7E0h Data (ExtraHeader + BsData + ExtraData) |
000h 2 Size of BS Data area (S1) ;\Extra Header 002h 2 Size of Extra Data area (S2) ;/ 004h S1 BS Data (in BS v3 format) ;-BS Data .. S2 Extra Data (unknown purpose) ;-Extra Data |
000h Nx20h STR Headers ;size = filesize/800h*20h ... Nx7E0h Data ;size = filesize/800h*7E0h |
006h 2 Number of Sectors in this Frame-1 (8..9 = 9..10 sectors) 00Ch 4 Frame Size in bytes (8..9*7E0h = 3F00h or 46E0h) 010h 2 Bitmap Width (always F0h) 012h 2 Bitmap Width (always 50h) 014h 0Ch Zerofilled (instead copy of BS header or copy of Extra header) 020h 7E0h Data (Extra Stuff, BS v2 data, plus Unused stuff) |
0000h Extra Stuff (7E0h bytes, whatever, often starts with 00,FF,00,FF,..) 07E0h BS v2 data (3720h or 3F00h bytes, including FFh-padding) ... Unused Sector (7E0h bytes, same as in previous frame or zerofilled) |
For 9 sectors: Only 1..7 are used, sector 8 is same as in previous frame For 10 sectors: Only 1..8 are used, sector 9 is zerofilled |
Filesize = 800h*((NumberOfFrames*5)) ;5 sectors, no xa-adpcm Filesize = 800h*((NumberOfFrames*5+7) AND not 7) ;4-5 sectors, plus xa-adpcm |
Sector 0: [10h] = Number of Frames, [12h]=Junk Sector 1: [10h] = Junk, [12h]=0 Sector 2: [10h] = Junk, [12h]=Junk Sector 3: [10h] = Junk, [12h]=Same as below (Bitmap Height) Below ONLY when having 5 sectors per frame: Sector 4: [10h] = Bitmap Width (140h) [12h]=Bitmap Height (D0h) That is, frames with 4 sectors do NOT have any Bitmap Width entry (the duplicated Height entry in sector 3 exists, so one could compute Width=NumMacroBlocks*100h/Height, or assume fixed Width=320, Height=208). |
Each movie file is followed by dummy padding file. For example, in Bugriders: MOVIE\*XA.STR Movie clip (with correct size, 320x192) MOVIE\*XB.STR Black Silence padding (wrong size 640x192, should be 320x192) |
00Ch 4 Frame Size (087Ch) 010h 2 Bitmap Width (wrongly set to 640, should be 320) 012h 2 Bitmap Height (192) 014h 2 MDEC Size (05A0h) 016h 2 BS ID (3800h) 018h 2 BS Quant (0001h) 01Ah 2 BS Version (0002h) Filesize is always 44Fh sectors (about 2.2Mbyte per *XB.STR file) |
1st NTSC/US movie: 320x160 pix, 0F61h frames, 4-5 sectors/frame, normal STR 1st PAL/EUR movie: 320x176 pix, 0CD0h frames, 5-6 sectors/frame, special STR 2nd NTSC/US movie: 320x160 pix, 1D6Ah frames, 4-5 sectors/frame, normal STR 2nd PAL/EUR movie: 320x160 pix, 18B5h frames, 5-6 sectors/frame, normal STR |
002h 2 STR Type (0001h=Custom, 176pix PAL video) ;instead of 8001h 006h 2 Number of Sectors in this Frame (always 5..6) 00Ch 4 Frame Size (always 2760h or 2F40h, aka 7E0h*5..6) 012h 2 Bitmap Height (00B0h, aka 176 pixels) ;instead of 00A0h 014h 8 Zerofilled ;instead BS[0..7] 020h 7E0h Data (in BS v3 format, plus FFh-padding) |
1st sector STR Type 5673h (Leading Dummy) ;\ 2nd sector STR Type 8001h (distorted/empty MDEC) ; junk 3rd..6th sector STR Type 8001h (distorted/garbage MDEC) ;/ 7th sector and up STR Type 8001h (normal MDEC, with odd [01Ch]) ;-movie Last 96h sectors STR Type 0078h (Ending Dummy) ;-junk |
002h 2 STR Type (5673h=Leading Dummy) 004h 4 Whatever (0004000Ch) 008h 4 Whatever (0098967Fh) 00Ch 4 Frame Size (always 100h) 010h 7F0h EAh-filled |
002h 2 STR Type (8001h=Normal MDEC ID, but content is empty) 004h 4 Whatever (0004000Ch) ;\ 008h 4 Whatever (0098967Fh) ; same as in 1st sector 00Ch 4 Frame Size (always 100h) ; (but ID at [002h] differes) 010h 7F0h EAh-filled ;/ |
002h 2 STR Type (8001h=Normal MDEC ID, but content is distorted) 004h 2 Sector number within current Frame (always 0) 006h 2 Number of Sectors in this Frame (always 1) 008h 4 Frame number (increasing, 1..4 for 3rd..6th sector) 00Ch 4 Frame Size (always 7D0h) 010h 10h EAh-filled 020h 7D0h Unknown (random/garbage?) 7F0h 10h EAh-filled |
Caution: The STR header values aren't constant throughout the frame: Entry entry [01Ch] is incremented per sector (or wraps to 0 in new section). 01Ch 4 Increasing sector number (within current movie section or so) |
002h 2 STR Type (0078h=Ending Dummy) 004h 2 Sector number within current Frame (always 0) 006h 2 Number of Sectors in this Frame (always 1) 008h 4 Frame number (increasing, in last 96h sectors) 00Ch 4 Frame Size (always 20h) 010h 2 Bitmap Width (always 40h) 012h 2 Bitmap Height (always 40h) 014h 7ECh Zerofilled |
00Ch 4 Frame Size in bytes (including 28h-byte extra stuff) 014h 8 Copy of Extra data [0..7] :-instead of BS header[0..7] 020h 7E0h Data (ExtraData + BsData) |
000h 28h Extra data (unknown purpose, reportedly "Camera data" ... whut?) 028h .. BS Data (in BS v1 format) |
002h 2 STR Type (0004h=FF9/Video) ;instead of 8001h 004h 2 Sector number within current Frame (02h..num-1) (2..9 for video) 006h 2 Total number of Audio+Video sectors in this frame (always 0Ah) 00Ch 4 Frame Size/4 (of BS data, excluding MBG extra) ;instead of Size/1 014h 8 Copy of BS[0..7] from 8th video sector ;instead 1st sector 01Ch 2 Usually 0000h (or 0004h in some MBG sectors) ;inszead of 0000h 01Eh 2 Usually 0000h (or 3xxxh in some MBG sectors) ;inszead of 0000h 020h 8F4h Data (in BS v2 format, plus MBG extra data, if any) |
Namely, entry [1Ch..1Fh]=nonzero occurs only on the sector that does contain the end of BS data (=and begin of MBG extra data), and of course [04h] does also increase per sector. |
[04h]=00h-01h 1st-2nd audio sector, SPU-ADPCM (see Audio streaming chapter) [04h]=02h-06h 1st-5th video sector, unused, [020h..913h] is FFh-filled [04h]=07h 6th video sector, contains end of BS data and MBG extra, if any [04h]=08h 7th video sector, contains middle of BS data [04h]=09h 8th video sector, contains begin of BS data |
Audio sectors are MODE2/FORM1 (800h bytes, with error correction) Video sectors are MODE2/FORM2 (914h bytes, without error correction) |
000000000100010 MDEC=001Eh (run=0, level=+1Eh) ;-normal (used) 000000000100011 MDEC=03E1h (run=0, level=-1Eh) ;-normal (not used) 0000010000001111100001 MDEC=03E1h (run=0, level=-1Eh) ;-escape (used) |
FF FF FF FF FE FF FE 41 AD AD AD AD AD AD AD AD AD AD AD AD AD AD AD AD AD AD AD AD AD AD AD AD AD AD AD AD AD AD AD AD (followed by FF's, which might be padding, or part of the extra data) |
_______________________ Non-standard STR Video Headers _______________________ |
000h 4 ID "SMJ",01h=Video 004h 1 Sector number within current Frame (02h..num-1) (2..9 for video) 005h 1 Total number of Audio+Video sectors in this frame, minus 1 (9) 006h 2 Frame number (0=First) 008h 7F8h Data (in BS v2 format) |
STR Sector Header: 000h 1 Always 01h 001h 1 Sector number within current Frame (00h..num-1) (8bit) 002h 2 Number of Sectors in this Frame 004h 2 Unknown (1 or 3) 006h 2 Frame number (decreasing, 0=Last) 008h 2 Bitmap Width in pixels ;\130hxE0h or 140hxB0h or 80hx60h 00Ah 2 Bitmap Height in pixels ;/ 00Ch 4 Zero 010h 2 Zero, or decreasing timer (decreases approx every 2 sectors) 012h 2 Zero, or decreasing timer (decreases approx every 1 sector) 014h 3 Zero 017h 1 Zero, or increases with step 2 every some hundred sectors 018h 2 Zero, or Timer (increments when [1Ah] wraps from 04h to 01h) 01Ah 1 Zero, or Timer (increments when [1Bh] wraps from 5Fh to 00h] 01Bh 1 Zero, or Timer (increments approx every 1 sector) 01Ch 2 Zero, or Whatever (changes to whatever every many hundred sectors) 01Eh 2 Zero, or 0204h 020h 7E0h Data (in BS v3 format) |
Namely, entry [10h..1Fh] can change within the frame (happens in japanese version), and of course [01h] does also increase per sector. |
LEVELS\*\*.IXA - Interactive gameplay movies CUTS\*.IXA - Non-interactive cut-scene movies |
000h 4 Sector number within current Frame (LEVELS=0..8, or CUTS=0..9) 004h 7FCh Data (see below) |
Note: CUTS videos have 2 leading XA-ADPCM sectors 000h .. BS Data (in BS v2/v3 format) ;-BS picture |
Note: LEVELS videos have 1 leading XA-ADPCM sector 000h 4 Offset to BS Data (always 28h) ;\ 004h 4*6 Offsets to Extra Stuff 1..6 ; extra header 01Ch 0Ch Zerofilled ;/ 028h .. BS Data (in BS v2/v3 format) ;-BS picture ... .. Extra Stuff 1..6 ;-extra data |
* There are only as many iki video sectors as needed to hold all the
frame's data. Remaining sectors are null.
* The first sector's Submode.Channel starts at zero, then increments for
each sector after that, and resets to zero after an audio sector.
* IK2 videos can also have variable frame rates that are very inconsistent.
|
| CDROM File Video Streaming Framerate |
007 - The World Is Not Enough 1Xtreme Arcade Party Pak Atari Anniversary Edition Redux Blast Radius Blue's Clues - Blue's Big Musical Chessmaster II Chronicles of the Sword Civilization II Colin McRae Rally Creatures - Raised in Space Cyberia Demolition Racer Dune 2000 ESPN Extreme Games FIFA Soccer 97 Fade to Black Family Connection - A Guide to Lightspan Fear Effect Fox Hunt Interactive CD Sampler Volume 1 Jade Cocoon - Story of the Tamamayu Jeopardy! 2nd Edition Juggernaut Krazy Ivan MTV Sports - Skateboarding featuring Andy Macdonald MTV Sports - T.J. Lavin's Ultimate BMX Medal of Honor Medal of Honor - Underground Official U.S. PlayStation Magazine Demo Disc 23 Planet of the Apes PlayStation Underground Number 2 Shockwave Assault Starblade Alpha Starwinder - The Ultimate Space Race Str.at.e.s. 1 - Match-A-Batch Str.at.e.s. 5 - Parallel Lives! Str.at.e.s. 7 - Riddle Roundup! The X-Files Top Gun - Fire at Will! Um Jammer Lammy Uprising X Wheel of Fortune - 2nd Edition Williams Arcade's Greatest Hits |
| CDROM File Video Streaming Audio |
000h 2 STR ID (0160h)
002h 2 STR Type (0000h, 0001h, 0100h, or 0101h)
0000h=Legend of Mana, Audio normal sectors
0001h=Legend of Mana, Audio sectors near end of movie
0000h=Chrono Cross Disc 1, Audio.left?
0001h=Chrono Cross Disc 1, Audio.right?
0100h=Chrono Cross Disc 2, Audio.left?
0101h=Chrono Cross Disc 2, Audio.right?
004h 2 Sector number in Frame (0=Audio.left?, 1=Audio.right?)
006h 2 Number of Audio sectors in this frame (always 2)
008h 4 Frame number (1=First)
00Ch 4 Unused (Chrono: FFh-filled or Mana: 00000FC0h=2x7E0h=Framesize?)
010h 10h Unused (Chrono: FFh-filled or Mana: 00h-filled)
020h 60h Unused (FFh-filled)
080h 4 ID "AKAO"
084h 4 Frame number (0=First)
088h 8 Unused (zerofilled)
090h 4 Remaining Time (step 690h) (can get stuck at 0340h or 0B20h at end)
094h 4 Zero
098h 4 Unknown (11h)
09Ch 4 Pitch (1000h=44100Hz)
0A0h 4 Number of bytes of audio data (always 690h)
0A4h 2Ch Unused (zerofilled)
0D0h 690h Audio (10h-byte SPU-ADPCM blocks) (1680 bytes)
760h A0h Unused (10h-byte SPU-ADPCM blocks with flag=03h and other bytes=0)
|
000h 4 ID "SMN",01h=Audio/left, "SMR",01h=Audio/right 004h 1 Sector number in Frame (0=Audio.left, 1=Audio.right) 005h 1 Total number of Audio+Video sectors in this frame, minus 1 (1 or 9) 006h 2 Frame number (0=First) 008h E8h Unknown (camera data?) (232 bytes) 0F0h 6 Audio ID (usually "MORIYA", sometimes "SHUN.M") 0F6h 0Ah Unknown (10 bytes) (reportedly 10 bytes at offset 250 = FAh ?????) 100h 4 ID "AKAO" 104h 4 Frame number (0=First) 108h 14h Unknown (20 bytes) 11Ch 4 Pitch (1000h=44100Hz) 120h 4 Number of bytes of audio data (always 690h) 124h 2Ch Unknown (44 bytes) 150h 20h Unknown (32 bytes) 170h 690h SPU-ADPCM Audio data (690h bytes) |
000h 2 STR ID (0160h) 002h 2 STR Type (0008h=FF9/Audio) 004h 2 Sector number in Frame (0=Audio.left, 1=Audio.right) 006h 2 Total number of Audio+Video sectors in this frame (always 0Ah) 008h 4 Frame number (1=First) 00Ch 4 Zero 010h 1 Audio flag? (00h=No Audio, 01h=Audio) 011h 4Fh Zerofilled --- XXX or whatever (when above is 00h) 060h 4 Number of Frames in this STR file 064h 1Ch EEh-filled Below 780h bytes are all zerofilled when [10h]=00h (no audio) Below 780h bytes are reportedly all ABh-filled "in the last frame of a movie on Disc 4" (unknown which movie, and if that occurs in other movies, too) 080h 4 ID "AKAO" 084h 4 Frame number (0=First) 088h 14h Unknown (20 bytes) 09Ch 4 Pitch (116Ah=48000Hz) (or 1000h=44100Hz in final movie) 0A0h 4 Number of bytes of audio data (0, 720h, 730h, or 690h=final movie) 0A4h 2Ch Unknown (44 bytes) 0D0h 730h SPU-ADPCM audio (plus leftover/padding when less than 730h bytes) |
000h 2 STR ID (0160h) 002h 2 STR Type (8001h, same as MDEC) 004h 2 Sector number within current Frame (0000h..num-1) 006h 2 Number of Sectors in this Frame (always 9) 008h 4 Frame number (0=First) 00Ch 4 Frame Size in bytes (always 4000h) 010h 4 Whatever (always 00A000A0h, would be width/height if it were video) 014h 8 Zerofilled 01Ch 4 Special ID (always DDCCBBAAh for Dance audio) 020h 7E0h Data (in SPU-ADPCM format, mono, 22200Hz aka Pitch=07F5h) |
Disney's The Emperor's New Groove (MagDemo39: ENG\STREAM\*.CVS) Disney's Aladdin in Nasira's Revenge (MagDemo46: ALADDIN\STREAM\*.CVS) |
| CDROM File Video Streaming Chunk-based formats |
STR Sector Header:
No STR Sector header (first sector starts directly with "Ad10" chunk)
Video Chunks (MDEC):
000h 4 Chunk ID "MDEC" ;\
004h 4 Chunk Size (2xx0h) (big-endian) ;
008h 2 Bitmap Width in pixels (big-endian) ; custom chunk header
00Ah 2 Bitmap Height in pixels (big-endian) ;
00Ch 2 Unknown (7FFFh) (big-endian) ;
00Eh 2 Unknown (AD14h or AD24h) (big-endian) ;/
010h .. Data (in BS v2 format) ;-standard BS v2 data
... .. FFh-Padding (to make Chunk Size a multiple of 10h-byte)
... 10h FFh-Padding (extra padding, INCLUDED in Chunk Size)
Audio Chunks (Ad10/Ad11) (22050Hz mono, or 22050Hz stereo):
000h 4 Chunk ID ("Ad10"=normal, "Ad11"=last audio chunk)
004h 4 Chunk Size (D38h or D28h) (or less in last chunk) (big-endian)
008h .. SPU-ADPCM audio data, mono or stereo (10h bytes per sample block)
Last STR Sector:
Last STR sector contains ending MDEC bytes, but can be smaller than 800h.
|
Unknown how the stereo data is arranged (chunks with D38h bytes can't be evenly divided into two halves with D30h/2 bytes each). -- TODO: Debug SPU DMA length to see what data amount(s) are transferred |
STR Sector Header:
000h 4 ID (DDCCBBAAh) (aka AABBCCDDh big-endian)
004h 4 Sector number within STR file (0=First, up to Filesize/800h-1)
008h 7F8h Data (video and audio chunks, see below) (first chunk is "Ad10")
Video Chunks (MDEC):
000h 4 Chunk ID "MDEC" ;\
004h 4 Chunk Size (1xx0h) (big-endian) ;
008h 2 Bitmap Width in pixels (big-endian) ; custom chunk header
00Ah 2 Bitmap Height in pixels (big-endian) ;
00Ch 4 Frame Number (starting at 0) (big-endian) ;/
010h .. Data (in BS v2 format) ;-standard BS v2 data
... .. FFh-Padding (to make Chunk Size a multiple of 10h-byte)
... 10h FFh-Padding (extra padding, NOT included in Chunk Size)
Audio Chunks (Ad10/Ad11) (22050Hz mono):
000h 4 Chunk ID ("Ad10"=normal, "Ad11"=last audio chunk)
004h 4 Chunk Size (D3Ch or D2Ch) (including in last chunk) (big-endian)
008h 4 Sample number (0 and up, step 1714h or 16F8h) (big-endian)
00Ch .. SPU-ADPCM audio data, mono (10h bytes per sample block)
... 10h SPU-ADPCM Padding (extra padding, NOT included in Chunk Size)
Last STR Sector:
Last STR sector contains ending MDEC bytes, but can be smaller than 800h.
|
STR Sector Header:
000h 4 ID (DDCCBBAAh) (aka AABBCCDDh big-endian)
004h 4 Sector number within STR file (0=First, up to Filesize/800h-1)
008h 7F8h Data (video and audio chunks, see below) (first chunk is "ad20")
Video Chunks (MDEC):
000h 4 Chunk ID "MDEC" ;\
004h 4 Chunk Size (...) (big-endian) ;
008h 2 Bitmap Width in pixels (big-endian) ; custom chunk header
00Ah 2 Bitmap Height in pixels (big-endian) ;
00Ch 4 Frame Number (starting at 0) (big-endian) ;/
010h .. Data (in BS v2 format) ;-standard BS v2 data
Audio Chunks (ad20/ad21) (22050Hz stereo):
000h 4 Chunk ID ("ad20"=normal, "ad21"=last audio chunk)
004h 4 Chunk Size (1A50h or 1A70h) (big-endian)
008h 4 Total number of 2x4bit samples in previous chunks (big-endian)
00Ch 2 Unknown (always 800h) (maybe Pitch: 800h=22050Hz) (big-endian)
00Eh 2 Unknown (always 200h) (big-endian)
010h .. SPU-ADPCM audio data, left (10h bytes per sample block)
... .. SPU-ADPCM audio data, right (10h bytes per sample block)
Last STR Sector:
000h 18h FFh-filled (aka 8-byte STR header and 10h-byte Chunk header)
018h - Nothing (total STR filesize is N*800h+18h bytes)
|
STR Sector Header:
No STR Sector header (first sector starts directly with "VLC0" chunk)
VLC0 Chunk (at begin of movie file):
000h 4 Chunk ID "VLC0"
004h 4 Chunk Size (always 1C8h) (big-endian)
008h 1C0h 16bit MDEC values for E0h huffman AC codes (little-endian)
MDEC Chunks(video frames):
000h 4 Chunk ID "MDEC" ;\
004h 4 Chunk Size (...) (big-endian) ; custom chunk header,
008h 2 Bitmap Width in pixels (big-endian) ; instead of STR header
00Ah 2 Bitmap Height in pixels (big-endian) ;
00Ch 4 Frame Number (starting at 0) (big-endian) ;/
010h .. Data (in BS v2 format, but using custom Huffman codes from VLC0)
... .. Zeropadding to 4-byte boundary
Audio Chunks (au00/au01):
000h 4 Chunk ID ("au00"=normal, "au01"=last audio chunk)
004h 4 Chunk Size (...) (big-endian)
008h 4 Total number of 2x4bit samples in previous chunks (big-endian)
00Ch 2 Unknown (always 800h) (maybe Pitch: 800h=22050Hz) (big-endian)
00Eh 2 Unknown (always 200h) (big-endian)
010h .. SPU-ADPCM audio data, left (0Fh bytes per sample block)
... .. SPU-ADPCM audio data, right (0Fh bytes per sample block)
... .. Garbagepadding to 4-byte boundary
Note: SPU-ADPCM does normally have 10h-byte blocks, but in this case,
the 2nd byte (with loop flags) is omitted, hence only 0Fh-byte blocks.
Zero Chunk (zeropadding at end of file, exists only in some EA videos):
000h .. Zeropadding
|
STR Sector Header: No STR Sector header (first sector starts directly with "VMNK" chunk) First chunk (800h bytes): 000h 4 ID "VMNK" (aka KNMV backwards, maybe for Konami Video/Movie) 004h 4 Unknown (01h) 008h 4 Unknown (01h) 00Ch 4 Unknown (F0h) 010h 4 Size of KLBS chunks? (40000h) 014h 4 Bitmap X1 (aka left border)? (16pix, 10h) 018h 4 Bitmap Y1 (aka upper border)? (16pix, 10h) 01Ch 4 Bitmap Width (288pix, 120h) 020h 4 Bitmap Height (144pix, 90h) 024h 7E4h Zerofilled Further chunks (40000h bytes, each): 000h 8 Zerofilled 008h 4 Chunk ID "KLBS" (aka SBLK backwards, maybe for Stream Block) 00Ch 4 Chunk Size (usually 40000h) 010h 4 Number of Name List entries 014h 4 Number of Name List entries (same as above) 018h 8 Zerofilled 020h N*30h Name List ... .. Data (referenced from Name List) ... .. Zeropadding (to end of 40000h-byte chunk) |
Name List entries: 000h 8 Zerofilled 008h 8 Data Type Name (eg. "SCIPPDTS") 010h 4 Time when to play/display the frame (0 and up) 014h 4 Time duration for that frame (usually 14h for Picture frames) 018h 4 Data Offset in bytes (from begin of chunk) 01Ch 4 Data Size in bytes 020h 10h Zerofilled |
Type "SDNSHDTS" aka SNDS,STDH - SoundStdHeader (Size=800h, Duration=0) 000h 4 Maybe Pitch? (800h) (big-endian) 004h 4 Maybe Pitch? (800h) (big-endian) 008h 4 Total SPU-ADPCM size in bytes (for whole .MOV) (big-endian) 00Ch 4 Unknown (FFFFFFFFh) (whatever) 010h 4 Unknown (00007FFFh) (big-endian) 014h 7ECh Zerofilled Type "SDNSSDTS" aka SNDS,STDS - SoundStdStream (Size=10h..4000h, Duration=9Ch) 000h 4000h SPU-ADPCM data in 10h-byte blocks (last chunk is less than 4000h) Type "SCIPPDTS" aka PICS,STDP - PictureStdPicture (Size=3xxxh, Duration=14h) 000h 3xxxh Picture Frame (in BS v1 format) Type "SCTELLEC" aka ETCS,CELL - ExtraCells? (Size=0Ch, Duration=1) 000h .. Maybe subtitle related...? Type "SCTEGOLD" aka ETCS,DLOG - ExtraD-log? (Size=19h..31h, Duration=27h..44h) 000h .. Maybe subtitle related...? |
Header Chunk: 000h 4 Fixed ID (74h,55h,89h,08h aka 08895574h) 004h 2 Bitmap Width (140h) 006h 2 Bitmap Height (100h) 008h 2 Video Frame Size/4 (17A0h or 13B0h) 00Ah 2 Number of Video Frames (01h or 32h) 00Ch 4 Frame End ID (eg. 62DCCACEh) (random?, but stays same within movie) Video Frame Chunk(s): ... .. Data (in BS v1/v2/v3 format) ;\size = hdr[008h]*4 ... .. FFh-filled (padding to Frame Size) ;/ ... 4 Frame End ID (eg. 62DCCACEh) ;-same value as in hdr[00Ch] |
000h 4 File ID (01h,"XSP") (aka PSX backwards) 004h 2 Unknown (0001h) 006h 2 Unknown (0040h) (this is used for something...) 008h 2 Bitmap Width (0140h) 00Ah 2 Bitmap Height (00F0h) 00Ch 4 Total number of video frames 010h 4 Number of video sectors per frame (always 8) 014h 4 Total number of video sectors, excluding audio/dummy (=NumFrames*8) 018h 1 Zero 019h 1 Sector List size (28h) (ie. each 4 frames) ;\or zerofilled when 01Ah 28h Sector Types (2=Video, 1=Audio, 0=Dummy) ;/not present 042h .. Zerofilled 7xxh .. Unknown, maybe just garbage ...? ... .. Zerofilled |
vVvvvvv--vvVvvv--vvvvVv--vvvvvv-Vvvvvvv- Video -------A-------A-------A-------A-------A Audio --------D-------D-------D--------------- Dummy V = 1st sector of video frame v = 2nd..8th sector of video frame (or fileheader in case of sector 0) A = Audio (each 8th sector, ie. sector 07h,0Fh,17h,1Fh,etc.) D = Dummy (occurs after some (not all) audio sectors) Some files have that sector arrangement stored in header[019h..041h], but other files have that header entries zerofilled (despite of using the same arrangement). |
0000h 8 Last 8 bytes of BS v1 bitstream ;\or garbage padding 0008h 3FF0h First 3FF0h of BS v1 bitstream ;/ 3FF8h 8 Footer (64bit, with squeezed BS header and other info) The footer bits are: 0-4 5bit Quant (00h..1Fh) (only 5bit, not 6bit) 5-15 11bit MDEC Size in 20h-word units (80h-byte units) 16-23 8bit Unknown (lowbits are often same as bit48 and up?) 24-31 8bit BS ID/100h (3800h/100h) 32-47 16bit Frame Number (0=First) 48-63 16bit Next Sector Number (start of next video frame) To decrypt/convert the frame to standard BS v1 format: x=[3FF8h] ;get footer [3FF8h..3FFFh]=[0000h..0007h] ;last 8 bytes of bitstream [0000h]=(x AND FF00FFE0h) ;size and ID=3800h [0004h]=(x AND 1Fh)+10000h ;quant and version=v1 The next_sector number is usually current_sector+1 (or +2 if that would be audio), in last frame it does point to end of file. Bitstreams smaller than 3FF8h are garbage padded (initially some 32bit garbage values, and in later frames leftovers from previous bitstream sectors). |
000h 4 Always FFFFFFFFh (unfortunately, this isn't a unique ID) 004h 7FCh Garbage (zeroes, random, or even leaked ASM source code) Dummy sectors have the same Subheader as video sectors, the leading FFFFFFFFh could also occur in BS bitstreams or frames with garbage padding, so one must use the sector arrangement pattern to identify dummy sectors. |
| CDROM File Video Streaming Mis-mastered files |
Format Content Where raw 920h-byte STR K9.5 1 - Live in Airedale (ZZBUFFER.STR) ;\ raw 920h-byte STR Need for Speed 3 (MOVIES\ZZZZZZZ*.PAD) ; raw 920h-byte STR 3D Baseball (ZZZZZZZZ.ZZZ) ; intended raw 920h-byte STR Wing Commander III (DUMMY.DAT) ; padding raw 920h-byte STR R-Types (DMY\DUMMY.BIN) ; raw 920h-byte STR Reel Fishing (MOVIE\STAFF.OLD) ; raw 920h+junk STR+junk Grand Slam (DUMMY.BIN) ; raw 920h-byte XA-ADPCM Spec Ops Airborne Commando (PADDING.NUL) ; raw 920h-byte SW-STR Cyberia (ENDFILL\*.STR) (software render) ; RIFFs/CDXAfmt STRs Sonic Wings Special (SW00.DMY = two RIFFs);/ raw 920h-byte XA-ADPCM Rugrats (MagDemo19: STREAMS\DB02.ISF) ;\nonsense raw 920h-byte Data BABEh Rugrats (MagDemo19: STREAMS\OPEN.BIN) ; dupes raw ???-byte CDDA Championship Surfer (MagDemo43: HWX\MUSIC);/ raw ???-byte CDDA Twisted Metal 2 (MagDemo50: TM2\FRWYSUB.DA) ;-? raw 920h-byte STR Sonic Wings Special (MOV\MQ*.STR) ;-unused? raw 920h-byte STR Apocalypse (MagDemo16: APOC\*.STR) raw 920h-byte XA-ADPCM Apocalypse (MagDemo16: APOC\*.XA) raw 920h-byte XA-ADPCM NFL Xtreme (MagDemo13: NFLX\GAME\SOUND\2PLAYRNO.XA) raw 920h-byte XA-ADPCM Ace Combat 2 (MagDemo01: ACE2.STP) raw 920h-byte XA-ADPCM Colony Wars (MagDemo02: CWARS\DEMO.PAK) raw 920h-byte XA-ADPCM Best Sports demo (AH2\GAMEDATA\COM\MUSIC\MUSIC.IXA) raw 920h-byte XA-ADPCM Tomb Raider: Last Revelation (MagDemo29: TR4\XA1.XA) raw 800h-byte XA-ADPCM Croc 1 demo (MagDemo02: CROC\MAGMUS.STR) (FORM1) RIFF/CDXAfmt XA-ADPCM Best Sports demo (LOMUDEMO\SFX\COMMENT.STR) RIFF/CDXAfmt ?+XA-ADPCM Ace Combat 3 Electrosphere (MagDemo30: AC3\*.SPB) RIFF/CDXAfmt XA-ADPCM Colony Wars Venegance (MagDemo14: CWV\SONYDEMO.PAK) RIFF/WAVEfmt CDDA T'ai Fu (MagDemo16: TAIFU\3_10.WAV, 2x16bit 44100Hz) RIFF/WAVEfmt CDDA Psalm69 (beta) FRONT\FIRE.TRK RIFF/WAVEfmt CDDA Harry Potter and the Philosopher's Stone ZZZDUMMY.Z |
Data/movie sectors look as so: 000h 4 Sub-Header (File, Channel, Submode OR 20h, Codinginfo) 004h 4 Copy of Sub-Header 008h 800h Data (2048 bytes) ;<-- contains STR movie sectors 808h 4 EDC (zerofilled) 80Ch 114h ECC (zerofilled) And XA-ADPCM sectors look as so: 000h 4 Sub-Header (File, Channel, Submode OR 64h, Codinginfo) 004h 4 Copy of Sub-Header 008h 900h Data (18*128 bytes) ;\contains XA-ADPCM audio sectors 908h 14h Data (zerofilled) ;/ 91Ch 4 EDC (zerofilled) |
000h 4 Subheader 01 44 2D 52 ".D-R" ;\distorted 004h 4 Subheader copy 01 4D 20 47 ".M G" ;/"CD-ROM G" 008h 299h Data ASCII 65 6E 65 72 61 ... "enerator for Windows"... 2A1h 567h Data BS bitstream (but lacks BS header and start of bitstream) |
| CDROM File Video BS Compression Versions |
Version .STR movies .BS pictures BS v2 60% 6% Most games BS v3 20% 4% Some newer games BS v1 15% 0.1% Old games BS ea 2% - (?) Electronic Arts titles BS iki 0.5% 0.1% Several games BS fraquant 0.2% 0.1% Rare (X-Files, Eagle One) BS v0 0.1% - Rare (Serial Experiments Lain) BS v2/v3.crypt 0.2% - Rare (Star Wars games) BS iki.encrypted 0.1% - Rare (Panekit) Wacwac MDEC 0.1% - Rare (Aconcagua) Polygon Streams 0.x% (?) - Some titles Raw MDEC - - Was never used in files? MPEG1 - - VCD Video CDs None ?% (?) 90% No videos or BS pictures |
v0 used by Serial Experiments Lain |
v1 used by Wipeout 2097 (MAKE.AV, XTRO*.AV)
v1 used by Viewpoint (MOVIES\*.STR) (oddly with [08h]=FirstFrame=0 and
[1Ch]=Unspecified=Nonzero) (the game also has ".str" files in
VIEW.DIR\streams, but that isn't MDEC/STR stuff)
v1 used by Ridge Racer Revolution (MOVIE\*.STR)
v1 used by Policenauts
v1 used by Final Fantasy VII (FF7)
v1 used by PSX-SDK: Programmer Tool CDROM (PSX\SAMPLE\PRESS\*\*\*.BS, ascii)
v1? used by Tekken 2
v1/v2 used by Final Fantasy Tactics (OPEN*.STR)
v1/v2 used by Project Horned Owl (*.STR)
v1/v2 used by Gex (*.FMV)
(and probably more)
|
v2 used by Gex - Enter the Gecko (*.STR) v2 used by Tomb Raider (FMV\*.FMV) v2 used by Alone (STR*\*.STR) v2 used by Kain (*.STR) v2 used by Fear Effect (BOOT.SID, LOGO.SID, ABGA\ABGA.FLX) v2 used by Parasite Eve 2 (INTERx.STR, and in .CDF's eg. stage1\folder501) v2 used by Witch of Salzburg (MOVIE\*.STR) v2 used by Breath of Fire III (LOGO\*.STR) v2 used by Hear it Now (MOVIE\*.STR) v2 used by Legend of Mana (MOVIE\*.STR) v2 used by Misadventures of Tron Bonne (STR\*.STR) v2 used by Rayman (VIDEO\*.STR) v2 used by Resident Evil 1 (PSX\MOVIE\*.STR) ;\although v3 is v2 used by Resident Evil 2 (PL0\ZMOVIE\*.STR, ZMOVIE\*.STR) ;/used in *.BSS v2 used by Tokimeki Memorial 2 (VX*.STR) v2 used by Spider-Man (CINEMAS\*.STR) v2 used by Perfect Assassin (CDV\*.STR) v2 used by Pandemonium 2 (*.STR) v2 used by Die Hard Trilogy 2 (MOVIE\*.STR) v2 used by Need for Speed 3 (MOVIES\*.STR) (oddly with [14h,18h]<>[20h,24h]) v2 used by Wild Arms (STR\*.STR) v2 used by Wild Arms 2 (STR\*.STR) v2 used by Frogger (*.STR) v2 used by Gundam Battle Assault (XA\*.STR) v2 used by Alundra (MOVIE\*.MOV) v2 used by Spec Ops (file 95h,96h within BIGFILE.CAT) v2 used by Crash Team Racing (file 1E1h..1F8h,1FAh within BIGFILE.BIG) (and many more) |
v2/v3 used by Lemmings Oh No More Lemmings (ANIMS\*.STR) v2/v3 used by Castlevania (*.STR) v3 used by Heart of Darkness (CINE\*.STR, SETUP\*.STR) v3 used by R-Types (MV\*.STR) v3 used by Black Matrix (MOVIE\*.STR) v3 used by Nightmare Creatures II (INTRO\*.STR, LEVEL*\*.STR) (and many more) |
Castrol Honda Superbike Racing EA Sports Supercross 2000, 2001 Future Cop - L.A.P.D. (retail and MagDemo14: FCOPLAPD\*.WVE and *.FSV) Hot Wheels - Turbo Racing Jampack Vol. 2 Knockout Kings 99, 2000, 2001 Madden NFL 99, 2000, 2001, 2002, 2003, 2004, 2005 (eg. MADN00\FMVIDEO.DAT\*) NASCAR 98, 99, 2000, 2001 (and 98 Collector's Edition, and 99 Legacy) NASCAR Thunder 2002, 2003, 2004 and NASCAR Rumble Nuclear Strike Official U.S. PlayStation Magazine Demo Disc 39 (...XXX which game?) PlayStation Underground Jampack - Winter 2000 Road Rash Jailbreak, and Road Rash 3D Tiger Woods PGA Tour Golf, and Tiger Woods USA Tour 2001 |
X-Files (Fox Interactive/Hyperbole Studios, 1999) Eagle One: Harrier Attack (Infogrames/Glass Ghost, 2000) Blue's Clues: Blue's Big Musical (Mattel/Viacom/TerraGlyph, 2000) |
iki: Gran Turismo 1 (STREAM.DAT) ;\with uncommon STR header iki: Gran Turismo 2 (STREAM.DAT) ;/ iki: Hot Shots Golf 2 / Everybody's Golf 2 (MagDemo31: HSG2\MINGOL2X.BIN) iki: Legend of Legaia (MagDemo20: LEGAIA\MOV\MV2.STR) iki: Legend of Dragoon (STR\*.IKI) iki: Omega Boost (MOVIE\*.IKI) iki: Um Jammer Lammy (MagDemo24: UJL\*.IKI) (retail: *\*.IKI and CM\*.IK2) iki: plus a dozen of japanese-only titles |
Panekit - Infinitive Crafting Toy Case (first 13Mbyte in PANEKIT.STR) |
v3.xor used by Star Wars Masters of Teras Kasi (MagDemo03: MASTERS\*.STR) v2.xor supported (but not actually used) by Star Wars Masters (MagDemo03) v3.swap used by Star Wars Rebel Assault II (*.STR, *.SED, Stills) v2.swap used by Star Wars Rebel Assault II (*.STR) v3.swap used by BallBlazer Champions (*.STR) |
Aconcagua (JP) (2000 Sony/WACWAC!) (STR_01_00.STR and STR_09_01.STR) |
Ape Escape (DEMO\*.STR, STR\*.STR, and KKIIDDZZ.HED\STR\0006h and up) Aconcagua (most STRs are Polygon Streams, except two are Wacwac MDEC streams) Panekit - Infinitive Crafting Toy Case (last 150Mbyte in PANEKIT.STR) |
Ridge Racer 1 (1994) Lightspan Online Connection CD |
| CDROM File Video BS Compression Headers |
000h 2 MDEC Size/4 (after huffman decompression) (rounded to 80h/4 bytes) 002h 2 File ID (3800h) 004h 2 Quantization step/factor (0000h..003Fh, for MDEC "DCT.bit10-15") 006h 2 Version (1, 2, or 3) (2 is most common) 008h ... Huffman compressed data blocks (Cr,Cb,Y1,Y2,Y3,Y4, Cr,Cb,Y1,Y2..) |
000h 2 MDEC Size/4 (rounded to 80h/4 bytes) (unencrypted) ;\same as normal
002h 2 File ID (3800h) (unencrypted) ; BS v1/v2/v3
004h 2 Quant (0..3Fh) (unencrypted) ;/
006h 2 Version (in bit15, plus random in LSBs):
00xxh..7FFFh for v2 (unknown if this could include values 0..3)
8000h..FFFFh for v3 (bit14-0=random, varies in each frame)
008h .. Encrypted bitstream
(each halfword XORed by BE67h for v2, or XORed by E67Bh for v3)
... (2) Zeropadding to 4-byte boundary (unencrypted)
... .. Zeropadding to end of sector (unencrypted)
The XOR values BE67h/E67Bh are hardcoded in the Star Wars Masters of Teras
Kasi .EXE (same XOR values for both retail and demo version), unknown if any
other games are also using that kind of encryption (and if yes, if they are
using the same XOR values).
|
000h 2 MDEC Size/4 (rounded to 80h/4 bytes) ;\same as normal 002h 2 File ID (3800h) ; BS v1/v2/v3 004h 2 Quant (0..3Fh) ;/ 006h 2 Version (random 16bit, 00xxh..FFFFh) ;-no meaningful version info 008h 2 Bitstream 2nd halfword ;\to "decrypt" the file, 00Ah 2 Bitstream 1st halfword ;/these must be swapped 00Ch .. Bitstream 3rd halfword and up ;-in normal order |
if header[06h]<=0003h then assume unencrypted v0/v1/v2/v3 if header[06h]>=0004h then strip any trailing 0 bits, and check EndOfFrame.. if last 10bit = 0111111111 then assume SWAP.v2 if last 10bit = 1111111111 then assume SWAP.v3 otherwise assume XOR.v2/v3 (and use header[06h].bit15 to distinguish v2/v3) |
000h 2 MDEC Size/4 (rounded to 80h/4 bytes) ;\same as normal 002h 2 File ID (3800h) ;/BS v1/v2/v3 004h 2 Bitmap Width in pixels ;instead of Quant 006h 2 Bitmap Height in pixels ;instead of Version 008h 2 Size of GT-ZIP compressed data (plus 2-byte alignment padding) 00Ah .. GT-ZIP compressed DC/Quant values (plus 2-byte alignment padding) ... .. Huffman compressed AC data blocks (Cr,Cb,Y1,Y2,Y3,Y4, Cr,Cb,Y1,Y2..) |
[buf+00h]=[buf+00h] XOR FFFFFFFFh [buf+04h] <--> [buf+08h] ;exchange 2x32bit [buf+0Ch] <--> [buf+0Eh] ;exchange 2x16bit [buf+10h]=[buf+10h]+FFFF6F7Bh [buf+14h]=[buf+14h]+69140000h [buf+18h]=[buf+18h]+FFFF7761h [buf+1Ch]=[buf+1Ch]+6B040000h |
X-Files, GRAPHICS\*.STR,*.BIN, LOGOS\*.STR,*.BS, *.BF\* Eagle One: Harrier Attack (\*.STR, DATA*\*.STR) (leading zerofilled sectors) Blue's Clues: Blue's Big Musical (*.STR) (has one leading zerofilled sector) |
004h 2 Quant (0001h..0003h, or fixed-point 8000h..9xxxh) |
quant=BsHeader[04h] ;get fractional quant value
BsHeader[04h]=0001h ;force quant=1 (for use in BS v1/v2/v3 decoder)
if quant<8000h then quant=quant*200h else quant=quant AND 7FFFh
quant[0]=default_quant_table[0]
for i=1 to 3Fh,
x=(default_quant_table[i]*quant)/200h
if x=00000000h then quant[i]=01h else quant[i]=(x AND FFh)
next i
use MDEC(2) command to apply quant[0..3Fh] to both Luma and Chroma tables
use normal BS v1/v2/v3 decoder to decompress the bitmap
|
000h 1 Quant for Y1,Y2,Y3,Y4 (00h..3Fh) 001h 1 Quant for Cr,Cb (00h..3Fh) 002h 2 File ID (3800h) (or Frame Number in ENDROLL1.STR on Disc 2) 004h 2 MDEC Size/2 (!), and without padding (!) (unlike v1/v2/v3/iki) 006h 2 BS Version (0) (actually MSBs of above Size, but MSBs are always 0) 008h .. Huffman Bitstream, first bit in bit7 of first byte |
000h 2 Bitmap Width in pixels ;\cropped to non-black screen area, 002h 2 Bitmap Height in pixels ;/size can vary within the sequence 004h 2 Quant for Y1,Y2,Y3,Y4 (0000h..003Fh) 006h 2 Quant for Cr,Cb (0000h..003Fh) 008h 4 Size of compressed BS Bitstream plus 4 ;Transparency at [008h]+0Ch 00Ch 2 Size/2 of MDEC data (after huffman decompression, without padding) 00Eh 2 BS Version (0) (actually MSBs of above Size, but it's always 0) 010h .. BS Bitstream with DC and AC values (Huffman compressed MDEC data) ... 4 Transparency Mask Decompressed Size (Width*Height*2/8) (=2bpp) ... .. Transparency Mask LZSS-compressed data |
000h 2 MDEC Size/4 (after huffman decompression) (rounded to 80h/4 bytes) 002h 2 File ID (3800h) 004h .. MDEC data (16bit DC/AC/EOB codes) ... .. Padding (FE00h-filled to 80h-byte DMA transfer block size boundary) |
| CDROM File Video BS Compression DC Values |
nnnnnnnnnn DC Value (signed 10bit, -200h..+1FFh) |
If output_size=NumberOfMdecCodes*2 then EndOfFrame If BlockIsCrCb then QuantDC=DC+QuantC*400h else QuantDC=DC+QuantY*400h |
nnnnnnnnnn DC Value (signed 10bit, -200h..+1FEh) 0111111111 End of Frame (+1FFh, that, in place of Cr) |
If DC=+1FFh then EndOfFrame QuantDC=DC+Quant*400h |
For Cr/Cb For Y1..Y4 Offset (added to old DC of Y/Cr/Cb block) 00 100 +(00h) ;\ 01s 00s -(01h)*4 ,+(01h)*4 ; 10sn 01sn -(03h..02h)*4,+(02h..03h)*4 ; required 110snn 101snn -(07h..04h)*4,+(04h..07h)*4 ; codes 1110snnn 110snnn -(0Fh..08h)*4,+(08h..0Fh)*4 ; for 10bit 11110snnnn 1110snnnn -(1Fh..10h)*4,+(10h..1Fh)*4 ; range 111110snnnnn 11110snnnnn -(3Fh..20h)*4,+(20h..3Fh)*4 ; 1111110snnnnnn 111110snnnnnn -(7Fh..40h)*4,+(40h..7Fh)*4 ;/ 11111110snnnnnnn 1111110snnnnnnn -(FFh..80h)*4,+(80h..FFh)*4 ;-11bit (!) - 11111110 Unused ;\ 111111110 111111110 Unused ; unused 1111111110 1111111110 Unused ;/ 1111111111 1111111111 End of Frame ;-end code Note: the "snnn" bits are indexing the values in right column, with s=0 for negative values, and s=1 for positive values. |
If bits=1111111111 then EndOfFrame If BlockIsCr then DC=DecodeHuffman(HuffmanCodesCbCr)+oldDcCr, oldDcCr=DC If BlockIsCb then DC=DecodeHuffman(HuffmanCodesCbCr)+oldDcCb, oldDcCb=DC If BlockIsY1234 then DC=DecodeHuffman(HuffmanCodesY1234)+oldDcY, oldDcY=DC If older_version AND DC>=0 then QuantDC=Quant*400h or (DC) ;\requires If older_version AND DC<0 then QuantDC=Quant*400h or (DC+400h) ;/11bit If newer_version then QuantDC=Quant*400h+(DC AND 3FFh) ;-wrap 10bit |
If BlockNo>=NumBlocks then EndOfFrame QuantDC = DCbuf[BlockNo]*100h + DCbuf[BlockNo+NumBlocks] |
| CDROM File Video BS Compression AC Values |
10 FE00h ;End of Block, EOB
11s 0001h
011s 0401h
010xs 0002h,0801h
0011xs 1001h,0C01h
00101s 0003h
00100xxxs 3401h,0006h,3001h,2C01h,0C02h,0403h,0005h,2801h
0001xxs 1C01h,1801h,0402h,1401h
00001xxs 0802h,2401h,0004h,2001h
000001xxxxxxxxxxxxxxxx 0000h..FFFFh ;Escape code for raw 16bit values
000001xxxxxx0000000000 0000h..FC00h ;Escape nonsense level=0 (used in v1)
0000001xxxs 4001h,1402h,0007h,0803h,0404h,3C01h,3801h,1002h
00000001xxxxs 000Bh,2002h,1003h,000Ah,0804h,1C02h,5401h,5001h,
0009h,4C01h,4801h,0405h,0C03h,0008h,1802h,4401h
000000001xxxxs 2802h,2402h,1403h,0C04h,0805h,0407h,0406h,000Fh,
000Eh,000Dh,000Ch,6801h,6401h,6001h,5C01h,5801h
0000000001xxxxs 001Fh,001Eh,001Dh,001Ch,001Bh,001Ah,0019h,0018h,
0017h,0016h,0015h,0014h,0013h,0012h,0011h,0010h
00000000001xxxxs 0028h,0027h,0026h,0025h,0024h,0023h,0022h,0021h,
0020h,040Eh,040Dh,040Ch,040Bh,040Ah,0409h,0408h
000000000001xxxxs 0412h,0411h,0410h,040Fh,1803h,4002h,3C02h,3802h,
3402h,3002h,2C02h,7C01h,7801h,7401h,7001h,6C01h
000000000000 Unused
|
10 FE00h ;End of Block, EOB
11s 0001h
011s 0002h
010xs 0401h,0003h
0011xs 0801h,0005h
00101s 0004h
00100xxxs 000Ah,000Bh,0403h,1801h,000Ch,000Dh,1C01h,000Eh
0001xxs 0006h,0C01h,0402h,0007h
00001xxs 0008h,1001h,0009h,1401h
000001xxxxxx0xxxxxxx 0000h..FC00h+(+001h..+07Fh AND 3FFh) ;\
000001xxxxxx000000001xxxxxxx 0000h..FC00h+(+080h..+0FFh AND 3FFh) ; Escape
000001xxxxxx000000000xxxxxxx Unused ; codes
000001xxxxxx1xxxxxxx 0000h..FC00h+(-080h..-001h AND 3FFh) ;
000001xxxxxx100000000xxxxxxx 0000h..FC00h+(-100h..-081h AND 3FFh) ;
000001xxxxxx100000001xxxxxxx Unused ;/
0000001xxxs 000Fh,0802h,2001h,0404h,0010h,0011h,2401h,0012h
00000001xxxxs 0013h,0405h,0014h,2801h,0015h,0C02h,3001h,0017h,
0016h,2C01h,0018h,001Ch,0019h,0406h,0803h,001Bh
000000001xxxxs 001Ah,3401h,001Dh,0407h,1002h,001Fh,001Eh,3801h,
0020h,0021h,0408h,0023h,0022h,1402h,0024h,0025h
0000000001xxxxs 0804h,0409h,0418h,0026h,3C01h,0027h,0C03h,1C03h,
0028h,0029h,002Ah,002Bh,040Ah,002Ch,1802h,002Dh
00000000001xxxxs 002Fh,002Eh,4001h,0805h,0030h,040Bh,0031h,0033h,
0032h,1C02h,0034h,1003h,0035h,4401h,040Ch,0037h
000000000001xxxxs 0036h,0038h,0039h,5401h,003Ah,0C04h,040Dh,5C01h,
2002h,003Bh,0806h,4C01h,003Ch,2402h,6001h,4801h
000000000000 Unused
|
FE00h End of Block (EOB) 7C1Fh Escape code (huffman code will be followed by v2-style 16bit value) |
10 00
11x 01,02
011x 03,04
010xx 05,06,07,08
0011xx 0D,0E,0B,0C
00101x 09,0A
00100xxxx 2E,2F,22,23,2C,2D,2A,2B,26,27,24,25,20,21,28,29
0001xxx 15,16,13,14,0F,10,11,12
00001xxx 1A,1B,1E,1F,18,19,1C,1D
000001 17h
0000001xxxx 3E,3F,38,39,30,31,34,35,32,33,3C,3D,3A,3B,36,37
00000001xxxxx 46,47,54,55,4E,4F,44,45,4A,4B,52,53,5E,5F,5C,5D,
42,43,5A,5B,58,59,48,49,4C,4D,40,41,50,51,56,57
000000001xxxxx 74,75,72,73,70,71,6E,6F,6C,6D,6A,6B,68,69,66,67,
64,65,62,63,60,61,7E,7F,7C,7D,7A,7B,78,79,76,77
0000000001xxxxx 9E,9F,9C,9D,9A,9B,98,99,96,97,94,95,92,93,90,91,
8E,8F,8C,8D,8A,8B,88,89,86,87,84,85,82,83,80,81
00000000001xxxxx B0,B1,AE,AF,AC,AD,AA,AB,A8,A9,A6,A7,A4,A5,A2,A3,
A0,A1,BE,BF,BC,BD,BA,BB,B8,B9,B6,B7,B4,B5,B2,B3
000000000001xxxxx C6,C7,C4,C5,C2,C3,C0,C1,C8,C9,D4,D5,D2,D3,D0,D1,
CE,CF,CC,CD,CA,CB,DE,DF,DC,DD,DA,DB,D8,D9,D6,D7
000000000000 Unused
|
| CDROM File Video BS Picture Files |
Alice in Cyberland (ALICE.PAC\*.BS) BallBlazer Champions (BBX_EXTR.DAT\Pics\*) (SWAP-encrypted) Bugriders: The Race of Kings (*\*.BS and STILLS\MENUS.BS\*) Die Hard Trilogy 2 (DATA\*.DHB, DATA\DH*\L*\*.DHB, MOVIE\*.DHB) Dino Crisis 2 (PSX\DATA\ST*.DBS\*) Duke Nukem (MagDemo12: DN_TTK\*) Final Fantasy VII (FF7) (MOVIE\FSHIP2*.BIN\*) (BS v1) Gran Turismo 1 (retail TITLE.DAT\* and MagDemo10/15) (in BS iki format) Jet Moto 2 (MagDemo03: JETMOTO2\*) Mary-Kate and Ashley Crush Course (MagDemo52: CRUSH\SCRN\*.BS) Mat Hoffman's Pro BMX (MagDemo48: MHPB\STILLS.BIN\*) (with width/height info) NFL Gameday '99 (MagDemo17: GAMEDAY\FE\GD98DATA.DAT) Official U.S. PlayStation Magazine Demo Disc 01-02 (MENU\DATA\*.BSS) Official U.S. PlayStation Magazine Demo Disc 03-54 (MENU.FF\*) Parasite Eve 2 (INIT.BS, and within .HED/.CDF archives) Reel Fishing (*.PAK\*) Resident Evil 1 (PSX\STAGE*\*.BSS, headerless archive, 8000h-byte align) Resident Evil 2 (COMMON\BSS\*.BSS, headerless archive, 10000h-byte align) Rugrats (MagDemo19: RUGRATS\*) Rugrats Studio Tour (MagDemo32: RUGRATS\DATA\RAW\*.BS) Starwars Demolition (MagDemo39+MagDemo41: STARWARS\SHELL\.BS+.TBL\*) Star Wars Rebel Assault 2 (RESOURCE.000\Stills\*) (SWAP-encrypted) Ultimate Fighting Championship (MagDemo38: UFC\CU00.RBB\390h..3E2h) Vigilante 8 (MagDemo09: EXAMPLE\*) Witch of Salzburg (PICT\PIC*\*.BS and DOT1 archives *.BSS, *.DAT, *.BIN) X-Files (LOGOS\*.BS and GRAPHICS\GRAPHICS.BIN and GRAPHICS\PACKEDBS.BIN\*) You Don't Know Jack 2 (MagDemo41: YDKJV2\RES\UI\*.BS) |
For BS iki format, use resolution from iki header (eg. Gran Turismo 1) For MHPB\STILLS.BIN, there's width/height in chunk headers Count the number of blocks (EOB codes) during Huffman decompression Divide that number by 6 to get the number of Macroblocks Search matches for Height=NumBlocks/Width with Width>=Height and Remainder=0 If Height=300..400, assume double H-resolution, repeat with Width/2>=Height And/or use a list of known common resoltions (see below examples) Search arrangements with many similar colors on adjacent macroblocks |
Blocks Pixels Example F0h 256x240 any? 12Ch 320x240 Resident Evil 2 (COMMON\BSS\*.BSS) 1E0h 512x240 Demo Disc 03-54 (MENU.FF\*), Duke Nukem (MagDemo12) 1E0h 640x192 Less common than above (but used by Witch of Salzburg) 4B0h 640x480 Vigilante 8 (MagDemo09), Jet Moto 2 (MagDemo03) var random Witch of Salzburg has various random resolutions iki ikihdr Gran Turismo 1 has A0hxA0h and odd size (!) E8hx28h ? ? Final Fantasy VII (FF7) ? ? Ultimate Fighting Championship (UFC\CU00.RBB\3B7h..3E2h) 118h 320x224 Alice in Cyberland (most files; or two such as panorama) 230h ? Alice in Cyberland (AD_115.BS and AD_123A.BS) |
C8h 320x160 Unlikely for pictures (but used for STR videos, eg. Alone) F0h 320x192 Unlikely for pictures (but used for STR videos, eg. Wipeout) 1E0h 384x320 Very unlikely to see that vertical resolution on PSX |
000h 2 Width (280h) ;\extra header 002h 2 Height (1E0h) ;/ 004h 2 MDEC Size/4 (after huffman decompression) (rounded to 80h/4 bytes) 006h 2 File ID (3800h) 008h 2 Quantization step/factor (0000h..003Fh, for MDEC "DCT.bit10-15") 00Ah 2 Version (1, 2, or 3) (2 is most common) 00Ch ... Huffman compressed data blocks (Cr,Cb,Y1,Y2,Y3,Y4, Cr,Cb,Y1,Y2..) |
| CDROM File Video Wacwac MDEC Streams |
Aconcagua (JP) (2000 Sony/WACWAC!) |
000h 2 STR ID (0160h) 002h 2 STR Type WACWAC Tables (0002h=IntroTableSet, 0003h=EndingTableSet) 004h 2 Sector number within current Frame (0000h..num-1) 006h 2 Number of Sectors in this Frame 008h 4 Frame number (6 or 11 and up, because 1st some frames are Polygons) 00Ch 4 Frame Size in bytes 010h 2 Bitmap Width (always 140h) ;\always 320x208 (in fact, the 012h 2 Bitmap Height (always 0D0h) ;/decoder is hardcoded as so) 014h 4 Quant (0..3Fh) (same for all sectors within the frame) 018h 8 Zerofilled 020h 7E0h Raw Bitstream data (without Quant or BS header) (garbage padded) |
Intro=Disc1:\ST01_01\STR_01_00.STR Ending=Disc2:\ST09_01\STR_09_01.STR Leading zeroes (150 sectors) Leading zeroes (150 sectors) Frame 0001h..0005h Polygon Frames Frame 0001h..000Ah Polygon Frames Frame 0006h..0545h MDEC Frames 20MB Frame 000Bh..0D79h MDEC Frames 50MB Frame 0546h..1874h Polygon Frames 48MB |
Read Huffman code for DC, and output Quant*400h+(DC AND 3FFh) Read Huffman code for Size, aka num1,num2,num3 values for below reads Repeat num1 times: Read Huffman code for AC1, and output AC Repeat num2 times: Read Huffman code for AC2, and output AC Repeat num3 times: Read Huffman code for AC3, and output AC Output EOB (end of block) |
14h*0Dh*6*41h*2+Align(80h)+Header(4) = 31880h+4 bytes |
80112AF8h (1690h bytes) ;Table Set for Intro Scene 80114188h (1B68h bytes) ;Table Set for Ending Scene |
000h 4 Table Set size (1690h or 1B68h) 004h 4 Table Set exploded size (when allocating 16bit/DC, 32bit/Size/AC) 008h 2 Size Table max Huffman size in bits (0Ah or 09h) ;\Size 00Ah 2 Size Table number of entries (40h) ;/ 00Ch 2 DC Table max Huffman size in bits (0Bh) ;\ 00Eh 2 DC Table number of entries (100h) ; DC 010h 2 DC Huffman code Escape 10bit (non-relative 10bit DC value) ; 012h 2 DC Huffman size Escape 10bit (3 or 6, escape prefix size) ;/ 014h 2 AC1 Table max Huffman size in bits (0Eh or 0Bh) ;\ 016h 2 AC1 Table number of entries (0DAh or 100h) ; 018h 2 AC1 Huffman code Escape 7bit (run=0bit, level=signed7bit) ; AC1 01Ah 2 AC1 Huffman code Escape 16bit (run=6bit, level=10bit) ; 01Ch 2 AC1 Huffman size Escape 7bit (9 or 7, escape prefix size) ; 01Eh 2 AC1 Huffman size Escape 16bit (9 or 7, escape prefix size) ;/ 020h 2 AC2 Table max Huffman size in bits (0Eh) ;\ 022h 2 AC2 Table number of entries (AAh or F4h) ; 024h 2 AC2 Huffman code Escape 8bit (run=3bit, level=signed5bit) ; AC2 026h 2 AC2 Huffman code Escape 16bit (run=6bit, level=10bit) ; 028h 2 AC2 Huffman size Escape 8bit (10 or 9, escape prefix size) ; 02Ah 2 AC2 Huffman size Escape 16bit (10 or 9, escape prefix size) ;/ 02Ch 2 AC3 Table max Huffman size in bits (0Eh) ;\ 02Eh 2 AC3 Table number of entries (87h or B2h) ; 030h 2 AC3 Huffman code Escape 8bit (run=4bit, level=signed4bit) ; AC3 032h 2 AC3 Huffman code Escape 16bit (run=6bit, level=10bit) ; 034h 2 AC3 Huffman size Escape 8bit (10 or 9, escape prefix size) ; 036h 2 AC3 Huffman size Escape 16bit (10 or 9, escape prefix size) ;/ 038h .. Size Table (64bit per entry) ;\ ... .. DC Table (32bit per entry) ; ... .. AC1 Table (64bit per entry) ; Tables ... .. AC2 Table (64bit per entry) ; ... .. AC3 Table (64bit per entry) ;/ |
0-1 Zero 2-31 Huffman code (10bit max) 32-39 Number of AC1 codes in this block ;\implies End of Block (EOB) 40-47 Number of AC2 codes in this block ; after those AC codes 48-55 Number of AC3 codes in this block ;/ 56-63 Huffman size (1..10 bits) |
0-9 Relative DC Value (relative to old DC from memorized Cr,Cb,Y) 10-15 Huffman size (1..11 bits) 16-31 Huffman code (11bit max) Notes: For the relative DC's, the decoder does memorize DC for Cr,Cb,Y upon decoding Cr,Cb,Y1,Y3 (but does NOT memorize DC when decoding Y2,Y4). Initial DC for Cr,Cb,Y is zero at begin of each 16x208pix slice. Obscurities: The decoder does accidentally use bit10 to sign-expand the DC value in bit0-9 (but does mask-off those bugged sign bits thereafter), and the decoder does uselessly memorize Y1 and Y3 separately (but uses only the most recently memorized value). |
0-1 Zero 2-31 Huffman code (14bit max) 32-47 MDEC code (6bit run, and 10bit AC level) 48-63 Huffman size (1..14 bits) |
| CDROM File Video Polygon Streaming |
000h 2 STR ID (0160h) 002h 2 STR Type (0002h=Custom, Software rendering) 004h 2 Sector number within current Frame (0..num-1) 006h 2 Number of Sectors in this Frame (varies) 008h 4 Frame Number (1=First) 00Ch 4 Frame Size in Bytes/4 (note: first frame in MAP*.STR is quite big) 010h 2 Rendering Width (0140h) 012h 2 Rendering Height (00C0h) 014h 0Ch Unknown (zerofilled or random garbage) 020h 7E0h Custom data for software rendering |
000h 4 Number of remaining frames ... 22FCh Unknown data (zeropadded if smaller) |
_______________ Unknown Streaming Data (Polygons or whatever) ________________ |
BIGFILE.FOO\0151h\0005h,0009h,000Fh,0017h,001Bh, 02E5h,02E9h,..,0344h,0348h BIGFILE.FOO\0152h\0186h,018Ch,0192h,0198h) BIGFILE.FOO\0153h\029Ah,02A0h,02A6h,02ACh) |
000h 2 STR ID (0160h) 002h 2 STR Type (0001h=Custom) 004h 2 Sector number within current Frame (always 0) 006h 2 Number of Sectors in this Frame (always 1) 008h 4 Frame Number (1=First) 00Ch 4 Frame Size (6FAh or 77Ah, sometimes 17Ah or 1FAh or 20Ah) 010h 2 Unknown (280h, or sometimes 300h or 340h) 012h 2 Frame Time (0=First, increases with step [19h], usually +5 or +7) 014h 2 Unknown (280h, or sometimes 300h or 3C0h, or 0) 016h 1 Frame Time (same as [012h] AND FFh) 017h 1 Unknown (0 or 1) 018h 1 Unknown (40h, or 80h, or C0h) 019h 1 Duration? (5 or 7, or sometimes less, step for Frame Time) 01Ah 1 Unknown (3, or less in last some frames) 01Bh 5 Zerofilled 020h 7E0h Data (increasing/decreasing bytes... maybe non-audio waveforms?) |
000h 2 STR ID (0160h) 002h 2 STR Type (0000h=Custom) 004h 2 Sector number within current Frame (0..2) 006h 2 Number of Sectors in this Frame (always 4) (3xSTR + 1xADPCM) 008h 4 Frame Number (1=First) 00Ch 4 Frame Size? (800h, despite of having 3 sectors with 7E0h each?) 010h 2 Unknown (00h or 01h) 012h 2 Unknown (A3h or ABh ... 6Ch or 7Bh ... or 43h or 49h) 014h 2 Sector number within current Frame (0..2) (same as [004h]) 016h 0Ah Zerofilled 020h 7E0h Data (polygon streaming or so?) |
Charumera ENDING.XA (with dummy/zero data) True Love Story TLS\MULTI.XA (with nonzero data) True Love Story 2 TLS2\ENDING.STR and TLS2\MULTI.XA True Love Story Fan Disc ;\probably use that format, too True Love Story: Remember My Heart ;/(not verified) |
0000h=Whatever special, channel 0 header (sector 0) 0400h=Whatever special, channel 1 header (sector 1) 0001h=Whatever special, channel 0 data (sector 2,4,6,8) 0401h=Whatever special, channel 1 data (sector 3,5,7,9) |
\*.STR MDEC movies ;\BS fraquant (except, demo version \DATA*\*.STR MDEC movies ;/ on MagDemo31 uses mormal BS v2) \DATA*\M*\L*.STR Multi-language TXT files with STR header on each sector \DATA*\M*\I*.STR unknown binary data (whatever and SPU-ADPCM) \LANGN.STR unknown binary data (whatever) |
| CDROM File Audio Single Samples VAG (Sony) |
000h 4 File ID (usually "VAGp") 004h 4 Version (usually 02h, or 20h) (big-endian) 008h 4 Reserved (0) (except when ID="VAGi") (big-endian) 00Ch 4 Channel Size (data size... per channel?) (big-endian) 010h 4 Sample Rate (in Hertz) (eg. 5622h=22050Hz) (big-endian) 014h 0Ch Reserved (0) (except when version=2) 020h 10h Name (ASCII, zeropadded) ... (..) Optional ID string (eg. "STEREO" in upper/lowercase) ... (..) Optional Padding to Data start ... .. ADPCM Data for channel(s) (usually at offset 030h) |
.vag default (eg. many PSX games) .vig 2-channel with interleave=10h (eg. PS2 MX vs ATV Untamed) .vas 2-channel with interleave=10h (eg. PS2 Kingdom Hearts II) .swag 2-channel with interleave=filesize/2 (eg. PSP Frantix) .l and .r 2-channel in l/r files (eg. PS2 Gradius V, PS2 Crash Nitro Kart) .str whatever (eg. P?? Ben10 Galactic Racing) .abc whatever (eg. PSP F1 2009 (v6), according to wiki.xentax.com) |
"VAGp" default (eg. many PSX games) "VAG1" 1-channel (eg. PS2 Metal Gear Solid 3) "VAG2" 2-channel (eg. PS2 Metal Gear Solid 3) "VAGi" 2-channel interleaved (eg. ?) "pGAV" little endian with extended header (eg. PS2 Jak 3, PS2 Jak X) "AAAp" extra header, followed by "VAGp" header (eg. PS2 The Red Star) |
00000000h v1.8 PC 00000002h v1.3 Mac (eg. PSX Wipeout 2097, in SAMPLES.WAD) 00000003h v1.6+ Mac 00000020h v2.0 PC (most common, eg. PSX Perfect Assassin) 00000004h ? (later games, uh when/which?) 00000006h ? (vagconf, uh when/which?) 00020001h v2.1 (vagconf2) ;\with HEVAG coding instead SPU-ADPCM 00030000h v3.0 (vagconf2) ;/(eg. PS4/Vita) 40000000h ? (eg. PS2 Killzone) (1-channel, little endian header) |
008h 4 Interleave (little endian) (the other header entries are big endian) |
014h 2 Volume left 4Eh,82h ;-Port 1F801C00h 016h 2 Volume right 4Eh,82h ;-Port 1F801C02h 018h 2 Pitch (includes fs modulation) A8h,88h ;-Port 1F801C04h +extra bit? 01Ah 2 ADSR1 00h,00h ;-Port 1F801C08h 01Ch 2 ADSR2 00h,E1h ;-Port 1F801C0Ah 01Eh 2 ? A0h,23h ;-Port 1F801C0xh maybe? |
01Eh 1 Number of channels (0 or 1=Mono, 2=Stereo) |
01Ch 2 Zero ;if non-zero: force Mono 01Eh 1 Number of channels (0 or 1=Mono, 2=Stereo ;if 10h..FFh: force Mono 01Fh 1 Zero ;if non-zero: force Mono |
None default (for 1-channel mono) (and separate .l .r stereo files) 800h when ID="VAG2" [008h] when ID="VAGi" (little-endian 32bit header[008h]) 1000h when ID="pGAV" and [020h]="Ster" and this or that 2000h when ID="pGAV" and [020h]="Ster" and that or this 10h when filename extension=".vig" 10h when Version=0002001h or Version=00030000h (and channels=2) filesize/2 when filename extension=".swag" 6000h when [6000h]="VAGp" (eg. PSX The Simpsons Wrestling) 1000h when [1000h]="VAGp" (eg. PS2 Sikigami no Shiro) ... |
000h 4 ID "AAAp" 004h 2 Interleave 006h 2 Number of Channels (can be 1 or 2?) 008h 30h*N VAGp header(s) for each channel, with Version=00000020h ... .. ADPCM Data (interleaved when multiple channels) |
| CDROM File Audio Sample Sets VAB and VH/VB (Sony) |
.VAB contains VAB header, and ADPCM binaries ;-all in one file .VH contains only the VAB header ;\in two separate files .VB contains only the ADPCM binaries ;/ |
0000h 4 File ID ("pBAV")
0004h 4 Version (usually 7) (reportedly 6 exists, too) (5, 20h exists)
0008h 4 VAB ID (usually 0)
000Ch 4 Total .VAB filesize in bytes (or sum of .VH and .VB filesizes)
0010h 2 Reserved (EEEEh)
0012h 2 Number of Programs, minus 1 (0000h..007Fh = 1..128 programs)
0014h 2 Number of Tones, minus? (max 0800h?) (aka max 10h per program)
0016h 2 Number of VAGs, minus? (max 00FEh)
0018h 1 Master Volume (usually 7Fh)
0019h 1 Master Pan (usually 40h)
001Ah 1 Bank Attribute 1 (user defined) (usually 00h)
001Bh 1 Bank Attribute 2 (user defined) (usually 00h)
001Ch 4 Reserved (FFFFFFFFh)
0020h 800h Program Attributes 10h-byte per Program 00h..7Fh (fixed size)
0820h P*200h Tone Attributes 200h-byte per Program 00h..P-1 (variable size)
xx20h 200h 16bit VAG Sizes (div8) for VAG 00h..FFh (fixed size)
xx20h (...) ADPCM data (only in .VAB files, otherwise in separate .VB file)
|
000h 1 tones Number of Tones in the Program (Yaroze: 4) (uh?) 001h 1 mvol Master Volume (Yaroze: 0..127) 002h 1 prior (Yaroze: N/A) 003h 1 mode (Yaroze: N/A) 004h 1 mpan Master Panning (Yaroze: 0..127) 005h 1 reserved0 006h 2 attr (Yaroze: N/A) 008h 4 reserved1 00Ch 4 reserved2 |
000h 1 prior Tone Priority (Yaroze: 0..127, 127=highest) 001h 1 mode Mode (Yaroze: 0=Normal, 4=Reverberation) 002h 1 vol Tone Volume (Yaroze: 0..127) 003h 1 pan Tone Panning (Yaroze: 0..127) 004h 1 center Centre note (in semitone units) (Yaroze: 0..127) 005h 1 shift Centre note fine tuning (Yaroze: 0..127) 006h 1 min Note limit minimum value (Yaroze: 0..127) 007h 1 max Note limit maximum value (Yaroze: 0..127) 008h 1 vibW (Yaroze: N/A) 009h 1 vibT (Yaroze: N/A) 00Ah 1 porW (Yaroze: N/A) 00Bh 1 porT (Yaroze: N/A) 00Ch 1 pbmin Max? value for downwards pitchbend (Yaroze: 0..127) 00Dh 1 pbmax Max value for upwards pitchbend (Yaroze: 0..127) 00Eh 1 reserved1 00Fh 1 reserved2 010h 2 ADSR1 Attack,Decay (Yaroze: 0..127,0..15) 012h 2 ADSR2 Release,Sustain (Yaroze: 0..127,0..31) 014h 2 prog Program number that tone belongs to (Yaroze: 0..127) 016h 2 vag VAG number (Yaroze: 0..254) 018h 8 reserved |
| CDROM File Audio Sequences SEQ/SEP (Sony) |
000h 4 File ID "pQES" 004h 4 Version (1) (big endian) 008h 2 Resolution (ticks per quarter note) (TPQN) (01h,80h) 00Ah 3 Tempo (microseconds per quarter note) (big endian) 00Dh 2 Rhythm (NN/NN) (04h,02h) 00Dh 1 Rhythm (Numerator) ;Numerator of time signature (n) 00Eh 1 Rhythm (Denominator) ;Denominator of time signature (2^n) 00Fh ... Score data, uh? (with many MIDI KeyOn's: xx,9x,xx,xx) ... 3 End of SEQ (2Fh=End of Track) (FFh,2Fh,00h) |
000h 4 File ID "pQES" ;same ID as in .SEQ files (!) 004h 2 Version (0) ;value 0, and only 16bit, unlike .SEQ files 006h .. 1st Sequence ... .. 2nd Sequence ... .. etc. |
000h 2 Sequence ID (0000h and up) (big endian) ;-ID number 002h 2 Resolution (ticks per quarter note) (01h,80h) ;\ 004h 3 Tempo (microseconds per quarter note) (07h,27h,0Eh); as in SEQ files 007h 2 Rhythm (NN/NN) (04h,02h) ;/ 009h 4 Data size (big endian, from 00Dh up to including End of SEQ) 00Dh ... Score data, uh? (...) ;\as in SEQ files ... 3 End of SEQ (2Fh=End of Track) (FFh,2Fh,00h) ;/ |
web.archive.org/web/2/loveemu.hatenablog.com/entry/20060630/PSX_SEQ_Format |
| CDROM File Audio Other Formats |
__________________________ .SQ .HD .BD (SSsq/SShd) ___________________________ |
.SQ Sequence Data (with ID "SSsq") .HD Voice Header (with ID "SShd") .BD Voice Binary (raw SPU-ADPCM, same as .VB) |
Alundra 2 Ape Escape Arc the Lad 3 i-mode mo Issho - Doko Demo Issho Tsuika Disc Koukidou Gensou - Gunparade March Omega Boost PoPoLoCrois Monogatari II The Legend of Dragoon Wild Arms 2 |
000h 2 Master Volume (usually 64h) 002h 2 Ticks per quarter note (usually 1E0h) 004h 2 Tempo (varies) 006h 6 Zerofilled 00Ch 4 ID "SSsq" 010h 100h Sixteen Channels (10h*10h bytes) (see below Data Structures) 110h .. MIDI Sequence (terminated by FFh,2Fh,00h) |
000h 4 Size of the .HD file itself 004h 4 Size of the corresponding .BD file 008h 4 Zero 00Ch 4 ID "SShd" 010h 1Ch*4 File List (UNSORTED offsets to File00h..1Bh, or FFFFFFFFh=Unused) 080h .. File Data area (all files are 2-byte aligned) |
000h 2 Number of Instruments, minus 1 (N-1) 002h N*2 Offsets to Instruments (or FFFFh=unused) ... .. Instrument entries |
000h 2 Unused (zero) 002h 80h Volumes for velocity 0..7Fh (usually linear/increasing 0..7Fh) |
000h 2 Number of Breath Controls, minus 1 (N-1)
002h N*2 Offsets to Breath values (or FFFFh=None)
... .. Breath values (whatever pipe/flute blow volume or so?)
maybe with Zeropadding to 2-byte boundary (?)
(or actually, each control is always(?) 40h-byte tall,
so no padding is needed here?)
|
000h 2 Number of Sequence packs, minus 1 (N-1) 002h N*2 Offsets to Sequence packs ... N*var Sequence pack entries (see below, each can have multiple seq's) ... .. MIDI Sequences (each terminated by FFh,2Fh,00h) ... .. Zeropadding to 2-byte boundary |
000h 2 Master volume 002h 0Eh Zerofilled 010h 180h Twentyfour Channels (18h*10h bytes) 190h 2 Number of Instruments, minus 1 (N-1) 192h N*2 Offsets to Instruments (relative to base=190h) ... .. Instrument entries (each may have multiple SFX Tones) |
These are usually/always unused (with Offset=FFFFFFFFh in File List). |
000h .. SPU-ADPCM data (usually starting with zerofilled 10h-byte block) |
000h 1 Unknown (always 0?) 001h 1 Index/ID 002h 1 Program index (from SShd) 003h 1 SSsq volume 004h 1 Pan 005h 4 Unknown (always 0?) 009h 1 Modulation 00Ah 1 Pitch Bend 00Bh 1 Priority 00Ch 1 Breath 00Dh 1 Unknown (maybe sixteenths?) 00Eh 1 Adjusted volume 00Fh 1 Unknown |
000h 2 Number of Sequences in this pack, minus 1 (N-1) 002h N*2 Offsets to MIDI Sequences |
000h 1 Number of Tones, minus 1 (N-1, plus bit7=type) (or FFh=SFX)
(when bit7=1, instrument can play multiple tones on a single cmd)
"(FFh are SFX instruments,
8Xh are instruments, that can play multiple tones on a
single command, (uh, what tones, on what command ?)
otherwise 0, (uh, maybe 0Xh ?),
second nibble is upper bound of notes AKA count - 1)"
001h 1 Volume
002h 1 Pan
003h 1 Unknown/Unused
004h 1 Pitch Bend Multiplier
005h 1 Breath Control Index (in SShd.File02h)
"if there are multiple breath control tables" ;uh, what if not?
006h 1 SFX Starting note ;\only used for SFX,
007h 1 SFX Number of Tones, minus 1 (N-1) ;/ie. when [000h]=FFh
008h N*10h Tone data (with N as specified in entry [000h] or [007h])
|
000h 1 noteMin ;\if a KeyOn is called on a specific program,
001h 1 noteMax ;/notes are selected if they are in range
002h 1 keyRoot ;the offset from the note requested is used to pitch bend
003h 1 sixteenths (flat pitch bend in 1/16 of a semitone)
004h 2 Offset (div8) to SPU-ADPCM data in .BD file
sound bank ptr (*4) ;uh, this is "div 8", not "mul 4" !!!
006h 4 ADSR
00Ah 1 Volume override ("if used", this value "would be << 8" and volume
would "be | onto" the lower bits during volume calculation)
00Bh 1 Volume
00Ch 1 Pan
00Dh 1 Pitch Bend Multiplier
00Eh 1 Breath Control Index
00Fh 1 Tone Flags
|
0 High priority 1 Noise 2-3 ? 4 Pitch Bend "multi" from instrument (=multiplier, multiple?) 5 Modulation on 6 Breath Control index from instrument 7 Reverb on |
____________________________ DNSa/PMSa/FNSa/FMSa _____________________________ |
"DNSa" (aka SouND backwards) ;sequence data "PMSa" (aka SaMPles backwards) ;samples with small header "FMSa" (aka SaMples-F... backwards) ;samples with bigger header ;\Legacy "FNSa" (aka SouNd-F... backwards) ;whatever tiny file ;/of Kain |
Akuji (MagDemo18: AKUJI\BIGFILE.DAT\*) (DNSa,PMSa) Gex 2 (MagDemo08: GEX3D\BIGFILE.DAT\*) (DNSa) Gex 3: Deep Cover Gecko (MagDemo20: G3\BIGFILE.DAT\*) (DNSa,PMSa) Legacy of Kain 2 (MagDemo13: KAIN2\BIGFILE.DAT\*) (DNSa) Legacy of Kain 2 (MagDemo26: KAIN2\BIGFILE.DAT\*) (DNSa,PMSa,FNSa,FMSa) Walt Disney World Racing Tour (MagDemo35: GK\BIGFILE.DAT\*) (DNSa,PMSa) |
000h 4 ID "PMSa" 004h 4 Total Filesize (minus 8) 008h .. SPU-ADPCM data (usually starting with zerofilled 10h-byte block) |
000h 4 ID "DNSa" ;aka SND backwards 004h 2 Offset from DNSa+4 to 8-byte entries (can be odd) 006h 1 Unknown (3) 007h 1 Number of 8-byte entries (N1) 008h 1? Number of 10h-byte entries (N2) ... .. Unknown (..) ... N1*8 Whatever 8-byte entries ... N2*10h Whatever 10h-byte entries ... .. ... circa 40h 4-byte entries...? ... .. Unknown (..) ... .. Several blocks with ID "QESa" or "QSMa" ;supposedly MIDI-style? |
000h 4 ID "FNSa" 004h 2 Always 00h,01h (maybe version) 006h 1 File ID or so (same as in FMSa) 007h 1 Usually 0 or 1 (maybe MSB of above) 008h 2 Zerofilled 00Ah 1 Number of sample IDs (N) 00Bh 09h Zerofilled (may inlcude MSB of above) 014h N*2 Sample IDs (same as in FMSa) ... .. Zeropadding to 4-byte boundary |
000h 4 ID "FMSa" 004h 2 Always 00h,01h (maybe version) 006h 1 File ID or so (same as in FNSa) 007h 1 Usually 0 or 1 (maybe MSB of above) 008h 1 Number of samples (N) 009h 7 Zerofilled (may inlcude MSB of above) 010h N*var Sample block(s) Sample Block format: 000h 2 Sample ID (same as in FNSa) 002h 2 Unknown (varies) 004h 6 Unknown (usually 64h,FFh,7Fh,40h,54h,00h) (volume/panning/etc?) 00Ah 2 Unknown (usually 3C3Ch, or similar with LSB=MSB) 00Ch 1 Unknown (usually 01h or 04h) 00Dh 1 Unknown (usually 0Ch) 00Eh 2 Unknown (usually 870Fh) 010h 2 Unknown (usually 5FC7h or 1FC7h) 012h 2 Zero 014h 4 Size of SPU-ADPCM data in bytes 018h .. SPU-ADPCM data (usually starting with zerofilled 10h-byte block) |
____________________________________ AKAO ____________________________________ |
XXX does that include different AKAO formats... for Samples and Midi? |
___________________________________ Others ___________________________________ |
| CDROM File Audio Streaming XA-ADPCM |
| CDROM File Audio CD-DA Tracks |
| CDROM File Audio MP3/ID3 Tags |
MPEG-1 FFh,Fxh Raw 1991/93 MPEG-2 FFh,Fxh Raw 1995/96 MPEG-2.5 FFh,Exh Raw 2000 ID3v2.2 "ID3",02h Header 1998 ID3v2.3 "ID3",03h Header 1999 ID3v2.4 "ID3",04h Header 2000 Xing VBR "Xing" Bitstream ? Xing CBR "Info" Bitstream ? FhG VBRI "VBRI" Bitstream ? Lame ver "LAME" Bitstream ? Lavc ver "Lavc" Bitstream ? Ancillary "here are".. Bitstream ? ID3v1.0 "TAG" Footer 1996 ID3v1.1 "TAG" Footer 1997 ID3v1.2 "EXT" Footer ? ID3v1+ "TAG+" Footer ? ID3v2.4 "3DI",04h Footer 2000 Lyrics3v1 "LYRICSEND" Footer ? Lyrics3v2 "LYRICS200" Footer 1998 ApeTagv1 "APETAGEX" Footer ? ApeTagv2 "APETAGEX" Footer ? |
________________________________ Header Tags _________________________________ |
000h 3 ID "ID3" ;\ 003h 1 Version (02h..04h) (2=v2.2, 3=v2.3, 4=v2.4) ; 004h 1 Revision (always 00h, there aren't any known revisions) ; Header 005h 1 Flags ; 006h 4 Size of below Chunks/Padding (4x7bit = 28bit) ;/ 00Ah (..) Extended header (usually none such) ... .. Chunks ... .. Padding (00h-filled) ... (10) Optional "3DI" Footer (if Ver=4 and FlagsBit4=1, usually none such) |
ID3v2.2 Chunks: 000h 3 Chunk Name (3-letter ASCII) 003h 3 Chunk Size (3x8bit = 24bit) 006h .. Chunk Data ID3v2.3 Chunks: 000h 4 Chunk Name (4-letter ASCII) 004h 4 Chunk Size (4x8bit = 32bit) 008h 2 Chunk Flags 00Ah .. Chunk Data ID3v2.4 Chunks: 000h 4 Chunk Name (4-letter ASCII) 004h 4 Chunk Size (4x7bit = 28bit) 008h 2 Chunk Flags 00Ah .. Chunk Data |
_______________________________ Bitstream Tags _______________________________ |
000h 4 ID "Xing" 004h 4 Flags (usually 0000000Fh) 008h (4) Number of Frames ;-when FlagsBit0=1 ... (4) Size of all Frames in bytes ;-when FlagsBit1=1 ... (100) Table of contents (seekpoints) ;-when FlagsBit2=1 ... (4) VBR Scale (or LAME quality) ;-when FlagsBit3=1 |
000h 4 ID ("VBRI")
004h 2 Version (0001h) example...
006h 2 Delay as Big-Endian float (16bit float?) 7344
008h 2 Quality indicator 75
00Ah 4 Number of Bytes 45000
00Eh 4 Number of Frames 7344
012h 2 Number of entries within TOC table (N) 100
014h 2 Scale factor of TOC table entries 1
016h 2 Size per table entry in bytes (max 4) (B) 2
018h 2 Frames per table entry 845
01Ah N*B TOC entries for seeking "as Big-Endian integral"
|
________________________________ Footer Tags _________________________________ |
000h 3 ID "TAG" 003h 30 Song name string 021h 30 Artist string 03Fh 30 Album name string 05Dh 4 Year string 061h 30 Comment string 07Fh 1 Genre byte see specification 080h --> 128 total |
000h 3 ID "TAG" ;\ 003h 30 Song name ; 021h 30 Artist ; same as v1.0 03Fh 30 Album name ; 05Dh 4 Year ;/ 061h 28 Comment (max 28 chars) ;\ 07Dh 1 Zero (00h=comment end marker) ; unlike v1.0 07Eh 1 Track Number (01h..xxh) (or 00h=None) ;/ 07Fh 1 Genre ;-same as v1.0 |
000h 3 ID "EXT" 003h 30 Last 30 chars of trackname (30+30 = 60 total) 021h 30 Last 30 chars of artist (30+30 = 60 total) 03Fh 30 Last 30 chars of album (30+30 = 60 total) 05Dh 15 Last 15 chars of comment (28+15 = 43 total) 06Ch 20 Sub genre text (20 total) 080h --> 128 total |
000h 4 ID ("TAG+")
004h 60 Song name
040h 60 Artist name
07Ch 60 Album name
0B8h 1 Speed (01h=slow, 02h=medium, 03h=fast, 04h=hardcore, ?=blank)
0B9h 30 Genre name
0D7h 6 Start time ("mmm:ss")
0DDh 6 End time ("mmm:ss")
0E3h --> 227 total 227 (E3h)
|
000h 11 ID "LYRICSBEGIN" 00Bh .. Lyrics text (max 5100 bytes) ... 9 ID "LYRICSEND" |
000h 11 ID "LYRICSBEGIN" 00Bh SIZ-11 Items (each has 3-byte ID, 5-digit ASCII len, data) ... 6 Size of above (SIZ) (6-digit decimal ASCII) ... 9 ID "LYRICS200" |
000h (32) Ape Header (if any, v2. only) ... .. Ape Items ... 32 Ape Footer |
000h 8 ID "APETAGEX" 008h 4 Version (3E8h=1000=v1.000, 7D0h=2000=v2.000) 00Ch 4 Tag Size in bytes (including footer) (excluding header, if any) 010h 4 Number of Items 014h 4 Global Flags (v2 only) (all zero in v1) (indicates header/footer) 018h 8 Reserved (0) |
000h 4 Item Size (LEN) 004h 4 Item Flags 008h .. Item ID (ASCII, terminated by 00h) .. LEN Item Data (can be text or binary, depending on Item Flags) |
000h 3 Header ID ("ID3")
003h 2 Header Version (04h,00h)
005h 1 Header Flags (with bit4=1=Footer Present)
006h 4 Header Size Entry (4x7bit=28bit)
00Ah .. ID3 chunks/padding (with Size as specified in header/footer)
... 3 Footer ID ("3DI") (aka ID3 spelled backwards)
... 2 Footer Version (04h,00h)
... 1 Footer Flags (with bit4=1=Footer Present)
... 4 Footer Size Entry (4x7bit=28bit)
|
| CDROM File Archives with Filename |
_______________________________ Entrysize=08h ________________________________ |
000h 4 ID ("DPAC") ;\
004h 4 Unknown (100h) ;
008h 4 Number of files (N) ;
00Ch 4 Directory Size (N*8) ; Header
010h 4 File Data area size (SIZE = Totalsize-Headersize) ;
014h 4 Unknown (1) ;
018h 7E8h Zerofilled (padding to 800h-byte boundary) ;
800h N*8 File List ;
... .. Zerofilled (padding to 800h-byte boundary) ;/
... SIZE File Data area ;-Data area
File List entries:
000h 8 Filename ("NAME")
004h 2 File Offset/800h (increasing)
006h 2 File Size/800h
|
_______________________________ Entrysize=10h ________________________________ |
000h N*10h File List (220h bytes)
File List entries:
000h 8 Filename ("FILENAME", if shorter: terminated by 00h plus garbage)
008h 4 Filesize in bytes
00Ch 4 Offset/800h in RESBODY.BIN (increasing) (or FFFFFFFFh if Size=0)
|
000h .. File Data (referenced from RESHEAD.BIN) |
000h N*10h File List ... .. File Data area File List entries: 000h 0Ch Filename (eg. "FILENAME 001") ;for last entry: "END 000" 00Ch 4 Offset (increasing, N*10h and up) ;for last entry: zero |
000h N*10h File List ... 10h End marker (FFh-filled) File List entries: 000h 8 Filename (zeropadded if less than 8 chars) 008h 2 Zero (0000h) 00Ah 2 Size/800h 00Ch 4 Offset/800h in MCD.IMG Note: Filenames are truncated to 8 chars (eg. "FOREST.T" instead "FOREST.TIM") |
000h .. File Data area (encrypted in True Love Story 2) |
init_key_by_filename(name): ;for MCD.IMG (using filenames from MCD.DIR)
i=0, key0=0001h, key1=0001h, key2=0001h
while i<8 and name[i]<>00h
key0=(key0 XOR name[i])
key1=(key1 * name[i]) AND FFFFh
key2=(key2 + name[i]) AND FFFFh
ret
init_key_by_numeric_32bit_seed(seed): ;maybe for LINEAR.IMG and PICT.IMG ?
key0=(seed) AND FFFFh
key1=(seed - (seed*77975B9h/400000000h)*89h) AND FFFFh
key2=(seed - (seed*9A1F7E9h/20000000000h)*3527h) AND FFFFh
ret
decrypt_data(addr,len):
for i=1 to len/2
key2=key2/2 + (key0 AND 1)*8000h
key0=key0/2 + (key1 AND 1)*8000h
key1=key1/2 + ((key1/2 OR key0) AND 1)*8000h
key0=((((key1+47h) AND FFFFh)/4) XOR key0)+key2+(((key1+47h)/2) AND 1)
halfword[addr]=halfword[addr] XOR key0, addr=addr+2
ret
|
Item Unencrypted Encrypted Parent Folder name "TLS" "TLS2" First name in MCD.DIR "BACKTILE" "TEST.RPS" First word in MCD.IMG 00000010h 074D4C8Ah |
000h N*10h File List ... (4) CRC32 on above header (Top-level only, not in Nested archives) ... .. File Data area ... (..) Huge optional padding to xx000h-byte boundary (in BallBlazer .DAT) File List entries in Top-level archives (with [0Ch].bit31=1): 000h 8 Filename (zeropadded if less than 8 chars) 008h 4 Decompressed Size (or 0=File isn't compressed) 00Ch 4 Offset, self-relative from current List entry (plus bit31=1) File List entries in Nested archives (with [0Ch].bit31=0): 000h 0Ch Filename (zeropadded if less than 12 chars) 00Ch 4 Offset, self-relative from current List entry (plus bit31=0) Last File List entry has [00h..0Bh]=zerofilled, and Offset to end of file. |
000h .. Uncompressed Data ... .. CRC32 on above Data (Top-level only, not in Nested archives) |
000h 1 Compression Method (01h=LZ/16bit, 02h=LZ/24bit) 001h 3 Decompressed Size (big-endian) 004h .. Compressed Data ... .. Zeropadding to 4-byte boundary ... .. CRC32 on above bytes (method, size, compressed data, padding) |
000h N*10h File List ... .. Zeropadding to 2000h 2000h .. File Data area (includes TIMs, TMDs, and compressed TIMs) File List entries: 000h 0Ch Filename (zeropadded if less than 12 chars) 00Ch 4 Offset (absolute offset, increasing, 4-byte aligned) |
if [000Ch]=2000h AND [1FFCh]=0 then VampireHunterD_with_AbsoluteOffsets |
_______________________________ Entrysize=14h ________________________________ |
000h 4 Number of files (big endian) 004h N*14h File List ... .. File Data |
000h 0Ch Filename ("FILENAME.EXT", zeropadded if shorter than 12 chars)
00Ch 4 Filesize in bytes (can be odd) (big endian)
010h 4 Fileoffset in bytes (increasing, 4-byte aligned) (big endian)
|
0000h 2000h Folder 1 2000h .. File Data for Folder 1 ... 2000h Folder 2 ... .. File Data for Folder 2 ... 2000h Folder End marker (FFFFFFFFh, plus zeropadding) |
0000h 4 Folder ID (increasing, 1,2,3, or FFFFFFFFh=End) 0004h 4 Number of files (max 198h) (N) 0008h 4 File Data Area size/800h (S) 000Ch 4 Zero (0) 0010h N*14h File List ... .. Zeropadding to 2000h 2000h S*800h File Data Area for this folder |
000h 4 Filesize in bytes 004h 10h Filename (FILENAME.EXT, zeropadded) |
000h 4 Number of Files (eg. 26h) (usually at least 02h or higher)
004h N*14h File List
... .. File Data area
File List entries:
000h 10h Filename ("FILENAME.EXT", zeropadded if shorter)
010h 4 Offset in bytes (increasing, 4-byte-aligned?)
|
000h 4 Number of Files
004h N*14h File List
... .. Zeropadding to 800h-byte boundary
... .. Files (each with appended 800h bytes with checksum/whatever?)
File List entries:
000h 0Ch Filename ("FILENAME.EXT", zeropadded if shorter)
00Ch 4 Filesize (in bytes, usually a multiple of 800h)
010h 4 Offset (in bytes, increasing, usually 800h-byte aligned)
Files:
000h ... Filedata (with size as in File List)
... 1 LSB of checksum (all bytes in Filedata added together)
... 3 Unknown (more checksum bytes? but isn't a simple sum of bytes)
... 7FCh Zeropadding to 800h-byte boundary
|
DIR: 000h 4 Number of Entries (0Eh) 004h N*14h File List DAT: 000h .. File Data (referenced from CROCII.DIR) |
000h 0Ch Filename ("FILENAME.EXT", zeropadded if shorter)
00Ch 4 File Size in bytes
010h 4 File Offset in .DAT file (800h-byte aligned, increasing)
|
000h N*14h File List
... 14h Zerofilled (File List end marker)
... .. File Data area
File List entries:
000h 0Ch Filename ("FILENAME.EXT", zeropadded if shorter)
00Ch 4 Offset (increasing, 4-byte aligned)
010h 4 Filesize in bytes (can be odd, eg. for .FA2 files)
|
000h N*14h File List (3Ch*14b bytes, unused entries are zeropadded)
4B0h .. Data area (TIM files for player uniforms)
File List entries:
000h 10h Filename ("FILENAME.EXT", zeropadded)
010h 4 Offset (zerobased, from begin of Data area, increasing)
|
_______________________________ Entrysize=18h ________________________________ |
000h 0Ch Fixed ID (always "KotJCo01Dir ") (always that same string) 00Ch 4 Number of Files 010h N*18h File List ... .. File Data area |
000h 10h Filename ("FILENAME.EXT", zeropadded)
010h 4 Offset in bytes (increasing, 1-byte or 4-byte aligned)
014h 4 Filesize in bytes (can be odd)
|
000h N*18h File List (18h-bytes each) ... 18h File List end marker (zerofilled) ... .. File Data |
000h 1 Filename Checksum (sum of bytes at [001h..00Dh])
001h 1 Filename Length (excluding ending zeroes) (eg. 8, 9, 10, 12)
002h 0Ch Filename ("FILENAME.EXT", zeropadded if less than 12 chars)
00Eh 2 Unknown (2000h) (maybe attr and/or ending zero for filename)
010h 4 Filesize in bytes (can be odd)
014h 4 Offset (increasing, 4-byte aligned)
|
000h 4 Header Size in bytes (2800h) (can be MUCH bigger than needed) 004h 4 Zero 008h 4 ID "Indx" 00Ch 4 Zero 010h 4 Number of Files (N) (CEh) (can be zero=empty in .IDX files) 014h 4 Header Size/800h (05h) 018h 4 Zero 01Ch 4 Zero 020h N*18h File List ... .. Zeropadding to end of Headersize ... .. File Data area |
000h 0Ch Filename ("FILENAME.EXT", zeropadded if shorter)
00Ch 4 Offset/800h
010h 4 File Size/800h
014h 4 File Size in bytes
|
IDX files use the same File List entry format as LVL, but the offsets
seem to refer to an external file with corresponding name, for example:
cdrom:\ABE2\CR.LVL\CR.IDX ;directory info
cdrom:\ABE2\CR.MOV ;external data (the .MOV being a .STR video)
XXX: That's not tested/verified, and not implemented in no$psx file viewer.
|
000h 4 Unknown (6) 004h 4 Total Filesize (1403800h) 008h 2 Unknown, Alignment? (800h) 00Ah 2 Number of Files, excluding zerofilled File List entries (ACh) 00Ch 4 Header Size (1800h) 010h 4 Unknown, Entrysize? (18h) 014h 4 Unknown, Entrysize? (18h) 018h N*18h File List (can contain unused zerofilled entries here and there!) ... .. File Data area |
000h 10h Filename ("FILENAME.EXT", zeropadded)
010h 4 File Offset in bytes (800h-byte aligned, unusorted/not increasing)
014h 4 File Size in bytes
|
000h 4 ID "KGB",00h 004h 4 Number of Files (N) 008h (4) Number of Files negated (-N) ;<-- optional, not in LITESHOW.KGB ... N*18h File List ... (..) CBh-padding to alignment boundary (only if align=800h) ... .. File Data area |
000h 10h Filename ("FILENAME.EXT", terminated by 00h, padded with CDh)
010h 4 File Size in bytes
014h 4 File Offset (800h-byte or 1/4-byte? aligned)
|
000h 4 Unknown (80000001h) 004h 4 Offset/800h to Final Padding area 008h 8 Zerofilled 010h N*18h File List ... (..) CDh-padding to 800h-byte alignment boundary ... .. File Data area ... 800h Some text string talking about "last-sector bug" ... 40BEh Final Padding area (CDh-filled) |
000h 10h Filename ("FILENAME.EXT", terminated by 00h, padded with CDh)
010h 4 File Offset/800h (increasing)
014h 4 File Size/800h
|
000h 0Fh ID ("Art", zeropadded) ;\
00Fh 1 Type or so ("?") ; sorts of File List entry
010h 4 Number of entries plus 1 (N+1) ; for root folder
014h 4 Total Size in bytes (can be odd) ;/
018h N*18h File List
... ... File Data area
File List entries:
000h 0Fh Filename ("FILENAME", zeropadded)
00Fh 1 Type/extension or so ("X" or "D")
010h 4 File Offset (unaligned, increasing)
014h 4 File Size in bytes (can be odd)
|
000h 4 Unknown (301h)
004h 4 Zero (0)
008h 4 Number of files (N)
00Ch N*18h File List
... .. Zeropadding to 800h-byte boundary
... .. File Data area
File List entries:
000h 4 Offset (800h-byte aligned, increasing)
004h 4 Filesize in bytes
008h 1 Unknown (01h)
009h 0Fh Filename ("FILENAME.EXT",00h, plus garbage padding)
|
Texsize is 6900Eh, but should be 6900Ch = 200h*1A4h*2+0Ch Filesize is 6A000h, but should be 69014h = 200h*1A4h*2+14h |
000h 2 Number of Files (C9h)
002h N*18h File List
... (..) Padding to 800h-byte boundary (if any, eg. in MOVIES.LIB)
... .. File data area (800h-byte aligned, or unaligned)
File List entries:
000h 4 Filesize in bytes
004h 4 Offset (increasing, 800h-byte aligned, or unaligned)
008h 10h Filename ("filename.ext", zeropadded)
|
000h 4 ID "DCAT"
004h 4 Number of Entries
008h N*18h File List
... .. Zerofilled (padding to 800h-byte boundary)
... .. File Data area
File List entries:
000h 10h Filename ("FILENAME.EXT", terminated by 00h, plus garbage padding)
010h 4 Filesize in bytes
014h 4 Offset (increasing, 800h-byte aligned)
|
000h 4 ID "FRID"
004h 4 Always E0000000h
008h 4 Always 800h (...maybe alignment)
00Ch 4 Number of Entries (N)
010h 4 Header Size (N*18h+20h, plus padding to 800h-byte boundary)
014h 4 Always 18h (...maybe entry size)
018h 8 Zerofilled
020h N*18h File List
... .. Zerofilled (padding to 800h-byte boundary)
... .. File Data area
File List entries:
000h 0Ch Filename ("FILENAME.EXT", zeropadded if shorter)
00Ch 4 Offset (increasing, 800h-byte aligned)
010h 4 Filesize in bytes
014h 4 Unknown (checksum? random?)
|
000h N*18h File List
... .. File Data area (directly after File List, without end-code)
Note: There is no file-list end-marker (instead, the Offset in 1st File
entry does imply the end of File List).
File List entries:
000h 10h Filename ("FILENAME.EXT", zeropadded)
010h 4 Offset (increasing, 4-byte aligned, or unaligned for TXT files)
014h 4 Filesize in bytes (or weird nonsense in SFX.MAD)
|
SFX.MAD has nonsense Filesize entries (eg. 164h for a 15150h-byte file). FACES.MAD contains only one TIM file... but as 3Mbyte junk appended? RINKS.MAD and TEAMS.MAD start with 0Dh,0Ah,1Ah followed by 4Mbyte junk. MISCFILE.MAD contains several nested .mad files. MISCFILE.MAD\panfont.mad\*.txt --> starts with FF,FE --> that's 16bit Unicode? |
INF: 000h N*18h File List WAD: 000h .. File Data area |
000h 4 File Offset/800h in .WAD file
004h 4 File Size in bytes
008h 10h Filename ("FILENAME.EXT", zeropadded)
|
000h 4 Number of entries (N)
004h N*18h File List
... .. Zeropadding to 800h-byte boundary
... .. File Data area
File List entries:
000h 10h Filename ("FILENAME.EXT", zeropadded)
010h 4 Fileoffset (800h-byte aligned, increasing)
014h 4 Filesize in bytes
|
000h 2 Type (31h=TPF with TIMs, 32=PPF with PMDs)
002h 2 Number of entries (N) (can be 0=None, eg. STAGE*\MORT.PPF)
004h 4 File List Size (N*18h)
008h 4 Header Size (always 14h)
00Ch 4 Data area Size (Filesize-14h-N*18h)
010h 4 Data area Offset (14h+N*18h)
014h N*18h File List
... .. File Data area
File List entries:
000h 10h Filename ("FILENAME.EXT", zeropadded)
010h 4 Filesize in bytes
014h 4 Fileoffset (from begin of Data area, increasing)
|
000h 4 ID "BACR" (aka RCAB backwards)
004h 4 Number of entries (N)
008h N*18h File List
... .. File Data area
File List entries:
000h 10h Filename ("FILENAME.EXT", zeropadded)
020h 4 Offset (from begin of Data area, increasing, 4-byte aligned)
024h 4 Filesize in bytes (can be odd)
|
_______________________________ Entrysize=19h ________________________________ |
000h 2 Number of files 002h N*19h Directory Entries for all files ... .. Data for all files (without any alignment, in same order as above) |
000h 10h Filename (ASCII, can be lowercase), terminated by 00h, plus garbage 010h 4 Filesize in bytes ;\maybe compressed/uncompressed, or rounded, 014h 4 Filesize in bytes ;/always both same 018h 1 Unknown (always 00h) |
_______________________________ Entrysize=1Ch ________________________________ |
000h 4 Number of entries with location 0=MIX (M=65h) 000h 4 Number of entries with location 1=XA (X=1) 008h M*1Ch File List for location 0=MIX ... X*1Ch File List for location 1=XA |
000h 10h Filename (terminated by 00h, padded with garbage) 010h 4 Offset/800h in DATA.MIX or Offset/930h DATA.XA file (increasing) 014h 4 Filesize in bytes 018h 4 File Location (0=DATA.MIX, 1=DATA.XA) |
000h 4 Unknown (80000001h) 004h 4 Offset/800h to Final Padding area 008h 8 Zerofilled 010h N*1Ch File List ... (..) CDh-padding to 800h-byte alignment boundary ... .. File Data area ... 3394h Final Padding area (CDh-filled) |
000h 14h Filename ("FILENAME.EXT", terminated by 00h, padded with CDh)
014h 4 File Offset/800h (increasing)
018h 4 File Size/800h
|
v1 (Syphon Filter 1) has filename_len=10h (and filelist_entrysize=18h) v2 (Syphon Filter 2) has filename_len=14h (and filelist_entrysize=1Ch) |
_______________________________ Entrysize=20h ________________________________ |
000h 4 Number of Files 004h N*20h File List ... 10h File List End: Name (zerofilled) ... 4 File List End: Offset (total filesize, aka end of last file) ... 0Ch File List End: Padding (zerofilled) ... .. File Data area |
000h 10h Filename ("FILENAME.EXT", terminated by 00h, padded with garbage)
010h 4 File Offset in bytes (increasing, 4-byte aligned)
014h 0Ch Padding (garbage) (usually 800F68A0h,800F68A0h,800F68A0h)
|
000h 4 Number of Files (1C3h) 004h N*20h File List ... .. Zeropadding to 800h-byte boundary ... .. File Data area |
000h 10h Filename ("FILENAME.EXT", zeropadded, sorted alphabetically)
010h 4 File Offset/800h (unsorted, not increasing)
014h 4 File Size in bytes
018h 4 File Size/800h
01Ch 4 Zero
|
000h 4 Number of Files (N)
004h 0Ch Zerofilled
010h N*20h File List
... .. File Data area
File List entries:
000h 14h Filename ("PATH\FILENAME.EXT", zeropadded)
014h 4 Filesize in bytes
018h 4 File Offset (increasing, 10h-byte aligned)
01Ch 4 Zerofilled
|
000h N*20h File List ... 4 File List End Offset/800h (end of last file) ... 4 File List End Size (zero) ... 18h File List End Name (zerofilled) ... .. Padding to 800h-byte boundary (each 20h-byte: 01h, and 1Fh zeroes) ... .. File Data |
000h 4 Offset/800h (increasing)
004h 4 Filesize in bytes
008h 18h Filename ("FILENAME.EXT" or ":NAME" or ":NAME:NAME", zeropadded)
|
000h N*20h File List (1920h bytes used; with padding: 5800h bytes in total)
... .. Zeropadding to Headersize (5800h)
... .. File Data area
File List entries:
000h 18h Filename ("FILENAME.EXT" or "PATH\FILENAME.EXT", zeropadded)
018h 4 Filesize in bytes
01Ch 4 File (Offset-Headersize)/800h
|
000h 4 ID ("TDSK") ;\
004h 4 Number of Files (1Bh) ; Directory
008h N*20h File List ;/
... 4 1st File Size (same as Size entry in File List) ;\File Data area
... .. 1st File Data ; (each file os
... 4 2nd File Size (same as Size entry in File List) ; preceeded by
... .. 2nd File Data ; a size entry)
... .. etc. ;/
File List entries:
000h 10h Filename ("FILENAME.EXT", zeropadded)
010h 4 File Size in bytes
014h 4 Unknown (35xxxxxxh..372xxxxxh)
018h 4 Unknown (3724xxxxh) (Timestamp maybe?)
01Ch 4 File Offset in bytes (increasing, 4-byte aligned)
|
000h N*20h File List (B60h bytes)
... .. Zeropadding to 800h-byte boundary
... .. File Data area (files are AAh-padded to 800h-byte boundary)
File List entries:
000h 4 Filesize in bytes
004h 2 File Offset/800h (16bit) (increasing)
006h 1Ah Filename ("FILENAME.EXT" or "PATH\FILENAME.EXT", zeropadded)
|
000h 2 Zero (0000h) 002h 2 Number of Files (N) 004h 4 Data Base (N*20h+10h) 008h 4 Unknown (20h) ;-maybe File List entry size? 00Ch 2 Unknown (10h) ;\maybe filename length and/or header size? 00Eh 2 Unknown (10h) ;/ 010h N*20h File List ... .. File Data area |
000h 4 Zero
004h 4 File Offset (increasing, 4-byte aligned, relative to Data Base)
008h 4 File Size in bytes (can be odd)
00Ch 4 Zero
010h 10h Filename ("FILENAME.EXT", zeropadded)
|
WAD:
000h N*20h File List
STR:
000h .. File Data (MagDemo39: 4.5Mbyte, MagDemo48: compressed/2.8Mbyte)
File List entries:
000h 14h Filename ("FILENAME.EXT", zeropadded)
014h 4 Offset in bytes, 4-byte aligned, in STR file
018h 4 Filesize, compressed (always rounded to multiple of 4 bytes)
01Ch 4 Filesize, decompressed (zero when not compressed)
|
- end flag is processed immediately (instead of after the block) - blocktype is only 1bit wide (instead of 2bit) - stored blocks have plain 16bit len (without additional 16bit inverse len) |
bmx_tinf_style_uncompress(dst,src)
tinf_init() ;init constants (needed to be done only once)
@@lop:
if tinf_getbit()=0 then goto @@done ;end flag, 1bit
if tinf_getbit()=0 then ;blocktype, 1bit
tinf_align_src_to_byte_boundary()
len=LittleEndian16bit[src], src=src+2 ;get len (without inverse len)
for i=0 to len-1, [dst]=[src], dst=dst+1, src=src+1, next i ;uncompressed
else
tinf_decode_dynamic_trees(), tinf_inflate_compressed_block() ;compressed
gpto @@lop
@@done:
ret
|
_______________________________ Entrysize=28h ________________________________ |
000h 4 Number of entries (eg. 20h or 28h) 004h N*28h File List ... .. Garbage padding to 800h-byte boundary ... .. File Data ... .. Huge zeropadding to 200000h or 2EE000h (2048Kbyte or 3000Kbyte) |
000h 20h Filename (terminated by 00h, padded with... looks like garbage) 020h 4 Size/800h 024h 4 Offset/800h (increasing) |
000h N*28h File List (less than 0C00h bytes used in TD4 demo) ... .. Zeropadding to Headersize (2000h or 3000h or 5000h) ... .. File Data |
000h 20h Filename ("PATH\FILENAME.EXT", zeropadded)
020h 4 Size in bytes
024h 4 (Offset-Headersize)/800h (increasing)
|
0000h N*28h File List 21C0h ... Unknown random gibberish? (23h,E8h,0Ch,1Dh,79h,C5h,24h,...) 4000h ... File Data area |
000h 1Ch Filename ("\PATH\FILENAME.EXT;0", zeropadded)
01Ch 4 Filesize in bytes
020h 4 Fileoffset in bytes (4000h and up, increasing)
024h 4 Filechecksum (32bit sum of all bytes in the file)
|
000h 4 ID "BIND" 004h 4 Number of files (N) 008h N*28h File List ... .. File Data area |
000h 20h Filename ("\FILENAME.EXT", zeropadded)
020h 4 File Offset (increasing, 4-byte aligned) ;\see note
024h 4 File Size in bytes (always a multiple of 4) ;/
|
size=((filesize+3) AND not 3) ;size entry for curr file (plus 3) offs=((filesize+4) AND not 3)+offs ;offs entry for next file (plus 4 !!!) |
000h 4 Number of entries (N)
004h 4 Number of entries (same as above)
008h 4 Number of entries (same as above)
00Ch 4 Number of entries (same as above)
010h N*28 File List
... .. Zeropadding to 800h-byte boundary
... .. File Data area
File List entries:
000h 20h Filename ("\PATH\FILENAME.EXT", zeropadded)
020h 4 Offset/800h, from begin of Data area (increasing)
024h 4 Filesize in bytes
|
_______________________________ Entrysize=34h ________________________________ |
000h 4 Number of Files
004h N*34h File List
... .. Zeropadding to 4000h
4000h .. File Data area
File List entries:
000h 10h Filename ("FILENAME.EXT", zeropadded)
010h 4 Filesize in bytes ;\always both same, always
014h 4 Filesize in bytes ;/both multiple of 800h
018h 4 Zero
01Ch 4 Type (07h..1Ah)
020h 4 Subtype (00h..01h)
024h 10h Zero
|
07h.0 .TIM (*.TIM) 07h.01h .TIM (HUD_*.TIM) 08h.0 .TIM (PSTART.TIM) 09h.0 .TIM (FONT.TIM) 0Ah.0 .SFX 0Eh.0 .MBL 10h.0 .ATR 11h.0 .RLC 13h.0 .AST 15h.0 .SCD 16h.0 .TXT (PAUSED.TXT) 17h.0 .TXT (OBJECT*.TXT) 18h.0 .BIN 1Ah.0 Misc (.3DO=TIM, .V=TXT, and TERRAIN.CLP .HI .LIT .MAP .PAT .POB .TER) |
_______________________________ Entrysize=40h ________________________________ |
000h 4 Number of Files (N)
004h N*40h File List
... .. File Data area
... .. Padding to 4-byte boundary
File List entries:
000h 4 Fileoffset (increasing, 4-byte aligned)
004h 4 Filesize (in bytes, can be odd)
008h 38h Filename ("FILENAME.EXT", zeropadded) (usually max 12 chars)
|
000h 4 Number of Files (N) 004h 4 Size of File Data area (SIZ) (total filesize-8-N*40h) 008h N*40h File List ... SIZ File Data area File List entries: 000h 4 Filesize in bytes 004h 4 Fileoffset in bytes (zerobased, from begin of File Data area) 008h 38h Filename, zeropadded |
000h 4 ID ("GLUE")
004h 4 Unknown (always 400h)
008h 4 Number of Files (N)
00Ch 4 Header Size (40h+N*40h)
010h 30h Zerofilled
040h N*40h File List
... .. Garbage padding to alignment boundary
... .. File Data area
File List entries:
000h 20h Filename ("FILENAME.EXT", zeropadded)
020h 4 File Offset in bytes (increasing, 800h-byte aligned)
024h 4 File Size in bytes
028h 2 File ID Number 1 (eg. 1-71 for C01.GLU-C71.GLU)
02Ah 2 Unknown (random, checksum, ?)
02Ch 4 File ID Number 2 (eg. increasing: 1, 2, 3)
030h 10h Zerofilled
|
000h 4 ID ("NAR",00h)
004h 4 Unknown (40h) ;maybe File List entry size?
008h 4 Header Size (10h+N*40h)
00Ch 4 Number of Files (N) (min=1)
010h N*40h File List
... .. File Data area
File List entries:
000h 4 File ID (increasing)
004h 4 Offset (increasing, 4-byte aligned)
008h 4 Filesize in bytes (can be odd)
00Ch 4 Filetype (ASCII, usually same as file extension, in lowercase)
010h 4 Unknown (looks like timestamp?)
014h 2Ch Filename ("FILENAME.EXT", zeropadded)
|
000h N*40h File List ... .. Zeropadding (usually to offset 2000h) ... .. Data ... .. Zeropadding (to 800h-byte boundary) File List entries: 000h 4 Size in bytes 004h 4 Offset in bytes (increasing, 800h-byte aligned) 008h 4 Checksum (sum of all data bytes) 00Ch 4 Zero 010h 30h Filename (ASCII, without extension, zeropadded) |
_______________________________ Entrysize=60h ________________________________ |
000h 4 Number of entries (N)
010h N*60h File List
... .. Zeropadding to 2000h
2000h .. File Data area
File List entries:
000h 4 Timestamp? (BFxxxxh..C0xxxxh) (or zero, in first file)
004h 4 Unknown (always 421C91h)
008h 4 Unknown (200h or 60200h)
00Ch 4 Filesize (uncompressed)
010h 4 Filesize (compressed, or 0 when not compressed)
014h 4 File Checksum (sum of all bytes in uncompressed file data)
018h 4 Unknown (random 32bit value?)
01Ch 10h Filename ("FILENAME.EXT", zeropadded)
02Ch 4 Zerofilled
030h 4 Unknown (0 or 1 or 8)
034h 4 File Type (see below)
038h 8 Zerofilled
040h 4 Offset MSBs (Fileoffset-2000h)/800h ;\increasing, 4-byte aligned
044h 4 Offset LSBs (Fileoffset AND 7FFh) ;/(or zero when filesize=0)
048h 18h Zerofilled
|
_______________________________ Entrysize=90h ________________________________ |
000h 4 ID (A69AA69Ah)
004h 4 Number of files (N)
008h N*90h File List
... .. File Data area
File List entries:
000h 80h Filename ("DATA\FILENAME.EXT",00h, plus CDh-padding)
080h 4 File Offset in bytes (increasing, 4-byte aligned)
084h 4 File Size in bytes
088h 8 Unknown (random/checksum?)
|
_____________________________ Variable Entrysize _____________________________ |
Used by Spider-Man (MagDemo31,40: SPIDEY\CD.HED and CD.WAD) Used by Spider-Man 2 (MagDemo52: SPIDEY\CD.HED and CD.WAD) Used by Tony Hawk's Pro Skater (MagDemo22: PROSKATE\CD.HED and CD.WAD) Used by Apocalypse (MagDemo16: APOC\CD.HED and CD.WAD) ;with PADBUG Used by MDK (Jampack Vol. 1: MDK\CD.HED and CD.WAD) ;without ENDCODE Used by Mat Hoffman's Pro BMX (old demo) (MagDemo39: BMX\BMXCD.HED+WAD) |
000h .. File Entries (see below) ... (1) End code (FFh) (if any, not present in MDK) |
000h .. Filename (ASCII, terminated by 00h, zeropadded to 4-byte boundary) ... 4 Offset in CD.WAD (in bytes, usually 800h-byte aligned) ... 4 Filesize (in bytes) |
000h 4 Number of Files (N) (1ADh) 004h 4 Unknown (7) (maybe HeaderSize/800h, same as first Offset/800h ?) 008h 4 Unknown (1430h = 14h+N*0Ch, same as first Name pointer) 00Ch 4 Unknown (1430h = 14h+N*0Ch, same as first Name pointer) 010h 4 Unknown (1430h = 14h+N*0Ch, same as first Name pointer) 014h N*4 Name List (pointers to name strings, 1430h and up) 6B4h bytes ... N*4 Size List (filesize in bytes) 6B4h bytes ... N*4 Offset List (Offset/800h) 6B4h bytes ... N*var Name Strings (ASCII strings, "folder\filename.ext",00h) ... .. Zerofilled (padding to 800h-byte boundary) ... .. File Data area |
000h 4 Number of Files (N)
004h N*8 File List (2x32bit entries: Offset, Size) (unaligned, can be odd)
... N*4 File Name Offsets
... N*var File Name Strings ("FILE NN",0Ah,00h)
... .. Garbage-padding to 4-byte boundary
... (4) Optional extra garbage? ("MON " in ATLANTFI.PAK, MARSFI.PAK, etc.)
... .. File Data area (ZLIB compressed, starting with big-endian 789Ch)
|
000h 4 ID (12h,34h,56h,78h) (aka 12345678h in big endian) 004h 4 Header Size (offset to File Data area) 008h 4 Number of Entries (can be 0=None, eg. LEVELS\LARGO07.DCF\Z16.CAT) 00Ch N*var Name List (Filenames in form "FILENAME.EXT",00h) ... .. Zeropadding to 4-byte boundary ... N*4 Size List (Filesizes in bytes) ... .. File Data area |
000h 4 Number of files (N) (3..EBh) (big-endian) 004h N*Var File List (list size is implied in first file offset) ... .. Zeropadding to 800h-byte boundary ... .. File Data area File List entries: 000h 4 File Type (ascii, .LLN .TXI .TPG .RCI .RCP .WDB .PCI .PCP .BLK) 004h 4 File Size (can be odd) (big-endian) 008h 4 File Offset (increasing, 800h-byte aligned) (big-endian) 00Ch 4 Extra Size (0 or 4 or 8) (big-endian) 010h .. Extra Data (if any) (32bit number, or "TEXTURES") |
000h 4 Timestamp? (36xxxxxxh=v1?, 38xxxxxxh=v2?, other=SLF.RFF) 004h 4 Number of Files (N) 008h 4 Base for Offset List (always 14h) 00Ch 4 Base for String Table (v1=N*4+14h, or v2=N*4+18h) 010h 4 Base for File Data (end of String Table plus align 4/800h/920h) 014h N*4 Offsets to File(s) (increasing, first=0, relative to above [010h]) ... (4) v2 only: End Offset for Last File (HOG filesize minus [010h]) ... .. String Table (filename list in form of "FILENAME.EXT",00h) ... .. Zeropadding to 4-byte or 800h-byte boundary ... .. File Data area |
v1 has [0Ch]=N*4+14h (without end-of-last-file entry; use end=total_size) v2 has [0Ch]=N*4+18h (and does have end-of-last-file entry) v1 has STR files in ISO filesystem (not in HOG archives) v2 has STR files in MOVIES.HOG (with [10h]=920h and [14h and up]=sectors) |
v1/v2 has [10h]=data base, aligned to 4 or 800h v1/v2 has [14h and up] in BYTE-offsets, relative to base=[10h] v1/v2 uses HOG format in .HOG files also in SLF.RFF v1/v2 has further .RFF files (but that aren't in HOG format) |
v2 MOVIE.HOG has [10h]=920h (which is meant to mean base="after 1st sector") v2 MOVIE.HOG has [14h and up] in SECTOR-units, with base="after 1st sector" v2 SLF.RFF does contain two HOG archives badged together (plus final padding) v2 has some empty 0-byte .HOG files (at least so in demo version) |
000h 4 ID "BIGF" (normal case, all big-endian, 4-byte aligned) ;\
ID "BIGH" (with [04h]=little-endian instead big-endian) ;
ID "BIG4" (with 40h-byte alignment padding instead 4-byte) ;
004h 4 Sum of Header+Filesizes (excluding Padding's!) (big-endian) ; Header
008h 4 Number of entries (N) ;11h (big-endian) ;
00Ch 4 Size of Header (including File List) ;11Fh (big-endian) ;
010h .. File List ;/
... .. Padding to 1/4/8-byte boundary (optional, before each file) ;\Data ... .. File Data ;/
|
000h 4 Offset in bytes (increasing, often 4/8-byte aligned) (big-endian)
004h 4 Size in bytes (can be odd, but often rounded to 4-byte) (big-endian)
008h .. Filename (ASCII, terminated by 00h) ;variable length
Note: Filenames can be empty ("",00h) (eg. in WCWDEMO\ZSOUND.BIG)
|
http://wiki.xentax.com/index.php/EA_BIG_BIGF_Archive |
https://wiki.multimedia.cx/index.php/Electronic_Arts_Formats_(2) - BNK etc |
000h 2 ID C0FBh (C0h,FBh) (big-endian) ;\ 002h 2 Size of Header-4 (00h,15h) (big-endian) ; Header 004h 2 Number of Files (00h,01h) (big-endian) ; 006h .. File List ;/ 019h .. Padding to 4-byte boundary? ;-Padding 01Ch .. File Data ;-Data ... 4 "CRCF" ;\ ... 4 Unknown (0C,00,00,00) (chunk-size little-endian?) ; Footer ... 4 Unknown (3B,2E,00,00) (checksum maybe?) ;/ |
000h 3 Offset in bytes (increasing) ;(big-endian, 24bit) 004h 3 Size in bytes ;(big-endian, 24bit) 008h .. Filename (ASCII, terminated by 00h) ;variable length |
PTH File: 000h N*var File List DAT File: 000h .. File Data area |
000h .. Filename ("FILENAME.EXT",00h) (variable length)
... 4 File Size in bytes (can be odd)
... 4 File Offset in bytes in DAT file (increasing, unaligned)
|
TOC: 000h N*var File List IMG: 000h .. File Data area |
000h .. Filename ("DATA\FILENAME.EXT",00h) (variable length)
... 4 File Offset (increasing, 800h-byte aligned, in .IMG file)
... 4 File Size in bytes
|
TGA[10h..11h] = 08h,08h ;bpp=8 (okay) and attr=8 (nonsense) TGA[10h..11h] = 10h,01h ;bpp=16 (okay) and attr=1 (okay) but it's yflipped |
| CDROM File Archives with Offset and Size |
000h 4 Zero 004h 4 Number of Files (260h) 010h N*8 File entries ... .. Zeropadding to 800h byte boundary ... .. File Data |
000h 4 Fileoffset/800h (increasing) 004h 4 Filesize in bytes |
MDEC v2 STR's (file 1E1h..1F8h,1FAh) TIM textures (file 01FBh..0200h and others) empty files (file 01F9h and others) small archives with named entries (file B5h,124h,125h,126h and others) stuff with date string and names (file 253h,256h) there seem to be no nested BIG files inside of the main BIG file |
000h 4 Number of files (N) (eg. 196h) 004h 4 Unknown (always 0Bh) (maybe sector size shift?) 008h N*4 File List ... .. Zeropadding to 800h-byte boudary ... .. File Data |
000h 2 Offset/800h (increasing) 002h 2 Size/800h (can be zero) |
000h N*4 File List ... .. Zeropadding to 800h-byte boundary ... .. File Data area File List entries: 000h 1 Size/800h (8bit) 001h 3 Offset/800h (24bit, increasing) |
000h N*8 File List ... .. Zeropadding to 800h-byte boundary ... .. File Data ... .. Garbage padding (can be several megabytes tall) |
000h 2 Offset/800h (increasing) 002h 2 Size/800h (same as below, rounded up to sector units) 004h 4 Size in bytes |
000h N*8 File List ... 4 File List end marker (00000000h) ... .. Garbage padding to 800h-byte boundary ... .. File Data |
000h 4 Offset/800h (increasing) 004h 4 Size in bytes (often zero; for unused file numbers) |
000h X*4 File List for BINPACK0.BIN ;\ ... .. Zeropadding ; BINPACK0 410h .. Unknown (some/all of it looks like garbage) ;/ 800h Y*4 File List for BINPACK1.BIN ;\ ... .. Zeropadding ; BINPACK1 C10h .. Unknown (some/all of it looks like garbage) ;/ |
000h 2 Offset/800h in BINPACK0.BIN or BINPACK1.BIN 002h 2 Size/800h |
000h 4 Number of Files 004h 4 Size of File Data area (total filesize-N*0Ch-8) 008h N*0Ch File List ... .. File Data area |
000h 4 Offset (zerobased, from begin of File Data area) 004h 4 Size in bytes 008h 4 Size rounded to mutiple of 4-bytes |
000h 0Ch ID "@(#)GT-ARC",00h,00h 00Ch 2 Content Type (8001h=Compressed, 0001h=Uncompressed) 00Eh 2 Number of Files (eg. 0Fh) 010h N*0Ch File List ... .. File Data area File List entries: 000h 4 Offset in bytes (increasing, unaligned) 004h 4 Compressed File Size (can be odd) ;\both same when uncompressed 008h 4 Decompressed File Size ;/(ie. when [00Ch]=0001h) |
000h 4 Number of Files (N) 004h N*8 File List ... .. File Data area |
000h 4 Offset in bytes (increasing, 1/4-byte? aligned) 004h 4 File Size in bytes (usually N*4, TXT's in ODT are padded as so) |
000h 4 ID "DFS_" (with align 4) or "DF2_" (with align 800h) 004h 4 Number of Files (N) 008h N*8 File List ... .. File Data area File List entries: 000h 4 Fileoffset in bytes (4-byte or 800h-byte aligned, increasing) 004h 4 Filesize in bytes (can be odd, eg. in BUSTGR_A\SELECT.BPE\*) |
000h 4 Total used filesize (excluding zeropadding to 2EE000h) 004h 4 Number of Files (N) 008h N*8 File List ... .. File Data area ... (..) In some files: Zeropadding to 2EE000h (3072Kbytes) |
000h 4 Offset (increasing, 4-byte aligned, see note) 004h 4 Filesize in bytes (can be odd in Monaco) |
If (Size AND 3)=0 then NextOffset=Offset+Size ;Align4 If (Size AND 3)>0 then NextOffset=Offset+Size+Align800h ;Align800h Namely, Monaco has files with Size=3BC5h. |
Rollcage 1 uses a single IMG file that contains both directory and data: 000h 4 Header offset (0) ;\ 004h 4 Header size (10h+N*10h) ; this seems to be a File List entry 008h 4 Header size (10h+N*10h) ; for the header itself 00Ch 4 Zero ;/ 010h N*10h File List ;-File List for actual files ... .. Zeropadding to 800h-byte boundary ... .. File Data area Number of files is "IMG[04h]/10h" (minus 1 for excluding the header itself) The other titles have seaparate IDX and IMG files for directory and data: SPEED.IDX = Directory (N*10h bytes File List with offsets into SPEED.IMG) SPEED.IMG = File data Number of files is "Filesize(SPEED.IDX)/10h" |
000h 4 Fileoffset in bytes (800h-byte aligned, increasing)
004h 4 Filesize in bytes
008h 4 When compressed: GT20 Header [004h] (decompressed size)
When uncompressed: Same as filesize
00Ch 4 When compressed: GT20 Header [008h] (overlap, usuallly 3, or 7)
When uncompressed: Zero
|
000h 4 Number of Entries 004h N*0Ch File List ... .. Zeropadding to 800h-byte boundary ... .. File Data area File List entries: 000h 4 Unknown (random/checksum?) 004h 4 File Offset (800h-byte aligned, increasing) 008h 4 File Size in bytes |
000h N*0Ch File List (154h entries) ... N*4 Filename Checksums (?) (154h entries) ... .. Zerofilled (padding to 800h-byte boundary) ... .. File Data area |
000h 4 Number of entries (including the 1st entry itself) 004h 4 Offset/800h (always 0, relative from begin of directory) 008h 4 Type (always 3=Directory) |
000h 4 For Files: Size in bytes, for Directories: Number of entries 004h 4 Offset/800h (from begin of current directory, increasing) 008h 4 Type (0=File, 3=Directory) |
000h 4 File ID (always 01h,02h,04h,08h) 004h 4 Maybe Version? (always 01h,00h,01h,00h) 008h 4 Header Size (18h+N*8+ArchiveNameLength) ;eg. 4ECh 00Ch 4 Sector Alignment (can be 4 or 800h) 010h 4 Number of Files (N) ;eg. 99h 014h 4 Length of Archive Name (including ending 00h) 018h N*8 File entries (see below) ... .. Archive Name, ASCII, terminated by 00h ;eg. "bigfile.dir",00h ... .. Zeropadding to Sector Alignment boundary ... .. File Data |
000h 4 Fileoffset (with above Sector Alignment) (increasing) 004h 4 Filesize in bytes |
nested CAT archives (file 07h,0Ch,11h,16h,1Bh,20h,25h,etc) empty files (file 3Eh,5Ah-5Fh,62h-67h,etc) MDEC v2 STR's (file 95h-96h) XA-ADPCM's (inside of nested CAT, in file94h\file*) |
0000h+N*4 1 Sector MM in BCD ;\based at 00:06:00 for file 0 0001h+N*4 1 Sector SS in BCD ; (unused files are set to 00:00:00) 0002h+N*4 1 Sector FF in BCD ;/ 0003h+N*4 1 Size MSB in hex (Size/800h/100h) 2000h+N 1 Size LSB in hex (Size/800h AND FFh) 2800h (..) Data area for file 001h..590h (demo version only) |
Sector 000ADh SCUS_944.76 ;exefile ;\ Sector 00130h SYSTEM.CNF ; iso root folder Sector 00131h DATA (sub-folder, 27h sectors) ;/ Sector 00158h (padding) ;-padding to 00:06:00 Sector 001C2h DATA\F0000.BIN ;file 000h ;\ Sector 001C7h DATA\F0001.BIN ;file 001h ; ... ; iso data folder Sector 00B54h DATA\F0032.BIN ;file 020h ; Sector 00B9Bh DATA\F0033.BIN ;file 021h ; ;\files exceeding the 800h ... ... ; ; directory size limit, not Sector 1A0C9h DATA\F1907.BIN ;file 773h ;/ ;/accessible via PSX kernel Sector 1AAF1h DUMMY.BIN ;-iso root folder (padding) |
Sector 07148h HSG2\MINGOL2.BIN ;file 000h..590h ;demo binary files Sector 0AC1Dh HSG2\MINGOL2X.BIN ;file 76Ch ;demo streaming file(s) Sector 0B032h HSG2\SCUS_944.95 ;exefile ;demo exe file |
MAPFILE.DAT: 000h N*8 File List entries MAPFILE.BIN: 000h .. Data (67Mbytes) File List entries: 000h 4 Size in bytes (can be 0=empty) 004h 4 Offset/800h in MAPFILE.BIN (increasing, 0 and up) |
CHRHEAD.BIN: 000h 4 Total Size of CHRHEAD.BIN (10h+N*0Ch) 004h 4 Number of entries (N) 008h 8 Zerofilled 010h N*0Ch File List CHRFILE.BIN: 000h .. Data File List entries: 000h Compressed size in bytes 004h Offset/800h in CHRFILE.BIN 008h Decompressed size in bytes (or 0=Uncompressed) |
000h 4 ID ("PAC ") ;\
004h 4 Number of files (N) ; Header
008h N*8 File List ;/
... .. File Data area ;-Data area
|
000h 2 File ID (inreasing, but may skip numbers, ie. non-linear) 002h 3 File Offset (increasing, relative to begin of Data area) 005h 3 File Size |
000h 4 Unknown (1) 004h 4 Filelist Offset (800h) 008h 4 Filelist Size (N*8+4) (7ACh) ... .. Padding to 800h-byte boundary (see note) 800h 4 Number of files (N) (F5h) 804h N*8 File List ... .. Padding to 800h-byte boundary (see note) ... .. File Data area |
000h 4 File Offset in bytes (increasing, 800h-byte aligned) 004h 4 File Size in bytes |
Step 1: Zeropadding to 200h-byte boundary (first 0..1FFh bytes) Step 2: Garbagepadding to 800h-byte boundary (last 0..600h bytes) |
000h 2 ID ("BD")
002h 2 Number of files (N)
004h N*8 File List
... .. Zeropadding to 3000h
3000h .. File Data area
|
000h 4 File Offset/800h (increasing) 004h 4 File Size in bytes |
000h 4 ID ("add",00h)
004h 4 Fixed (4)
008h 4 Offset to File List (usually/always 20h)
00Ch 4 Number of Files (N)
010h 4 Fixed (10h)
014h 0Ch Zerofilled
020h N*10h File List
... .. File Data area
|
000h 4 Offset (increasing, 4-byte aligned) ;\or both zero 004h 4 Size (can be odd) ;/ 008h 4 Unknown (0) (or 00h,10h,11h,20h,30h,40h when Offset/Size=0) 00Ch 4 Zero (0) |
000h 4 ID ("CNA",00h)
004h 4 Unknown (1)
008h 4 Number of Files (N) (5A4h)
00Ch 4 Size of File Data area (total_size-N*10h-40h-padding)
010h 0Ch Zerofilled
01Ch 0Ch Name "IMODE.417", zeropadded (same as filename in ISO filesystem)
028h 18h Zerofilled
040h N*10h File List
... .. Zeropadding to 800h-byte boundary
... .. File Data area
File List entries:
000h 4 File ID (increasing, with gaps)
004h 4 Offset/800h (increasing)
008h 4 Filesize in bytes
00Ch 4 Zero
|
000h 4 Number of files (N) 004h N*4 File List ... .. Zeropadding to 800h-byte boundary |
000h 2 File Offset/800h (increasing) 002h 2 File Size/800h |
000h 5*4 File Sizes (can be odd) (can be 0 for 2nd and 5th file) 014h 5*4 File Offsets (28h and up, increasing by sizes rounded to N*10h) 028h .. File Data area (first file usually/always contains "SShd") |
0000h 4 ID "siff" ;\Header 0004h 4 Total Filesize (DADB1Ch) ;/ 0008h 4 ID "RSRC" ;\ 000Ch 4 String Size (70h) ; ASCII string 0010h 70h String "RC ver1.0 Copyright",...,00h ;/ 0080h 4 ID "RIDX" ;\ 0084h 4 File List Size (1F78h) (3EFh*8) ; Directory 0088h N*8 File List (Offset, Size1) ;/ 2000h 4 ID "EXIX" ;\ 2004h 4 Extended List Size (FBCh) (3EFh*4) ; Extended 2008h N*4 Extended List (Size2) ;/ 2FC4h 4 ID "GAP0" ;\Alignment Padding 2FC8h 4 Padding Size (2Ch) ; (so that next chunk 2FCCh 2Ch Padding (1Ah-filled) ;/starts at boundary-8) 2FF8h 4 ID "RBB0" ;\ 2FFCh 4 File Data area Size (DAAB1Ch) ; Data area 3000h .. File Data area ;/ |
000h 4 File Offset (increasing, 4-byte aligned, from ID "RBB0" plus 8) 004h 4 File Size in bytes (can be odd) |
000h 4 File Size in bytes (always the same size as in RIDX chunk) |
000h 4 ID "OIFF" ;\Header 004h 4 Total Filesize ;/ 008h 4 ID "TIMT" or "ANMT" ;\ 00Ch 4 Size (N*4) ; Directory Table 010h N*4 File List (offsets from begin of Data ID+8);/ ... 4 ID "TIMD" or "ANMD" ;\ ... 4 Data Area size (SIZ) (Filesize-18h-N*4) ; Data area ... SIZ Data Area ;/ |
MEGA.CSH: 000h N*0Ch File List MEGA.BIN: 000h .. File Data area |
000h 4 Offset (in MEGA.BIN file, 800h-byte aligned, increasing) 004h 4 Unknown (32bit id/random/checksum/whatever) 008h 4 Filesize in bytes |
000h 4 Number of entries (1 or more) (N) 004h N*10h File List ... .. File Data area (.VB aka SPU-ADPCM) File List entries: 000h 4 Offset from begin of Data area, increasing 004h 4 Filesize in bytes 008h 4 Unknown (0 or 1) 00Ch 4 Unknown (AC44h, 0FA0h, 2EE0h, 2710h, 2B11h, 3E80h, 1F40h, etc.) Note: Above AC44h might be 44100Hz, or just file number 44100 decimal? |
000h 4 ID (always 2A81511Ch) 004h 0Ch Zerofilled 010h 1 Unknown (1) 011h 1 Compression Flag for all files (00h=Uncompressed, 80h=Compressed) 012h 2 Number of files (bit0-13?=N, bit14=Unknown, can be set) 014h N*0Ch File List, 12 bytes/entry ;<-- when [11h]=00h=uncompressed 014h N*10h File List, 16 bytes/entry ;<-- when [11h]=80h=compressed ... .. File Data area |
000h 4 File ID (usually 0=first, increasing) (or 0001h,7531h,7532h,...) 004h 4 Offset-10h in bytes (increasing, 4h-byte aligned) 008h 4 Filesize, uncompressed (can be odd) 00Ch (4) Filesize, compressed (can be odd) ;<-- exists only if compressed |
000h 4 ID "0FDG XSP" (aka PSX GDF0 backwards)
008h 4 Header Size (N*10h+10h)
00Ch 4 Number of files (N)
010h N*10h File List
... .. Zeropadding to 800h-byte boundary
... .. File Data area
File List entries:
000h 4 ID/Type ("MARV", "MARS", "MARD", "PMET", "COLR", "MROF")
004h 4 ID/Num (usually 1 SHL N, or all zero)
008h 4 Offset (800h-byte aligned, increasing)
00Ch 4 Size in bytes
|
000h 4 ID "MRG",1Ah 004h 4 Number of Files (eg. 0, 1, 2, 193h, 2E7h, or 1DBBh) 008h N*8 File List ... .. Padding to 800h-byte boundary (8Ch-filled) (not in nested MRG's) ... .. File Data area File List entries: 000h 4 Offset/800h, or 4-byte aligned Offset/1 (increasing) 004h 4 Size (can be odd, and can be zero) Size oddities: Empty files in demo version have Size=0 and Offset=0. Empty files in retail version have Size=0 and Offset=OffsetOfNextFile. MRG archives can start or end with Empty files. All files can be empty (eg. retail DRAGN0.BIN\1190h). NumFiles can be zero (eg. retail DRAGN0.BIN\1111h, demo DRAGN0.BIN\10E2h). Offset oddities: SECT\*.BIN have Offset/800h Nested MRGs have 4-byte aligned Offset/1 The two variants can be detected as: if FirstOffset=(NumFiles*8+8) then NestedVariant if FirstOffset=(NumFiles*8+8+7FFh) AND NOT 7FFh then RootVariant Whereas, FirstOffset is the first NONZERO offset in file list (important for demo version, which has archives that start with ZERO offsets). |
000h 4 Random/Checksum? 004h 4 Faded ID (FADED007h) 008h 4 Part 1 Offset (Sound) (always E5Ch) 00Ch 4 Part 2 Offset (Texture) (when Type=01h: Offset-E5Ch) 010h 4 Part 3 Offset (?) (when Type=01h: Offset-E5Ch) 014h 4 Part 4 Offset (?) (when Type=01h: Offset-E5Ch) 018h 4 Type (10h or 20h=Normal) (or 01h=Special in BB\8\*.BBK) 01Ch B0Ch Part 1 Info (Sound) (when Type=01h: garbage-filled) B28h 314h Part 2 Info (Texture) E3Ch 14h Part 3 Info (?) E50h 0Ch Part 4 Info (?) E5Ch .. Part 1 Data (Sound, SPU-ADPCM data, if any) ... .. Part 2 Data (Texture data) (starts with BDEF1222h or BDEF1111h) ... .. Part 3 Data (?) ;\maybe map, models, and/or whatever ... .. Part 4 Data (?) ;/ |
01Ch 4 Random/Checksum? 020h 4 Faded ID (FADED007h) 024h 4 Part 1 Size (eg.7C7F0h) 028h 4 SPU Start Addr (1010h) (for data from file offset E5Ch) 02Ch 4 SPU Middle Addr (eg. 58F70h) 030h 4 SPU End Addr (eg. 7D800h) (start+size) 034h 2 Middle entry number (often 3Ch) 036h 2 Number of used entries-1 (eg. 50h means that 51h entries are used) 038h AF0h Sample List (100 entries, unused ones are zerofilled) 914h 214h Zerofilled (unused 1Ch-byte entries) (total is 1Ch*64h) Sample List entries: 000h 4 SPU Offset (1010h and up) (SpuOffset=1010h is FileOffset=E5Ch) 004h 4 Sample Size in bytes 008h 4 Unknown (0) 00Ch 4 Unknown (0) 010h 4 Pitch (400h=11025Hz, 800h=22050Hz, 2E7h=8000Hz, 8B5h=24000Hz) 014h 4 Unknown (0 or 1) 018h 4 File ID (00001F08h and up) |
B28h 4 Random/Checksum? B2Ch 4 Faded ID (FADED007h) B30h 4 Part 2 Size (N*16000h) ;Width=2C0h halfwords, Height=N*64 B34h 4 Zero (0h) B38h 4 Some RAM Address (8010xxxxh) B3Ch 4 Unknown (eg. 195h or E3h) ;same as at [DA4h] B40h 4+4 VRAM Address X,Y (140h,0) ;maybe load target B48h 4+4 VRAM Address X,Y (140h,0) ;maybe palette base? B50h 4+4 VRAM Address X,Y (xx0h,Height-40h) ;often at/near end of used area B58h 4 Unknown (eg. 1D0h or 1E0h) B5Ch 4 Unknown (eg. 1Ah or 0Dh) B60h 200h Some halfwords? (most are FFFFh, some are 0000h) D60h 40h Zerofilled (0) DA0h 4 Unknown (eg. 185h or E2h) DA4h 4 Unknown (eg. 195h or E3h) ;same as at [B3Ch] DA8h 9x10h Special Texpages (VramX,Y, SizeX,Y, StepX,Y, Flag/Type/Num or so?) E38h 4 Some RAM Address (800Axxxxh) |
E3Ch 4 Random/Checksum? E40h 4 Faded ID (FADED007h) E44h 4 Part 3 Size (eg. A9728h or 51264h) E48h 4 RAM End Address (start+size) (eg. 801Fxxxxh) (near memtop) E4Ch 4 RAM Start Address (end-size) (eg. 801xxxxxh) |
E50h 4 Random/Checksum? E54h 4 Faded ID (FADED007h) E58h 4 Part 4 Size (usually 10CCCh) (or 105E0h in demo version) |
| CDROM File Archives with Offset |
R-Types (CG.1, PR\PR.1, and nested inside CG.1) Final Fantasy IX (nested inside FF9.IMG, FF9.IMG\DB, FF9.IMG\DB\DOT1) Legend of Mana (*.EFF,*.SET,*.BTP(?) in folders SND*,SOUND,WM(?)) Witch of Salzburg (*.ANM/BIN/BSS/DAT/MDL/SCE) Rayman (RAY\*.XXX, RAY\SND\*.ALL, and nested inside *.XXX) Pandemonium II (JESTERS.PKG\0101\0008 and JESTERS.PKG\0101\000D) Incredible Crisis (MagDemo38: IC\TAN_DAT.CDB\<DOTLESS>\<DOT1>\<SHIFTJIS>) Various games on PlayStation Magazine Demo Discs (Disc 03-54) |
000h 4 Number of Files (N) (eg. 2..18) 004h N*4 File List (offsets to each file, increasing, aligned) ... (4) Optional: Total filesize (aka end-offset for last list entry) ... .. Optional: Zeropadding to alignment boundary (when alignment>4) ... .. File Data |
Align800h, no extra entry R-Types (CG.1 and PR\PR.1) Align4, no extra entry R-Types (nested in CG.1), FF9 (in IMG, IMG\DB) Align2, no extra entry Incredible Crisis (IC\TAN_DAT.CDB\*\*) Align800h, with extra entry MLB 2000 (DATA.WAD) Align10h, with extra entry Witch of Salzburg (*.ANM/BIN/BSS/DAT/MDL/SCE) Align4, with extra entry Rayman (*.XXX, *.ALL) |
000h 2 Number of Files (N) 002h 2 ID for 32bit version (FFFFh=32bit entries) 004h N*4 File List (offsets to each file, increasing, 4-byte aligned) ... .. File Data |
000h 2 Number of Files (N) 002h N*2 File List (offsets to each file, increasing, 4-byte aligned) ... .. Zeropadding to 4-byte boundary ... .. File Data |
000h 2 Unknown/Fixed (always 0001h) 002h 2 Number of Files (N) 004h N*4 File List (offsets to each file, increasing) (4-byte aligned?) ... .. File Data |
000h 4 Total Filesize (aka end-offset for last list entry) 004h 4 Number of Files (N) 008h N*4 File List (offsets to each file, increasing, 4-byte aligned) ... .. File Data |
000h 4 Zero 004h 4 Zero 008h 4 Number of entries 008h N*4 File List (Offsets) ... .. Data (for TPK: TIM with 4-byte extra header) (for PTI: raw TIM) |
000h 4 Unknown (can be 00h,01h,10h,11h,20h,30h) 004h ... TIM file |
000h 4 Number of entries 004h 4 Zero 008h N*4 File List (32bit Offsets) ... .. Data (usually TMD model files) (or Non-ASCII text strings?) |
EFFECT\*.MPK --> contains TMD models MAPFILE\87Fh,883h,..,87Fh --> contains TMD models MAPFILE\07Bh,0BFh,..,88Eh --> contains Non-ASCII text strings (?) |
000h 2 Number of Files 002h N*2 File List (Offset/800h to file data, increasing) ... 2 Total Size/800h (end-offset for last file) ... .. Zeropadding to 800h-byte boundary ... .. File Data |
000h N*4 Offsets to File data (increasing, usually 4-byte aligned) ... (4) Filesize (end-offset for last file) (only in Ape Escape) ... ... File Data |
000h 4 Size of Data Area (total filesize minus 0D0h) 004h 4 Number of files 008h N*4 File List (zerobased offsets from begin of Data Area) ... .. Zeropadding to 0D0h 0D0h .. File Data Area |
000h 4 Number of Files (N) (3C9h) 004h N*4 File List (Offset/800h) ... 4 Total Size/800h ;<-- last offset ... 4 Unknown (00,E8,82,2E) ;<-- ??? maybe chksum*800h or so? ... .. Zeropadding to 800h-byte boundary ... .. File Data area |
000h 4 Zero 004h 4 Number of Entries (4D3h) 008h N*4 File List (Offset/800h) ... 4 Total Size/800h (aka end Offset/800h of last file) ... .. Zeropadding to 800h-byte boundary ... .. File Data area |
#define init_data 0 ;for file 0000h #define gameover_data 1 ;for file 0001h #define town01 3 ;for file 0003h #define town0b 12 ;for file 000Ch ... ;... #define other6 1222 ;for file 04C6h #define other7 1228 ;for file 04CCh |
000h 4 Number of Entries (N) 004h N*4 File List (Offset-(4+N*4), increasing) (or FFFFFFFFh=Unused entry) ... .. File Data area |
000h 4 ID "OA05" 004h N*4 Offset List (usually/always 5 used entries, plus zeropadding) 030h .. File Data area (usually/always starting at offset 30h) |
000h 4 ID "SEGG" 004h 4 Offset to .VH file 008h 4 Offset to .VB file 00Ch 4 Number of .SEQ files (N) (usually 6Eh, or 08h in MENU.SGG) 010h N*4 Offsets to .SEQ files (increasing, unaligned) ... .. SEQ files ... .. Padding to 4-byte boundary ... .. VH file ... .. VB file |
000h 8 ID "VRAM-WAD" (here as archive ID, although same as compress ID) 004h N*4 File List (offsets to Data) ;NumFiles=(FirstOffset-8)/4 ... .. Data (compressed .PAK files, which do ALSO have ID="VRAM-WAD") |
000h 4 Unknown (3) 004h 4 Total Size 008h 4 Number of Files (N) (max 40h, for max 40h*4 bytes in file list) 00Ch N*4 File List (increasing offsets, 800h-byte aligned) ... .. Unknown (looks like garbage padding for unused File List entries) 10Ch 6F4h 42h-filled padding to 800h-byte boundary 800h .. File Data area |
000h 8 Fixed (88h,0,0,0,0,0,0,0) 008h 4 Number of Files (eg. 1Dh or 585h, including last/end file) 00Ch N*4 File List (increasing offsets, 800h-byte aligned) ... .. Zeropadding to 800h-byte boundary ... .. File Data area |
000h 4 Total Filesize (3E800h in Spyro) 004h N*8 File List (1B0h bytes in Spyro) ... .. Zeropadding to 800h-byte boundary ... .. File Data (4-byte aligned, despite of above 800h-byte hdr padding) |
000h 4 Fileoffset (increasing, 4-byte aligned) 004h 4 File ID? (unsorted, not increasing, used range is 000h..1FAh) |
000h 4 Fixed ID ("bf00")
004h 2 Number of Files (N)
006h 2 Unknown (always 42h, maybe frame rate or so?)
008h 2 Bitmap Width (always 28h aka 40 decimal)
00Ah 2 Bitmap Height (always 1Eh aka 30 decimal)
00Ch N*4 File List (increasing 32bit offsets, 4-byte aligned)
... .. File Data area (contains .BS fraquant files, played in sequence)
|
| CDROM File Archives with Size |
000h 4 Number of files (N) (existing ranges are 01h..3Fh) 00Ch N*4 File List (filesizes in bytes, always multiple of 4) ... .. File Data area (usually starts with 0002ABBAh in 1st file) |
000h 4 Zero (0) 004h 4 Type/ID (27100h=160000, 2BF20h=180000, 30D40h=200000 decimal) 008h 4 Number of files (N) 00Ch N*0Ch File List ... .. Zeropadding to 7FCh 7FCh 4 Checksum (32bit sum of SIGN-EXPANDED bytes at [000h..7FBh]) ... .. File Data |
000h 4 File Type/ID or so (roughly increasing, eg. 1,3,6,5,7,8,9,A,B) 004h 4 Filesize in bytes 008h 4 Filesize rounded up to multiple of 800h bytes |
000h 4 Fixed 1 (maybe version, or compression flag) 004h (4) Unknown (000xxxx0h) ;<-- Extra in The Grinch only (not Bunny) ... 4 Number of files ... N*0Ch File List ... .. Zeropadding to 7FCh 7FCh 4 Checksum (32bit sum of SIGN-EXPANDED bytes at [000h..7FBh]) ... .. File Data |
000h 4 File Type/ID or so (roughly increasing, eg. 1,2,3,6,5,7,8,9,A) 004h 4 Filesize in bytes (rounded to N*4 even if compressed data is less) 008h 4 Filesize rounded up to multiple of 800h bytes |
000h 4 Fixed 1 (maybe version, or compression flag) 004h 4 Number of files (4) 008h N*8 File List ... .. Zeropadding to 800h-byte boundary (without checksum, unlike .BZE) ... .. File Data |
000h 4 Size in bytes 004h 4 Size rounded to multiple of 800h |
000h 2 ID ("PX")
002h 2 Unknown (1 or 3)
004h 4 Header Size (eg. 80h, 7C0h, or 1730h) (N*8+8)
008h N*8 File List
... .. Zeropadding to 800h-byte boundary
... .. File Data area
File List entries:
000h 4 Offset (increasing, 800h-byte aligned)
004h 1 Zero
005h 3 Filesize in bytes (24bit) (can be odd)
|
XXX detect this WITH extension=".RC" check before OBJ
(else type=1 could be mistaken as offs=1) (eg RC1\BP0*.RC)
|
000h N*8 File List ... 8 File List end (zerofilled) ... .. Garbage padding to 800h-byte boundary |
000h 4 Filetype (see below) 004h 4 Filesize in bytes |
00h = End of File List (at least so when Type and Size are both zero) 01h = .TIM 02h = Unknown 03h = Unknown 05h = .VH 06h = .VB 09h = Unknown 0Ah = .TIM (left half of a larger image) (right half has type 01h) 0Bh = Unknown 0Ch = Unknown |
HED: 000h 2 Number of entries (N) 002h N*6 File List WAD: 000h ... File data (at 800h-byte aligned locations) |
000h 3 File ID (24bit) 003h 3 File Size in bytes (21bit, max 2Mbyte) (upper 3bit=unused?) |
000h 4 Header Size (N*SectorSize) (xxh, 800h, 1000h, 4800h, or 920h) 004h 4 Sector Size (4=ChildArchive, 800h=MainArchive, 920h=FMV/MADN00) 008h 4 File List entrysize (0=32bit, 1=16bit/MADN00, 4=16bit/MADN01) 00Ch N*2/4 File List (16bit or 32bit filesizes in bytes) ... .. Zeropadding to SectorSize boundary ... .. Files (with above sizes, each zeropadded to SectorSize boundary) |
000h 4 Total Filesize-4 (or, in Potter games: Filesize-0) 004h N*14h File List (2 entries in Croc2, 3 entries in Aladdin/Emperor/Pott) ... .. File Data area (SPU-ADPCM) (.VB files with leading zeroes) File List entries: (Aladdin/Emperor) (Croc2) (Potter) 000h 4 Sample Rate in Hertz (AC44h=44100Hz) (5622h=22050Hz) (7D00h) 004h 2 Sample Rate Pitch (1000h=44100Hz) (0800h=22050Hz) (B9Ch) 006h 2 Unknown (7Fh) (32h) (7Fh) 008h 4 Unknown (1) (8) (8) 00Ch 4 Unknown (1FC0001Fh) (40008Fh) (1FC0001Fh) 010h 4 Filesize (xxx0h) (xxx0h) (xxx0h) |
000h 4 ID ("CPRS")
004h 4 Maybe Header Size (N*10h+8)
008h 4 Number of Files (N)
00Ch 4 Zero
010h N*10h File List
... .. Zeropadding to 1000h
1000h .. File Data (SPU-ADPCM data)
File List entries:
000h 4 Offset-1000h (0 and up, increasing, 800h-byte aligned)
004h 2 Sample Rate Pitch (5CEh=16000Hz or 800h=22050Hz)
006h 2 Whatever (always 2)
008h 4 Whatever (always 0)
00Ch 4 Filesize in bytes (always multiple of 800h)
|
000h 800h File List (with 10h or 20h bytes per entry) 800h .. File Data (each file is zeropadded to 800h-byte boundary) |
Dino Crisis 1 --> always size 10h Dino Crisis 2 --> usually size 20h Dino Crisis 2 --> sometimes size 10h (eg. SC24.DAT, SC48.DAT, WEP_*.DAT) |
File List entries, type 0 and 7:
000h 4 Type (0=Data (or .BS pictures), 7=CompressedData)
004h 4 Size
008h 4 RAM Addresss (80000000h..801FFFFFh)
00Ch 4 Zero
010h (10h) Zerofilled
File List entries, type 1 and 2 and 8:
000h 4 Type (1=Bitmap, 2=Palette, 8=CompressedBitmap)
004h 4 Size (see below Size Notes)
008h 2 VRAM Address X (0..3FFh)
00Ah 2 VRAM Address Y (0..1FFh) (or 280h in Dino 2 ST703.DAT)
00Ch 2 Width in halfwords (1..400h)
00Eh 2 Height (1..200h)
010h (10h) Zerofilled
File List entries, type 3 and 4:
000h 4 Type (3=VoiceHeader("Gian"), 4=VoiceData(SPU-ADPCM))
004h 4 Size
008h 4 SPU Address (0..7FFF0h)
00Ch 2 Unknown (0..7) ;\usually both same (or val1=0, val2>0)
00Eh 2 Unknown (0..7) ;/
010h (10h) Zerofilled
File List entries, type 5 (eg. ME*.DAT):
000h 4 Type (5=Unknown... maybe Midi-style or so)
004h 4 Size
008h 4 Load Address (0, or on next 4-byte boundary after previous file)
00Ch 2 Unknown (0..2) ;\always both same
00Eh 2 Unknown (0..2) ;/
010h (10h) Zerofilled
File List entries, type 6 and 9:
The EXE code does also accept type 6 and 9 (type 6 is handled same as
type 0, and type 9 is ignored), but the actual archives don't seem to
contain any files with those types.
File List entries, padding for unused entries:
000h 10h Type ("dummy header ")
010h (10h) Zerofilled
|
Bitmaps and Palettes can have following sizes: Width*Height*2 ;normal case Width*Height*2 + Align(1000h) ;eg. Dino Crisis 1 DOOR*.DAT Width*Height*2 + Align(800h) ;eg. Dino Crisis 2 DOOR27.DAT CompressedBitmaps can have following sizes in compressed form: Less than Width*Height*2 ;normal case Less than Width*Height*2 + 1000h ;eg. Dino Crisis 2 M_RESULT,ST002.DAT CompressedBitmaps can have following sizes after decompression: Width*Height*2 + 8 ;normal case Width*Height*2 + Align(1000h?) + 8 ;eg. Dino Crisis 2 M_RESULT,ST002.DAT |
| CDROM File Archives with Chunks |
Group Header:
000h 4 Group ID ("FORM") (or "LIST" or "CAT " or "PROP")
004h 4 Group Size-08h (SIZ) (filesize-8) (big-endian)
008h 4 Group Type (4-character ASCII) (should be a unique identifier)
00Ch SIZ-4 Chunk(s), and/or nested Group(s)
Chunk Format:
000h 4 Chunk Type (4-character ASCII) (meaning depends on Group Type)
004h 4 Chunk Size (SIZ) (big-endian)
00Ch SIZ Data (eg. .TIM, .VB, .VH or custom data)
... .. Zeropadding to 2-byte boundary
|
000h 4 Chunk ID (4-letter ASCII) (VCSP/VCOV or VCBG/VCML/VCMR/FREE) 004h 4 Chunk Size (SIZ) (big-endian) 008h 4 Extra Value (usually 0..100h) (little-endian) 00Ch SIZ-4 Body |
Group Header:
000h 4 Group ID ("FORM" or "BODY")
004h 4 Group Size-08h (SIZ) (little-endian)
008h SIZ Chunk(s)
Chunk Format:
000h 4 Chunk Type (4-character ASCII)
004h 4 Chunk Size (SIZ) (little-endian)
00Ch SIZ Data
... .. Zeropadding to 2-byte boundary
|
Group Header:
000h 4 Group ID ("hTIX","hFNT","hMBD","hHBS")
004h 4 Group Size (total filesize) (little-endian)
... (8) Unknown extra (0,0,0,0,0Ch,0,0,0) ;<-- only in "hHBS" files
... .. Chunk(s)
Chunk Format:
000h 4 Chunk Type ("cCLT","cBIT","cSTR","cMAP","cIDX","cVAB","cSEQ")
004h 4 Chunk Size (SIZ) (little-endian)
00Ch SIZ-8 Data
... .. Maybe Zeropadding to boundary? (Chunk Size is always N*4 anyways)
|
000h 4 Chunksize in bytes (SIZ) (usually a multiple of 4) 004h SIZ Chunkdata (eg. .TIM file or other stuff) |
000h 0Ch Chunk Filename ("filename.ext", zeropadded if shorter)
00Ch 4 Chunk Data Size in bytes (SIZ)
010h SIZ Chunk Data (usually VAGp files, in VAG.WAD)
|
000h .. Chunk(s) (.BS files with extra header info) ... 4 End Marker (00000000h) Chunk format: 000h 4 Chunk size (including whole chunk header) 004h 2 Bitmap Width (eg. F0h) 006h 2 Bitmap Height (eg. 80h) 008h 2 Data Size/4 (same as (Chunksize-0Ch-filenamelen)/4) 00Ah 2 MDEC Size/4 (same as at Data[0]) 00Ch .. Filename (eg. "lsFact",00h or "bsRooftop1",00h) ;\filename field ... .. Filename Zeropadding to 4-byte boundary ;/ ... .. Data (in BS v2 format) (MDEC Size/4, BS ID 3800h, etc.) |
000h 4 Chunk Size (18h plus size of Data and Padding) 004h 4 Unknown (80xxxxxxh) (RAM address?) 008h 4 Unknown (1D4A00xxh) (LSB usually 08h, or sometimes 01h or 20h) 00Ch 2 File ID (0xxxh) 00Eh 2 Method (0000h=LZSS Compressed, 0001h=Uncompressed) 010h 4 Unknown (80xxxxxxh) (RAM address?) 014h 4 Unknown (80xxxxxxh) (RAM address?) 018h .. Data (plus garbage-padding to 4-byte boundary) |
000h 4 ID (100h) 004h .. Chunk(s) ... 4 Zero (Chunk Size=0=End) ... .. Optional zeropadding to 800h-byte boundary (in R4.BIN\*) |
000h 4 Chunk Size (SIZ) 004h SIZ Chunk Data (TIM file) (note: includes 0x0pix TIMs with palette) |
000h 8 ID "TXSPC",0,0,0 (aka CPSXT backwards) 008h 4 Timestamp? (32A5C8xxh) 00Ch 4 Number of Chunks (N) (can be 0=None, eg. TM2\SCREEN\ARROWS.TMS) 010h N*4 Unknown ... N*var Chunks Chunk format: 000h 4 Chunk Size-4 (SIZ) 004h SIZ Chunk Data (TIM file) |
000h .. Chunk(s) |
000h .. Chunk(s) for 1st folder ;\Foldersizes are: ... .. Zeropadding to Foldersize-boundary ; 20000h (PM.DT0 and PM.PCC) ... .. Chunk(s) for 2nd folder ; 28000h (PM.MAP) ... .. Zeropadding to Foldersize-boundary ; 42000h (PM.SD0) ... .. etc. ;/ |
000h 4 Chunk ID (800000xxh) 004h 4 Chunk Size (size of Data part, excluding ID+Size) 008h .. Data |
80000004h x(2),y(2),width(2),height(2) Bitmap 8bpp ;PM.PCC,MAP 80000005h w(2),h(2),zero(4) Array32bit(w,h) ;PM.MAP 80000006h x(2),width(2) Bitmap Palette ;PM.* 80000007h x(2),y(2),w(1),h(1),zero(2) Array8bit(w,h) ;PM.MAP 80000010h width(2),height(2),x(2),y(2) Bitmap 16bpp ;*.BD 80000012h zero(0) ? ;*.BD 80000014h x(2),y(2),width(2),height(2) Bitmap 4bpp ;PM.DT0 80000016h x(2),y(2),w(1),h(1),n(1),3Fh(1) BitmapArray4bpp(n*2) ;PM.DT0 80000018h ... ? ;PM.PCC 8000001Ah zero(8) ? ;PM.PCC 8000001Ch x(2),y(2),width(2),height(2) Bitmap 1bpp flags? ;*.BD 80000020h zero(8) Sound .SEQ file ;PM.SD0 80000021h zero(8) Sound .VH file ;PM.SD0 80000022h zero(8) Sound .VB file ;PM.SD0 80000024h x(2),zero(6) ? ;PM.DT0\4\0 00000000h Zeropadding to next folder Zeropadding ;PM.* |
000h .. Chunks |
000h 1 Chunk Type (see below) 001h 3 Unknown (some flags or file ID, or zero in many files) 004h 4 Chunk Size (SIZ) 008h SIZ Chunk Data (eg. SEQ file) |
02h unknown ST*.BIN 05h .TXT ROLL.BIN 05h LZ-compressed TIM DEMODATA.BIN, ST*.BIN (except ST1*.BIN) 06h DOT1 with stuff and TSQ?? ST*.BIN 07h .TMD DEMODATA.BIN, ST*.BIN (except ST1*.BIN) 08h unknown ST*.BIN 09h "PRM:" ST*.BIN 0Ah unknown ST*.BIN 0Bh DOT1 with stuff ST*.BIN (except ST1*.BIN) (odd: ST3*.BIN) 0Ch .SEQ ROLL.BIN, ST*.BIN 0Dh unknown COMDATA.BIN 0Eh unknown ST*.BIN 0Fh DOT1 with LZ-compressed TIMs ST*.BIN 10h DEFLATE-compressed TIM COMDATA.BIN, ROLL.BIN, ST*.BIN 11h DOT1 with stuff ST*.BIN Note: Type=05h can be uncompressed TXT or compressed TIM. |
07 00 00 00 xx xx 00 00 41 00 00 00 .. TMD Model ("A")
0C 00 00 00 xx xx 00 00 70 51 45 53 .. SEQ Midi ("pQES")
0E xx 00 00 08 00 00 00 xx xx xx xx .. Whatever in ST7DATA.BIN (see note)
10 01 00 00 24 28 00 00 EC 9B 7F 70 .. Deflated TIM in COMDATA.BIN
10 08 1A 00 30 0C 00 00 ED 58 4F 88 .. Deflated TIM in ROLL.BIN
ST7DATA.BIN has 2 chunks with Type=0Eh, followed by SEQ chunk at offset=20h.
|
000h N*2 Chunk List (16bit Offset/800h to Part-1-Chunks in .DAT files) ... .. Zeropadding to 800h-byte boundary Notes: The Chunk List can contain zeroes (as first entry at offset 0, and as unused entries; in VAB.IDX those can be followed by further USED entries). For 2-part DAT files, the Chunk List contains offsets for Part 1 only. |
000h 4 Chunksize/800h ;\ 004h 4 Datasize in bytes ; Single 008h 4 Always 015A5A01h or 015A5A00h ; Part 00Ch 4 Always 2803h ; with 010h .. Midi data .SEQ file ; 1 file ... .. Zeropadding to 800h-byte boundary ;/ |
000h 4 Chunksize/800h ;\ 004h 4 Size of .VH Voice Header in bytes ; Single 008h 4 Size of .VB Voice Binary in bytes ; Part 00Ch .. Voice Header .VH file ; with ... .. Zeropadding to 800h-byte boundary ; 2 files ... .. Voice Binary .VB file ; ... .. Zeropadding to 800h-byte boundary ;/ |
000h 4 Part 1 Chunksize/800h ;\ 004h 4 Size of all TIM files in bytes (can be 0=None) ; Part 1 008h .. Texture data (several TIMs appended after each other) ; ... .. Zeropadding to 800h-byte boundary ;/ ... 4 Number of Files (N) ;\ ... 4 Part 2 Chunksize/800h ; ... N*8 File List ; Part 2 ... .. Garbage-padding to 800h-byte boundary? ; ... .. File Data area (each file Garbage-padded to 800h-byte) ; File List entries: ; 000h 4 File Type/ID ; 004h 4 Size in bytes ;/ |
type 0 --> sectors=([04h]+7FFh+40h)/800h ;misc type 1 --> sectors=([04h]+7FFh)/800h ;vram type 5 --> sectors=([24h]+7FFh)/800h+([2Ch]+7FFh)/800h+1 ;adpcm type 8 --> sectors=([04h]+7FFh+800h)/800h ;midi |
000h 4 Chunk Type (00h) 004h 4 Chunk Size in Bytes (SB) ;-excluding hdrsiz 008h 4 Chunk Size in Sectors (SB+40h+7FFh)/800h ;-including hdrsiz 00Ch 08h Zerofilled 014h 4 Unknown (xxh) 018h 4 Main RAM Address ? (80xxxx00h) 01Ch 24h Zerofilled 040h SB Data ... .. Zeropadding to 800h-byte boundary |
000h 4 Chunk Type (01h) 004h 4 Chunk Size in Bytes (SB+800h) ;\including hdrsiz 008h 4 Chunk Size in Sectors (SB+800h+7FFh)/800h ;/ 00Ch 04h Zerofilled 010h 4 Unknown (0 or 1000h) 014h 4 Unknown (0 or 1) 018h N*20h Bitmap List (see below) ... 20h Bitmap List End Code (0,0,0,0,FFFFFFFFh,0,0,0) ... .. Zeropadding to 800h-byte boundary 800h SB Data ;for Width*2*Height bytes of all bitmap(s) ... .. Zeropadding to 800h-byte boundary Bitmap List entry format: 000h 4 VRAM Address X (140h or 380h or 3C0h etc) 004h 4 VRAM Address Y (0 or 100h or 0Fxh or 1Fxh) 008h 4 Bitmap Width (in halfwords) 00Ch 4 Bitmap Height 010h 4 Bitmap Size (Width*Height*2)+0,E0h,100h,1E0h (buggy) 014h 4 Bitmap Type (0=Bitmap, 1=Palette) 018h 08h Zerofilled |
000h 4 Chunk Type (05h) 004h 4 Chunk Size in Bytes (SH+SB) ;\weirdly, excluding 008h 4 Chunk Size in Sectors (SH+SB+7FFh)/800h ;/hdrsiz and paddings 00Ch 08h Zerofilled 014h 4 Unknown (000000xxh) 018h 4 Unknown (000000xxh) 01Ch 4 Unknown (000000xxh) 020h 4 SPU RAM Address ? (000xxxx0h) 024h 4 Size of .VH file (SH) (0000xx20h) 028h 04h Zerofilled 02Ch 4 Size of .VB file (SB) (000xxxx0h) 030h 7D0h Zerofilled 800h SH Data for .VH file ... .. Zeropadding to 800h-byte boundary ... SB Data for .VB file ... .. Zeropadding to 800h-byte boundary |
000h 4 Chunk Type (08h) 004h 4 Chunk Size in Bytes (SB) ;\excluding hdrsiz 008h 4 Chunk Size in Sectors (SB+7FFh)/800h ;/ 00Ch 0Ch Zerofilled 018h 4 Unknown (usaully 1) 01Ch 4 Unknown (usually 0..2Bh) 020h 4 Number of MIDI sequences (usually 1..3) 024h 7DCh Zerofilled 800h SB MIDI Sequence(s) ... .. Zeropadding to 800h-byte boundary MIDI Sequence format: 000h 4 Size in bytes (including sequence header and padding) 004h 3 Unknown ;\maybe resolution (xxh,xxh,0xh) 007h 3 Unknown ;/and/or tempo? (00h,E0h,01h) 00Ah 2 Rhythm (NN/NN) ? (04h,02h) 00Ch ... Score data (with many MIDI KeyOn's: 9x,xx,xx,tt) ... 3 End of SEQ (2Fh=End of Track) (FFh,2Fh,00h) ... .. Zeropadding to 4-byte boundary |
| CDROM File Archives with Folders |
- Using multiple archive files nested within each other - Using filenames with path string (eg. "path\filename.ext") |
Overall File Structure JFS for root ;\ JFS for 1st folder ;\these are dupicated, ; header with complete list JFS for 2nd folder ; also stored in below ; of all file/folder names JFS for 3rd folder ; data area ; etc. ;/ ;/ JFS for 1st folder, plus data for files in that folder ;\ JFS for 2nd folder, plus data for files in that folder ; data area JFS for 3rd folder, plus data for files in that folder ; etc. ;/ |
00h 4 ID "JFS",00h 04h 4 Size in bytes (for root: including nearby child JFS's) 08h 4 Number of file/folder entries in this folder (N) 0Ch N*14h File/Folder entries |
00h 12 "FILENAME.EXT" (or zeropadded if shorter) 0Ch 4 Offset from begin of JFS in data area (without any alignment) 10h 4 Size in bytes, plus 00000000h=File |
00h 12 "DIRNAME.EXT" (or zeropadded if shorter) 0Ch 4 Offset to child JFS in data area 10h 4 Offset to child JFS in header area, plus 80000000h=ChildFolder |
FAT.BIN: 00h 2 Number of folders (X) (43h) 02h 2 Number of files (Y) (8F0h) 04h 4 Unknown (1000h) 08h X*10h Directory Entry 0000h..X-1 (entry 0000h is named "ROOT") .. Y*10h File Entry 0000h..Y-1 DATA.BIN: 00h .. File Data area |
00h 8 Name (terminated by 00h if less than 8 chars) 08h 2 First Subdirectory number (0001h and up, 0000h would be root) 0Ah 2 Number of Subdirectories (0000h=None, if so above is usually 00FFh) 0Ch 2 First File number (0000h and up) 0Eh 2 Number of files (0000h=None, if so above is usually 00FFh) |
00h 8 Name (terminated by 00h if less than 8 chars) 08h 4 Offset/800h to DATA.BIN 0Ch 4 Size in bytes (when compressed: decompressed size+02000000h) |
HOG.TOC: 000h N*14h Folder/File List (starting with root folder) HOG.DAT: 000h .. File Data (referenced from HOG.TOC) |
000h 1 Type ("D"=Directory)
001h 8 Name ("FILENAME", zeropadded if shorter) (or "\" for root)
009h 3 Extension (usually zero for directories)
00Ch 4 Folder Offset/14h in .TOC file (aka 1st child file/folder index)
010h 4 Folder Size/14h (aka number of child files/folders)
|
000h 1 Type ("F"=File)
001h 8 Name ("FILENAME", zeropadded if shorter)
009h 3 Extension ("EXT", zeropadded if shorter)
00Ch 4 File Offset/800h in .DAT file (increasing)
010h 4 File Size in bytes
|
000h 4 Unknown (demo=A0409901h, us/retail=A0617023h) 004h 4 Unknown (0h) 008h 4 Number of files (F) (demo=B7h, us/retail=1294h) 00Ch 4 Number of folders (D) (demo=0Fh, us/retail=3Eh) 010h D*8 Folder List ... .. Zerofilled (padding to 800h-byte boundary) 800h F*10h File List ... .. Zerofilled (padding to 800h-byte boundary) ... .. File Data area |
000h 4 Folder ID (Random, maybe folder name checksum?) 004h 4 First file number in this folder (0=first, increasing) |
000h 4 File Offset/800h 004h 4 File Size in bytes 008h 4 Folder ID (same as Parent Folder ID in Folder List) 00Ch 4 File ID (Random, maybe file name checksum?) |
LFS: 000h N*18h File/Folder List DAT: 000h .. File data |
000h 10h Filename ("FILENAME.EXT", zeropadded)
010h 4 Offset in bytes, in BLASTO.DAT
014h 4 Size in bytes
|
000h 10h Foldername ("DIRNAME", zeropadded)
010h 4 Index to first child (at Offset=(-Index)*18h in BLASTO.LFS)
014h 4 Zero
|
000h 1 End marker, at end of root & child directories (00h or 80h) 001h 17h Unknown |
000h 4 Root ID (20001107h) 004h 4 Number of Folders (N) 008h N*0Ch Folder List ... .. Zeropadding to 800h-byte boundary ... .. Child Folder area Folder List entries: 000h 4 Offset/800h (from begin of Child Folder area) (increasing) 004h 4 Size in bytes 008h 4 Number of files in child directory |
000h 4 Child ID (20001108h) 004h 4 Number of Files (N) (same as in Folder List entry) 008h N*08h File List ... .. Zeropadding to 800h-byte boundary ... .. 1st File Data ... .. Zeropadding to 800h-byte boundary ... .. 2nd File Data ... .. Zeropadding to 800h-byte boundary ... .. etc. File List entries: 000h 4 Unknown (0 or 1 or 2) 004h 4 Size in bytes |
000h 4 Fixed ID (CCCC0067h)
004h .. Root Folder (with Name="Root",00h,FDh,FDh,FDh)
Folder Chunk format:
000h 1 Length of Name (including 4-byte padding)
001h 1 Number of Child Folders
002h 2 Number of Child Files
004h .. Name ("name",00h, CDh-padded to 4-byte boundary; Root=FDh-padded)
... .. Child File(s)
... .. Child Folder(s)
File Chunk format:
000h 1 Length of filename (including 4-byte padding)
001h 1 Filetype (see below)
002h 2 Array Size (or FFFFh for non-array filetypes)
004h 4 Filesize (SIZ) (including 4-byte padding)
008h 4 Decompressed Size (or 0=Uncompressed)
00Ch .. Filename/Symbol ("name.ext",00h, CDh-padded to 4-byte boundary)
... SIZ Data/Value (CDh-padded to 4-byte boundary)
|
"AXEL.MR\display\resolution\r3\Groups\Combined_Polyset",1Ah,01h,04h,00h "CALYPSO.MR\display\resolution\r3\Groups\Combined_Polyset",A8h,00h, CDh,CDh |
Typ Size Expl. 02h var Text String (terminated by 00h, garbage-or-00h-padded to 4-byte) 03h 8 Misc (*.IMG\textures\*) ;\ 03h 20h Misc (*.MR\display\resolution\r*\Groups\*) ; these are all 03h var Misc (*.MR\display\resolution\*List) ; filetype=03h 03h file Misc (*.MR\display\*.bit) (same as type=0Ch) ;/ 04h 4 Numeric 32bit 05h 8 Numeric 4x16bit point (X,Y,Z,CDCDh) 06h file Model (*.mod) (DOTLESS archive with model data) 0Bh 4 Numeric 32bit repeat,light 0Ch file XYWH Bitmap/Palette (*.bit, *.clt) (in GAME.IMG, MENU\menu) 0Dh 4 Numeric 32bit delay 0Eh 4 Numeric 32bit color (maybe 24bit RGB plus 00h-padding?) 0Fh 10h Whatever 10h-byte "pos" 10h file Sony .VAB file (*.vab) 12h N*1 Array? (with Arraysize=0014h) 16h N*?? Array Text Strings (with Arraysize=0001h) (in MAIN.MR\worlds) 1Ah N*10h Array Guns,startpoints (RCCAR.MR\*, NEON.MR\world) 1Bh 4 Numeric 2x16bit (X,Y) (in MENU.MR) 1Ch N*4 Array lloc (in MENU.MR\menu\screens) (with Arraysize=04h or 1Fh) 25h 8 Whatever 8-byte (in GAME.MR\dualShock) 26h N*8 Array CollideArray (in GAME.MR\dualShock) (with Arraysize=4 or 6) |
000h .. ZLIB compressed data (usually starting with big-endian 789Ch) (compression is used for almost all files, except VERY small ones) |
| CDROM File Archive HUG/IDX/BIZ (Power Spike) |
000h .. File Data |
000h 4 ID "HUGE" 004h 4 Checksum (sum of all bytes at [010h and up]) 008h 4 Number of Folders (D) (87h) 00Ch 4 Number of Files (F) (F9h) 010h D*1Ch Folder List (Folder 0..D-1) ... F*18h File List (File 0..F-1) |
000h 0Ch Folder Name ("DIRNAME", zeropadded)
00Ch 4 First Child File (or FFFFFFFFh=None)
010h 4 Number of Child Files (or 00000000h=None)
014h 4 First Child Folder (or FFFFFFFFh=None)
018h 4 Next Sibling Folder (or FFFFFFFFh=None)
|
000h 0Ch File Name ("FILENAME.EXT", zeropadded if shorter than 12)
00Ch 4 File Checksum (sum of all bytes in file added together)
010h 4 File Offset/800h in GAME.HUG
014h 4 File Size in bytes
|
000h 4 ID "BIG!" 004h 4 Number of entries (N) 008h N*1Ch File List ... .. BIZ compressed File Data |
000h 10h Filename (zeropadded) 010h 4 File Offset (increasing, unaligned, can be odd) 014h 4 File Size decompressed 018h 4 File Size compressed |
| CDROM File Archive TOC/DAT/LAY |
CD.TOC contains File/Folder entries CD.DAT contains the actual File bodies CD.LAY devkit leftover (list of filenames to be imported from PC to TOC/DAT) |
00h 4 Offset to next Sibling File/Folder/Final entry 04h 4 Filesize in bytes 08h 4 Filedata Offset/800h in CD.DAT 0Ch .. Filename (ASCII, terminated by 00h) ... .. Padding to 4-byte boundary (garbage) |
00h 4 Offset to next Sibling File/Folder/Final entry 04h 4 Filesize (always FFFFFFFFh in Folder entries) 08h 4 Offset to first File/Folder in Child directory 0Ch .. Name of Child directory (ASCII, terminated by 00h) ... .. Padding to 4-byte boundary (garbage) |
00h 4 Offset to next Sibling entry (00000000h=None)
04h 4 Filesize (FFFFFFFFh in child folders, FFFFFFFEh in root folder)
08h 4 Offset to first File/Folder in Parent directory (or to self for root)
0Ch 1 Empty Name ("",00h)
0Dh 3 Padding to 4-byte boundary (garbage)
|
| CDROM File Archive WAD (Doom) |
000h 4 ID "IWAD" (or "PWAD" for homebrew patches, or "PACK" in A.D. Cop) 004h 4 Number of File List entries (N) (including final ENDOFWAD entry) 008h 4 Offset to Directory Area (filesize-N*10h) 00Ch .. File Data area ... N*10h File List |
000h 4 Offset to file data (increasing by compressed size, 4-byte aligned) 004h 4 Filesize in bytes (uncompressed size) (zero in ENDOFWAD file) 008h 8 Filename (uppercase ASCII, zeropadded if less than 8 chars) |
@@collect_more:
flagbits=[src]+100h, src=src+1 ;8bit flags
@@decompress_lop:
flagbits=flagbits SHR 1
if zero then goto @@collect_more
if carry=0 then
[dst]=[src], dst=dst+1, src=src+1
else
disp=([src]*10h)+([src+1]/10h)+1, len=([src+1] AND 0Fh)+1, src=src+2
if len=1 then goto @@decompress_done
for i=1 to len, [dst]=[dst-disp], dst=dst+1, next i
endif
goto @@decompress_lop
@@decompress_done:
ret
|
000h 2 Number of Files (N) (usually 01h..3Eh) 002h 2*N File IDs ... .. Zeropadding to 800h-byte boundary 800h .. SPU-ADPCM Data (aka .VB files) |
| CDROM File Archive WAD (Cardinal Syn/Fear Effect) |
Old format: Without leading Header Size entry (Cardinal Syn MagDemo03: SYN\*) New format: With leading Header Size entry (eg. Fear Effect) |
if [04h]*1Ch+8 >= [00h] then OLD version |
000h (4) Header Size (including folder/type/file directories) (new version) ... 4 Number of Folders ... .. Folder List (root) ... .. Type Lists (for each folder) ... .. File Lists (for each folder\type) ... .. File Data (for each folder\type\file) Folder List Entries: 000h 14h Folder name (ASCII, zeropadded) 014h 4 Offset to Type List 018h 4 Number of different Types in this folder Type List Entries: 000h 4 Offset to file entries (of same type, eg. .TIM files) 004h 4 Number of file entries (of same type, eg. .TIM files) 008h 4 Sum of all Filesizes with that type 00Ch 4 Group Type (0000000xh) File List entries (Files within Type list): 000h 14h Name (ASCII, terminated by 00h, plus garbage padding) 014h 4 Offset to File Data (seems 4-byte aligned... always?) 018h 4 File Type (000x00xxh) 01Ch 4 Filesize in bytes ;\maybe compressed/uncompressed, or rounded, 020h 4 Filesize in bytes ;/always both same |
.BGD FileType=00000001h .ANM FileType=00000003h .TIM FileType=00000004h (GroupType=1) .SP2 FileType=00000005h .PMD FileType=00000007h .MOV FileType=00000008h .SPR FileType=0000000Ch .PVT FileType=0000000Dh .DB FileType=0000000Eh .VH FileType=00000010h (GroupType=1) ;only in OLDER demo version MagDemo03 .VB FileType=00000011h (GroupType=1) .MSG FileType=00000012h (GroupType=1) (actually, this is .TIM, too) .KMD FileType=00000013h .OC FileType=00000018h .EMD FileType=00000019h .COL FileType=0000001Bh .CF FileType=0000001Ch .CFB FileType=0000001Dh .CL FileType=0000001Eh .SPU FileType=0000001Fh (GroupType=1) ;added in newer demo version MagDemo09 .OFF FileType=00000020h (GroupType=1) ;added in newer demo version MagDemo09 .RCT FileType=00000021h ;added in newer demo version MagDemo09 |
.TIM FileType=00000000h (GroupType=1) .RMD FileType=000x0001h .DB FileType=00000002h .ANM FileType=00000003h .SYM FileType=00000004h .VB FileType=000x0008h (GroupType=1) .SEQ FileType=00000010h .BIN FileType=00000012h .SFX FileType=00000013h .VH FileType=000x0014h (GroupType=2) .TM FileType=00000015h .NRM FileType=00000017h .WPD FileType=00000018h |
| CDROM File Archive DIR/DAT (One/Viewpoint) |
Used by One (DATAFILE.BIN and DIRFILE.BIN) Used by Viewpoint (VIEW.DAT and VIEW.DIR) |
000h 60h Extension List (20h x 3-char ASCII, zeropadded if shorter than 3) 060h .. Root Directory (can contain folders and files) ... .. Child Directories (can contain files) (maybe also sub-folders?) |
In Viewpoint: "...VCSVCFBINTXTVH.VB.STRST1ST2ST3......//..." In One: "...VCTVCKSNDBINCPEINI..................//..." |
000h 1 Length of Filename and Extension index
bit7-3 File Extension Index (0..1Fh = Offset I*3 in DIR file)
bit2-0 Filename Length-1 (0..7 = 1..8 chars)
001h .. Filename in 6bit chars (N*6+7/8 bytes = 1..6 bytes for 1..8 chars)
bit7-2 1st character, whole 6bit ;\1st byte
bit1-0 2nd character, upper 2bit (if any) ;/
bit7-4 2nd character, lower 4bit (if any) ;\2nd byte (if any)
bit3-0 3rd character, upper 4bit (if any) ;/
bit7-6 3rd character, lower 2bit (if any) ;\3rd byte (if any)
bit5-0 4th character, whole 6bit (if any) ;/
bit7-2 5th character, whole 6bit (if any) ;\4th byte (if any)
bit1-0 6th character, upper 2bit (if any) ;/
bit7-4 6th character, lower 4bit (if any) ;\5th byte (if any)
bit3-0 7th character, upper 4bit (if any) ;/
bit7-6 7th character, lower 2bit (if any) ;\6th byte (if any)
bit5-0 8th character, whole 6bit (if any) ;/
bitN-0 Zeropadding in LSBs of last byte ;-zeropadding
The 6bit characters codes are:
00h..09h="0..9", 0Ah..23h="a..z", 24h="_", 25h..3Fh=Unused
... 4 Filesize and End Flag
bit31 End of Directory Flag (0=Not last entry, 1=Last entry)
bit30-0 Filesize 31bit (or 0=Child Folder)
... 4 Offset and fixed bit
bit31 Unknown (always 1)
bit30-0 File Offset in DAT file (or Folder offset in DIR file)
|
| CDROM File Archive Darkworks Chunks (Alone in the Dark) |
000h 4 ID "VRAM" 004h 4 With Tags (0=No, 1=Yes) (or "DRAM" when empty 4-byte chunk) 008h (4) Number of Tagged items (N) (0=None) ;\only when [4]=1 00Ch N*10h Tagged Item(s) ;/(not so in LEVELS\*\VIEW*) ... .. Scanline Rows(s) ... 4 End code (00000000h) (aka final Scanline Row with width=0) Tagged Item(s) (IMG, LINE, GLOW, FLARE, BALLE, BLINK, COURIER7, BMP_xxx): 000h 8 Tag (ASCII, if less than 8 chars: terminate by 00h, pad by FDh) 008h 8 Data Scanline Row(s) (bitmap scanlines and palette data): 000h 4 Header (bit0-8=Width, bit10-18=Y, bit20-29=X, bit9,19,30,31=?) 004h W*2 Data (Width*2 bytes, to be stored at VRAM(X,Y)) |
000h 4 ID "G3DB" 004h 4 Unknown (0, 1, or 2) 008h 4 Size of Data part (SIZ) 00Ch 4 Number of List entries (eg. 6 or 0Ah or 117Ch) (N) 010h SIZ Data (supposedly LibGDX models in G3DB format) ... N*4 List |
000h 4 ID "DRAM" 004h 4 Size of Data part (SIZ) (can be odd) 008h 4 Number of List entries (N) 00Ch SIZ Data (raw data, and/or tags TEXT, SPC, COURIER7) ... N*4 List |
000h 4 ID "WEAP" 004h 4 Size-10h? 008h .. Data |
000h 4 ID "HAND" 004h 4 Size-0Ch? (18h) 008h 8 Zerofilled 010h 4x4 Unknown (FFh,FF00h,xF0000h,FF3232h,FF6464h,FFDCDCh,FFFFFFh,..) 020h 4 Unknown (0, 1, 101h, or 201h) |
000h 4 ID "MIDB" 004h 1 Unknown (0 or 1) 005h 1 Number of SEQ blocks (1..4) (S) 006h 1 Number of Unknown 80h-byte blocks (1..2) (U) 007h U*80h Unknown Blocks (mostly FFh-filled) ... S*Var SEQ Block(s) ... .. VAB Block SEQ Blocks: Probably some MIDI sequence data, similar to Sony's .SEQ format. 000h 4 Size-0Ch (can be odd) 004h 8 Name (zeropadded if less than 8 chars) 00Ch 4 ID "DSEQ" ;\Size 010h .. Data ;/ VAB Blocks: Apparently inspired on Sony's .VAB format (but the ID is spelled other way around, Lists have variable size, and entries have different format). 000h 4 ID "VABp" (this is: not pBAV, unlike normal .VAB files) 004h 4 Unknown (0) 008h 4 Unknown (0) 00Ch 4 Size of all SPU-ADPCM samples (SIZ) 010h 2 Number of List 1 entries (N1) 012h 2 Number of List 2 entries (N2) 014h 2 Number of Samples (N3) 016h 6 Unused? (CCh-filled) 01Ch N1*10h List 1 ... N2*10h List 2 ... N3*2 Sample Size List (size of each SPU-ADPCM sample) ... SIZ SPU-APDCM Sample(s) |
000h 4 ID "DSND" 004h 4 Unknown (0 or 2) 008h .. VAB Block (same as in MIDB chunks, see there) |
| CDROM File Archive Blue Chunks (Blue's Clues) |
000h 4 Size of AUDD+SEPD+VABB chunks ;\for quick look-up only
004h 4 Size of all VRAM chunks ; (can be ignored by chunk crawlers)
008h 4 Size of STGE+ANIM+FRAM chunks ;/(note: sum is total filesize-0Ch)
... .. AUDD Chunk (contains .VH) ;\
... .. SEPD Chunk(s) (contains .SEP) ; sound
... .. VABB Chunk (contains .VB) ;/
... (..) VRAM Chunk(s) (not in IN\FE2.TXD) ;-textures/palettes
... (..) STGE Chunk (if any, not in IN\FE*.TXD) ;-stage data?
... (..) ANIM Chunk (if any, not in IN\FE*.TXD) ;\animation
... (..) FRAM Chunk(s) (if any, not in IN\FE*.TXD) ;/
... (..) Further groups with ANIM+FRAM Chunks (if any) ;-more animation(s)
AUDD Chunks:
000h 4 Chunk ID ("AUDD")
004h 4 Chunk Size (of whole chunk from Chunk ID and up)
008h 4 Compression Flag (0=Uncompressed)
00Ch 4 Zero
010h .. VH File (Sony Voice Header, starting with ID "pBAV")
SEPD Chunks:
000h 4 Chunk ID ("SEPD")
004h 4 Chunk Size (of whole chunk from Chunk ID and up)
008h 4 Compression Flag (0=Uncompressed)
00Ch 2 Zero
00Eh 2 Number of sequences (in the SEP sequence archive)
010h 4 Zero
014h .. SEP File (Sony Sequence archive, starting with ID "pQES")
... .. Zeropadding to 4-byte boundary
VABB Chunks:
000h 4 Chunk ID ("VABB")
004h 4 Chunk Size (of whole chunk from Chunk ID and up)
008h 4 Compression Flag (0=Uncompressed)
00Ch .. VB File (Sony Voice Binary, with raw SPU-ADPCM samples)
VRAM Chunks:
000h 4 Chunk ID ("VRAM")
004h 4 Chunk Size (of whole chunk from Chunk ID and up)
008h 4 Compression Flag (1=Compressed)
00Ch 2 VRAM.X
00Eh 2 VRAM.Y
010h 2 Width in halfwords
012h 2 Height
014h 4 Decompressed Size (Width*Height*2) ;\Texture Bitmaps 8bpp
018h .. Compressed Data ; (or Palettes, in last VRAM
... .. Zeropadding to 4-byte boundary ;/chunk)
STGE Chunks:
000h 4 Chunk ID ("STGE")
004h 4 Chunk Size (of whole chunk from Chunk ID and up)
008h 4 Compression Flag (0=Uncompressed)
00Ch .. Unknown (stage data?)
ANIM Chunks:
000h 4 Chunk ID ("ANIM")
004h 4 Chunk Size (of whole chunk from Chunk ID and up)
008h 4 Compression Flag (0=Uncompressed)
00Ch .. Unknown (animation sequence info?)
FRAM Chunks:
000h 4 Chunk ID ("FRAM")
004h 4 Chunk Size (of whole chunk from Chunk ID and up)
008h 4 Compression Flag (0=When Chunksize=14h, 1=When Chunksize>14h)
00Ch 1 Width in bytes
00Dh 1 Height
00Eh 6 Unknown, looks like three signed 16bit values (maybe X,Y,Z)?
014h (4) Decompressed Size (Width*Height*1) ;\Animation Frame Bitmap 8bpp
018h (..) Compressed Data ; (only if Chunksize>14h)
... (..) Zeropadding to 4-byte boundary ;/
|
| CDROM File Archive HED/CDF (Parasite Eve 2) |
0000h 78h Streaming List (03h entries, 28h-bytes each, all entries used) 0078h 1B00h File List (360h entries, 8 bytes each, all entries used) 1B78b 8 File List End Code (FFFFFFFFh,FFFFFFFFh) |
0000h 800h Root: Folder List (100h entries, 8-byte each, unused=zeropadded) 0800h .. 1st Folder (File/Streaming List and Data) ... .. 2nd Folder (File/Streaming List and Data) ... .. etc. |
000h 4 Folder ID (usually N*100+1 decimal, increasing, eg. 101,201,301,etc.) 004h 4 Folder Size/800h (of whole folder, with File/Stream List and Data) The Folder List ends with unused/zeropadded entries with ID/Size=00000000h. |
0000h 510h File List (A2h entries, 8-bytes each, unused=zeropadded) 0510h 4 Zero (padding to decimally-minded offset 1300 aka 514h) 0514h 2D0h Streaming List (12h entries, 28h-bytes each, unused=zeropadded) 07E4h 1Ch Zero (padding to end of sector) 0800h ... Data (for Files, Audio streams, and sometimes also Movie streams) |
000h 4 File ID (increasing, eg. 0,1,2,3,4,etc.) (or 99) (or N*100+x) 004h 4 File Offset/800h in in .CDF (from begin of current Folder) |
The offset of next File in File List (same as CurrOffset for 0-byte files) The offset of next Audio stream in Streaming List The offset of next Movie stream in Streaming List (if it's in .CDF, not .STR) The size of the current Folder (for STAGE1-5) The size of the whole .CDF file (for STAGE0) |
000h 1 Chunk Type (see below)
001h 1 End Flag (01h=More Chunks follow, FFh=Last Chunk)
002h 2 Unknown (usually 800h, sometimes 500h or 600h)
(eg. 500h in stage0\file30301\chunkX)
(eg. 600h in stage1\folder1201\file0\chunkXYZ)
004h 4 Chunk Size/800h
008h 4 Unknown (usually zero) (or 80xxxx00h in Chunk Type 0 files?)
00Ch 4 Zero (0)
010h .. Data (Chunk Size-10h bytes)
|
00h=Room package .pe2pkg 01h=Image .pe2img 02h=CLUT .pe2clut 04h=CAP2 Text .pe2cap2 05h=Room backgrounds .bs 06h=SPK/MPK music program .spk ;stereo/mono, sound/music, single/multiple? 07h=ASCII text .txt (eg. stage0\20101..20132) ;Reportedy also (but wrong): ;60h=Sounds .pe2snd (but nope, that's wrong, see below) ;60h is a MDEC movie from Streaming List (unrelated to File List chunks), ;60h is 20h-byte .STR header each 800h-bytes (occurs in "stage1\folder501") |
stage0\40105...40198 are raw hMPK files without chunks stage0\11000, 20213, 20214, 20300, .., 660800 and 900000 are empty 0-byte |
000h 2 Stream Type (0001h=Movie) 002h 2 Unknown (8000h or 0000h) 004h 4 Offset/800h in current Folder of .CDF file ;<-- used when [024h]=0 008h 4 Offset/800h in INTERx.STR file ;<-- used when [024h]>0 00Ch 2 Unknown (0000h) 00Eh 2 Stream ID (increasing, usually starting at 64h aka 100 decimal) 010h 2 Stream sub.ID (usually 0, increases +1 upon multiple same IDs) 012h 2 Picture Width (0140h = 320 decimal) 014h 2 Picture Height (00F0h = 224 decimal) 016h 2 Unknown (0000h) 018h 2 Unknown (0000h or 0018h) maybe 24bpp or 24fps 01Ah 2 Unknown (73Ah or 359h or 3DCh) (Size? but it's slighty too large?) 01Ch 6 Unknown (zero) 022h 2 Unknown (0 or 1) (often 1 when [024h]>0, but not always) 024h 2 Movie number in INTERx.STR, 1 and up? (or 0=Movie is in STAGEx.CDF) 026h 2 Unknown (0 or 1) |
000h 2 Stream Type (0002h=Audio) 002h 2 Unknown (806Ah or increasing 0133h,0134h,0135h) 004h 4 Offset/800h in STAGEx.CDF file (increasing offsets) 008h 4 Unknown (0 or 13000h or E000h) 00Ch 2 Stage Number (0..5 = STAGE0-5) 00Eh 2 Stream ID (1, or increasing 3Ah,3Bh,3Ch) 010h 4 Stream sub.ID (usually 0Bh, increases +0Ah upon multiple same IDs) 014h 2 Unknown (0 or 2B0h or 3ADh or 398h) (Size/800h minus something?) 016h 2 Unknown (usually 20h, sometimes 0Fh) 018h 4 Unknown (2 or 1) ... maybe num channels ? 01Ch 2+2 Unknown (0,0 or 800h,800h) 020h 8 Unknown (0) |
000h 800h Whatever increasing 32bit index/timing values? FFFFFFFFh=special? ;That header exists in stage0\ and stage3\folder101\ ;That header doesn't exist in all files (eg. not in stage1\folder301\) |
000h 4 Chunk Index (increases each second chunk, from 0 and up) 004h 4 Number of Chunk Indices 008h 4 Fixed (02h,"STM") ;2-channel Stream? 00Ch 1 Chunk Subindex (toggles 00h or 01h per each chunk) ;ch left/right? 00Dh 1 Chunk Size/800h 00Eh 4 Unknown (can be 00h, 01h, 11h, 20h, 21h) 00Fh 4 Unknown (can be A0h or C0h) 010h .. Data (Chunk Size-10h bytes) (looks like SPU-ADPCM audio) |
000h 0 Number of ADPCM blocks? (eg. 28h or 49h) 004h 4 Size of extra data block in bytes (eg. 13900h or 24200h) 008h 38h Zerofilled 040h 8 Zerofilled (maybe 1st sample of 1st SPU-ADPCM block) 048h .. Looks like more SPU-ADPCM block(s), terminated by ADPCM end flag(s) ... .. Zerofilled (padding to end of last 800h-byte sector) |
| CDROM File Archive IND/WAD (MTV Music Generator) |
0000h 20h Name/ID ("Music 2", zeropadded)
0020h 4 Unknown (110000h)
0024h 4 Filesize-1000h (size excluding last 1000h-byte padding)
0028h 4 Unknown (17E0h)
002Ch 4 Unknown (5)
0030h N*10h Folder List, starting with Root in first 10h-byte
2CF0h 4 Small Padding (34h-filled)
2CF4h 1000h Final Padding (34h-filled)
Folder List entries that refer to Child Folders in ECTS.IND:
000h 8 Folder Name ("EXTRA*~*", zeropadded if less than 8) ("" for root)
008h 2 Self-relative Index to first Child folder (positive)
00Ah 2 Number of Child Folders (0..7FFFh)
00Ch 4 Always 0007FFFFh (19bit Offset=7FFFFh, plus 13bit Size=0000h)
Folder List entries that refer to File Folders in ECTS.WAD:
000h 8 Folder Name ("EXTRA*~*", zeropadded if less than 8)
008h 2 Self-relative Index to Parent folder (negative)
00Ah 2 Number of Child Folders (always 8000h=None)
00Ch 4 Offset and Size in ECTS.WAD
The 32bit "Offset and Size" entry consists of:
0-18 19bit Offset/800h in ECTS.WAD
19-31 13bit Size/800h-1 in ECTS.WAD
|
There are several File Folders (at the locations specified in ECTS.IND).
The separate File Folders look as so:
000h 4 Number of files (N)
004h N*10h File List
... .. 34h-Padding to 800h-byte boundary
... .. File Data area
File List entries:
000h 8 File Name ("NAMELIST", "ACIDWO~1", etc.) (00h-padded if shorter)
008h 4 Offset/800h (always from begin of WAD, not from begin of Folder)
00Ch 4 Filesize in bytes
The first file in each folder is called "NAMELIST" and contains this:
000h 20h Long Name for Parent Folder (eg. "Backgrounds", zeropadded)
020h 20h Long Name for this Folder (eg. "Extra 1", zeropadded)
040h N*20h Long Names for all files in folder (except for NAMELIST itself)
For example, Long name for "ACIDWO~1" would be "Acidworld". Short names are
uppercase, max 8 chars, without spaces (with "~N" suffix if the long name
contains spaces or more than 8 chars). Many folder names are truncated to
one char (eg. "D" for Long name "DTex"), in such cases short names CAN be
lowercase (eg. "z" for Long name "zTrans").
The Long Names are scattered around in the NAMELIST files in ECTS.WAD file,
so they aren't suitable for lookup (unless when loading all NAMELIST's).
|
| CDROM File Archive GAME.RSC (Colonly Wars Red Sun) |
0000h 4 Offset to Bonkers List (2794h) 0004h F*8 Folder List (80h bytes, 10h entries) 0084h N*14h File List(s) for each folder (2710h bytes, 1F4h entries) 2794h 4 Number of Bonkers (FE3h) 2798h B*8 Bonkers List (7F18h bytes, FE3h entries) A6B0h 8 Unknown (zerofilled) A6B8h .. File Data area |
000h 4 Offset to File List for this folder ;\both zero when empty 004h 4 Number of Files in this folder ;/ |
000h 10h Filename ("FILENAME_EXT", zeropadded)
010h 3 Index (in Bonkers list) (000h..Fxxh)
013h 1 Folder Number where the file is stored (00h..0Fh)
|
000h 4 File Offset (to Data, inreasing, 4-byte aligned, A6B8h and up) 004h 4 Folder Number where the file is stored (00h..0Fh) |
| CDROM File Archive BIGFILE.DAT (Soul Reaver) |
000h 2 Number of Folders (175h in retail, 0Ah in demo) 002h 2 Zero 004h N*8 Folder List (8-byte per Folder) ... .. Zeropadding (to 800h-byte boundary) ... .. 1st Folder (with File List, and File Data for that folder) ... .. 2nd Folder (with File List, and File Data for that folder) ... .. 3rd Folder (with File List, and File Data for that folder) ... .. etc. |
000h 2 Unknown (somehow randomly increases from -8000h to +7E8Fh) 002h 2 Number of Files in this Folder (eg. 97h) 004h 4 Offset to Folder (usually 800h-aligned) |
000h 2 Number of Files (same value as FolderistEntry[002h]) ;\encrypted 002h 2 Zero ; by 16bit 004h N*10h File List (10h-byte per Folder) ; XOR value ... .. Zeropadding (to 800h-byte boundary) ;/ ... .. File Data for this folder ;-unencrypted |
000h 4 Unknown (random? filename hash? encrypted name?) 004h 4 File Size in bytes 008h 4 File Offset (usually 800h-aligned) 00Ch 4 Unknown (random? filename hash? encrypted name?) |
key = FileListEntry[000h] XOR FolderListEntry[002h] ;encrypted num entries key = FileListEntry[002h] ;encrypted Zero key = FileListEntry[zeropadding, if any] ;encrypted Zeropadding |
| CDROM File Archive FF8 IMG (Final Fantasy VIII) |
Offset 0000h in FF8DISCn.IMG in NTSC retail versions Offset 2800h in FF8DISCn.IMG in PAL retail versions Offset 0000h in FF8DISC1.IMG in french demo version Offset ?????h in FF8.EXE in MagDemo23 (...maybe offset 3357Ch ?) Offset 33510h in FF8.EXE in japanese demo version ? Offset 33584h in FF8.EXE in other demo versions ? |
if FF8DISCn.IMG starts with 000003xxh --> assume Root at IMG offset 0 if FF8DISCn.IMG starts with xxxxxxxxh --> assume Root at IMG offset 2800h if FF8TRY.IMG starts with "SmCdReadCore" --> assume Root somewhere in EXE |
000h N*8 File List entries ... .. Zeropadding to end of 800h-byte sector |
000h 4 ISO Sector Number (origin at 00:02:00) (unsorted, not increasing) 004h 4 Filesize in bytes |
retail.start 040005241800bf8f1400b18f1000b08f2000bd270800e00300000000 retail.end 0000010002000300 demo.start 76DF326F34A8D0B863C8C0EC4BE817F8 demo.end 0000000000000000000000000000000000100010 |
000h 4 ISO Sector Number (origin at 00:02:00) 004h 4 Filesize in bytes |
sector = NumSectors(IMG file)
@@lop:
seek(sector-1), read(buf,08h bytes)
if first4byte[buf+0]=("SMJ",01h), or ("SMN",01h) then
num_sectors=(byte[buf+5]+1)*(halfword[buf+6]+1)
sector=sector-num_sectors
AddToMovieFileList(sector, num_sectors)
goto @@lop
endif
|
000h 4 Number of Files (N) (usually 2) 004h N*8 File List ... .. File Data area |
000h 4 Offset in bytes (increasing, 4-byte aligned, see Quirk) 004h 4 File Size in bytes (can be odd) |
root sectors: 27CBh ;\ field sectors: D466h ; total known sectors: 36D13h movie sectors: 270E2h ;/ unknown sectors: 14F49h total IMG sectors: 4BC5Ch |
| CDROM File Archive FF9 IMG (Final Fantasy IX) |
000h Root Directory 800h 1st Child Folder ... 2nd Child Folder ... 3rd Child Folder ... ... 8000h ? Last folder, with Type3, contains 1FFh x increasing 16bit numbers ... Data for files in 1st Child Folder ... Data for files in 2nd Child Folder ... Data for files in 3rd Child Folder ... |
000h 4 ID "FF9 "
004h 4 Unknown (06h on Disc 1 of 4) (maybe version, or disc id?)
008h 4 Number of Folder List entries (0Fh)
00Ch 4 Unknown (01h on Disc 1 of 4) (maybe version, or disc id?)
(or Offset/800h to first file list?)
010h N*10h Folder List
... .. Padding to 800h-byte boundary ("FF9 FF9 FF9 FF9 ")
|
000h 4 FolderType (2=Normal, 3=Special, 4=Last entry) 004h 4 Number of entries in File List (0..1FFh ?) 008h 4 Offset/800h to Child Folder with File List 00Ch 4 Offset/800h to File Data (same as 1st offs in File List) (0=Last) |
000h N*8 File List entries (N=Number of files, from Root directory) N*8 8 File List END entry (ID=FFFFh, Attr=FFFFh, Offs=EndOfLastFile) ... .. Zeropadding to 800h-byte boundary |
000h 2 File ID (increasing, often decimal 0,10,100, or FFFFh=Last) 002h 2 Attr (unknown purpose, eg. 0,2,3,4,8,21h,28h,2Fh,44h,114h,FFFFh) 004h 4 Offset/800h to File Data (increasing, implies end of prev entry) |
000h N*2 File Offsets/800h, from File Data Offset in Root (or FFFFh=None) N*2 2 End Offset for last file |
IMG\DOT1 (eg. dir01\file003C) IMG\DB (eg. dir01\file2712) IMG\DB\DOT1 (eg. dir01\file2712\00-0411) IMG\DB\DOT1\DOT1 (eg. dir01\file2712\00-0443\*) IMG\DB\DB (eg. dir03\file2328\1B-000*) |
dir00 - Status/Menu/Battle/... -Text and random stuff. dir01 - Misc Images (Logos, Fonts, World 'mini' Map images, etc). dir02 - Dialog Text dir03 - Map models (Mini-zidane, airships, save point moogle, tent...) dir04 - Field models dir05 - Monster Data (Part I, stats, names, etc). dir06 - Location Data (Dungeon, Cities, etc). dir07 - Monster Data (Part II, 3d models) dir08 - Weapon Data (including models) dir09 - Samplebanks and Sequencer Data (ie music). dir0A - party members Data (including models) dir0B - Sound effects dir0C - World Map Data dir0D - Special effects (magic, summons...) |
| CDROM File Archive GTFS (Gran Turismo 2) |
000h 4 ID "GTFS" ;\ 004h 4 Zero ; 008h 2 Number of 4-byte File Offset List entries (N) ; File(0) 00Ah 2 Number of 20h-byte File/Folder Name List entries (F) ; 00Ch 4 Zero ; 010h N*4 File Offset List (see below) ;/ ... .. Zeropadding to 800h-byte boundary ... F*20h File/Folder Name List (see below) ;-File(1) ... .. Zeropadding to 800h-byte boundary ... .. File Data ;-File(2) ... .. Zeropadding to 800h-byte boundary ... File Data ;-File(3) ... .. ... ... File Data ;-File(N-2) ... .. Zeropadding to 800h-byte boundary EOF 0 End of File ;-File(N-1) |
File(0) and File(1) = Directory information File(2)..File(N-2) = Regular data files File(N-1) = Offset List entry points to the end of .VOL file |
Bit0-10 = Number of padding bytes in last sector of this file (0..7FFh) Bit11-31 = Offset/800h to first sector of this file (increasing) To compute the filesize: Size=(Entry[N+1] AND FFFFF800h)-Entry[N] |
000h 4 Unknown (379xxxxxh) (maybe timestamp?)
004h 2 When Flags.bit0=0: Index of File in File Offset List (2 and up)
When Flags.bit0=1: Index of first child in Name List, or...
When Flags.bit0=1: Index of 1st? parent in Name List (Name="..")
006h 1 Flags (bit0:0=File, 1=Directory; bit7:1=Last Child entry)
007h 19h Name (ASCII, zeropadded)
|
size=gz_filesize size=size-GzipHeader(including ExtraHeader, Filename, Comment, HeaderCrc) size=size-GzipFooter(8) ;initially assuming 8-byte footer (without padding) i=gz_filesize-4 @@search_footer: if buf[i]<size then i=i-1, size=size-1 goto @@search_footer decompressed_size = buf[i] |
| CDROM File Archive Nightmare Project: Yakata |
CD.IMG 550Mbyte Contains file 004h..FFFh CDRTBL.DAT 32Kbyte Alias for file 000h (File List for file 000h..FFFh) FDTBL.DAT 2Kbyte Alias for file 001h (Folder List and Disc ID) SLPS_010.4* 500Kbyte Alias for file 003h (Boot EXE) SYSTEM.CNF 72bytes Alias for file 002h (Boot Info) XXXXXXXX. 27Mbyte Padding (zerofilled) |
FDLTBL.DAT seems to be used to divide the file list in CDRTBL.DAT into separate folders. The Folder List entries are containing the first file number for each folder. Empty folders have same file number as next entry. The last folder contains the specified file number plus all remaining files. 000h 56h*2 Folder List (16bit File Numbers, increasing from 0004h to 0xxxh) 0ACh 748h Zerofilled 7F4h 0Ah Game ID (ASCII "SLPS1045",00h,00h; always so on Disc 1..3) 7FEh 2 Disc ID (1..3 = Disc 1..3) |
000h 8000h File List (1000h x 8-byte entries)
File List entries:
000h 4 Sector (MM:SS:FF:00 in BCD, increasing) ;\all zero for
004h 2 Size1 (NumFramesCh1 or NumSectors) ; unused entries
006h 2 Size0 (NumFramesCh0 or Zero) ;/
The meaning of the Size entries depends on the file type:
Normal binaries: [004h]=NumSectors [006h]=0 (1 channel)
XA-ADPCM streams: [004h]=NumSectors-50h [006h]=0 (16 channels)
MDEC streams: [004h]=NumFrames [006h]=0 (audio+video)
Special streams: [004h]=NumFramesCh1 [006h]=NumFramesCh0 (2 channels)
To determine the actual filesize, one must compute the difference between
sectors for current and next used file entry (or end of CD.IMG for last file;
or alternately assume last file to be a Normal Binary with Size=NumSectors).
Normal Binaries:
Contains single files (file=0/channel=0). Filetypes include TIM, VB, VH,
other/custom file formats, and DOT1 archives.
The DOT1 archives have 4-byte aligned offsets, but, unconventionally, with
some offsets set to ZERO (usually the last entry, and sometimes also other
entries):
SEQ files (Disc1:Dir08h\File173h) ;with ZERO entries (=uncommon)
SEQ files (Disc1:Dir09h\File176h..3D7h) ;with ZERO entries (=uncommon)
SEQ files (Disc1:Dir0Ah\File3DAh..3E6h) ;with ZERO entries (=uncommon)
TIM files (Disc1:Dir4Fh\File962h..983h) ;with ZERO entries (=uncommon)
TIM files (Disc1:Dir0Ch\File414h..426h) ;without ZERO entries (=normal DOT1)
XA-ADPCM Streams (Disc1:Dir0Bh\File3E7h..413h):
These contain 16 audio streams (file=1/channel=00h-0Fh). The Size entry is
set to total size in sectors for all streams, minus 50h (ie. there appears
to be 50h sectors appended as padding before next file).
MDEC Streams (Disc1:Dir53h\FileBD1h..BEBh):
These are standard STR files with MDEC video (file=0/channel=1) and
XA-ADPCM (file=1/channel=1). There are 10 sectors per frame (8-9 video
sectors plus 1-2 audio sectors). The total filesize is NumFrames*10+Align(8)
sectors; the Align(8) might be there to include one final audio sector.
Special Streams (Disc1:Dir07h\File0E9h-16Eh and Dir50h\File985h..B58h):
These are custom STR files (non-MDEC format), perhaps containing Polygon
streams or whatever.
There are two channels (file=1/channel=00h-01h), each channel contains
data that consists of 5 sectors per frame (1xHeader plus 4xData).
The sectors have STR ID=0160h, and STR Type as follows:
0000h=Whatever special, channel 0 header (sector 0)
0400h=Whatever special, channel 1 header (sector 1)
0001h=Whatever special, channel 0 data (sector 2,4,6,8)
0401h=Whatever special, channel 1 data (sector 3,5,7,9)
The File List size entries contain Number of Frames for each channel (either
of these entries may be zero, or bigger/smaller/same than the other entry).
The smaller channel is padded to same size as bigger channel (ie. total
filesize is "max(NumFramesCh0,NumFramesCh1)*10 sectors"; though that formula
doesn't always hold true, for example, Disc1:Dir50h\FileA2Dh and FileB1Bh
are bigger or smaller than expected).
|
| CDROM File Archive FAdj0500 (Klonoa) |
FILE.IDX 000h 8 ID "FAdj0500" 008h 38h RAM addresses (80xxxxxxh, 0Ch words) 038h 4 Zero 03Ch 4 RAM address (80xxxxxxh) 040h N*10h File List (including Folder start/end markers) FILE.BIN 000h .. File Data area (split into filesizes from FILE.IDX) |
Type 0 (Folder End): 000h 4 Type (0=Folder End) 000h 4 Zero 008h 4 RAM address (always 801EAF8Ch) 00Ch 4 Zero Type 1.a (Folder Start): 000h 4 Type (1=Folder Start) 000h 4 Folder Offset/800h (offset of FIRST file in this Folder) 008h 4 RAM address (always 801EAF8Ch) 00Ch 4 Folder Size/800h (size of ALL files in this Folder) Type 1.b (Force Offset, can occur between Files within a Folder): 000h 4 Type (1=Same as Folder Start) 000h 4 Folder Offset/800h (offset of NEXT file in this Folder) 008h 4 RAM address (always 801EAF8Ch) 00Ch 4 Folder Size/800h (zero for Force Offset) Type 2 (File entries, within Folder Start/End): 000h 4 Type (2=File) 004h 4 Filesize in bytes (4-byte aligned?) 008h 4 RAM address 1 (80xxxxxxh, or zero) 00Ch 4 RAM address 2 (80xxxxxxh) |
| CDROM File Archives in Hidden Sectors |
Sector 10h (00:02:16) Volume Descriptor (CD001) ;\ Sector 11h (00:02:17) Volume Terminator (CD001) ; Sector 12h (00:02:18) Path Table 1 ; Sector 13h (00:02:19) Path Table 2 ; standard ISO Sector 14h (00:02:20) Path Table 3 ; Sector 15h (00:02:21) Path Table 4 ; Sector 16h (00:02:22) Root Directory ;/ Sector 17h (00:02:23) Hidden ID ;\ Sector 18h (00:02:24) Hidden Directory ; hidden directory Sector .. (00:02:xx) Hidden Unknown ;/ Sector .. (00:02:xx) Hidden Files... (referenced via Hidden Directory) |
Sector 17h (Hidden.ID)
000h 0Eh ID ("DS01_XENOGEARS"=Disc 1, or "DS02_XENOGEARS"=Disc 2)
00Eh 7F2h Zerofilled
Sector 18h..27h
000h N*7 File List entries
Sector 28h (Hidden.Unknown)
Seems to contain a list of 16bit indices 0000h..1037h,FFFFh in File List
(that, as raw list indices, regardless of the directory structure)
000h Unknown 0016 0018 FFFF FFFF 01A8 FFFF FFFF FFFF ;\
010h Unknown FFFF FFFF FFFF FFFF 0A35 0A3A 0D35 0AD3 ; as so on Disc 2
020h Unknown 0A22 0A2E 0A2F FFFF FFFF FFFF FFFF FFFF ; (values<>FFFFh
030h Unknown 0014 0001 0013 FFFF 0075 FFFF FFFF FFFF ; on Disc 1
040h Unknown 0C10 0C14 0C15 0C19 0F52 FFFF FFFF FFFF ; are 5 less, eg.
050h Unknown 0F4C 0B6E 0C4D 1037 0C09 0BAD FFFF FFFF ; 0011,0013,FFFF..)
060h Unknown 002E 0034 FFFF FFFF FFFF FFFF FFFF FFFF ;
070h Unknown FFFF FFFF FFFF FFFF ;/
078h 2 Disc Number (0001h=Disc 1, 0002h=Disc 2)
07Ah 786h Zerofilled
Sector 29h 1st file
|
000h 3 24bit Offset (increasing sector number, or 0=special) 003h 4 32bit Size (filesize in bytes, or negative or 0=special) |
offset=curr, size=+N file at sector=curr, size N bytes offset=curr, size=-N begin of sub-directory, with N files offset=curr, size=0 empty file, size 0 bytes offset=0, size=0 unused file entry offset=FFFFFFh, size=0 end of root-directory |
Sector 17h (Hidden.ID)
000h 2 Disc Number (0001h=Disc 1, 0002h=Disc 2)
002h 2 Number of Discs? (0002h) (always 2, even if only 1 disc)
004h 2+2 Sector and Size for Hidden.ID (Sector=0017h, Size=002Ch)
008h 2+2 Sector and Size for Hidden.Directory (Sector=0018h, Size=60E0h)
00Ch 2+2 Sector and Size for Hidden.Unknown (Sector=0025h, Size=0022h)
010h 10h Zerofilled
020h 0Ch Title ID ("CHRONOCROSS",00h) ;Chrono Cross (retail)
09h Title ID ("DEWPRISM",00h) ;Threads of Fate (retail)
10h Title ID ("DEWPRISM_TAIKEN",00h) ;Threads of Fate (demo)
0xxh 7xxh Zerofilled (unused, since Hidden.ID has only Size=2Ch/29h/30h)
Sector 18h..24h (Hidden.Directory)
000h N*4 File List entries
... .. Zeropadding (till Size=60E0h, aka 6200 entries)
... 720h Zeropadding (till end of 800h-byte sector)
Sector 25h (Hidden.Unknown)
Seems to contain a list of 16bit indices 0000h..1791h,FFFFh in File List
(though many of the listed indices are unused file list entries)
000h 2 Disc Number (0001h=Disc 1, 0002h=Disc 2)
002h 10h Unknown 0000 1791 1777 1775 00ED 09DF FFFF 0002 ;\same on
012h 10h Unknown 0025 0943 10E3 FFFF FFFF 0C77 0FD9 0FA3 ;/Disc 1+2
022h .. Zerofilled (unused, since Hidden.ID has only Size=0022h)
Sector 26h 1st file (same as boot EXE in ISO)
|
0-22 Sector number 23 Flag (0=Normal, 1=Unused entry) 24-31 Number of unused bytes in last sector, div8 (0..FFh = 0..7F8h bytes) |
filesize = ([addr+4]-[addr] AND 7FFFFFh)*800h - ([addr+3] AND FFh)*8 |
TOF\DEWPRISM.HED (6000h bytes) VirtSector=1Ah, PhysSector=A0A5h TOF\DEWPRISM.EXE (97800h bytes) VirtSector=26h, PhysSector=A0B1h TOF\DEWPRISM.IMG (19EA800h bytes) VirtSector=155h, PhysSector=A1E0h |
| CDROM File Archive HED/DAT/BNS/STR (Ape Escape) |
000h 52Ch List for .DAT file ;value 0000h..6FFFh = sector 0..6FFFh in DAT 52Ch D4h Zerofilled 600h C4h List for .BNS file ;value 7000h..71AFh = sector 0..1AFh in BNS 6C4h 3Ch Zerofilled 700h 50h List for .STR file(s) ;raw CDROM sector numbers from 00:02:00 750h B0h Zerofilled |
0-19 File Offset/800h (20bit) 20-31 File Size/800h (12bit) |
.HED is 2048 bytes .DAT is 58720256 bytes = 3800000h bytes ;div800h would be 7000h .BNS is 884736 bytes = D8000h bytes ;div800h would be 1B0h .STR's: 7D3Bh+150 = 7DD1h = sector for STR\LAB.STR |
| CDROM File Archive WAD.WAD, BIG.BIN, JESTERS.PKG (Crash/Herc/Pandemonium) |
000h N*8 File List ... .. Zeropadding to 4-byte or 800h-byte boundary (or garbage padding) ... .. File Data... |
000h 4 Offset in bytes (4- or 800h-byte aligned, increasing) ;\both zero 004h 4 Size in bytes (always multiples of 800h bytes) ;/when Unused |
000h 4 ID ("PWF ") ;\
004h 4 Total Filesize (707800h) ;
008h 4 Unknown (1) ; extra stuff
00Ch 4 Number of files (N) ;
010h 7F0h Zerofilled ;/
800h N*8 File List ;\
... .. Zerofilled (padding to 800h-byte boundary) ; standard WAD.WAD
... .. File Data area ;/
File List entries:
000h 4 File Offset in bytes (increasing, 800h-byte aligned)
004h 4 File Size in bytes
|
000h N*8 File List ... .. ASCII string (junk, but somewhat needed as nonzero end marker) ... .. Zeropadding to 800h-byte boundary; not in 4-byte aligned nested PKG ... .. File Data... |
000h 4 Offset in bytes (increasing, or 0=First child) ;\both FFFFFFFFh 004h 4 Size in bytes (always nonzero) ;/when Unused |
Example 00003800h,00000666h ;root00h (file 666h bytes, padded=800h) 00004000h,00000300h ;root01h\.. (folder 300h bytes, padded=800h) 00000000h,000000FDh ;root01h\child00h (file FDh bytes, padded=100h) ;\300h FFFFFFFFh,FFFFFFFFh ;root01h\child01h (unused) ; byte 00000100h,000001FDh ;root01h\child02h (file 1FDh bytes, padded=200h) ;/ 00004800h,00001234h ;root02h (file 1234h bytes, padded=1800h) 00006000h,00001234h ;root03h (file 1234h bytes, padded=1800h) FFFFFFFFh,FFFFFFFFh ;root04h (unused) 00007800h,00001234h ;root05h (file 1234h bytes, padded=1800h) etc. |
| CDROM File Archive BIGFILE.BIG (Gex) |
000h 4 Number of Files (eg. F4h) 004h 0Ch Zero 010h N*10h File entries ... 4 Archive ID (eg. 00000000h, FF53EC8Bh, or 83FFFFFFh) ... .. Zeropadding to 800h byte boundary ... .. File Data |
000h 4 Archive ID (same value as in above header) 004h 4 Filename checksum or so (randomly ordered, not increasing) 008h 4 Filesize in bytes 00Ch 4 Fileoffset (800h-byte aligned) (increasing) |
looks like a lot of raw data without meaningful file headers... file C3h,ECh are raw SPU-ADPCM file 08h,09h are nested BIG archives, but with FileEntry[00h]=FF53EC8Bh file D9h,DAh are nested BIG archives, but with FileEntry[00h]=83FFFFFFh |
| CDROM File Archive BIGFILE.DAT (Gex - Enter the Gecko) |
000h 4 Number of Files (C0h) 004h N*18h File entries ... .. Zeropadding to 800h byte boundary ... .. File Data |
000h 4 Random 004h 4 Filesize in bytes (uncompressed size) 008h 4 Filesize in bytes (compressed size, or 0=uncompressed) 00Ch 4 Fileoffset (800h-byte aligned) (increasing, unless UNSORTED) 010h 4 Random 014h 4 Random (or ascii in 1st file) |
@@collect_more:
flagbits=[src]+[src+1]*100h+10000h, src=src+2 ;16bit flags, unaligned
@@decompress_lop:
if dst>=dst.end then goto @@decompress_done
flagbits=flagbits SHR 1
if zero then goto @@collect_more
if carry=0 then
[dst]=[src], dst=dst+1, src=src+1
else
len=([src] AND 0Fh)+1), disp=([src] AND 0F0h)*10h+[src+1], src=src+2
if len=1 or disp=0 then goto invalid ;weirdly, these are left unused
for i=1 to len, [dst]=[dst-disp], dst=dst+1, next i
endif
goto @@decompress_lop
@@decompress_done:
ret
|
standard TIM (eg. file 01h,02h) malformed TIM (eg. file 0Fh,14h) (with [8]=2*cx*cy+4 instead 2*cx*cy+0Ch) crippled VAB (eg. file 0Eh,13h) (with hdr=filesize-4 plus raw ADPCM samples) several DNSa (eg. file 0Dh,12h,17h,BCh) SND sound? (also used by kain) PMSa (eg. Gex 3, World Racing) (SMP spu-adpcm samples) there seem to be no nested DAT files inside of the main DAT file |
| CDROM File Archive FF9 DB (Final Fantasy IX) |
000h 1 ID (DBh) 001h 1 Number of Types 002h 2 Zero (0) 004h N*4 Type List ... .. File Lists & File Data for each Type |
000h 3 Offset to File List (self-relative, from current entry in Type List) 003h 1 Data Type (00h..1Fh) |
000h 1 Data type (00h..1Fh) (same as in Type List) 001h 1 Number of Files 002h 2 Zero (0) 004h N*2 File ID List (unique ID per type) (different types may have same ID) ... .. Zeropadding to 4-byte boundary ... N*4 Offset List (self-relative, from current entry in Offset List) ... 4 End Offset (first-relative, from first entry in Offset List) ... .. File Data (referenced from above Offset List) |
00h Misc (DOT1 Archives, or other files) 01h Unused? 02h Reportedly 3D Model data (vertices,quads,triangles,texcoords) 03h Reportedly 3D Animation sequences 04h TIM Texture 05h Reportedly Scripts (hdr="EV") (eg. dir04\file32\1B-0001) 06h ? (eg. dir02\file*) 07h Sound "Sequencer Data" (hdr="AKAO") (eg. dir09\file*) 08h Sound? tiny files (hdr="AKAO") (eg. dir04\file32\1B-0001) 09h Sound Samples (hdr="AKAO") (eg. dir0B\file*) 0Ah Reportedly Field Tiles and Field Camera parameters 0Bh Reportedly Field Walkmesh (eg. dir04\file32\1B-0001) 0Ch Reportedly Battle Scene geometry (eg. dir06\file*) 0Dh ? (eg. dir01\file01) 0Eh Unused? 0Fh Unused? 10h ? (eg. dir05\file*) 11h ? (eg. dir05\file*) 12h Reportedly CLUT and TPage info for models (eg. dir04\file32\1B-0001) 13h Unused? 14h ? (eg. dir05\file*) 15h Unused? 16h ? (eg. dir04\file32\1B-0001) 17h ? (eg. dir04\file32\1B-0000) 18h Sound (hdr="AKAO") (eg. dir04\file32\1B-0001) 19h ? (eg. dir04\file32\1B-0001) 1Ah ? (eg. dir06\file*) 1Bh DB Archives (ie. further DB's nested inside of the parent DB archive) 1Ch ? (eg. dir04\file32\1B-0001) 1Dh ? (eg. dir03\file2328\1B-0001) 1Eh ? (eg. dir04\file32\1B-0001) 1Fh ? (eg. dir04\file32\1B-0001) 20h..FFh Unused? |
| CDROM File Archive Ace Combat 2 and 3 |
ACE2.DAT Directory for Data in ACE2.DAT itself ;normal binary data ACE2.STH Directory for Data in separate ACE2.STP file ;streaming data |
000h 4 Unknown (1) 004h 4 Number of entries (N) 008h N*8 File List |
0-27 28bit Size/N (DAT=Size/4, STP=Size/800h) 28-31 4bit Type or Channel Number (see below) 32-63 32bit Offset/800h in ACE2.STP or ACE2.DAT file |
File Bit28-31 Channel Sector types... Interleave Notes DAT 0 ch=0 DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD 1:1 data (normal) DAT 2 ch=0 DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD 1:1 data (exe) STH 0-6 ch=0-6 S.......S.......S.......S....... 1:8 stereo STH 8 ch=1 vvvvvvvSvvvvvvvSvvvvvvvSvvvvvvvS 1:1 video+stereo Whereas D=data, S=Stereo/Audio, v=video, .=other channels |
ACE.BPH Directory for Data in separate ACE.BPB file ;normal binary data ACE.SPH Directory for Data in separate ACE.SPB file ;streaming data |
000h 4 ID "AC3E" (=Ace Combat 3 Electrosphere) 004h 4 Type (BPH=3=Data?, SPH=1=Streaming?) 008h 2 BCD Month/Day? (Japan=0427h, US=1130h) 00Ah 2 BCD Year (or zero) (SPH=1999h, BPH=0) 00Ch 4 Unknown (SPH=0, BPH/US=16CFh or BPH/JP=1484h) 010h 4 Number of entries (N) 014h N*8 File List |
0-18 19bit Size/N (BPH=Size/4, SPB=Size/800h) 19-23 5bit Channel Number (BPH=0, SPH=0..1Fh) 24-26 3bit Channel Interval (BPH=0, SPH=1 SHL N, eg. 3=Interval 1:8) 27 1bit Video Flag (0=No, 1=Has Video sectors) 28 1bit Audio Flag (0=No, 1=Has Audio sectors) 29 1bit Always 1 (except special entries with Bit31=0, see below) 30 1bit Unknown (US: Always 1, Japan: 0 or 1) 31 1bit Always 1 (except special entries with Bit31=0, see below) 32-63 32bit Offset/800h in ACE.BPB or ACE.SPB file (or 0 when bit31=0 ?) |
For unknown purpose, the normal entries with Bit31=1 are occassionally followed by one or more entries with Bit31=0. Unknown if those entries do affect the actual storage (like switching to different channel numbers, or jumping to non-continous sector numbers). That unknown stuff exists in Japanese version only, not in US version. 0-18 19bit Unknown (maybe some snippet size value in whatever units?) 19-23 5bit Always 0 (instead of Channel) 24-27 4bit Same as in most recent entry with Bit31=1 28-31 4bit Always 5 (instead of Flags) 32-63 32bit Always 0 (instead of Offset) |
File Bit24-31 Sector types... Interval Content BPH.US E0h DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD 1:1 data SPH.US F8h SvvvvvvvSvvvvvvvSvvvvvvvSvvvvvvv 1:1 stereo+video SPH.US FBh S.......v.......S.......v....... 1:8 stereo+video SPH.US F3h S.......S.......S.......S....... 1:8 stereo SPH.US F4h S...............S............... 1:16 stereo SPH.US F5h M............................... 1:32 mono BPH.JAP E0h DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD 1:1 data SPH.JAP B8h,F8h SvvvvvvvSvvvvvvvSvvvvvvvSvvvvvvv 1:1 stereo+video SPH.JAP B9h Svvv....vvvv....Svvv....vvvv.... 1:2 (4:8) stereo+video SPH.JAP BAh,FAh Mv......vv......vv......vv...... 1:4 (2:8) mono+video SPH.JAP BBh,FBh S.......v.......S.......v....... 1:8 stereo+video SPH.JAP B3h,F3h S.......S.......S.......S....... 1:8 stereo SPH.JAP B5h,F5h M............................... 1:32 mono Whereas D=data, S=Stereo/Audio, M=Mono/Audio, v=Video, .=Other channels |
| CDROM File Archive NSD/NSF (Crash Bandicoot 1-3) |
v0 Crash Bandicoot Prototype (oldest known prototype from 08 Apr 1996) v1 Crash Bandicoot 1 (retail: S*\*.NSD and .NSF) v2 Crash Bandicoot 2 (MagDemo02: CRASH\S0\*.NSD and .NSF) v3 Crash Bandicoot 3 Warped (MagDemo26,50: (S0\*.NSD and .NSF) |
____________________________________ NSD _____________________________________ |
0000h 100h*4 Lookup Table, using index=((Filename/8000h) AND FFh) ;\ 0400h 4 Number of Chunks in .NSF file ; Lookup 0404h 4 Number of Files in Lookup File List (N) ;/ 0408h 4 Level Data Filename (eg. 4F26E8DFh="DATh.L") ;-LevelDat 040Ch 4 Bitmap Number of Colors (100h) (P) (0=None) ;\ 0410h 4 Bitmap Width (200h or 1B0h) (X) (0=None) ; Bitmap 0414h 4 Bitmap Height (0D8h or 090h) (Y) (0=None) ;/ 0418h 4 Compression: Offset/800h of first uncompressed chunk ;\ 041Ch 4 Compression: Number of compressed chunks (0..40h) ; Compress 0420h 40h*4 Compression: Compressed Chunk List (0=unused entry) ;/ ... N*8 Lookup File List ;-Lookup ... .. Level Data (size/format varies, see below) ;-LevelDat ... P*2 Bitmap Palette (16bit values, 8000h..FFFFh) ;\Bitmap ... X*Y Bitmap Pixels (0D8h*200h) ;/ |
v0 NSD Filesize=408h + N*8 ;-Lookup only v1 NSD Filesize=520h + N*8 + P*2+X*Y + 210h ;\ v2 NSD Filesize=520h + N*8 + P*2+X*Y + 1DCh+S*18h ; with extra stuff v3 NSD Filesize=520h + N*8 + P*2+X*Y + 2DCh+S*18h ;/ |
Lookup File List entries (indexed via Lookup Table): 00h 4 Chunk Number in .NSF file 04h 4 Filename (five 6bit characters) |
0 Type (always 1=Filename) (as opposed to 0=Memory Pointer) 1-6 5th character ;-Extension ;\character set is: 7-12 4th character ;\ ; 00h..09h="0..9" 13-18 3rd character ; Name ; 0Ah..23h="a..z" 19-24 2nd character ; ; 24h..3Dh="A..Z" 25-30 1st character ;/ ;/3Eh..3Fh="_" and "!" 31 Always zero? |
Level Data in NSD v1 (or NSF v0 file DAT*.L):
000h 4 01h ;\
004h 4 Level Number (xxh) (same as xx in S00000xx.NSD/NSF) ;
008h 4 3807C8FBh = "s0_h.Z" ? ; LevelDat
00Ch 4 Zero ; v1
010h 4 Zero ;
014h L*4 Namelist (40h*4) ;
... 4 5Ah ;
... F8h Zerofilled ;/
Level Data in NSD v2-v3:
000h 4 Number of Spawn Points (S) ;\
004h 4 Zero ;
008h 4 Level Number (xxh) (same as xx in S00000xx.NSD/NSF) ; LevelDat
00Ch 4 Number of Objects? (can be bigger than below list) ; v2/v3
(eg. 1BDh or A5h or E4h) ;
010h L*4 Namelist for Objects? (v2=40h*4, or v3=80h*4) ;
... 4 Unknown, always 5Ah (maybe just list end marker?) ;
... C8h Zerofilled ;
... S*18h Spawn Points ;/
|
Compressed Chunk List entries at [420h..51Fh]: 0-5 Compressed Chunk Size/800h (1..1Fh=800h..F800h bytes, 20h..3Fh=Bad?) 6-31 Compressed Chunk Offset/800h |
____________________________________ NSF _____________________________________ |
N*8Kbyte-Compressed-chunks: 000h 2 ID, always 1235h (instead of 1234h) 002h 2 Zero 004h 4 Decompressed Size (max 10000h) (usually 9xxxh..Fxxxh, often Fxxxh) 008h 4 Skip Size (max 40h or so, when last LZSS_len was 40h) 00Ch .. Compressed data ... SK Unused (Skip size) ... .. Final uncompressed bytes (10000h-compressed_size-skip_size) 64Kbyte-Texture-chunks: 000h 2 ID, always 1234h 002h 2 Chunk Family (1=Texture) 004h 4 Filename (five 6bit characters) 008h 4 File Type (5=Texture) 00Ch 4 Checksum (sum of bytes ar [0..FFFFh], with initial [0Ch]=00000000h) 010h ... Zerofilled 020h ... Texture data (raw VRAM data, FFE0h bytes?) 64Kbyte-NonTexture-chunks: 000h 2 ID, always 1234h 002h 2 Chunk Family (0=Misc or 2..5=Sound) 004h 4 Chunk Number*2+1 008h 4 Number of Files (N) (can be 0, eg. prototype S0000003 chunk21h) 00Ch 4 Checksum (sum of bytes ar [0..FFFFh], with initial [0Ch]=00000000h) 010h N*4 File List (Offsets from ID=1234h to entries) (4-byte aligned) ... .. Offset for end of last File ... .. File Data (NSF Child Archives) (includes Type/Filename) ... .. Padding to 10000h-byte boundary |
000h 4 ID, always 0100FFFFh 004h 4 Filename (five 6bit characters) 008h 4 File Type (01h..04h, or 06h..15h) 00Ch 4 Item Count (I) 010h I*4 Item List (Offsets from ID=0100FFFFh to items) (...unaligned?) ... .. Offset for end last item ... .. Data (Items) |
dst=chunk_buffer_64kbyte
if chunksize is known (from NSD file)
src=dst+10000h-chunksize
diskread(fpos,src,chunksize)
else (when parsing raw NSF file without NSD file)
src=temp_buffer_64kbyte
diskread(fpos,src,10000h)
dst_start=dst, src_start=src
if halfword[src+00h]<>1234h then ;check ID (1234h=raw, or 1235h=compressed)
dst_end=dst+word[src+04h]
skip_size=word[src+08h]
src=src+0Ch
while dst<dst_end
x=[src], src=src+1
if x<80h then
for i=0 to x-1, [dst]=[src], dst=dst+1, src=src+1, next i ;uncompressed
else
x=(x AND 7Fh)*100h+[src], src=src+1
disp=x/8, len=(x AND 7)+3, if len=0Ah then len=40h
for i=0 to len-1, [dst]=[dst-disp], dst=dst+1, next i ;compressed
src=src+src_skip
if src<>dst then
while dst<dst_start+10000h, [dst]=[src], dst=dst+1, src=src+1 ;uncompressed
chunksize=src-src_start ;<-- compute (when chunksize was unknown)
fpos=fpos+chunksize ;<-- fileposition of next chunk
|
_________________________________ Filetypes __________________________________ |
Typ Family Ext Ver Name Description 00h - ! - NONE Nothing 01h 0 V all SVTX Misc.Vertices 02h 0 G all TGEO Misc.Model ;\changed format in v2-v3 ? 03h 0 W all WGEO Misc.WorldScenery ;/ 04h 0 S all SLST Misc.UnknownSLST 05h 01h T all TPAG Texture.VRAM 06h 0 L v0 LDAT Misc.LevelData ;-stored in NSD in v1-v3 07h 0 Z all ZDAT Misc.Entity ;-changed format in v2-v3 ? 08h - - - CPAT Internal? 09h - - - BINF Internal? 0Ah - - - OPAT Internal? 0Bh 0 C all GOOL Misc.GoolBytecode 0Ch 02h A v0 ADIO OldSound.Adpcm ;\type 0Ch 0Ch 03h A all ADIO Sound.Adpcm ;/ 0Dh 0 M all MIDI Misc.MidiMusic ;-changed format in v1-v3 ? 0Eh 04h N all INST Sound.Instruments 0Fh 0 D v0-1 IMAG Misc.UnknownIMAG ;\type 0Fh 0Fh 0 X v2-3 VCOL Misc.UnknownVCOL ;/ 10h - - - LINK Internal? 11h 0 P v0-1 MDAT Misc.UnknownMDAT ;\type 11h 11h 0 R v3 RAWD Misc.UnknownRAWD ;/ 12h 0 U v0-1 IPAL Misc.Unknown ;-Crash 1 only? (eg. S0000019.NSF) 13h 0 B v1-3 PBAK Misc.DemoPlayback ;-eg. in MagDemo02 14h 0 V v0-1 CVTX Misc.UnknownCVTX ;\type 14h 14h 05h O v2-3 SDIO Speech.Adpcm ;/ 15h 0 D v2-3 VIDO Misc.UnknownVIDO |
| CDROM File Archive STAGE.DIR and *.DAT (Metal Gear Solid) |
File MagDemo13/44 MagDemo25 Retail/PAL .EXE 9C000h 9C800h 9D800h ;-executable STAGE.DIR 590800h 11A7800h 42AE000h ;-main archive FACE.DAT 2CA000h 3Dh (txt) 358800h ;-face animation archive ZMOVIE.STR - - 2D4E800h ;-movie archive DEMO.DAT 149B000h 3Dh (txt) EC20000h ;\DAT/SYM combos (the .SYM DEMO.SYM 88h - - ; files were leaked in VOX.DAT 14F2000h 9F800h B054800h ; MagDemo13/MagDemo44 only) VOX.SYM 988h - - ;/ BRF.DAT - 66800h 575800h ;\whatever, unknown format(s) RADIO.DAT 16CB8h 3Dh (txt) 1AA956h ;/ |
000h 4 Size of File List (N*0Ch) 004h N*0Ch Folder List ... .. Zeropadding to 800h-byte boundary ... .. Folder Data Folder List entries: 000h 8 Foldername (zeropadded if less than 8 chars) ;nickname=stg 008h 4 Offset/800h to File List Folder Data (per folder): 000h 2 Unknown (always 1) (maybe File List size/800h?) 002h 2 Folder Size/800h (of whole folder, with file list plus file data) 004h N*8 File List ... Zeropadding to 800h-byte 800h Data (for files in current folder) File List entries: 000h 2 File ID (checksum on name) 002h 1 File Family (one of following chars: "cnrs") 003h 1 File Type (one of following chars: "abcdeghiklmoprswz",FFh) 004h 4 File Size (or File Offset, when File Family="c") |
.?a ???? if any ???? (does NOT exist on PAL disc 1) ;nickname=azm .sb MIPS binary code (leading) ;nickname=bin .cc Whatever (eg. vr10\*, s01a\*) ;nickname=con .nd Texture Archive (leading) (contains PCX files) ;nickname=dar .rd Misc Archive (leading) (eg. init\*) ;nickname=dar .se Sound Effects? (trailing) ;nickname=efx .cg Whatever, reportedly bytecode functions ;nickname=gcx .ch Whatever ;nickname=hzm .ci Whatever (eg. ending\*, s01a\*) ;nickname=img .ck Whatever, model? aka "pat_xxx" files ;nickname=kmd .cl Lights, first word = size/10h ;nickname=lit .sm Sound Music? Nested DOT1+DOTLESS Archives ;nickname=mt3 .co Whatever "OARa" (eg. d16e\*, s00a\*, s02c\*) ;nickname=oar .cp PCX bitmap (eg. init\*) ;nickname=pcc .cr Whatever "sNRJ1F" (eg. roll\*) ;nickname=rar .cs Whatever (eg. d16e\*, s01a\*) ;nickname=sgt .sw Wave Archive (trailing) ;nickname=wvx .cz Whatever "KMDa" (eg. s11a, a11c, s14e, s15a) ;nickname=zmd .c,FFh End of Family="c" area ;nickname=dar? |
NextBlock = CurrBlock + 4 + Offset(lastfile)+Size(lastfile) + Align800h |
000h 4 Number of Files in this block (eg. 19h or 1Ch) 004h N*0Ch File List for this block ... .. File Data for this block ... .. Zeropadding to 800h-byte boundary (followed by next block, if any) File List entries: 000h 2 File Type (0=Main/Eye/Mouth frames, 1=All frames are full size) 002h 2 File ID (name checksum?) 004h 4 Filesize in bytes 008h 4 Offset in bytes, minus 4 |
This type use a single palette for all frames, and only the first frame is full 52x89pix, the other frames contain only the update sections (eg. eyes). 000h 4 Offset to 200h-byte palette (usually 20h) ;\Main 004h 4 Offset to Main Bitmap (52x89pix) (usually 220h) ;/ 008h 4 Offset to 4th Bitmap (usually xxxxh or 0=None) ;\Eyes 00Ch 4 Offset to 5th Bitmap (usually xxxxh or 0=None) ;/ 010h 4 Zero 014h 4 Offset to 2nd Bitmap (usually 143Ch or 0=None) ;\Mouth 018h 4 Offset to 3rd Bitmap (usually xxxxh or 0=None) ;/ 01Ch 4 Zero 020h 200h Palette (256 colors) ;\Main 220h 1218h Main Bitmap ;/ 1438h 4 Zero 143Ch .. 2nd Bitmap (if any) ;\Mouth ... .. 3rd Bitmap (if any) ;/ ... .. 4th Bitmap (if any) ;\Eyes ... .. 5th Bitmap (if any) ;/ |
This type use separate palettes for each frame, all frames are full 52x89pix. 000h 4 Number of frames 004h N*0Ch Frame List ... 200h 1st Frame Palette ... 1218h 1st Frame Bitmap (52x89pix) ... 4 ? ... 200h 2nd Frame Palette ... 1218h 2nd Frame Bitmap (52x89pix) ... 4 ? ... .. 3rd Frame ... Frame List entries: 000h 4 Offset to Palette 004h 4 Offset to Bitmap (usually at Palette+200h) 008h 4 Unknown (often 000x000xh) |
000h 1 Offset X (always 00h in Main Bitmap) 001h 1 Offset Y (always 00h in Main Bitmap) 002h 1 Width (always 34h in Main Bitmap, or less in 2nd-5th bitmap) 003h 1 Height (always 59h in Main Bitmap, or less in 2nd-5th bitmap) 004h .. Bitmap Pixels at 8bpp (Width*Height bytes) |
10 08 00 00 0x 00 00 00 .. |
"0xNNNNNNNN name",0Ah |
000h 4 Unknown (eg. 36h,BFh,5Eh,00h) 004h 4 Unknown (eg. 03h,13h,00h,00h) 008h 1 Unknown (eg. 80h) 009h 2 Chunk Size (eg. 0xh,xxh) ;big-endian .. .. Chunk Data (Chunk Size-2 bytes) (binary stuff, and text strings) |
000h 4 Number of files in this folder
004h .. File(s)
... .. 01h-padding to 800h-byte boundary
Files have this format:
000h .. Filename ("name.pll",00h)
... .. Zeropadding to 4-byte boundary (aligned to begin of BRF.DAT)
... 4 File data size (usually a multiple of 4)
... .. File data
... 1 Zero (00h)
|
000h .. PCX file (starting with 0A,05,01,01 or 0A,05,01,08) ... .. 01h-padding to 800h-byte boundary |
"name.c",00h + garbage-padding to 4-byte boundary ;<-- maybe source code? "pat_lamp",00h + zero- padding to 4-byte boundary ;<-- name for File ID ! |
000h 2 File ID (checksum on name?) 002h 1 File Type (one of following chars: "p" for .nd, or "kors" for .rd) 003h 1 Zero (00h) 004h 4 Chunk Size (rounded to 4-byte boundary) 008h .. Chunk Data |
.p PCX bitmap ;-in *\*.nd archives .k Whatever ;\ .o Whatever "OARa" ; in init*\*.rd archives .a Whatever ; .r Misc (TIM and other stuff) ;/ |
000h 4 Unknown (800h or C00h) ;big-endian
004h 4 Size of File List (N*10h) ;big-endian
008h 8 Zerofilled
010h N*10h File List (xx,xx,xx,00,00,00,00,7F,00,00,00,0F,00,19,0A,00)
... 4 Unknown (40000h or 60000h) ;big-endian
... 4 Size of SPU-ADPCM Data area ;big-endian
... 8 Zerofilled
... .. SPU-ADPCM Data area (indexed from File List)
File List entries:
000h 4 Offset+Flags ;little-endian!
bit0-16 Offset (from begin of SPU-ADPCM Data area)
bit17 Unknown (0 or 1)
bit18 Unknown (1)
bit19-31 Unknown (0)
004h 12 Whatever (always 00,00,00,7F,00,00,00,0F,00,19,0A,00)
|
000h 80h*10h List (unused entries are 1x00000000h,3xFFFFFFFFh) 800h .. Data (whatever, usually 14h or more bytes per list entry) List entries: 000h 1 Unknown (eg. 01h,10h,20h,A0h,80h,FFh) ;\ 001h 1 Number of Voices? (1..3) ; all zero for 002h 1 Unknown (1 or 0) ; unused list entries 003h 1 Unknown (2 or 0 or 1) ;/ 004h 4 Offset-800h for 1st Voice? ;-FFFFFFFFh=Unused 008h 4 Offset-800h for 2nd Voice? (if any) ;-FFFFFFFFh=Unused 00Ch 4 Offset-800h for 3rd Voice? (if any) ;-FFFFFFFFh=Unused Data: Seems to contain 4-byte entries (last entry being 00,00,FE,FF). |
Data: Seems to contain 4-byte entries (last entry being 00,00,FE,FF). |
sum=0,
for i=0 to len(filename)-1
sum=sum*20h+filename[i] ;\or so, 16bit overflows might be
sum=(sum+sum/10000h) AND FFFFh ;/cropped slightly differently
|
| CDROM File Archive DRACULA.DAT (Dracula) |
000h 4 Zero 004h 4 Number of Entries (503h) 008h 4 Zero 00Ch 4 Random 010h 10h Zero 020h N*10h File List ... .. Zeropadding to 800h-byte boundary ... .. Fild Data area |
000h 4 Offset/800h 004h 4 Type (see below for info on different file types) 008h 4 Filesize in bytes 00Ch 4 Random (or 0 when Filesize=0) |
Type=00000001h Cubemap ;\either one of these Type=00000040h Cubemap.empty ;/ Type=00000020h Cubemap.overlay? ;\these have size=0 when unused Type=00000400h Cubemap.sounds ;/ |
Type=00000000h Archive with TIMs (Size=AB74h) (" RSC3.1V")
Type=00000004h Unknown (Size=16164h) (00000064h)
Type=00000008h Related to DRACULA1.STR (Size=1000h) (" RTS1.1V")
Type=00001000h Unknown (Size=2000h) ("BXFS1.1V")
Type=00008000h Unknown (Size=71Dh) (" CM1.1V")
Type=00020000h Unknown (Size=3B9h) (" GSM0.1V")
Type=02000000h Unknown (Size=0h) (empty)
Type=00000100h Related to DRACULA1.XA (Size=1000h) ("RAAX1.1V")
Type=00000010h Unknown (Size=450h) (" HYP0.1V")
Type=00100000h Unknown (Size=4014h) (" xFS1.1V") (x=A1h)
Type=00000080h Unknown (Size=258F4h) (00000010h)
Type=00000200h TIM (gui charset) (Size=6E9Eh) (TIM)
Type=00010000h TIM (gui buttons) (Size=10220h) (TIM)
Type=00040000h Unknown (Size=2C4h) (" TES0.1V")
Type=00002000h TIM (gui book pages) (Size=1040h) (TIM)
Type=00000800h Cubemap ;\as Type 01h, (Size=4092Ch) (" RIV3.1V")
Type=00004000h Cubemap ;/but [10h,14h]=0 (Size=4092Ch) (" RIV3.1V", too)
|
000h 8 Name, ASCII, padded with leading spaces (eg. " RIV3.1V") 008h 4 Something (0, 1 or 2) (unknown, this isn't number of list entries) 00Ch 4 Zero 010h 4 Offset to Ext data (ACh) ;\ext data 014h 4 Size of Ext data (eg. 0 or 84h) ;/ 018h 6*4 Offsets to Side 0-5 ;\cubemap sides 030h 6*4 Sizes of Side 0-5 (0, 10220h, or 10820h) ;/ 048h 44h Zerofilled 08Ch 20h Name, ASCII (eg. "DEBUT0.VR", zeropadded) 0ACh .. Ext Data (if any) ... .. Cubemap TIM sides (if any) Note: The cubemap TIMs have 100h or 400h colors (in the latter case: 100h colors for each quarter of the 8bpp bitmap). Note: The TIMs can be arranged as 3D-cubemap with six sides, or as hires 2D-bitmap (composed of four TIMs, and 2 empty TIMs with size=0). |
Same as Type 01h, but size is always 0ACh (and all seven Size entries are 0) |
000h 8 Name, ASCII, padded with leading spaces (eg. " XFS0.1V") 008h 4 Zero 00Ch 4 Number of Files (N) (max 10h) 010h N*10h File List (100h bytes, zeropadded when less than 10h files) 110h .. File Data (VAG files) File List entries: 000h 4 Unknown (55F0h, 255F0h or 20000h) 004h 4 File ID (01010000h, increasing, or other when above=2xxxxh) 008h 4 Offset in bytes ;\.VAG files 00Ch 4 Filesize in bytes ;/ |
000h 8 Name, ASCII, padded with leading dot (eg. ".MNA4.1V") 008h 4 Zero 00Ch 4 Random 010h 4 Unknown 01h 014h 4 Total Number of 40h-byte blocks (01h..[018h]) (H) 018h 4 Total Number of 120h-byte blocks (eg. 1Fh,31h) (N) 01Ch 4 Total Number of 1Ch-byte blocks (eg. 1Eh, 50h, F7h) (M) 020h 4 Unknown 0 or 1 (in file 4EAh) 024h 4 Unknown 01h 028h 6*4 Offsets to Side 0-5 (at end of file and up) (or 0) ;\cubemap 040h 6*4 Sizes of Side 0-5 (10220h, or 10820h) (or 0) ;/sides 058h H*40h 40h-byte blocks ... N*120h 120h-byte blocks (related to offsets in 40h-byte blocks) ... M*1Ch 1Ch-byte blocks (related to offsets in 120h-byte blocks) ... .. Unknown data (related to offsets in 1Ch-byte blocks) ... .. Ext data (related to Ext offsets in 40h-byte blocks) FILE DOES END HERE! (below is allocated in above header, but not actually stored in the file) (maybe allocated as rendering buffer?) ... - Cubemap TIM sides The 40h-byte blocks are: 000h 20h Name (eg. "FLAMMES", zeropadded) 020h 4 Unknown 01h or 00h 024h 4 Offset to 120h-byte blocks (usually 98h, or higher) 028h 4 Unknown 00h 02Ch 4 Number of 120h-byte blocks (01h..[018h]) 030h 4 Unknown 01h 034h 4 Ext Offset ;\usually all zero 038h 4 Ext Size (3C000h) ; (except, nonzero in file 4EAh) 03Ch 4 Ext Random (checksum?) ;/ The 120h-byte blocks are: 000h 18h*4 List with Offsets to 1Ch-byte blocks (usually 4 entries nonzero) 060h 18h*4 List with Zeroes 0C0h 18h*4 List with Numbers of 1Ch-byte blocks (usually max 4 entries) The 1Ch-byte blocks are: 000h 4 Unknown 04h 004h 4 Width 20h or 10h 008h 4 Height 20h or 10h or 30h 00Ch 4 Unknown 60h or 10h 010h 4 Unknown 00h or 30h 014h 4 Offset to Unknown Data 018h 4 Size of Unknown Data (Width*Height*1) |
000h 8 Name (" RSC3.1V")
008h 8 Zerofilled
010h 4 Number of used entries (1Fh) (max 80h)
014h 80h*4 Offset List (offsets to files) (A14h and up)
214h 80h*4 Zero List (zerofilled)
414h 80h*4 Size List (filesizes)
614h 80h*4 Width List (0Ch,18h,34h,2Ch) (in pixels)
814h 80h*4 Height List (0Ch,24h,34h,2Ch)
A14h .. Data (TIM files, with mouse pointers)
|
| CDROM File Archive Croc 1 (DIR, WAD, etc.) |
CROCFILE.DIR:
000h 4 Number of Entries (N)
004h N*18h File List
... 4 Checksum (sum of all of the above bytes)
CROCFILE.1:
000h .. File Data (referenced from .DIR)
File List entries:
000h 0Ch Filename ("FILENAME.EXT", zeropadded if shorter)
00Ch 4 File Size in bytes (can be odd) (including 8 byte for size/chksum)
010h 4 File Offset in .1 file (unaligned, can be odd, increasing)
014h 4 Zero (0)
|
000h 4 Size-8 of whole file (or Size-0 for those in MP*.WAD)
004h 4 Flags? (usually 0Ch or 14h)
008h 1 Filename length (including trailing 00h, if any)
009h .. Filename ("P:\CROC\EDITOR\MAPS\..\*.MAP") (+00h in MAP05*.WAD)
... .. Unknown
... 1 Description length
... .. Description (eg. "Default New Map")
... .. Unknown
... (4) Checksum of whole file (sum of all bytes) (not in MP*.WAD)
|
MAP*.WAD: 000h 4 Size-8 of whole file 004h .. MAP file(s) (each with size/checksum, same format as MP*.MAP) ... 4 Checksum of whole file (sum of all of the above bytes) CROC.WAD, CROCSLID.WAD, EXCLUDE.WAD, MP*.WAD, OPTIONS.WAD, SWIMCROC.WAD: 000h 4 Size-8 of whole file 004h 4 Offset-8 to SPU-ADPCM data area 008h .. Data File area (model.MOD anim.ANI, bytecode.BIN, header.CVG, etc.) ... .. SPU-ADPCM data area (if any, note in CROCSLID.WAD and OPTIONS.WAD) The Data File area contains several "files" but doesn't have any directory with filename/offset/size. The only way to find the separate files seems to be to detect the type/filesize of each file, and then advance to next file (bytecode.BIN files start with a size entry, but files like .MOD or .ANI require parsing their fileheader for computing filesize). Note: The PC version reportedly has .WAD files bundled with .IDX file (that makes it easier to find files and filenames). Note: The STRAT.DIR file contains a list of filenames used in .WAD files (but lacks info on offset/size, so it isn't really useful). |
Sound.BIN Files (CROCFILE.DIR\AMBI*.BIN, MAP*.BIN, JRHYTHM.BIN, REVERB.BIN): 000h 4 Size of .SEQ file ;\if any (not in REVERB.BIN) 004h .. SEQ file (starting with ID "pQES") ;/ ... 4 Size of .VH file ;\always present ... .. VH file (starting with ID "pBAV") ;/ ... .. VB file (sample data, SPU-ADPCM data, up to end of file) Music.BIN files (MAGMUS.BIN, MUSIC.BIN): 000h 4 Size-8 of whole file (118h) 004h .. Increasing 32bit values ;sector numbers in PACK*.STR files or so? ... 4 Unknown (2EEh or 258h) (aka 750 or 600 decimal) ... .. Zeropadding 11Ch 4 Checksum (sum of all of the above bytes) Note: MUSIC.BIN has an extra copy (without chksum) in EXCLUDE.WAD\MUSIC.BIN Ascii.BIN files (CREDITS*.BIN, MNAME.BIN): 000h 4 Size-8 of whole file 004h (2) Type or so? (02h,01h) (only in CREDITS*.BIN, not in MNAME.BIN) ... .. Ascii strings (each string is: len,"text string",unknown) ... 4 Checksum (sum of all of the above bytes) Texture.BIN files (type 4) (STILLGO.BIN, STILLST.BIN, STILLTL.BIN): 000h 2 Type (4=Texture/uncompressed, with 0Eh-byte list entries) 002h 1 Zero (maybe Extra6byte as in type 5,6 Texture.BIN files) 003h 2 Number of List entries (N) (always 4B0h in all three files) 005h 2 Number of Texture Pages (usually 2) 007h 2 Zero (maybe Unknown/Animation as in type 5,6 Texture.BIN files) 009h N*0Eh Polygon List (?,?,?,?,?,?, x1,y1, x2,y1, x1,y2, x2,y2) ... 40000h Texture Page uncompressed data (two pages, 20000h bytes each) ... 4 Checksum (sum of all of the above bytes) Texture.BIN files (type 5,6) (ENDTEXT*.BIN, FONT.BIN, FRONTEND.BIN, OUTRO.BIN, PUBLISH.BIN, STILL*.BIN, TB*.BIN, TK*.BIN, TPAGE213.BIN): 000h 4 Zero (0) (in TPAGE213.BIN: Size-8 of whole file) 004h 2 Type (6=Texture/RLE16) (in TPAGE213.BIN: 5=Texture/uncompressed) 006h 1 Extra6byte flag/size (0=None, 3=Extra6byte: TB*.BIN, TPAGE*.BIN) ... (6) Extra6byte data (unknown purpose, only present when [006h]=3) ... 2 Number of Polygon List entries (N) ... 2 Number of Texture Pages (usually 1) (in TK*_ENM.BIN: usually 2) ... 2 Number of Unknown Blocks (0=None, or 1,2,4,8) ... (..) Unknown Block(s), if any ... 2 Number of Animation Blocks (0=None) ... (..) Animation Block(s), if any ... N*0Ch Polygon List (?,?,?,?, x1,y1, x2,y1, x1,y2, x2,y2) ;x,y or y,x? ... (4) Texture Page compressed size (T1) ;\only when [004h]=Type=6 ... (T1) Texture Page compressed data ;/ ... (4) Texture Page compressed size (T2) ;\only when [004h]=Type=6 ... (T2) Texture Page compressed data ;/ and NumPages=2 ... 20000h Texture Page uncompressed data ;-only when [004h]=Type=5 ... 4 Checksum (sum of all of the above bytes) Unknown Block(s): (Unknown purpose, each Unknown Block has the format shown below) 000h 2 Unknown (looks like some index value, different for each entry) 002h 2 Number of Unknown Items (eg. 1 or 2 or 4) 004h .. Unknown Items (NumItems*6 bytes) (three halfwords each?) Animation Block(s): (This is supposedly used to update portions of the Texture Page for animated textures, each Animation Block has the format shown below) 000h 2 Number of Bitmap Frames in this Animation (usually 8) 002h 2 Bitmap Width (in halfword units) 004h 2 Bitmap Height 006h 2 Unknown (1 or 3) ;\ 008h 2 Unknown (C10h, CC8h, 1E8h, or xxxh) ; maybe vram X,Y address? 00Ah 2 Unknown (0) ;/ 00Ch .. Bitmap Frames (Width*2*Height*NumFrames bytes, uncompressed) Croc 1 RLE16 compression: This is using unsigned little-endian 16bit LEN/DATA pairs, LEN can be: 0000h..7FFFh --> Load one halfword, fill 1..8000h halfwords 8000h..FFFFh --> Copy 1..8000h uncompressed halfwords BUG: Texture pages should be 20000h bytes (256x256 halfwords), but for whatever reason, the size of decompressed data can be 1FFEAh, 1FFF0h, 1FFFAh, 20000h, or 20002h. Bytecode.BIN (inside of .WAD files): 000h 4 Size of whole file 004h .. Whatever bytecode (starting with initial 16bit program counter?) Unknown.BIN (last 1-2 file(s) in EXCLUDE.WAD file): 000h 4 Number of entries (N) 004h N*18h Whatever ... 4 Checksum (sum of above bytes) Unknown purpose, retail version has one such file (with 0Ah entries), demo version has two such files (with 0Ah and 4Eh entries. The files start with: 0A,00,00,00,00,00,00,00,00,00,64,00,00,00,EB,FF,... ;demo+retail 4E,00,00,00,00,00,64,00,00,00,50,00,00,00,64,00,... ;demo |
Demo version has one .MOD file in CROCFILE.DIR (retail has more such files): 000h 2 Number of Models (N) (1 or more) (up to ECh exists) ;\header 002h 2 Flags (0 or 1) ;/ 004h N*Var SubHeadersWithData ;see below ;-data ... 4 Checksum (sum of all of the above bytes) ;-checksum SubHeadersWithData(N*Var): 004h 4 Radius ;\ 008h 48h Bounding Box[9*8] (each 8byte are 4x16bit: X,Y,Z,0) ; for each 050h 4 Number of Vertices (V) ; model 054h V*8 Vectors (4x16bit: X,Y,Z,0) ; ... V*8 Normals (4x16bit: X,Y,Z,0) ; ... 4 Number of Faces (F) (aka Polygons?) ; ... F*14h Faces (8x16bit+4x8bit: X,Y,Z,0,V1,V2,V3,V4, Tex/RGB) ; ... 2 Number of collision info 1? (X) ;\ ; ... 2 Number of collision info 2? (Y) ; only if ; ... X*2Ch Collision info 1? ; Flags.bit0=1 ; ... Y*2Ch Collision info 2? ;/ ;/ There are further .MOD models inside of .WAD files, with slightly re-arranged entries (and additional reserved/garbage fields): 000h 2 Number of Models (N) (1 or more) (up to ECh exists) ;\ 002h 2 Flags (0 or 1) ; header 004h 4 Reserved/garbage (usually 224460h) (or 22C9F4h/22DF54h) ;/ 008h (4) Number of Models WITH Data arrays (M) ;\ 00Ch (M*2) Model Numbers WITH Data arrays (increasing, 0..N-1) ; ext.hdr ... (..) Padding to 4-byte boundary (garbage, usually=M) ;/ ... N*68h Subheader(s) ;see below ;-part 1 ... N*Var DataArray(s) ;see below ;-part 2 Subheaders(N*68h): 000h 4 Radius ;\ 004h 48h Bounding Box[9*8] (each 8byte are 4x16bit: X,Y,Z,0) ; for each 04Ch 4 Number of Vertices (V) ; model 050h 4 Reserved/garbage (usually 0022xxxxh) ; 054h 4 Reserved/garbage (usually 0022xxxxh) ; 058h 4 Number of Faces (F) (aka Polygons?) ; 05Ch 4 Reserved/garbage (usually 0022xxxxh) ; 060h 2 Number of collision info1? (X) ; 062h 2 Number of collision info2? (Y) ; 064h 4 Reserved/garbage (usually 0022xxxxh) or xxxxxxxxh) ;/ DataArrays(N*Var) with sizes V,F,X,Y from corresponding Subheader: (if ext.hdr is present, then below exists only for models listed in ext.hdr) 000h V*8 Vectors (4x16bit: X,Y,Z,0) ;\ ... V*8 Normals (4x16bit: X,Y,Z,0) ; for each ... F*14h Faces (8x16bit+4x8bit: X,Y,Z,0,V1,V2,V3,V4, Tex/RGB) ; model ... X*2Ch Collision info 1? ; ... Y*2Ch Collision info 2? ;/ The ext.hdr mentioned above exists only in some .MOD files (usually in one of the last chunks of MP*.WAD). Files with ext.hdr have N>1, Flags=1 (but files without ext.hdr can also have those settings). Files with ext.hdr do usually have uncommon garbage values at hdr[4], which isn't too helpful for detection. The only way to detect models with ext.hdr seems to be to check if the ext.hdr contains valid increasing entries in range 0..N-1. WAD's that do contain a model with ext.hdr do usually also contain an extra 100h-byte file, that file contains N bytes for model 0..N-1 (plus zeropadding to 100h-byte size), the bytes are supposedly redirecting models without Data Arrays to some other data source. The 100h-byte files don't have any header or checksum, they contain up to 9Ch entries (so there's always some zeropadding to 100h), the existing 100h-byte files contain following values in first 4 bytes (as 32bit value): 04141401h, 0C040017h, 01010101h, 09030503h, 0A0B0A0Bh, 03020102h, 0C060900h, 00060501h, 04040201h, 01010203h, 01030201h, 05000302h, 0C040317h, or Zero. To distinguish from other files: BIN/MAP files start with a 4-byte aligned Size value; if Size=0 or (Size AND 3)>0 or Size>RemainingSize then it's probably a 100h-byte file. Best also check if last some bytes are zeropadded. Exceptions: Retail MP090..MP100_*.WAD has model with ext.hdr, but no 100h-byte file Demo MP041_00.WAD has model with ext.hdr, with zerofilled 100h-byte file Note: Some models have ALL models listed in ext.hdr (which is about same as not having any ext.hdr at all; except, they ARE bundled with 100h-byte file). |
Some (not all) MP*.WAD files are bundled with MP*.DEM files, supposedly containing data for demonstration mode. There are two versions: demo version: size 2584h (9604 decimal) (some files with partial checksum) retail version: size 0E10h (3600 decimal) (without checksum) |
Animation data, there is only one such file in CROCFILE.DIR: 000h 2 Value (100h) 002h 2 Number of Triggers (T) (2) 004h (T*2) Trigger List (with 2x8bit entries: FrameNo, TriggerID) ... .. Probably, Padding to 4-byte boundary (when T=odd) ... 4 Number of entries 1 (X) ... X*18h Whatever Array 1 ... 4 Number of entries 2 (Y) (usually/always 64h) ... X*Y*4 Whatever Array 2 ... 4 Number of entries 3 (Z) (usually/always 0Ah) ... X*Z*18h Whatever Array 3 There are further .ANI files inside of .WAD files: 000h 2 Value (100h or 200h) ;Animation Speed? 002h 2 Number of Triggers (T) (0, 1, 2, 3, 5, or 9) 004h 4 Garbage/Pointer (usually 224460h) (or zero) 008h 4 Number of entries 1 (X) (1 or more) ;Num Frames 00Ch 4 Garbage/Pointer (usually 22C9F4h) (or 224460h or 22DF54h) 010h 4 Number of entries 2 (Y) (usually 64h) (or 0) ;Num Vertices (?) 014h 4 Garbage/Pointer 018h 4 Number of entries 3 (Z) (usually 0Ah) (or 6 or 9) 01Ch 4 Garbage/Pointer 020h (T*2) Trigger List (with 2x8bit entries: FrameNo, TriggerID) ... .. Padding to 4-byte boundary (garbage, usually=X) ... X*18h Whatever Array 1 ... X*4 Garbage/Pointers (0021EE74h,0021EE74h,xxx,...) ... X*Y*4 Whatever Array 2 ;Vertex 3x10bit? ;only if Y>0 ... (X*4) Garbage/Pointers (0021EE74h,0021EE74h,xxx,...) ;only if Y>0 ... X*Z*18h Whatever Array 3 |
There is only one such file in CROCFILE.DIR: 000h 4 Size-8 of whole file 004h 4 Unknown (0) 008h 4 Unknown (1) 00Ch .. SPU-ADPCM data ... 4 Checksum (sum of all of the above bytes) There are further .CVG files inside of .WAD files, these consist of two parts; 0Ch-byte Headers (in the data file area), and raw SPU-ADPCM data (in the spu-adpcm data area at end of the .WAD file): Header(0Ch): 000h 4 Size+8 of data part 004h 4 Unknown (0) 008h 4 Unknown (0 or 1) Data(xxxx0h): 000h .. SPU-ADPCM data (starting with sixteen 00h bytes) |
This file contains a list of filenames for files inside of .WAD files, but
it does NOT tell where those files are (in which WAD at which offset).
000h 4 Number of Entries (N)
004h N*xxh File List (retail=14h bytes, or demo=18h bytes per entry)
... 4 Checksum (sum of all of the above bytes)
List entries are:
demo: entrysize=18h ;Filename(0Ch)+Size(4)+Zeroes(8)
retail: entrysize=14h ;Filename(0Ch)+ Zeroes(8)
The list contains hundreds of filenames, with following extensions:
*.BIN byte-code strategies
*.MOD models
*.ANI animations
*.CVG spu-adpcm voice data
These "filenames" seem to be actually solely used as "memory handle names":
MemoryHandle(#1) = LoadFile("FILENAME.BIN") ;<-- names NOT used like this
MemoryHandle("FILENAME.BIN") = LoadFile(#1) ;<-- names used like this
|
Huge files with XA-ADPCM audio data |
Huge mis-mastered 24Mbyte file (contains several smaller XA-ADPCM blocks, accidentally stored in 800h-byte FORM1 data sectors, instead of 914h-byte FORM2 audio sectors). |
MDEC movies |
Raw bitmaps (25800h bytes, uncompressed, 320x240x16bpp) |
| CDROM File Archive Croc 2 (DIR, WAD, etc.) |
000h 4 Total Filesize+/-xx (-4 or +800h or +1800h) 004h 4+4+.. XSPT Chunk ;Textures ... 4+4+.. XSPS Chunk ;SPU-ADPCM Sound (if any, not in all .WAD's) ... 4+4+.. FINU Chunk ;...whatever Data...? ;Potter games only ... 4+4+.. XSPL Chunk ;...whatever Data...? ;Potter games only ... 4+4+.. XSPD Chunk ;...whatever Data...? ... 4+4+.. TROP Chunk ;...whatever Data...? ;Potter games only ... 4+4 DNE Chunk ;End marker (in Harry Potter: with data!) |
000h 4 Chunk Name "XSPT" (aka TPSX backwards) 004h 4 Chunk Size (excluding 8-byte Name+Size) 008h 4 Chunk Flags (02h or 06h or 0Eh) ;02h in Croc 2 00Ch (20h) Name (eg. "Default new map", zeropadded) ;\if Flags bit2=1 ... (804h) Unknown ... SAME as in XSPD chunk !!! ;/ ... 4 Number of List 1 entries (N1) (xxh..xxxh) ;\ ... 4 Number of Texture Pages (1..4) ; List 1 and NumPages ... N1*0Ch List 1 Whatever (6B 2F xx 00..) ;/ ... 4 Number of List 2 entries (N2) (0..xxh) ;\ ... 4 Unknown (2 or 7) ; List 2 ... N2*04h List 2 Whatever (halfwords?) (if N2>0) ;/ ... (5*C00h) Whatever, 5*C00h, Palette+Stuff? ;-if Flags bit3=1 ... .. RLE16 compressed Texture Pages ;-Texture bitmap RLE16 Texture notes: Compressed data consists of signed little-endian 16bit LEN+DATA pairs: LEN=0000h --> invalid/unused LEN=0001h..7FFFh --> copy LEN halfwords from src LEN=8000h..FFFFh --> load ONE halfword as fillvalue, fill -LEN halfwords Compressed size is everything up to end of XSPT chunk Decompressed size is 20000h*NumTexturePages (=20000h,40000h,60000h or 80000h) That is: Width=256 halfwords, height 256*NumTexturePages lines. There seems to be only one RLE16 compression block for all Texture Pages, rather than one RLE16 block for each Page. BUG #1: Decompressed data in Aladding/Emperor does often contain only 1FFFEh,3FFFEh,5FFFEh,7FFFEh bytes (the decompressed data has correct size when appending ONE halfword with random/zero value). BUG #2: Compressed data in Croc 2 ends with a RLE16 length value (-LEN), but lacks the corresponding RLE16 filldata (the decompressed data is 7FFFEh when filling those LEN halfwords with random/zero values). |
000h 4 Chunk Name "XSPS" (aka SPSX backwards) ;\ 004h 4 Chunk Size (excluding 8-byte Name+Size) ; header 008h 4 Chunk Flags (0 or 3 or 7) ;/ 00Ch 4 Number of Sounds (N1) (1..xxh) ;\always present 010h N1*14h Sound List ;/ ... (4) VAB/VH Size ;\if Flags=3 or 7 ... (..) VAB/VH Header ;/ (bit0 or bit1?) ... (4) Unknown (2 or 4) ;-if Flags=3 or 7 ... (4) Whut (N2) ;\if Flags.bit2=1 ... (N2*10h) Whut List (4 words: xxh,10h,xxxx00h,xxxx0h);/ ... 4 Size of all Part 1 Sound Data blocks ;\always ... .. SPU-ADPCM Sound Data (referenced from Sound List) ;/ ... (4) Size of all Part 2 Sound Data blocks (+8) ;\if Flags= ... (..) SPU-ADPCM Sound Data (referenced from Sound List?) ; 3 or 7 ... (8) Zero ;/ Sound List entries (as in FESOUND.WAD): 000h 4 Sample Rate in Hertz (AC44h=44100Hz, 5622h=22050Hz, 3E80h=16000Hz) 004h 2 Sample Rate Pitch (1000h=44100Hz, 0800h=22050Hz, 05CEh=16000Hz) 006h 2 Unknown (7Fh) 008h 4 Unknown (1) (1) (8) 00Ch 4 Unknown (42008Fh) (1FC0001Fh) (40008Fh) 010h 4 Filesize (xxx0h) (xxx0h) |
000h 4 Chunk Name "XSPD" (aka DPSX backwards) 004h 4 Chunk Size (excluding 8-byte Name+Size) 008h 4 Flags-and/or-other stuff ? (eg. 00000094h or 0A801094h) 00Ch 804h Unknown ... SAME as in XSPT chunk !!! 810h .. Unknown ... |
000h 4 Chunk Name " DNE" (aka END backwards) 004h 4 Chunk Size (0) (except, in Harry Potter: nonzero) ... .. Data (usually none such) (except, in Harry Potter: with data!) |
000h 4 Number of entries (N) (always 2EEh, aka 750 decimal) (or 258h) 004h N*8 Whatever entries... maybe data for demonstration mode? |
| CDROM File Archive Alien Resurrection (WAD) |
000h 4 Always 100h 004h 4 Number of 4-byte entries in TXF footer (0..25h) 008h 4 Number of ...? (usually same as above, or less) (0..25h) 00Ch 4 Number of ...? (0..0Ah) 010h 4 Number of Files (N) (0..8) 014h 4 Trailer Part Size 1? (a bit smaller than Trailer Total Size) 018h 4 Trailer Part Size 2? (0..170h) (usually multiple of 4) 01Ch 4 Trailer Total Size (TS) 020h N*8 File List (2x32bit: Type, Size) ... .. Zeropadding to 800h-byte boundary 800h .. File Data (with zeropadding to 800h-byte boundary, each) ... TS Trailer (with zeropadding to 800h-byte boundary) |
00h,"FXT" (aka TXF backwards) Textures
00h,"PAM" (aka MAP backwards) Map
00h,"BVC" (aka CVB backwards) CVB
00h,"NIB" (aka BIN backwards) Binary ("CMD " or "pQES"+"pBAV")
00h,"DVC" (aka CVD backwards) CVD (there can be several CVDs)
00h,"TAR" (aka RAT backwards) Rat
|
| CDROM File Archive Headerless Archives |
PSX Resident Evil 2, COMMON\DATA\*.DIE contains TIM+VAB badged together PSX Resident Evil 2, COMMON\DATA\*.ITP contains 1000h-byte aligned TIMs Blaster Master, DATA\MENU\*\*.PRT contains three smaller TIMs badged together Blaster Master, DATA\MENU\*\*.BG contains three bigger TIMs badged together Misadventures of Tron Bonne, KATWA\*.BIN has headerless archives (TIM+audio) Headerless BSS files contain several BS files with huge padding inbetween |
| CDROM File Compression |
.BS used by several games (and also in most .STR videos) .GIF used by Lightspan Online Connection CD .JPG used by Lightspan Online Connection CD .BMP with RLE4 used by Lightspan Online Connection CD (MONOFONT, PROPFONT) .BMP with RLE8+Delta also used by Online Connection CD (PROPFONT\ARIA6.BMP) .PCX with RLE used by Jampack Vol. 1 (MDK\CD.HED\*.pcx) .PCX with RLE used by Hot Wheels Extreme Racing (MagDemo52: US_01293\MISC\*) .PCX with RLE used by Metal Gear Solid (slightly corrupted PCX files) |
.XA uses XA-ADPCM (and also used in .STR videos) .VAG .VB .VAB uses SPU-ADPCM |
| CDROM File Compression LZSS (Moto Racer 1 and 2) |
000h 4 ID "LZSS" 004h 4 Decompressed Size 008h .. Compressed Data |
@@collect_more:
flagbits=[src]+100h, src=src+1 ;8bit flags
@@decompress_lop:
flagbits=flagbits SHR 1
if zero then goto @@collect_more
if carry=1 then
[dst]=[src], dst=dst+1, src=src+1
else
disp=([src]+[src+1]*100h) AND 3FFh, len=([src+1]/4)+2_or_3, src=src+2
if disp=0 then goto @@decompress_done
for i=1 to len, [dst]=[dst-disp], dst=dst+1, next i
endif
goto @@decompress_lop
@@decompress_done:
ret
|
| CDROM File Compression LZSS (Dino Crisis 1 and 2) |
@@collect_more:
flagbits=[src]+100h, src=src+1 ;8bit flags
@@decompress_lop:
flagbits=flagbits SHR 1
if zero then goto @@collect_more
if carry=1 then
[dst]=[src], dst=dst+1, src=src+1
else
disp=[src]+[src+1]*100h AND FFFh, len=[src+1]/10h+2, src=src+2
if disp=0 then error
for i=1 to len, [dst]=[dst-disp], dst=dst+1, next i
endif
if src<src_end then goto @@decompress_lop
ret
|
| CDROM File Compression LZSS (Serial Experiments Lain) |
Each chunk is having this format: 000h 4 Chunk ID "napk" 004h 4 Decompressed size 008h .. LZSS compressed TIM data ... .. Zeropadding to 800h-byte boundary |
Each chunk is having this format: 000h 4 Chunk ID "lapk" 004h 4 Chunk size (excluding 8-byte chunk header, excluding zeropadding) 008h 4 Number of Files in this Chunk (N) 00Ch N*0Ch File List ... .. File Data (bitmaps in .BS v0 format with uncommon headers) ... .. Zeropadding to 800h-byte boundary File List entries: 000h 4 Offset in bytes (zerobased, from begin of File Data area) 004h 2 Bitmap Width/2 + some 3bit value in LSBs? 006h 2 Bitmap Height 00Ch 4 Zero File Data (bitmaps in .BS v0 format with uncommon headers): 000h 2 Bitmap Width 002h 2 Bitmap Height 004h 2 Quant for Y1,Y2,Y3,Y4 006h 2 Quant for Cr,Cb 008h 4 Size of compressed BS Bitstream plus 4 ;Transparency at [008h]+0Ch 00Ch 2 Size/2 of MDEC data (after huffman decompression, without padding) 00Eh 2 BS Version (0) (actually MSBs of above Size, but it's always 0) 010h .. BS Bitstream with DC and AC values (Huffman compressed MDEC data) ... 4 Transparency Mask Decompressed Size (Width*Height*2/8) (=2bpp) ... .. Transparency Mask LZSS-compressed data |
dst_end=dst+[src], src=src+4 ;decompressed size
@@collect_more:
flagbits=([src] SHL 24)+800000h, src=src+1 ;8bit flags
@@decompress_lop:
if dst=dst_end then goto @@decompress_done
flagbits=flagbits SHL 1 ;32bit shift with carry-out/zeroflag
if zero then goto @@collect_more
if carry=0 then
[dst]=[src], dst=dst+1, src=src+1
else
disp=[src]+1, len=[src+1]+3, src=src+2
for i=1 to len, [dst]=[dst-disp], dst=dst+1, next i
endif
goto @@decompress_lop
@@decompress_done:
ret
|
| CDROM File Compression LZSS.8/32 and LZ+RLE+DELTA (Viewpoint) |
for i=1 to dst_len, [dst]=[src], src=src+1, dst=dst+1 ret |
dst_end=dst+((dst_len+1) and not 1)) ;dst_buf_size must be multiple of 2 !
dst_start=dst
@@decompress_lop:
code=LittleEndian16bit[src], src=src+2
len=code AND FFFh, code=code/1000h
if code=0 ;\RLE copy
for i=1 to len, [dst+0..1]=[src+0..1], src=src+2, dst=dst+2 ;/
elseif code=1 ;\
fillval=[src+0..1], src=src+2 ; RLE fill
for i=1 to len, [dst+0..1]=fillval, dst=dst+2 ;/
elseif code=3..4 ;\
from=dst-8000h, if from<dst_start then from=dst_start ; LZ
if code=3 then from=from+LittleEndian16bit[src]*2, src=src+2 ; <-- far
if code=4 then from=from+(len AND FFh)*2, len=len/100h ; <-- near
for i=1 to len, [dst+0..1]=[from+0..1], from=from+2, dst=dst+2 ;/
else ;code=2 or code=5 or code=6..0Fh ;\
for i=1 to len ;
steps=LittleEndain16bit[src+0..1], src=src+2 ;4x4bit steps ; Delta
for j=1 to 4 ;
x=steps AND 0Fh, steps=steps/10h ;
if code=2 and x>7 then x=8-x ; <-- +/-N
if code=5 then x=x ; <-- +N
if code>5 then x=0-x ; <-- -N
if dst>dst_start then x=x+[dst-1] else x=x+(whatever/zero) ;
[dst]=x, dst=dst+1 ;/
if dst<>dst_end then goto @@decompress_lop
code=LittleEndian16bit[src] ;overshot, nonsense read after dst_end
ret
|
dst_end=dst+((dst_len+3) and not 3)) ;dst_buf_size must be multiple of 4 !
collected_bits=LittleEndian32bit[src+0], curr_bit=1 ;-fetch 32x1bit
collected_codes=LittleEndian32bit[src+4], src=src+8 ;-fetch 2x16bit
@@decompress_lop:
if dst=dst_end then goto @@decompress_done ;-end check
if (collected_bits and curr_bit)=0 ;\copy 4-byte
[dst+0..3]=[src+0..3], src=src+4, dst=dst+4 ;/uncompressed
else
disp=(collected_codes and 3FFh)*4 ;\
len=(collected_codes/400h) and 3Fh ; copy
for i=1 to len, [dst+0..3]=[dst-disp+0..3], src=src+4, dst=dst+4 ;/
collected_codes=collected_codes/10000h ;\
if collected_codes=0 then ; fetch
collected_codes=LittleEndian32bit[src+4], src=src+8 ;/
curr_bit=curr_bit*2
if curr_bit AND FFFFFFFFh=0 then ;fetch more (even if already at dst_end ?!)
collected_bits=LittleEndian32bit[src+0], curr_bit=1 ;-fetch
goto @@decompress_lop
@@decompress_done:
ret
|
dst_end=dst+dst_len
collected_bits=LittleEndian32bit[src], src=src+4, curr_bit=1 ;-fetch 32x1bit
collected_codes=LittleEndian32bit[src], src=src+4 ;-fetch 2x16bit
collected_bytes=LittleEndian32bit[src], src=src+4, numbytes=4 ;-fetch 4x8bit
@@decompress_lop:
if dst=dst_end then goto @@decompress_done ;-end check
if (collected_bits and curr_bit)=0 ;\copy 1-byte
[dst]=collected_bytes AND FFh, dst=dst+1 ;/uncompressed
collected_bytes=collected_bytes/100h, numbytes=numbytes-1 ;\
if numbytes=0 ; fetch
collected_bytes=LittleEndian32bit[src], src=src+4, numbytes=4;/
else
disp=(collected_codes and 3FFh) ;\copy
len=(collected_codes/400h) and 3Fh ; compressed
for i=1 to len, [dst]=[dst-disp], src=src+1, dst=dst+1 ;/
collected_codes=collected_codes/10000h ;\
if collected_codes=0 then ; fetch
collected_codes=LittleEndian32bit[src+4], src=src+8 ;/
curr_bit=curr_bit*2
if curr_bit AND FFFFFFFFh=0 then ;fetch more (even if already at dst_end ?!)
collected_bits=LittleEndian32bit[src+0], curr_bit=1 ;-fetch
goto @@decompress_lop
@@decompress_done:
ret
|
| CDROM File Compression LZSS.ZOO (Fossil Fuckers) |
0000h 4 Decompressed Size ;\1st sector 0004h 7FCh Garbage ;/ 0800h 4 Decompressed Size (same as above) ;\2nd sector 0804h 7FCh LZSS compressed data, part 1 ;/ 1000h 800h LZSS compressed data, part 2 ;-3rd sector 1800h 800h LZSS compressed data, part 3 ;-4th sector ... .. etc. |
Compressed (with size.bit31=0): 0000h 4 Decompressed Size ;\1st sector 0004h 7FCh LZSS compressed data, part 1 ;/ 0800h 800h LZSS compressed data, part 2 ;-2nd sector 1000h 800h LZSS compressed data, part 3 ;-3rd sector ... .. etc. Uncompressed (with size.bit31=1): 0000h 4 Uncompressed Size, plus 80000000h ;\uncompressed 0004h .. Uncompressed Data ;/ |
SCUS-94187 Porsche Challenge NTSC-U ;-known to use this compression format SIPS-60016 Porsche Challenge NTSC-J ;\ SCPS-45117 Porsche Challenge ASIA ; probably thise are using it, too SCES-00409 Porsche Challenge PAL ;/ |
\CDFAT.DAT ;whatever \SYSTEM.CNF ;boot info \Sxxx_nnn.nn ;boot exe (name depends on region) \SRC\CAR.EXE ;another exe \SRC\MENU\STREAM\*.STR ;mdec video streams \SRC\MUSIC\*.MVB ;spu-adpcm streams |
decompress_zoo_file:
if LittleEndian32bit[src+14h]=FDC4A7DCh then refuse ;refuse ZOO archives
if LittleEndian32bit[src]<>LittleEndian32bit[src+800h] then refuse
src=src+804h ;skip header and garbage
call decompress_body
ret
;---
decompress_porsche_file:
if gamecode<>(SCUS-94187, SIPS-60016, SCPS-45117, SCES-00409) then refuse
if filename=(CDFAT.DAT, *.CNF, *.MVB, *.STR) or [src]="PS-X EXE" then refuse
dst_len=LittleEndian32bit[src], src=src+4
if dst_len AND 80000000h then
for i=1 to dst_len AND 7FFFFFFFh, [dst]=[src], src=src+1, dst=dst+1
else
call decompress_body
ret
;---
decompress_body:
next=src+7FCh ;end of 1st sector
@@sector_lop:
decompress_sector
src=next, next=src+800h ;next sector
if src<src_end then goto @@sector_lop
ret
;---
decompress_sector:
@@collect_more:
flagbits=([src] SHL 24)+800000h, src=src+1 ;8bit flags
@@decompress_lop:
flagbits=flagbits SHL 1 ;32bit shift with carry-out/zeroflag
if zero then goto @@collect_more
if carry=0 then
[dst]=[src], dst=dst+1, src=src+1
else
disp=[src]*100h+[src+1], src=src+2
if disp=FFFFh then goto @@decompress_done
len=(disp/800h)+3, disp=(disp AND 7FFh)+1
for i=1 to len, [dst]=[dst-disp], dst=dst+1, next i
endif
goto @@decompress_lop
@@decompress_done:
ret
|
| CDROM File Compression Ulz/ULZ (Namco) |
000h 4 ID ("Ulz",1Ah) (parts lowercase)
004h 3 Decompressed Size in bytes
007h 1 Version (0 or 2)
008h 3 Offset to Uncompressed data <-- reportedly can be 0 in version=0?
00Bh 1 Number of Disp bits (DispBits=N, LenBits=16-N) (usually 0Ah..0Dh)
00Ch 4 Offset to Compressed data
010h .. Compression Flags (32bit entries)
... .. Uncompressed data (8bit entries)
... .. Zeropadding to 4-byte boundary
... .. Compressed data (16bit entries)
|
000h 4 ID ("ULZ",1Ah) (all uppercase)
004h 2 Zero
006h 1 Version (0 or 2)
007h 1 Number of Disp bits (DispBits=N, LenBits=16-N) (usually 0Ah..0Dh)
008h 4 Offset to Uncompressed data
00Ch 4 Offset to Compressed data
010h 4 Decompressed Size in bytes
014h .. Compression Flags (32bit entries)
... .. Uncompressed data (8bit entries)
... .. Zeropadding to 4-byte boundary
... .. Compressed data (16bit entries)
|
if [src+00h]="Ulz",1Ah then
version = Byte[src+07h]
disp_bits = Byte[src+0Bh]
dst_end = LittleEndian24bit[src+04h] + dst
src_dta = LittleEndian24bit[src+08h] + src
src_lz = LittleEndian32bit[src+0Ch] + src
src_flg = src + 10h
add_len = 3
flg_1st = 31 ;process flag bit31 first
if [src+00h]="ULZ",1Ah then
version = Byte[src+06h]
disp_bits = Byte[src+07h]
src_dta = LittleEndian32bit[src+08h] + src
src_lz = LittleEndian32bit[src+0Ch] + src
dst_end = LittleEndian32bit[src+10h] + dst
src_flg = src + 14h
add_len = 2
flg_1st = 0 ;process flag bit0 first
collected = 80000000h ;initially empty, plus stop bit
@@decompress_lop:
if version=2 AND dst=dst_end then goto @@decompress_done
flag = collected AND 80000000h
collected=collected*2
if collected=0
collected = LittleEndian32bit[src_flg], src_flg=src_flg+4
if flg_1st=0 then ReverseBitOrder(collected) ;or make custom/faster code
flag = collected AND 80000000h
if version=0 AND collected=0 then goto @@decompress_done
if version=0 then collected=collected*2 ;<-- has implied stop bit
if version=2 then collected=collected*2 + 1 ;<-- shift-in stop bit
if flag=0 ;compressed
disp = LittleEndian16bit[src_lz], src_lz=src_lz+2
len = (disp SHR disp_bits) + add_len
disp = (disp AND ((1 shl disp_bits)-1)) + 1
for i=1 to len, [dst]=[dst-disp], dst=dst+1, next i
else ;uncompressed
[dst]=[src_dta], dst=dst+1, src_dta=src_dta+1
goto @@decompress_lop
@@decompress_done:
ret
|
| CDROM File Compression SLZ/01Z (chunk-based compressed archive) |
000h 3 ID (either "01Z" or "SLZ", both are used) 003h 1 Method (00h=Uncompressed, 01h=LZSS, 02h=LZSS+FILL) 004h 4 Compressed size (SIZ) (same as decompressed when Method=0) 008h 4 Decompressed size 00Ch 4 Distance to next chunk, if any (SIZ+10h+Align4, or 0=None) 010h SIZ Compressed data |
method=byre[src+3]
len=word[src+8]
src=src+10h
if method=0 then
for i=1 to len, [dst]=[src], dst=dst+1, src=src+1, next i
goto @@decompress_done
dst_end = dst+len
@@collect_more:
flagbits=[src]+100h, src=src+1 ;8bit flags
@@decompress_lop:
if method=2 AND dst=dst_end then goto @@decompress_done
flagbits=flagbits SHR 1
if zero then goto @@collect_more
if carry=1 then
[dst]=[src], dst=dst+1, src=src+1
else
disp=([src]+[src+1]*100h) AND 0FFFh, len=([src+1]/10h)+3, src=src+2
if method=1 AND disp=0 then goto @@decompress_done
if method=2 AND len=12h then ;special fill mode...
len=disp/100h+3, val=disp AND FFh ;len=3..12h
if len=3 then len=val+13h, val=[src], src=src+1 ;len=13h..112h
for i=1 to len, [dst]=val, dst=dst+1, next i ;len=4..112h
else
for i=1 to len, [dst]=[dst-disp], dst=dst+1, next i
endif
goto @@decompress_lop
@@decompress_done:
ret
|
| CDROM File Compression LZ5 and LZ5-variants |
LZ5 is often implemented with a ringbuf (instead of actual sliding window) LZ5 uses absolute ringbuf indices (instead of relative sliding dest indices) LZ5 requires the ringbuf to be initially prefilled with constants LZ5 ringbuf is 1000h bytes tall and starts with write index FEEh |
INFO.DAT encrypted directory with filename, offset and compressed/uncompressed size GAME.DAT 000h 4 ID "ALZ1" 004h ... ALZ1 Compressed data (with size as defined in INFO.DAT) ... 4 ID "ALZ1" ... ... ALZ1 Compressed data (with size as defined in INFO.DAT) ... |
000h 4 Compressed Size ;=Filesize-4 004h .. ALZ1 Compressed data (Filesize-4 bytes) |
000h 4 Compressed Size+0..7 ;=(Filesize-4)+0..7 004h .. ALZ1 Compressed data (Filesize-4 bytes) |
000h 4 Compressed Size ;=(Filesize-4-Padding) 004h .. ALZ1 Compressed data (Filesize-4-(0..3) bytes) ... .. Zeropadding to 4-byte boundary |
000h 4 Decompressed size 004h 4 Compressed size (including 8-byte header, without padding, if any) 008h .. DECODE_S compressed data (containing TIM, SEQ, VAB, TPK, or BO3!) ... (..) Optional padding to 4-byte boundary (eg. in MAPFILE\0BEh\*) |
EFFECT\*.TPK --> compressed TPK's MAPFILE\* --> compressed TIM's MAPFILE\88Ah --> compressed SEQ's SOUND\*.SLH --> compressed VAB's CHRHEAD\* --> compressed TIM's VAB's and BO3!'s |
000h 8 ID "00zLATAD" (aka DATALz00 backwards) ;\PreHeader 008h 4 Total Filesize excluding PreHeader+Padding (SIZ+0Ch) ;/ 00Ch 4 Unknown (always 1000h) ;\ 010h 4 Compressed data size (SIZ) ; Header 014h 4 Decompressed data size ;/ 018h SIZ zLATAD Compressed data ;-Data ... .. Padding to 4-byte boundary ;-Padding |
000h 8 ID "VRAM-WAD" 008h 4 Compressed size (Filesize-Padding-10h) 00Ch 4 Decompressed size (18000h, 28000h, 40000h bytes) 010h .. VRAMWAD Compressed data (192x256, 320x256, 512x256 halfwords) ... (..) Padding to 4-byte boundary (if any, in files in .VRW archives) |
MagDemo43: POWER\GAME.IDX\PERSOS\PSX\CUSTOM\TEXTURE\NFIELD.BIZ\LPORJ.PSI |
000h .. FA2 Compressed .FA archive |
DEFAULT = ALZ1 or BIZ or LZ5 or DECODE_S
if DEFAULT then wr=0FEEh, mask=FFFh ;\
if VRAMWAD then wr=0FEEh, mask=FFFh ; initial ringbuf write index
if zLATAD then wr=0000h, mask=FFFh ; and ringbuf mask (size-1)
if SCRATCH then wr=01BEh, mask=1FFh ;
if FA2 then wr=00EFh, mask=0FFh ;/
if FA2 then len2=0
initialize_ringbuf_content (see below)
numbits=0
@@decompress_lop:
if dst>=dst.end then goto @@decompress_done
if numbits=0
flagbits=[src], numbits=8, src=src+1 ;8bit flags
numbits=numbits-1
if VRAMWAD or FA2 then flagbits SHL 1, else flagbits=flagbits SHR 1
if carry=1 then
dta=[src], [dst]=dta, ringbuf[wr AND mask]=dta
dst=dst+1, wr=wr+1, src=src+1
else
if DEFAULT then rd=[src]+([src+1]/10h)*100h), len=([src+1] AND 0Fh)+3
if zLATAD then rd=[src]+([src+1] AND 0Fh)*100h), len=([src+1]/10h)+3
if SCRATCH then rd=[src]+([src+1]/80h)*100h), len=([src+1] AND 7Fh)+3
if VRAMWAD then rd=[src+1]+([src]/10h)*100h), len=([src] AND 0Fh)+3
if FA2 then rd=[src], len=len2, len2=0, src=src+1
if FA2 and len=0 then len=[src]/10h+2, len2=([src] AND 0Fh)+2, src=src+1
if FA2=0 then src=src+2
for i=1 to len ;read ringbuf[rd] (instead of relative [dst-rd])
dta=ringbuf[rd AND mask], [dst]=dta, ringbuf[wr AND mask]=dta
dst=dst+1, wr=wr+1, rd=rd+1
next i
endif
goto @@decompress_lop
@@decompress_done:
ret
|
if ALZ1 or zLATAD then
ringbuf[000h..FFFh]=(00h) ;zeroes
if VRAMWAD or DECODE_S then
ringbuf[000h..FEDh]=(00h) ;zeroes
ringbuf[FEEh..FFFh]=(uninitialized) ;uninitialized, don't use
if BIZ then
ringbuf[000h..FEDh]=(20h) ;ascii space
ringbuf[FEEh..FFFh]=(uninitialized) ;uninitialized, don't use
if SCRATCH then
ringbuf[000h..1BFh]=(00h) ;zeroes
ringbuf[1C0h..1FFh]=(uninitialized) ;uninitialized, don't use
if FA2 then
ringbuf[000h..0FFh]=(00h) ;zeroes
if LZ5 then
ringbuf[000h..CFFh]=(000h..CFFh)/0Dh ;increasing, repeated 0Dh times each
ringbuf[D00h..DFFh]=(00h..FFh) ;increasing
ringbuf[E00h..EFFh]=(FFh..00h) ;decreasing
ringbuf[F00h..F7Fh]=(00h) ;zeroes
ringbuf[F80h..FEDh]=(20h) ;ascii space
ringbuf[FEEh..FFFh]=(should be 00h) ;see note, better don't use
|
| CDROM File Compression PCK (Destruction Derby Raw) |
000h 3 Decompressed size (24bit, little-endian) 003h 1 Unused (0) 004h ... LZSS compressed data, starting with 30bit+2bit flags |
[03h]=00h, [04h]=00h, [08h]="PS-X EXE" ;DDRAW\*.EXE [03h]=00h, [04h] AND FCh=00h, [08h]="BC",04h,40h,0,0 ;DDRAW\LDPICS\*.PCK |
dst_end=dst+LittleEndian24bit[src], src=src+4
@@collect_more:
flagbits=BigEndian32bit([src]), src=src+4
dispbits=14-(flagbits AND 03h), flagbits=(flagbits OR 3)-1
dispmask=(1 SHL dispbits)-1
@@decompress_lop:
flagbits=flagbits SHL 1 ;32bit shift with carry-out/zeroflag
if zero then goto @@collect_more
if carry=0 then
[dst]=[src], dst=dst+1, src=src+1
else
disp=BigEndian16bit[src], src=src+2
len=(disp SHR dispbits)+3
disp=(disp AND dispmask)+1
for i=1 to len, [dst]=[dst-disp], dst=dst+1, next i
endif
id dst<dst_end then goto @@decompress_lop
@@decompress_done:
ret
|
| CDROM File Compression GT-ZIP (Gran Turismo 1 and 2) |
000h 2 MDEC Size/4 (after huffman decompression) (rounded to 80h/4 bytes) 002h 2 File ID (3800h) 004h 2 Bitmap Width in pixels ;instead quant 006h 2 Bitmap Height in pixels ;instead version 008h 2 Size of GT-ZIP compressed data (plus 2-byte alignment padding) 00Ah .. GT-ZIP compressed DC/Quant values (plus 2-byte alignment padding) ... .. Huffman compressed AC data blocks (Cr,Cb,Y1,Y2,Y3,Y4, Cr,Cb,Y1,Y2..) |
000h .. Compressed Data (without header) |
000h 0Ch ID "@(#)GT-ZIP",0,0 00Ch 4 Decompressed Size 010h .. Compressed Data (unknown compressed size due to below padding) ... .. Zeropadding to 4-byte boundary (when stored in DOT1 archives) |
if [src]="@(#)GT-ZIP",0,0 then dst.end=dst+[src+0Ch], src=src+10h
@@collect_more:
flagbits=[src]+100h, src=src+1 ;8bit flags
@@decompress_lop:
if src>=src.end then goto @@decompress_done ;(when src.end is known)
if dst>=dst.end then goto @@decompress_done ;(when dst.end is known)
flagbits=flagbits SHR 1
if zero then goto @@collect_more
if carry=0 then
[dst]=[src], dst=dst+1, src=src+1
else
len=[src], src=src+1, disp=[src], src=src+1 ;len, disp
if disp>=80h then disp=(disp-80h)*100h+[src], src=src+1 ;longer disp
for i=1 to (len+3), [dst]=[dst-(disp+1)], dst=dst+1, next i
endif
goto @@decompress_lop
@@decompress_done:
ret
|
Source Compressed Size Decompressed Size Compressed GAMEFONT.DAT In ISO Filesystem Unknown (n/a) Compressed GT-ARC In ISO Filesystem Unknown (n/a) Files in GT-ARC In GT-ARC In GT-ARC Files with GT-ZIP header Unknown (due to padding) In GT-ZIP DC values in IKI videos Unknown (due to padding) From Width*Height |
| CDROM File Compression GT20 and PreGT20 |
000h 4 ID ("GT20"=Compressed) (or reportedly "NOGT"=Uncompressed)
004h 4 Size of decompressed data in bytes
008h 4 Overlap for in-situ decompression (usually 3, or sometimes 7)
00Ch 4 Size of Leading Zeropadding in bytes (0..7FFh)
010h .. Leading Zeropadding (0..7FFh bytes)
... .. Compressed Data
|
DecompressGT20:
src=src+word[src+0Ch]+10h ;skip header and any leading zeropadding
collected=00000001h ;end-bit
@@lop:
if GetBit=0
[dst]=[src], dst=dst+1, src=src+1 ;uncompressed byte
else
if GetBit=0
disp=byte[src]-100h, src=src+1 ;disp=(-100h..-1)
len=(GetBit*2)+(GetBit*1)+2 ;len=(2..5)
else
tmp=halfword[src], src=src+2
disp=(tmp/8)-2000h ;disp=(-2000h..-1)
len=(tmp AND 7)+2 ;len=(2..9)
if len=2
tmp=byte[src], src=src+1
if (tmp AND 80h) then disp=disp-2000h ;disp=(-4000h..-1)
len=(len AND 7Fh)+2 ;len=(2..81h)
if len=3 then goto decompression_done
if len=2 then len=halfword[src], src=src+2 ;len=(0..FFFFh)
for i=1 to len, [dst]=[dst+disp], dst=dst+1, next i
goto @@lop
;---
GetBit:
collected=collected SHR 1
if zero then collected=(word[src] SHR 1)+80000000h, src=src+4
return carry (from shift right)
|
000h 4 Compression Method (0=None, 2=Compressed, Other=Invalid) 004h 4 Compressed Size (SIZ) (same as decompressed when method=0) 008h 4 Decompressed Size 00Ch SIZ Compressed Data ... .. Garbagepadding to 4-byte boundary (in 4-byte aligned DAT files) |
DecompressPreGT20:
src=src+0Ch ;skip header
collected=80h ;end-bit
@@lop:
if GetBit=1
[dst]=[src], dst=dst+1, src=src+1 ;uncompressed byte
else
if GetBit=0
len=(GetBit*2)+(GetBit*1)+2 ;len=(2..5)
disp=byte[src]-100h, src=src+1 ;disp=(-100h..-1)
else
tmp=bigendian_halfword[src], src=src+2
disp=(tmp/8)-2000h ;disp=(-2000h..-1)
len=(tmp AND 7)+2 ;len=(2..9)
if len=2
len=byte[src]+1, src=src+1 ;len=(1..100h)
if len=1 then goto decompression_done
for i=1 to len, [dst]=[dst+disp], dst=dst+1, next i
goto @@lop
;---
GetBit:
collected=collected SHL 1 ;8bit shift
if zero then collected=(byte[src] SHL 1)+01h, src=src+1
return carry (from 8bit shift left)
|
| CDROM File Compression HornedLZ |
B3 10 00 4F .. Compressed TIM with TIM Type=00h (4bpp without CLUT) DB 10 00 3F .. Compressed TIM with TIM Type=08h,09h,etc. |
Type=05h can be uncompressed .TXT or HornedLZ-compressed .TIM
(check if 2nd data byte is ASCII or 10h)
Type=0Fh is a DOT1 archive with HornedLZ-compressed .TIMs
(parse the DOT1 archive and treat its contents as compressed .TIMs)
Type=10h contains Deflated TIMs
(a completely different compression method)
|
collected=01h ;end-bit
@@lop:
if GetBit=1
[dst]=[src], dst=dst+1, src=src+1 ;uncompressed byte
else
if GetBit=1
tmp=[src], src=src+1
len=tmp/40h+2, disp=tmp or (-40h) ;len=(2..05h), disp=(-40h..-1)
else
tmp=[src]*100h+[src+1], src=src+2
len=tmp/1000h+2, disp=tmp or (-1000h) ;len=(2..11h), disp=(-1000h..-1)
if len=2 then
len=[src]+2, src=src+1 ;len=(2..101h)
if len=2 then goto decompression_done
for i=1 to len, [dst]=[dst+disp], dst=dst+1, next i
goto @@lop
;---
GetBit:
collected=collected SHR 1
if zero then collected=([src] SHR 1)+80h, src=src+1
return carry (from shift right)
|
| CDROM File Compression LZS (Gundam Battle Assault 2) |
000h 4 ID ("lzs",00h)
004h 4 Zerofilled
008h 4 Fixed (must be 1) (method/version?)
00Ch 14h Zerofilled
020h 2 Fixed (must be 3) (method/version?)
022h 2 Offset to Compressed Data minus 20h (usually 38h-20h)
024h 4 Decompressed Size
028h 2 Flagsize (must be 08h, 10h, or 20h) (usually 20h=32bit)
02Ah 2 Lensize (must be 02h..07h) (usually 05h=5bit)
02Ch 4 Compressed Size (total filesize, including "lzs" header)
030h 8 Name? (always "000000",00h,00h)
038h .. Compressed data (usually at offset 38h)
|
dst_end = dst+littleendian32bit[src+24h]
flg_bits = littleendian16bit[src+28h] ;8,16,32
len_bits = littleendian16bit[src+2Ah] ;2..7
len_mask = (1 shl len_bits)-1 ;03h..7Fh
src=src+littleendian16bit[src+22h]+20h
collected_bits=0
@@collect_more:
for i=0 to flg_bits/8-1 ;read 8bit/16bit/32bit little-endian
collected_bits=collected_bits+([src] SHL (i*8)), src=src+1
num_collected=flg_bits
@@decompress_lop:
if dst=dst_end then goto @@decompress_done
if num_collected=0 then goto @@collect_more
num_collected=num_collected-1
flagbits=flagbits SHR 1
if carry=1 then
[dst]=[src], dst=dst+1, src=src+1
else
temp=bigendian16bit[src], src=src+2
len=(temp AND len_mask)+3
disp=(temp SHR len_bits), if disp=0 then goto @@decompress_error
for i=1 to len, [dst]=[dst-disp], dst=dst+1, next i
endif
goto @@decompress_lop
@@decompress_done:
ret
|
| CDROM File Compression BZZ |
Jersey Devil .BZZ (MagDemo10: JD\*.BZZ) Bugs Bunny: Lost in Time (MagDemo25: BBLIT\*.BZZ) The Grinch (MagDemo40: GRINCH\*.BZZ) |
decompress_bzz:
method=byte[src], src=src+1 ;method (00h..1Fh) ;usually/always 0Bh)
shifter = ((method/8) and 3) ;00h..03h ;usually 1
len_bits = ((method and 7) xor 7) ;07h..00h ;usually 4
len_mask = (1 shl len_bits)-1 ;7Fh..00h ;usually 0Fh
threshold=len_mask/2, if threshold>07h then threshold=13h ;usually 07h
for i=0 to len_mask
if i>threshold then len_table[i] = ((i-threshold) shl shifter)+threshold+3
else len_table[i] = i+3 ;method=18h max=(7Fh-13h)*8+13h+3=376h=886 decimal
next i ;method=0Hh max=(0Fh-07h)*2+07h+3=1Ah=26 decimal
num_flags=bigendian24bit[src]+1, src=src+3 ;NUM24+1
@@collect_more:
if src>=src_end then goto @@decompress_error
flagbits=[src]+100h, src=src+1 ;8bit flags
@@decompress_lop:
flagbits=flagbits SHR 1
if zero then goto @@collect_more
if carry=1 then
if src>=src_end then goto @@decompress_error
[dst]=[src], dst=dst+1, src=src+1
else
if src+1>=src_end then goto @@decompress_error
temp=bigendian16bit[src], src=src+2
len=len_table[temp AND len_mask]
disp=temp SHR len_bits, if disp=0 then goto @@decompress_error
for i=1 to len, [dst]=[dst-disp], dst=dst+1, next i
endif
num_flags=num_flags-1, if num_flags>0 then goto @@decompress_lop
@@decompress_error:
ret
|
Case 1) source has NUM24+1 codes
--> decode all NUM24+1 codes (otherwise output will be too small)
Case 2) source has NUM24 codes (and enough padding for another code)
--> decode all NUM24+1 codes (for compatibility with case 1)
--> output will have some constant garbage byte(s) appended
--> exception: omit last code if it contains invalid disp=0
Case 3) source has NUM24 codes (and not enough padding for another code)
--> decode only NUM24 codes (abort if NUM24+1 exceeds src_end)
--> output should (probably) have correct size
--> never exceed src_end which would be highly unstable
|
| CDROM File Compression RESOURCE (Star Wars Rebel Assault 2) |
decompression function:
base=src, method=[src], dst_end=dst+BigEndian24bit[src+1], src=src+4
@@decompress_lop:
if dst>=dst_end then goto @@decompress_done
if [src] AND 80h then
if method=01h then
len=([src]-80h)/8+3, disp=(BigEndian16bit[src] AND 7FFh)+1, src=src+2
else ;method=02h
len=([src]-80h)+4, disp=(BigEndian16bit[src+1])+1, src=src+3
for i=1 to len, [dst]=[dst-disp], dst=dst+1
else ;uncompressed
len=[src]+1, src=src+1
for i=1 to len, [dst]=[src], src=src+1, dst=dst+1
goto @@decompress_lop
@@decompress_done:
src=(src+3) AND NOT 3
if LittleEndian32bit[src]<>crc(base, src-base) then error
ret
|
STD_BBX.DAT\s*t\tp_a\* ;\double compression, Top-level is ALSO compressed BBX_INTR.DAT\data1\pics\* ;/ BBX_INTR.DAT\Stad\pics\* ;\ BBX_INTR.DAT\Stad\wire\* ; Nested archives with compression BBX_INTR.DAT\Subtitl\* ; BBX_INTR.DAT\Subtitl\sub\*;/ |
| CDROM File Compression TIM-RLE4/RLE8 |
Compressed 4bpp RLE4-TIM with uncompressed CLUT ;\only 4bpp can be compressed Compressed 4bpp RLE8-TIM with uncompressed CLUT ;/ Uncompressed 4bpp TIM with uncompressed CLUT ;\only this type/combinations Uncompressed 8bpp TIM with uncompressed CLUT ; are allowed if uncompressed Uncompressed 16pp TIM without CLUT ;/ End code 00000000h (plus more zeropadding) ;-end of headerless archive |
hdr[02h]=Method (0000h=Uncompressed, 0001h=RLE4, 0002h=RLE8) |
@@decompress_lop: color=[src]/10h, len=([src] AND 0Fh)+1, src=src+1 for i=1 to len, putpixel(color), next i ;len=1..10h if numpixels<Width*Height*4 then goto @@decompress_lop |
@@decompress_lop:
color1=[src]/10h, color2=[src] AND 0Fh, src=src+1
if color1=color2
len=[src]+2, src=src+1
for i=1 to len, putpixel(color1), next i ;len=2..101h
else
putpixel(color1), if numpixels<Width*Height*4 then putpixel(color2)
for i=1 to len, putpixel(color) ;len=1..10h
if numpixels<Width*Height*4 then goto @@decompress_lop
|
80078760h ape_escape_load_tim_archive 8007894Ch ape_escape_decompress_with_4bit_lengths 800789FCh ape_escape_decompress_with_8bit_lengths |
RLE8: Ape Escape, MagDemo22: KIDZ\KKIIDDZZ.HED\DAT\file004h\1stTIM RLE4: Ape Escape, MagDemo22: KIDZ\KKIIDDZZ.HED\DAT\file135h\1stTIM RLE8: Ape Escape, MagDemo22: KIDZ\KKIIDDZZ.HED\DAT\file139h\1stTIM |
| CDROM File Compression RLE_16 |
000h 8 ID "_RLE_16_" 008h 4 Decompressed Size (usually 3C008h) (33408h=Apocalypse warning.rle) 00Ch .. RLE Compressed Data (usually a .BMR bitmap) |
src=src+0Ch ;skip ID and size
@@decompress_lop:
len=halfword[src], src=src+2
if len=0000h then goto @@decompress_done ;end-code
if (len AND 8000h)=0 then
for i=1 to len, halfword[dst]=halfword[src], dst=dst+2, src=src+2, next i
else
fillvalue=halfword[src], src=src+2
for i=1 to len-8000h, halfword[dst]=fillvalue, dst=dst+2, next i
goto @@decompress_lop
@@decompress_done:
ret
|
| CDROM File Compression PIM/PRS (Legend of Mana) |
000h 1 Unknown (always 01h) (maybe File ID or Compression method) 001h .. Compressed data ;for TIM: usually 00,10, F0,00, 00,0x, F0,00, ... |
nn,data[nn+1] ;nn=00..EF len=nn+1 [dst]=data[1] ;-uncompressed F0,xn len=n+3 [dst]=0x ;1x4bit ;\ F1,nn,xx len=nn+4 [dst]=xx ;1x8bit ; F2,nn,yx len=nn+2 [dst]=0x,0y ;2x4bit ; RLE fill F3,nn,xx,yy len=nn+2 [dst]=xx,yy ;2x8bit ; F4,nn,xx,yy,zz len=nn+2 [dst]=xx,yy,zz ;3x8bit ;/ F5,nn,xx,data[nn+4] len=nn+4 [dst]=xx,data[1] ;\interleaved F6,nn,xx,yy,data[nn+3] len=nn+3 [dst]=xx,yy,data[1] ; fill combo F7,nn,xx,yy,zz,data[nn+2] len=nn+2 [dst]=xx,yy,zz,data[1] ;/ F8,nn,xx len=nn+4 [dst]=xx ;xx=xx+1 ;\ F9,nn,xx len=nn+4 [dst]=xx ;xx=xx-1 ; fill with FA,nn,xx,ss len=nn+5 [dst]=xx ;xx=xx+ss ; signed step FB,nn,xx,yy,ss ;ss=signed len=nn+3 [dst]=xx,yy ;yyxx=yyxx+ss ;/ FC,xx,ny len=n+4 [dst]=[dst-yxx-1] ;\ FD,xx,nn len=nn+14h [dst]=[dst-xx-1] ; LZ compress FE,xn len=n+3 [dst]=[dst-x*8-8] ;/ FF len=0 end ;-end code |
BIN\*.BIN ---> packed misc binary MAP\*\FDATA.PRS ---> packed resource, whatever MAP\*\MAP*.PRS ---> packed MPD resource, "SKmapDat" WM\WMTIM\*.PIM ---> packed TIM image, 384x384x4bpp, bad compression ratio WM\WMAP\*.PAT ---> packed loaddata WM\WMAP\*.PIM ---> packed TIM image, 320x256x16bit, with UNCOMPRESSED dupe |
| CDROM File Compression BPE (Byte Pair Encoding) |
000h 4 ID "BPE_" 004h 4 Total Filesize of compressed file including header (big-endian) ... .. Compression block(s) Each compression block contains: 000h .. Dictionary info ... 2 Size of compressed data (big-endian) ... .. Compressed data |
000h 4 Decompressed size (little-endian) 004h 4 ID "BPE",1Ah 008h .. Compression block(s) ... .. End code (00000000h) (aka last block with Blocksize=0) Each compression block contains: 000h 4 Size of decompressed block (little-endian) (or 0=End code) 004h .. Dictionary info ... .. Compressed data ... .. Padding to 4-byte boundary |
if [src+0]="BPE_" then type=GROOVE ;\
if [src+4]="BPE",1Ah then type=DRAGOON ;
if type=GROOVE then src_end = src+BigEndian32bit[src+4] ; hdr
if type=DRAGOON then dst_end = dst+LittleEndian32bit[src+0] ;
src=src+8 ;/
@@block_lop:
if type=DRAGOON then ;\blk
dst_blk_end = dst+LittleEndian32bit[src]+4, src=src+4 ; len
if dst=dst_blk_end then goto @@decompress_done ;/
for i=00h to FFh, dict1[i]=i, next i ;\
i=00h ;
@@dict_lop: ; dict
num=[src], src=src+1 ;
if num>7Fh then i=i+(num-7Fh), num=0, if i=100h then goto @@dict_done ;
for j=0 to num ;
a=[src], src=src+1 ;
if a<>i then b=[src], src=src+1, dict1[i]=a, dict2[i]=a ;
i=i+1 ;
if i<100h then goto @@dict_lop ;
@@dict_done: ;/
if type=GROOVE then ;\blk
src_blk_end = src+BigEndian16bit[src]+2, src=src+2 ;/len
i=0 ;\
@@data_lop: ;
if i=0 then ;\ ; data
if type=GROOVE and src=src_blk_end then goto @@data_done ; get data ;
if type=DRAGOON and dst=dst_blk_end then goto @@data_done; from src ;
x=[src], src=src+1 ; or heap ;
else ; ;
i=i-1, x=heap[i] ;/ ;
a=dict1[x] ;-xlat ;
if a=x then ;\ ;
[dst]=x, dst=dst+1 ; output data to ;
else ; dst or heap ;
b=dict2[x], heap[i]=b, heap[i+1]=a, i=i+2 ;/ ;
goto @@data_lop ;
@@data_done: ;/
if type=GROOVE and src<src_end then goto @@block_lop ;\next
if type=DRAGOON then src=(src+3) AND not 3, goto @@block_lop ;/blk
@@decompress_done:
if type=DRAGOON and dst<>dst_end then error
ret
|
| CDROM File Compression RNC (Rob Northen Compression) |
000h 3 ID ("RNC")
003h 1 Compression Method (01h or 02h) (or 00h=uncompressed)
004h 4 Size of Uncompressed Data ;big-endian
008h (4) Size of Compressed Data (SIZ) ;big-endian ;\
00Ch (2) CRC16 on Uncompressed Data ;\with initial ;big-endian ; method
00Eh (2) CRC16 on Compressed Data ;/value 0000h ;big-endian ; 1..2
010h (1) Leeway (difference between compressed and uncompressed data; only
in largest pack block, if larger than decompressed data) ;
011h (1) Number of pack blocks (or 00h=Not specified) ;/
... SIZ Compressed Data (or uncompressed data for method 0)
... (..) Zeropadding to 800h-byte boundary-4 ;\in PSX Heart of Darkness
... (4) Unknown ;/
|
decompress_rnc_method_1: num_blocks=[src+11h], src=src+12h dummy=GetBits(2) ;skip/ignore first 2 bits @@block_lop: GetTree(rawlen_tree) GetTree(disp_tree) GetTree(lzlen_tree) num_items=GetBits(16) goto @@item_injump @@item_lop: disp=GetHuffCode(disp_tree)+1 len=GetHuffCode(lzlen_tree)+2 for i=1 to len, [dst]=[dst-disp], dst=dst+1 @@item_injump: len=GetHuffCode(rawlen_tree) ;can be 0=none for i=1 to len, [dst]=[src], src=src+1, dst=dst+1 ;with optional decrypt num_items=num_items-1 ;AND FFFFh (in DOS version, at least) if num_items<>=0 then @@item_lop num_blocks=num_blocks-1 ;AND FFh (in DOS version, at least) if num_blocks<>00h then goto @@block_lop ret ;--- GetTree(tree) ;note: below can have num=0=none (eg. very small uncompressed blocks ;may leave the disp and lzlen trees unused/uninitialized). num=GetBits(5) ;number of symbols (00h..10h) for i=0 to num-1, codesizes[i]=GetBits(4) ;sizes (1..15 bits, or 0=unused) lzh_explode_tree(tree,codesizes,num) ;alike LHA trees ret ;--- GetCode(tree): val=GetHuffCode(tree) if val>1 then val=(1 SHL (val-1)) + GetBits(val-1) return val |
0 + Byte(DATA[1]) Copy 1 Byte from Source 1000 + Dist + Byte(X) Copy 4 Bytes from Dest-(Dist+X+1) 10010 + Dist + Byte(X) Copy 6 Bytes from Dest-(Dist+X+1) 10011 + Dist + Byte(X) Copy 7 Bytes from Dest-(Dist+X+1) 1010 + Dist + Byte(X) Copy 5 Bytes from Dest-(Dist+X+1) 10110 + Dist + Byte(X) Copy 8 Bytes from Dest-(Dist+X+1) 10111 + nnnn + Byte(DATA[12..72]) Copy nnnn*4+12 Bytes from Source 110 + Byte(X) Copy 2 Bytes from Dest-(X+1) 1110 + Dist + Byte(X) Copy 3 bytes from Dest-(Dist+X+1) 1111 + Byte(0) + 0 + zeropadding End of last pack block 1111 + Byte(0) + 1 End of non-last pack block 1111 + Byte(L) + Dist + Byte(X) Copy L+8 Bytes from Dest-(Dist+X+1) ;L>00h |
0 = 0000h 1000 = 0200h 110 = 0100h 1001 = 0300h 111000 = 0C00h 101000 = 0800h 111001 = 0D00h 101001 = 0900h 11101 = 0600h 10101 = 0400h 111100 = 0E00h 101100 = 0A00h 111101 = 0F00h 101101 = 0B00h 11111 = 0700h 10111 = 0500h |
000h 4 ID ("RNCA") (RNC Archive) ;\
004h 2 Offset to End of Folder list (big-endian) ; header
006h 2 CRC16 on Folder List (initial value 0000h) (big-endian) ;
008h .. Folder List ;/
... .. Data (RNC compressed files, each starting with "RNC",0xh) ;-data
... 4 Zero ;-end
Folder List entries:
000h 2 Offset to End of File list (big-endian)
... .. Folder Path ("DIR\SUBDIR\",00h) (or "",00h for root)
... .. File List
... 1 File List end marker (00h)
File List entries:
000h .. Filename ("FILENAME.EXT",00h)
... 4 Offset to Data for this file (big-endian)
|
000h 4 ID ("RNC",01h or 02h) (as in newer RNC files, but without CRCs)
004h 4 Size of Uncompressed Data ;big-endian
008h 4 Size of Compressed Data (SIZ) ;big-endian
00Ch SIZ Compressed data (processed backwards, fetched in 8bit units)
|
rawlen_bits = (1,1,2,2,3,8,15) ;-pack-ice rawlen_bits = (1,1,2,2,3,10) ;-rnc1old rawlen_bits = (1,1,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16) ;-rnc2old maxlzlenbits = 10 ;\pack-ice maxdispbits = 12 ;/and rnc1old maxlzlenbits = ([src+0Ch+src_len-1]/10h)+1 ;\rnc2old maxdispbits = ([src+0Ch+src_len-1] AND 0Fh)+1 ;/ |
Method 1: Syndicate Method RNC1old: Heimdall Method RNC2old: Knightmare |
Method 2: Demolition Racer (MagDemo27: DR\DD.DAT\*.RNC) Method 2: Heart of Darkness (IMAGES\US.TIM) Method 2: Jonah Lomu Rugby (LOMUDEMO\GFX\*.PAK) Method 2: NBA Jam: Tournament Edition (*.RNC, headerless .BIN/.GFX archives) Method 2: Test Drive 5 (MagDemo13: TD5.DAT\*.RNC) Method 2: Test Drive Off-Road 3 (MagDemo27: TDOR3\TDOR3.DAT\*.rnc) |
3 Ninjas Kick Back Addams Family Addams Family Values The Adventures of Mighty Max Asterix and the Great Rescue Asterix and the Power of the Gods The Incredible Hulk The Itchy & Scratchy Game (unreleased) Marsupilami Mortal Kombat Mr. Nutz Outlander The Pagemaster RoboCop 3 Spirou Spot Goes to Hollywood Stargate Street Racer Tinhead Tintin in Tibet World Championship Soccer II |
http://aminet.net/package/util/pack/RNC_ProPack - official tool & source code https://segaretro.org/Rob_Northen_compression - description (contains bugs) |
| CDROM File Compression Darkworks |
decompress:
dictsize=1000h, dict0=alloc(dictsize), dict1=alloc(dictsize)
src=load_next_800h_byte_sector ;load first sector
dst=dict0 ;temp dest in current dict
dst_base=dst ;memorize start of newly decompressed data
@@decompress_lop:
if [src]=00h then ;\
esc=[src+1], src=src+1 ;
forward_to_actual_dest(source=dst_base, len=dst-dst_base) ; escape
if esc=0 or esc>4 then esc=2 (or warn_invalid_escape_code) ;
if esc=1 then goto @@decompress_done ;
if esc=2 or esc=4 then src=load_next_800h_byte_sector ;
if esc=3 or esc=4 then swap(dict0,dict1), dst=dict0 ;
dst_base=dst ;/
elseif ([src] AND 03h)=0 then ;\
len=[src]/4+2, dat=[src+1], src=src+2 ; fill 8bit
for i=1 to len, [dst]=dat, dst=dst+1 ;/
elseif ([src] AND 03h)=1 then ;\
len=[src]/4+([src+2] AND 40h)+4 ;
ptr=[src+1]+([src+2] AND 3Fh)*100h ; LZ compressed
if ptr+len>dictsize then error (exceeds allocated dictsize) ;
if ([src+2] AND 80h) then ptr=ptr=dict1 else ptr=ptr=dict0 ;
src=src+3 ;
for i=1 to len, [dst]=[ptr], ptr=ptr+1, dst=dst+1 ;/
elseif ([src] AND 03h)=2 then ;\
len=[src]/4+3, dat0=[src+1], dat1=[src+2], src=src+3 ; fill 16bit
for i=1 to len, [dst]=dat0, [dst+1]=dat1, dst=dst+2 ;/
elseif ([src] AND 03h)=3 then ;\
len=[src]/4+1, src=src+1 ; uncompressed
for i=1 to len, [dst]=[src], src=src+1, dst=dst+1 ;/
goto @@decompress_lop
@@decompress_done:
dealloc(dict0), dealloc(dict1)
ret
|
| CDROM File Compression Blues |
if LittleEndian32bit[src+08h]<>1 then error ;compression flag
dst_end=dst+LittleEndian32bit[src+14h], src=src+18h, num_collected=0
@@decompress_lop:
if GetBit=1 then
[dst]=[src], src=src+1, dst=dst+1 ;code 1 uncompressed byte
elseif GetBit=1 then
len=[src], src=src+1 ;code 01 fill or end code
if len=00h then goto @@decompress_done
len=len+1, fillvalue=[dst-1]
for i=1 to len, [dst]=fillvalue, dst=dst+1
else
len=GetBit*2+GetBit
if len=0 then ;code 0000 long LZ range
len=[src] AND 0Fh, disp=[src]/10h+[src+1]*10h-1000h, src=src+2
else ;code 00xx short LZ range
disp=[src]-100h, src=src+1
len=len+1
for i=1 to len, [dst]=[dst+disp], dst=dst+1
goto @@decompress_lop
@@decompress_done:
if dst<>dst_end then error
ret
;---
GetBit:
if num_collected=0 then collected=[src], src=src+1, num_collected=8
collected=collected*2
return (collected/100h) AND 1
|
| CDROM File Compression Z (Running Wild) |
decompress_z: src=src+4 ;skip 32bit decompressed size entry @@reload_lop: load_table1 ;table for first 9bits load_table2 ;table for codes longer than 9bits @@decompress_lop: sym=get_symbol() if sym<100h then [dst]=sym, dst=dst+1, goto @@decompress_lop if sym=100h then goto @@escape len=sym-0FCh ;change 101h..140h to 05h..44h disp=((get_symbol()-101h)*40h) ;change 101h..140h to 00h..3Fh*40h disp=((get_symbol()-101h) or disp)+1 ;change 101h..140h to 00h..3Fh+above+1 copy len bytes from dst-disp to dst goto @@decompress_lop @@escape: if GetBits(1)=0 then goto @@reload_lop ret ;----- load_table1: t=0 @@load_lop: x=GetBits(10h) if x and 8000h then num=1 else num=(1 shl (9-(x/400h))) for i=1 to num, table1[t]=x, t=t+1, next i if t<200h then goto @@load_lop ret ;----- load_table2: num=GetBits(9)*2 ;can be 0=none, max=3FEh if num>0 then for i=0 to num-1, table2[i]=GetBits(9), next i ret ;----- get_symbol: ;returns a value in range 0..140h: ; 00h..FFh = data 00h..FFh (or unused for disp codes) ; 100h = escape (or unused for disp codes) ; 101h..140h = length 05h..44h (or 6bit fraction of 12bit disp) ; 141h..3FFh = would be possible for short codes, but shouldn't be used x=table1[PeekBits(9)] if (x and 8000h)=0 then SkipBits(x/400h), return (x and 3FFh) ;-short code SkipBits(9) ;skip first 9 bits, and process futher bit(s).. ;\ x=x-0C000h ;change C000h..C1FFh and up to 000h..1FFh ; long code @@lop: ; (with more x=table2[x*2+GetBits(1)] ;branch node0/node1 ; than 9bit) if x>=141h then x=x-141h, goto @@lop ; return x ;/ |
| CDROM File Compression ZAL (Z-Axis) |
if src_len=0 then goto @@decompress_done ;empty (without end code)
lzlen=0, rawlen=0
if [src]=10h..FFh then ;\special handling
rawlen=[src]-11h, src=src+1 ; for code=10h..FFh
if rawlen<=0 then goto @@decompress_error ;/at begin of source
@@decompress_lop:
memcopy(dst-disp,dst,lzlen) ;copy compressed bytes
memcopy(src,dst,rawlen) ;copy uncompressed bytes
code=[src], src=src+1
if code=00h..0Fh then
if rawlen=0 ;when OLD rawlen=0...
lzlen=0, rawlen=code+3 ;\
if rawlen=3 then ;
while [src]=00h, rawlen=rawlen+FFh, src=src+1 ;
rawlen=rawlen+[src]+0Fh, src=src+1 ;/
else ;when OLD rawlen>0, and depending on OLD lzlen...
rawlen=code AND 03h
disp=code/4+[src]*4, src=src+1
if lzlen=0 then disp=disp+801h, lzlen=3, else then disp=disp+1h, lzlen=2
if code=10h..1Fh then
lzlen=(code AND 07h)+2
if lzlen=2 then
while [src]=00h, lzlen=lzlen+FFh, src=src+1
lzlen=lzlen+[src]+07h, src=src+1
rawlen=[src] AND 03h, disp=[src]/4+[src+1]*40h+(code/8 AND 1)*4000h+4000h
src=src+2
if disp=4000h AND code=11h then goto @@decompress_done ;end code
if disp=4000h AND code<>11h then goto @@decompress_error
if code=20h..3Fh then
lzlen=code-20h+2
if lzlen=2 then
while [src]=00h, lzlen=lzlen+FFh, src=src+1
lzlen=lzlen+[src]+1Fh, src=src+1
rawlen=[src] AND 03h, disp=[src]/4+[src+1]*40h+1, src=src+2
if code=40h..FFh then
rawlen=code AND 03h
lzlen=(code/20h)+1
disp=((code/4) AND 07h)+([src]*8)+1, src=src+1
goto @@decompress_lop
@@decompress_done:
ret
|
| CDROM File Compression EA Methods |
0-7 ID (usually FBh) (or 31h for Method 4A31h with 16bit sizes) 8 Extended Header (usually 0) (or 1 for headers with extra entries) 9-14 Used to distinguish different methods 15 Extended Size (usually 0 for 24bit sizes) (or 1 for 32bit sizes) |
10FBh = LZSS Compression (RefPack) 90FBh = LZSS Compression (RefPack, with 32bit size) (not on PSX) 30FBh = Huffman Compression 32FBh = Huffman Compression with filter 34FBh = Huffman Compression with dual filter 46FBh = BPE Byte-Pair Encoding 4AFBh = RLE Run-Length Encoding 4A31h = RLE Run-Length Encoding, with 16bit size C0FBh = File Archive (not a compression method) |
PGA Tour 96, 97, 98 (*.* and *.VIV\*) (with method 10FBh) Need for Speed 3 Hot Pursuit (*.Q* with method 10FBh, 30FBh, 32FBh) |
FIFA - Road to World Cup 98 (*.PSH chunk C0h/C1h with method 10FBh) Sled Storm (MagDemo24: ART3\LOAD*.PSH chunk C0h/C1h with method 10FBh) WCW Mayhem (MagDemo28: WCWDEMO\*.BIG\*.PSH with chunk C0h/C1h with 10FBh) |
| CDROM File Compression EA Methods (LZSS RefPack) |
000h 2 Method (10FBh, or 11FBh,90FBh,91FBh) (big-endian) ... (3/4) Compressed size (24bit or 32bit) (optional) ... 3/4 Uncompressed size (24bit or 32bit) (big-endoan) ... .. Compressed data |
0ddzzzrrdddddddd rawlen=r(2), lzlen=z(3)+3, disp=d(10)+1 10zzzzzzrrdddddddddddddd rawlen=r(2), lzlen=z(6)+4, disp=d(14+1 110dzzrrddddddddddddddddzzzzzzzz rawlen=r(2), lzlen=z(10)+5, disp=d(17)+1 111rrrrr rawlen=r(5)*4+4, lzlen=0 111111rr rawlen=r(2), lzlen=0, endflag=1 |
method=BigEndian16bit[src], src=src+2
if (method AND 100h)>0 then src=src+3+method/8000h ;compressed size, if any
if (method AND 8000h]=0 then dst_size=BigEndian24bit[src], src=src+3
if (method AND 8000h)>0 then dst_size=BigEndian32bit[src], src=src+4
endflag=0
@@decompress_lop:
if ([src] AND 80h)=0 then
rawlen=[src] AND 03h
lzlen=([src] AND 1Fh)/4+3
disp=([src] AND 60h)*8+[src+1]+1
src=src+2
elseif ([src] AND 40h)=0 then
rawlen=[src+1]/40h
lzlen=[src] AND 3Fh+4
disp=([src+1] AND 3Fh)*100h+[src+2]+1
src=src+3
elseif ([src] AND 20h)=0 then
rawlen=[src] AND 03h
lzlen=([src] AND 0Ch)*40h+[src+3]+5
disp=([src] AND 10h)*1000h+[src+1]*100h+[src+2]+1
src=src+4
elseif ([src] AND FCh)=FCh then
rawlen=[src] AND 03h
lzlen=0
src=src+1, endflag=1
else
rawlen=([src] AND 1Fh)*4+4
lzlen=0
src=src+1
for i=1 to rawlen, [dst]=[src], src=src+1, dst=dst+1, next i
for i=1 to lzlen, [dst]=[dst-disp], dst=dst+1, next i
if endflag=0 then goto @@decompress_lop
if (dst-dst_base)<>dst_size then error
ret
|
| CDROM File Compression EA Methods (Huffman) |
000h 2 Method (30FBh..35FBh) (big-endian) ... (3) Extra 3 bytes (only present if Method.bit8=1) ... 3 Decompressed Size (big-endian) ... 1 Escape code ... .. Number of codes per width ... .. Data placement for each code ... .. Compressed Data |
decompress_ea_huffman:
method=GetBits(16) ;3xFBh ;-get method (30FBh..35FBh)
if method AND 100h then dummy=GetBits(24) ;-skip extra (if any)
dst_size=GetBits(24) ;-get uncompressed size
ESC=GetBits(8) ;-get escape code
huffwidth=0, huffcode=0, totalnumcodes=0 ;\
while (huffcode shl (10h-huffwidth))<10000h ;
num=GetVarLenCode ; get num codes per width
huffwidth=huffwidth+1 ;
numcodes_per_width[width]=num ;
totalnumcodes=totalnumcodes+num ;
huffcode=(huffcode*2)+num ;/
for i=0 to FFh, data_defined_flags[i]=00h ;\
dat=FFh, index=0 ;
while index<totalnumcodes ;
n=GetVarLenCode+1 ;- ; get/assign data values
while n>0 ;search Nth notyet defined entry ;
dat=(dat+1) AND FFh ;wrap in 8bit range! ;
if data_defined_flags[dat]=0 then n=n-1 ;
data_defined_flags[dat]=1 ;
data_values[index]=dat, index=index+1 ;/
huffcode=0000h, index=0 ;\
InitEmptyHuffTree(data_tree) ;
for width=1 to huffwidth ;
for i=1 to numcodes_per_width[width] ; create huffman tree
dat=data_values[index], index=index+1 ;
CreateHuffCode(data_tree,dat,huffcode,width) ;
huffcode=huffcode+(1 shl (10h-width) ;/
@@decompress_lop: ;\
dat=GetHuffCode(data_tree) ;
if dat<>ESC ;
[dst]=dat, dst=dst+1 ; decompress
else ;
num=GetVarLenCode ;
if num=0 then ;
if GetBits(1)=1 then goto @@decompress_done ;
[dst]=GetBits(8), dst=dst+1 ;
else ;
dat=[dst-1] ;
for i=0 to num-1, [dst]=dat, dst=dst+1 ;
goto @@decompress_lop ;/
@@decompress_done:
if (dst-dst_base)<>dst_size then error ;-error check
dst=dst_base, x=00h, y=00h ;\
if (method AND FEFFh)=32FBh ; optional final
for i=0 to dst_size-1, x=x+[dst+i], [dst+i]=x ; unfiltering
if (method AND FEFFh)=34FBh ;
for i=0 to dst_size-1, x=x+[dst+i], y=y+x, [dst+i]=y ;/
ret
;------------------
GetVarLenCode:
num=2
while GetBits(1)=0, num=num+1
return (GetBits(num)+(1 shl num)-4)
GetBits(num):
return "num" bits, fetched from big-endian bitstream
GetHuffCode(data_tree):
...
InitEmptyHuffTree(data_tree):
...
CreateHuffCode(data_tree,dat,huffcode,width):
...
numcodes_per_width[10h] ;9bit numcodes per width 0..15 (entry[0]=unused)
data_values[100h] ;8bit data values for up to 100h huffman codes
data_defined_flags[100h] ;1bit flags for data(00h..FFh)
|
| CDROM File Compression EA Methods (BPE) |
000h 2 Method (46FBh or 47FBh) (big-endian) ... (5) Extra 5 bytes (only present if Method=47FBh) ... 3 Decompressed Size (big-endian) ... 1 Escape code ... 1 Number of Dict entries (N) ... N*3 Dict (each 3 bytes: Index,Dat1,Dat2) ... .. Compressed Data |
method=BigEndian16bit[src], src=src+2
if method=47FBh then src=src+5
dst_size=BigEndian24bit[src], src=src+3
esc=[src], src=src+1
num=[src], src=src+1
for i=0 to FFh, dict1[i]=i ;initially default=self (uncompressed bytes)
for i=1 to num, j=[src], dict1[j]=[src+1], dict2[j]=[src+2], src=src+3
@@decompress_lop:
x=[src], src=src+1
if x=dict1[x] then
if x=esc then x=[src], src=src+1, if x=00h then goto @@decompress_done
[dst]=x, dst=dst+1
else
heap[0]=x, i=1
while i>0
i=i-1, x=heap[i], a=dict1[x]
if a=x then [dst]=x, dst=dst+1 ;\output data to
else b=dict2[x], heap[i]=b, heap[i+1]=a, i=i+2 ;/dst or heap
goto @@decompress_lop
@@decompress_done:
if (dst-dst_base)<>dst_size then error
ret
|
| CDROM File Compression EA Methods (RLE) |
000h 2 Method (4AFBh=24bit or 4A31h=16bit) (big-endian) ... 2/3 Decompressed Size (24bit or 16bit) (big-endian) ... .. Compressed Data |
00h..3Fh Copy 0..3Fh uncompressed bytes 40h..7Fh Load new fillbyte and fill 0..3Fh bytes 80h..BFh Use old fillbyte and fill 0..3Fh bytes (initial fillbyte=00h) C0h..FFh Copy 0..3Fh bytes with constant value in upper 4bit |
method=BigEndian16bit[src], src=src+2
if (method AND 00FFh)=31h then dst_size=BigEndian16bit[src], src=src+2
if (method AND 00FFh)<>31h then dst_size=BigEndian24bit[src], src=src+3
fillbyte=00h ;initially zero
@@decompress_lop:
type=[src]/40h, len=[src] AND 3Fh, src=src+1, dst_size=dst_size-len
if type=0 then ;\uncompressed bytes
for i=1 to len, [dst]=[src], src=src+1, dst=dst+1 ;/
elseif type=1 then ;\
fillbyte=[src], src=src+1 ; fill with new dat
for i=1 to len, [dst]=fillbyte, dst=dst+1 ;/
elseif type=2 then ;\fill with old dat
for i=1 to len, [dst]=fillbyte, dst=dst+1 ;/
elseif type=3 then
x=[src], [dst]=x, src=src+1, dst=dst+1, x=x AND F0h
for i=2 to len ;<-- or so?
if (i AND 1)=0 then [dst]=x+([src]/10h) dst=dst+1
if (i AND 1)=1 then [dst]=x+([src] AND 0Fh), dst=dst+1, src=src+1
if dst_size<>0 then goto @@decompress_lop
ret
|
| CDROM File Compression ZIP/GZIP/ZLIB (Inflate/Deflate) |
Twisted Metal 4 (MagDemo30: TM4DATA\*.MR\* and *.IMG\*) Kula Quest / Kula World / Roll Away (*.PAK) (*.PAK\*) (and probably more games... particulary files starting with "x") |
Final Fantasy VII (FF7) (BATTLE\TITLE.BIN) Gran Turismo 2 (MagDemo27: GT2\*) (with corrupted/zeropadded GZIP footers) Mat Hoffman's Pro BMX (old demo) (MagDemo39: BMX\BMXCD.HED\TITLE_H.ZLB) |
Mat Hoffman's Pro BMX (new demo) (MagDemo48: MHPB\FE.WAD+STR) |
Project Horned Owl (COMDATA.BIN, DEMODATA.BIN, ROLL.BIN, ST*DATA.BIN) |
Komocchi (DUMMY.BIN, a dummy padding file containing .MP3 pop songs) |
| Inflate - Core Functions |
tinf_init() ;init constants (needed to be done only once) tinf_align_src_to_byte_boundary() repeat bfinal=tinf_getbit() ;read final block flag (1 bit) btype=tinf_read_bits(2) ;read block type (2 bits) if btype=0 then tinf_inflate_uncompressed_block() if btype=1 then tinf_build_fixed_trees(), tinf_inflate_compressed_block() if btype=2 then tinf_decode_dynamic_trees(), tinf_inflate_compressed_block() if btype=3 then ERROR ;reserved until bfinal=1 tinf_align_src_to_byte_boundary() ret |
tinf_align_src_to_byte_boundary() len=LittleEndian16bit[src+0] ;get len if LittleEndian16bit[src+2]<>(len XOR FFFFh) then ERROR ;verify inverse len src=src+4 ;skip len values for i=0 to len-1, [dst]=[src], dst=dst+1, src=src+1, next i ;copy block ret |
repeat sym1=tinf_decode_symbol(tinf_len_tree) if sym1<256 [dst]=sym1, dst=dst+1 if sym1>256 len = tinf_read_bits(length_bits[sym1-257])+length_base[sym1-257] sym2 = tinf_decode_symbol(tinf_dist_tree) dist = tinf_read_bits(dist_bits[sym2])+dist_base[sym2] for i=0 to len-1, [dst]=[dst-dist], dst=dst+1, next i until sym1=256 ret |
sum=0, cur=0, len=0 repeat ;get more bits while code value is above sum cur=cur*2 + tinf_getbit() len=len+1 sum=sum+tree.table[len] cur=cur-tree.table[len] until cur<0 return tree.trans[sum+cur] |
val=0 for i=0 to num-1, val=val+(tinf_getbit() shl i), next i return val |
bit=tag AND 01h, tag=tag/2 if tag=00h then tag=[src], src=src+1, bit=tag AND 01h, tag=tag/2+80h return bit |
tag=01h ;empty/end-bit (discard any bits, align src to byte-boundary) ret |
| Inflate - Initialization & Tree Creation |
tinf_build_bits_base(length_bits, length_base, 4, 3) length_bits[28]=0, length_base[28]=258 tinf_build_bits_base(dist_bits, dist_base, 2, 1) ret |
for i=0 to 29 bits[i]=min(0,i-delta)/delta base[i]=base_val base_val=base_val+(1 shl bits[i]) ret |
for i=0 to 15, tinf_len_tree.table[i]=0, next i ;[0..15]=0 ;len tree... tinf_len_tree.table[7,8,9]=24,152,112 ;number of 7bit/8bit/9bit huffcodes for i=0 to 23, tinf_len_tree.trans[i+0] =i+256, next i ;[0..23] =256..279 for i=0 to 143, tinf_len_tree.trans[i+24] =i+0, next i ;[24..167] =0..143 for i=0 to 7, tinf_len_tree.trans[i+168]=i+280, next i ;[168..175]=280..287 for i=0 to 111, tinf_len_tree.trans[i+176]=i+144, next i ;[176..287]=144..255 for i=0 to 15, tinf_dist_tree.table[i]=0, next i ;[0..15]=0 ;\dist tinf_dist_tree.table[5]=32 ;number of 5bit huffcodes ; tree for i=0 to 31, tinf_dist_tree.trans[i]=i, next i ;[0..31]=0..31 ;/ ret |
hlit = tinf_read_bits(5)+257 ;get 5 bits HLIT (257-286) hdist = tinf_read_bits(5)+1 ;get 5 bits HDIST (1-32) hclen = tinf_read_bits(4)+4 ;get 4 bits HCLEN (4-19) for i=0 to 18, lengths[i]=0, next i for i=0 to hclen-1 ;read lengths for code length alphabet lengths[clcidx[i]]=tinf_read_bits(3) ;get 3 bits code length (0-7) tinf_build_tree(code_tree, lengths, 19) ;build code length tree for num=0 to hlit+hdist-1 ;decode code lengths for dynamic trees sym = tinf_decode_symbol(code_tree) len=1, val=sym ;default (for sym=0..15) if sym=16 then len=tinf_read_bits(2)+3, val=lengths[num-1] ;3..6 previous if sym=17 then len=tinf_read_bits(3)+3, val=0 ;3..10 zeroes if sym=18 then len=tinf_read_bits(7)+11, val=0 ;11..138 zeroes for i=1 to len, lengths[num]=val, num=num+1, next i tinf_build_tree(tinf_len_tree, 0, hlit) ;\build trees tinf_build_tree(tinf_dist_tree, 0+hlit, hdist) ;/ ret |
for i=0 to 15, tree.table[i]=0, next i ;clear code length count table ;scan symbol lengths, and sum code length counts... for i=0 to num-1, x=lengths[i+first], tree.table[x]=tree.table[x]+1, next i tree.table[0]=0 sum=0 ;compute offset table for distribution sort for i=0 to 15, offs[i]=sum, sum=sum+tree.table[i], next i for i=0 to num-1 ;create code to symbol xlat table (symbols sorted by code) x=lengths[i+first], if x<>0 then tree.trans[offs[x]]=i, offs[x]=offs[x]+1 next i ret |
clcidx[0..18] = 16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15 ;constants |
typedef struct TINF_TREE: unsigned short table[16] ;table of code length counts unsigned short trans[288] ;code to symbol translation table |
TINF_TREE tinf_len_tree ;length/symbol tree TINF_TREE tinf_dist_tree ;distance tree TINF_TREE code_tree ;temporary tree (for generating the dynamic trees) unsigned char lengths[288+32] ;temporary 288+32 x 8bit ;\for dynamic tree unsigned short offs[16] ;temporary 16 x 16bit ;/creation |
unsigned char length_bits[30] unsigned short length_base[30] unsigned char dist_bits[30] unsigned short dist_base[30] |
| Inflate - Headers and Checksums |
src_start=src, dst_start=dst ;memorize start addresses if (src[0]<>1fh or src[1]<>8Bh) then ERROR ;check id bytes if (src[2]<>08h) then ERROR ;check method is deflate flg=src[3] ;get flag byte if (flg AND 0E0h) then ERROR ;verify reserved bits src=src+10 ;skip base header if (flg AND 04h) then src=src+2+LittleEndian16bit[src] ;skip extra data if (flg AND 08h) then repeat, src=src+1, until [src-1]=00h ;skip file name if (flg AND 10h) then repeat, src=src+1, until [src-1]=00h ;skip file comment hcrc=(tinf_crc32(src_start, src-src_start) & 0000ffffh)) ;calc header crc if (flg AND 02h) then x=LittleEndian16bit[src], src=src+2 ;get header crc if (flg AND 02h) then if x<>hcrc then ERROR ;verify header tinf_uncompress(dst, destLen, src, src_start+sourceLen-src-8) ;----> inflate crc32=LittleEndian32bit[src], src=src+4 ;get crc32 of decompressed data dlen=LittleEndian32bit[src], src=src+4 ;get decompressed length if (dlen<>destLen) then ERROR ;verify dest len if (crc32<>tinf_crc32(dst_start,dlen)) then ERROR ;verify crc32 ret |
src_start=src, dst_start=dst ;memorize start addresses if (src[0]<>1fh or src[1]<>A1h) then ERROR ;check id bytes src=src+2 ;skip header tinf_uncompress(dst, destLen, src, sourceLen-0Ah) ;----> inflate crc32=LittleEndian32bit[src], src=src+4 ;get crc32 of decompressed data dlen=LittleEndian32bit[src], src=src+4 ;get decompressed length if (dlen<>destLen) then ERROR ;verify dest len if (crc32<>tinf_crc32(dst_start,dlen)) then ERROR ;verify crc32 ret |
src_start=src, dst_start=dst ;memorize start addresses hdr=BigEndian16bit[src], src=src+2 ;get header if (hdr MOD 31)<>0 then ERROR ;check header checksum (modulo) if (hdr AND 20h)>0 then ERROR ;check there is no preset dictionary if (hdr AND 0F00h)<>0800h then ERROR ;check method is deflate if (had AND 0F000h)>7000h then ERROR ;check window size is valid tinf_uncompress(dst, destLen, src, sourceLen-6) ;------> inflate chk=BigEndian32bit[src], src=src+4 ;get data checksum if src-src_start<>sourceLen then ERROR ;verify src len if dst-dst_start<>destLen then ERROR ;verify dst len if a32<>tinf_adler32(dst_start,destLen)) then ERROR ;verify data checksum ret |
s1=1, s2=0 while (length>0) k=max(length,5552) ;max length for avoiding 32bit overflow before mod for i=0 to k-1, s1=s1+[src], s2=s2+s1, src=src+1, next i s1=s1 mod 65521, s2=s2 mod 65521, length=length-k return (s2*10000h+s1) |
| CDROM File Compression LArc/LHarc/LHA (LZS/LZH) |
PSX Championship Surfer (MagDemo43: HWX\*.DAT) ;method lh5 PSX Net Yaroze Demo Disc SLED-01340 (DATA\JAPAN\*.FPC\*.LZH) ;method lh5 |
LHA Header+Data for 1st file LHA Header+Data for 2nd file End Marker (00h) |
00h 1 Header Size (Method up to including Extended Area) (=16h+F+E)
01h 1 Header Checksum, sum of bytes at [02h+(0..15h+F+E)]
02h 5 Compression Method (eg. "-lh0-"=Uncompressed)
07h 4 Compressed Size
0Bh 4 Uncompressed Size
0Fh 2 Last modified time (in MS-DOS format)
11h 2 Last modified date (in MS-DOS format)
13h 1 MS-DOS File attribute (usually 20h)
14h 1 Header level (must be 00h for v0)
15h 1 Path\Filename Length
16h (F) Path\Filename (eg. "PATH\FILENAME.EXT")
'\' may apper in the 2nd byte of Shift_JIS, processing
of Shift_JIS is indispensable when you need full
implementation of reading Pathname.
16h+F 2 CRC16 (with initial value 0000h) on uncompressed file
18h+F (E) Extended area (used by UNIX in v0)
18h+F+E .. Compressed data
|
00h 1 Header Size (Method up to including 1st Ext Size) (=19h+F+E) 01h 1 Base Header Checksum, sum of bytes at [02h+(0..18h+F+E)] 02h 5 Compression Method (eg. "-lh0-"=Uncompressed) 07h 4 Skip size (size of all Extended Headers plus Uncompressed Size) 0Bh 4 Uncompressed Size 0Fh 2 Last modified time (in MS-DOS format) 11h 2 Last modified date (in MS-DOS format) 13h 1 Reserved (must be 20h) (but is 02h on Amiga) 14h 1 Header level (must be 01h for v1) 15h 1 Length of Filename (or 00h when name is in Extended Header) 16h (F) Filename (eg. "FILENAME.EXT; path (if any) is in Extended Header) 16h+F 2 CRC16 (with initial value 0000h) on uncompressed file 18h+F 1 Compression Tool OS ID (eg. "M"=MSDOS) 19h+F (E) Extended area (unused in v1, use Ext Headers instead) 19h+F+E 2 Size of 1st Extended Header (0000h=None) 1Bh+F+E .. Extended Header(s) (optional stuff) ... .. Compressed data |
00h 2 Header Size (whole Header including all Extended Headers) 02h 5 Compression Method (eg. "-lh0-"=Uncompressed) 07h 4 Compressed Size 0Bh 4 Uncompressed Size 0Fh 4 Last modified date and time (seconds since 1st Jan 1970 UTC) 13h 1 Reserved (must be 20h) (but is 02h on Amiga) 14h 1 Header level (must be 02h for v2) 15h 2 CRC16 (with initial value 0000h) on uncompressed file 17h 1 Compression Tool OS ID (eg. "M"=MSDOS) 18h 2 Size of first Extended Header (0000h=None) 1Ah .. Extended Header(s) (filename and optional stuff) ... 0/1 Nullbyte (End-Marker conflict: change Headersize xx00h to xx01h) ... .. Compressed data |
00h 2 Word size for 32bit Header entries (always 4=32bit) 02h 5 Compression Method (eg. "-lh0-"=Uncompressed) 07h 4 Compressed Size 0Bh 4 Uncompressed Size 0Fh 4 Last modified date and time (seconds since 1st Jan 1970 UTC) 13h 1 Reserved (must be 20h) 14h 1 Header level (must be 03h for v3) 15h 2 CRC16 (with initial value 0000h) on uncompressed file 17h 1 Compression Tool OS ID (eg. "M"=MSDOS) 18h 4 Header Size (whole Header including all Extended Headers) 1Ch 4 Size of first Extended Header (00000000h=None) 20h .. Extended Header(s) (filename and optional stuff) ... .. Compressed data |
Method Len Window -lz4- - - - LArc Uncompressed File -lh0- - - - LHA Uncompressed File -lhd- - - - LHA Uncompressed Directory name entry -lzs- 2..17 2Kbyte LArc LZSS-Compressed (rare, very-very old) ;-15bit -lz5- 3..17 4Kbyte LArc LZSS-Compressed (LArc srandard) ;-16bit -lh1- 3..60 4Kbyte LHA LZHUF-Compressed (old LHA standard) -lh2- 3..256 8Kbyte LHA Obscure test (used in self-extractor) -lh3- 3..256 8Kbyte LHA Obscure test (experimental) -lh4- 3..256 4Kbyte LHA AR002-Compressed (rare, for small RAM) ;\4bit -lh5- 3..256 8Kbyte LHA AR002-Compressed (new LHA standard) ;/ -lh6- 3..256 32Kbyte LHA AR002-Compressed (rare) ;\ -lh7- 3..256 64Kbyte LHA AR002-Compressed (rare) ; 5bit -lh8- 3..256 64Kbyte LHA AR002-Compressed (accidently same as lh7) ; -lh9- 3..256 128Kbyte LHA AR002-Compressed (unimplemented proposal) ; -lha- 3..256 256Kbyte LHA AR002-Compressed (unimplemented proposal) ; -lhb- 3..256 512Kbyte LHA AR002-Compressed (unimplemented proposal) ; -lhc- 3..256 1Mbyte LHA AR002-Compressed (unimplemented proposal) ; -lhe- 3..256 2Mbyte LHA AR002-Compressed (unimplemented proposal) ; -lhx- 3..256 512Kbyte LHA AR002-Compressed (rare) ;/ |
00h 1 Extension Type (00h..FFh, eg. 01h=Filename) 01h .. Extension Data ... 2/4 Size of next Extended Header (0=None) (v1/v2=16bit, v3=32bit) |
00h CRC16 on whole Header with InitialValue=0000h and InitialCrcEntry=0000h 01h Filename 02h Directory name (with FFh instead of "\", and usually with trailing FFh) 3Fh Comment (unspecified format/purpose) 40h MS-DOS File attribute of MS-DOS format 41h Windows FILETIME for last access, creation, and modification 42h Filesize (uncompressed and compressed size, when exceeding 32bit) 50h Unix Permission 51h Unix User ID and Group ID 52h Unix Group name 53h Unix User name (owner) 54h Unix Last modified time in time_t format 7Dh Capsule offs/size (if the OS adds extra header/footer to the filebody) 7Eh OS/2 Extended attribute 7Fh Level 3 Attribute in Unix form and MS-DOS form FFh Level 3 Attribute in Unix form |
http://fileformats.archiveteam.org/wiki/LHA |
| CDROM File Compression UPX |
000h 88h Standard PS-X EXE header 088h 20h Unknown 0A8h 4 ASCII ID "UPX!" 0ACh 1Eh Unknown 0CAh 9Ah ASCII "$info: This file is ..." 164h 69Ch Zerofilled 800h .. Leading zeropadding (to make below end on 800h-byte boundary) ... .. Decompression stub ... .. Compressed data (ending on 800h-byte boundary) |
| CDROM File Compression LZMA |
000h 1 Ignored byte (usually 00h, unknown purpose) 001h .. Bitstream with actual compression codes ... .. EOS end code (end of stream) (optional) ... .. Ignored byte (present in case of Normalization after last code) ... .. Padding to byte-boundary |
Three decompression parameters: lc, lp, pb Decompressed size (required if the bitstream has no EOS end code) Dictionary size (don't care when decompressing the whole file to memory) Presence/Absence of EOS end code |
000h 1 Parameters (((pb*5)+lp)*9)+lc (usually 5Dh) ;\ 001h 4 Dictionary Size in bytes (usually 10000h) ; Header 005h 8 Decompressed Size in bytes (or -1=Unknown) ;/ 00Dh 1 LZMA ignored 1st byte of bitstream (00h) ;\LZMA 00Eh .. LZMA bitstream (with optional EOS end code) ;/ |
000h .. LZIP Member(s) ... .. Optional extra data (if any) (eg. zeropadding or some SHA checksum) |
000h 5 ID and version ("LZIP",01h) ;\LZIP Header
005h 1 Dictionary size (5bit+3bit code, see below) ;/
006h .. LZMA bitstream (with lc=3, lp=0, pb=2) (with EOS end code)
... 4 CRC32 on uncompressed data ;\
... 8 Size of uncompressed data ; LZIP Footer
... 8 Size of compressed data (including header+footer) ;/
|
temp = 1 SHL (hdr[005h] AND 1Fh) dict_size = temp - (temp/10h)*(hdr[005h]/20h) |
http://www.nongnu.org/lzip/manual/lzip_manual.html#File-format |
000h .. LZMA bitstream (with lc=3, lp=0, pb=2) (without EOS end code) |
000h 6 ID ("7z",BCh,AFh,27h,1Ch)
... .. ..
|
ChunkID=00h - Last chunk: 000h 1 Chunk ID (00h=End) ChunkID=01h..02h - Uncompressed chunks: 000h 1 Chunk ID (01h=Uncompressed+ResetDictionary, 02h=Uncompressed) 001h 2 Uncompressed Data Size-1 (big-endian) 003h .. Uncompressed Data (to be copied to destination and dictionary) Note: The uncompressed data is stored in LZMA dictionary, and the last uncompressed byte is updating the LZMA prevbyte. ChunkID=03h..7Fh - Invalid chunks: 000h 1 Chunk ID (03h..7Fh=Invalid) ChunkID=80h..FFh - LZMA-compressed chunks: 000h 1 Chunk ID (80h/A0h/C0h/E0h + Upper5bit(UncompressedSize-1)) 001h 2 LSBs(UncompressedSize-1) (big-endian) 003h 2 CompressedSize-1 (big-endian) 005h (1) Parameters (((pb*5)+lp)*9)+lc (only present if ChunkID=C0h..FFh) ... .. LZMA bitstream (without EOS end code) |
ChunkID dict/prev lc/lp/pb state dist[0-3] probabilities code/range 01h reset - - - - - 02h - - - - - - 80h+n - - - - - reset A0h+n - - reset reset reset reset C0h+n - reset reset reset reset reset E0h+nn reset reset reset reset reset reset (Note: Those resets occur before processing the chunk data) |
Dictionary Size byte (00h..28h = 4K,6K,8K,12K,16K,24K,..,2G,3G,4G) Which can be decoded as so: if (param AND 1)=0 then dict_size=1000h shl (param/2) if (param AND 1)=1 then dict_size=1800h shl (param/2) if param=28h then dict_size=FFFFFFFFh ;4GB-1 if param>28h then error In .xz files, that byte is stored alongsides with the Filter ID. |
https://github.com/ilyakurdyukov/micro-lzmadec |
| CDROM File Compression XZ |
000h .. Stream(s) |
000h 6 Header ID (FDh,"7zXZ",00h) (FDh,37h,7Ah,58h,5Ah,00h) ;\
006h 2 Checksum Type (0000h, 0100h, 0400h or 0A00h) ; Header
008h 4 Header CRC32 on above 2 bytes ;/
00Ch .. Compressed Block(s) ;-Block(s)
... .. Index List ;-Index
... 4 Footer CRC32 on below 6 bytes ;\
... 4 Index List Size/4-1 ; Footer
... 2 Checksum Type (must be same as in Header) ;
... 2 Footer ID ("YZ") (59h,5Ah) ;/
... .. Optional Zeropadding (multiple of 4 bytes) ;-Padding
Checksum Type (for Block checksums):
0000h=None
0100h=CRC32 (little-endian)
0400h=CRC64 (little-endian)
0A00h=SHA256 (big-endian)
Other=Reserved
|
000h 1 Index Indicator (00h) (as opposed to 01h..FFh in Block Headers) 001h VL Number of Records (must be same as number of Blocks in Stream) ... .. Index Record(s) ... .. Zeropadding to 4-byte boundary ... 4 CRC32 on above bytes Index Record: 000h VL Unpadded Block Size (BlockHeader + CompressedData + 0 + Checksum) ... VL Uncompressed Block Size |
000h 1 Block Header Size/4-1 (01h..FFh = 8..400h bytes) ;\ 001h 1 Block Flags ; 002h (VL) Compressed Size ;present if Flags.bit6 = 1 ; Header ... (VL) Uncompressed Size ;present if Flags.bit7 = 1 ; ... .. Filter Info 0 (LAST filter when DECOMPRESSING) ; ... (..) Filter Info 1 ;present if Flags.bit0-1 = 1,2,3 ; ... (..) Filter Info 2 ;present if Flags.bit0-1 = 2,3 ; ... (..) Filter Info 3 ;present if Flags.bit0-1 = 3 ; ... .. Zeropadding to 4-byte boundary ; ... (..) Optional Zeropadding (multiple of 4 bytes) ; ... 4 CRC32 on above bytes ;/ ... .. Compressed Data ;-Data ... .. Zeropadding to 4-byte boundary ;-Pad ... (..) Checksum on uncompressed Data (None/CRC32/CRC64/SHA256) ;-Check Block Flags: 0-1 Number of filters-1 (0..3 = 1..4 filters) 2-5 Reserved (0) 6 Compressed Size field is present (0=No, 1=Present) 7 Uncompressed Size field is present (0=No, 1=Present) Filter Info: 000h VL Filter ID ... VL Size of Filter Properties ... .. Filter Properties Filter IDs: 03h Delta Filter (with 1 byte param) 04h..09h Executable Filters (with 0 or 4 byte param) 21h LZMA2 Compression (with 1 byte param) 300h..4FFh Reserved to ease .7z compatibility 20000h..7FFFFh Reserved to ease .7z compatibility 2000000h..7FFFFFFh Reserved to ease .7z compatibility xxxxxxxxxxxxxxxxh Custom Registered IDs (obtained from Lasse Collin) 3Frrrrrrrrrriiiih Custom Random IDs (40bit random+16bit filterno) 4000000000000000h and up Reserved for internal use (don't use in xz files) |
The filter parameter is 1 byte tall: Dictionary Size byte (00h..28h = 4K,6K,8K,12K,16K,24K,..,2G,3G,4G) The compressed data contains: LZMA2 chunks (with LZMA-compressed data and/or uncompressed data) |
Distance-1 (00h..FFh = distance 1..100h) unfilter_delta(buf,len,param_byte): dist=byte(param)+1, i=dist ;init dist and skip first some unfiltered bytes while i<len, byte(buf[i]) = buf[i]+buf[i-dist], i=i+1 |
ID Parameters Alignment Description 04h 0 or 4 bytes 1 byte 80x86 filter (32bit or 64bit) 05h 0 or 4 bytes 4 bytes PowerPC filter (big endian) 06h 0 or 4 bytes 16 bytes IA64 filter 07h 0 or 4 bytes 4 bytes ARM filter (little endian) 08h 0 or 4 bytes 2 bytes ARM Thumb filter (little endian) 09h 0 or 4 bytes 4 bytes SPARC filter 0Ah,0Bh Inofficial hacks/proposals for ARM64? |
if param_size=0 then offset=00000000h
if param_size=4 then offset=LittleEndian32bit(param)
Nonzero offsets are intended for executables with multiple sections and
cross-section jumps. The offset shall/must match the filter's alignment.
unfilter_bcj_x86(buf,len,offset):
i=0, len=len-4, offset=offset+4
while i<len
x=byte[buf+i], i=i+1
if (x AND FEh)=E8h ;Opcode=E8h or E9h
x=LittleEndian32bit[buf+i]
if ((x+01000000h) AND FE000000h)=0 ;MSB=00h or FFh
LittleEndian32bit[buf+i]=SignExpandLower25bit(x-i-offset)
i=i+4
unfilter_bcj_arm(buf,len,offset):
i=0, len=len/4, offset=(offset+8)/4
while i<len
x=LittleEndian32bit[buf+i*4]
if (x AND FF000000h)=EB000000h
LittleEndian32bit[buf+i*4]=((x-i-offset) and 00FFFFFFh)+EB000000h
i=i+1
unfilter_bcj_armthumb(buf,len,offset):
i=0, len=len/2-1, offset=(offset+4)/2
while i<len
x=LittleEndian32bit[buf+i*2]
if (x AND F800F800h)=F800F000h
msw=LittleEndian16bit[buf+i*2+0] AND 7FFh
lsw=LittleEndian16bit[buf+i*2+2] AND 7FFh
x=msw*800h+lsw-i-offset
LittleEndian16bit[buf+i*2+0]=F000h+(7FFh and (x/800h))
LittleEndian16bit[buf+i*2+2]=F800h+(7FFh and (x/1))
i=i+1
unfilter_bcj_sparc(buf,len,offset):
i=0, len=len/4, offset=offset/4
while i<len
x=BigEndian32bit[buf+i*4]
if (x AND FFC00000h)=40000000h or (x AND FFC00000h)=7FC00000h
x=SignExpandLower23bit(x-i-offset)
BigEndian32bit[buf+i*4]=(x AND 3FFFFFFFh)+40000000h
i=i+1
unfilter_bcj_powerpc(buf,len,offset):
i=0, len=len/4, offset=offset/4
while i<len
x=BigEndian32bit[buf+i*4]
if (x AND FC000003h)=48000001h
BigEndian32bit[buf+i*4]=(((x/4-i-offset) AND 00FFFFFFh)*4)+48000001h
i=i+1
unfilter_bcj_ia64(buf,len,offset):
i=0, len=len/10h, offset=offset/10h
xlat[0..1Fh]=0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,4,4,6,6,0,0,7,7,4,4,0,0,4,4,0,0
while i<len
flags=xlat[byte[buf] and 1Fh] ;shared 5bit for three 41bit opcodes
for slot=0 to 2
if flags and (1 shl slot) ;process three 41bit opcodes
bitbase=slot*41+5
hi=byte[buf+(bitbase+37)/8] shr ((bitbase+37) and 7) and 0Fh
lo=LittleEndian16bit[buf+(bitbase+9)/8] shr ((bitbase+9) and 7) and 07h
if hi=5 and lo=0
mid=LittleEndian32bit[buf+(bitbase+13)/8]
x=mid shr ((bitbase+13) and 7)
x=x and 8FFFFFh, if (x and 800000h) then x=x-700000h
x=x-i-offset
x=x and 1FFFFFh, if (x and 100000h) then x=x+700000h
mid=mid AND NOT (8FFFFFh shl ((bitbase+13) and 7)) ;strip old
mid=mid OR x shl ((bitbase+13) and 7)) ;place new
LittleEndian32bit[buf+(bitbase+13)/8]=mid ;apply
i=i+1, buf=buf+10h
|
decode_variable_len_integer: i=0, num=0 @@lop: x=[src], src=src+1, num=num+((x and 7Fh) shl i), i=i+7 if x AND 80h then goto @@lop return num |
https://tukaani.org/xz/format.html |
http://web.archive.org/web/20220603034213/https://tukaani.org/xz/format.html |
https://www.mail-archive.com/xz-devel@tukaani.org/msg00537.html |
| CDROM File Compression FLAC audio |
000h 4 FLAC ID ("fLaC")
004h .. Metadata block with STREAMINFO
... .. Metadata block(s) with further info (optional)
... .. FLAC Frame(s)
|
1bit Last Metadata block flag (1=Last, 0=More blocks follow) 7bit Block Type (see below) 24bit Size of following metadata in bytes (N) N*8bit Metadata (depending on Type) |
00h = STREAMINFO 01h = PADDING 02h = APPLICATION 03h = SEEKTABLE 04h = VORBIS_COMMENT 05h = CUESHEET 06h = PICTURE .. = Reserved 7Fh = Invalid (to avoid confusion with a frame sync code) |
16bit Minimum Block size in samples (10h..FFFFh) ;\min=max implies 16bit Maximum Block size in samples (10h..FFFFh) ;/fixed blocksize 24bit Minimum Frame size in bytes (or 0=Unknown) 24bit Maximum Frame size in bytes (or 0=Unknown) 20bit Sample rate in Hertz (01h..9FFF6h = 1..655350 Hz) 3bit Number of channels-1 (00h..07h = 1..8 channels) 5bit Bits per sample-1 (03h..1Fh = 4..32 bits) (max 24bit implemented) 36bit Total number of samples per channel (or 0=Unknown) 128bit MD5 on unencoded audio data (...in which format? endian/interleave?) |
https://xiph.org/flac/format.html |
http://web.archive.org/web/20201208111432/https://xiph.org/flac/format.html |
https://www.nayuki.io/page/simple-flac-implementation |
| CDROM File Compression ARJ |
Main header chunk Local file chunk(s) Chapter chunk(s), backup related, exist only in newer archives End Marker |
000h 2 ARJ ID (EA60h, aka 60000 decimal)
002h 2 Header size (from 004h up to including Filename+Comment) (max 2600)
004h 1 Header size (from 004h up to including Extra Data) (1Eh+extra)
005h 1 Archiver version number (01h..0xh)
006h 1 Minimum archiver version to extract (usually 01h)
007h 1 Host OS
008h 1 ARJ Flags (bit0-7, see below)
009h 1 Security version (2 = current)
00Ah 1 File Type (must be 2=ARJ Comment in main header)
00Bh 1 Reserved/Garbage (LSB of Archive creation Date/Time, same as [00Ch])
00Ch 4 Date/Time when archive was created
010h 4 Date/Time when archive was last modified
014h 4 Zero (or Secured Archive size, excluding Security and Protection)
018h 4 Zero (or Security envelope file position) (after End Marker)
01Ch 2 Zero (or Filespec position in filename) (0) (what is that??)
01Eh 2 Zero (or Security envelope size in bytes) (78h, if any)
020h 1 Zero (or >2.50?: Encryption version, 0-1=Old, 2=New, 4=40bit GOST)
021h 1 Zero (or >2.50?: Last chapter (eg. 4 when having chapter 1..4)
022h (1) Extra data: ARJ Protection factor ;\extra,
023h (1) Extra data: ARJ Flags (bit0=ALTVOLNAME, bit1=ReservedBit) ; if any
024h (2) Extra data: Spare bytes ;/
... .. Filename, max 500 bytes ("FILENAME.ARJ",00h)
... .. Comment, max 2048 bytes ("ASCII Comment",00h)
... 4 CRC32 on Header (from 004h up to including Comment)
... 2 Size of 1st extended header (usually 0=none)
... (0) Extended Header(s?) (usually none such)
|
000h 2 ARJ ID (EA60h, aka 60000 decimal)
002h 2 Header size (from 004h up to including Filename+Comment) (max 2600)
004h 1 Header size (from 004h up to including Extra Data) (1Eh+extra)
005h 1 Archiver version number
006h 1 Minimum archiver version to extract (usually 01h)
007h 1 Host OS
008h 1 ARJ Flags (bit0,2-5)
009h 1 Method
00Ah 1 File Type (0=Binary, 1=Text, 3=Directory Name, 4=Volume Name)
00Bh 1 Reserved/Garbage (LSB of Archive update Date/Time?)
00Ch 4 Date/Time modified
010h 4 Filesize, compressed (max 7FFFFFFFh)
014h 4 Filesize, uncompressed
018h 4 CRC32 on uncompressed file data
01Ch 2 Zero (or Filespec position in filename) (what is that??)
01Eh 2 File access mode (aka MSDOS file attribute) (20h=Normal)
020h 1 Zero (or >2.50?: first chapter of file's lifespan)
021h 1 Zero (or >2.50?: last chapter of file's lifespan)
022h (4) Extra data: Extended file position (maybe for split?) ;\extra,
026h (4) Extra data: Date/Time accessed ;\ARJ ; 0,4 or 10h
03Ah (4) Extra data: Date/Time created ; 2.62 ; bytes
03Eh (4) Extra data: Original file size even for volumes ;/ ;/
... .. Filename, max 500 bytes ("PATH/FILENAME.EXT",00h)
... .. Comment, max 2048 bytes ("ASCII Comment",00h)
... 4 CRC32 on Header (from 004h up to including Comment)
... 2 Size of 1st extended header (usually 0=none)
... (0) Extended Header(s?) (usually none such)
... .. Compressed file data
|
000h 2 ARJ ID (EA60h, aka 60000 decimal)
002h 2 Header size (from 004h up to including Filename+Comment) (max 2600)
004h 1 Header size (from 004h up to including Extra Data) (1Eh+extra)
005h 1 Archiver version number (eg. 0Ah=2.75a)
006h 1 Minimum archiver version to extract (usually 01h)
007h 1 Host OS
008h 1 ARJ Flags (usually 00h)
009h 1 Method (usually 01h, although chapters have no data) what file???
00Ah 1 File Type (must be 5=ARJ Chapter)
00Bh 1 Reserved/Garbage (LSB of Chapter Date/Time, same as [00Ch])
00Ch 4 Date/Time stamp created
010h 4 Zero (or reportedly, ?) what question?
014h 4 Zero (or reportedly, ?) what question?
018h 4 Zero (or reportedly, original file's CRC32) what file???
01Ch 2 Zero (or reportedly, entryname position in filename) what file???
01Eh 2 Zero (or reportedly, file access mode) what file???
020h 1 Chapter range start (01h=First chapter?) what range???
021h 1 Chapter range end (contains same value as above) what range???
022h (4) Extra data: Extended file position (usually none such)what extra???
... .. Filename ("<<<001>>>",00h for First chapter)
... .. Comment ("",00h)
... 4 CRC32 on Header (from 004h up to including Comment)
... 2 Size of 1st extended header (usually 0=none)
... (0) Extended Header(s?) (usually none such)
|
000h 2 ARJ ID (EA60h, aka 60000 decimal) 002h 2 Header size (0=End) |
0 = stored (uncompressed) 1 = compressed most (default) (Window=6800h=26Kbyte, Chars=255, Tree=31744) 2 = compressed medium (Window=5000h=20Kbyte, Chars=72, Tree=30720) 3 = compressed less (Window=2000h=8Kbyte, Chars=32, Tree=30720) 4 = compressed least/fastest (Window=6800h? or 8000h?) 8 = no data, no CRC ;\unknown if/where that is used (maybe only used 9 = no data ;/internally, and never stored in actual files?) |
0 = binary file (default) 1 = text file (with converted line breaks, via -t1 switch) 2 = ARJ comment header (aka ARJ main file header) 3 = directory name 4 = volume label (aka disc name) 5 = ARJ chapter label (aka begin of newer backup sections) |
0 GARBLED
1 OLD_SECURED has old signature (with signature in Main Header?)
1 ANSIPAGE ANSI codepage used by ARJ32 (for what? for "FILENAME.ARJ"?)
2 VOLUME presence of succeeding volume
3 ARJPROT
4 PATHSYM archive name translated ("\" changed to "/")
5 BACKUP obsolete
6 SECURED has new signature (in security envelope?)
7 ALTNAME dual-name archive
|
0 GARBLED passworded file
1 NOT USED
2 VOLUME continued file to next volume (file is split)
3 EXTFILE file starting position field (for split files)
4 PATHSYM filename translated ("\" changed to "/")
5 BACKUP_FLAG obsolete
|
0 GARBLED ;\ 1 RESERVED ; 2 VOLUME ; what does that mean in Chapters??? 3 EXTFILE ; 4 PATHSYM ;/ 5 BACKUP obsolete < 2.50a ;-how can obsolete exist in Chapters??? 6 RESERVED |
0=MSDOS, 1=PRIMOS, 2=UNIX, 3=AMIGA, 4=MACDOS (aka MAC-OS) 5=OS/2, 6=APPLE GS, 7=ATARI ST, 8=NEXT 9=VAX VMS, 10=WIN95, 11=WIN32 (aka WinNT or so?) |
@@decompress_lop:
if dst>=dst_end then goto @@decompress_done
width=count_ones(max=7), len = get_bits(width) + (1 shl width)+1
if len=2 then
[dst]=get_bits(8), dst=dst+1
else ;len>=3
width=count_ones(max=4)+9, disp = get_bits(width) + (1 shl width)-1FFh
for i=1 to len, [dst]=[dst-disp], dst=dst+1, next i
goto @@decompress_lop
@@decompress_done:
ret
;---
count_ones(max):
num=0
@@lop:
if get_bits(1)=1 then
num=num+1, if num<max then goto @@lop
return num
|
| CDROM File Compression ARC |
000h 1 Fixed ID (1Ah)
001h 1 Compression Method (00h..1Fh)
002h 13 Filename ("FILENAME.EXT",00h) (garbage-padded if shorter)
00Fh 4 Filesize, compressed
013h 4 File Timestamp in MSDOS format
017h 2 CRC16 with initial value 0000h on uncompressed/decrypted file
019h (4) Filesize, uncompressed ;<-- not present for Method=1
... .. Compressed file data (size as stored in [00Fh])
|
Method 00h and 1Fh --> Chunksize=02h (archive/subdir end markers) Method 01h --> Chunksize=19h+[0Fh] (old uncompressed ARC archives) Others Methods --> Chunksize=1Dh+[0Fh] (normal case) |
00h End-of-archive marker (1Ah,00h) 01h ARC v? Uncompressed (with short 19h-byte header) 02h ARC v? Uncompressed (with normal 1Dh-byte header) 03h ARC v? Packed (RLE90) Used for small files 04h ARC v? Squeezed (RLE90+Huffman) Based on CP/M Squeeze 05h ARC v4.00 Crunched (OldRandomizedLZW) Derived from LZWCOM 06h ARC v4.10 Crunched (RLE90+OldRandomizedLZW) Alike CP/M Crunch v1.x 07h ARC vBeta? Crunched (RLE90+NewRandomizedLZW) Leaked beta version? 08h ARC v5.00 Crunched (RLE90+ClearGap12bitLZW) Most common ARC method 09h Inofficial Squashed (ClearGap13bitLZW) Used by PKARC/PKPAK 0Ah ARC v7.xx Trimmed (RLE90+LZHUF) Based on LHArc lh1 0Ah Inofficial Crushed (RLE90+LZW/LZMW?) PAK 0Bh Inofficial Distilled (LZ77+Huffman) PAK v2.0 14h-1Dh ARC v6.0 Used/reserved for Information items: 14h Archive info 15h Extended File info (maybe a prefix(?) for actual file entries?) 16h OS-specific info 1Eh-27h ARC v6.0 Used/reserved for Control items: 1Eh ARC v6.00 Subdir (nested ARC-like format, created by the "z" option) 1Fh ARC v6.00 End-of-subdir marker (1Ah,1Fh) 48h Not used in ARC ;\Hyper archives start with 1Ah,48h or 1Ah,53h 53h Not used in ARC ;/(an unrelated format that also starts with 1Ah) 80h-xxh Not used in ARC ;-Spark archives (ARC-like, with extended headers) |
000h 2 Item size (LEN) 002h 1 Item Subtype 003h .. Item Data (LEN-3 bytes) |
Method=14h, Subtype=0 Archive description (eg. "Comment blah",00h) Method=14h, Subtype=1 Archive creator program name (eg. "ARC 7.12 ...",00h) Method=14h, Subtype=2 Archive modifier program name Method=15h, Subtype=0 File description (eg. "Comment blah",00h) Method=15h, Subtype=1 File long filename (if not MS-DOS "8.3" filename) Method=15h, Subtype=2 File extended date-time info (reserved) Method=15h, Subtype=3 File Icon (reserved) Method=15h, Subtype=4 File attributes (see below) (eg. "RWHSN",00h) Method=16h, Subtype=.. Operating system info (reserved) |
R=ReadAccess, W=WriteAccess, H=HiddenFile, 1=SystemFile, N=NetworkShareable |
90h,00h Output 90h, but DON'T change prevbyte ;<-- ARC
90h,00h Output 90h, and DO set prevbyte=90h ;<-- BinHex
90h,00h Output 90h, and UNKNOWN what to do ;<-- StuffIt
90h,01h..03h Output prevbyte 00h..02h times (this is not useful)
90h,04h..FFh Output prevbyte 03h..FEh times (this does save memory)
xxh Output xxh, and memorize prevbyte=xxh
arc_decompress_rle90:
src_end = src+src_size
prevbyte = <initially undefined in ARC source code>
@@decompress_lop:
if src>=src_end then goto @@decompress_done
x=[src], src=src+1
if x<>90h then
[dst]=x, dst=dst+1, prevbyte=x ;output x, and memorize prevbyte=x
else ;x=90h
x=[src], src=src+1
if x=00h then
[dst]=90h, dst=dst+1 ;output 90h, but DO NOT change prevbyte
if BinHex then prevbyte=90h ;for BinHex, DO change prevbyte
else
for i=1 to x-1, [dst]=prevbyte, dst=dst+1, next i
goto @@decompress_lop
|
000h 2 Number of Tree entries (0..100h) (when 0, assume tree=FEFFh,FEFFh)
002h N*4 Tree entries (16bit node0, 16bit node1)
... .. Huffman bitstream (starting in bit0 of first byte)
... .. Maybe supposedly padding to byte boundary?
The 16bit nodes are:
0000h..00FFh Next Tree index
0100h..FEFEh Invalid
FEFFh End of compressed data
FF00h..FFFFh Data values FFh..00h (these are somewhat inverted/reversed)
arc_decumpress_squeeze:
if [src]=0000h then tree=empty_tree, else tree=src+2 ;-start tree
InitBitstreamLsbFirst(src+2+[src]*4) ;-start bitstream
@@decompress_lop:
index=0000h ;\
while index<FEFFh ; huffman decode
index=[tree+index*4+GetBits(1)*2] ;/
if index>FEFFh then ;-check end code
[dst]=(index XOR FFh) AND FFh), dst=dst+1 ;-store data
goto @@decompress_lop
return
empty_tree dw FEFFh,FEFFh ;upen empty tree, ARC defines two 1bit END codes
|
arc_decompress_randomized_lzw: num_free=1000h, stack=empty, oldcode=-1 for i=0 to FFFh, lzw_parent[i]=EEEEh ;mark all codes as unused if method=1 then create_code(0000h,00h) ;create end code (cpm crunch v1) for i=0 to FFh, create_code(FFFFh,i) ;codes for 00h..FFh with parent=none @@decompress_lop: if method>1 and and src>=src_end then goto @@decompress_done code=GetBitsMsbFirst(12), i=code if method=1 and code=0 then goto @@decompress_done ;end code (cpm crunch v1) if lzw_parent[i]=EEEEh then i=oldcode, push(oldbyte) ;-for KwKwK strings while lzw_parent[i]<>FFFFh, push(lzw_data[i]), i=lzw_parent[i] oldbyte=lzw_data[i], [dst]=oldbyte, dst=dst+1 if oldcode<>-1 then create_code(oldcode,oldbyte) oldcode=code while stack<>empty, [dst]=pop(), dst=dst+1 goto @@decompress_lop @@decompress_done: ret ;--- create_code(parent,data): if num_free=0 then goto @@no_further_codes, else num_free=num_free-1 ;-full i=(parent+data) AND 0000FFFFh ;\ if method=7 then i=(i*3AE1h) AND FFFh ;new "fast" randomizer ; else i=i OR 800h, i=((i*i)/40h) AND FFFh ;old "slow" randomizer ; if lzw_parent[i]=EEEEh then goto @@found_free ; alloc while lzw_sibling[i]>0000h, do i=lzw_sibling[i] ;find chain end ; code e=i, i=(i+65h) AND FFFh ;memorize chain end & do some random skip ; while lzw_parent[i]<>EEEEh, do i=(i+1) AND FFFh ;find a free code ; lzw_sibling[e]=i ;weirdly, i=0 will make it behave as sibling=none ; @@found_free: ;/ lzw_data[i]=data, lzw_parent[i]=parent, lzw_sibling[i]=0000h ;-apply @@no_further_codes: ret |
ARC Method 8 with 1-byte header (0Ch) --> nCompress 3-byte header 1Fh,9Dh,8Ch ARC Method 9 without header --> nCompress 3-byte header 1Fh,9Dh,8Dh |
Differences LHArc method lh1 ARC method 0Ah Data/len codes: 100h..139h=Len(3..3Ch) 100h=End, 101h..139h=Len(3..3Bh) Initial dictionary: 20h-filled Uninitialized |
PKARC/PKPAK adds comments (starting with "PK",AAh,55h) PAK adds extended records (described in PAK.DOC file in the v2.51) |
| CDROM File Compression RAR |
File Header:
000h 4 ID "RE~^" (aka 52h,45h,7Eh,5Eh)
004h 2 Header Size (usually 0007h, or bigger when Comment/Ext1 exist)
006h 1 Archive Flags (80h or xxh)
... (2) Archive Comment Size ;\Only present when ArchiveFlags.bit1=1
... (..) Archive Comment Data ;/
... (2) Ext1 Size ;\Only present when ArchiveFlags.bit5=1
... (..) Ext1 Data ;/
... .. Unknown (TECHNOTE hints sth can be here, when bigger HeaderSize?)
Archive Flags:
0 Volume (maybe related to split-volume on several floppies?)
1 Comment
2 Unknown? (non-english description is in 1.402's TECHNOTE.DOC)
3 Unknown? (non-english description is in 1.402's TECHNOTE.DOC)
4 Unknown? (non-english description is in 1.402's TECHNOTE.DOC)
5 EXT1
6 Unspecified (maybe unused)
7 Unspecified (maybe unused, but... it's usually 1)
File Data blocks:
000h 4 Filesize, compressed
004h 4 Filesize, uncompressed
008h 2 Checksum on uncompressed? file (sum=LeftRotate16bit(sum+byte[i])
00Ah 2 Header Size (usually 0015h+FilenameLength)
00Ch 4 File Modification Timestamp in MSDOS format
010h 1 File Attribute in MSDOS format (20h=Normal)
011h 1 Flags
012h 1 Version (0=0.99, 1=1.00, 2=1.30) (always 2 in public version)
013h 1 Filename Length
014h 1 Method (00h=m0a=Stored, 03h=m3a=Default) (1..5 = fastest..best)
... (2) File Comment Length ;\Only present if FileFlags.bit3=1
... (..) File Comment Data ;/
... .. Filename ("PATH\FILENAME.EXT", without any end marker)
... .. Unknown (TECHNOTE hints sth can be here, when bigger HeaderSize?)
... .. Compressed file data
File Flags:
0 Unknown? (non-english description is in 1.402's TECHNOTE.DOC)
1 Unknown? (non-english description is in 1.402's TECHNOTE.DOC)
2 Unknown? (non-english description is in 1.402's TECHNOTE.DOC)
3 Comment (non-english description is in 1.402's TECHNOTE.DOC)
4-7 Unspecified (maybe unused)
|
000h 2 Chunk Header CRC; Lower 16bit of CRC32 on [002h..HdrSize-1 or less]
002h 1 Chunk Type (72h..7Ah)
003h 2 Chunk Flags
005h 2 Chunk Header Size
007h (4) Data block size ;<-- Only present if Flags.bit15=1
... .. Header values (depending on Chunk Type and Chunk Header Size)
... .. Data block ;<-- Only present if Flags.bit15=1
Chunk Types:
72h="r"=Marker block (with "r" being 3rd byte in ID "Rar!",1Ah)
73h="s"=Archive header
74h="t"=File header
75h="u"=Old style Comment header (nested within Type 73h/74h)
76h="v"=Old style Authenticity information
77h="w"=Old style Subblock
78h="x"=Old style Recovery record
79h="y"=Old style Authenticity information
7AH="z"=Subblock
Chunk Flags:
0-13 Flags, meaning depends on Chunk Type
14 If set, older RAR versions (before 1.52 or so?) will ignore the
block and remove it when the archive is updated. If clear, the
block is copied to the new archive file when the archive is
updated;
or does "older" mean older than the "archiver version"?
15 Data Block present (0=No, 1=Yes, with size at [007h])
|
000h 7 ID ("Rar!",1Ah,07h,00h) (or "Rar!",1Ah,07h,01h for RAR 5.0)
The above ID can be somewhat parsed as normal chunk header, as so:
000h 2 Faux CRC (6152h, no actual valid CRC)
002h 1 Chunk Type (72h)
003h 2 Faux Flags (1A21h, no actual meaning)
005h 2 Chunk Header size (0007h)
|
000h 2 CRC32 AND FFFFh of fields HEAD_TYPE to RESERVED2
002h 1 Chunk Type: 73h
003h 2 Archive HeaderFlags
005h 2 Header size (usually 000Dh) (plus Comment Block, if any)
007h 2 RESERVED1 (0000h)
009h 4 RESERVED2 (0000011Dh)
... (..) Comment block ;<-- only present if Flags.bit1=1
... (..) Reserved for additional blocks
Archive Header Chunk Flags:
0 Volume attribute (archive volume) (split-volume? volume-label? what?)
1 Archive comment present ;<-- used only before RAR 3.x
RAR 3.x uses "the separate comment block" and does not set this flag.
2 Archive lock attribute
3 Solid attribute (solid archive)
4 New volume naming scheme (0=Old="name.???", 1=New="name.partN.rar")
5 Authenticity information present ;<-- used only before RAR 3.x
6 Recovery record present
7 Chunk headers are encrypted
8 First volume ;<-- set only by RAR 3.0 and later
9-13 Reserved for internal use
14-15 See overall Chunk Format
|
000h 2 CRC32 AND FFFFh on HEAD_TYPE to FILEATTR and file name
002h 1 Header Type: 74h
003h 2 Bit Flags
005h 2 File header full size including file name and comments
007h 4 Compressed file size (can be bigger than uncompressed)
00Bh 4 Uncompressed file size
00Fh 1 Operating system used for archiving
010h 4 CRC32 on uncompressed file
014h 4 File Modification Timestamp in MSDOS format
018h 1 RAR version needed to extract file (Major*10+Minor) (min=0Fh=1.5)
019h 1 Compression Method (usually 35h in RAR 1.52)
01Ah 2 Filename size
01Ch 4 File Attribute in MSDOS format (20h=Normal, Upper24bit=whatever=0)
... (..) Comment block ;-Only present if Flags.bit3=1
... (4) MSBs of compressed file size ;\Only present if Flags.Bit8=1
... (4) MSBs of uncompressed file size ;/
... .. Filename ("PATH\FILENAME.EXT")
... (..) Filename extra fields (see Flags.bit9+bit11)
... (8) Encryption SALT ;-Only present if Flags.Bit10=1
... (..) Extended Time, variable size ;-Only present if Flags.Bit12=1
... (..) * other new fields may appear here.
... .. Compressed file data
File Chunk Flags:
0 File continued from previous volume
1 File continued in next volume
2 File encrypted with password
3 File comment present ;<-- used only before RAR 3.x
RAR 3.x uses the separate comment block and does not set this flag.
4 Information from previous files is used (solid flag) ;RAR 2.0 and later
5-7 Dictionary bits (for RAR 2.0 and later)
8 64bit Filesizes (for files "larger than 2Gb")
9 Unicode Filename, this can be in Dual or Single name form:
Dual name: "NormalName",00h,"UnicodeName" ;<-- in UTF-8 or what?
Single name: "UnicodeName" ;<-- in UTF-8
10 Header contains 8-byte Encryption SALT entry
11 Backup File (with version number ";n" appended to filename)
12 Extended Time field present
13-14 -
15 Data Block present (always 1=With 32bit size at [007h], or 64bit size)
Dictionary Bits (bit5-7)
00h=Dictionary Size 64 Kbyte
01h=Dictionary Size 128 Kbyte ;\
02h=Dictionary Size 256 Kbyte ; RAR 2.0 and up
03h=Dictionary Size 512 Kbyte ;
04h=Dictionary Size 1024 Kbyte ;/
05h=Dictionary Size 2048 Kbyte ;\RAR ?? and up
06h=Dictionary Size 4096 Kbyte ;/
07h=File is a directory ;-RAR 2.0 and up
Operating System Indicators:
00h=MS DOS
01h=OS/2
02h=Windows
03h=Unix
04h=Mac OS
05h=BeOS
??h=Android?
Compression Method:
35h=Default in RAR 1.52 (used even when file is too small to be compressed)
xxh=Other methods (unknown values)
30h=Stored (RAR 2.00 supports uncompressed small files and -m0 switch)
N/A=Stored (RAR 1.52 simply ignores "-m0" switch, and enforces "-m1" or so)
|
000h 2 Header CRC of fields from HEAD_TYPE to COMM_CRC 002h 1 Chunk Type: 75h 003h 2 Chunk Flags (unknown if/which flags are used) 005h 2 Chunk Header size (0Eh+Compressed comment size) 007h 2 Uncompressed comment size 009h 1 RAR version needed to extract comment 00Ah 1 Packing Method 00Ch 2 Comment CRC 00Eh .. Compressed comment data |
* 1.3 (Does not have the RAR! signature)
o There is difficulty finding information regarding this sub-format.
* 1.5
o Utilizes a proprietary compression method that is not public.
o Considered the root model of subsequent formats.
o A detailed list of information can be found here.
* 2.0
o Utilizes a proprietary compression method that is not public.
o Based off of version 1.5 of the RAR file format.
* 3.0
o Utilizes the PPMII and Lempel-Ziv (LZSS)] algorithms.
o Encryption now uses cipher block chaining (AES?-CBC) instead of AES
o Based off of version 1.5 of the RAR file format.
|
| CDROM File Compression ZOO |
File Header:
000h 20 Text Message (usually "ZOO #.## Archive.",1Ah,00h,00h)
014h 4 ID (FDC4A7DCh) (use this ID for detection, and ignore above text)
018h 4 Offset to first Chunk (22h or 2Ah+commentsize?)
01Ch 4 Offset to first Chunk, negated (-22h or -2Ah-commentsize?)
020h 1+1 Version needed to extract (Major,Minor) (usually 1,01 or 2,00)
022h (1) Archive Header Type (01h) ;\
023h (4) Offset to Archive Comment (0=None) ; v2.00 and
027h (2) Length of Archive Comment (0=None) ; up only
029h (1) Version Data (01h or 03h) "HVDATA" ;/
File Chunks:
000h 4 ID (FDC4A7DCh)
004h 1 Type of directory entry (1=Old, 2=New, with extra entries)
005h 1 Compression method (0=Stored, 1=LZW/default, 2=LZH)
006h 4 Offset to next Chunk
00Ah 4 Offset to File Data
00Eh 4 File Modification Date/time in MSDOS format
012h 2 CRC16 on uncompressed file (with initial value 0000h)
014h 4 Filesize, uncompressed
018h 4 Filesize, compressed
01Ch 1+1 Version needed to extract (Major,Minor) (usually 1,00 or 2,01)
01Eh 1 Deleted flag (0=Normal, 1=Deleted)
01Fh 1 File structure (unknown purpose)
020h 4 Offset of comment field (0=None)
024h 2 Length of comment field (0=None)
026h 13 Short Filename ("FILENAME.EXT",00h, garbage padded if shorter)
033h (1) Unknown (4Fh) (or 00h when with comment?) ;-Type=1
033h (2) Length of 038h and up (0Ah+longname+dirname) ;\
035h (1) Timezone (signed) (7Fh=Unknown) ;
036h (2) CRC16 on Header (000h..037h+[033h], with [036h]=0000h) ;
038h (1) Length of Long Filename (0=None, use Short Filename) ;
039h (1) Length of Directory name (0=None) ; Type=2
03Ah (..) Long Filename ("longfilename.ext",00h) (if any) ;
... (..) Directory name ("/path",00h) (if any) ;
... (2) System ID (0=Unix, 1=DOS, 2=Portable) (but for DOS=0) ;
... (3) File Attributes (24bit) (but for DOS=0) ;
... (1) Backup Flags (bit7=On, bit6=Last, bit0-3=Generation) ;
... (2) Backup File Version Number (for backup copies) ;/
... 5 File Leader aka Fudge Factor ("@)#(",00h) ;\
... .. File Data ; All types
... .. File Comment (if any) (ASCII, "Text string",0Ah) ;/
Last Chunk:
000h 4 ID (FDC4A7DCh)
004h (30h) Zerofilled ;-Type 1
004h (1) Fixed (02h) ;\
005h (31h) Zerofilled ; Tyoe 2
036h (2) CRC16 on Header (with [036h]=0000h) (always 83FCh) ;/
... (..) Comments may be stored here (if added after archive creation)
... (..) Padding, if any (1Ah-filled in some files)
|
zoo xz source.too testfile.txt ;extract to tiny/temp file testfile.tzt zoo az dest.zoo testfile.txt ;import from tiny/temp file testfile.tzt |
000h 2 Zoo Tiny ID (07FEh) 002h 1 Type (01h) 003h 1 Compression Method 004h 4 Date/time in MSDOS format 008h 2 CRC16 on uncompressed file, or what (?) 00Ah 4 Filesize, uncompressed 00Eh 4 Filesize, compressed 012h 1 Major_ver 013h 1 Minor_ver 014h 2 Comment size (0=None) 016h 13 Short Filename 023h .. File data ... plus comment, if any? |
000h 2 Zoo Filter ID (32h,5Ah) ... .. Compressed data ... 2 CRC16 on uncompressed file, or what (?) |
| CDROM File Compression nCompress.Z |
000h 2 ID (1Fh,9Dh) 002h 1 Mode (MaxBits(9..16) + bit7=WithClearCode) (usually 90h) 003h .. ClearGapLZW compressed data |
BUG: MaxBits=9 does accidentally act as MaxBits=10 (although without actually using more than 200h codes, the 10bit codes always have MSB=0). |
| CDROM File Compression Pack.z (Huffman) |
Old: 000h 2 ID (1Fh,1Fh) 002h 2 Uncompressed size, bit16-31 (Little-Endian) 004h 2 Uncompressed size, bit0-15 (Little-Endian) 006h 2 Number of tree entries (min=2, max=400h?) (Little-Endian) 008h .. Tree (8bit or 24bit per entry) ... .. Compressed data (16bit Little-Endian, 1st bit = MSB of 2nd byte) New: 000h 2 ID (1Fh,1Eh) 002h 4 Uncompressed size, bit31-0 (Big-Endian) 006h 1 Max codesize (CS) 008h CS Tree, number of huffcodes with codesize=(1,2,3,..) ... .. Tree, data values for each huffcode ... .. Compressed data |
| CDROM File Compression Freeze/Melt.F (LZHUF-based) |
000h 2 ID (1Fh,9Eh) 002h .. Compressed Data (LZHUF, with EndCode, 13Bh codes) |
000h 2 ID (1Fh,9Fh) 002h 3 Custom Disp Code Sizes (LittleEndian24bit, see below) 005h .. Compressed Data (LZHUF, with EndCode, 1FFh codes, specials) Custom Disp Code Sizes: bit0 Number of 1bit codes (v1=0) bit1-2 Number of 2bit codes (v1=0) bit3-5 Number of 3bit codes (v1=1) bit6-9 Number of 4bit codes (v1=3) bit10-14 Number of 5bit codes (v1=8) bit15 Zero bit16-21 Number of 6bit codes (v1=12) bit22-23 Zero |
id=LittleEndian16bit[src], src=src+2
if id=9E1Fh then ;Freeze v1
numdatacodes=13Bh, withendcode=1, displsbs=6
buf[0..7]=0,0,1,3,8,12,24,16 ;<-- this will make standard LZHUF values
elseif id=9F1Fh then ;Freeze v2
numdatacodes=1FFh, withendcode=1, displsbs=7
x=LittleEndian24bit[src+02h], src=src+3
if (x AND C08000h)<>0 then error
buf[0]=(x SHR 0) AND 01h ;Number of 1bit codes (v1=0)
buf[1]=(x SHR 1) AND 03h ;Number of 2bit codes (v1=0)
buf[2]=(x SHR 3) AND 07h ;Number of 3bit codes (v1=1)
buf[3]=(x SHR 6) AND 0Fh ;Number of 4bit codes (v1=3)
buf[4]=(x SHR 10) AND 1Fh ;Number of 5bit codes (v1=8)
buf[5]=(x SHR 16) AND 3Fh ;Number of 6bit codes (v1=12)
count=62, weight=256, shift=7
for i=0 to 5
count=count-buf[i], weight=weight-(buf[i] SHL shift), shift=shift-1
x=weight-count, buf[6]=x, if x<0 then error ;Number of 7bit codes (v1=24)
x=count*2-weight, buf[7]=x, if x<0 then error ;Number of 8bit codes (v1=16)
else
error
k=0, for i=0 to 7, for j=1 to buf[i], codesizes[k]=i+1, k=k+1
if k>64 then error
lzh_explode_tree(disp_tree,codesizes,k)
|
Tool Method Ext NumCodes EndCode Len DispLsbs DispCodes Dict LHA/LHarc -lh1- .lzh 13Ah - N+3-100h 6bit+1 Fixed 20h's Amiga LHW Frozen .lbr 13Ah - N+3-100h 6bit+1 Fixed 20h's CP/M ARC Trim .arc 13Ah 100h N+3-101h 6bit+1 Fixed - CP/M CrLZH v1 .xYx 13Bh ! 100h N+3-101h 6bit+1 Fixed 20h's CP/M CrLZH v2 .xYx 13Bh ! 100h N+3-101h 5bit+1 ! Fixed 20h's Unix Freeze v1 .F 13Bh ! 100h N+3-101h 6bit+1 Fixed - Unix Freeze v2 .F 1FFh ! 100h N+3-101h 7bit+1 ! Variable 20h's Amiga DMS Deep .dms 13Ah - N+3-100h 8bit+1 ! Fixed 00h's Amiga LhLib Lh - 13Dh ! 13Ch ! N+1-100h 6bit ! Fixed - |
| CDROM File Compression Octal Oddities (TAR, AR, CPIO, RPM) |
0000h .. TAR Chunk(s) ... 400h TAR End Marker (400h bytes zerofilled) ... .. Zerofilled (whatever further padding) |
000h 100 text Filename ("path/filename.ext",00h)
064h 8 octal Mode Flags
06Ch 8 octal User ID
074h 8 octal Group ID
07Ch 12 octal Filesize
088h 12 octal File modification time (seconds since 01 Jan 1970)
094h 8 octal Header Checksum (sum of byte[0..1F3h], with [94h..9Bh]=20h)
09Ch 1 text Type (00h or "0" for normal files)
09Dh 100 text Whatever link name
101h 8 text Tar ID (6x00h or "ustar",00h,"00" or "ustar ",00h)
109h 32 text User Name (owner)
129h 32 text Group Name
149h 8 octal Device major ;\device number (when Type="4")
151h 8 octal Device minor ;/
159h 155 ? Whatever prefix ;-when ID="ustar",00h,"00" or 6x00h
159h 131 ? Whatever prefix ;\
1DCh 12 octal File access time ; when ID="ustar ",00h
1E8h 12 octal File status-change time ;/
1F4h 12 - Zeropadding to 200h-byte boundary
200h .. - File data (Filesize bytes)
... .. - Zeropadding to 200h-byte boundary
|
"0000123." <-- normal weirdness, with leading zeroes and end-byte ("."=00h)
" 123 . " <-- extra weird, leading/trailing spaces, mis-placed end-byte
" 123 " <-- extra weird, leading/trailing spaces, without end-byte
|
000h 8 text ID ("!<arch>",0Ah) ;reportedly "!<thin>",??h is similar?
008h .. - File entries
File entries:
000h 16 text Filename
010h 12 decimal File modification Timestamp (in seconds)
01Ch 6 decimal Owner ID
022h 6 decimal Group ID
028h 8 octal File Mode (type and permission)
030h 10 decimal Filesize in bytes (SIZ)
03Ah 2 fixed Fixed (60h, 0Ah)
03Ch SIZ - Data
... .. - Padding to 2-byte boundary (0Ah-filled)
|
Filename="#1/nn" --> Long Filename is stored in first "nn" bytes of Data Filename="/nn" --> Long Filename,0Ah is stored at offset "nn" in file "//" |
Used in Amiga ADFLibPPC.lha\Bin\AmigaPPC\libadf.a See also: http://justsolve.archiveteam.org/wiki/AR See also: https://en.wikipedia.org/wiki/Ar_(Unix) |
0000h .. CPIO Chunk(s) (with actual files) ... 57h CPIO Chunk (with filename "TRAILER!!!",00h) ... .. Zeropadding to 200h-byte boundary (not always present) |
Align 2, Binary, little-endian (but partial "big-endian" for 2x16bit pairs) Align 2, Binary, big-endian Align 1, Ascii, octal strings Align 4, Ascii, hexadecimal lowercase strings, checksum=0) Align 4, Ascii, hexadecimal lowercase strings, checksum=sum of bytes in file) |
000h 2 binary 16bit ID (71C7h) ;-little-or big endian
002h 2 binary 16bit dev ;\
004h 2 binary 16bit ino ; same
006h 2 binary 16bit mode ; endianness
008h 2 binary 16bit uid ; as in ID
00Ah 2 binary 16bit gid ;
00Ch 2 binary 16bit nlink ; (but be aware
00Eh 2 binary 16bit rdev ; of the fixed
010h 2 binary 16bit File modification time, upper 16bit ;\ ; upper/lower
012h 2 binary 16bit File modification time, lower 16bit ;/ ; 16bit order
014h 2 binary 16bit Filename size (including ending 00h) ; for time and
016h 2 binary 16bit Filesize, upper 16bit ;\ ; filesize)
018h 2 binary 16bit Filesize, lower 16bit ;/ ;/
01Ah .. text Filename, terminated by 00h ("path/filename",00h)
... .. binary Zeropadding to 2-byte boundary
... .. binary File data (Filesize bytes)
... .. binary Zeropadding to 2-byte boundary
|
000h 6 octal 18bit ID "070707" (=71C7h)
006h 6 octal 18bit dev ;\unique file id
00Ch 6 octal 18bit ino ;/within archive
012h 6 octal 18bit Mode (file attributes)
018h 6 octal 18bit User ID of owner
01Eh 6 octal 18bit Group ID
024h 6 octal 18bit nlink (related to duplicated dev/ino?)
02Ah 6 octal 18bit rdev (system-defined info on char/blk devices)
030h 11 octal 33bit File modification time
03Bh 6 octal 18bit Filename size (including ending 00h)
041h 11 octal 33bit Filesize
04Ch .. text Filename, terminated by 00h ("path/filename",00h)
... .. binary File data (Filesize bytes)
|
000h 6 hex 24bit ID "070701"=Without Checksum, or "070702"=With Checksum
006h 8 hex 32bit ino (does that 32bit value include 16bit "dev"?)
00Eh 8 hex 32bit mode
016h 8 hex 32bit uid
01Eh 8 hex 32bit gid
026h 8 hex 32bit nlink
02Eh 8 hex 32bit mtime
036h 8 hex 32bit Filesize
03Eh 8 hex 32bit devmajor
046h 8 hex 32bit devminor
04Eh 8 hex 32bit rdevmajor
056h 8 hex 32bit rdevminor
05Eh 8 hex 32bit Filename size (including ending 00h)
066h 8 hex 32bit Checksum, sum of all bytes in file, zero when ID=070701
06Eh .. text Filename, terminated by 00h ("path/filename",00h)
... .. binary Zeropadding to 4-byte boundary
... .. binary File data (Filesize bytes)
... .. binary Zeropadding to 4-byte boundary
|
000h 60h File Header (officially called "Lead" instead of "Header") 060h .. Signature Record (contains "Header Record" in "Signature format") ... .. Padding (to 8-byte boundary) ... .. Info Record (called "Header" and also uses "Signature format") ... .. Archive file (usually a GZIP compressed CPIO) (called "Payload") |
000h 4 File ID (EDh,ABh,EEh,DBh) (aka octal string "\355\253\356\333") 004h 1 Major version (3) 005h 1 Minor version (0) 006h 2 Type (0=Binary Package, 1=Source Package) 008h 2 Architecture ID (defined in ISO/IEC 23360) 00Ah 66 Package name, terminated by 00h 04Ch 2 Operating System ID (1) 04Eh 2 Signature Type (5) 050h 16 Reserved space (officially undefined, usually zerofilled) |
000h 4 Record ID (8Eh,ADh,E8h,01h) (aka octal string "\216\255\350\001") 004h 4 Reserved (zerofilled) (aka octal string "\000\000\000\000") 008h 4 Number of Item List entries (N) 00Ch 4 Size of Item Data (SIZ) 010h N*10h Item List (4x32bit each: Tag, Type, Offset, Size) ... SIZ Item Data (referenced via Offset/Size entries in above list) |
00h=NULL Not Implemented 01h=CHAR Unknown, maybe unsigned 8bit (unaligned) 02h=INT8 Unknown, maybe signed 8bit (unaligned) 03h=INT16 Unknown, maybe signed 16bit (align2) 04h=INT32 Unknown, maybe signed 323bit (align4) 05h=INT64 Reserved, maybe signed 643bit (maybe align8) 06h=STRING Variable, NUL terminated string (unaligned) 07h=BIN Unknown, reportedly 1-byte size??? (unaligned) 08h=STRING_ARRAY Variable, Sequence of NUL terminated strings (unaligned) 09h=I18NSTRING Variable, Sequence of NUL terminated strings (unaligned) |
There are dozens of required & optional tag values defined. |
Basic extensions: .cpio (CPIO) .pax (CPIO for MAC) .rpm (RPM installation package for RPM package manager) .spec (RPM source file for creating RPM header/records) .tar (TAR, tape archive) Double extensions (and short forms like tgz): .tgz short for .tar.gz (gzip) .tbz short for .tar.bz2 (bzip2) .txz short for .tar.xz (XZ) .tlz short for .tar.lz (Lzip) or .tar.lzma (LZMA_Alone) .tzst short for .tar.zst (zstandard) .tsz short for .tar.sz (Sunzip) .taz short for .tar.Z (nCompress or possibly some other compressed format) .tz short for .tar.Z (nCompress or possibly some other compressed format) .spm short for .src.rpm (RPM source code package) |
| CDROM File Compression MacBinary, BinHex, PackIt, StuffIt, Compact Pro |
000h 1 Old version number, must be kept at zero for compatibility
001h 1 Length of filename (1..63) (though v3 says 1..31)
002h 63 Filename (only "length" bytes are significant)
041h 4 File type (normally expressed as four characters)
045h 4 File creator (normally expressed as four characters)
049h 1 Finder flags, bit8-15 (see [065h] for bit0-7)
04Ah 1 Zero (must be 00h for compatibility)
04Bh 2 File Vertical position within its window
04Dh 2 File Horizontal position within its window
04Fh 2 File Window or folder ID
051h 1 Protected flag (bit0=Protected, whatever that is)
052h 1 Zero (must be 00h for compatibility)
053h 4 Filesize, Data Fork (0=None)
057h 4 Filesize, Resource Fork (0=None)
05Bh 4 File Timestamp, creation
05Fh 4 File Timestamp, last modification
063h 27 v1: Reserved (zerofilled)
063h 2 v2/v3: Length of Get Info comment (if any, usually 0000h)
065h 1 v2/v3: Finder Flags, bit0-7 (see [049h] for bit8-15)
066h 6 v2: Reserved (zerofilled)
066h 4 v3: ID ("mBIN"=MacBinary III)
06Ah 1 v3: Script of file name (from fdScript field of an fxInfo record)
06Bh 1 v3: Extended Finder flags (from fdXFlags field of fxInfo record)
06Ch 8 v2/v3: Reserved (zerofilled)
074h 4 v2/v3: Length of "total files" when "packed files are unpacked", uh?
078h 2 v2/v3: Extended Header size (reserved for future, always 0000h)
07Ah 1 v2/v3: MacBinary II uploader version (81h=v2, 82h=v3)
07Bh 1 v2/v3: MacBinary II downloader minimum version (81h=v2)
07Ch 2 v2/v3: CRC16-XMODEM on [000h..07Bh]
07Eh 2 Reserved for computer type and OS ID (0000h)
... .. Extended Header (if any, maybe stored here? when [078h]>0)
... .. Padding to 80h-byte boundary
... .. Data Fork (if any)
... .. Padding to 80h-byte boundary
... .. Resource Fork (if any)
... .. Padding to 80h-byte boundary
... .. Get Info comment (if any, usually none)
|
1) ASCII to BINARY conversion (similar to BASE64) 2) RLE90 decompression of whole file (header+data+resource+crc's) 3) Processing the header+data+resource from the decompressed binary 4) For Multipart files, repeat above steps for each part |
The file may start with some text message, comments, description. Skip any
such text lines until reaching a line that contains this 45-byte ID string:
(This file must be converted with BinHex 4.0)
That line should be followed by following characters (each char representing
6bit binary value, MSB first, first char is bit7-2 of first byte):
!"#$%&'()*+,- char(21h..2Dh) --> bin(00h..0Ch)
0123456 char(30h..36h) --> bin(0Dh..13h)
89 char(38h..39h) --> bin(14h..15h)
@ABCDEFGHIJKLMN char(40h..4Eh) --> bin(16h..24h)
PQRSTUV char(50h..56h) --> bin(25h..2Bh)
XYZ[ char(58h..5Bh) --> bin(2Ch..2Fh)
`abcdef char(60h..66h) --> bin(30h..36h)
hijklm char(68h..6Dh) --> bin(37h..3Ch)
pqr char(70h..72h) --> bin(3Dh..3Fh)
: char(3Ah) --> start/end marker
CR/LF char(0Dh/0Ah) --> linebreaks per 64 chars (CR and/or LF)
SPC/TAB char(09h/20h) --> blanks (reportedly in some files)
|
RLE90 decompression is same as in ARC files, except, code 90h,00h is handled differently: ARC keeps prevbyte=unchanged, BinHex sets prevbyte=90h. RLE90 compression is somewhat optional: 90h must be encoded as 90h,00h, but many encoders don't bother to compress repeating bytes (eg. many files contain "!!!!!!!!" chars aka uncompressed 00h-filled bytes). There is no way to know the decompressed size before decompression (either decompress the whole file and allocate more memory as needed, or decompress only the header (filename+16h bytes) and then compute decompressed size as filename+16h+data+2+resource+2 bytes). |
The decompressed binary contains following data (similar as MacBinary):
00h 1 Length of Filename (1..63)
01h .. Filename ("FILENAME.EXT")
01h+N 1 Version (00h)
02h+N 4 File Type
06h+N 4 File Creator
0Ah+N 2 Finder Flags
0Ch+N 4 Filesize, uncompressed, Data Fork
10h+N 4 Filesize, uncompressed, Resource Fork
14h+N 2 Header CRC16-XMODEM on uncompressed 14h+N bytes
16h+N .. Data Fork
... 2 Data Fork CRC16-XMODEM on uncompressed Data Fork
... .. Resource Fork
... 2 Resource Fork CRC16-XMODEM on uncompressed Resource Fork
... .. Padding (might reportedly occur in some files)
Caution: There is a document that does claim that the CRC field should be be
set to 0000h before CRC calculation, and that the CRC would be computed on
Size+2 bytes (up to including he CRC field), that appears to be nonsense,
the CRC is computed on Size+0 bytes, not Size+2.
|
Emails or other text documents may contain multiple binhex files, if so,
each part should be reportedly followed by a line containing:
--- end of part NN ---
Unknown if there are any .hqx files with such multipart stuff.
Unknown if the next part starts with "(This file must.." or just with ":".
|
Bitstream for Uncompressed File Entries:
32bits Uncompressed Header[000h..003h] (Method/Crypto="PMag")
..bits Uncompressed Header[004h..061h] (uncompressed size = 5Eh)
..bits Uncompressed Data+Resource+CRC (uncompressed size = Data+Rsrc+2)
Bitstream for Compressed File Entries:
32bits Uncompressed Header[000h..003h] (Method/Crypto="PMa4")
..bits Compressed Huffman Tree (for decoding following bits)
..bits Compressed Header[004h..061h] (uncompressed size = 5Eh)
..bits Compressed Data+Resource+CRC (uncompressed size = Data+Rsrc+2)
..bits Padding to 8bit-boundary (byte align next File Entry)
Bitstream for Archive End Marker (after last file):
32bits Uncompressed Header[000h..003h] (Method/Crypto="PEnd")
File Entry Format:
000h 4 Method/Crypto (usually "PMag"=Uncompressed, "PMa4"=Huffman)
004h 1 Filename length
005h 63 Filename ("FILENAME", garbage padded)
044h 4 File Type
048h 4 File Creator
04Ch 2 Finder flags
04Eh 2 Locked?
050h 4 Filesize, uncompressed, Data fork
054h 4 Filesize, uncompressed, Resource fork
058h 4 Timestamp, creation
05Ch 4 Timestamp, modification
060h 2 CRC16-XMODEM on [004h..05Fh]
... .. Data Fork
... .. Resource Fork
... 2 CRC16-XMODEM on uncompressed Data+Resource forks
Method/Crypto:
"PEnd" = Archive End marker (4-byte end marker, without filename etc.)
"PMag" = Uncompressed
"PMa1" = Uncompressed, Encrypted Simple
"PMa2" = Uncompressed, Encrypted DES
"PMa3" = Uncompressed, Encrypted reserved
"PMa4" = Huffman
"PMa5" = Huffman, Encrypted Simple
"PMa6" = Huffman, Encrypted DES
"PMa7" = Huffman, Encrypted reserved
Decompression: ;for PackIt (and also for StuffIt method 03h)
InitBitstreamMsbFirst(src) ;-src is after "PMa4" PackIt ID
tree=GetMem(200h*4) ;-alloc tree (probably less needed)
num_entries=0 ;\init tree
root=GetTreeEntry ;/
while dst<dst_end ;-decompress, till end...
index=root ;\
while index<FF00h ; huffman decode
index=[tree+index*4+GetBits(1)*2] ;/
[dst]=index AND FFh, dst=dst+1 ;-store data
return
;---
GetTreeEntry:
if GetBits(1)=1 then
return GetBits(8)+FF00h ;-final data entry
else
index=num_entries ;-current index
num_entries=num_entries+1 ;-alloc next index
[tree+index*4+0*2] = GetTreeEntry ;-recursive call for node0
[tree+index*4+1*2] = GetTreeEntry ;-recursive call for node1
return index
|
StuffIt Archive Header:
000h 4 ID ("SIT!", short for StuffIt)
Reportedly, there are several alternate IDs:
"SIT!","ST46","ST50","ST60","ST65","STin","STi2","STi3","STi4"
Unknown why, and if some do differ somehow (ST65 appears to be
same as SIT!) (for STi, the "i" might be short for it? installer?)
004h 2 Number of entries in root directory
006h 4 Total size of archive
00Ah 4 ID ("rLau", short for Raymond Lau)
00Eh 1 Version number (01h=v1.x-v1.5.x, 02h=v1.6-v4.5)
00Fh 7 Reserved (zerofilled) ;-when version=01h
00Fh 1 Unknown (C6h or FFh) ;\
010h 4 Offset to first root entry (16h or elsewhere!) ; when version=02h
014h 2 Unknown (0001h or FFFFh) ;/
File Entries:
000h 1 Compression method, Resource fork
001h 1 Compression method, Data fork
002h 1 Filename length (1..63 for version=01h, 1..31 for version=02h)
003h 1Fh Filename ("FILENAME.EXT", garbage padding)
022h 20h Filename further chars ;-when version=01h
022h 2 Filename+size CRC ;\
024h 2 Unknown (always 0000h or 0986h?) ; when version=02h
026h 4 Unknown Resource fork related ;maybe window ;
02Ah 4 Unknown Data fork related ;coords ? ;
02Eh 1 Unknown Data fork related ;
02Fh 1 Unknown Resource fork related ;
030h 2 Number of child entries (excluding End marker) ;
032h 4 Offset to previous entry ;
036h 4 Offset to next entry ;
03Ah 4 Offset to parent entry ;
03Eh 4 Offset to first child (or -1 for file entries) ;/
042h 4 File type (eg. "APPL")
046h 4 File creator (eg. "ACTA")
04Ah 2 Finder flags (2100h)
04Ch 4 Creation date
050h 4 Modification date
054h 4 Filesize, uncompressed, Resource fork (0=None)
058h 4 Filesize, uncompressed, Data fork (0=None)
05Ch 4 Filesize, compressed, Resource fork (0=None)
060h 4 Filesize, compressed, Data fork (0=None)
064h 2 CRC16 on uncompressed(?) Resource fork (0=None)
066h 2 CRC16 on uncompressed(?) Data fork (0=None)
068h 1 Pad bytes for encrypted Resource? (00h)
069h 1 Pad bytes for encrypted Data? (00h)
06Ah 2 Unknown Data fork related (0000h, or 0004h=Encrypted?)
06Ch 2 Unknown Resource fork related (0000h, or 0004h=Encrypted?)
06Eh 2 CRC16 on Header [000h..06Dh] with initial=0000h
070h .. Compressed Data, Resource fork (if any) (size=[05Ch])
... .. Compressed Data, Data fork (if any) (size=[060h])
StuffIt Methods:
00h Uncompressed
01h RLE90 (same as... unknown if this is like BinHex, or like ARC)
02h ClearGapLZW (same as nCompress, 14bit, with Clear(+gap), no Stop code)
03h Huffman (same as PackIt "PMa4" method)
05h LZHUF (same as LHA "lh1" method)
06h Fixed Huffman Segmented. PackBits, then optional Huffman coding.
The set of Huffman codes is predefined, but the meaning
of a code can be different in each segment
08h MW (Miller-Wegman, presumably LZMW)
0Dh LZ+Huffman (?) ;-StuffIt and StuffIt5
0Eh Installer (uh?)
0Fh Arsenic (BWT and arithmetic coding) ;-StuffIt5 only?
1xh Encrypted methods (same as above, plus encryption)
20h Folder start ;\StuffIt (not StuffIt5)
21h Folder end ;/
|
Folder start
Child entries
Folder end
Folder start
Child entries
Folder end
|
StuffIt Archive Header:
000h 82 ID "StuffIt (c)1997",...,"/StuffIt/",0Dh,0Ah,1Ah,00h)
052h 1 Version (always 05h)
053h 1 Flags (can be 00h, 10h, 80h) (bit4=what?, bit7=Encrypted)
054h 4 Total size of archive
058h 4 Offset to first entry in root directory (64h, plus Extra Data)
05Ch 2 Number of entries in root directory
05Eh 4 Same as [058h] (maybe one is 1st entry, and other is Header size)?
062h 2 Header CRC16 on [000h..[05xh]-1] with [062h]=0000h and initial=0
064h .. Extra Data (see below)
... .. File/Folder entries
Extra data can be:
None (when [58h]=64h) ;with Flags=00h
05h,76h,35h,B9h,87h,11h ;maybe 05h=Length? ;with Flags=80h=crypto
0Dh,A5h,A5h,"Reserved",A5h,A5h,00h) ;maybe 0Dh=Length? ;with Flags=10h=what?
File/Folder entries:
000h .. Base Header
... .. OS Header (depending on OS Type in Base Header)
... .. Resource fork (if any) (MAC only, not Windows)
... .. Data fork (if any)
Base Header:
000h 4 ID (A5A5A5A5h) (or B4B4B4B4h=corrupted charset conversion maybe?)
004h 1 OS Type (1=Mac, 3=Windows)
005h 1 Unknown (0)
006h 2 Base Header size (41h) (30h+IV?+Filename+Comment)
008h 1 Unknown (0) (maybe Flags MSB?)
009h 1 Flags (bit3=Comment, bit6=Folder, bit5=Encrypted)
00Ah 4 Timestamp, Creation (Mac OS format, seconds since 1904)
00Eh 4 Timestamp, Modification (Mac OS format, seconds since 1904)
012h 4 Offset of previous entry (0=None)
016h 4 Offset of next entry (0=None)
01Ah 4 Offset of parent folder entry (0=None)
01Eh 2 Filename size (F)
020h 2 Base Header CRC-16 on [000h..[006h]-1]
022h (4) Offset of first child entry in folder (FFFFFFFFh=End) ;\Folder
026h (4) Size of complete directory ; (if Flags
02Ah (4) Unknown ; bit6=1)
02Eh (2) Number of child entries (excluding folder End marker) ;/
022h (4) Data fork uncompressed size ;\
026h (4) Data fork compressed size ;
02Ah (2) Data fork CRC-16 (0 for method 0Fh) ; File
02Ch (2) Data fork Unknown (0000h) ; (if Flags
02Eh (1) Data fork compression method (00h,0Dh,0Fh) ; bit6=0)
02Fh (1) Data fork Encryption IV? size ;
... (..) Data fork Encryption IV? data ;/
... .. File/Folder name ("FILENAME.EXT")
... (2) Comment size (K) ;\Comment
... (2) Comment Unknown (0) ; (if Flags
... (..) Comment data ;/bit3=1)
OS Header for Mac (OS=1):
000h 2 Flags2 (bit0=HasResource, bit4=same as archive header [053h] ?)
002h 2 CRC16 on OS Header (with [002h]=0000h, initial=0)
004h 4 Mac OS file type ;\
008h 4 Mac OS file creator ; as so for Files
00Ch 2 Mac OS Finder flags ; (seems to contain
00Eh 2 Mac OS Unknown ; other stfuff/junk
010h 4 Mac OS Unknown ; for Folders)
014h 4 Mac OS Unknown ;
018h 4 Mac OS Unknown ;
01Ch 4 Mac OS Unknown ;
020h 4 Mac OS Unknown ;/
024h (4) Resource fork uncompressed size ;\
028h (4) Resource fork compressed size ; only if
02Ch (2) Resource fork CRC-16 (0 for method 0Fh) ; Flags2
02Eh (2) Resource fork Unknown ; bit0=1
030h (1) Resource fork compression method ;
031h (1) Resource fork Encryption IV? size ;
... (..) Resource fork Encryption IV? data ;/
OS Header for Windows (OS=3):
000h 2 Flags 2 (bit4=same as archive header [053h] ?)
002h 2 CRC16 on OS Header (with [002h]=0000h, initial=0)
004h 4 Windows File Attribute (20h=Normal, 10h=Folder)
008h 08h Windows Zerofilled
010h 4 Windows Timestamp last accessed?
014h 4 Windows Unknown (0005xxxxh)
018h 08h Windows Zerofilled
|
StuffIt Archive Header: 000h 8 ID "StuffIt!" (reportedly "StuffIt?" also exists) 008h .. Unknown... |
Archive header:
000h 1 File ID (always 01h)
001h 1 Volume number (01h for single-volume, Other=Unknown)
002h 2 Random Volume ID? (...must be same in all split volume files?)
004h 4 Offset to Footer (from begin of file)
008h .. Compressed files (resource+data fork pairs)
... .. Footer (directory information)
Footer format:
000h 4 CRC32 XOR FFFFFFFFh on following bytes
004h 2 Number of entries in root folder (including all child entries)
006h 1 Comment length (usually 00h=None)
007h N Comment
007h+N .. File/Folder entries
Folder entries, with [000h].bit=1:
000h 1 Foldername length (N), plus bit7=Type (1=Folder)
001h N Foldername ("FOLDERNAME")
001h+N 2 Number of entries in this folder (including all child entries)
File entries, with [000h].bit=0:
000h 1 Filename length (N), plus bit7=Type (0=File)
001h N Filename ("FILENAME.EXT")
001h+N 1 Volume number (01h for single-volume, Other=Unknown)
002h+N 4 Offset to compressed Resource (followed by compressed Data)
006h+N 4 File type
00Ah+N 4 File creator
00Eh+N 4 Timestamp, creation (seconds since 1904)
012h+N 4 Timestamp, modification (seconds since 1904)
016h+N 2 Finder flags
018h+N 4 CRC32 XOR FFFFFFFFh on uncompressed Resource + Data forks
01Ch+N 2 Method/Flags (see below)
01Eh+N 4 Filesize, uncompressed, Resource fork
022h+N 4 Filesize, uncompressed, Data fork
026h+N 4 Filesize, compressed, Resource fork
02Ah+N 4 Filesize, compressed, Data fork
Method/Flags:
0 Encryption (0=None, 1=Encrypted, unknown how)
1 Method for Resource fork (0=RLE8182, 1=RLE8182+LZSSHUF)
2 Method for Data fork (0=RLE8182, 1=RLE8182+LZSSHUF)
3-15 Unknown/unused (0)
Note: RLE8182 and RLE8182+LZSSHUF are also used by Mac DiskDoubler.
|
This is same as RLE90, with two-byte escape code (81h,82h instead of 90h): 81h,82h,00h Output 81h,82h 81h,82h,01h..03h Output prevbyte 00h..02h times (this is not useful) 81h,82h,04h Output prevbyte 03h times (useful if prev=81h, next=82h) 81h,82h,05h..FFh Output prevbyte 04h..FEh times (this does save memory) 81h,xxh Output 81h, and then process xxh 81h,padding Output 81h, at end of file (with padding<>82h) xxh Output xxh (unless it is 81h) Note: prevbyte is the previous output byte (ie. that stored at [dst-1]). If the uncompressed file ends with 81h, then the compressed file MUST contain a dummy padding byte (the RLE decoder in macutils sets a prefix flag upon 81h, but doesn't output it to dst until receiving the padding byte, which could be 81h, or any value other than 82h). |
This uses LZSS-style flag bits (to distinguish between data and len/disp), combined with three Huffman trees (for data, len, disp values). The sliding window is 2000h bytes (8Kbytes). The format appears to be a simplified variant or LHA compression (but gets complicated by inventing weird corner cases). |
if uncompressed_size=0 then goto @@all_done ;-empty (eg. for unused forks)
[dst+0000h..1FFCh]=uninitialized ;\
[dst+1FFDh..1FFFh]=00h,00h,00h ; prefill sliding window
dst+dst+2000h ;/
@@block_lop:
InitBitstreamMsbFirst(src)
GetLzsshufTree(data_tree,100h) ;tree for data=00h..FFh
GetLzsshufTree(len_tree,40h) ;tree for len=00h..3Fh (0,1 usually unused)
GetLzsshufTree(disp_tree,80h) ;tree for dispUpper7bit=00h..7Fh
block_org=src, blocksize=0 ;block origin (after above trees)
@@decompress_lop:
if src>=src_end then goto @@all_done ;<-- this may overshoot on padding bits
if out>=out_end then goto @@all_done ;<-- more precise; if RleOnTheFly
if blocksize>=1FFF0h AND type=CompactPro then goto @@block_done
if blocksize>=0FFF0h AND type=Disc Double then goto @@block_done
if GetBits(1)=1 then
[dst]=GetHuffCode(data_tree), dst=dst+1, blocksize=blocksize+2
else
len=GetHuffCode(len_tree)+0, blocksize=blocksize+3
disp=GetHuffCode(disp_tree)*40h+GetBits(6), if disp=0000h then disp=2000h
for i=1 to len, [dst]=[dst-disp], dst=dst+1, next i
if RleOnTheFly then forward above byte(s) to RLE (which advances "out" ptr)
goto @@decompress_lop
@@block_done:
;the decoder does prefetch data in 16bit units, and it does always have
;16..31 bits prefetched, these bits are discarded at block end...
src=src+2+((src-block_org) AND 1) ;discard 16..31 bits (till 16bit-boundary)
goto @@block_lop ;start next block, with new trees
@@all_done:
ret
|
num=GetBits(8)*2, if num>max then goto error ;number of symbols (00h and up) for i=0 to num-1, codesizes[i]=GetBits(4) ;sizes (1..15 bits, or 0=unused) lzh_explode_tree(tree,codesizes,num) ;alike LHA trees ret |
Disp=0 acts as Disp=2000h (don't care when using ringbuf[index AND 1FFFh]) Len=0..1 could be definied in the len_tree (but are usually size=0bit=unused) Unknown if disp_tree & len_tree can be empty (when using data_tree only)? RLE ending with 81h,padding should only output 81h (see RLE8182 description) |
A few .cpt files (eg. ABC's-1.09.cpt.hqx\..\Colin's ABC's\Message.h) have incomplete trees (like only one disp code, "0"=DispUpper7bit=00h, without defining any further huffman codes like "1" or "1xxx"). This isn't much of a problem (except, one may need to remove incomplete tree error checking in the "lzh_explode_tree" function). |
End of Last Block is usually determined by forwarding the LZSSHUF output
directly to the RLE8182 decompressor (which does then check if uncompressed
size is reached) (marked "RleOnTheFly" in above sample code).
Alternately, one could decompress in separate steps (LZSSHUF to tempbuf, and
then tempbuf to RLE8182), but that requires to deal with padding bits.
- padding seems to be 16..31 bits (?) alike at end of blocksize
- padding bits are (always?) zeroes, which act as flag=0=compressed
- compressed data occupies at least flg(1),len(1),disp(1),displsbs(6)=9bits
That can lead to decoding a few extra codes (with lengths up to 3Fh each),
so the tempbuf must have trailing space for writing that garbage padding.
And, those padding bits tend to translate to disp=0000h (aka disp=2000h),
which can cause reads from the whole sliding window, so tempbuf requires
2000h leading bytes to avoid page faults (not just the 3 initialized bytes).
|
MAC File Type,Creator IDs = "APPL","aust" (StuffIt). MAC File Type,Creator IDs = "APPL","EXTR" (CompactPro). MAC File Type,Creator IDs = "APPL","DSEA" (DiskDoubler). |
StuffIt .sea files: These are often raw StuffIt archives (apparently
somebody had removed the MacBinary header and the resource fork with
the decompressor).
CompactPro .sea files: These are often stored as MacBinary without 80h-byte
padding appended to the Data and Resource forks.
That applies to "Santa.sea" but other such files have OTHER corruptions,
which may include wrong Size and/or garbage in reserved MacBinary fields?
|
Resource fork Header:
000h 4 Offset to Resource Data section (from start of file) (100h)
004h 4 Offset to Resource Map section (from start of file) (100h+DataSiz)
008h 4 Size of Resource Data section (can be 0=None)
00Ch 4 Size of Resource Map section
010h F0h Unknown (can contain filename/type.. MAYBE just garbage padding?)
100h .. Resource Data section, contains Data Record(s)
... .. Resource Map section
Data Record(s) in Resource Data section (usually at offset 100h and up):
000h 4 Size of Data for this record
004h .. Data for this record
Resource Map section:
000h 4 Offset to Resource Data section (from start of file) ;\
004h 4 Offset to Resource Map section (from start of file) ; same as in
008h 4 Size of Resource Data section ; header
00Ch 4 Size of Resource Map section ;/
010h 4 Zero (internally used by Resource Manager, nextResourceMap)
014h 2 Zero (internally used by Resource Manager, fileRef)
016h 2 Map Attributes
0-4 Zero (reserved)
5 Zero (internally used by Resource Manager, changed)
6 Zero (internally used by Resource Manager, need compression)
7 Resource map is read-only
8-15 Zero (reserved)
018h 2 Offset to Type List (from start of resource map) (usually 1Ch ?)
01Ah 2 Offset to Name List (from start of resource map)
... .. Type List
... .. Resource List (with one or more entry for each entry in Type List)
... .. Name List (each name consists of 8bit NameLength, plus name string)
Type List follows the header and contains an array of resource type records.
000h 2 Number of Type Records, minus one (FFFFh=None, 0000h=One, etc.)
002h N*8 Type Records
Type Record format:
000h 4 Resource Type (four-character constant)
004h 2 Number of Resource List entries, minus one (0000h=One, etc.)
006h 2 Offset to first Resource List entry (from start of Type List)
Resource List entries:
000h 2 Resource ID (C000h..FFFFh=Special/Owned)
002h 2 Offset to Resource Name (from start of Name List) (FFFFh=None)
004h 1 Attributes
0 Resource data is compressed (0=No, 1=Compressed)
1 Zero (internally used by Resource Manager, changed)
2 Load Resource as soon as file is opened (0=No, 1=Preload)
3 Resource is read-only (0=No, 1=Protected)
4 Resource may not be moved in memory (0=No, 1=Locked)
5 Resource may be paged out of memory (0=No, 1=Purgeable)
6 Load Resource to (0=Application heap, 1=System Heap)
7 Zero (reserved)
005h 3 Offset to Resource Data (from start of Resource Data section)
008h 4 Zero (internally used by Resource Manager, resourcePtr)
Note: Some (or all?) 16bit offsets are reportedly signed (max 32Kbyte), the
24bit offsets are reportedly unsigned (max 16Mbyte).
|
Compressed resource have a standarized header, the decompression function(s) are supposed to be stored in separate "dmcp" resource (unknown if the OS is also providing standard decompression functions). 000h 4 ID (always A89F6572h for compressed resource) 004h 2 Always 0012h (maybe compression header size) 006h 1 Type (08h=Type8, 09h=Type9) 007h 1 Always 01h 008h 4 Uncompressed resource size 00Ch 1 For Type8: workingBufferFractionalSize ;\ 00Dh 1 For Type8: expansionBufferSize ; Type8 00Eh 2 For Type8: dcmpID (ID in "dmcp" decompress resource) ; 010h 2 For Type8: Zero (reserved?) ;/ 00Ch 2 For Type9: dcmpID (ID in "dmcp" decompress resource) ;\Type9 00Eh 4 For Type9: decompressor_specific_parameters_with_io ;/ 012h .. Compressed Resource Data http://formats.kaitai.io/compressed_resource/ |
https://github.com/kreativekorp/ksfl/wiki/Macintosh-Resource-File-Format |
ID MSBs Owner Type Notes C000h DRVR driver or desk accessory C800h WDEF window definition: code to draw windows D000h MDEF menu definition: code to draw menus D800h CDEF control definition: code to draw UI widgets E000h PDEF printer driver E800h PACK utility code package/library used by the Mac OS F000h cdev control panel; owner id is set to 1 F800h reserved reserved for future use |
| CDROM File Compression CP/M Squeeze, Crunch, CrLZH, LBR |
CP/M .LBR archive (ID=1x00h, 11x20h, 2x00h) (uncompressed archive) CP/M .xQx squeeze (ID=76h,FFh) (compressed file, RLE90+Huffman) CP/M .xZx crunch (ID=76h,FEh) (compressed file, RLE90+LZW) CP/M .xYx CrLZH (ID=76h,FDh) (compressed file, LZHUF Variant) |
000h 1 Status (always 00h) 001h 8+3 FilenameExt (always 20h-filled) 00Ch 2 Offset/80h (always 0000h) 00Eh 2 Size/80h (always nonzero) (aka directory size, NumEntries/4) In very old files: 010h 10h Garbage In newer files: 010h 2 CRC16 (with this field set to 0000h during calculation) 012h 8 Date/Time (as in File entries, see there) 01Ah 1 Pad Count (always 00h) (directory entries are full N*80h-byte) 01Bh 5 Reserved (zero) |
000h 1 Status (00h=Active, FEh=Deleted, FFh=Unused) 001h 8+3 FilenameExt (20h-padded, when shorter than 8+3) 00Ch 2 Offset/80h (0000h) 00Eh 2 Size/80h (nonzero) 010h 2 CRC16 012h 2 Creation Date (days since 31 Dec 1977) 014h 2 Last Change Date (days since 31 Dec 1977, or 0000h=Same as Creation) 016h 2 Creation Time (MSDOS format, HH:MM:SS = 5:6:5 bits) 018h 2 Last Change Time 01Ah 1 Pad Count (0..7Fh, number of unused bytes in last 80h-byte block) 01Bh 5 Reserved (zero) |
000h 2 ID (76h,FFh) (aka "v",FFh) ;\
002h 2 Checksum (sum of all decompressed bytes) ; header
004h .. Filename ("Filename.ext",00h) ;/
... 2 Tree Size (N) (0..100h) ;\
... N*4 Tree (2x16bit, FEFFh..00FFh) ; compressed data
... .. Compressed data ;/
... (2) Timestamp ID (77h,FFh) ;\
... (2) Timestamp Date (MSDOS format) ; optional timestamp
... (2) Timestamp Time (MSDOS format) ; extension
... (2) Timestamp Checksum (sum of above three words) ;/
... (..) Padding to 80h-byte boundary ;-optional padding
|
000h 2 ID (76h,FEh) (aka "v",FEh)
002h .. Filename/Comment ("Filename.ext[comment]",00h)
... 1 Version used for compression (10h,12h,20h,23h,24h,28h)
... 1 Version required for decompression (10h,20h) (v1.0, v2.0)
... 1 Error Detection type (00h=Checksum, other=Reserved)
... 1 Spare (conventionally 00h in v1.0, 00h/09h in v1.2, or 05h in v2.x)
XXX or 01h in v2.0
... .. Compressed data
... 2 Checksum (sum of all decompressed bytes)
... .. Padding to 80h-byte boundary (as common for CP/M files) (1Ah-filled)
|
Crunch v1.x --> OldRandomizedLZW with added End Code (000h) Crunch v2.x --> PostRandomizedLZW with added special Codes (100h..103h) |
000h 2 ID (76h,FDh) (aka "v",FDh)
002h .. Filename/Comment ("Filename.ext[comment]",00h)
... 1 Version used for compression (10h,11h,20h) (v1.x, v2.0)
... 1 Version required for decompression (10h,20h) (v1.0, v2.0)
... 1 Error Detection type (00h=Checksum, 01h=CRC16, other=Reserved)
... 1 Spare (conventionally/always 05h)
... .. Compressed data
... 2 Checksum/CRC16 (sum of all decompressed bytes) (or rarely=CRC16 ?)
... .. Padding to 80h-byte boundary (as common for CP/M files) (1Ah-filled)
|
CrLZH v1/v2 uses 13Bh codes, with 100h=EndCode (same as in ARC archives)
CrLZH v1 uses DispLsbs=6bit, although using only 2Kbyte dictionary
CrLZH v2 uses DispLsbs=5bit, to better match 2Kbyte dictionary
XXX support CRC instead of Checksum (if CRC is ever used?)
|
| CDROM File XYZ and Dummy/Null Files |
| CDROM Protection - SCEx Strings |
"SCEI" for Japan "SCEA" for America (and all other NTSC countries except Japan) "SCEE" for Europe (and all other PAL countries like Australia) |
| CDROM Protection - Bypassing it |
| CDROM Protection - Modchips |
entrypoint: ;at power_up
gate=input/highz
data=input/highz
wait 50 ms
data=output/low
wait 850 ms
gate=output/low
wait 314 ms
loop:
wait 72 ms ;pause (eighteen "1=low" bits)
sendbyte("S") ;1st letter
sendbyte("C") ;2nd letter
sendbyte("E") ;3rd letter
sendbyte(...) ;4th letter (A, E, or I, depending on region)
goto loop
sendbyte(char):
sendbit(0) ;one start bit (0=highz)
for i=0 to 7
sendbit(char AND 1) ;output data (LSB first)
char=char/2
next i
sendbit(1) ;1st stop bit (1=low)
sendbit(1) ;2nd stop bit (1=low)
return
sendbit(bit):
if bit=1 then data=output/low elseif bit=0 then data=input/highz
wait 4 ms ;4ms per bit = 250 bits per second
return
|
Board data gate PU-xx unknown? unknown? ;older PSX boards |
Board data sync PU-23, PM-41 CXD2938Q.Pin42 CXD2938Q.Pin5 ;newer PSX and older PSone PM-41(2) CXD2941R.Pin36 CXD2941R.Pin76 ;newer PSone boards |
1. Com 19h,20h ;Retrieve CDROM Controller timestamp 2. Com 01h ;CdlNop: Get CD status 3. Com 07h ;CdlMotorOn: Make CD-ROM drive ready (blah?) 4. Com 02h,1,1,1 ;CdlSetloc(01:01:01) (sector that does NOT have SCEx data) 5. Com 0Eh,1 ;CdlSetmode: Turn on CD-DA read mode 6. Short Delay 7. Com 16h ;CdlSeekP: Seek to Setloc's parameters (4426) 8. Com 0Bh ;CdlMute: Turn off sound so CdlPlay is inaudible 9. Com 03h ;CdlPlay: Start playing CD-DA. 10. Com 19h,04h ;ResetSCExInfo (reset GetSCExInfo response to 0,0) 11. Long Delay ;wait until the modchip (if any) has output SCEx data 12. Com 19h,05h ;GetSCExInfo (returns total,success counters) 13. Com 09h ;CdlPause: Stop command 19h. |
1 3.5V (supply)
2 IC304.Pin44 (unknown?) (XLAT)
3 BIOS.Pin15 (D2)
4 BIOS.Pin31 (A18)
5 SPU.Pin5 ("sync")
6 SPU.Pin42 ("data")
7 IC304.Pin19 (SHELL_OPEN)
8 GND (supply)
|
SPU.Pin42 "data" -------|>|------ CPU.Pin149 (A20) SPU.Pin5 "sync" ---------------- IC723.Pin17 |
| CDROM Protection - Chipless Modchips |
A20 = the normal SCEX signal (inverted ASCII, eg. "A" = BEh) ;all boards A21 = uninverted SCEX signal (uninverted ASCII, eg. "A" = 41h) ;PU-7..PU-20 A21 = always 1 during SCEX output ;PU-22 and up |
.--------.-. .--------.-.
GATE--------|C NPN | . DATA--------|C NPN | .
A20--[10K]--|B BC | | A21--[10K]--|B BC | |
GND---------|E 547 | ' GND---------|E 547 | '
'--------'-' '--------'-'
|
.-------------------.
A21----|OE1,OE2 |
A20----|IN1 74HC126 OUT1|--- DATA
WFCK---|IN2 OUT2|--- SYNC
'-------------------'
|
GATE---------GND DATA---------A20 |
SYNC--------WFCK DATA---|>|---A20 |
GATE is IC703.Pin2 (?) (8pin chip with marking "082B") ;PU-7? .. PU-16 GATE is IC706.Pin7/10 (16pin "118" (uPC5023GR-118) ;PU-18 .. PU-20 SYNC is IC723.Pin17(TEO)(20pin "SONY CXA2575N") ;PU-22 .. PM-41(2) DATA is IC???.Pin7 (CG) (8pin chip with marking "2903") ;PU-7? .. PU-16 DATA is IC706.Pin1 (CG) (16pin "118" (uPC5023GR-118) ;PU-18 .. PU-20 DATA is HC05.Pin17 (CG) (52pin "SONY SC4309xxPB") ;PU-7 .. EARLY-PU-8 DATA is HC05.Pin32 (CG) (80pin "SONY E35D, 4246xx 185") ;LATE-PU-8 .. PU-20 DATA is SPU.Pin42 (CEI) (208pin "SONY CXD2938Q") ;PU-22 .. PM-41 DATA is SPU.Pin36?(CEI) (176pin "SONY CXD2941R") ;PM-41(2) WFCK is SPU.Pin5 (WFCK) (208pin "SONY CXD2938Q") ;PU-22 .. PM-41 WFCK is SPU.Pin84(WFCK) (176pin "SONY CXD2941R") ;PM-41(2) A20 is CPU.Pin149(A20) (208-pin CPU CXD8530 or CXD8606) ;PU-7 .. PM-41(2) A20 is EXP.Pin28 (A20) (68-pin Expansion Port) ;PU-7 .. PU-22 A21 is CPU.Pin150(A21) (208-pin CPU CXD8530 or CXD8606) ;PU-7 .. PM-41(2) A21 is EXP.Pin62 (A21) (68-pin Expansion Port) ;PU-7 .. PU-22 |
| CDROM Protection - LibCrypt |
1. 2 bits from both MSFs are modified,
CRC-16 is recalculated and XORed with 0x0080.
Games: Net Yaroze Demo (E), MediEvil (E).
2. 2 bits from both MSFs are modified,
original CRC-16 is XORed with 0x8001.
Games: CTR: Crash Team Racing (E) (No EDC), CTR: Crash Team Racing (E)
(EDC), Dino Crisis (E), Eagle One: Harrier Attack (E), Gekido:
Urban Fighters (E), et al.
3. Either 2 bits or none from both MSFs are modified,
CRC-16 is recalculated and XORed with 0x0080.
Games: Ape Escape (S) et al.
|
No. <------- Minute=03/Normal -------> <------- Minute=09/Backup -------> Bit15 14105 (03:08:05) 14110 (03:08:10) 42045 (09:20:45) 42050 (09:20:50) Bit14 14231 (03:09:56) 14236 (03:09:61) 42166 (09:22:16) 42171 (09:22:21) Bit13 14485 (03:13:10) 14490 (03:13:15) 42432 (09:25:57) 42437 (09:25:62) Bit12 14579 (03:14:29) 14584 (03:14:34) 42580 (09:27:55) 42585 (09:27:60) Bit11 14649 (03:15:24) 14654 (03:15:29) 42671 (09:28:71) 42676 (09:29:01) Bit10 14899 (03:18:49) 14904 (03:18:54) 42813 (09:30:63) 42818 (09:30:68) Bit9 15056 (03:20:56) 15061 (03:20:61) 43012 (09:33:37) 43017 (09:33:42) Bit8 15130 (03:21:55) 15135 (03:21:60) 43177 (09:35:52) 43182 (09:35:57) Bit7 15242 (03:23:17) 15247 (03:23:22) 43289 (09:37:14) 43294 (09:37:19) Bit6 15312 (03:24:12) 15317 (03:24:17) 43354 (09:38:04) 43359 (09:38:09) Bit5 15378 (03:25:03) 15383 (03:25:08) 43408 (09:38:58) 43413 (09:38:63) Bit4 15628 (03:28:28) 15633 (03:28:33) 43634 (09:41:59) 43639 (09:41:64) Bit3 15919 (03:32:19) 15924 (03:32:24) 43963 (09:46:13) 43968 (09:46:18) Bit2 16031 (03:33:56) 16036 (03:33:61) 44054 (09:47:29) 44059 (09:47:34) Bit1 16101 (03:34:51) 16106 (03:34:56) 44159 (09:48:59) 44164 (09:48:64) Bit0 16167 (03:35:42) 16172 (03:35:47) 44312 (09:50:62) 44317 (09:50:67) |
No. <-- Modified --> No. <--Unmodified--> Bit15 14105 (03:08:05) Bit14 14104 (03:08:04) Bit13 14231 (03:09:56) Bit12 14230 (03:09:55) Bit11,3 14485 (03:13:10) Bit10,2 14484 (03:13:09) Bit9,1 14579 (03:14:29) Bit8,0 14578 (03:14:28) Bit7 14649 (03:15:24) Bit6 14648 (03:15:23) Bit5 14899 (03:18:49) Bit4 14898 (03:18:48) |
| CDROM Disk Images CCD/IMG/SUB (CloneCD) |
00h..0Bh 12 Subchannel P (Pause-bits, usually all set, or all cleared) 0Ch..17h 12 Subchannel Q (ADR/Control, custom info, CRC-16-CCITT) 18h..5Fh .. Subchannel R..W (usually zero) (can be used for CD-TEXT) |
[CloneCD] ;File ID and version [Disc] ;Overall Disc info [CDText] ;CD-TEXT (included only if present) [Session N] ;Session(s) (numbered 1 and up) [Entry N] ;Lead-in entries (numbered 0..."TocEntries-1") [TRACK N] ;Track info (numbered 1 and up) |
Version=3 ;-version (usually 3) (rarely 2) |
TocEntries=4 ;-number of [Entry N] fields (lead-in info blocks) Sessions=1 ;-number of sessions (usually 1) DataTracksScrambled=0 ;-unknown purpose (usually 0) CDTextLength=0 ;-total size of 18-byte CD-TEXT chunks (usually 0) CATALOG=NNNNNNNNNNNNN ;-13-digit EAN-13 barcode (included only if present) |
Entries=N ;number of following entries (CDTextLength/18) (not /16) Entry 0=80 00 NN NN NN NN NN NN NN NN NN NN NN NN NN NN ;entry 0 Entry 1=80 NN NN NN NN NN NN NN NN NN NN NN NN NN NN NN ;entry 1 ... Entry XX=8f NN NN NN NN NN NN NN NN NN NN NN NN NN NN NN ;entry N-1 Note: Each entry contains 16 bytes (ie. "18-byte CD-TEXT" with CRC excluded) "NN NN NN.." consists of 2-digit lowercase HEX numbers (without leading "0x") |
PreGapMode=2 ;-unknown purpose (usually 1 or 2) (or 0) PreGapSubC=1 ;-unknown purpose (usually 0 or 1) |
Session=1 ;-session number that this entry belongs to (usually 1) Point=0xa0 ;-point (0..63h=Track, non-BCD!) (A0h..XXh=specials) Q2 ADR=0x01 ;-lower 4bit of ADR/Control (usually 1) Q0.lo Control=0x04 ;-upper 4bit of ADR/Control (eg. 0=audio, 4=data) Q0.hi TrackNo=0 ;-usually/always 0 (as [Entry N]'s are in Lead-in) Q1 AMin=0 ;\current MSF address Q3 ASec=0 ; (dummy zero values) (actual content Q4 AFrame=0 ; would be current lead-in position) Q5 ALBA=-150 ;/ALBA=((AMin*60+ASec)*75+AFrame)-PreGapSize Zero=0 ;-probably reserved byte from Q channel Q6 PMin=1 ;\referenced MSF address (non-BCD!), for certain Q7 PSec=32 ; Point's, PMin may contain a Track number, and PSec Q8 PFrame=0 ; the disc type value (that without non-BCD-glitch) Q9 PLBA=6750 ;/PLBA=((PMin*60+PSec)*75+PFrame)-PreGapSize |
MODE=2 ;-mode (0=Audio, 1=Mode1, 2=Mode2) ISRC=XXXXXNNNNNNN ;-12-letter/digit ISRC code (included only if present) INDEX 0=N ;-1st sector with index 0, missing EVEN if any? INDEX 1=N ;-1st sector with index 1, usually same as track's PLBA INDEX 2=N ;-1st sector with index 2, if any etc. |
| CDROM Disk Images CDI (DiscJuggler) |
Sector Data (sector 00:00:00 and up) ;-body Number of Sessions (1 byte) <--- located at "Filesize-Footersize" Session Block for 1st session (15 bytes) ;\ nnn-byte info for 1st track ; 1st session nnn-byte info for 2nd track (if any) ; etc. ;/ Session Block for 2nd session (15 bytes) ;\ nnn-byte info for 1st track ; 2nd session (if any) nnn-byte info for 2nd track (if any) ; etc. ;/ etc. ;-further sessions (if any) Session Block for no-more-sessions (15 bytes) ;-end marker nnn-byte Disc Info Block ;-general disc info Entrypoint (4 bytes) <--- located at "Filesize-4" |
00h 1 Number of Sessions (usually 1) |
00h 1 Unknown (00h) 01h 1 Number of Tracks in session (01h..63h) (or 00h=No More Sessions) 02h 7 Unknown (00h-filled) 09h 1 Unknown (01h) 0Ah 3 Unknown (00h-filled) 0Dh 2 Unknown (FFh,FFh) |
00h 12 Unknown (FFh,FFh,00h,00h,01h,00h,00h,00h,FFh,FFh,FFh,FFh) 0Ch 3 Unknown (DAh,0Ah,D5h or 64h,05h,2Ah) (random/id/chksum?) 0Fh 1 Total Number of Tracks on Disc (00h..63h) (non-BCD) 10h 1 Length of below Path/Filename (F) 11h (F) Full Path/Filename (eg. "C:\folder\file.cdi") 11h+F 11 Unknown (00h-filled) 1Ch+F 1 Unknown (02h) 1Dh+F 10 Unknown (00h-filled) 27h+F 1 Unknown (80h) 28h+F 4 Unknown (00057E40h) (=360000 decimal) (disc capacity 80 minutes?) 2Ch+F 2 Unknown (00h,00h) 2Eh+F 2 Medium Type (0098h=CD-ROM, 0038h=DVD-ROM) |
00h 30h+F Track/Disc Header (see above)
30h+F 02h Number of Indices (usually 0002h) (I=Num*4)
32h+F (I) 32bit Lengths (per index) (eg. 00000096h,00007044h)
32h+FI 04h Number of CD-Text blocks (usually 0) (T=Num*18+VariableLen's)
36h+FI (T) CD-Text (if any) (see "mirage_parser_cdi_parse_cdtext")
36h+FIT 02h Unknown (00h,00h)
38h+FIT 01h Track Mode (0=Audio, 1=Mode1, 2=Mode2/Mixed)
39h+FIT 07h Unknown (00h,00h,00h,00h,00h,00h,00h)
40h+FIT 04h Session Number (starting at 0) (usually 00h)
44h+FIT 04h Track Number (non-BCD, starting at 0) (00h..62h)
48h+FIT 04h Track Start Address (eg. 00000000h)
4Ch+FIT 04h Track Length (eg. 000070DAh)
50h+FIT 0Ch Unknown (00h-filled)
5Ch+FIT 04h Unknown (00000000h or 00000001h)
60h+FIT 04h read_mode (0..4)
0: Mode1, 800h, 2048
1: Mode2, 920h, 2336
2: Audio, 930h, 2352
3: Raw+PQ, 940h, 2352+16 non-interleaved (P=only 1bit)
4: Raw+PQRSTUVW, 990h, 2352+96 interleaved
64h+FIT 4 Control (Upper 4bit of ADR/Control, eg. 00000004h=Data)
68h+FIT 1 Unknown (00h)
69h+FIT 4 Track Length (eg. 000070DAh) (same as above)
6Dh+FIT 4 Unknown (00h,00h,00h,00h)
71h+FIT 12 ISRC Code 12-letter/digit (ASCII?) string (00h-filled if none)
7Dh+FIT 4 ISRC Valid Flag (0=None, Other?=Yes?)
81h+FIT 1 Unknown (00h)
82h+FIT 8 Unknown (FFh,FFh,FFh,FFh,FFh,FFh,FFh,FFh)
8Ah+FIT 4 Unknown (00000001h)
8Eh+FIT 4 Unknown (00000080h)
92h+FIT 4 Unknown (00000002h) (guess: maybe audio num channels??)
96h+FIT 4 Unknown (00000010h) (guess: maybe audio bits/sample??)
9Ah+FIT 4 Unknown (0000AC44h) (44100 decimal, ie. audio sample rate?)
9Eh+FIT 2Ah Unknown (00h-filled)
C8h+FIT 4 Unknown (FFh,FFh,FFh,FFh)
CCh+FIT 12 Unknown (00h-filled)
D8h+FIT 1 session_type ONLY if last track of a session (else 0)
(0=Audio/CD-DA, 1=Mode1/CD-ROM, 2=Mode2/CD-XA)
D9h+FIT 5 Unknown (00h-filled)
DEh+FIT 1 Not Last Track of Session Flag (0=Last Track, 1=Not Last)
DFh+FIT 1 Unknown (00h)
E0h+FIT 4 address for last track of a session? (otherwise 00,00,FF,FF)
|
00h 30h+F Track/Disc Header (see above) 30h+F 4 Disc Size (total number of sectors) 34h+F 1 Volume ID Length (V) ;\from Primary Volume Descriptor[28h..47h] 35h+F (V) Volume ID String ;/(ISO Data discs) (unknown for Audio) 35h+FV 1 Unknown (00h) 36h+FV 4 Unknown (01h,00h,00h,00h) 3Ah+FV 4 Unknown (01h,00h,00h,00h) 3Eh+FV 13 EAN-13 Code 13-digit (ASCII?) string (00h-filled if none) 4Bh+FV 4 EAN-13 Valid Flag (0=None, Other?=Yes?) 4Fh+FV 4 CD-Text Length in bytes (T=Num*1) 53h+FV (T) CD-Text (for Lead-in) (probably 18-byte units?) 53h+FVT 8 Unknown (00h-filled) 5Bh+FVT 4 Unknown (06h,00h,00h,80h) |
00h 4 Footer Size in bytes |
| CDROM Disk Images CUE/BIN/CDT (Cdrwin) |
FILE "PATH\FILENAME.BIN" BINARY
TRACK 01 MODE2/2352
INDEX 01 00:00:00 ;real address = 00:02:00 (+2 seconds)
TRACK 02 AUDIO
PREGAP 00:02:00 ;two missing seconds (NOT stored in .BIN)
INDEX 01 08:09:29 ;real address = 08:13:29 (+2 seconds +pregap)
TRACK 03 AUDIO
INDEX 00 14:00:29 ;real address = 14:04:29 (+2 seconds +pregap)
INDEX 01 14:02:29 ;real address = 14:06:29 (+2 seconds +pregap)
TRACK 04 AUDIO
INDEX 00 18:30:20 ;real address = 18:34:20 (+2 seconds +pregap)
INDEX 01 18:32:20 ;real address = 18:36:20 (+2 seconds +pregap)
|
(must appear before any other commands, except CATALOG) (uh, may also appear before further tracks) |
AUDIO ;930h ;bytes 000h..92Fh CDG ;? ;? MODE1/2048 ;800h ;bytes 010h..80Fh MODE1/2352 ;930h ;bytes 000h..92Fh MODE2/2336 ;920h ;bytes 010h..92Fh MODE2/2352 ;930h ;bytes 000h..92Fh CDI/2336 ;920h ;? CDI/2352 ;930h ;bytes 000h..92Fh |
(ISRC must be after TRACK, and before INDEX) |
TRACK 1 MODE2/2352 ;three spaces indent, and 1-digit track INDEX 1 00:00:00 ;three spaces indent, and 1-digit index |
TRACK 01 MODE2/2352 ;two spaces indent, and 2-digit track
INDEX 01 00:00:00 ;four spaces indent, and 2-digit index
|
| CDROM Disk Images MDS/MDF (Alcohol 120%) |
Bit7..0 = Subchannel P..W (in that order, eg. Bit6=Subchannel Q) |
1st..8th bit = Bit7..Bit0 of 1st byte (in that order, ie. MSB/Bit7 first)
9st..16th bit = Bit7..Bit0 of 2nd byte ("")
17th.. = etc.
|
Header (58h bytes) Session block(s) (usually one 18h byte entry) Data blocks (N*50h bytes) Index blocks (usually N*8 bytes) Filename blocks(s) (usually one 10h byte entry) Filename string(s) (usually one 6 byte string) Read error(s) (usually none such) |
00h 16 File ID ("MEDIA DESCRIPTOR")
10h 2 Unknown (01h,03h or 01h,04h or 01h,05h) (Fileformat version?)
12h 2 Media Type (0=CD-ROM, 1=CD-R, 2=CD-RW, 10h=DVD-ROM, 12h=DCD-R)
14h 2 Number of sessions (usually 1)
16h 4 Unknown (02h,00h,00h,00h)
1Ah 2 Zero (for DVD: Length of BCA data)
1Ch 8 Zero
24h 4 Zero (for DVD: Offset to BCA data)
28h 18h Zero
40h 4 Zero (for DVD: Offset to Disc Structures) (from begin of .MDS file)
44h 0Ch Zero
50h 4 Offset to First Session-Block (usually 58h) (from begin of .MDS file)
54h 4 Offset to Read errors (usually 0=None) (from begin of .MDS file)
|
00h 4 Session Start Sector (starting at FFFFFF6Ah=-150 in first session) 04h 4 Session End Sector (XXX plus 150 ?) 08h 2 Session number (starting at 1) (non-BCD) 0Ah 1 Number of Data Blocks with any Point value (Total Data Blocks) 0Bh 1 Number of Data Blocks with Point>=A0h (Special Lead-In info) 0Ch 2 First Track Number in Session (01h..63h, non-BCD!) 0Eh 2 Last Track Number in Session (01h..63h, non-BCD!) 10h 4 Zero 14h 4 Offset to First Data-Block (usually 70h) (from begin of .MDS file) |
00h 1 Track mode (see below for details) 01h 1 Number of subchannels in .MDF file (0=None, 8=Sector has +60h bytes) 02h 1 ADR/Control (but with upper/lower 4bit swapped, ie. MSBs=ADR!) Q0 03h 1 TrackNo (usually/always 00h; as this info is in Lead-in area) Q1 04h 1 Point (Non-BCD!) (Track 01h..63h) (or A0h and up=Lead-in info) Q2 05h 4 Zero (probably dummy MSF and reserved byte from Q channel) Q3..Q6? 09h 1 Minute (Non-BCD!) ;\MM:SS:FF of Point'ed track Q7 0Ah 1 Second (Non-BCD!) ; (or disc/lead-out info when Point>=A0h) Q8 0Bh 1 Frame (Non-BCD!) ;/ Q9 |
0Ch 4 Offset to Index-block for this track (from begin of .MDS file) 10h 2 Sector size (800h..930h) (or 860h..990h if with subchannels) 12h 1 Unknown (02h) (maybe number of indices?) 13h 11h Zero 24h 4 Track start sector, PLBA (00000000h=00:02:00)(or 00000096h=00:02:00?) 28h 8 Track start offset (from begin of .MDF file) 30h 4 Number of Filenames for this track (usually 1) 34h 4 Offset to Filename Block for this track (from begin of .MDS file) 38h 18h Zero |
(upper 4bit seem to be meaningless?) 00h=None (used for entries with Point=A0h..FF) A9h=AUDIO ;sector size = 2352 930h ;bytes 000h..92Fh AAh=MODE1 ;sector size = 2048 800h ;bytes 010h..80Fh ABh=MODE2 ;sector size = 2336 920h ;bytes 010h..92Fh ACh=MODE2_FORM1 ;sector size = 2048 800h ;bytes 018h..817h (incomplete!) ADh=MODE2_FORM2 ;sector size = 2324+0? 914h ;bytes 018h..91Bh (incomplete!) ADh=MODE2_FORM2 ;sector size = 2324+4? 918h ;bytes ??..?? (contains what?) ECh=MODE2 ;sector size = 2448 990h ;(930h+60h) (with subchannels) |
00h 4 Number of sectors with Index 0 (usually 96h or zero) 04h 4 Number of sectors with Index 1 (usually size of main-track area) |
00h 4 Offset to Filename (from begin of .MDS file) 04h 1 Filename format (0=8bit, 1=16bit characters) 05h 11 Zero |
00h 6 Filename, terminated by zero (usually "*.mdf",00h) |
00h 4 Unknown (1) 04h 4 Offset to following stuff 08h 4 Unknown (2) 0Ch 4 Unknown (7) 10h 4 Unknown (1) 14h 4 Number of read errors (E) 18h E*4 LBA's for sectors with read errors (0 and up) |
| CDROM Disk Images NRG (Nero) |
CUES,DAOI,END!,NERO <-- when image was DUMPED with nero TINF,RELO,TOCT,END!,NERO <-- when image was CREATED with nero |
4 File ID "NERO"/"NER5" 4/8 Fileoffset of first chunk |
4 Chunk ID "CUES"/"CUEX" 4 Chunk size (bytes) |
1 ADR/Control from TOC (usually LSBs=ADR=1=fixed, MSBs=Control=Variable) 1 Track (BCD) (00h=Lead-in, 01h..99h=Track N, AAh=Lead-out) 1 Index (BCD) (usually 00h=pregap, 01h=actual track) 1 Zero |
1 Zero 1 Minute (BCD) ;starting at 00:00:00 = 2 seconds before ISO vol. descr. 1 Second (BCD) 1 Sector (BCD) |
4 Logical Sector Number (HEX) ;starting at FFFFFF6Ah (=00:00:00) |
4 Chunk ID "DAOI"/"DAOX" 4 Chunk size (bytes) 4 Garbage (usually same as above Chunk size) 13 EAN-13 Catalog Number (13-digit ASCII) (or 00h-filled if none/unknown) 1 Zero 1 Disk type (00h=Mode1 or Audio, 20h=XA/Mode2) (and probably 10h=CD-I?) 1 Unknown (01h) 1 First track (Non-BCD) (01h..63h) 1 Last track (Non-BCD) (01h..63h) |
12 ISRC in ASCII (eg. "USXYZ9912345") (or 00h-filled if none/unknown)
2 Sector size (usually 800h, 920h, or 930h) (see Mode entry for more info)
1 Mode:
0=Mode1/800h ;raw mode1 data (excluding sync+header+edc+errorinfo)
3=Mode2/920h ;almost full sector (exluding first 16 bytes; sync+header)
6=Mode2/930h ;full sector (including first 16 bytes; sync+header)
7=Audio/930h ;full sector (plain audio data)
Mode values from wikipedia:
00h for data Mode1/800h
02h
03h for Mode 2 Form 1 data eh? FORM1??? Mode2/920h
05h for raw data Mode1?/930h
06h for raw Mode 2/form 1 data Mode2/930h
07h for audio Audio/930h
0Fh for raw data with sub-channel Mode1?/930h+WHAT?
10h for audio with sub-channel Audio/930h+WHAT?
11h for raw Mode 2/form 1 data with sub-channel Mode2/WHAT?+WHAT?
Note: Some newer files do actually use different sector sizes for each
track (eg. 920h for the data track, and 930h for any following audio
tracks), older files were using the same sector size for all tracks
(eg. if the disk contained 930-byte Audio tracks, then Data tracks
were stored at the same size, rather than at 800h or 920h bytes).
3 Unknown (always 00h,00h,01h)
4/8 Fileoffset 1 (Start of Track's Pregap) (with Index=00h)
4/8 Fileoffset 2 (Start of actual Track) (with Index=01h and up)
4/8 Fileoffset 3 (End of Track) (aka begin of next track's pregap)
|
4 Chunk ID "END!" 4 Chunk size (always zero) |
4 Chunk ID "TINF"/"ETNF"/"ETN2" 4 Chunk size (bytes) (0Ch/14h/1Ch*NumTracks) |
4/4/8 Track fileoffset ;\32bit in TINF/ETNF chunks, 4/4/8 Track length (bytes) ;/64bit in ETN2 chunks 3 Zero 1 Mode (should be same as in DAO chunks, see there) (implies sector size) 0/4/4 Start lba on disc ;\only in ETNF/ETN2 chunks, 0/4/4 Unknown? ;/not in TINF chunks |
4 Chunk ID "RELO" 4 Chunk size (bytes) 4 Zero |
4 Chunk ID "TOCT" 4 Chunk size (bytes) 1 Disk type (00h=Mode1 or Audio, 20h=XA/Mode2) (and probably 10h=CD-I?) 1 Zero (00h) |
4 Chunk ID "SINF" 4 Chunk size (bytes) 4 Number of tracks in session |
4 Chunk ID None/"CDTX" 4 Chunk size (bytes) (must be a multiple of 18 bytes) |
18 Raw 18-byte CD-text data fragments |
4 Chunk ID "MTYP" 4 Chunk size (bytes) 4 Unknown? (00000001h for CDROM) (maybe other value for DVD) |
4 Chunk ID "AFNM" 4 Chunk size (bytes) .. Track Filenames (eg. "Track1.wav",0,"Track2.wav",0) |
4 Chunk ID "VOLM" 4 Chunk size (bytes) .. Name (eg. "Audio CD",00h) |
| CDROM Disk Image/Containers CDZ |
FileID ("CDZ",00h for cdztool v0/v1, or "CDZ",01h for cdztool v2 and up)
One or two Chunk(s)
|
4 32bit Decompressed Size (of all blocks) (must be other than "ZLIB") |
4 ZLIB ID ("ZLIB")
8 64bit Decompressed Size (of all blocks)
|
4 Chunk ID (eg. "CUE",00h)
8 Chunk Size in bytes (starting at "ZLIB" up to including Footer, if any)
4 ZLIB ID ("ZLIB")
8 64bit Decompressed Size (of all blocks)
|
4 Number of Blocks (N) 4 Block 1 Compressed Size (CS.1) 4 Block 1 Decompressed Size (always 00010000h, except last block) CS.1 Block 1 Compressed ZLIB Data (starting with 78h,9Ch) ... ... ;\ 4 Block N Compressed Size (CS.N) ; further block(s) 4 Block N Decompressed Size ; (if any) CS.N Block N Compressed ZLIB Data ;/ |
4*N Directory Entries for N blocks ;-this ONLY for BIN chunk |
BPD*(N-1) Directory Entries for N-1 blocks ;\this ONLY for BIN chunk 1 Bytes per Directory Entry (BPD) ;/(not for CUE/CCD/MDS) |
noname+noname --> .CUE+.BIN (cdztool v1 and below) "BIN",0 --> .ISO (cdztool v2? and up) "CUE",0+"BIN",0 --> .CUE+.BIN (cdztool v2 and up) "CCD",0+"BIN",0 --> .CCD+.IMG (cdztool v2 and up) "CCD",0+"BIN",01h --> .CCD+.IMG+.SUB (930h sectors, plus 60h subchannels) "MDS",0+"BIN",0 --> .MDS+.MDF (cdztool v5 only) |
cdztool.exe v0, unrelased prototype cdztool.exe v1, 22 May 2005, CRC32=620dbb08, 102400 bytes, pSX v1.0-5 cdztool.exe v2, 02 Jul 2006, CRC32=bcb29c1e, 110592 bytes, pSX v1.6 cdztool.exe v3, 22 Jul 2006, CRC32=4062ba82, 110592 bytes, pSX v1.7 cdztool.exe v4, 13 Aug 2006, CRC32=7388dd3d, 118784 bytes, pSX v1.8-11 cdztool.exe v5, 22 Jul 2007, CRC32=f25c1659, 155648 bytes, pSX v1.12-13 |
| CDROM Disk Image/Containers ECM |
45 43 4D 00 ;FileID "ECM",00h 3C ;Type 0, Len=10h (aka 0Fh+1) 00 FF FF FF FF FF FF FF FF FF FF 00 00 02 00 02 ;16 data bytes 02 ;Type 2, Len=1 (aka 00h+1) 00 00 08 00 00 00 00 00 00 00 00 ..... 00 00 00 ;804h data bytes 3C ;Type 0, Len=10h (aka 0Fh+1) 00 FF FF FF FF FF FF FF FF FF FF 00 00 02 01 02 ;16 data bytes 02 ;Type 2, Len=1 (aka 00h+1) 00 00 08 00 00 00 00 00 00 00 00 ..... 00 00 00 ;804h data bytes ... FC FF FF FF 3F ;End Code (Len=FFFFFFFFh+1) NN NN NN NN ;EDC (on decompressed data) |
1st Byte: Bit7=More, Bit6-2=LengthBit4-0, Bit1-0=Type(0..3) 2nd Byte: Bit7=More, Bit6-0=LengthBit5-11 3rd Byte: Bit7=More, Bit6-0=LengthBit12-18 4th Byte: Bit7=More, Bit6-0=LengthBit19-25 5th Byte: Bit7-6=Reserved/Zero, Bit5-0=LengthBit26-31 |
Type 0: load 1 byte, save 1 byte Type 1: load 803h bytes [0Ch..0Eh,10h..80Fh], save 930h bytes [0..92Fh] Type 2: load 804h bytes [14h..817h], save 920h bytes [10h..92Fh] Type 3: load 918h bytes [14h..91Bh], save 920h bytes [10h..92Fh] |
A RAR file containing a 7Z file containing a ECM file containing a BIN file. The BIN containing only Track 1, other tracks stored in APE files. And, of course, the whole mess without including the required CUE file. |
| CDROM Subchannel Images |
000h 4 FileID ("SBI",00h)
004h .. Subchannel entries (with 7 or 14 bytes per entry)
Subchannel entry format:
000h 3 Real absolute MM:SS:FF address where the sub q data was bad
003h 1 Format (1, 2 or 3)
004h 10 Q0..Q9 (complete 10-byte sub q data, excluding CRC) ;<-- Format 1
004h 3 Q3..Q5 (3-byte wrong relative MM:SS:FF address) ;<-- Format 2
004h 3 Q7..Q9 (3-byte wrong absolute MM:SS:FF address) ;<-- Format 3
|
000h N*15 Subchannel entries (with 15 bytes per entry) Subchannel entry format: 000h 3 Real absolute MM:SS:FF address where the sub q data was bad 003h 12 Q0..Q11 (complete 12-byte sub q data, including CRC) |
000h 16 ASCII "LibCryptKey=####" (with #### = 16bit uppercase HEX key) |
Q0..Q9 Subchannel Q data (normally position data) Q10..Q11 Subchannel Q checksum Q12..Q15 Dummy/garbage/padding (usually 00000000h or FFFFFFFFh) |
1. With CRC (Q0..Q11 intact) (and Q12..Q15 randomly 00000000h or FFFFFFFFh) 2. Without CRC (only Q0..Q9 intact, but Q10..Q15 zerofilled) 3. Without anything (only Q0 intact, but Q1..Q15 zerofilled) |
CCD/IMG/SUB (CloneCD) P-W 60h-bytes Non-interleaved (in separate .SUB file) CDI (DiscJuggler) P-Q 10h-bytes Non-interleaved (in .CDI file) "" P-W 60h-bytes Interleaved (in .CDI file) CUE/BIN/CDT (Cdrwin) N/A (none) ISO (single-track) N/A (none) MDS/MDF (Alcohol 120%) P-W 60h-bytes Interleaved (in .MDF file) NRG (Nero) P-W 60h-bytes Interleaved (in .NRG file) |
00h-07h 80 C0 80 80 80 80 80 C0 ;P=FFh, Q=41h=ADR/Control, R..W=00h 08h-0Fh 80 80 80 80 80 80 80 C0 ;P=FFh, Q=01h=Track, R..W=00h 10h-17h 80 80 80 80 80 80 80 C0 ;P=FFh, Q=01h=Index, R..W=00h 18h-1Fh 80 80 80 80 80 80 80 80 ;P=FFh, Q=00h=RelMinute, R..W=00h 20h-27h 80 80 80 80 80 80 80 80 ;P=FFh, Q=00h=RelSecond, R..W=00h 28h-2Fh 80 80 80 80 80 80 80 80 ;P=FFh, Q=00h=RelSector, R..W=00h 30h-37h 80 80 80 80 80 80 80 80 ;P=FFh, Q=00h=Reserved, R..W=00h 38h-3Fh 80 80 80 80 80 80 80 80 ;P=FFh, Q=00h=AbsMinute, R..W=00h 40h-47h 80 80 80 80 80 80 C0 80 ;P=FFh, Q=02h=AbsSecond, R..W=00h 48h-4Fh 80 80 80 80 80 80 80 80 ;P=FFh, Q=00h=AbsSector, R..W=00h 50h-57h 80 80 C0 80 C0 80 80 80 ;P=FFh, Q=28h=ChecksumMsb, R..W=00h 58h-5Fh 80 80 C0 C0 80 80 C0 80 ;P=FFh, Q=32h=ChecksumLsb, R..W=00h |
00h-0Bh FF FF FF FF FF FF FF FF FF FF FF FF ;Subchannel P (Pause) 0Ch-17h 41 01 01 00 00 00 00 00 02 00 28 32 ;Subchannel Q (Position) 18h-23h 00 00 00 00 00 00 00 00 00 00 00 00 ;Subchannel R 24h-2Fh 00 00 00 00 00 00 00 00 00 00 00 00 ;Subchannel S 30h-3Bh 00 00 00 00 00 00 00 00 00 00 00 00 ;Subchannel T 3Ch-47h 00 00 00 00 00 00 00 00 00 00 00 00 ;Subchannel U 48h-53h 00 00 00 00 00 00 00 00 00 00 00 00 ;Subchannel V 54h-5Fh 00 00 00 00 00 00 00 00 00 00 00 00 ;Subchannel W |
This is probably based on MMC protocol, which would be as crude as this: The 96 pause bits are summarized in 1 bit. Pause/Checksum are optional. 00h-09h 41 01 01 00 00 00 00 00 02 00 ;Subchannel Q (Position) 0Ah-0Bh 28 32 ;<-- OPTIONAL, can be zero! ;Subchannel Q (Checksum) 0Ch-0Eh 00 00 00 ;Unused padding (zero) 0F 80 ;<-- OPTIONAL, can be zero! ;Subchannel P (Bit7=Pause) |
| CDROM Disk Images PBP (Sony) |
000000h 4 ID (00h,"PBP")
000004h 4 Version? (10000h) (but, reportedly "always 100h or 1000100h")
000008h 4 Offset of the file PARAM.SFO (28h)
00000Ch 4 Offset of the file ICON0.PNG (3D8h)
000010h 4 Offset of the file ICON1.PMF (3D8h) or ICON1.PNG
000014h 4 Offset of the file PIC0.PNG (3D8h) or UNKNOWN.PNG
000018h 4 Offset of the file PIC1.PNG (3D8h) or PICT1.PNG
00001Ch 4 Offset of the file SND0.AT3 (3D8h)
000020h 4 Offset of the file DATA.PSP (3D8h)
000024h 4 Offset of the file DATA.PSAR (10000h)
000028h .. PARAM.SFO file (zerofilled in homebrew PBP)
0003D8h .. PNG files etc (zerofilled in homebrew PBP)
010000h 0Ch ID "PSISOIMG0000"
01000Ch 4 PBP Size-10000h (144740h)
010010h 4 PBP Size-6420h (???) (14E320h)
010014h .. Zerofilled
010400h 0Bh Game ID ("_SCUS_94476" for Hot Shots Golf 2)
01040Bh .. Zerofilled
010800h A00h TOC List (0Ah-byte per entry) (unused entries are zerofilled)
011200h 20h Zerofilled
011220h 4 PBP Size-D2CFh (???) (147471h)
011224h 4 Zero
011228h 4 Unknown (7FFh)
01122Ch 11h Game Name ("Hot Shots Golf",C2h,AEh,"2")
01123Dh .. Zerofilled
014000h .. Sector List (20h-byte per entry) (unused entries are zerofilled)
... .. Zerofilled
110000h .. Deflated sectors (9300h bytes after decompression)
15467Dh B8h One extra compression block that is NOT in Sector List ???
154735h 0Bh Weird padding with ASCII "00000000000"
154740h - End of file
TOC List (Subchannel Q with ADR=1 during Lead-In):
000h 1 ADR/Control (eg. 41h=Data Track)
001h 1 Track (always 00h=Lead-in for all TOC List entries)
002h 1 Point (A0h, A1h, A2h, or Track 01h and up) (BCD?)
003h 3 Dummy MSF (usually 00:00:00 or weirdly 00:02:01) (BCD?)
006h 1 Reserved (00h)
007h 3 Actual MSF (or TOC info for Point=A0h,A1h) (BCD?)
Example TOC (DBALL.PBP):
41 00 A0 00 00 00 00 01 20 00 ;First Track (1) and Type (20h=CDROM-XA)
41 00 A1 00 00 00 00 01 00 00 ;Last Track Number (1)
41 00 A2 00 00 00 00 27 19 22 ;Lead-Out, uh at 27:19:22 in DBALL.PBP ???
41 00 01 00 02 01 00 00 02 00 ;Track 1 at 00:02:00
(remaining entries are zerofilled)
Example TOC (PSALM69.PBP):
01 00 01 00 02 00 00 00 00 00 ;Track 1 as audio <-- why that ???
01 00 02 02 37 44 00 00 00 00 ;Track 2 as audio
01 00 03 03 25 45 00 00 00 00 ;Track 3 as audio
41 00 01 00 02 01 00 00 02 00 ;Track 1 as data <-- listed last?
(remaining entries are zerofilled)
(weirdly, most MM:SS:FF values are stored in byte[3..5] instead [7..9])
(there are no point=A0h,A1h,A2h entries)
Example TOC (GOOGLE_AI_TTS.PBP):
01 00 01 00 02 00 00 00 00 00 ;Track 1 as audio
01 00 02 00 02 30 00 00 00 00 ;Track 2 as audio, but without pregap?
01 00 03 00 02 60 00 00 00 00 ;Track 3 as audio, but without pregap?
01 00 04 00 03 15 00 00 00 00 ;Track 4 as audio, but without pregap?
(remaining entries are zerofilled)
Sector List:
000h 4 Offset-110000h to Sector(N*10h)
004h 2 Compressed size of Sector(N*10h+(0..0Fh)) ;9300h=uncompressed?
006h 2 Zero (but, reportedly "usually 1... and 0 for the last entry")
008h 10h Zero (but, reportedly "first 10h bytes of SHA1 sum of 10h sectors")
018h 8 Zero (padding)
|
? |
? |
? |
| CDROM Disk Images CHD (MAME) |
000h 08h ID "MComprHD" (MAME Compressed Hunks of Data) 008h 4 Header size (4Ch=V1, 50h=V2) 00Ch 4 Header version (probably 01h=V1, 02h=V2) 010h 4 Flags (bit0=DriveHasParent, bit1=AllowWrites) 014h 4 Compression type (0=None, 1=ZLIB) 018h 4 Number of sectors per hunk 01Ch 4 Total number of hunks represented 020h 4 Number of cylinders on hard disk 024h 4 Number of heads on hard disk 028h 4 Number of sectors on hard disk 02Ch 10h MD5 checksum on raw data 03Ch 10h MD5 checksum on parent file N/A - V1: Uses fixed 200h-byte Sector size 04Ch (4) V2: Number of bytes per sector ... ? Supposedly followed by map and/or data at whatever locations |
000h 08h ID "MComprHD" (MAME Compressed Hunks of Data)
008h 4 Header size (78h=V3, 6Ch=V4)
00Ch 4 Header version (03h=V3, 04h=V4)
010h 4 Flags (bit0=DriveHasParent, bit1=AllowWrites)
014h 4 Compression type (0=None, 1=ZLIB, 2=ZLIB_PLUS) (V4: 3=AV)
018h 4 Total number of hunks represented (N) (92h)
01Ch 08h Total size of all uncompressed hunks (N*2640h) (15D080h)
024h 08h Offset to the first blob of metadata
02Ch 10h V3: MD5 checksum on raw data ;\
03Ch 10h V3: MD5 checksum on parent file ;
04Ch 4 V3: Number of bytes per hunk (2640h=990h*4) ; V3
050h 14h V3: SHA1 checksum on raw data ;
064h 14h V3: SHA1 checksum on parent file ;/
02Ch 4 V4: Number of bytes per hunk (2640h=990h*4) ;\
030h 14h V4: SHA1 checksum on raw+meta ; V4
044h 14h V4: SHA1 checksum on raw+meta of parent ;
058h 14h V4: SHA1 checksum on raw data ;/
... N*10h Map entries (for each hunk)
... 10h Map end marker ("EndOfListCookie",00h)
... .. Metadata Chunk(s)
... .. Compressed Sectors (aka hunks)
|
000h 8 ID "MComprHD" (MAME Compressed Hunks of Data) 008h 4 Header size (7Ch=V5) 00Ch 4 Header version (05h=V5) 010h 4 Compressor 0 (usually "cdlz"=cdrom/lzma) 014h 4 Compressor 1 (usually "cdzl"=cdrom/zlib) 018h 4 Compressor 2 (usually "cdfl"=cdrom/flac) 01Ch 4 Compressor 3 (usually 0=none) 020h 8 Total size of all uncompressed hunks (N*4C80h-HunkPadding) 028h 8 Offset to Map (3D797h) 030h 8 Offset to first Metadata chunk (7Ch) 038h 4 Number of bytes per hunk (512k maximum) (990h*8) (4C80h) 03Ch 4 Number of bytes per sector (990h) (30h+60h) 040h 14h SHA1 on raw data 054h 14h SHA1 on raw+meta 068h 14h SHA1 on raw+meta of parent (0=No parent) ... .. Metadata Chunk(s) ... .. Padding to BytesPerHunk-boundary ;\when uncompressed ... .. Uncompressed Sectors (aka hunks) ;/ ... .. Compressed Sectors (aka hunks) ;-when compressed ... .. Map ________________________________ CHD Metadata ________________________________ |
000h 4 Chunk ID (aka Blob Tag) (eg. "CHT2" for each CDROM track) 004h 1 Flags (00h=V3, 01h=V4/V5) ;maybe some kind of flag/type/version? 005h 3 Chunk Data Size (24bit) 008h 8 Offset to next Chunk (or 0=Last chunk) 010h .. Chunk Data (eg. "TRACK:1 TYPE:MODE2_RAW ... POSTGAP:0",00h for CHT2) |
Summary of Chunk IDs and corresponding Data entries: ID_______Data_______________________________________________________ "GDDD" "CYLS,HEADS,SECS,BPS" ;-hard disk standard info ;\ "IDNT" ? ;-hard disk identify info ; HDD "KEY " ? ;-hard disk key info ;/ "CIS " ? ;-pcmcia CIS info ;-PCMCIA "CHCD" 94Ch-byte binary (4+99*24 bytes) ;\ "CHTR" "TRACK TYPE SUBTYPE FRAMES" ; CD-ROM "CHT2" "TRACK TYPE SUBTYPE FRAMES PREGAP PGTYPE PGSUB POSTGAP" ;/ "CHGT" ? ;\Sega "CHGD" "TRACK TYPE SUBTYPE FRAMES PAD PREGAP PGTYPE PGSUB POSTGAP" ;/GD-ROM "AVAV" "FPS WIDTH HEIGHT INTERLACED CHANNELS SAMPLERATE" ;\AV "AVLD" ? (A/V Laserdisc frame) ;/ "DVD " ? (for PSP's UMD) ;-DVD |
CYLS:# Hard disc number of cylinders HEADS:# Hard disc number of heads SECS:# Hard disc number of sectors BPS:# Hard disc bytes per sector TRACK:# CDROM current track number (1..99) TYPE:string CDROM sector type/size SUBTYPE:string CDROM subchannel info (usually "NONE") FRAMES:# CDROM number of sectors per track (with/without pregap?) PAD:# Sega GDROM only: whatever pad value? PREGAP:# CDROM ... maybe number of pregap sectors? (can be HUGE !!??) PGTYPE:string CDROM ... whatever type? (usually "MODE1"??) PGSUB:string CDROM ... whatever subchannel (usually "RW"??) POSTGAP:# CDROM ... maybe number of pstgap sectors? (usually 0) FPS:#.###### AV Video(?)-frames per second? with 6-digit fraction? (.avi?) WIDTH:# AV Width (maybe in pixels?) HEIGHT:# AV Height (maybe in pixels?) (with/without interlace?) INTERLACED:# AV Interlace (maybe a flag that might be maybe 0 or 1?) CHANNELS:# AV Channels (maybe audio mono/stereo or so?) SAMPLERATE:# AV Samplerate (maybe audio samplerate, maybe in Hertz?) For SUBTYPE and PGSUB: "RW" 60h-byte interleaved ;normal "cooked" 96 bytes per sector "RW_RAW" 60h-byte uninterleaved ;raw uninterleaved 96 bytes per sector "NONE" 0-byte ;no subcode data stored (default) (unknown how RAW and RW_RAW differ, one format does probably store 8 bits for 8 subchannels per byte... but unknown which format is doing so?) For TYPE and PGTYPE (and CHCD numeric type 0..7): "MODE1/2048" or "MODE1" CHCD=0 800h-byte ;\Data Mode1 "MODE1/2352" or "MODE1_RAW" CHCD=1 930h-byte ;/ "MODE2/2336" or "MODE2" ;\dupe? CHCD=2 920h-byte ;\ "MODE2/2336" or "MODE2_FORM_MIX" ;/ CHCD=5 920h-byte ; "MODE2/2048" or "MODE2_FORM1" CHCD=3 800h-byte ; Data Mode2 "MODE2/2324" or "MODE2_FORM2" CHCD=4 914h-byte ; "MODE2/2352" or "MODE2_RAW" or "CDI/2352" CHCD=6 930h-byte ;/ "AUDIO" (stored as big-endian samples!!!) CHCD=7 930h-byte ;-Audio CD-DA |
000h 4 Number of tracks (N) (1..99) 004h N*18h Track entries ... .. Zeropadding to 94Ch-byte size (when less than 99 tracks) Track entries: 000h 4 Track Type (0..7, CHCD=# in above table) (eg. 6=MODE2_RAW) 004h 4 Subchannel Type (0=RW, 1=RW_RAW, 2=None) 008h 4 Sector Size (800h, 914h, 920h or 930h) 00Ch 4 Subchannel Size (0 or 60h) 010h 4 Number of Frames (aka number of sectors) 014h 4 Padding Frames (0..3) (to make Total Frames a multiple of 4) |
__________________________________ CHD Maps __________________________________ |
44bit Offset to compressed data 20bit Size of compressed data (or uncompressed data when size=hunksize) |
000h 8 Offset to compressed data (64bit big-endian) 008h 4 CRC32 on uncompressed data (32bit big-endian) 00Ch 3 Size of compressed data (24bit mixed-endian: Mid, Low, High) 00Fh 1 Flags, indicating compression info (=whut? maybe below V34 stuff?) |
V34_MAP_ENTRY_TYPE_INVALID = 0 invalid type V34_MAP_ENTRY_TYPE_COMPRESSED = 1 standard compression V34_MAP_ENTRY_TYPE_UNCOMPRESSED = 2 uncompressed data V34_MAP_ENTRY_TYPE_MINI = 3 mini: use offset as raw data V34_MAP_ENTRY_TYPE_SELF_HUNK = 4 same as another hunk in this file V34_MAP_ENTRY_TYPE_PARENT_HUNK = 5 same as a hunk in the parent file V34_MAP_ENTRY_TYPE_2ND_COMPRESSED = 6 compressed with secondary algorithm |
V5 uncompressed map format (when [filehdr+10h]=00000000h): 000h N*4 Hunk List (32bit offsets: Offset/BytesPerHunk) (usually 1,2,3..) V5 compressed map format (when [filehdr+10h]<>00000000h): 000h 4 Length of compressed map 004h 6 Offset of first block (48bit) (E4h, after meta) 00Ah 2 CRC16 on decompressed map entries 00Ch 1 bits used to encode complength 00Dh 1 bits used to encode self-refs 00Eh 1 bits used to encode parent unit refs 00Fh 1 Reserved for future use (probably zero) 010h .. Compressed Map entries (bitstream with Huffman/RLE encoding) The decompressed map entries should look as shown below (one could store them differently, eg. as 32bit little endian values; however, they must be stored exactly as shown below when computing the CRC16 on decompressed map entries): 000h 1 Compression type (0..3=Codec0..3, 4=Uncompressed, 5=Self, 6=Parent) 001h 3 Compressed length (24bit big-endian) 004h 6 Offset to compressed data (48bit big-endian) 00Ah 2 CRC16 on decompressed data (big-endian) V5 compression codecs: 0,0,0,0 = CHD_CODEC_NONE ;-unused (when using less than 4 codecs) "zlib" = CHD_CODEC_ZLIB ;\ "lzma" = CHD_CODEC_LZMA ; general codecs "huff" = CHD_CODEC_HUFFMAN ; "flac" = CHD_CODEC_FLAC ; "zstd" = CHD_CODEC_ZSTD ;/ "cdzl" = CHD_CODEC_CD_ZLIB ;\ "cdlz" = CHD_CODEC_CD_LZMA ; general codecs with CD frontend "cdfl" = CHD_CODEC_CD_FLAC ; "cdzs" = CHD_CODEC_CD_ZSTD ;/ "avhu" = CHD_CODEC_AVHUFF ;-A/V codecs |
readfile(src,NumberOfHunks*4) ;\
i=0 ; load uncomoressed
while i<NumberOfHunks ; map (needed only
ofs=bigendian32bit[src+i*4]*BytesPerHunk ; for uncompressed
byte[map+i*0Ch+00h]=04h ;typ=Uncompressed ; files, which can
bigendian24bit[map+i*0Ch+01h]=BytesPerHunk ; be created via
bigendian48bit[map+i*0Ch+04h]=ofs ; chdman commandline
bigendian16bit[map+i*0Ch+0Ah]=none ;no crc ; options)
ofs=ofs+len, i=i+1 ;/
|
readfile(hdr,10h) ;\read map hdr and
readfile(src,bigendian32bit[hdr+0]) ; compressed map
InitBitstream(src,BigEndianMsbFirst) ;/
i=0 ;\
while i<10h ;
val=GetBits(4), num=1 ;
if val=01h then ; read huffman tree
val=GetBits(4) ;
if val<>01h then num=GetBits(4)+3 ;
for j=1 to num, codesizes[i]=val, i=i+1 ;
nonlzh_explode_tree(codetree,codesizes,10h) ;/
i=0, typ=0, num=0 ;\
while i<NumberOfHunks ;
if num=0 ; load huffman coded
x=GetHuffCode(codetree) ; map type values
if x=07h then ;COMPRESSION_RLE_SMALL ;
num=GetHuffCode(codetree)+03h ;
elseif x=08h then ;COMPRESSION_RLE_LARGE ;
num=GetHuffCode(codetree)*10h ;
num=GetHuffCode(codetree)+num+13h ;
else typ=x, num=1 ;
byte[map+i*0Ch+0]=typ, i=i+1, num=num-1 ;/
i=0, s=0, p=0 ;index,self,parent ;\
o=bigendian48bit[hdr+4] ;offset ; load other
while i<NumberOfHunks ; map items
typ=byte[map+i*0Ch+00h], ofs=o, len=0, crc=0 ;
if typ<04h then len=GetBits([hdr+0Ch]), crc=GetBits(16); ;Method 0..3
elseif typ=04h then len=BytesPerHunk, crc=GetBits(16) ; ;Uncompressed
elseif typ=05h then s=GetBits([hdr+0Dh]), ofs=s ; ;New Self
elseif typ=06h then p=GetBits([hdr+0Eh]), ofs=p ; ;New Parent
elseif typ=09h then typ=05h, ofs=s ; ;Old Self
elseif typ=0Ah then typ=05h, s=s+1, ofs=s ; ;Old Self+1
elseif typ=0Bh then typ=06h, p=i*SectorsPerHunk, ofs=p ; ;Direct Parent
elseif typ=0Ch then typ=06h, ofs=p ; ;Old Parent
elseif typ=0Dh then typ=06h, p=p+SectorsPerHunk, ofs=p ; ;Old Parent+1
else goto error ;
byte[map+i*0Ch+00h]=typ ;
bigendian24bit[map+i*0Ch+01h]=len ;
bigendian48bit[map+i*0Ch+04h]=ofs ;
bigendian16bit[map+i*0Ch+0Ah]=crc ;
o=o+len, i=i+1 ;/
if bigendian16bit[hdr+0Ah]<>noncrc16(map,i*0Ch) then error ;-final crc check
|
______________________________ CHD Compression _______________________________ |
000h .. Uncompressed data |
000h .. Deflate-compressed data |
000h .. LZMA-compressed data (with lc=3, lp=0, pb=2) (without EOS end code) |
000h 1 Output format for 16bit samples ("L"=Little-endian, "B"=Big-endian)
001h .. FLAC-compressed data frame(s)
|
000h .. Huffman-compressed data (small tree, large tree, plus data) |
000h .. ECC Flags, (SectorsPerHunk+7)/8 bytes ;little-endian, bit0=1st flag ... 2/3 Size of compressed Data part (SIZ) ;big-endian, 16bit or 24bit ... SIZ Deflate compressed Data part ;uncompressed=930h*N bytes ... .. Deflate compressed Subchannel part ;uncompressed=60h*N bytes |
000h .. ECC Flags, (SectorsPerHunk+7)/8 bytes ;little-endian, bit0=1st flag ... 2/3 Size of compressed Data part (SIZ) ;big-endian, 16bit or 24bit ... SIZ LZMA compressed Data part ;uncompressed=930h*N bytes ... .. Deflate compressed Subchannel part ;uncompressed=60h*N bytes |
000h .. FLAC-compressed Data Frame(s) ;uncompressed=930h*N bytes ... .. Deflate compressed Subchannel part ;uncompressed=60h*N bytes |
_________________________ CHD Compression for CDROMs _________________________ |
Fix the 0Ch-byte Sync mark at [000h..00Bh] Fix the 114h-byte ECC data at [81Ch..92Fh] in relation to Mode at [00Fh] Fixing just means to overwrite those values (there's no XOR-filter or so). CHD doesn't filter EDC values, MM:SS:FF:Mode Sector headers, nor Subheaders. |
decompressing the subchannel part without decompressing the whole data part, and for using libraries that don't return the end of the compressed data part |
___________________________ CHD CDROM Sector Sizes ___________________________ |
000h Sector Data (800h, 914h, 920h or 930h bytes) ... Subchannel Data (0 or 60h bytes) ... Zeropadding to 990h-byte size (0..190h bytes) |
- The ECC-Filter works only for 930h-byte sectors (920h does also contain
ECC, but CHD can't filter that, resulting in very bad compression ratio)
- The last 60h-byte are supposed to be Deflate-compressed Subchannel Data
(but 800h..920h+60h sectors actually contain Zeropadding in that location)
|
__________________________ CHD Compression Methods ___________________________ |
decompress_chd_huffman_hunk:
InitBitstream(src,BigEndianMsbFirst) ;-init
codesizes[0..17h]=00h ;initially all unused ;\
codesizes[0]=GetBits(3) ;get first entry ;
i=GetBits(3)+1 ;leading unused entries ; small
@@small_tree_lop: ; tree
val=GetBits(3) ;
if val=07h then goto @@small_tree_done ;trailing unused entries ;
codesizes[i]=val, i=i+1 ;apply entry ;
if i<18h then goto @@small_tree_lop ;
@@small_tree_done: ;
nonlzh_explode_tree(codetree,codesizes,18h) ;/
data=00h ;\
@@large_tree_lop: ;
val=GetHuffCode(codetree)-1 ;using small tree codes ; large
if val>=00h then ; tree
data=val, codesizes[i]=data, i=i+1 ;
else ;
len=GetBits(3)+2 ;
if len=7+2 then len=GetBits(8)+7+2 ;
for n=1 to len, codesizes[i]=datal, i=i+1 ;
if i<100h then goto @@large_tree_lop ;
nonlzh_explode_tree(codetree,codesizes,100h) ;/
for n=1 to decompressed_size ;\data
[dst]=GetHuffCode(codetree), dst=dst+1 ;using large tree codes ;/
|
_________________________________ CHD Notes __________________________________ |
Track <---- Track1---------> <---- Track2---------> <--End--> Section Index0 IndexN TrackPad Index0 IndexN TrackPad HunkPad Real Disc Yes Yes - Yes Yes - - CHD Header - Yes Yes - Yes Yes - CHD Data - Yes Yes - Yes Yes Yes |
Index0/pregap: Metadata PREGAP:sectors isn't stored in compressed data Track padding: Metadata FRAMES:sectors is rounded up to N*4 sectors Hunk padding: The last hunk is additionally rounded up to hunksize |
XXX Unknown what kind of "data" that is (probably "normal compressed data", that happens to be 8 bytes or smaller). |
chdman hdr meta features/requirements/bugs/quirks/failures... v0.58 - - - ;-CHD didn't exist in older MAME versions v0.59 V1 - - ;\ v0.71 V2 - - ; supports harddisk CHD files only, not cdrom v0.78 V3 xxxx - ;/ v0.81 V3 CHCD bad ;-crashes after creating the CHD file header v0.90 V3 CHCD ok ;\ v0.110 V3 CHCD ok ; requires cdrdao TOC/BIN as input (CUE/BIN does crash) v0.111 V3 CHTR ok ; (warning: BIN filenames may not contain space chars!) v0.112 V3 CHTR bug ; ;\works, but compression is somewhat bugged (files v0.118 V3 CHTR bug ; ;/are BIGGER instead of SMALLER after compression) v0.120 V3 CHTR ok ; v0.130 V3 CHTR ok ; v0.131 V4 CHTR ok ;/ v0.140 V4 CHT2 ok ;\requires "unicows.dll" (=Quintessential Media Player) v0.145 V4 CHT2 ok ;/ v0.146 V5 CHT2 bad ;\says output file already exists (crashes on -f force) v0.154 V5 CHT2 bad ;/ v0.155 V5 CHT2 bad ;\crashes instantly (shortly before CreateEventW) v0.160 V5 CHT2 bad ;/ v0.161 V5 CHT2 bad ;\says output file already exists (crashes on -f force) v0.169 V5 CHT2 bad ;/ v0.170 V5 CHT2 bad ;\missing KERNEL32.DLL:AddVectoredExceptionHandler v0.217 V5 CHT2 bad ;/ v0.218 V5 CHT2 bad ;\requires "newer version of windows" (64bit) v0.247 V5 CHT2 bad ;/ v0.265 ? ? bad ;-missing KERNEL32.DLL:GetModuleHandleExW |
https://github.com/mamedev/mame/tree/master/src/lib/util |
https://github.com/mamedev/mame/blob/master/src/tools/chdman.cpp |
https://github.com/SnowflakePowered/chd-rs/tree/master/chd-rs/src |
http://www.psxdev.net/forum/viewtopic.php?f=70&t=3980 |
| CDROM Disk Images Other Formats |
800h-byte ISO's seem to be most common (for non-PSX images) 930h-byte ISO's are sometimes used for PSX-images (but lack CDDA tracks) |
Raw ISO's for PSX do often have extension .BIN instead of .ISO (that's bad because Open File Menues usually don't show .BIN files, because .BIN is usually expected to be bundled with .CUE sheet files) |
http://www.ezbsystems.com/isz/iszspec.txt |
000h 10h ID ("MEDIA DESCRIPTOR") (weirdly, same as in Alcohol .MDS)
010h 2 Unknown (02h,01h) (maybe version or so)
012h 1Ah Copyright string (A9h," 2000-2015 Disc Soft Ltd.")
02Ch 4 Unknown (FFFFFFFFh)
030h 4 Offset to Unknown Footer (322040h) (N*800h+40h)
034h 4 Unknown (0)
038h 4 Unknown (B0h)
03Ch 4 Unknown (0)
040h N*800h Sector Data
322040h 270h Unknown (Advertising IDs? CRCs? Encrypted CUE sheet? Garbage?)
|
ntracks 3 size 39:33:17 data1 00:02:00 track02 31:36:46 track03 36:03:17 ;(insert 2 blanks lines here, and insert 1 leading space in next line) trk end 39:37:17 |
header: 200h bytes header (see below) data: 990h bytes per sector (2352 Main, 96 Sub), 00:00:00->Lead Out |
000h 00 001h 00 002h First Track 003h Last Track 004h Track 1 (ADR << 4) | CTRL ;\ 005h Track 1 Start Minutes ; Track 1 006h Track 1 Start Seconds ; 007h Track 1 Start Frames ;/ ... ... ;-Probably Further Tracks (?) n+0 Last Track Start Minutes ;\ n+1 Last Track Start Seconds ; Last Track n+2 Last Track Start Frames ; n+3 Last Track (ADR << 4) | CTRL ;/ n+4 Lead-Out Track Start Minutes ;\ n+5 Lead-Out Track Start Seconds ; Lead-Out n+6 Lead-Out Track Start Frames ; n+7 Lead-Out Track (ADR << 4) | CTRL ;/ ... 00 1FFh 00 |
| CDROM Patch Files |
000h 5 PPF Header ID ("PPF10")
005h 1 Encoding Method (0=v1.0)
006h 32h Patch Description (50 chars, space-padded)
038h .. Patch entries
|
000h 5 PPF Header ID ("PPF20")
005h 1 Encoding Method (0=v1.0, 1=v2.0) (usually 1)
006h 32h Patch Description (50 chars, space-padded)
038h 4 Filesize of patched image (usually multiple of 930h)
03Ch 400h Validation data (from .BIN offset 9320h)
43Ch .. Patch entries
... (12h) ID "@BEGIN_FILE_ID.DIZ" ;\
... (LEN) ASCII text ; optional
... (10h) ID "@END_FILE_ID.DIZ" ; (as so in SLES-02080.PPF)
... (4) Size of ASCII text (LEN, 32bit) ;/
|
000h 5 PPF Header ID ("PPF30")
005h 1 Encoding Method (0=v1.0, 1=v2.0, 2=v3.0) (usually 2)
006h 32h Patch Description (50 chars, space-padded)
038h 1 Imagetype (0=BIN, 1=GI PrimoDVD)
039h 1 Validation data present (0=No, 1=Yes)
03Ah 1 Undo data present (0=No, 1=Yes)
03Bh 1 Dummy (not used) (0)
03Ch (400h) Validation data (from 9320h or 80A0h) ;-optional (when [039h]=1)
... .. Patch entries
... (12h) ID "@BEGIN_FILE_ID.DIZ" ;\
... (LEN) ASCII text (max 3072 chars) ; optional
... (10h) ID "@END_FILE_ID.DIZ" ; (as so in SLES-X2082.PPF)
... (2) Size of ASCII text (LEN, 16bit) ;/
|
000h 4 Offset (32bit, good for CDROM) 004h 1 Length 005h LEN New Data |
000h 8 Offset (64bit, probably intended for DVD) 008h 1 Length 009h LEN New Data ... (LEN) Old Data for undo ;-optional (when [03Ah]=1) |
| CDROM Internal Info on PSX CDROM Controller |
| CDROM Internal HC05 Instruction Set |
Opcode Clk HINZC Name Syntax x6 ... 2-5 --NZ- LDA MOV A,<op> ;A=op xE ... 2-5 --NZ- LDX MOV X,<op> ;X=op x7 ... 4-6 --NZ- STA MOV <op>,A ;op=A xF ... 4-6 --NZ- STX MOV <op>,X ;op=X xC ... 2-4 ----- JMP JMP <op> ;PC=op xD ... 5-7 ----- JSR CALL <op> ;[SP]=PC, PC=op xB ... 2-5 H-NZC ADD ADD A,<op> ;A=A+op x9 ... 2-5 H-NZC ADC ADC A,<op> ;A=A+op+C x0 ... 2-5 --NZC SUB SUB A,<op> ;A=A-op x2 ... 2-5 --NZC SBC SBC A,<op> ;A=A-op-C x4 ... 2-5 --NZ- AND AND A,<op> ;A=A AND op xA ... 2-5 --NZ- ORA OR A,<op> ;A=A OR op x8 ... 2-5 --NZ- EOR XOR A,<op> ;A=A XOR op x1 ... 2-5 --NZC CMP CMP A,<op> ;A-op x3 ... 2-5 --NZC CPX CMP X,<op> ;X-op x5 ... 2-5 --NZ- BIT TEST A,<op> ;A AND op A7,AF,AC = Reserved (no STA/STX/JMP with immediate operand) |
Opcode Clk ALU/LDA/LDX Clk STA/STX Clk JMP/CALL Ax nn 2 cmd r,nn - N/A -/6 call relative (BSR) Bx nn 3 cmd r,[nn] 4 mov [nn],r 2/5 cmd nn Cx nn mm 4 cmd r,[nnmm] 5 mov [nnmm],r 3/6 cmd nnmm Dx nn mm 5 cmd r,[X+nnmm] 6 mov [X+nnmm],r 4/7 cmd X+nnmm Ex nn 4 cmd r,[X+nn] 5 mov [X+nn],r 3/6 cmd X+nn Fx 3 cmd r,[X] 4 mov [X],r 2/5 cmd X |
Opcode Clk HINZC Name Syntax xC ... 3-6 --NZ- INC INC op ;increment ;op=op+1 xA ... 3-6 --NZ- DEC DEC op ;decrement ;op=op-1 xF ... 3-6 --01- CLR ?? op,00h ;clear ;op=op AND 00h x3 ... 3-6 --NZ1 COM NOT op ;complement ;op=op XOR FFh x0 ... 3-6 --NZC NEG NEG op ;negate ;op=00h-op x9 ... 3-6 --NZC ROL RCL op ;rotate left through carry x6 ... 3-6 --NZC ROR RCR op ;rotate right through carry x8 ... 3-6 --NZC LSL SHL op ;shift left logical x4 ... 3-6 --0ZC LSR SHR op ;shift right logical x7 ... 3-6 --NZC ASR SAR op ;shift right arithmetic xD ... 3-5 --NZ- TST TEST op,FFh ;test for negative or zero (AND FFh?) x1,x2,x5,xB,xE = Reserved (except for: 42 = MUL) |
Opcode Clk RMW Clk CLR Clk TST 3x nn 5 cmd [nn] 5 MOV [nn],00h 4 TEST [nn],0FFh 4x 3 cmd A 3 MOV A,00h,slow 3 TEST A,0FFh,slow 5x 3 cmd X 3 MOV X,00h,slow 3 TEST X,0FFh 6x nn 6 cmd [X+nn] 6 MOV [X+nn],00h 5 TEST [X+nn],0FFh 7x 5 cmd [X] 5 MOV [X],00h 4 TEST [X],0FFh |
Opcode Clk HINZC Name Syntax 00h+i*2 nn dd 5 ----C BRSET JNZ [nn].i,dest ;C=[nn].i, branch if set 01h+i*2 nn dd 5 ----C BRCLR JZ [nn].i,dest ;C=[nn].i, branch if clear 10h+i*2 nn 5 ----- BSET SET [nn].i ;set [nn].i 11h+i*2 nn 5 ----- BCLR RES [nn].i ;clear [nn].i |
Opcode Clk HINZC Name Syntax 20 nn 3 ----- BRA JR nn ;branch always 21 nn 3 ----- BRN NUL nn ;branch never 22 nn 3 ----- BHI JA nn ;if C=0 and Z=0, higher ? 23 nn 3 ----- BLS JBE nn ;if C=1 or Z=1, lower or same ? 24 nn 3 ----- BCC/BHS JNC/JAE nn ;if C=0, carry clear, higher.same 25 nn 3 ----- BCS/BLO JC/JB nn ;if C=1, carry set, lower 26 nn 3 ----- BNE JNZ/JNE nn ;if Z=0, not equal / not zero 27 nn 3 ----- BEQ JZ/JE nn ;if Z=1, equal / zero 28 nn 3 ----- BHCC JNH nn ;if H=0, half-carry clear 29 nn 3 ----- BHCS JH nn ;if H=1, half-carry set 2A nn 3 ----- BPL JNS nn ;if S=0, plus / not signed 2B nn 3 ----- BMI JS nn ;if S=1, minus / signed 2C nn 3 ----- BMC JEI nn ;if I=0, interrupt mask clear 2D nn 3 ----- BMS JDI nn ;if I=1, interrupt mask set 2E nn 3 ----- BIL JIL nn ;if XX=LO, interrupt line low 2F nn 3 ----- BIH JIH nn ;if XX=HI, interrupt line high AD nn 6 ----- BSR CALL relative nn ;branch to subroutine always |
Opcode Clk HINZC Name Syntax 9D 2 ----- NOP NOP ;no operation 97 2 ----- TAX MOV X,A ;transfer A to X 9F 2 ----- TXA MOV A,X ;transfer X to A 9C 2 ----- RSP MOV SP,00FFh ;reset stack pointer (SP=00FFh) 42 11 0---0 MUL MUL X,A ;X:A=X*A (unsigned multiply) 81 6 ----- RTS RET ;return from subroutine 80 9 xxxxx RTI RETI ;return from interrupt 99 2 ----1 SEC STC ;set carry flag 98 2 ----0 CLC CLC ;clear carry flag 9B 2 -1--- SEI DI ;set interrupt mask (disable ints) 9A 2 -0--- CLI EI ;clear interrupt mask (enable ints) 8E ..2 -0--- STOP STOP ;? 8F ..2 -0--- WAIT WAIT ;? 83 10 -1--- SWI SWI ;software interrupt ...? PC=[FFFCh] <IRQ> ? ????? Interrupt ;? PC=[FFFxh] <RESET> ? ????? Reset ;? PC=[FFFEh] 82,84..8D,90..96,9E = Reserved |
A 8bit accumulator X 8bit index register SP 6bit stack pointer (range 00C0h..00FFh) PC 16bit program pointer (range 0000h..FFFFh) CCR 5bit condition code register (flags) (111HINZC) |
SP.highest PC.lo
PC.hi
X
A
SP.lowest Flags (CCR, 5bit condition code register) (111HINZC)
|
nn immediate ;00h..FFh [nn] direct address ;[0000h..00FFh] [nnmm] extended address ;[0000h..FFFFh] [X] indexed, no offset ;[0000h..00FFh] [X+nn] indexed, 8bit offset ;[0000h..01FEh] [X+nnmm] indexed, 16bit offset ;[0000h..FFFFh] [nn].i bit ;[0000h..00FFh].bit0..7 dd relative ;$+2..3+(-80h..+7Fh) |
operand "X+nn" performs an unsigned addition, and can address 0000h..01FEh. 16bit operands (nnmm) are encoded in BIG-ENDIAN format (same for pushed PC). |
Vector Prio Usage FFF0h 7=lo TBI Vector (Timebase) FFF2h 6 SSPI Vector (SPI bus) (SPI1 and SPI2) FFF4h 5 Timer 2 Interrupt Vector (Timer 2 Input/Compare) FFF6h 4 Timer 1 Interrupt Vector (Timer 1 Input/Compare/Overflow) FFF8h 3 KWI Vector (Key Wakeup) (KWI0..7 pins) FFFAh 2 External Interrupt Vector (/IRQ1 and /IRQ2 pins) FFFCh none Software Interrupt Vector (SWI opcode) ;\regardless of FFFEh 1=hi Reset Vector (/RESET signal and COP) ;/CPU's "I" |
.hc05 select HC05 instruction set (default would be .mips) .nocash select nocash syntax (default would be .native opcode names) db ... define 8bit byte(s), or quoted ascii strings dw ... define 16bit word(s) in BIG ENDIAN (for HC05 exception vectors) org nnnn change origin for following opcodes end end of file mov c,[nn].i alias for "jnz [nn].i,$+3" (dummy jump & set carry=[nn].i) |
| CDROM Internal HC05 On-Chip I/O Ports |
0 OPTM Option Map Select (bank-switching for Port 00h..0Fh) 1 FOSCE Fast (Main) Oscillator Enable (0=Disable OSC, 1=Normal) 2-3 SYS System Clock Select (0=OSC/2, 1=OSC/4, 2=OSC/64, 3=XOSC/2) 4-5 - Not used (0) 6 STUP XOSC Time Up Flag (R) 7 FTUP OSC Time Up Flag (R) (0=Busy, 1=Ready/Good/Stable) |
PA.0-7 PAn Port A Bit0..7 Input/Output (0=Low, 1=High) (R/W) PB.0-7 PBn Port B Bit0..7 Input /KWI0..7 (0=Low, 1=High) (R) PC.0 PC0 Port C Bit0 Input/Output /SDI1 (SPI)(0=Low, 1=High) (R/W) PC.1 PC1 Port C Bit1 Input/Output /SDO1 (SPI)(0=Low, 1=High) (R/W) PC.2 PC2 Port C Bit2 Input/Output /SCK1 (SPI)(0=Low, 1=High) (R/W) PC.3 PC3 Port C Bit3 Input/Output /TCAP (T1) (0=Low, 1=High) (R/W) PC.4 PC4 Port C Bit4 Input/Output /EVI (T2) (0=Low, 1=High) (R/W) PC.5 PC5 Port C Bit5 Input/Output /EVO (T2) (0=Low, 1=High) (R/W) PC.6 PC6 Port C Bit6 Input/Output /IRQ2 (0=Low, 1=High) (R/W) PC.7 PC7 Port C Bit7 Input/Output /IRQ1 (0=Low, 1=High) (R/W) PD.0-7 PDn Port D Bit0..7 Input/Output (0=Low, 1=High) (R/W) PE.0-7 PEn Port E Bit0..7 Input/Output (0=Low, 1=High) (R/W) PF.0-7 PFn Port F Bit0..7 Input/Undoc A/D-input (0=Low, 1=High) (R)(R/W) |
DDRX.0-7 DDRXn Port X Data Direction Bit0..7 (0=Input, 1=Output) (R/W) |
RCR1.0 RAL Port A.Bit0-3 Pullup Resistors (0=Off, 1=On) RCR1.1 RAH Port A.Bit4-7 Pullup Resistors (0=Off, 1=On) RCR1.2 RBL Port B.Bit0-3 Pullup Resistors (0=Off, 1=On) RCR1.3 RBH Port B.Bit4-7 Pullup Resistors (0=Off, 1=On) RCR1.4 RGL Port G.Bit0-3 Pullup Resistors (0=Off, 1=On) ;\ RCR1.5 RGH Port G.Bit4-7 Pullup Resistors (0=Off, 1=On) ; on chips RCR1.6 RHL Port H.Bit0-3 Pullup Resistors (0=Off, 1=On) ; with Port G,H RCR1.7 RHH Port H.Bit4-7 Pullup Resistors (0=Off, 1=On) ;/ RCR2.0-7 RCn Port C.Bit0-7 Pullup Resistors (0=Off, 1=On) |
WOM1.0 AWOML Port A.Bit0-3 Open Drain Mode when DDR=1 (0=No, 1=Open Drain) WOM1.1 AWOMH Port A.Bit4-5 Open Drain Mode when DDR=1 (0=No, 1=Open Drain) WOM1.2 GWOML Port G.Bit0-3 Open Drain Mode when DDR=1 (0=No, 1=Open Drain) WOM1.3 GWOMH Port G.Bit4-5 Open Drain Mode when DDR=1 (0=No, 1=Open Drain) WOM1.4 HWOML Port H.Bit0-3 Open Drain Mode when DDR=1 (0=No, 1=Open Drain) WOM1.5 HWOMH Port H.Bit4-5 Open Drain Mode when DDR=1 (0=No, 1=Open Drain) WOM1.6-7 - Not used (0) WOM2.0-5 CWOMn Port C.Bit0..5 Open Drain Mode when DDR=1 (0=No, 1=Open Drain) WOM2.6-7 - Not used (always both bits set) |
0-1 - Not used (0) 2 IRQ2S IRQ2 Select Edge-Sensitive Only (0=LowLevelAndNegEdge, 1=NegEdge) 3 IRQ1S IRQ1 Select Edge-Sensitive Only (0=LowLevelAndNegEdge, 1=NegEdge) 4 KWIE Key Wakeup Interrupt Enable (0=Disable, 1=Enable) 5 - Not used (0) 6 IRQ2E IRQ2 Interrupt Enable (0=Disable, 1=Enable) 7 IRQ1E IRQ1 Interrupt Enable (0=Disable, 1=Enable) |
0 RKWIF Reset Key Wakeup Interrupt Flag (0=No Change, 1=Reset) (W) 1 - Not used (0) 2 RIRQ2 Reset IRQ2 Interrupt Flag (0=No Change, 1=Reset) (W) 3 RIRQ1 Reset IRQ1 Interrupt Flag (0=No Change, 1=Reset) (W) 4 KWIF Key Wakeup Interrupt Flag (PB/KWI) (0=No, 1=IRQ) (R) 5 - Not used (0) 6 IRQ2F IRQ2 Interrupt Flag (PC6) (0=No, 1=IRQ) (R) 7 IRQ1F IRQ1 Interrupt Flag (PC7) (0=No, 1=IRQ) (R) |
0-7 KWIEn Port B.Bit0..7 Key Wakeup Interrupt Enable (0=Disable, 1=Enable) |
0 SPRn SPI Clock Rate (0=ProcessorClock/2, 1=ProcessorClock/16) 1-3 - Not used (0) 4 MSTRn SPI Master Mode Select (0=Slave/SCK.In, 1=Master/SCK.Out) 5 DORDn SPI Data Transmission Order (0=MSB First, 1=LSB First) 6 SPEn SPI Enable (SPI1:PortC, SPI2:PortG) (0=Disable, 1=Enable) 7 SPIEn SPI Interrupt Enable (... ack HOW?) (0=Disable, 1=Enable) |
0-5 - Not used (0) 6 DCOLn SPI Data Collision Occurred (0=No, 1=Collision) 7 SPIFn SPI Transfer Complete Flag (0=Busy, 1=Complete) (R) |
0-7 BITn Data to be sent / being received |
0-1 T2R Timer2 Prescaler (0=SysClk, 1=SysClk/4, 2=SysClk/32, 3=SysClk/256) 2-3 T3R PWM Prescaler (0=CLK3, 1=CLK3/2, 2=CLK3/8, 3=Timer2compare) 4-6 - Not used (0) 7 TBCLK Time Base Clock (0=XOSC, 1=OSC/128) ;<-- write-able only ONCE |
0 COPC COP Clear 2bit COP timeout divider (0=No Change, 1=Clear) (W) 1 COPE COP Enable ;<-- write-able only ONCE 2 - Not used (0) 3 RTBIF Reset Time Base Interrupt Flag (0=No Change, 1=Clear TBIF) (W) 4-5 TBR Time Base Interrupt Rate (0=TBCLK/128, 1=/4096, 2=/8192, 3=/16384) 6 TBIE Time Base Interrupt Enable (0=Disable, 1=Enable) 7 TBIF Time Base Interrupt Flag (0=No, 1=IRQ) (R) |
0-4 - Not used (0) 5 XOSCR XOSC Feedback Resistor (0=None, 1=Implemented) 6 OSCR OSC Feedback Resistor (0=None, 1=Implemented) 7 RSTR /RESET Pullup Resistor (0=None, 1=Implemented) |
0 OLVL Output Level on TCMP pin on Compare Match? (0=Low, 1=High) 1 IEDG Input Edge on TCAP pin (0=NegativeEdge, 1=PositiveEdge) 2-4 - Not used (0) 5 TOIE Timer Overflow Interrupt Enable (0=Disable, 1=Enable) 6 OC1IE Output Compare Interrupt Enable (0=Disable, 1=Enable) 7 ICIE Input Capture Interrupt Enable (0=Disable, 1=Enable) |
0-4 - Not used (0) 5 TOF Timer Overflow Flag (0=No, 1=Yes) (R) ;clear by Port 19h access 6 OC1F Output Compare Flag (0=No, 1=Yes) (R) ;clear by Port 17h access 7 ICF Input Capture Flag (0=No, 1=Yes) (R) ;clear by Port 15h access |
0-15 Capture Value |
0-15 Compare Value |
0-15 Counter |
0-15 Alternate Counter (uh, what?) |
0 OL2 Timer Output 2 Edge (0=Falling, 1=Rising) 1 OE2 Timer Output 2 Enable (EVO) (0=Disable, 1=Enable) 2 IL2 Timer Input 2 Edge/Level (0=Low/Falling, 1=High/Rising) 3 IM2 Timer Input 2 Mode Select for EVI (0=EventMode, 1=GatedByCLK2) 4 T2CLK Timer 2 Clock Select (0=CLK2 from Prescaler, 1=EXCLK from EVI) 5 - Not used (0) 6 OC2IE Output Compare 2 Interrupt Enable (0=Disable, 1=Enable) 7 TI2IE Timer Input 2 Interrupt Enable (EVI) (0=Disable, 1=Enable) |
0-1 - Not used (0) 2 ROC2F Reset Output Compare 2 Interrupt Flag (0=No Change, 1=Clear) (W) 3 RTI2F Reset Timer Input 2 Interrupt Flag (0=No Change, 1=Clear) (W) 4-5 - Not used (0) 6 OC2F Output Compare 2 Interrupt Flag (0=No, 1=Yes) (R) 7 TI2F Timer Input 2 Interrupt Flag (EVI) (0=No, 1=Yes) (R) |
0-7 Compare Value ("Transferred to buffer on certain events?")
|
0-7 Counter Value, incremented at T2R (set to 01h on Compare Matches) |
I/O bank 0: 0:06h..07h, 0:0Dh..0Fh I/O bank 1: 1:01h, 1:06h..07h, 1:0Ch..0Dh, and upper 4bit of 1:05h Unbanked I/O: 20h..3Dh Unused Memory: 0240h..0FFFh, 5000h..FDFFh |
[nn],[mmnn],[nn+x],[mmnn+x] --> returns LAST byte of current opcode (=nn) [x] --> returns FIRST byte of following opcode |
| CDROM Internal HC05 On-Chip I/O Ports - Extras |
PG.0 PG0 Port G Bit0 Input/Output /SDI2 (0=Low, 1=High) (R/W) PG.1 PG1 Port G Bit1 Input/Output /SDO2 (0=Low, 1=High) (R/W) PG.2 PG2 Port G Bit2 Input/Output /SCK2 (0=Low, 1=High) (R/W) PG.3 PG3 Port G Bit3 Input/Output /TCMP (0=Low, 1=High) (R/W) PG.4 PG4 Port G Bit4 Input/Output /PWM0 (0=Low, 1=High) (R/W) PG.5 PG5 Port G Bit5 Input/Output /PWM1 (0=Low, 1=High) (R/W) PG.6 PG6 Port G Bit6 Input/Output /PWM2 (0=Low, 1=High) (R/W) PG.7 PG7 Port G Bit7 Input/Output /PWM3 (0=Low, 1=High) (R/W) PH.0-7 PHn Port H Bit0..7 Input/Output (0=Low, 1=High) (R/W) PJ.0-3 PJn Port J Bit0..3 Output (0=Low, 1=High) (R/W) PJ.4-7 - Not used (0) |
0-7 DDRXn Port X Data Direction Bit0..7 (0=Input, 1=Output) (R/W) |
0 - Not used (0) 1 PDH Select Port D (H) (0=FP35-FP38 pins, 1=PD7-PD4 pins) 2 PEL Select Port E (L) (0=FP31-FP34 pins, 1=PE3-PE0 pins) 3 PEH Select Port E (H) (0=FP27-FP30 pins, 1=PE7-PE4 pins) 4 - Not used (0) 5-6 DUTY LCD Duty Select (...) 7 LCDE LCD Output Enable BP and FP pins (0=Disable, 1=Enable) |
0-3 First Data Unit ;\Fourty 4bit LCD values (in the twenty registers) 4-7 Second Data Unit ;/(some duties use only the LSBs of that 4bit values) |
0-3 CH0-3 PWM Channel 0..3 on Port G.Bit4-7 Enable (0=Disable, 1=Enable) 4-7 - Not used (0) |
0-7 PWM Counter, incremented at PHI2 (range 01h..FFh) |
0-7 Duty (N cycles High, 255-N cycles Low) |
0-3 A/D Conversion result (probably unsigned, 00h=Lowest, FFh=Max voltage?) |
0-3 CH0-3 A/D Channel (0..7=PortF.Bit0-7, 8..0Fh=Reserved/Vref/FactorTest) 4 - Not used (0) 5 ADON A/D Charge Pump enable (0=Disable, 1=Enable) 6 ADRC A/D RC Oscillator On (0=Normal/Use CPU Clock, 1=Use RC Clock) 7 COCO A/D Conversion Complete (0=Busy, 1=Complete) (R) |
0 PGM EPROM Program Command (0=Normal, 1=Apply Programming Power) 1 ELAT EPROM Latch Control (0=Normal/Read, 1=Latch/Write) 2-7 RES Reserved for Factory Testing (always 0 in user mode) |
| CDROM Internal HC05 I/O Port Usage in PSX |
porta.0-7 i/o CXD1815Q.Data (indexed via Port E) porta.0 in debug.dta.serial.in ;\normally unused (exists in early bios) porta.1 out debug.dta.serial.out ; (prototype/debug_status stuff) porta.2 out debug.clk.serial.out ;/(with portc.5 = debug.select) |
portb.0 in F-BIAS ;unused portb.1 in SCEx input (serial 250 baud, received via 1000Hz timer2 irq) portb.2 in LMTSW aka /POS0 ;\pos0 and door switches portb.3 in DOOR aka SHELL_OPEN ;/ portb.4 in TEST2 portb.5 in TEST1 (CL316) enter test mode (instead of mainloop) portb.6 in COUT ;<-- unused, extra pin, not "SENSE=COUT" portb.7 in CXD2510Q.SENSE ;-from CXD2510Q (and forwarded from CXA1782BR) |
portc.0 in CXD2510Q.SUBQ ;\ portc.1 in? NC (SPI.OUT) ; used via SPDR1 to receive SPI bus SUBQ data portc.2 out CXD2510Q.SQCK ;/ portc.3 out SPEED portc.4 out ="SPEED XOR 1" ... AL/TE ... or CG ... or MIRR ? portc.5 out ROMSEL: debug.select (or "SCLK" on later boards???) portc.6 in CXD1815Q.XINT/IRQ2 ;unused (instead INTSTS bits are polled) portc.7 in CXD2510Q.SCOR/IRQ1 ;used via polling INTSR.7 (not as irq) |
portd.0 out NC ;-unused (always 1) portd.1 out CXD2510Q.DATA ;\serial bus for CXD2510Q portd.2 out CXD2510Q.XLAT ; (and also forwarded to CXA1782BR) portd.3 out CXD2510Q.CLOK ;/ portd.4 out CXD1815Q.DECCS ;\ portd.5 out CXD1815Q.DECWR ; control for data/index on Port A/E portd.6 out CXD1815Q.DECRD ;/ portd.7 out LDON ... IC723.Pin11 ... maybe "laser on" ? |
porte.0-4 out CXD1815Q.Index (for data on Port A) porte.5 out NC, not used porte.6 out NC, see "idx_4xh" maybe test signal ??? porte.7 out? NC, TEST? configured as OUTPUT... but used as INPUT? |
portf.0 out NC, TX ;\ portf.1 in NC, RX ; not used by sony's cdrom bios portf.2 out NC, RTS ; (but used by motorola's bootstrap rom) portf.3 out NC, DTR ;/ portf.0 in Serial Data In (from daughterboard) ;\ portf.1 out Serial Data Out (to daughterboard) ; usage in SCPH-5903 portf.2 out Serial Clock Out (to daughterboard) ; (PSX with Video CD) portf.3 out Audio/Video Select (0=Normal, 1=VCD) ;/ portf.4-7 - NC, not used (probably pins don't even exist) |
SPI 1 - used for receiving SUBQ (via Port C) IRQ 1 - used for latching/polling SUBQ's "SCOR" (not used as interrupt) IRQ 2 - connects to CXD1815Q.XINT, but isn't actually used at all Timer 1 - unused Timer 2 - generates 1000Hz interrupts (for 250 baud "SCEx" string transfers) DDRx - data directions for Port A-F (as listed above) |
| CDROM Internal HC05 Motorola Selftest Mode |
| CDROM Internal HC05 Motorola Selftest Mode (52pin chips) |
Pin30 PortC.6 (/IRQ2) (/XINT) ----> wire to 3.5V (VCC) Pin31 PortC.7 (/IRQ1) (SCOR) ----> wire to 7V (2xVCC) |
Pin16 PortB.0 ----> ModeSelectBit0 (0=GND, 1=3.5V) Pin17 PortB.1 ----> ModeSelectBit1 (0=GND, 1=3.5V) |
Mode0: Jump to RAM Address 0040h (useless when RAM is empty) Mode1: Semifunctional Selftest (useless) Mode2: Upload 200h bytes to RAM & jump to 0040h (allows fast/custom dumping) Mode3: Download ROM as ASCII hexdump (nice, but very slow) |
Pin50 PortF.0 ----> TX output (11bytes: 0Dh,0Ah," AAAA DD ") Pin51 PortF.1 <---- RX input (1byte: "!" to request next 11 bytes) Pin52 PortF.2 ----> RTS output or so (not needed) Pin1 PortF.3 ----> DTR output or so (not needed) Ground ------------ GND for RX/TX |
http://www.psxdev.net/forum/viewtopic.php?f=70&t=557 |
.------------ pin31, PC7, SCOR, cut the connection
39 | 27 to Signal Processor,
.-----------------. then wire Pin31 to 7.5V
40 | | 26
| C nnnn |
| SC4309nnPB |
| G63C 185 |
pin50, TX <--- | | ---- pin17, PB1, SCEX, wire to 3.5V,
pin51, RX ---> | | for Mode2 Selection
52 | O | 14
'-----------------'
1 13
|
CN602.Pin1 = 7.5V ;\on PSX boards (with either 5pin or CN602.Pin3 = 3.5V ;/ 7pin CN602 connectors) IC601.Pin1 = 7.5V ;-on PSone boards (3pin 78M05 voltage regulator) IC102.Pin32 = 3.5V ;-on PSone boards (32pin Main BIOS ROM chip) |
CXD2510Q.Pin63 (eg. on PU-8 boards) ;\ CXD2545Q.Pin74 (eg. on PU-18 boards) ; either one of these, depending CXD1817R.Pin49 (eg. on PU-20 boards) ; on which chipset you have CXD2938Q.Pin77 (eg. on PM-41 boards) ; CXD2941R.Pin85 (eg. PM-41(2) boards) ;/ |
4-digit ASCII HEX address --> change address, and return 0Dh,0Ah," AAAA DD " chr(00h) --> increment address, and return 0Dh,0Ah," AAAA DD " chr(07h) --> jump to current address (not so useful) other characters --> same as chr(00h) All digits/characters sent to RX input will produce an echo on TX output. |
| CDROM Internal HC05 Motorola Selftest Mode (80pin chips) |
Pin PortC 46 PC7/IRQ1 (SCOR) disconnect from PCB, then wire the pin to Vtst (7.6V) 45 PC6/IRQ2 (/XINT) wire to Vdd (3.5V) (you have to solder to the pin) |
Pin PortA DDRA Usage 23 PA0 in RXD 24 PA1 out TXD 25 PA2 in - 26 PA3 in Testmode.bit0 (GND=0, 3.5V=1) 27 PA4 in Testmode.bit1 (GND=0, 3.5V=1) 28 PA5 in Testmode.bit2 (GND=0, 3.5V=1) 29 PA6 out RTS (don't care) 30 PA7 out - |
PA5 PA4 PA3 Effect 0 x x Jump to 0040h ;\ 1 0 0 Test (complex) ; not so useful 1 0 1 Test (simple loop) ;/ 1 1 0 ROM Dump 4200h bytes (plain binary, non-ASCII) 1 1 1 RAM Upload 100h bytes to 0040h..013Fh, then jump to 0040h |
.------------ pin46, PC7/IRQ1, SCOR, cut & wire to 7.5V
|.----------- pin45, PC6/IRQ2, wire to 3.5V
60 || 41
.-----------------.
61 | o | 40
| Sony Computer | ,----- pin28, PA5, wire to 3.5V
| Entertainment | _________/ ,--- pin27, PA4, wire to 3.5V
| Inc. (C) E35D | ==========='---- pin26, PA3, mode select
| 4246xx 185 | ----> pin24, PA1, TXD (for ROM dump)
| | <---- pin23, PA0, RXD (for RAM upload)
80 | O | 21
'-----------------'
1 20
|
CN602.Pin1 = 7.5V ;\on PSX boards (with 7pin CN602 connectors) CN602.Pin3 = 3.5V ;/ |
| CDROM Internal CXD1815Q Sub-CPU Configuration Registers |
0-1 "L" Reserved (should be 0) 2 LSB 1st CD DSP DATA order (0=MSB first, 1=LSB first) 3-4 BCK MD CD DSP Number of BCLKs per WCLK (0=16, 1=24, 2=32, 3=Reserved) 5 BCK RED Strobe DATA on BLCK Edge (0=Falling Edge, 1=Rising Edge) 6 LCH LOW Channel on LRCK=Low (0=Right, 1=Left) 7 C2PL1st ... C2PO lower byte 1st |
0 HCLKDIS HCLK Pin Output (0=8.4672MHz, 1=Disable; Fixed Low) 1 CLKDIS CLK Pin Output (0=16.9344MHz, 1=Disable; Fixed Low) 2 9BITRAM SRAM Databus width (0=8bit/normal, 1=9bit) 3-4 RAM SZ SRMA Address bus (0=32K, 1=64K, 2=128K, 3=Reserved) 5 PRTYCTL ... Priority Control 6 XSLOW Number of clock cycles per DMA cycle (0=12, 1=4) (for SRAM) 7 "L" Reserved (should be 0) |
0 "L" Reserved (should be 0) 1 DACODIS .... DAC Out Disable 2 DAMIXEN Digital Audio Mixer Enable (0=Attentuator/Mixer for CD-DA, 1=No) 3 SMBF2 Number of Sound Map Buffer Surfaces (0=Three, 1=Two) 4 SPMCTL Sound Parameter Majority Control (0=?) ;\for ADPCM params 5 SPECTL Sound Parameter Error Control (0=?) ;/ 6-7 "L" Reserved (should be 0) |
0-2 DECMD Decoder Mode (0-7)
0 or 1 Decoder Disable ;-disable sector reading
2 or 3 Monitor-only Mode ;\no error correction
4 Write-only Mode ;/
5 Real-time Correction Mode ;\with error correction
6 Repeat Correction Mode ;/
7 CD-DA Mode ;-audio
3 AUTODIST Auto Distinction (0=Use MODESEL/FORMSEL bits, 1=Use Sector Hdr)
(Error Correction is done according to above MODE/FORM values)
4 FORMSEL Form Select (0=FORM1, 1=FORM2) (must be 0 for MODE1)
5 MODESEL Mode Select (0=MODE1, 1=MODE2)
6 ECCSTR ECC Strategy (0=Normal, 1=Use Error Flags; requires 9bit SRAM)
7 ENDLADR Enable Drive Last Address ...
|
0 "L" Reserved (should be 0) 1 DBLSPD Double Speed Mode (0=Normal, 1=Double) (init CD DSP first) 2 RPSTART Repeat Correction Start (0=No, 1=Start) (automatically cleared) 3 SWOPEN Sync Window Open (0=SyncControlledByIC, 1=OpenDetectionWindow) 4 CD-DA CD-DA Play (0=No, 1=Playback CD-DA as audio) 5 CDDAMUTE CD-DA Mute (0=Normal, 1=Mute CD-DA Audio) 6 RTMUTE Real-time Mute (0=Normal, 1=Mute CDROM ADPCM) 7 SMMUTE Sound Map Mute (0=Normal, 1=Mute Sound Map ADPCM) |
| CDROM Internal CXD1815Q Sub-CPU Sector Status Registers |
0 CFORM FORM assumed by Error Correction (0=FORM1, 1=FORM2) 1 CMODE MODE assumed by Error Correction (0=MODE1, 1=MODE2) 2 ECCOK ECC Okay (0=Bad, 1=Okay) 3 EDCOK EDC Okay (0=Bad, 1=Okay) 4 CORDONE Correction Done (0=None, 1=Error occurred and was corrected) 5 CORINH Correction Inhibit (0=Okay,1=AUTODIST couldn't determine MODE/FORM) 6 ERINBLK Erasure in Block (0=Okay, 1=At least 1 byte is wrong & uncorrected) 7 EDCALL0 EDC all-zero (0=No/EDC Exists, 1=Yes/All four EDC bytes are 00h) |
0 NOSYNC No Sync (0=Okay, 1=Sector Sync Mark Missing) 1 SHRTSCT Short Sector (0=Okay, 1=Sector Sync Mark within Sector Data) 2-4 - Reserved (undefined) 5 RTADPBSY Real-time ADPCM Busy (0=No, 1=Busy/playback) 6-7 - Reserved (undefined) |
0 CI Error in 4th Subheader byte (Coding Info) (0=Okay, 1=Error) 1 SUBMODE Error in 3rd Subheader byte (Submode) (0=Okay, 1=Error) 2 CHANNEL Error in 2nd Subheader byte (Channel) (0=Okay, 1=Error) 3 FILE Error in 1st Subheader byte (File) (0=Okay, 1=Error) 4 MODE Error in 4th Header byte (MODE) (0=Okay, 1=Error) 5 BLOCK Error in 3rd Header byte (FF) (0=Okay, 1=Error) 6 SEC Error in 2nd Header byte (SS) (0=Okay, 1=Error) 7 MIN Error in 1st Header byte (MM) (0=Okay, 1=Error) |
1st read: 1st Header byte (MM) 2nd read: 2nd Header byte (SS) 3rd read: 3rd Header byte (FF) 4th read: 4th Header byte (MODE) |
1st read: 1st Subheader byte (File) 2nd read: 2nd Subheader byte (Channel) 3rd read: 3rd Subheader byte (Submode) (SM) 4th read: 4th Subheader byte (Coding Info) (CI) |
(1) The corrected value in the real-time correction or
repeat correction mode
(2) Value of the raw data from the drive in the monitor-only
or write-only mode
The CMOME? and CMODE bits (bits 1, 0) of ECCSTS indicate the FORM and MODE
of the sector the decoder has discriminated by the raw data from the drive.
Due to erroneous correction, the values of these bits may be at variance
with those of the HDR register MODE byte and SHDR register submode byte
bit5.
|
| CDROM Internal CXD1815Q Sub-CPU Address Registers |
0-6 CMADR Address bit10-16 (in 1Kbyte steps) 7 - Reserved (undefined) |
HADR = (CMADR AND 7Fh)*400h+offset HXFR = length OR 4000h |
ADPMNT = (CMADR AND 7Fh) OR 80h |
0-6 ADPxxx ADPCM source Address bit10-16 (in 1Kbyte-steps) 7 RTADPEN Real-time ADPCM Enable (0=Disable, 1=Enable Real-time ADPCM) |
0-16 DLADR Addr. bit0-16 ... 17-23 "L" Reserved (should be 0) |
0-16 DADRC Incrementing Drive-to-Buffer Write Address, bit0-16 17-23 "L" Reserved (should be 0) |
0-15 DADRC Address bit0-15 ;bit16 is in Port 0Bh ... |
0-11 HXFR number of data bytes, bit0-11 (0..FFFh) ...
12 HADR.16 HADR bit16
13 "L" Reserved (should be 0)
14 "L" ?? Reserved (should be 0) ;<-- XXX but on PSX: Always 1 !?!
; seems to Disable INT8 ?!!!
15 DISHXFRC Disable HXFRC (0=Use HXFRC, 1=Disable, Infinite-or-Zero Len?)
|
0-15 HADR Addr. bit0-15 ;bit16 in Port 0Dh ... |
0-11 HXFRC Host Transfer Counter bit0-11 (number of remaining bytes) 12 HADRC bit16 ;MSB of Port 0Ch/0Dh 13 DADRC bit16 ;MSB of Port 0Eh/0Fh 14-15 - Reserved (undefined) (usually both bits set) |
0-15 HADRC Address bit0-15 ;bit16 is in Port 0Bh |
900h is loaded into HXFRC and 600Ch, 6A0Ch, or 740Ch is loaded into HADRC (at least, supposedly, above addresses , for cases when using 32K SRAM) |
HADR and HXFR are loaded into HADRC and HXFRC |
0000h 1st Sector (at 0000h..0923h) (unused gap at 0924h..0BFFh) 0C00h 2nd Sector (at 0C00h..1523h) (unused gap at 1524h..17FFh) 1800h 3rd Sector (at 1800h..2123h) (unused gap at 2124h..23FFh) 2400h 4th Sector (at 2400h..2D23h) (unused gap at 2D24h..2FFFh) 3000h 5th Sector (at 3000h..3923h) (unused gap at 3924h..3BFFh) 3C00h 6th Sector (at 3C00h..4523h) (unused gap at 4524h..47FFh) 4800h 7th Sector (at 4800h..5123h) (unused gap at 5124h..53FFh) 5400h 8th Sector (at 5400h..5D23h) (unused gap at 5D24h..5FFFh) 6000h Soundmap ADPCM Buffer (at 600Ch..690Bh) (gaps at 6000h and 690Ch) 6A00h Soundmap ADPCM Buffer (at 6A0Ch..730Bh) (gaps at 6A00h and 730Ch) 7400h Soundmap ADPCM Buffer (at 740Ch..7D0Bh) (gaps at 7400h and 7D0Ch) 7E00h Unknown/Unused |
| CDROM Internal CXD1815Q Sub-CPU Misc Registers |
0-2 HINT Request Host Interrupt (INT1..INT7, or 0=None/No change) 3-7 "L" Reserved (should be 0) |
0-2 HINTSTS Pending Host Interrupt (INT1..INT7, or 0=None/All acknowledged) 3 DMABUSY DMA Busy (0=Data FIFO Empty and HXFRC=0, 1=Data Transfer Busy) 4 PRMRRDY Parameter Read Ready (0=Parameter FIFO Empty, 1=Ready/Not Empty) 5 RSLEMPT Result Empty (0=Response FIFO Not Empty, 1=Empty) 6 RSLWRDY Result Write Ready (0=Response FIFO Full, 1=Ready/Not Full) 7 BUSYSTS Command Busy Status (0=Command Not Empty, 1=Ack'ed by CLRBUSY) |
0 RESYNC Sync with CD DSP (0=No change, 1=Resync, eg. after speed change) 1-3 "L" Reserved (should be 0) 4 RTADPCLR Abort Real-time ADPCM (0=No Change, 1=Abort; when ADPMNT.7=0) 5 CLRRSLT Clear Reply FIFO (0=No change, 1=Acknowledge; clear FIFO) 6 CLRBUSY Acknowledge Command (0=No change, 1=Acknowledge; clear BUSYSTS) 7 CHPRST Chip Reset (0=No change, 1=Do Chip Initialization) |
0 HCRISD Host Chip Reset Issued 1 HSTCMND Host Command ... 2 DECINT Decoder Interrupt .. 3 HDMACMP Host DMA Complete . <-- PSX: used for retry ?!?!!! 4 RTADPEND Real-time ADPCM end 5 RSLTEMPT Result Empty 6 DECTOUT Decoder Time Out 7 DRVOVRN Drive Overrun |
0-7 Param FIFO (check HIFSTS.4 to see if the FIFO is empty) |
0-7 Command (check INTSTS.1 or HIFSTS.7 to see if a command was sent) |
0-7 Data (has 8-byte FIFO) |
0 S/M ADPCM Stereo/Mono (0=Mono, 1=Stereo) 1 - Reserved (undefined) 2 FS ADPCM Sampling Frequency (0=37.8kHz, 1=18.9kHz) 3 - Reserved (undefined) 4 BITLNGTH ADPCM Sample Bit Length (0=Normal/4bit, 1=8bit) 5 ADPBUSY ADPCM Decoding (0=No, 1=Yes/Busy) 6 EMPHASIS ADPCM Emphasis (0=Normal/Off, 1=On) 7 MUTE DA Data is Muted (uh?) (0=No, 1=Yes/Muted) |
0 S/M ADPCM Stereo/Mono (0=Mono, 1=Stereo) 1 "L" Reserved (should be 0) 2 FS ADPCM Sampling Frequency (0=37.8kHz, 1=18.9kHz) 3 "L" Reserved (should be 0) 4 BITLNGTH ADPCM Sample Bit Length (0=Normal/4bit, 1=8bit) 5 "L" Reserved (should be 0) 6 EMPHASIS ADPCM Emphasis (0=Normal/Off, 1=On) 7 "L" Reserved (should be 0) |
0-7 Reserved (undefined) |
0-7 Reserved (should be 00h) (or don't write at all) |
| CDROM Internal Commands CX(0x..3x) - CXA1782BR Servo Amplifier |
23-20 4bit Command (00h) 19 1bit FS4 Focus Servo (0=Off, 1=On) 18 1bit FS3 DEFECT 17 1bit FS2 Enable Focus Search Voltage (0=Off, 1=On) 16 1bit FS1 Select Focus Search Voltage (0=Falling, 1=Rising) 15-0 16bit Unused (don't care) |
23-20 4bit Command (01h) 19 1bit TG1,TG2 ON/OFF Tracking Servo Gain Up/Normal (hmmm?) 18 1bit Brake Circuit ON/OFF 17-16 2bit PS Sled Kick Height (0=+/-1, 1=+/-2, 2=Undoc, 3="Don't use"?) 15-0 16bit Unused (don't care) |
23-20 4bit Command (02h) 19-18 2bit Tracking Control (0=Off, 1=Servo On, 2=F-Jump, 3=R-Jump) ;TM1,3,4 17-16 2bit Sled Control (0=Off, 1=Servo On, 2=F-Fast, 3=R-Fast) ;TM2,5,6 15-0 16bit Unused (don't care) |
23-20 4bit Command (03h) 19 1bit Value to be adjusted (0=Balance, 1=Gain) 18-16 3bit New Balance or Gain value (depending on above bit) 15-0 16bit Unused (don't care) |
N-N 4bit Command (04h..07h) |
N-N 4bit Command (08h..0Fh) |
| CDROM Internal Commands CX(4x..Ex) - CXD2510Q Signal Processor |
23-20 4bit Command (4) 19-16 4bit AS3-0 Auto Sequence Command (see below) 15-12 4bit MT3-0 Max Timer Value (N timer units, or 0=Invalidate Timer) 11 1bit LSSL Timer Units (0=2.9ms, 1=186ms) (for above MT value) 10-8 3bit Unused (zero) 7-0 8bit Unused (don't care) |
00h Cancel 04h/05h Forward/Reverse Fine Search ;<--sends CX(25h) ;\these do internally 07h Focus-On ;<--sends CX(02h) ; send commands to 08h/09h Forward/Reverse 1 Track Jump ;\ ; CXA1782BR 0Ah/0Bh Forward/Reverse 10 Track Jump ; sends CX(25h) ; and, auto sequence 0Ch/0Dh Forward/Reverse 2N Track Jump ;/ ;/is interrupted? 0Eh/0Fh Forward/Reverse 1N Track Move ;<--CXD2545Q only(Reserved on CXD2510Q) 01h..03h,06h = Reserved |
23-20 4bit Command (5) 19-16 4bit TR3-0 Timer (N*0.022ms for Blind/Overflow, N*0.045ms for Brake) 15-8 8bit Unused (don't care on CXD2510Q, zero on CXD2545Q) 7-0 8bit Unused (don't care) |
23-20 4bit Command (6) 19-16 4bit SD3-0 Timer KICK.D (N*2.9ms for Fine Search? else N*1.45ms?) 15-12 4bit KF3-0 Timer KICK.F (N*0.09ms) 11-8 4bit Unused (don't care on CXD2510Q, zero on CXD2545Q) 7-0 8bit Unused (don't care) |
23-20 4bit Command (7) 19-4 16bit Track Jump Count Setting (0..65535) for Command 4x 3-0 4bit Unused (don't care) |
23-20 4bit Command (8) 19 1bit CDROM (0=Audio, 1=CDROM; no average and pre-value stuff) 18 1bit DOUT Mute (0=Not muted, 1=Mute DOUT) 17 1bit D.out Mute-F (0=Not muted, 1=Mute DA) 16 1bit WSEL (0=Enhanced Sync Window, 1=Enhanced Anti-Rolling) 15 1bit VCO SEL (0=Double Correction, 1=Quadruple Correction) 14 1bit ASHS (0=Double Correction, 1=Quadruple Correction) 13 1bit SOCT (0=Output SubQ to SQSO, 1=Output Each? to SQSO) 12 1bit Unused (zero) 11-8 4bit Unused (don't care on CXD2510Q, zero on CXD2545Q) 7-0 8bit Unused (don't care) |
23-20 4bit Command (9) 19 1bit DCLV ON-OFF (complex stuff, related to gain and frequencies) 18 1bit DSPB ON-OFF (0=Normal Speed, 1=Double Speed; fixed pitch) 17 1bit ASEQ ON-OFF (select output on SENS pin) 16 1bit DPLL ON-OFF (0=Analog RFPLL, 1=Digital RFPLL) 15-14 1bit Bilingual Audio (0=Stereo, 1=RightOnly, 2=LeftOnly, 3=Mute) 13 1bit FLFC (normally 0) 12 1bit Unused (zero) 11-8 4bit Unused (don't care on CXD2510Q, zero on CXD2545Q) 7-0 8bit Unused (don't care) |
23-20 4bit Command (0Ah) 19 1bit Vari Up (write 1-then-0 to increase pitch by +0.1%) 18 1bit Vari Down (write 1-then-0 to decrease pitch by -0.1%) 17 1bit Mute (0=Not muted; unless muted elsewhere, 1=Mute & Peak=0) 16 1bit ATT (0=Attentuation off, 1=Minus 12 dB) 15-14 2bit PCT (0=Normal, 1=LevelMeter, 2=PeakMeter, 3=Normal) (0-1=QuadC2) 13-12 2bit Unused (zero) 11-8 4bit Unused (don't care on CXD2510Q, zero on CXD2545Q) 7-0 8bit Unused (don't care) |
23-20 4bit Command (0Bh) 19-4 16bit Traverse Monitor Count (used when monitored by COMP and COUT) (?) 3-0 4bit Unused (don't care) |
23-20 4bit Command (0Ch) 19-18 2bit Gain MDP for CLVP mode (0=-6db, 1=0dB, 1=+6dB, 3=Reserved) 17-16 2bit Gain MDS for CLVS/CLVP (0=-12dB, 1=-6dB, 2=0dB, 3=Reserved) 15 1bit Zero (zero) 14 1bit Gain DCLV0 overall gain (0=0dB, 1=+6dB 13-12 2bit Unused (zero) 11-8 4bit Unused (don't care on CXD2510Q, zero on CXD2545Q) 7-0 8bit Unused (don't care) |
23-20 4bit Command (0Dh) 19 1bit DCLV PWM MD Digital CLV PWM mode (0=Use MDS+MDP, 1=Ternary MDP) 18 1bit TB Bottom Hold in CLVS/CLVH modes (0=At cycle RFCK/32, 1=RFCK/16) 17 1bit TP Peak Hold in CLVS mode (0=At cycle RFCK/4, 1=RFCK/2) 16 1bit Gain CLVS for CLVS mode (0=0dB, 1=+6dB)(always +6dB in CLVP mode) 15-8 8bit Unused (don't care on CXD2510Q, zero on CXD2545Q) 7-0 8bit Unused (don't care) |
23-20 4bit Command (0Eh) 19-16 4bit CM3-0 15-8 8bit Unused (don't care on CXD2510Q, zero on CXD2545Q) 7-0 8bit Unused (don't care) |
00h Stop Spindle Motor Stop mode 06h CLVA Automatic CLVS/CLVP switching mode, normally used for playback 08h Kick Spindle Motor Forward rotation mode 0Ah Brake Spindle Motor Reverse rotation mode 0Ch CLVH Peak hold at 34kHz 0Eh CLVS Rough Servo Mode, RF-PLL related 0Fh CLVP PLL Servo mode |
23-0 N/A Don't use |
80bit subq 15bit peak level (lsb first) (absolute/unsigned value) 1bit peak l/r flag (aka appears as "MSB" of peak level) |
Index ASEQ=0 ASEQ=1 ;<-- ASEQ can be set via CX(9xx) 0X HighZ SEIN (FZC) ;\aka SENS output 1X HighZ SEIN (A.S) ... aka DEFECT ; from CXA1782BR 2X HighZ SEIN (T.Z.C) ... aka TZC ; forwarded through 3X HighZ SEIN (SSTOP) ... aka Gain/Bal ;/CXD2510Q 4X HighZ XBUSY 5X HighZ FOK 6X HighZ SEIN (HighZ) AX GFS GFS BX COMP COMP CX COUT COUT EX /OV64 /OV64 7X-9X,DX,FX HighZ 0 |
FZC Focus Zero Cross
DEFECT Defect?
TZC Tracking Zero Cross
SSTOP Gain or Balance adjust reached wanted level
XBUSY Low while the auto sequencer operation is busy
FOK High for "focus OK" (same as FOK pin)
GFS High when the played back frame sync is obtained with correct timing
COMP Measures the number of tracks set with Reg B. High when Reg B is
latched, low when the initial Reg B number is input by CNIN
COUT Measures the number of tracks set with Reg B. High when Reg B is
latched, toggles each time the Reg B number is input by CNIN. While
$44 and $45 are being executed, toggles with each CNIN 8-count
instead of the Reg B number
OV64 Low when filtered EFM signal is lengthened by 64 channel clock
pulses or more
|
| CDROM Internal Commands CX(0x..Ex) - CXD2545Q Servo/Signal Combo |
23-20 4bit Command (01h) 19 1bit Anti Shock (0=Off, 1=On) 18 1bit Brake (0=Off, 1=On) 17 1bit Tracking Gain (0=Normal, 1=Up) 16 1bit Tracking Gain Filter (0=Select 1, 1=Select 2) 15-0 16bit Unused (don't care) |
23-20 4bit Command (03h) 19-18 2bit Subcommand (0) 17-16 2bit Sled Kick Level (0=+/-1, 1=+/-2, 2=+/-3, 3=+/-4) 15-0 16bit Unused (don't care) |
23-16 8bit Command (34h) 15 1bit Zero (0) 14-8 7bit Address (00h..4Fh = Select Coefficient K00..K4F) 7-0 8bit Data (00h..FFh = New value) PLUS 8bit Eight more bits on PSone (!) |
23-12 12bit Command (34Fh) 11-10 2bit Index (0=TRVSC, 1=FBIAS, 2=?, 3=?) 9-0 10bit Data (for FBIAS: bit0=don't care) |
23-16 8bit Command (35h) 15-14 2bit FT Focus Search-up speed 1 13-8 6bit FS Focus Search limit voltage (default 011000b) (+/-1.875V) 7 1bit FTZ Focus Search-up speed 2 6-0 7bit FG AGF Convergence Gain Setting (default 0101101b) |
23-16 8bit Command (36h) 15 1bit Zero (0) 14 1bit DTZC DTZC Delay (0=4.25us/Default, 1=8.5us) 13-8 6bit TJ Track Jump voltage (default 001110b) (+/-1.09V) 7 1bit Zero (0) 6-0 7bit TG AGT Convergence Gain Setting (default 0101110b) |
23-16 8bit Command (37h) 15-14 2bit FZS XXX pg. 84 13-8 6bit SM Sled Move Voltage 7 1bit AGS 6 1bit AGJ 5 1bit AGGF 4 1bit AGGT 3 1bit AGV1 2 1bit AGV2 1 1bit AGHS 0 1bit AGHT |
23-16 8bit Command (38h) 15 1bit VCLM VC level measurement on/off 14 1bit VCLC VC level compensation for FCS_In Register on/off 13 1bit FLM Focus zero level measurement on/off 12 1bit FLC0 Focus zero level compensation for FZC Register on/off 11 1bit RFLM RF zero level measurement on/off 10 1bit RFLC RF zero level compensation on/off 9 1bit AGF Focus automatic gain adjustment on/off 8 1bit AGT Tracking automatic gain adjustment on/off 7 1bit DFSW Defect switch disable (1=disable defect measurement) 6 1bit LKSW Lock switch (1=disable sled free-running prevention) 5 1bit TBLM Traverse center measurement on/off 4 1bit TCLM Tracking zero level measurement on/off 3 1bit FLC1 Focus zero level compensation for FCS_In Register on/off 2 1bit TLC2 Traverse center compensation on/off 1 1bit TLC1 Tracking zero level compensation on/off 0 1bit TLC0 VC level compensation for TRK/SLD_In register on/off |
23-16 8bit Command (39h) 15 1bit DAC Serial data readout DAC mode on/off 14-8 7bit SD Serial readout data select (see below) 7-0 8bit Unused (don't care) |
Addr Data Content 00h 8bit VC input signal 01h 8bit SE input signal 02h 8bit TE input signal 03h 8bit FE input signal 04h-07h 9bit TE AVRG register (mirrored to 04h-07h) 08h-0Bh 9bit FE AVRG register (mirrored to 08h-0Bh) 0Ch-0Fh 9bit VC AVRG register (mirrored to 0Ch-0Fh) 12h 8bit RFDC envelope (peak) 13h 8bit RFDC envelope (bottom) 1Ch 9bit TRVSC register 1Dh 9bit FBIAS register 1Eh 8bit RFDC input signal 1Fh 8bit RF AVRG register 20h-3Fh 16bit Data RAM (M00-M1F) 40h-7Fh 8bit Coefficient RAM (K00-K3F) (note: K40-K4F cannot be read out) |
23-16 8bit Command (3Ah) 15 1bit Zero (0) 14 1bit FBON: FBIAS register addition (0=off, 1=Add FBIAS to FCS) 13-0 14bit Zero (0) |
23-16 8bit Command (3Bh) 15-14 2bit SFO FOK Slice Level (...depends on SFOX) 13-12 2bit SDF DFCT Slice Level (0=89mV, 1=134mV, 2=179mV, 3=224mV) 11-10 2bit MAX DFCT Maximum Time (0=No Limit, 1=2ms, 2=2.36ms, 3=2.72ms) 9 1bit SFOX FOK Slice Level (...depends on SFO) 8 1bit BTF Bottom Hold Double-Speed Count-Up mode for MIRR (0=off) 7-6 2bit D2V Peak Hold 2 for DFCT (0=22.05kHz, 1=44.1, 2=88.2, 3=176.4) 5-4 2bit D1V Peak Hold 1 for DFCT (0=176.4kHz, 1=352.8, 2=705.6, 3=1411) 3-0 4bit Zero (0) |
23-16 8bit Command (3Ch) 15-0 16bit Unused (don't care) |
23-16 8bit Command (3Dh) 15-0 16bit Unused (don't care) |
23-16 8bit Command (3Eh) 15-14 2bit F1NDM FCS servo filter 1st stage (1=normal, 2=down) 13-12 2bit F3NUM FCS servo filter 3rd stage (1=normal, 2=up) 11-10 2bit T1NDM TRK servo filter 1st stage (1=normal, 2=down) 9-8 2bit T3NUM TRK servo filter 3rd stage (1=normal, 2=up) 7 1bit DFIS FCS hold filter input extraction node (0=M05, 1=M04) 6 1bit TLCD Mask TLC2 set by D2 of CX(38) only when FOK low 5 1bit RFLP Pass signal from RFDC pin through low-pass-filter 4-0 5bit Zero (0) |
23-16 8bit Command (3Fh) ... XXX pg. 89 15-14 2bit Unused (0) 13-12 2bit XTD 11 1bit Unused (0) 10-8 3bit DRR 7 1bit Unused (0) 6 1bit ASFG 5 1bit Unused (0) 4 1bit LPAS 3-2 2bit SRO 1-0 2bit Unused (0) |
Index ASEQ=0 ASEQ=1 Length $0X Z FZC - $1X Z AS - $2X Z TZC - $38 Z AGOK*1 - $38 Z XAVEBSY*1 - $30-37,$3A-3F Z SSTP - $3904 Z TE Avrg Reg. 9 bit $3908 Z FE Avrg Reg. 9 bit $390C Z VC Avrg Reg. 9 bit $391C Z TRVSC Reg. 9 bit $391D Z FB Reg. 9 bit $391F Z RFDC Avrg Reg. 8 bit $4X Z XBUSY - $5X Z FOK - $6X Z 0 - $AX GFS GFS - $BX COMP COMP - $CX COUT COUT - $EX OV64 OV64 - $7X-9X,DX,FX Z 0 - |
| CDROM Internal Commands CX(0x..Ex) - CXD2938Q Servo/Signal/SPU Combo |
CX(34910000) NewScexStopReading CX(3491xy80) NewScexRandomKey(xy) CX(34920000) NewScexFlushResyncOrSo CX(34944A00) NewScexInitValue1 CX(3498C000) NewScexInitValue2 CX(349C1000) NewScexThis ;\inverse ;\use CX(3C2080) for COUT selection CX(349D1000) NewScexThat ;/of COUT ;/ |
1st byte: Unknown/unused (normally ADR/Control) ;\these should be probably 2nd byte: Unknown/unused (normally Track) ; set to some invalid values 3rd byte: Unknown/unused (normally Index/Point) ;/to avoid SUB-Q confusion 4th..10th byte: SCEx data or Dummy bytes (depending on xy.bit7..1) 11th..12th byte: Unknown/unused (normally Audio Peak level) |
CXD2545Q CXD2938Q CX(3C) CX(3C0080) TzcCoutSelectHPTZC;\ <--formerly CX(3C) - CX(3C2080) TzcCoutSelectSCEX ; <--special NewScex mode CX(3D) CX(3C4080) TzcCoutSelectDTZC ;/ <--formerly CX(3D) |
CXD2545Q CXD2938Q CX(8180) CX(810408) MODE = Audio (CD-DA) CX(8120) CX(812400) MODE = Audio (CD-DA) (manual SPI bus access) CX(8980) CX(890408) MODE = CDROM (Data) - CX(898000) MODE = CDROM (Data) (used on RESET) |
| CDROM Internal Commands CX(xx) - Notes |
| CDROM Internal Commands CX(xx) - Summary of Used CX(xx) Commands |
<--vC1--> <--vC2--> <--vC3--> CXD2510Q CXD2545Q CXD2938Q CX(00) CX(00) CX(00) AllFocusSwitchesOff CX(02) CX(02) CX(02) FocusSearchVoltageFalling CX(03) CX(03) CX(03) FocusSearchVoltageRising ;ForTestOnly CX(08) CX(08) CX(08) FocusServoOn CX(0C) CX(0C) CX(0C) FocusServoOnAndDefectOn ;diff.usage vC# ? ----- CX(11) - - SledKickHeight2 CX(12) - - SledKickHeightInvalid CX(19) - - TrackingGainAndSledKickHeight2 CX(1D) - - TrackingGainBrakeAndSledKickHeight2 CX(1E) - - TrackingGainBrakeAndSledKickHeightInvalid ----- - CX(11) CX(11) AntiShockOff ;\ - CX(13) CX(13) AntiShockOffGainUp ; - CX(17) CX(17) AntiShockOffGainUpBrake ;/ ----- CX(20) CX(20) CX(20) SledAndTrackingOff CX(21) CX(21) CX(21) SledServoOn ;ForTestOnly CX(22) CX(22) CX(22) SledFastForward CX(23) CX(23) CX(23) SledFastReverse CX(24) - - TrackingServoOn CX(25) CX(25) CX(25) SledAndTrackingServoOn - CX(26) CX(26) SledFastForwardAndTrackingServoOn CX(28) CX(28) CX(28) TrackingForwardJump ;ForTestOnly CX(2C) CX(2C) CX(2C) TrackingReverseJump ;ForTestOnly ----- CX(30+n) - - BalanceAdjust(0..7) CX(38+n) - - GainAdjust(0..7) ----- - CX(30) CX(30) SetSledKickLevel1 ;\ - CX(31) CX(31) SetSledKickLevel2 ; - CX(32) CX(32) SetSledKickLevel3 ;/ ----- - CX(3400E6) CX(3400E6) SetK00toE6hSledInputGain ;def=E0h - CX(340730) CX(340730) SetK07to30hSledAutoGain ;blah ;def=30h - CX(34114A) CX(34114A) SetK11to4AhFocusOutputGain ;def=32h - CX(341330) CX(341330) SetK13to30hFocusAutoGain ;blah ;def=30h - CX(341D6F) CX(341D6F) SetK1Dto6FhTrackingLowBoostFilterAL ;def=44h - CX(341F64) CX(341F64) SetK1Fto64hTrackingLowBoostFilterBL ;def=5Eh - CX(342220) CX(342220) SetK22to20hTrackingOutputGain ;def=18h - CX(342330) CX(342330) SetK23to30hTrackingAutoGain ;blah ;def=30h - CX(342D28) CX(342D28) SetK2Dto28hFocusGainDownOutputGain ;def=1Bh - CX(343E70) CX(343E70) SetK3Eto70hTrackingGainUpOutputGain ;def=57h - - CX(34910000) NewScexStopReading ;\ - - CX(3491x180) NewScexRandomKey(x) ; - - CX(34920000) NewScexFlushResyncOrSo ; SCEX SPECIAL - - CX(34944A00) NewScexInitValue1 ; see also: - - CX(3498C000) NewScexInitValue2 ; CX(3C2080) - - CX(349C1000) NewScexThis ;\inverse ; - - CX(349D1000) NewScexThat ;/of COUT ;/ - CX(34F000) CX(34F000) SetTRVSCto000h - CX(34Fxxx) CX(34Fxxx) SetFBIAStoNNNh ----- - CX(3740AA) CX(3740AA) SetSMto00h ;\set SM to 0,6,7,9 - CX(3746AA) CX(3746AA) SetSMto06h ; (sled move voltage) - CX(3747AA) CX(3747AA) SetSMto07h ; (and init several - CX(3749AA) CX(3749AA) SetSMto09h ;/fixed settings) ----- - CX(380010) CX(380010) ModeMeasureTrackingZeroLevel ;\Measure modes - CX(380800) CX(380800) ModeMeasureRfZeroLevel ; (accepted - CX(382000) CX(382000) ModeMeasureFocusZeroLevel ; every 2.9ms) - CX(388000) CX(388000) ModeMeasureVcLevel ;/ - CX(38140A) CX(38140A) ModeCompensate - CX(38140E) CX(38140E) ModeCompensateAndTraverseCenter - CX(38148A) CX(38148A) ModeCompensateAndDefectOff - CX(38148E) CX(38148E) ModeCompensateAndDefectOffTraverseCenter - CX(3814AA) CX(3814AA) ModeCompensateAndStuffAndMeasureTraverse ;! - CX(38150A) CX(38150A) ModeCompensateAndTrackingAutoGain - CX(38150E) CX(38150E) ModeCompensateAndTrackingAutoGain - CX(38160A) CX(38160A) ModeCompensateAndFocusAutoGain ----- - CX(391E) - SenseRFDCinputSignalWithoutDAC ;\rather - CX(3983) - SenseFEinputSignalWithDAC ;/unused - CX(399C) - SenseTRVSCregisterWithDAC ;\only if - CX(399D) - SenseFBIASregisterWithDAC ;/TEST1=LOW ----- - CX(3A0000) CX(3A0000) FocusBiasAdditionOff ;\ - CX(3A4000) CX(3A4000) FocusBiasAdditionOn ;/ - CX(3B2250)!CX(3B7250)!InitOperationForMirrDfctFok <-- vC2/vC3 DIFF - CX(3C) !!!CX(3C0080) TzcCoutSelectHPTZC;\ <--formerly CX(3C) - - !!!CX(3C2080) TzcCoutSelectSCEX ; <--special NewScex mode - CX(3D) !!!CX(3C4080) TzcCoutSelectDTZC ;/ <--formerly CX(3D) - CX(3E0000) CX(3E0000) InitFilterBits ;\ - CX(3E0008) CX(3E0008) InitFilterBitsInvalid ;/ - CX(3F0008) CX(3F0008) InitOtherStuff ;- ----- CX(4000) CX(4000) CX(4000) AutoSeqCancel CX(4700) CX(4700) CX(4700) AutoSeqFocusOn CX(4800) CX(4800) CX(4800) Forward1track CX(4900) CX(4900) CX(4900) Reverse1track CX(4C00) CX(4C00) CX(4C00) Forward2Ntrack CX(4D00) CX(4D00) CX(4D00) Reverse2Ntrack ----- CX(54) CX(54) CX(54) BlindBrakeOverflowTimer=4 CX(5A) CX(5A) CX(5A) BlindBrakeOverflowTimer=A CX(6100) CX(6100) CX(6100) SledKickBrakeKickTimer CX(70xxx0) CX(70xxx0) CX(70xxx0) TrackJumpCountSetting CX(8180) CX(8180)!!!CX(810408) MODE = Audio (CD-DA) - CX(8120)!!!CX(812400) MODE = Audio (CD-DA) (manual SPI bus access) - - CX(810000/UNUSED) - - CX(812000/UNUSED) CX(8980) CX(8980) CX(890408) MODE = CDROM (Data) - - CX(898000) MODE = CDROM (Data) (used on RESET) CX(9B00) CX(9B00)!!!CX(9B1000) NormalSpeed CX(9F00) CX(9F00)!!!CX(9F1000) DoubleSpeed CX(A040) CX(A040) CX(A040) Attentuation Off CX(A140) CX(A140) CX(A140) Attentuation -12 dB CX(B01000) CX(B01000) CX(B01000) TraverseMonitorCounterSetting CX(C600) CX(C600) CX(C600) SpindleServoCoefficientSetting CX(D7) CX(D7) CX(D70000) ClvControl (fixed) CX(E0) CX(E0) CX(E00000) SpindleMotorStop - - CX(E02000) <-- aka bugged CX(E0) with CRAP=2000h CX(E6) CX(E6) CX(E60000) AutomaticNormal CX(E8) CX(E8) CX(E80000) SpindleMotorForward - - CX(E8crap) <-- aka bugged CX(E8) with CRAP=xxxxh CX(EA) CX(EA) CX(EA0000) SpindleMotorReverse - - CX(EAcrap) <-- aka bugged CX(EA) with CRAP=xxxxh CX(EE) CX(EE) CX(EE0000) RoughServo ----- CX(F) CX(F) CX(F) Unused (N/A) ----- CX(Xx) CX(Xx) CX(Xx) ;\ CX(Xxxx) CX(Xxxx) CX(Xxxx) ; TestCommand (cmd_19h_50h) CX(Xxxxxx) CX(Xxxxxx) CX(Xxxxxx) ; - - CX(Xxxxxxxx) ;/ - CX(Xxxxxx) CX(Xxxxxx) SerialSense, CX(Xxxx) with extra 8bit junk |
sense(30) SEIN.BAL ;vC2: SSTP sense(38) SEIN.GAIN ;vC2: AGOK(AGT/AGF) or XAVEBSY(AVRG) or SSTP(else?) sense(40) XBUSY (low=AutoSeqBusy) sense(50) FOK (high=FokusOkay) sense(A0) GFS (high=GoodFrameSync, ie. CorrectPlaybackSpeed) sense(C5) COUT (toggles each 100h 'tracks') (100h=selected via CX(B01000)) sense(EA) /OV64 (low=EFM too long?) |
| CDROM Internal Coefficients (for CXD2545Q) |
Addr Val Expl. K00 E0 Sled input gain K01 81 Sled low boost filter A-H K02 23 Sled low boost filter A-L K03 7F Sled low boost filter B-H K04 6A Sled low boost filter B-L K05 10 Sled output gain K06 14 Focus input gain K07 30 Sled auto gain K08 7F Focus high cut filter A K09 46 Focus high cut filter B K0A 81 Focus low boost filter A-H K0B 1C Focus low boost filter A-L K0C 7F Focus low boost filter B-H K0D 58 Focus low boost filter B-L K0E 82 Focus phase compensate filter A K0F 7F Focus defect hold gain K10 4E Focus phase compensate filter B K11 32 Focus output gain K12 20 Anti shock input gain K13 30 Focus auto gain K14 80 HPTZC / Auto Gain High pass filter A K15 77 HPTZC / Auto Gain High pass filter B K16 80 Anti shock high pass filter A K17 77 HPTZC / Auto Gain low pass filter B K18 00 Fix (should not change this preset value) K19 F1 Tracking input gain K1A 7F Tracking high cut filter A K1B 3B Tracking high cut filter B K1C 81 Tracking low boost filter A-H K1D 44 Tracking low boost filter A-L K1E 7F Tracking low boost filter B-H K1F 5E Tracking low boost filter B-L K20 82 Tracking phase compensate filter A K21 44 Tracking phase compensate filter B K22 18 Tracking output gain K23 30 Tracking auto gain K24 7F Focus gain down high cut filter A K25 46 Focus gain down high cut filter B K26 81 Focus gain down low boost filter A-H K27 3A Focus gain down low boost filter A-L K28 7F Focus gain down low boost filter B-H K29 66 Focus gain down low boost filter B-L K2A 82 Focus gain down phase compensate filter A K2B 44 Focus gain down defect hold gain K2C 4E Focus gain down phase compensate filter B K2D 1B Focus gain down output gain K2E 00 Not used K2F 00 Not used K30 80 Fix (should not change this preset value) K31 66 Anti shock low pass filter B K32 00 Not used K33 7F Anti shock high pass filter B-H K34 6E Anti shock high pass filter B-L K35 20 Anti shock filter comparate gain K36 7F Tracking gain up2 high cut filter A K37 3B Tracking gain up2 high cut filter B K38 80 Tracking gain up2 low boost filter A-H K39 44 Tracking gain up2 low boost filter A-L K3A 7F Tracking gain up2 low boost filter B-H K3B 77 Tracking gain up2 low boost filter B-L K3C 86 Tracking gain up phase compensate filter A K3D 0D Tracking gain up phase compensate filter B K3E 57 Tracking gain up output gain K3F 00 Not used K40 04 Tracking hold filter input gain K41 7F Tracking hold filter A-H K42 7F Tracking hold filter A-L K43 79 Tracking hold filter B-H K44 17 Tracking hold filter B-L K45 6D Tracking hold filter output gain K46 00 Not used K47 00 Not used K48 02 Focus hold filter input gain K49 7F Focus hold filter A-H K4A 7F Focus hold filter A-L K4B 79 Focus hold filter B-H K4C 17 Focus hold filter B-L K4D 54 Focus hold filter output gain K4E 00 Not used K4F 00 Not used |
| CDROM Video CDs (VCD) |
| VCD ISO Basic Files (INFO, ENTRIES, AVSEQnn, ISO Filesystem) |
008h 32 System Identifier (always "CD-RTOS CD-BRIDGE" for VCDs)
028h 32 Volume Identifier (often nonsense, eg. "" or "__" or "VolumeLabel")
23Eh 128 Application Identifier ("CDI/CDI_APPL.VCD;1" or "CDI/CDI_VCD.APP;1")
400h 8 CD-XA Identifying Signature ("CD-XA001" for PSX and VCD)
|
VCDs are using MODE2 (with 800h-byte and 914h-byte sectors) MPEG videos are on extra data tracks (outside of the ISO area on Track 1) Files in VCD or SVCD folders use fixed sectors numbers (00:04:00 and up) All 16bit/32bit values in files in VCD,SVCD,EXT,etc are BIG-ENDIAN |
000h 8 ID "VIDEO_CD" for VCD (or "SUPERVCD"/"HQ-VCD " for SVCD) 008h 1 Version ;Version Major (01h) (or 02h for VCD 2.0) 009h 1 System Profile Tag ;Version Minor (00h) (or 01h for VCD 1.1 or HQ) 00Ah 16 Album ID/Desc (name in ASCII, padded with SPC) (usually empty) 01Ah 2 Total Number of CDs in Album (1..N) ;\usually always 1,1 (even 01Ch 2 Number of this CD in Album (1..N) ;/for movies with 2 discs) 01Eh 13 PAL Flags, 98x1bit, for each Track? (0=NTSC, 1=PAL) 02Bh 1 InfoStatusFlags (see below) Below is usually zero-filled when not using PBC 02Ch 4 Size of PSD.VCD file (or PSD.SVD?) (0=None) 030h 3 First segment addr MM:SS:00 in BCD (00:02:00 ???) 033h 1 Offset Multiplier for "PsdOffset" values in PSD.VCD (must be 8) 034h 2 Number of ListIDs in LOT.VCD file (1..7FFFh, plus 1 in some discs) 036h 2 Number of ITEMnnnn.DAT files (plus nonsense in some discs?) Below is usually zero-filled (maybe exists on SVCD only?) 038h 1980 SegmentContent[1..1980] (b0-1=Audio, b2-4=Video, b5=Cont, b6-7=OGT) 7F4h 5*2 volume start time[0]: 5x16bit ;aka playing_time[5] in seconds (?) 7FEh 2 Reserved (0) |
bit0 Reserved, must be zero bit1-2 Restriction (0=No, 1..3=Restricted category 1..3) (eg. "not for kids") bit3 Special Information is encoded in the pictures, uh? bit4 MPEG User Data is used for Closed Caption (user_data_cc) (0=No, 1=Yes) bit5 Next Disc with PBC (0=Start at ListID#1, 1=Start at ListID#2) bit6 Next Disc without PBC (0=Start at Track #2, 1=Start at Track #3) bit7 Extended PBC available (0=No, 1=Yes... aka EXT\PSD_X exists?) |
000h 8 ID "ENTRYVCD" for VCD and SVCD (or "ENTRYSVD" for VCD30) 008h 1 Version ;\same as in INFO.VCD/SVD 009h 1 System Profile Tag ;/ 00Ah 2 Number of Entries/Chapters (1..500) 00Ch 4*500 Entry[N] (Track 02h..99h, and MM:SS:FF) (all 4 bytes in BCD) 7DCh 36 Reserved (0) |
0x02 --- VCD2.0 0x01 --- SVCD, should be same as version in INFO.SVD |
0x01 if VCD1.1 0x00 else |
| VCD ISO Playback Control PBC Files (PSD, LOT, ITEMnnnn) |
PsdPlayListDescriptor (14+2*N bytes):
00h 1 Type (10h=PlayList)
01h 1 Number of Items (noi) ;for Start-of-Movie and Numeric-Input?
02h 2 ListID for this Descriptor (1..7FFFh)
04h 2 PsdOffset for Prev button (FFFFh=Disable)
06h 2 PsdOffset for Next button (FFFFh=Disable)
08h 2 PsdOffset for Return/back button (FFFFh=Disable)
0Ah 2 Play time in 1/15s (=max 72.8 minutes) (or 0000h=full item)
0Ch 1 Delay time in "1s/10s" units after ;<-- uh, after? after what?
0Dh 1 Auto pause time in "1s/10s" units (used for each item in list if
the auto pause flag in a sector is true) [WHAT is that? Trigger bit?]
0Eh 2*N ItemID[N] ;item number (0..599 or 1000..2979)
Entry 0 is for "start of movie" (usually 0002h=Track 2)
Entry 1..N-1 is for numeric input ?
PsdSelectionListDescriptor (20+2*N bytes, or 36+6*N bytes):
00h 1 Type (18h=SELECTION_LIST, or 1Ah=EXT_SELECTION_LIST)
01h 1 Flags (bit0=SelectionArea, bit1=CommandList, bit2-7=Reserved)
02h 1 nos <-- aka Number of Numeric-input selections ?
03h 1 bsn <-- ?
04h 2 ListID for this Descriptor (1..7FFFh)
06h 2 PsdOffset for Prev button
08h 2 PsdOffset for Next button
0Ah 2 PsdOffset for Return/back button
0Ch 2 PsdOffset for Default button (uh, what is that?)
0Eh 2 PsdOffset for Timeout
10h 1 totime <-- aka Timeout Time maybe? in WHAT units?
11h 1 loop <-- aka ?
12h 2 itemid <-- aka Item to be displayed during the selection?
14h 2*N PsdOffset[N] for Numeric-input ?
Below only for SVCDs (with Type=18h), or for Extended VCDs (with Type=1Ah):
(14h+2*N) 4 Area for Prev (x1,y1,x2,y2) ;\these extra entries exist for
(18h+2*N) 4 Area for Next (x1,y1,x2,y2) ; SVCDs with Type=18h, and
(1Ch+2*N) 4 Area for Return (x1,y1,x2,y2) ; Extended VCDs with Type=1Ah
(20h+2*N) 4 Area for Default (x1,y1,x2,y2) ; (but do NOT exist for
(24h+2*N) 4*N Area[N] (x1,y1,x2,y2) ;/older VCDs with Type=18h)
PsdEndListDescriptor (8 bytes)
00h 1 Type (1Fh=EndList)
01h 1 Next_disc ;00h to stop PBC or NNh to switch to disc no NN (BCD!?)
02h 2 Item (0 or 1000..2979, should be still image, eg. Change Disc pic)
04h 4 Reserved (0)
N/A - This descriptor doesn't have a ListID (unlike as other descriptors)
PsdCommandListDescriptor (5+2*N bytes)
00h 1 Type (20h=CommandList)
01h 2 Command_count
03h 2 ListID for this Descriptor (1..7FFFh)
05h 2*N command[EMPTY_ARRAY_SIZE] ;uh, WHAT is a command?
PsdAlignmentPadding (after each list entry)
00h 0..7 Padding to next 8-byte PsdOffset boundary (00h-filled)
|
1..60 --> wait "N" seconds 61..254 --> wait "(N-60)*10+60" seconds 255 --> wait infinite |
0..1 - Play nothing 2..99 - Play Track 2..99 (TOC tracks, for AVSEQnn.DAT and AUDIOnn.DAT?) 100..599 - Play Entry 1..500 from table in ENTRIES file up to end of track 600..999 - Reserved 1000..2979 - Play SPI Segment Play Item 1..1980 (ITEMnnnn.DAT file) 2980..65535 - Reserved |
0..N Offset within PSD.VCD file, in 8-byte units FFFDh PSD_OFS_MULTI_DEF_NO_NUM ;\uh, what is that? FFFEh PSD_OFS_MULTI_DEF ;/ FFFFh PSD_OFS_DISABLED ;-no function assigned to the button |
0000h 2 Reserved (0) 0002h 2*7FFFh PsdOffset[1..7FFFh] ;for ListID 1..7FFFh |
| VCD ISO Search Files (SCANDATA, SEARCH, TRACKS, SPICONTX) |
TRACKS_SVD_SECTOR = (PSD_VCD_SECTOR+1) ;aka 2nd sector in PSD.SVD? SEARCH_DAT_SECTOR = (TRACKS_SVD_SECTOR+1) ;aka 3rd..Nth sector in PSD.SVD? |
SCANDATA.DAT Format for VCD 2.0 (12+3*N bytes):
000h 8 ID "SCAN_VCD"
008h 1 Version (02h for VCD 2.0)
009h 1 Reserved (0)
00Ah 2 Number of scan points (in 0.5s units) (max FFFFh = ca. 9.1 hours)
00Ch 3*N Scan Point[0..N-1] ;MM:SS:FF of closest I-frame
SCANDATA.DAT Format for SVCD (16+3*N+2*X+3*Y+3*Z bytes):
000h 8 ID "SCAN_VCD"
008h 1 Version (01h for SVCD)
009h 1 Reserved (0)
00Ah 2 scandata_count ;number of 3-byte entries in the table
00Ch 2 track_count ;number of MPEG tracks on disc
00Eh 2 spi_count ;number of consecutively recorded play item segments
; (as opposed to the number of segment play items).
010h 3*N msf_t cum_playtimes[N] ;cumulative playing time up to track N.
; (track time just wraps at 99:59:74)
xxxh 2*X spi_indexes[X] ;Indexes into the following scandata table
xxxh 2 mpegtrack_start_index ;Index into the following scandata table
; (where the MPEG track scan points start)
xxxh 3*Y The scandata table... [Y] ;8bit Track Number and 16bit Index
uint8_t track_num ;Track number as in TOC
uint16_t table_offset ;Index into scandata table
xxxh 3*Z msf_t scandata_table[Z] ;MM:SS:FF
|
000h 8 ID "SEARCHSV" 008h 1 Version (01h) 009h 1 Reserved (0) 00Ah 2 Number of scan points 00Ch 1 Time_interval (in units of 0.5 seconds) (must be 01h) 00Dh 3*N Scan Point[0..N-1] ;MM:SS:FF of closest I-frame |
SVCD\TRACKS.SVD Format for SVCD (11+4*N bytes): 000h 8 ID "TRACKSVD" 008h 1 Version (01h) 009h 1 Reserved (0) 00Ah 1 Number of MPEG tracks (N) 00Bh 3*N Track playing_time[N] (MM:SS:FF, in BCD)(in sectors, not real time) 0xxh 1*N TrackContent[N] ;bit0-1=Audio,bit2-4=Video,bit5=Reserved,bit6-7=OGT SVCD\TRACKS.SVD Format for VCD30 (11+5*N bytes) (some sort of SVCD-prototype): 000h 8 ID "TRACKSVD" 008h 1 Version (01h) 009h 1 Reserved (0) 00Ah 1 Number of MPEG tracks (N) 00Bh 5*N Cum_Playing_time and Content (MM:SS:FF in BCD, and OGT, Audio) |
0000h 8 ID "SPICONSV" 0008h 1 Version (01h) 0009h 1 Reserved (0) 000Ah 2*1980 Segment Content[1..1980] (1st byte=OGT, 2nd byte=Audio) 0F82h 126 Reserved (0) |
bit0-1 Audio characteristics:
0 = No MPEG audio stream
1 = One MPEG1 or MPEG2 audio stream without extension
2 = Two MPEG1 or MPEG2 audio streams without extension
3 = One MPEG2 multi-channel audio stream with extension
bit2-4 Video characteristics:
In TRACKS.SVD this must be 0,3,7 (no still pictures)
0 = No MPEG video data
1 = NTSC still picture
2 = NTSC Reserved (NTSC still pic hires?)
3 = NTSC motion picture
4 = Reserved
5 = PAL still picture
6 = PAL Reserved (PAL still pic hires?)
7 = PAL motion picture
bit5 Indicates segment is continuation of an item
In TRACKS.SVD this must be 0 (reserved)
0 = First or only segment of item
1 = Second or later segment of item
bit6-7 Overlay Graphics/Text (OGT):
0 = No OGT substream
1 = Sub-stream 0 available
2 = Sub-stream 0 & 1 available
3 = All OGT sub-substreams available
|
1st byte = Audio characteristics ;\probably same values as 2nd byte = Overlay Graphics/Text (OGT) ;/in above bitfields? |
| VCD ISO Misc files (CAPTnn, AUDIOnn, KARINFO, PICTURES, CDI) |
Revision A (spotted on two discs from 1997 and 1999): CDI_APPL.VCD 80702 bytes, 04-Mar-1996, CRC32=AE8FC5D0h ;executable VCD_BACK.DYV 92572 bytes, 18-Jul-1995, CRC32=00693E5Eh ;whatever? VCD_BTN.C8 93719 bytes, 18-Jul-1995, CRC32=FF0A636Ah ;whatever? Revision B (spotted on a disc from 2003): CDI_VCD.APP 20648 bytes, 00-Nul-0000 CRC32=DC885F70h ;executable CDI_FONT.FNT 145388 bytes, 00-Nul-0000 CRC32=FB4D63F4h ;font? CDI_ALL.RTF ? bytes, CRC32=? ;realtimefile? CDI_BUM.RTF ? bytes, CRC32=? ;realtimefile? Revision C (spotted on a disc from 2006, and homebrews from 2001 and 2017): CDI_VCD.APP 102400 bytes, 00-Nul-0000 CRC32=E91E128Dh ;executable CDI_VCD.CFG 193 bytes, 00-Nul-0000 CRC32=D1C6F7ADh ;config/ascii CDI_TEXT.FNT 13616 bytes, 00-Nul-0000 CRC32=BDC55E86h ;font? CDI_IMAG.RTF 1510028 bytes, 00-Nul-0000 CRC32=(RIFF) ;realtimefile? |
| VCD MPEG-1 Multiplex Stream |
VCD discs --> Sector Size = 914h bytes (the discs MODE2/FORM2 sector size) .mpg files --> Sector Size = 800h bytes (regardless of physical sector size) |
32bit PACK_START_CODE (000001BAh) ;-4byte 2bit Fixed (00b for MPEG-1) (would be 01b for MPEG-2) ;\ 2bit Fixed (10b) ; 3bit System Clock Reference, bit32-30 ;\ ; 1bit Marker (1) ; System Clock Reference (SCR) ; 15bit System Clock Reference, bit29-15 ; (intended Time, ; 5byte 1bit Marker (1) ; in 90kHz clock cycles) ; 15bit System Clock Reference, bit14-0 ;/ ; 1bit Marker (1) ;/ 1bit Marker (1) ;\ 22bit Multiplex Rate (total bitrate of the stream, in 400bit/s units) ; 3byte 1bit Marker (1) ;/ |
32bit SYSTEM_HEADER_START_CODE (000001BBh) ;\6byte 16bit Header Length minus 6 (in bytes) (0006h+N*3) ;/ 1bit Marker (1) ;\ 22bit Rate bound (max multiplex rate of all packs in the stream, ; 3byte 1bit Marker (1) in 400bit/s units) ;/ 6bit Audio Bound (max number of audio streams in this ISO stream) ;\ 1bit Fixed Flag (1=Fixed bitrate) ; 1byte 1bit CSPS Flag (1=Constrained) ;/ 1bit System Audio Lock Flag XXX ;\ 1bit System Video Lock Flag XXX ; 1byte 1bit Marker (1) ; 5bit Video Bound (max number of video streams in this ISO stream) ;/ 8bit Reserved (FFh) ;-1byte |
8bit Stream ID (C0h..DFh=Audio, E0h..EFh=Video) ;\ 2bit Fixed (11b) ; 3byte 1bit STD buffer scale (0=Mul128/audio, 1=Mul1024/video) ; 13bit STD buffer size (largest required buffer over all packets) ;/ |
32bit START (000001xxh BDh-BFh=Special, C0h-DFh=Audio, E0h-EFh=Video);\6byte 16bit Packet Length minus 6 (in bytes) (1..18, plus data) ;/ |
(2bit) Fixed (11b, indicates presence of stuffing) ;\optional 0..16byte (6bit) Fixed (111111b) ;/ |
(2bit) Fixed (01b, indicates presence of buffer size) ;\ (1bit) STD Buffer Scale (0=Mul128/audio, 1=Mul1024/video) ; optional 2byte (13bit) STD Buffer Size (for decoding, in above scale units) ;/ |
2bit Fixed (00b, indicates no further stuffing/buffer info);\ 1bit PTS Flag (Presentation Time Stamp) ; 0.5 bytes 1bit DTS Flag (Decoding Time Stamp) ;/ |
(3bit) Presentation Time Stamp, bit32-30 ;\ (1bit) Marker (1) ; optional 4.5 bytes (15bit) Presentation Time Stamp, bit29-15 ; (time when to output the (1bit) Marker (1) ; the packet to audio/video (15bit) Presentation Time Stamp, bit14-0 ; hardware, in 90kHz cycles) (1bit) Marker (1) ;/ |
(4bit) Fixed (0001b) ;\ (3bit) Decoding Time Stamp, bit32-30 ; optional 5 bytes (1bit) Marker (1) ; (recommended time when (15bit) Decoding Time Stamp, bit29-15 ; to decode the block, (1bit) Marker (1) ; in 90kHz cycles) (15bit) Decoding Time Stamp, bit14-0 ; (1bit) Marker (1) ;/ |
(4bit) Fixed (1111b) ;-optional 0.5 bytes |
... packet data bytes ;-data...(not crossing sector) |
32bit END_CODE (000001B9h) ;-4byte |
| VCD MPEG-1 Video Stream |
32bit SEQUENCE_HEADER_CODE (000001B3h) ;-4byte 12bit Width in pixels (1..4095) ;\3byte 12bit Height in pixels (1..2800, for max AFh slices) ;/ 4bit Aspect Ratio (01h..0Eh, see below) ;\1byte 4bit Framerate (01h..08h, see below) ;/ 18bit Bitrate (in 400bit/s units, 3FFFFh=variable rate) ;\ 1bit Marker (1) ; 3byte 10bit VBV (required decoding memory size, in "16 kB" units) ; +6bit 1bit Constrained Parameter Flag ;/ 1bit Load Intra Q Matrix (0=No, use Standard Matrix, 1=Yes, Custom) |
(64byte) Intra Quantizer Matrix (64 x 8bit, unsigned) (in zigzag order) 1bit Load Non-Intra Q Matrix (0=No, use Standard Matrix, 1=Yes, Custom) |
(64byte) Non-Intra Quantizer Matrix (64 x 8bit, unsigned) (in zigzag order) |
0 - ;forbidden 1 1.0 ;square pixels 2 0.6735 ;0.6735 3 0.7031 ;16:9, 625 line, PAL 4 0.7615 ;0.7615 5 0.8055 ;0.8055 6 0.8437 ;16:9, 525 line, NTSC 7 0.8935 ;0.8935 8 0.9157 ;4:3, 625 line, PAL, CCIR601 9 0.9815 ;0.9815 10 1.0255 ;1.0255 11 1.0695 ;1.0695 12 1.0950 ;4:3, 525 line, NTSC, CCIR601 13 1.1575 ;1.1575 14 1.2015 ;1.2015 15 - ;reserved |
0 - ;forbidden 1 23.976 (24000/1001) ;NTSC encapsulated film rate 2 24.0 ;Standard international cinema film rate 3 25.0 ;PAL video frame rate (625/50) 4 29.97 (30000/1001) ;NTSC video frame rate 5 30.0 ;NTSC video frame rate drop-frame (525/60) 6 50.0 ;PAL double frame rate/progressive 7 59.94 (60000/1001) ;NTSC double frame rate 8 60.0 ;NTSC double frame rate drop-frame 9-15 - ;reserved |
32bit GROUP_START_CODE (000001B8h) 1bit Drop Frame (1=drop this frame; for reducing 30 fps to 29.97 fps) 5bit Time Code Hours (0..23) 6bit Time Code Minutes (0..59) 1bit Marker (1) 6bit Time Code Seconds (0..59) 6bit Time Code Picture (0..59) 1bit Closed GOP 1bit Broken Link |
32bit PICTURE_START_CODE (00000100h) ;\ 10bit Temporal Reference (display order, 0..3FFh) ; 61bit 3bit Coding Type (0=Invalid, 1=I, 2=P, 3=B, 4=D, 5-7=Reserved); 16bit VBV Delay (in 90kHz cycles, FFFFh=variable bitrate) ;/ |
(1bit) full fel forward vector (0=half pix, 1=full pix) ;\optional 4bit (3bit) forward f code (0=invalid, 1..7=0..6bits) ;/ |
(1bit) full backward vector ;\optional 4bit (3bit) backward f code ;/ |
(1bit) Fixed (1, indicates presence of Extra Info) ;\opt. N*9bit (8bit) Extra Information ;/ |
1bit Fixed (0, indicates no further Extra Info) ;-1bit 0-7bit Padding to byte boundary (0) ;-0..7bit |
0 Forbidden 1 I - Intra Coded (full image) 2 P - Predictive Coded (based on prev I or P frame) 3 B - Bidirectionally Predictive Coded (based on prev+next I or P frame) 4 D - DC Intra Coded (don't care, lowres thumbnail) 5 Reserved 6 Reserved 7 Reserved |
DISPLAY ORDER: I B B B P B B B P B B B P B B B I B B B P B B B P B B B P B B B ... | |_______|_______| | |_______|_______| | | | | I-Frame P-frames I-Frame P-frames |
STORAGE ORDER: I P B B B P B B B P B B B I B B B P B B B P B B B P B B B ... | |_______|_______| | |_______|_______| | | | | I-Frame P-frames I-Frame P-frames |
32bit PACK_START_CODE (000001xxh; xx=01h..AFh; vertical index) ;-4byte 5bit Quantizer Scale (1..31) (may be later changed by blocks) ;-5bit |
(1bit) Fixed (1, indicates presence of Extra Info) ;\opt. N*9bit (8bit) Extra Information ;/ |
1bit Fixed (0, indicates no further Extra Info) ;-1bit |
... Macroblock (within horizontal line) ;... |
0-7bit Padding to byte boundary (0) ;-0..7bit |
32bit START_CODE (000001B2h=User Data, 000001B5h=Extension Data) ;-4byte ... data (end is signaled by presence of next 000001xxh code) ;-data |
32bit SEQUENCE_END_CODE (000001B7h) ;-4byte |
N*11bit Macroblock_address_increase escape/stuffing codes (if any)
1..11bit Macroblock_address_increase
1-6bit Macroblock_type
5bit Quantizer_scale
... Motion_vector
3-9bit Coded_block_pattern
... Block(i)
|
Addr Incr Type Motion Vector QScale CBP Block b0 (Y1) Block b1 (Y2) Block b2 (Y3) Block b3 (Y4) Block b4 (Cb) Block b5 (Cr) |
| VCD MP2 Audio Stream |
Header (32bit) Optional CRC (16bit) (or 0bit if none) Allocation Information Scale Factor Selector Information Scale Factors Data |
12bit Syncword (FFFh) ;\
1bit Revision (0=MPEG-2, 1=MPEG-1) ; 2 bytes
2bit Layer (2=Audio LayerII) ;for VCDs ;
(3=LayerI, 1=LayerIII, 0=reserved) ;not on VCDs ;
1bit Protection_bit (1=no crc) ;/
4bit Bitrate_index (1..14) ;\
(0=free format, 15=reserved) ;
2bit Sampling_frequency ; 1 byte
1bit Padding_bit ;
1bit Private_bit ;/
2bit Mode ;\
2bit Mode_extension (aka bound) ;
1bit Copyright ; 1 byte
1bit Original/home ;
2bit Emphasis ;/
|
16bit CRC |
XXX... |
| Controllers and Memory Cards |
| Controller and Memory Card I/O Ports |
0-7 Data to be sent 8-31 Not used |
0-7 Received Data (1st RX FIFO entry) (oldest entry) 8-15 Preview (2nd RX FIFO entry) 16-23 Preview (3rd RX FIFO entry) 24-31 Preview (4th RX FIFO entry) (5th..8th cannot be previewed) |
0 TX Ready Flag 1 (1=Ready/Started) 1 RX FIFO Not Empty (0=Empty, 1=Not Empty) 2 TX Ready Flag 2 (1=Ready/Finished) 3 RX Parity Error (0=No, 1=Error; Wrong Parity, when enabled) (sticky) 4 Unknown (zero) (unlike SIO, this isn't RX FIFO Overrun flag) 5 Unknown (zero) (for SIO this would be RX Bad Stop Bit) 6 Unknown (zero) (for SIO this would be RX Input Level AFTER Stop bit) 7 /ACK Input Level (0=High, 1=Low) 8 Unknown (zero) (for SIO this would be CTS Input Level) 9 Interrupt Request (0=None, 1=IRQ7) (See JOY_CTRL.Bit4,10-12) (sticky) 10 Unknown (always zero) 11-31 Baudrate Timer (21bit timer, decrementing at 33MHz) |
0-1 Baudrate Reload Factor (1=MUL1, 2=MUL16, 3=MUL64) (or 0=MUL1, too) 2-3 Character Length (0=5bits, 1=6bits, 2=7bits, 3=8bits) 4 Parity Enable (0=No, 1=Enable) 5 Parity Type (0=Even, 1=Odd) (seems to be vice-versa...?) 6-7 Unknown (always zero) 8 CLK Output Polarity (0=Normal:High=Idle, 1=Inverse:Low=Idle) 9-15 Unknown (always zero) |
0 TX Enable (TXEN) (0=Disable, 1=Enable) 1 /JOYn Output (0=High, 1=Low/Select) (/JOYn as defined in Bit13) 2 RX Enable (RXEN) (0=Normal, when /JOYn=Low, 1=Force Enable Once) 3 Unknown? (read/write-able) (for SIO, this would be TX Output Level) 4 Acknowledge (0=No change, 1=Reset JOY_STAT.Bits 3,9) (W) 5 Unknown? (read/write-able) (for SIO, this would be RTS Output Level) 6 Reset (0=No change, 1=Reset most JOY_registers to zero) (W) 7 Not used (always zero) (unlike SIO, no matter of FACTOR) 8-9 RX Interrupt Mode (0..3 = IRQ when RX FIFO contains 1,2,4,8 bytes) 10 TX Interrupt Enable (0=Disable, 1=Enable) ;when JOY_STAT.0-or-2 ;Ready 11 RX Interrupt Enable (0=Disable, 1=Enable) ;when N bytes in RX FIFO 12 ACK Interrupt Enable (0=Disable, 1=Enable) ;when JOY_STAT.7 ;/ACK=LOW 13 Desired Slot Number (0=/JOY1, 1=/JOY2) (set to LOW when Bit1=1) 14-15 Not used (always zero) |
0-15 Baudrate Reload value for decrementing Baudrate Timer |
BitsPerSecond = (44100Hz*300h) / MIN(((Reload*Factor) AND NOT 1),1) |
Actually, /IRQ7 means "more-data-request", accordingly, it does NOT get triggered after receiving the LAST byte. |
| Controller and Memory Card Misc |
Memory Card 1 Memory Card 2 Controller 1 Controller 2 |
JOYDAT,JOYCMD,JOYCLK Data in/out/clock +7.5V,+3.5V,GND Supply /JOY1,/JOY2 Selects controller/memorycard 1, or controller/memorycard 2 /ACK Indicates that the device is ready to send more data (IRQ7) /IRQ10 Lightgun (controllers only, not memory card) (IRQ10) |
01h=Standard Controller (controller port) 21h=Special Yaroze Access Card (memory card slot) 41h=Special I-Mode Data-cable (controller port) 81h=Standard Memory Card (memory card slot) |
| Controller and Memory Card Signals |
____ _____
/SEL |____________________________________________________________|
______ ____ ____ ____ ____ _________
CLK |||||||| |||||||| |||||||| |||||||| ||||||||
_______________________________________________________________________
CMD X 01h XXXX 42h XXXX 00h XXXX 00h XXXX 00h XXXX
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
_____________________________________________________________
DAT -----XXXXXXXXXXXXX ID XXXX 5Ah XXXX key1 XXXX key2 XXXX-----
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/ACK ---------------|_|---------|_|---------|_|---------|_|-----------------
|
____
/SEL |__________________________________________________________________
______ _ _ _ _ _ _ _ __________________ _ _ _ _
CLK |_| |_| |_| |_| |_| |_| |_| |_| |_| |_| |_| |_|
__________ ___
CMD |________________________________________________| |_______
____
DAT -----XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX |___________
/ACK ----------------------------------------------|___|--------------------
|
| Controller and Memory Card Multitap Adaptor |
01 42 00 00 .. ;normal read |
01 42 01 00 .. ;method 1: receive special ID and data from ALL four pads 0n 42 00 00 .. ;method 2: receive data from pad number "n" (1..4) |
Halfword 0 --> Controller ID for MultiTap (5A80h=Multitap) Halfword 1..4 --> Player A (Controller ID, Buttons, Analog Inputs, if any) Halfword 5..8 --> Player B (Controller ID, Buttons, Analog Inputs, if any) Halfword 9..12 --> Player C (Controller ID, Buttons, Analog Inputs, if any) Halfword 13..16 --> Player D (Controller ID, Buttons, Analog Inputs, if any) |
Previous access had REQ=0 and returned Slot A data ---> returns Slot A data Previous access had REQ=0 and returned Slot A-D data -> returns Slot A data Previous access had REQ=1 and returned Slot A data ---> returns Slot A-D data Previous access had REQ=1 and returned Slot A-D data -> returns garbage Previous access had REQ=1 and returned garbage -------> returns Slot A-D data |
80 xx .. .. ;normal access |
8n xx .. .. ;access memory card in slot "n" (1..4) |
Bomberman World Breakout: Off the Wall Fun Circuit Breakers Crash Team Racing FIFA series soccer games Frogger Gauntlet: Dark Legacy Hot Shots Golf 2 & 3 NBA Live (any year) (up to 8 players with two multitaps) Need For Speed 3 Need For Speed 5 Poy Poy (4 players hitting each other with rocks and trees) Running Wild |
.------.
SCPH-1070 | | SCPH-111
(gray case) | | (white case)
(for PSX) | D | (for PSone)
| | .----------------.
cable | | cable .' D C '.
''--.. | C | '''--..__| |
\| | | |
.----------------' | '. A B .'
| | '----------------'
| |
| A B /
'---------------------'
|
7.5V Restrictions (rumble motors) --> See "PadInfoAct" config command |
| Controllers - Communication Sequence |
Send Reply Comment 01h Hi-Z Controller Access (unlike 81h=Memory Card access), dummy response 42h idlo Receive ID bit0..7 (variable) and Send Read Command (ASCII "B") TAP idhi Receive ID bit8..15 (usually/always 5Ah) MOT swlo Receive Digital Switches bit0..7 MOT swhi Receive Digital Switches bit8..15 --- transfer stops here for digital pad (or analog pad in digital mode) --- 00h adc0 Receive Analog Input 0 (if any) (eg. analog joypad or mouse) 00h adc1 Receive Analog Input 1 (if any) (eg. analog joypad or mouse) --- transfer stops here for analog mouse ---------------------------------- 00h adc2 Receive Analog Input 2 (if any) (eg. analog joypad) 00h adc3 Receive Analog Input 3 (if any) (eg. analog joypad) --- transfer stops here for analog pad (in analog mode) ------------------- --- transfer stops here for nonstandard devices (steering/twist/paddle) --- |
0-3 Number of following halfwords (01h..0Fh=1..15, or 00h=16 halfwords) 4-7 Controller Type (or currently selected Controller Mode) 8-15 Fixed (5Ah) |
xx00h=N/A (initial buffer value from InitPad BIOS function) 5A12h=Mouse (two button mouse) 5A23h=NegCon (steering twist/wheel/paddle) 5A31h=Konami Lightgun (IRQ10-type) 5A41h=Digital Pad (or analog pad/stick in digital mode; LED=Off) 5A53h=Analog Stick (or analog pad in "flight mode"; LED=Green) 5A63h=Namco Lightgun (Cinch-type) 5A73h=Analog Pad (in normal analog mode; LED=Red) 5A7xh=Dualshock2 (with variable number of inputs enabled) 5A79h=Dualshock2 (with all analog/digital inputs enabled) 5A80h=Multitap (multiplayer adaptor) (when activated) 5A96h=Keyboard (rare lightspan keyboard) 5AE3h=Jogcon (steering dial) 5AE5h=Fishing/Mode1 (fishing controller, ASC-0521TR2 Mode=1) 5AE8h=Keyboard/Sticks (rare homebrew keyboard/segasticks adaptor) 5AF3h=Config Mode (when in config mode; see rumble command 43h) FFFFh=High-Z (no controller connected, pins floating High-Z) |
| Controllers - Standard Digital/Analog Controllers |
___ ___ ___ ___
__/_L_\__ Analog Pad __/_R_\__ __/_L_\__ Digital Pad __/_R_\__
/ _ \--------------/ \ / _ \--------------/ \
| _| |_ | | /\ | | _| |_ | | /\ |
| |_ X _| |SEL STA| [] () | | |_ X _| | | [] () |
| |_| ___ ANALOG ___ >< | | |_| | SEL STA | >< |
|\______ / L \ LED / R \ ______/| |\_________/--------------\_________/|
| | Joy |--------| Joy | | | | | |
| / \___/ \___/ \ | | / \ |
\____/ \____/ \____/ \____/
|
__Halfword 0 (Controller Info)_______________________________________________ 0-15 Controller Info (5A41h=digital, 5A73h=analog/pad, 5A53h=analog/stick) __Halfword 1 (Digital Switches)______________________________________________ 0 Select Button (0=Pressed, 1=Released) 1 L3/Joy-button (0=Pressed, 1=Released/None/Disabled) ;analog mode only 2 R3/Joy-button (0=Pressed, 1=Released/None/Disabled) ;analog mode only 3 Start Button (0=Pressed, 1=Released) 4 Joypad Up (0=Pressed, 1=Released) 5 Joypad Right (0=Pressed, 1=Released) 6 Joypad Down (0=Pressed, 1=Released) 7 Joypad Left (0=Pressed, 1=Released) 8 L2 Button (0=Pressed, 1=Released) (Lower-left shoulder) 9 R2 Button (0=Pressed, 1=Released) (Lower-right shoulder) 10 L1 Button (0=Pressed, 1=Released) (Upper-left shoulder) 11 R1 Button (0=Pressed, 1=Released) (Upper-right shoulder) 12 /\ Button (0=Pressed, 1=Released) (Triangle, upper button) 13 () Button (0=Pressed, 1=Released) (Circle, right button) 14 >< Button (0=Pressed, 1=Released) (Cross, lower button) 15 [] Button (0=Pressed, 1=Released) (Square, left button) __Halfword 2 (Right joystick) (analog pad/stick in analog mode only)_________ 0-7 adc0 RightJoyX (00h=Left, 80h=Center, FFh=Right) 8-15 adc1 RightJoyY (00h=Up, 80h=Center, FFh=Down) __Halfword 3 (Left joystick) (analog pad/stick in analog mode only)__________ 0-7 adc2 LeftJoyX (00h=Left, 80h=Center, FFh=Right) 8-15 adc3 LeftJoyY (00h=Up, 80h=Center, FFh=Down) __Further Halfword(s) (Dualshock2 only, and only if enabled)_________________ 0-7 .. Analog Button (if enabled) (00h=Released, FFh=Max Pressure) 8-15 .. Analog Button (if enabled) (00h=Released, FFh=Max Pressure) .. .. .. |
...''''''''''...
____ .''________________''._____ ___ 00h
| .'' ''. |
|.' '.| ___ 10h
.' '.
:| |:
: | | : ___ 60h
.' | .''''''. | '.
: | .' '. | :
: | : : | : ___ 80h
: | : : | :
: | '. .' | :
'. | '......' | .' ___ A0h
: | | :
:| |:
'. .' ___ F0h
|'. .'|
|__'..______________________..'__| ___ FFh
. '.. ..' .
00h '''..........''' FFh
|
Big Circle --> Mechanically possible field of motion Square Area --> Digitally visible 8bit field of motion Small Circle --> Resting position when releasing the joystick |
SCPH-1150 Min=(00,00), Mid: (72..90,79..AC), Max=(FF,FF) at 25'C SCPH-1200 Min=(0E,0E), Mid: (6C..8A,75..79), Max=(ED,ED) at 16'C SCPH-110 Min=(11,11), Mid: (8A..9F,70..96), Max=(FD,FD) at 16'C |
ID is 5A53h (identifying itself as analog stick) (rather than analog pad) Left/right joy-buttons disabled (as for real analog stick, bits are always 1) Some buttons are re-arranged: bit9=L1 bit10=[] bit11=/\ bit12=R1 bit15=R2 |
| Controllers - Mouse |
__Halfword 0 (Controller Info)________________ 0-15 Controller Info (5A12h=Mouse) __Halfword 1 (Mouse Buttons)__________________ 0-7 Not used (All bits always 1) 8-9 Unknown (Seems to be always 0) (maybe SNES-style sensitivity?) 10 Right Button (0=Pressed, 1=Released) 11 Left Button (0=Pressed, 1=Released) 12-15 Not used (All bits always 1) __Halfword 2 (Mouse Motion Sensors)___________ 0-7 Horizontal Motion (-80h..+7Fh = Left..Right) (00h=No motion) 8-15 Vertical Motion (-80h..+7Fh = Up..Down) (00h=No motion) |
3D Lemmings Alien Resurrection Area 51 Ark of Time Atari Anniversary Edition Atlantis: The Lost Tales Breakout: Off the Wall Fun Broken Sword: The Shadow of the Templars Broken Sword II: The Smoking Mirror Clock Tower: The First Fear Clock Tower II: The Struggle Within Command & Conquer: Red Alert Command & Conquer: Red Alert - Retaliation Constructor (Europe) Die Hard Trilogy Die Hard Trilogy 2: Viva Las Vegas Discworld Discworld II: Missing Presumed...!? Discworld Noir Dune 2000 Final Doom Galaxian 3 Ghoul Panic Klaymen Klaymen: Neverhood no Nazon (Japan) Lemmings and Oh No! More Lemmings Monopoly Music 2000 Myst Neorude (Japan) Perfect Assassin Policenauts (Japan) Puchi Carat Quake II Railroad Tycoon II Rescue Shot Risk Riven: The Sequel to Myst RPG Maker Sentinel Returns SimCity 2000 Syndicate Wars Tempest 2000 (Tempest X3) Theme Aquarium (Japan) Transport Tycoon Warhammer: Dark Omen Warzone 2100 X-COM: Enemy Unknown X-COM: Terror from the Deep Z |
1x 3pin 4.00MHz "[M]4000A, 85 2" 2x 2pin button (left/right) 1x 8pin connector (to cable with shield and 7 wires) 1x 3pin "811, T994I" -----> XXX maybe Mitsumi PST994I System Reset? 2x 3pin photo transistor (black) ;\or so, no idea which one is 2x 2pin photo diode (transparent) ;/sender and which is sensor 1x 2pin electrolyt capacitor 16V, 10uF |
1x 32pin "(M), SC442116, FB G22K, JSAA815B" 1x 14pin "BA10339F, 817 L67" (Quad Comparator) 2x 3pin "LC" (amplifier for photo diodes) 1x 3pin "24-" (looks like a dual-diode or so) plus many SMD resistors/capacitors |
PSX.Controller.Pin1 JOYDAT ---- brown -- Mouse.Pin4 PSX.Controller.Pin2 JOYCMD ---- red -- Mouse.Pin3 PSX.Controller.Pin3 +7.5V ---- N/A PSX.Controller.Pin4 GND ---- orange -- Mouse.Pin7 GND (G) PSX.Controller.Pin5 +3.5V ---- yellow -- Mouse.Pin1 PSX.Controller.Pin6 /JOYn ---- green -- Mouse.Pin5 PSX.Controller.Pin7 JOYCLK ---- blue -- Mouse.Pin2 PSX.Controller.Pin8 /IRQ10 ---- N/A PSX.Controller.Pin9 /ACK ---- purple -- Mouse.Pin6 PSX.Controller.Shield --------- shield -- Mouse.Pin8 GND (SHIELD) |
__First Character____________________ 6 First Character Flag (1) 5 Left Button (1=Pressed) 4 Right Button (1=Pressed) 2-3 Upper 2bit of Vertical Motion 0-1 Upper 2bit of Horizontal Motion __Second Character___________________ 6 Non-first Character Flag (0) 5-0 Lower 6bit of Horizontal Motion __Third Character____________________ 6 Non-first Character Flag (0) 5-0 Lower 6bit of Vertical Motion __Fourth Character (if any)__________ 6 Non-first Character Flag (0) 5 Middle Button (1=Pressed) 4 Unused ??? 3-0 Wheel ??? |
"M" = Two-Button Mouse (aka "Microsoft" mouse) "3" = Three-Button Mouse (aka "Logitech" mouse) "Z" = Mouse-Wheel |
__First Byte_________________________ 7-3 First Byte Code (10000b) 2 Left? Button (0=Pressed) 1 Middle? Button (0=Pressed) 0 Right? Button (0=Pressed) __Second Byte________________________ 7-0 Horizontal Motion (X1) __Third Byte_________________________ 7-0 Vertical Motion (Y1) __Fourth Byte________________________ 7-0 Horizontal Motion (X2) __Fifth Byte_________________________ 7-0 Vertical Motion (Y2) |
| Controllers - Racing Controllers |
__Halfword 0 (Controller Info)_______________________________________________ 0-15 Controller Info (5A23h=neGcon) __Halfword 1 (Digital Switches)______________________________________________ 0-2 Not used (always 1) (would be Select, L3, R3 on other pads) 3 Start Button (0=Pressed, 1=Released) 4 Joypad Up (0=Pressed, 1=Released) 5 Joypad Right (0=Pressed, 1=Released) 6 Joypad Down (0=Pressed, 1=Released) 7 Joypad Left (0=Pressed, 1=Released) 8-10 Not used (always 1) (would be L2, R2, L1 on other pads) 11 R Button (0=Pressed, 1=Released) (would be R1 on other pads) 12 B Button (0=Pressed, 1=Released) (would be /\ on other pads) 13 A Button (0=Pressed, 1=Released) (would be () on other pads) 14-15 Not used (always 1) (would be ><, [] on other pads) __Halfword 2 (Right joystick) (analog pad/stick in analog mode only)_________ 0-7 Steering Axis (00h=Left, 80h=Center, FFh=Right) (or vice-versa?) 8-15 Analog I button (00h=Out ... FFh=In) (Out=released, in=pressed?) __Halfword 3 (Left joystick) (analog pad/stick in analog mode only)__________ 0-7 Analog II button (00h=Out ... FFh=In) (Out=released, in=pressed?) 8-15 Analog L button (00h=Out ... FFh=In) (Out=released, in=pressed?) |
_____ _ _ _____ ____
|__L__\_______/ || \_______/__R__| / \
/ _ namco || neGcon \ / \
| _| |_ || B | | |
| |_ X _| ....||.... II A | .... Rotation Axis ... | ... \|/
| |_| || I | |
| START || | \
| ________ || ________ | \__\
| / \_||_/ \ | /
\____/ \____/
|
_______ | namco | Halfword 1 (digital buttons): | | Bit3 Button A (0=Pressed) (aka neGcon Start button) | A B | Bit13 Button B (0=Pressed) (aka neGcon A button aka () button) | | Other bits (not used, always 1) | _ | Halfword 2 and 3 (analog inputs): | (_) | Steering Axis (00h..FFh) (as for neGcon) |_______| Analog I,II,L button values (not used, always 00h) |
____ ____ Halfword 1 (digital buttons): | / _ \ Bit12 Button (0=Pressed) (aka neGcon B button aka /\ button) |_ / (_) ) Other bits (not used, always 1) |_|___ /\ Halfword 2 and 3 (analog inputs): ____| |_ Steering Axis (00h..FFh) (as for neGcon) |__________| Analog I,II,L button values (not used, always 00h) |
__________________________
/ ____________________ \ Stick
/ / \ \ ___ Brakes Gas
/ ( ) \ ( ) II I
/ I \ / A \ \ / ___ ___
/ /\ II \____________MODE__/ B /\ \ | | | | |
| | \ L _ R / | | | |!!!|_|!!!|___
| | ) _| |_ MadCatz ( | |_|_ /|!!!| |!!!| /
| | | |_ X _| | | | | | / |___| |___| /
| | | |_| | | | / / =========== /
| | \ SEL STA / | | / / =========== /
\ \__/ ______________________ \__/ / / /_____________/
\____/ \____/_/
|___________________________|
|
____________________
/ ________________ \ ___ Stick Brakes Gas
/ / MC2 \ \ ( ) ___ ___
/ /__________________\ \ \ / | | | |
| A () _|_ I >< | | |!!!|_|!!!|___
| B /\ _ | _ II [] | | /|!!!| |!!!| /
___| L2 / \ STA / \ R2 |_|_ / |___| |___| /
/ \ / | SEL | \ / \ / =========== /
/ ____\ |___| |___| /____ \ / =========== /
/__/ \____________________/ \__\ /_____________/
|
Mode Buttons...................... Gas Brake Stick Wheel Digital >< [] () /\ L1 R1 L2 R2 L1 R1 >< () L1/R1 lt/rt Analog >< [] () /\ L1 R1 L2 R2 L3 R3 UP DN L1/R1 LT/RT Negcon I II A B L R L R L R I II up/dn Twist |
__Halfword 0 (Controller Info)___________________ 0-15 Controller Info (5AE3h=Jogcon in Jogcon mode) (ie. not Digital mode) halfword1: buttons: same as digital pad halfword2: 0 unknown (uh, this isn't LSB of rotation?) 1-15 dial rotation (signed offset since last read?) (or absolute position?) halfword3: 0 flag: dial was turned left (0=no, 1=yes) 1 flag: dial was turned right (0=no, 1=yes) 2-15 unknown |
___ ________ ___
__/_L_\__ / \ __/_R_\__
/ _ \ / LED MODE \-/ \
| _| |_ | SEL STA | /\ |
| |_ X _| | ________ | [] () |
| |_| | / \ | >< |
|\_________/\/ \/\__ ______/|
| | | JOGCON | | |
| | | DIAL | | |
| | \ / | |
| | \________/ | |
| | | |
| | | |
\_____/ \_____/
|
| Controllers - Lightguns |
| Controllers - Lightguns - Namco (GunCon) |
__Halfword 0 (Controller Info)___________________ 0-15 Controller Info (5A63h=Namco Lightgun; GunCon/Cinch Type) __Halfword 1 (Buttons)___________________________ 0-2 Not used (All bits always 1) 3 Button A (Left Side) (0=Pressed, 1=Released) ;aka Joypad Start 4-12 Not used (All bits always 1) 13 Trigger Button (0=Pressed, 1=Released) ;aka Joypad O-Button 14 Button B (Right Side) (0=Pressed, 1=Released) ;aka Joypad X-Button 15 Not used (All bits always 1) __Halfword 2 (X)_________________________________ 0-15 8MHz clks since HSYNC (01h=Error, or 04Dh..1CDh) __Halfword 3 (Y)_________________________________ 0-15 Scanlines since VSYNC (05h/0Ah=Error, PAL=20h..127h, NTSC=19h..F8h) |
ERROR: Sensed light during VSYNC (eg. from a Bulb or Sunlight). |
ERROR: no light sensed at all (not aimed at screen, or screen too dark). BUSY: no light sensed yet (when trying to read gun during rendering). |
666666h Minimum Gray 770000h Minimum Blue 007700h Minimum Green 000099h Minimum Red |
__Halfword 2 (X)_________________________________ 0-7 X-Coordinate (actual: see X-Offset) ;\with unspecified 8-15 X-Offset (00h: X=X-80, Nonzero: X=X-80+220) ;/dotclock? __Halfword 3 (Y)_________________________________ 0-7 Y-Coordinate (actual: Y=Y-25) (but then, max is only 230, not 263 ?) 8-15 Pad ID (uh, what id?) (reportedly too dark/bright error flag?) |
_-_______________________--_
-----> | namco \\\\ \ Namco G-Con 45 (light gray) (cinch)
sensor |............ .. .....\\\\...|_
|_ : :.. _____ _\
| O :__../ )))| (
\__________/ |_\____/| \
: : | |
: : | | NPC-103
A-Button (Left) Trigger | | SLPH-00034/SLEH-0007/SLUH-00035
B-Button (Right) |______|
|
| Controllers - Lightguns - Konami Justifier/Hyperblaster (IRQ10) |
Send 01h 42h 00h x0h 00h Reply HiZ 31h 5Ah buttons |
__Halfword 0 (Controller Info)___________________ 0-15 Controller Info (5A31h=Konami Lightgun; Timer/IRQ10 type) __Halfword 1 (Buttons) 0-2 Not used (All bits always 1) 3 Start Button (Left Side) (0=Pressed, 1=Released) ;aka Joypad Start 4-13 Not used (All bits always 1) 14 Back Button (Rear End) (0=Pressed, 1=Released) ;aka Joypad X-Button 15 Trigger Button (0=Pressed, 1=Released) ;aka Joypad []-Button |
__ ______ _
_|__\_______________/ ___ \ \ Konami Justifier/Hyperblaster (light green)
| _______________ __ / \ \ \
|__| _ _ _ _ |==| O| \O\ .... Back Button (Rear End)
|__:_:_:_:_:__ |___\__ / ( (
|_| ) \ : \ \
Trigger ...... \___/| :...|.|.... Start Button (Left Side)
| | |
| | | SLPH-00013/SLPH-00014/SLEH-0005/SLUH-00017
/ _|_|
\___--
|
IF NTSC then X=(Timer0-140)*0.198166, Y=Timer1 IF PAL then X=(Timer0-140)*0.196358, Y=Timer1 |
| Controllers - Lightguns - PSX Lightgun Games |
Area 51 (Mesa Logic/Midway) (IRQ10)
Crypt Killer (Konami) (IRQ10)
Die Hard Trilogy 1: (Probe Entertainment) (IRQ10)
Die Hard Trilogy 2: Viva Las Vegas (n-Space) (IRQ10/Cinch)
Elemental Gearbolt (Working Designs) (IRQ10/Cinch)
Extreme Ghostbusters: Ultimate Invasion (LSP) (Cinch)
Galaxian 3 (Cinch)
Ghoul Panic (Namco) (Cinch)
Gunfighter: The Legend of Jesse James (Rebellion) (Cinch)
Judge Dredd (Gremlin) (Cinch)
Lethal Enforcers 1-2 (Konami) (IRQ10)
Maximum Force (Midway) (IRQ10/Cinch)
Mighty Hits Special (Altron) (EU/JPN) (Cinch)
Moorhuhn series (Phenomedia) (Cinch)
Point Blank 1-3 (Namco) (Cinch)
Project Horned Owl (Sony) (IRQ10)
Rescue Shot (Namco) (Cinch)
Resident Evil: Gun Survivor (Capcom) (JPN/PAL versions) (Cinch)
Silent Hill (IRQ10) ("used for an easter egg")
Simple 1500 Series Vol.024 - The Gun Shooting (Cinch)
Simple 1500 Series Vol.063 - The Gun Shooting 2 (Cinch)
Snatcher (IRQ10)
Sporting Clays (Charles Doty) (homebrew with buggy source code) (IRQ10/Cinch)
Star Wars Rebel Assault II (IRQ10)
Time Crisis, and Time Crisis 2: Project Titan (Namco) (Cinch)
|
| Controllers - Configuration Commands |
42h "B" Read Buttons (and analog inputs when in analog mode) 43h "C" Enter/Exit Configuration Mode (stay normal, or enter) |
40h "@" Unused, or Dualshock2: Get/Set ButtonAttr?
41h "A" Unused, or Dualshock2: Get Reply Capabilities
42h "B" Read Buttons AND analog inputs (even when in digital mode)
43h "C" Enter/Exit Configuration Mode (stay config, or exit)
44h "D" Set LED State (analog mode on/off)
45h "E" Get LED State (and Type/constants)
46h "F" Get Variable Response A (depending on incoming bit) ("PadInfoAct")
47h "G" Get whatever values (response HiZ F3h 5Ah 00h 00h 02h 00h 01h 00h)
48h "H" Unknown (response HiZ F3h 5Ah 00h 00h 00h 00h 01h 00h)
49h "I" Unused
4Ah "J" Unused
4Bh "K" Unused (or MORE bytes from "PadInfoComb")
4Ch "L" Get Variable Response B (depending on incoming bit) (PadInfoMode)
4Dh "M" Get/Set RumbleProtocol
4Eh "N" Unused
4Fh "O" Unused, or Dualshock2: Set ReplyProtocol
|
____________________________ Normal Mode Commands ____________________________ |
Send 01h 42h 00h xx yy (00h 00h 00h 00h) (...) Reply HiZ id 5Ah buttons ( analog-inputs ) (dualshock2 buttons...) |
yy.bit0-7 ---> Left/Large Motor M1 (analog slow/fast) (00h=stop, FFh=fastest) xx.bit0 ---> Right/small Motor M2 (digital on/off) (0=off, 1=on) |
Send 01h 43h 00h xx 00h (zero padded...) (...) Reply HiZ id 5Ah buttons (analog inputs...) (dualshock2 buttons...) |
xx=00h Stay in Normal mode xx=01h Enter Configuration mode |
____________________________ Config Mode Commands ____________________________ |
Send 01h 42h 00h M2 M1 00h 00h 00h 00h Reply HiZ F3h 5Ah buttons analog-inputs |
Send 01h 43h 00h xx 00h 00h 00h 00h 00h Reply HiZ F3h 5Ah 00h 00h 00h 00h 00h 00h |
xx=00h Enter Normal mode (Exit Configuration mode) xx=01h Stay in Configuration mode |
Send 01h 44h 00h Led Key 00h 00h 00h 00h Reply HiZ F3h 5Ah 00h 00h Err 00h 00h 00h |
When Led=00h --> Digital mode, with LED=Off When Led=01h --> Analog mode, with LED=On/red When Led=02h..FFh --> Ignored (and, in case of dualshock2: set Err=FFh) |
When Key=00h..02h --> Unlock (allow user to push Analog button) When Key=03h --> Lock (stay in current mode, ignore Analog button) When Key=04h..FFh --> Acts same as (Key AND 03h) |
Send 01h 45h 00h 00h 00h 00h 00h 00h 00h Reply HiZ F3h 5Ah Typ Num Led Act Com 00h |
Typ: Controller Type (01h=PSX/Analog Pad, 03h=PS2/Dualshock2) Num: Number of Modes (usually 02h) (for cmd 4Ch) Led: Current Mode (usually 00h=Digital/LedOff, 01h=Analog/LedRed) Act: Number of Actuators (aka motors) (usually 02h) (for cmd 46h) Com: Number of Combiner Lists (usually 01h) (for cmd 47h) |
Send 01h 46h 00h ii 00h 00h 00h 00h 00h Reply HiZ F3h 5Ah 00h 00h Fnc Sub Siz Pwr |
Fnc InfoActFunc Function type (01h=Continuous-rotation vibration)
Sub InfoActSub Sub-type (rotation-speed when Fnc=01h: 1=Low, 2=High)
Siz InfoActSize Parameter data length
(0: 1 bit (ON/OFF only), 1 or greater: number of bytes)
Pwr InfoActCurr Maximum current drain (0Ah=Small, 14h=Big)
|
When ii=00h --> returns Fnc,Sub,Siz,Pwr = 01h,02h,00h,0ah ;small motor When ii=01h --> returns Fnc,Sub,Siz,Pwr = 01h,01h,01h,14h ;big motor When ii=Other --> returns Fnc,Sub,Siz,Pwr = all zeroes |
Send 01h 47h 00h ii 00h 00h 00h 00h 00h Reply HiZ F3h 5Ah 00h 00h 02h 00h 01h 00h |
ii = list number 02h = num entries in selected list? 00h,01h = entries in that list? (combining actuator 00h and 01h is allowed) |
Send 01h 4Ch 00h ii 00h 00h 00h 00h 00h Reply HiZ F3h 5Ah 00h 00h cc dd 00h 00h |
Send 01h 48h 00h ii 00h 00h 00h 00h 00h Reply HiZ F3h 5Ah 00h 00h 00h 00h ee 00h |
Send 01h 4xh 00h 00h 00h 00h 00h 00h 00h Reply HiZ F3h 5Ah 00h 00h 00h 00h 00h 00h |
| Controllers - Vibration/Rumble Control |
SCPH-1150 DualAnalog Pad with 1 motor ;-old rumble method SCPH-1200 DualAnalog Pad with 2 motors, PSX-design ;\new rumble method SCPH-110 DualAnalog Pad with 2 motors, PSone-design ;/ SCPH-10010 DualAnalog Pad with 2 motors, PS2/Dualshock2 ;-plus analog buttons Blaze Scorpion Lightgun with rumble ;\unknow how to control rumble Fishing controllers with rumble ;/ SCPH-1180 Analog Pad without rumble ;\unknow if there're config commands SCPH-1110 Analog Stick without rumble ;/for analog mode (probably not) |
_________________________________ Old Method _________________________________ |
Send 01h 42h 00h xx yy (00h 00h 00h 00h) Reply HiZ id 5Ah buttons ( analog-inputs ) |
xx --> must be 40h..7Fh (ie. bit7=0, bit6=1) ;\switches motor on yy --> must be 01h,03h,...,FDh,FFh (ie. bit0=1) ;/ |
_________________________________ New Method _________________________________ |
Send 01h 4Dh 00h aa bb cc dd ee ff ;<-- set NEW aa..ff values Reply HiZ F3h 5Ah aa bb cc dd ee ff ;<-- returns OLD aa..ff values |
00h = Map Right/small Motor (Motor M2) to bit0 of this byte 01h = Map Left/Large Motor (Motor M1) to bit0-7 of this byte 02h..FEh = Unknown (can be mapped, maybe for extra motors/outputs) FFh = Map nothing to this byte |
Send 01h 4Dh 00h 00h 01h FFh FFh FFh FFh ;enable new method (two motors) Send 01h 4Dh 00h FFh FFh FFh FFh FFh FFh ;disable motor control |
| Controllers - Analog Buttons (Dualshock2) |
Send 01h 40h 00h Idx Val 00h 00h 00h 00h ;<-- Set NEW Val, array[Idx]=Val Reply HiZ F3h 5Ah 00h 00h Val 00h 00h 00h ;<-- Old Val (or FFh when Idx>0Bh) |
Digital button sensitivity, or Analog button sensitivity, or Analog button bit-depth/conversion speed, or something else? |
Send 01h 41h 00h 00h 00h 00h 00h 00h 00h Reply HiZ F3h 5Ah FFh FFh 03h 00h 00h 00h |
Send 01h 41h 00h aa bb cc dd ee ff Reply HiZ F3h 5Ah 00h 00h 00h 00h 00h 00h |
- HighZ (always transferred) 1st byte - ID/Mode/Len (always transferred) 2nd byte - 5Ah (always transferred) 3rd byte 0 LSB of digital buttons (0=No, 1=Yes) 4th byte 1 MSB of digital buttons (0=No, 1=Yes) 5th byte 2 RightJoyX (0=No, 1=Yes) 6th byte 3 RightJoyY (0=No, 1=Yes) 7th byte 4 LeftJoyX (0=No, 1=Yes) 8th byte 5 LeftJoyY (0=No, 1=Yes) 9th byte 6 DPAD Right (0=No, 1=Yes) button 00h 10th byte 7 DPAD Left (0=No, 1=Yes) button 01h 11th byte 8 DPAD Uup (0=No, 1=Yes) button 02h 12th byte 9 DPAD Down (0=No, 1=Yes) button 03h 13th byte 10 Button /\ (0=No, 1=Yes) button 04h 14th byte 11 Button () (0=No, 1=Yes) button 05h 15th byte 12 Button >< (0=No, 1=Yes) button 06h 16th byte 13 Button [] (0=No, 1=Yes) button 07h 17th byte 14 Button L1 (0=No, 1=Yes) button 08h 18th byte 15 Button R1 (0=No, 1=Yes) button 09h 19th byte 16 Button L2 (0=No, 1=Yes) button 0Ah 20th byte 17 Button R2 (0=No, 1=Yes) button 0Bh 21st byte 18-39 Must be 0 (otherwise command is ignored) 40-47 Unknown (no effect?) |
Send 01h 41h 00h 03h 00h 00h 00h 00h 00h Digital buttons Send 01h 41h 00h 3Fh 00h 00h 00h 00h 00h Digital buttons + analog sticks Send 01h 41h 00h FFh FFh 03h 00h 00h 00h Enable all 18 input bytes |
00h Button released 01h..2Fh Normal (soft) pressure 30h..FEh Medium pressure FFh Hard pressure |
Analog=00h --> not pressed Analog=01h..FFh --> pressed (no matter if soft, medium, or hard pressure) |
https://gist.github.com/scanlime/5042071 - tech (=mentions unknown details) https://store.curiousinventor.com/guides/PS2/ - guide (=omits unknown stuff) |
| Controllers - Dance Mats |
D.D.R. Dance Dance Revolution 2nd Remix (and maybe whatever further games) |
US Version (white/black/red/blue) Handheld Version (blue/gray)
__________.---------.___________ _____/ MINI \_____
| \ / | | D.D.R. |
| SELECT '-------' START | |L1 L2 SEL STA R2 R1|
|------------.------.------------| | ___ ___ ___ |
| .''''. / \ .''''. | || X | | ^ | | O ||
| | \/ | | /\ | | .''. | | ||___| |___| |___||
| | /\ | | /..\ | | '..' | | | ___ .---. ___ |
| '....' '. || .' '....' | || < | |Stay | | > ||
| .-------. .''''''''. .-------. | ||___| |Cool!| |___||
|/ /| .' '. |\ \| | ___ '___' ___ |
| / |-- | | --| \ | || []| | v | | /\||
| \ |-- | Stay Cool! | --| / | ||___| |___| |___||
|\ \| '. .' |/ /| |___________________|
| '-------' '........' '-------' |
| .''''. .' || '. .''''. | Gothic Dance Mat (black/silver)
| | /\ | | \''/ | | |''| | | _.----------._
| | /__\ | | \/ | | |..| | | | \ SEL STA / | This one
| '....' \ / '....' | | '--------' | wasn't ever
'------------'------'------------' | .----------. | produced,
| | .''''. | | as cool as
European Version (pink/blue/yellow) | | | /\ | | | it could have
__________.---------.___________ | | | /..\ | | | been, the lame
| \ SEL STA / | | | '.||.' | | marketing
| '-------' | | +----------+ | people didn't
|----------.----------.----------| | | .''''. | | even think
| .''''. | .''''. | .''''. | | | | /\ | | | about it.
| | \/ | | | /\ | | | .''. | | | | | /..\ | | |
| | /\ | | | /..\ | | | '..' | | | | '.||.' | |
| '....' | '.||.' | '....' | | +----------+ |
|----------+-.. ..-+----------| | | .'||'. | |
| .'/|'. / '''' \ .'|\'. | | | | \''/ | | |
| | / |--|/ \|--| \ | | | | | \/ | | |
| | \ |--|\ /|--| / | | | | '....' | |
| '.\|.' \ .... / '.|/.' | | +----------+ |
|----------+-'' ''-+----------| | | .'||'. | |
| .''''. | .'||'. | .''''. | | | | \''/ | | |
| | /\ | | | \''/ | | | |''| | | | | | \/ | | |
| | /__\ | | | \/ | | | |..| | | | | '....' | |
| '....' | '....' | '....' | | '----------' '
'----------|----------|----------' '--------------'
|
| Controllers - Fishing Controllers |
Action Bass (Syscom Entertainment) (1999) (SLPH-00100) Bass Landing (ASCII/agetec) (1999) (SLPH-00100, SLUH-00063) Bass Rise, Fishing Freaks (Bandai) (1999) (BANC-0001) Bass Rise Plus, Fishing Freaks (Bandai) (2000) (BANC-0001, SLPH-00100) Breath of Fire IV (Capcom) (SLUH-00063) Championship Bass (EA Sports) (2000) (SLUH-00063) Fish On! Bass (Pony Canyon) (1999) (BANC-0001, SLPH-00100) Fisherman's Bait 2/Exiting Bass2 - Big Ol'Bass(Konami)(SLPH-00100,SLUH-00063) Fishing Club: (series with 3 titles) (have "headset-logo" on back?) Lake Masters II (1999) (Dazz/Nexus) (SLPH-00100) Lake Masters Pro (1999) (Dazz/Nexus) (BANC-0001, SLPH-00100) Let's Go Bassfishing!: Bass Tsuri ni Ikou! (Banpresto) (1999) (SLPH-00100) Matsukata Hiroki no World Fishing (BPS The Choice) (1999) (SLPH-00100) Murakoshi Seikai-Bakuchou Nihon Rettou (Victor) (SLPH-00100) Murakoshi Masami-Bakuchou Nippon Rettou:TsuriConEdition (1999) (SLPH-00100) Pakuchikou Seabass Fishing (JP, 03/25/99) (Victor) (SLPH-00100) Perfect Fishing: Bass Fishing (2000) (Seta) (yellow/green logo) Perfect Fishing: Rock Fishing (2000) (Seta) (yellow/green logo) Oyaji no Jikan: Nechan, Tsuri Iku De! (2000) (Visit) (BANC-0001, SLPH-00100) Reel Fishing II / Fish Eyes II (2000)(Natsume/Victor)(SLPH-00100, SLUH-00063) Simple 1500 Series Vol. 29: The Tsuri (2000) (yellow/green logo) Suizokukan Project: Fish Hunter e no Michi (1999)(Teichiku)(SLPH-00100) Super Bass Fishing (1999) (King) (BANC-0001, SLPH-00100, yellow/green logo) Super Black Bass X2 (2000) (Starfish) (SLPH-00100) Tsuwadou Keiryuu Mizuumihen (Best Edition)(2000) (ASCII PS1+PS2 controllers?) Tsuwadou Seabass Fishing (PlayStation the Best) (1999) (Oz Club) (SLPH-00100) Uki Uki Tsuri Tengoku Nagami/Uokami Densetsu Oe (2000) (Teichiku)(SLPH-00100) Umi no Nushi Tsuri-Takarajima ni Mukatte (1999)(Victor)(BANC-0001,SLPH-00100) Winning Lure (Hori) (2000) (for Hori HPS-97 controller) AKA HPS-98 ? |
ASCII ASC-0514TR aka ASCII SLPH-00100 (silver) ASCII ASC-0521TR2 (silver) (similar to SLPH-00100, with additional hardware) agetec SLUS-00063 (silver) (US version of ASCII's SLPH-00100 controller) Bandai BANC-0001 (dark gray/blue) (has less buttons than ASCII/agetec) Interact Fission (light gray/blue)(similar to ASCII/agetec, 2 extra buttons?) Naki (transparent blue) (looks like a clone of the ASCII/agetec controllers) SAMMY SMY-0506FS (looks same as ASC-0521TR2) SAMMY SMY-0511FS (shortened joystick, rearranged /\,[],(),>< buttons) Hori HPS-97/HPS-98 (black/gray) (a fishing rod attached to a plastic fish) |
___
__|___|__
_| |_ _ __
| | | | | |=|__| <--- crank handle
| | SEL STA | | | |
| | | |---| \ ASCII SLPH-00100
| \ / |---| / agetec SLUH-00063
/ L1 R1 \ | | __
| L2 .---. R2 | |_|=|__|
| | joy | |
| |stick| | <------- analog thumb controlled joystick
| /\ '---' >< |
| [] () |
\ ASCII /
'.___________.' \___ 10 buttons (SEL,STA,L1,L2,R1,R2,/\,[],(),><)
\ _____ /
| | Note: many (not all) agetec controllers
| | have the >< and () buttons exchanged
| |
| | Aside from the crank/buttons/joystick,
| | the controller reportedly contains:
| | some sort of motion sensors?
| | some kind of rumble/vibration?
| |
'.___.'
'--...___ cable
|
___
| |
__|___|__ .--------------- star handle
.''| |''. | _ __
/ | | \ _ | |=|__| <--- crank handle
| ' ' | | | | |
| 1 . 2 |-| |-| \ ASCII ASC-0521TR2
| L1 R1 |-| |-| /
| L2 SEL STA R2 | |_| | | __
| | |_|=|__|
| /\ .---. >< |
| | joy | | <------- analog thumb controlled joystick
| [] |stick| () | (with L3 button)
\ '---' /
'.___________.' \___ 10 buttons (SEL,STA,L1,L2,R1,R2,/\,[],(),><)
\ _____ / and 3-position switch (with positiona 1 . 2)
| |
| | Note: SMY-0511FS has a short joystick stump,
| | and rearranged buttons:
| | /\ left of joystick
| | [] right of joystick
| | () below of joystick
| | >< near index finger (on bottom side of case)
|ASCII|
'.___.'
'--...___ cable
|
___
__|___|__ .--------------- star handle
_| | | _ __
| .---. |\ _ | |=|__| <--- crank handle
|| joy | | | | | | |
||stick| | |-| |-| \
| '---' | |-| |-| /
/ \ | \|_| | | __
| | ... | | |_|=|__|
| | : : | ()|
| |O :___: O| | <--- two buttons: () and ><
| |- |___| -| ><| and some slide switch with I and 0 positions?
| | | |
\ | BANDAI | / unknown if the joystick is digital or analog
'._\_______/_.'
| | unknown if there are motion sensors and/or rumble
'. .'
| |
| |
| |
| |
| |
| |
| |
'.___.'
'--...___ cable
|
....----------------O
.'' \ \ HPS-97 (controller bundled with game)
_:_ \ \ HPS-98 (controller only, for HPS-96 game)
__|___|__ short \
_| |_ elastic \
| | pole \
| | \ <--- string (from pole to
| SW? | _ __ \ reel inside of fish)
/ \ | |=|__| \
| .---. | | | \
| ( ) | joy | |--| \ \ ___
| |stick| |--| / \ / /
| ( ) '---' | | | __ \ ...---''''''--. /|
| | |_|=|__| <--- crank \ ' '/ |
\ ( ) ( ) / handle '..| |.
'.___________.' |__________________| :
\ / \ plastic fish :
| | joystick, (presumable some heavy :
| | four buttons, stationary thing that :
| | and a switch? rests on floor) :
| | (presumably with :
| | motor-driven reel?) :
| | :
| | the two cables do probably connect :
| | to both of the PSX controller slots :
'.___.' cable 2 ---'
'--...___ cable 1
|
| Controllers - Fishing Controllers - ASC-0521TR2 |
Digital Joypad mode (power-up default)
Mode0 (".")
Mode1 ("1")
Mode2 ("2")
|
__Halfword 0 (Controller Info)_______________________________________________ 0-15 Controller Info (5A41h=digital) __Halfword 1 (Digital Switches)______________________________________________ 0-15 Buttons (with Joystick mapped as DPAD) (and L3 mapped to () button) |
__Halfword 0 (Controller Info)_______________________________________________ 0-15 Controller Info (5A73h=analog/pad) __Halfword 1 (Digital Switches)______________________________________________ 0-15 Buttons (with Joystick mapped as DPAD) (and L3 mapped to () button) __Halfword 2 (Right joystick) (analog pad/stick in analog mode only)_________ 0-7 adc0 Fixed (always 80h=Center) 8-15 adc1 Reel Wheel (00h=Backward, 80h=Stopped, FFh=Forward) __Halfword 3 (Left joystick) (analog pad/stick in analog mode only)__________ 0-7 adc2 Pendulum X (00h=Left, 80h=Center, FFh=Right) 8-15 adc3 Pendulum Y (00h=Down, 80h=Center, FFh=Up) |
Byte00.bit0 Small vibration motor (0=Off, 1=On) Byte01.bit7-0 Big vibration motor (0=Off, FFh=Max) |
__Halfword 0 (Controller Info)_______________________________________________ 0-15 Controller Info (5AE5h=custom/fishing) __Halfword 1 (Digital Switches)______________________________________________ 0-15 Buttons (with DPAD bits always released) (and L3 mapped as such) __Halfword 2 (Right joystick) (analog pad/stick in analog mode only)_________ 0-7 adc0 Fixed (always 80h=Center) 8-15 adc1 Fixed (always 80h=Center) __Halfword 3 (Left joystick) (analog pad/stick in analog mode only)__________ 0-7 adc2 Joystick X (00h=Left, 80h=Center, FFh=Right) 8-15 adc3 Joystick Y (00h=Up, 80h=Center, FFh=Down) __Halfword 4 0-7 adc4 3-Axis sensor (00h, 80h=Center, FFh) 8-15 adc5 3-Axis sensor (00h, 80h=Center, FFh) __Halfword 5 0-7 adc6 3-Axis sensor (00h, 80h=Center, FFh) 8-15 adc7 Reel Wheel (00h=Stopped, FFh=Forward) |
Byte00.bit0 Small vibration motor (0=Off, 1=On) Byte01.bit7-0 Big vibration motor (0=Off, FFh=Max) |
__Halfword 0 (Controller Info)_______________________________________________ 0-15 Controller Info (5A73h=analog/pad) (with DPAD LT/RT used as extra ID) __Halfword 1 (Digital Switches)______________________________________________ 0-15 Buttons (UP/DN=Star wheel, LT/RT=Stuck, and L3 mapped as such) __Halfword 2 (Right joystick) (analog pad/stick in analog mode only)_________ 0-2 adc Joystick Y (upper 3bit) (00h=Up, 04h=Center, 07h=Down) 3-7 adc Joystick X (5bit) (00h=Left, 10h=Center, 1Fh=Right) 8 adc Pendulum Y (upper 1bit) (00h=Down, 10h=Center, 1Fh=Up) 9-13 adc Pendulum X (5bit) (00h=Left, 10h=Center, 1Fh=Right) 14-15 adc Joystick Y (lower 2bit) (to be merged with upper 3bit) __Halfword 3 (Left joystick) (analog pad/stick in analog mode only)__________ 0-3 adc 3-Axis sensor Y (4bit) (00h, 08h=Center, 0Fh) 4-7 adc Pendulum Y (lower 4bit) (to be merged with upper 1bit) 8-11 adc Reel Wheel (..bit?) (00h=Stopped, 0xh=Forward) 12-15 adc 3-Axis sensor X (4bit) (00h, 08h=Center, 0Fh) |
Byte00.bit0 Small vibration motor (0=Off, 1=On) Byte01.bit7-4 Big vibration motor (0=Off, 0Fh=Max) Byte01.bit3-0 Band brake motor (0=Off, 0Fh=Max) |
Mode 0: Works Mode 1: Stays in analog mode (if analog mode was enabled) Mode 2: Works, but DPAD stays stuck at UP/DN=Released, LT/RT=Pressed) |
| Controllers - Mahjong and Card Game Controllers |
HPS-90 Wai Wai Jansou CDROM HPS-91 Wai Wai Jansou Set (CDROM with two Jansou controllers) HPS-92 Wai Wai Jansou Controller (clear/gray) HPS-93 Wai Wai Jansou Controller (clear/blue) HPS-94 Wai Wai Jansou Controller (..unknown color..) HPS-95 Wai Wai Jansou Controller (..unknown color..) HPS-116 Wai Wai 3-nin Uchi Mahjong Set (CDROM with two Jansou Controllers) ______________________________________ | | | .-----------------------------. | | | ####################### | | LCD display | |__________.---------.________| | with DPAD and nine buttons | _ | | _| |_ SEL START O | | |_ _| _ _ O O | | |_| (_) (_) O | |__________B_________________A___O_____| |
HPS-104 Wai Wai Trump Taisen CDROM HPS-105 Wai Wai Trump Taisen Set (CDROM with two Trump Controllers) HPS-106 Wai Wai Trump Taisen Controller ______________________________________ | | | .-----------------------------. | | | ####################### | | LCD display | |__________.---------.________| | with six buttons | | | _ SEL START _ | | < (_) _ _ (_) A | | (_) > (_) B | |______________________________________| |
| Controllers - I-Mode Adaptor (Mobile Internet) |
| Controllers - I-Mode Adaptor - Controller Port Commands |
Small Control Messages (sent/received via command 14h, 15h, or 18h) Large 80h-byte Data Blocks (sent/received via command 14h) |
Send 41h 11h (0) (0) (0) Reply 00h 5Ah 8Eh Stat[2] |
Send 41h 12h NewX NewY (0) (0) (0) Reply 00h 5Ah 6Fh NewX NewY Stat[2] |
X = usually/always 00h (but can be 00h..04h) (00h..04h) Y = usually 03h=UsedBeforeShutdown, or 06h=UsedAfterWakeup (00h..FFh) |
Always 6Fh, followed by echoing the (newly written) parameter values (whereas, X=05h..FFh gets forcefully changed to X=00h) |
Send 41h 13h 0Fh (0) (0) Reply 00h 5Ah C0h Stat[2] |
Usually/always 0Fh ;XXX but in browser: initially 03h, later 0Fh |
Send 41h 14h Data[80h] MsgLen Msg[19h] Chksum (0) (0) Reply 00h 5Ah Data[80h] MsgLen Msg[19h] Chksum Stat[2] |
Data[80h] = Data Stream bytes (see below) Msglen = 0..2 ;Hamster Club-i uses only 0..1 for sending though Msg[2] = Message bytes Chksum = Above 83h bytes XORed together |
00h 1 1st Snippet Length (1..58h, plus bit7=LastSnippetFlag) ;\ 01h .. 1st Snippet Data ; ... 1 2nd Snippet Length (1..58h, plus bit7=LastSnippetFlag) ; ... .. 2nd Snippet Data ; if any ... 1 3rd Snippet Length (1..58h, plus bit7=LastSnippetFlag) ; ... .. 3rd Snippet Data ; ... .. etc. ;/ ... 1 End marker (00h) (aka snippet length zero) ;\end ... .. Unused padding ;/ 7Fh 1 Flags (bit0=PhoneBusy) ;-flags |
Send 41h 15h MsgLen Msg[19h] Chksum (0) (0) Reply 00h 5Ah MsgLen Msg[19h] Chksum Stat[2] |
Msglen = 0..19h Msg[19h] = Message bytes Chksum = Above 1Ah bytes XORed together |
Send 41h 16h MODE (0) (0) Reply 00h 5Ah 4Ah Stat[2] |
MODE = Indicates if Command 14h or 15h will be used (0=Cmd15h, 1=Cmd14h) |
Send 41h 17h FLAG (0) (0) Reply 00h 5Ah 56h Stat[2] |
bit0 Clear Send queue ;\clear queue inside of PSX (probably implies bit1 Clear Recv queue ;/request to also clear queue in Fujitsu chip) bit2 Ack/swap/apply/discard TX block number? ;\for 80h-byte data blocks bit3 Ack/swap/apply/discard RX block number? ;/ bit4 Reset/Shutdown (changes Stat[2] to 00h,00h) |
Send 41h 18h MsgLen Msg[1] (0) (0) Reply 00h 5Ah MsgLen Msg[1] Stat[2] |
| Controllers - I-Mode Adaptor - Connect Messages |
85h,01h,01h,02h,plain_random[8],00h,03h,00h,00h,01h ;-AUTH_START_REQ 85h,01h,04h,02h,crypted_random[8] ;-AUTH_CRYPT_REQ 85h,01h,05h,02h ;-AUTH_DONE 85h,01h,06h ;-DEAUTH_REQ 8Eh ;<-- is that same 8Eh as in Keitai Eddy? ;-AUTH_PING_REQ F2h,00h,01h,02h,08h,00h,00h,00h,00h ;-GW_CONNECT_REQ F2h,00h,01h,02h,00h,00h,00h,00h,00h ;-GW_DISCONNECT_REQ F2h,00h,01h,02h,01h,00h,00h,00h,00h ;used in browser ;-GW_PING_REQ A8h ;<-- used in the browser, after entering a 4-digit PIN number |
38h,02h ;return 06h ;-Wokeup ;\ 85h,01h,02h,x,x,H,L,dat(HL) ;return 02h ;-AUTH_CRYPT_ACK ; 85h,01h,03h,data[3] ;return 01h ;-AUTH_error/busy? ; 85h,01h,04h,x,dat(8),H,L,dat(HL) ;return 03h ;-AUTH_START_ACK ; STATE 85h,01h,07h ;return 04h ;-DEAUTH_ACK ; F1h,00h,03h,x,H,L,dat(HL) ;return 05h,[0Ah] ;state [0Ah]=1=okay? ; F2h,00h,02h,x,08h,x,H,L,dat(HL+4) ;return 0Ah ;-GW_CONNECT_ACK ; F2h,00h,02h,x,00h,x,H,L,dat(HL+4) ;return 0Bh ;-GW_DISCONNECT_ACK ; F2h,00h,02h,x,01h,x,H,L,dat(1+HL) ;return 0Dh ;-GW_PING_ACK ; F2h,00h,02h,x,09h,x,H,L,dat(1+HL) ;return 0Dh ;-GW_PING_ACK, too? ; F2h,00h,03h,.. ;return 0Ch ;ready to GW_CONNECT ? ;/ 21h,... ;used by browser ;return 14h, modus=0 ;\ 80h ;not implemented ;return 1Fh, modus=0 ; 81h ;return 20h, modus=0 ; 8Ah,.. ;not implemented ;return 21h, modus=0 ; 8Bh,.. ;return 22h, modus=0 ; ? A4h,.. ;return 18h, modus=0 ; A5h,.. ;return 0, modus=40h ; A6h ;return 17h, modus=0 ; A7h ;return 16h, modus=0 ; AAh,.. ;\multiple uses ;return 15h ; AAh,.. ; depending on ;return 0, modus=0 ; AAh ;/state/flags ;return 23h, modus=0 ;AUTH_PING_ACK ; E0h,.. ;\terminated ;return 0, set modus and 40h or 1 ; E6h,.. ;/by AAh ? ;return 0, set modus and 50h or 2 ;/ C0h..CFh ;ignored ;\ D1h,... ;whatever ; data? 00h..0Fh ;data bytes? ;/ |
C0h..CFh 19h missing 21h 35h,x, ... , endflag(bit0) 38h,data[1] 61h,data[10h] 64h,01h 64h,02h,data[1] 64h,03h,data[6] 64h,04h 64h,06h 64h,07h 64h,0Dh,data[24h] 64h,0Eh, ... , endflag(bit0) 6Ch,01h 6Ch,02h,data[1] 6Ch,03h 6Ch,06h,data[7+1],H,L,data[HL*2],data[5],,H,L,data[HL*2],H,L,data[HL*2] ;? 6Ch,07h 6Ch,08h 6Ch,0Ah,data[5+1+3],H,L,data[HL*2],H,L,[HL*2] ;? 6Ch,0Ch 6Ch,0Dh,data[24h] 6Ch,0Eh, ... , endflag(bit0) 6Eh,data[1] 80h 81h 85h,x,01h,data[0Eh] 85h,x,02h,x,x,H,L,data[HL] 85h,x,03h,data[3] 85h,x,04h,00h,data[9],H,L,data[HL] 85h,x,04h,02h,data[8] 85h,x,05h,data[1] 85h,x,07h 86h,data[1] 87h missing 8Ah missing 8Bh A3h missing A4h missing A5h A6h A7h missing AAh (but may work as breakout code and ping_ack?) missing D1h (but may work as breakout code?) missing E0h ;with end_code=AAh E2h,x, ... ,AAh ;with end_code=AAh missing E6h ;with end_code=AAh E7h,data[2] E8h,x,x,N,data[N*2] F1h,x,03h,x,H,L,data[HL] F1h,x,04h,data[2] F2h,x,02h,x,00h,x,H,L,data[HL+4] F2h,x,02h,x,08h,x,H,L,data[HL+4] F2h,x,02h,x,01h,x,H,L,data[HL+1] F2h,x,02h,x,09h,x,H,L,data[HL+1] F2h,x,03h,x,x,H,L,data[HL] |
x = don't care for length (but actual code may insist on specific values) H,L = high/low nibbles of HL length value missing = not handled in length table (but exists in code) |
| Controllers - I-Mode Adaptor - Transfer Messages |
01h,BBB*20h+nnn*2,01h,<TLP_MESSAGE>,crc16 req=00xh ;-TLP messages 01h,BBB*20h+01h,crc16 --> error ? ;\ 0xh,BBB*20h+x5h,crc16 --> error ? req=020h ; 01h,BBB*20h+09h,crc16 --> error_wrong_blkno_lsb req=040h ; handshake 01h,BBB*20h+11h,crc16 --> error_no_reply ; errors 03h,BBB*20h+01h,crc16 --> transfer_timer req=010h ; 03h,BBB*20h+xxh,crc16 --> error ? ;/ 0xh,1Fh,crc16 --> unknown req=400h ;\ 01h,3Fh,crc16 --> GW_CONNECT_REQ req=080h ; 01h,53h,crc16 --> GW_DISCONNECT_REQ req=100h ; control 0xh,73h,crc16 --> unknown req=200h ; 03h,87h,0xh,e,a,crc16 --> blkno (expected,actual) req=800h ;/ |
x1_bbb0nnn0_00000001 event=0Fh (matching blkno) ;\ x1_bbb0xxx0 event=10h (wrong blkno in bit1-3) ; TLP x1_bbb1nnn0_00000001 event=11h (matching blkno) ; messages x1_bbb1xxx0 event=12h (wrong blkno in bit1-3) ;/ x1_bbb00001 (aka 01h) event=14h ;\ x1_bbb00101 (aka 05h) event=17h ; x1_bbb01001 (aka 09h) event=1Ah ; handshake 01_bbb10001 (aka 11h) event=13h ; errors? 11_bbb10001 (aka 11h) event=15h ; 01_bbb10101 (aka 15h) event=16h ; 11_bbb10101 (aka 15h) event=18h ; 01_bbb11001 (aka 19h) event=19h (error_wrong_blkno_lsb_ack?); 11_bbb11001 (aka 19h) event=1Bh ; x1_bbb0xx01 (other) event=27h (invalid) ; 01_bbb1xx01 (other) event=26h (invalid) ; 11_bbb1xx01 (other) event=28h (invalid) ;/ 01_00001111 (aka_0Fh) event=23h (force disconnect?) ;\ 11_00001111 (aka 0Fh) event=27h (invalid) ; 01_00011111 (aka 1Fh) event=22h (GW_DISCONNECT_ACK) ; 11_00011111 (aka 1Fh) event=26h (invalid) ; control x1_00101111 (aka 2Fh) event=1Eh ; 01_00111111 (aka 3Fh) event=26h (invalid) ; 11_00111111 (aka 3Fh) event=1Fh ; x1_01000011 (aka 43h) event=20h ; 11_01010011 (aka 53h) event=21h ; 01_01010011 (aka 53h) event=26h (invalid) ; x1_01100011 (aka 63h) event=1Dh ; 01_01110011 (aka 73h) event=1Ch (GW_CONNECT_ACK) ; 11_01110011 (aka 73h) event=None/07h/08h (error, ignore/retry/giveup) 01_10000111 (aka 87h) event=25h (force disconnect?) ; 11_10000111 (aka 87h) event=27h (invalid) ; 01_10010111 (aka 97h) event=24h (force disconnect?) ; 11_10010111 (aka 97h) event=26h (invalid) ; x1_xxx0xx11 (other) event=27h (invalid) ; 01_xxx1xx11 (other) event=26h (invalid) ; 11_xxx1xx11 (other) event=28h (invalid) ;/ xxxxxxxx (other) ignored (1st byte other than 01h or 03h or 10h+x) xxx1xxx0 ignored single-byte reply, do NOT reload timeouts xxxxxxxx (other) ignored single-byte reply, but DO reload timeouts xxxxxxxx_xxxxxxxx reload timeouts (on any reply with 2 or more bytes) |
| Controllers - I-Mode Adaptor - TLP Transport Layer |
000h 3 Send Command (01h,BBB*20h+NNN*2,01h) (imode/cable-specific command) 003h .. TLP Packet (contains Checksum, Message Type, ..., Data) ... 2 CRC16_CCITT_REVERSE ;little endian, initial=FFFFh, result XOR FFFFh |
bit0 must be 0 (indicates TLP_messages) bit1-3 outgoing block number (increased after each message, 0 at gw_connect) bit4 unknown (usually 0) bit5-7 remote block number (from bit1-3 of remote message) (..plus 0..1 ?) |
bit4-7 unused (usually zero) bit3 allowed in Type=10h bit2 unknown, must be set for Type=11h bit1 allowed in Type=11h,20h,21h,30h (and implied for Type=31h) bit0 allowed in Type=10h,11h,20h,30h |
000h 2 Checksum (sum of following 16bit values plus carry-outs, XOR FFFFh)
002h 1 Message Type (10h)
003h 1 Service Identifier (0Ah) (whatever, maybe means 0Ah=HTTP)
004h 1 Logical Number (01h) (bit0-6=Connection, bit7=Flag?)
005h 1 Communication Mode (01h) (bit0-1=Mode, bit2-7=Value?)
006h 1 Communication Parameters[0] (01h)
007h 1 Communication Parameters[1] (01h)
008h 1 Communication Parameters[2] (8Ch) max packet size/10, 8Ch=1400 byte
009h 1 Communication Parameters[3] (01h)
00Ah 1 Communication Parameters[4] (FFh) timeout/1000 or so?
00Bh 1 Communication Parameters[5] (00h)
00Ch 1 Communication Parameters[6] (0Ah)
00Dh 1 Logic State (09h) (indicates presence of below optional components)
... 2 Operator Specific Information (4821h) ;-when bit3=1 ;\
... (1) Requested Segment Number (-) ;-when bit1=1 ;
... 1 Transmit Segment Number+Flags (C0h) ;\ ; Optional
... 2 Transmit Length (1..1400) (03B7h) ; when bit0=1 ;
... LEN Transmit Data ("POST http://ne-net.com/"..);/ ;/
|
000h 2 Checksum
002h 1 Message Type (11h)
003h 1 Logical Number (01h)
004h 1 Communication Mode (01h) ;\
005h 1 Communication Parameters[0] ;
006h 1 Communication Parameters[1] ; these can/may/should use same
007h 1 Communication Parameters[2] ; values as in message type 10h
008h 1 Communication Parameters[3] ;
009h 1 Communication Parameters[4] ;
00Ah 1 Communication Parameters[5] ;
00Bh 1 Communication Parameters[6] ;/
00Ch 1 Logic State (07h) (indicates presence of below optional components)
... (2) Operator Specific Information (-) ;-when bit3=1 ;\
... 1 Requested Segment Number (0..3Fh) ;-when bit1=1 ;
... 1 Transmit Segment Number (0..3Fh+Flags) ;\ ; Optional
... 2 Transmit Length (big-endian) ; when bit0=1 ;
... .. Transmit Data ("HTTP/1.0 200 OK"..) ;/ ;/
|
000h 2 Checksum 002h 1 Message Type (12h) 003h 1 Logical Number 004h 1 Disconnect Reason (00h..08h) |
000h 2 Checksum 002h 1 Message Type (20h/21h) 003h 1 Logical Number 004h 1 Disconnect Reason (00h..08h) (0=Okay/Transfer completed) 005h 1 Logic State (usually 00h) ... (2) Operator Specific Information ;-when bit3=1 ;\ ... 1 Requested Segment Number (0..3Fh) ;-when bit1=1 ; Optional ... 1 Transmit Segment Number (0..3Fh+Flags) ;\ ; usually ... 2 Transmit Length ; when bit0=1 ; none such ... .. Transmit Data ;/ ;/ |
000h 2 Checksum 002h 1 Message Type (30h) 003h 1 Logical Number 004h 1 Logic State (usually 03h) (must be xxxx0x11 binary) 005h 1 Requested Segment Number (0..3Fh) ;\ 006h 1 Transmit Segment Number (0..3Fh+Flags) ; always present because 007h 2 Transmit Length ; above bit1,0 are both set 009h .. Transmit Data ;/ |
000h 2 Checksum 002h 1 Message Type (31h) 003h 1 Logical Number 004h 1 Requested Segment Number (0..3Fh) (alike as if Logic State bit1=1) |
000h 2 Checksum 002h 1 Message Type (40h) 003h 1 Service Identifier (must be 09h, unlike as in Message Type 10h) 004h 1 Communication Mode/Logical Number (bit0-1=Mode, bit2-7=Connection) 005h 2 Data Length 007h .. Data (whatever info) |
000h 2 Checksum 002h 1 Message Type (41h) 003h 1 Communication Mode/Logical Number (bit0-1=Mode, bit2-7=Connection) |
000h 2 Checksum 002h 1 Message Type (50h) 003h 1 Logical Number 004h 1 Transmit Segment Number 005h 1 Transmit SmallData Length (max 5 bytes or so?) 006h .. Transmit SmallData[..] ;flagbits! (per Communication Mode 6bit) |
000h 2 Checksum 002h 1 Message Type (60h) 003h 1 Logical Number |
| Controllers - I-Mode Adaptor - HTTP Requests/Replies |
HTTP/1.0 ascii headers (1991) HTTP/1.1 ascii headers, with Host: domain (1997) HTTP/2 binary headers for faster transfers (2015) |
GET http://www.mydomain.net/index.html HTTP/1.0 |
GET /index.html HTTP/1.0 Host: www.mydomain.net |
GET request downloading a HTM file, or GIF file, or anything else POST same as GET, with additional parameters (in request.body) HEAD same as GET, but returns only response.header (without response.body) |
POST http://ne-net.com/hc/i/ps/ArenaParty.cgi HTTP/1.0 ;-request User-Agent: DoCoMo/1.0/ex_ps1302 Content-type: application/x-www-form-urlencoded ;\for POST body Content-Length: 789 ;/ <blank line> ;-end of header uid=NULLGWDOCOMO&val=%0A%0A%...%CD%13%03%07 ;-POST body |
HTTP/1.0 200 OK ;-status code
Content-Length: 123 ;\for body
Content-Type: text/html ;/
<blank line> ;-end of header
<HTML><HEAD><TITLE>Hello</TITLE></HEAD>...</HTML> ;-file body
|
The PSX browser does support HTM, TXT, GIF The PSX browser does support <TABLE> The PSX browser does not support JPG (and certainly no STJ or PNG) The PSX browser seems to ignore things like <B>, <HR>, <FONT SIZE> TXT/HTM/GIF loading aborts after 10K (10240 bytes) in http response.body |
| Controllers - I-Mode Adaptor - Software |
RedirectURL == http://docomo.ne.jp/mn/ == http://problemkaputt.de/ |
Sxxx-????? Doko Demo Issyo (PlayStation the Best release only) (Sony) 2000 Sxxx-????? Doko Demo Issyo Deluxe Pack (Bomber eXpress/Sony) 2001 SLPS-03266 Hamster Club-I (Jorudan) 2002 SCPS-10141 iMode mo Issyo: Dokodemo Issho Tsuika Disc (Bomber/Sony) 2001 SLPS-02717 Keitai Eddy (iPC) (phone cable connects to SIO port) 2000 SLPS-03121 Komocchi (Victor) 2001 SLPM-87151 Mobile Tomodachi (Hamster) 2002 SLPS-03321 Motto Trump Shiyouyo! i-Mode de Grand Prix (Pure Sound) 2002 SLPM-86837 One Piece Mansion (Capcom) (japanese version only) 2001 PBPX-95013 Keitai Henshuu (CompactNetFront browser) (in SCPH-10180K kit) 2001 |
| Controllers - I-Mode Adaptor - Misc |
PSX old Keitai Eddy cable: SIO Connector --------- PCB (in middle of cable) --------- I-Mode connector PSX new standard cable (SCPH-10180): Controller Port (with PCB inside of plug) ---------------- I-Mode connector PC Version (Data Link Cable SO003): COM port ------ unknown hardware ------------------------- I-Mode connector PC Version (USB Data Link Cable F001): USB port ------ unknown hardware ------------------------- I-Mode connector |
has several ASCII strings: 800108BC " HTTP/1.0",0Dh,0Ah,"User-Agent: ",00h 800108D4 0Dh,0Ah,"Content-type: text/plain",0Dh,0Ah,"Content-Length: ",00h 80010904 "Content-Length: ",00h 80013C18 "uid=NULLGWDOCOMO&val=",00h 80013C30 "http://ne-net.com/hc/i/ps/",00h 80013C30 "HTTP/1.0",0Dh,0Ah,"User-Agent: ",00h 80013C64 "DoCoMo/1.0/ex_ps1302",00h 80013C7C 0Dh,0Ah,"Content-type: application/x-www-form-urlencoded",0Dh,0Ah, "Content-Length: ",00h 80014040 "Ranking.cgi" ;2580h bytes +32bit chksum, two such files 800141DC "Regist.cgi" ;10h bytes +32bit chksum 800145E0 "HamList.cgi" ;488h bytes +32bit chksum 80014668 "HamSet.cgi" ;1h byte +8bit chksum 800148C0 "ArenaParty.cgi" ;1h byte +8bit chksum 80014948 "ArenaBattle.cgi" ;394h or 4 bytes +32bit chksum 80014958 "ArenaResult.cgi" ;4h bytes or none +32bit chksum 80014AEC "Stroll.cgi" ;38h bytes +32bit chksum 80018B88 "-- autholize pass -2",0Ah,0 80018DD0 "User-Agent:DoCoMo/1.0/ex_ps",00h 80018DEC "User-Agent: DoCoMo/1.0/ex_ps",00h 80018E0C "TL_Disconnect Invalid TL handle = %d ",0Ah,00h 80018E34 "TL_Disconnect TLCF2_ERR_OTHERS",0Ah,00h 8001910C "Ayame.log",00h 80019118 "com1:" 800D8C60 25h --> "%" 800E1648 48h,54h,... ---> "HTTP/1.0",0Dh,0Ah,00h 800E16C8 55h,73h,... ---> "User-Agent: DoCoMo/1.0/",00h 801018F0 "Access TLm Version 3.0 (Ayame)",00h 80101910 "Copyright 1997 - 2000 Access Co., Ltd.",00h 80101938 "Gamma Release 1.3 (Apr. 18, 2000),00h 801024E8 "GET",00h 80102500 "POST",00h 80102728 "POST",00h and some known code/data locations: 800CA80C code: send joy byte 800D94BC code: send imode byte 41h 800D9F3C code: send NOT(-42h) aka NOT(FFFFFFBEh) aka 41h To get I-Mode transfers: In main menu, select "iE-K" then select "NETWORK BATTLE" (or the other option; other than the two RANKING options). |
has similar ASCII strings: GET http, POST http://dkd.to/p/, User-Agent, com1:, Access TLm, .. |
has a few ASCII strings: 8006AB6C-and-up maybe compare 5Ah for replies? 80072144 80014548h "-- autholize pass -2",0Ah,0 80072CB8 80014790h "User-Agent:DoCoMo/..." 80072D34 800147ACh "User-Agent:DoCoMo/..." 80073498 800147CCh "TL_Disconnect Invalid TL handle = %d ",0Ah,0 8007A9E4 80014ACCh "Ayame.log" 8007A9F0 80014AD8h "com1:" 800852C0 48h,54h,... "HTTP/1.0",0Dh,0Ah,00h 80085340 55h,73h,... "User-Agent:" |
has ASCII strings (only in memory when selecting 3rd main menu option). |
no ASCII strings (and merely accesses phone address book, without internet?). requires entering a 4-digit PIN (that part is similar as in Keitai Eddy) |
| Controllers - I-Mode Adaptor - Libimode Library |
sceImode_Param Context Structure 00h short fCommandType Command type (00h..07h) 02h short fPortNo iMODE cable connection port (0:port1, 1:port2) 04h short fSlotNo iMODE cable connection slot (A~D:0~3) (unused) 06h - padding - 08h char* fSendBuff Send data buffer address ;\ 0Ch short fSendBuffSize Send data buffer size ; TX 0Eh short fSendDataSize Actual size of send data ;/ 10h char* fRcvBuff Receive data buffer address ;\ 14h short fRcvBuffSize Size of receive data buffer ; RX 16h short fRcvDataSize Size of receive data buffer ;/ 18h char* fInfoBuff Info data receive buffer address ;\ 1Ch short fInfoBuffSize Info data receive buffer size ; Info ? 1Eh short fInfoDataSize Actual size of info data received ;/ 20h short fStatus State variable (00h..10h) 22h short fLastError Error class (signed, -63h..+00h) Commands: 0=IMODE_CMD_RCV Check receive data (default) 1=IMODE_CMD_SND Send request 2=IMODE_CMD_STS Get state 3=IMODE_CMD_ABORT Abort send/receive 4=IMODE_CMD_AUTH_START Begin authentication 5=IMODE_CMD_AUTH_END End authentication 6=IMODE_CMD_GW_CONNECT Connect gateway 7=IMODE_CMD_GW_DISCONNECT Disconnect gateway States: -1 =UNINITIALIZED Pre-Init / Post-Finalize 00h=DORMANT Initial State ;- 01h=AUTH_STARTING Authenticating ;\CND_AUTH_START 02h=AUTH_STARTED Authenticated ;/ 03h=GW_CONNECTING Gateway connecting ;\ 04h=GW_CONNECTED Gateway connected ; CMD_GW_CONNECT 05h=CONNECTING ? Connecting ;/ 06h=CONNECTED ? Connected 07h=SENDING ?? Sending ;\IMODE_CMD_SND 08h=SENDCOMPLETE ?? Send completed ;/ 09h=RECEIVING ?? Receiving ;\IMODE_CMD_RCV 0Ah=RECEIVECOMPLETE ?? Receive completed ;/ 0Bh=DISCONNECTING ? Disconnecting ;\ CMD_ABORT? 0Ch=DISCONNECTED ? Disconnected ; CMD_GW_DISCONNECT 0Dh=GW_DISCONNECTING Gateway disconnecting ; 0Eh=GW_DISCONNECTED Gateway disconnected ;/ 0Fh=AUTH_ENDING Authentication ending ;\CMD_AUTH_END 10h=AUTH_ENDED Authentication ended ;/ |
req=400h cmd=0Fh+10h (1Fh) ? ;\ req=080h cmd=2Fh+10h (3Fh) gw_connect ; req=100h cmd=43h+10h (53h) gw_disconnect ; control req=200h cmd=63h+10h (73h) ? (event 20h/21h?) ; req=800h cmd=87h+xx,n,n,n (87h or 97h) ;5byte ;shutdown? ;/ req=010h cmd=01h+xx (01h or 11h) misc & transfer_timer ;\handshake req=020h cmd=05h+xx (05h or 15h) misc ; errors? req=040h cmd=09h+xx (09h or 19h) wrong_blkno_lsb ;/ req=00xh event 0Ah/0Bh --> cmd=00h+xx+ttt+bbb+(Nbyte), or cmd=01h/05h+10h |
event=-1 none event=00h user_action_05h_11h (connect_stage_1, begin_gw_connect) ;req=080h event=01h unused event=02h unused event=03h user_action_05h_12h (connect_stage_3, begin_gw_disconnect);req=100h event=04h unused event=05h trigger ;killer_xfer_req=020h ;\generated somehow event=06h trigger ;killer_xfer_req=010h ;/(send handshake error?) event=07h error_retry (upon timeout, or incoming_11_01110011 error msg) event=08h error_giveup (after four (re-)tries) event=09h transfer_timer (triggers req=010h, or req=020h) event=0Ah ;\send 2, 5, or N byte (send data message?) outgoing event=0Bh ;/ outgoing event=0Ch ;\ outgoing event=0Dh ; send 2, or 5 byte (send control message?) outgoing event=0Eh ;/ outgoing event=0Fh (matching blkno) incoming_x1_bbb0nnn0_nnnnnnnn ;\ event=10h (wrong blkno bit1-3) incoming_x1_bbb0xxx0 ; TLP event=11h (matching blkno) incoming_x1_bbb1nnn0_nnnnnnnn ; messages event=12h (wrong blkno bit1-3) incoming_x1_bbb1xxx0 ;/ event=13h ;\ incoming_01_bbb10001 (aka 11h) ;\ event=14h ; incoming_x1_bbb00001 (aka 01h) ; event=15h ;/ incoming_11_bbb10001 (aka 11h) ; handshake event=16h ;\flags OR 10h incoming_01_bbb10101 (aka 15h) ; errors? event=17h ; result=20h incoming_x1_bbb00101 (aka 05h) ; event=18h ;/ incoming_11_bbb10101 (aka 15h) ; event=19h ;\ incoming_01_bbb11001 (aka 19h) ; event=1Ah ; flags OR 40h incoming_x1_bbb01001 (aka 09h) ; event=1Bh ;/ incoming_11_bbb11001 (aka 19h) ;/ event=1Ch (GW_CONNECTED) incoming_01_01110011 (aka 73h) ;\ event=1Dh (req_disconnect?) incoming_x1_01100011 (aka 63h) ; event=1Eh ;\ incoming_x1_00101111 (aka 2Fh) ; event=1Fh ; req=200h, and incoming_11_00111111 (aka 3Fh) ; control event=20h ; req=400h incoming_x1_01000011 (aka 43h) ; event=21h ;/ incoming_11_01010011 (aka 53h) ; event=22h (GW_DISCONNECTED) incoming_01_00011111 (aka 1Fh) ; event=23h (force disconnect?) incoming_01_00001111 (aka_0Fh) ; event=24h (force disconnect?) incoming_01_10010111 (aka 97h) ; event=25h (force disconnect?) incoming_01_10000111 (aka 87h) ;/ event=26h (invalid) incoming_01_bbb1nn01 (other) ;\ event=27h (invalid) incoming_x1_bbb0nn01 (other) ; handshake event=28h (invalid) incoming_11_bbb1nn01 (other) ;/ event=26h (invalid) incoming_01_00111111 (aka 3Fh) ;\ event=26h (invalid) incoming_11_00011111 (aka 1Fh) ; control event=26h (invalid) incoming_11_10010111 (aka 97h) ; event=26h (invalid) incoming_01_xxx1xx11 (other) ; event=26h (invalid) incoming_01_01010011 (aka 53h) ; event=27h (invalid) incoming_11_00001111 (aka 0Fh) ; event=27h (invalid) incoming_11_10000111 (aka 87h) ; event=27h (invalid) incoming_x1_xxx0xx11 (other) ; event=28h (invalid) incoming_11_xxx1xx11 (other) ;/ |
| Controllers - I-Mode Adaptor - Unknown Features |
| Controllers - I-Mode Adaptor - References |
Media Concept ../technology/rd/technical_journal/bn/vol1_1/vol1_1_010en.pdf Network System ../technology/rd/technical_journal/bn/vol1_1/vol1_1_014en.pdf i-mode Server ../technology/rd/technical_journal/bn/vol1_1/vol1_1_020en.pdf Micro Browser ../technology/rd/technical_journal/bn/vol1_1/vol1_1_026en.pdf (above files can found at www.docomo.ne.jp/english/binary/pdf/corporate/..) |
| Controllers - Keyboards |
Adaptor with short cable to PSX-controller port (and prototype marking) Adaptor without cable, directly plugged into controller port (final version?) |
Send 01h 42h 00h 00h 00h 00h 00h 00h 00h 00h 00h 00h 00h 00h 06h Reply HiZ 96h 5Ah num dat dat dat dat dat dat dat dat dat dat dat |
08 10 18 20 28 30 38 40 48 50 57 5F
76 05 06 04 0C 03 0B 83 0A 01 09 78 07 pr 7E br
0E 16 1E 26 25 2E 36 3D 3E 46 45 4E 55 6A 66 '70'6C'7D 77'4A 7C 7B
0D 15 1D 24 2D 2C 35 3C 43 44 4D 54 5B 5D '71'69'7A 6C 75 7D
58 1C 1B 23 2B 34 33 3B 42 4B 4C 52 5D 5A 6B 73 74 79
12 61 1A 22 21 2A 32 31 3A 41 49 4A 51 59 '75 69 72 7A
14'1F 11 29 '11'27'2F'14 '6B'72'74 70 71'5A
|
xx --> Pressed: xx Released: F0 xx ;xx=01..83 'xx --> Pressed: E0 xx Released: E0 F0 xx ;xx=11..7D pr --> Pressed: E0 12 E0 7C Released: E0 F0 7C E0 F0 12 br --> Pressed: E1 14 77 Released: E1 F0 14 F0 77 And, Logitech keyboards with built-in pointing device use prefix E2. Some multimedia keyboards may have '3F=Sleep, '37=Power, '5E=Wake, and/or Play/Pause/Volume/Email/whatever buttons (though that may be more common on USB keyboards than PS/2 ones). |
Send .. .. .. 01h xxh FFh FFh FFh FFh FFh 00h .. .. .. .. Send .. .. .. 00h .. .. .. .. .. .. 00h .. .. .. .. |
[1F801058h]=00CEh ;SIO_MODE 8bit, no parity, 2 stop bits (8N2) [1F80105Ah]=771Ch ;SIO_CTRL rx enable (plus whatever nonsense bits) [1F80105Eh]=006Ch ;SIO_BAUD 19200 bps RX Keyboard Scancode (same ASCII-style as in later versions?) CTS Caps-Lock state DSR Num-Lock state |
Send 01h 42h 00h 0h 0h Reply HiZ 41h 5Ah PadA |
Send 01h 42h 00h 0h 0h 0h 0h 0h 0h 0h 0h 00h 00h 0h 0h 0h 0h 0h 0h Reply HiZ E8h 5Ah PadA PadB PadC PadD Ver Lock Buffer(0..5) |
Version=1 ; version number 0 SCROLL ; scroll lock on 1 NUM ; num lock on 2 CAPS ; caps lock on 3 DONETEST ; keyboard has just done a selftest 4 EMUA ; emulation mode a 5 EMUB ; emulation mode b |
01 11 12 13 14 15 16 17 18 19 1A 1B 1C 1D 69 1F 60 21 22 68 24 25 5E 26 2A 28 29 5F 3D 2D 0B 0E 0F 67 2F 1E 2D 27 51 57 45 52 54 59 55 49 4F 50 5B 5D 0D 10 61 62 37 38 39 3B 41 53 44 46 47 48 4A 4B 4C 3A 40 23 34 35 36 2B 02 5C 5A 58 43 56 42 4E 4D 3C 3E 3F 03 63 31 32 33 04 05 06 20 07 08 09 0A 65 64 66 30 2E 6A |
Send 01h 42h 00h 00h 00h 00h 00h Reply HiZ 12h 5Ah key flg dx dy |
bit0-1 = Always 11b (unlike Sony mouse) bit2 = Left Mouse Button (0=Pressed, 1=Released) ;\BUG: left/right buttons bit3 = Right Mouse Button (0=Pressed, 1=Released) ;/should be vice-versa bit4-5 = Always 11b (like Sony mouse) bit6 = Key Release (aka F0h prefix) (0=Yes, 1=No) bit7 = Key Extended (aka E0h prefix) (0=Yes, 1=No) |
| Controllers - Additional Inputs |
| Controllers - Misc |
SCPH-1010 digital joypad (with short cable) SCPH-1080 digital joypad (with longer cable) SCPH-1030 mouse (with short cable) SCPH-1090 mouse (with longer cable) SCPH-1092 mouse (european?) SCPH-1110 analog joystick SCPH-1150 analog joypad (with one vibration motor, with red/green led) SCPH-1180 analog joypad (without vibration motors, with red/green led) SCPH-1200 analog joypad (with two vibration motors) (dualshock) SCPH-110 analog joypad (with two vibration motors) (dualshock for psone) SCPH-10010 dualshock2 (analog buttons, except L3/R3/Start/Select) (for ps2) SCPH-1070 multitap |
SCPH-4010 VPick (guitar-pick controller) (for Quest for Fame, Stolen Song) |
__________ __________
| | | ^ | ^
| L1 R1 | | X <+> O | <+> = Digital Stick
\ ___| <--- L2 [] ---> |___ v / v
| | <--- R2 /\ ---> | |
___| |___________________________| |___ Not sure if all buttons
| | | SEL STA =?= | | | are shown at their
| | | | | | correct locations?
| | |_ [] /\ _| | | (drawing is based on
| _| / L1 R1 \ |_ | below riddle/lyrics)
| \_____/ X O \_____/ |
| /___\ L2 R2 /___\ |
| |
| |
\___________________________________________/
|
The thumb buttons on the left act as L1 and R1,
the trigger is L2, the pinky button is R2
The thumb buttons on the right act as X and O,
the trigger is Square and the pinky button is Triangle.
I find this odd as the triggers should've been L1 and R1,
the pinkies L2 and R2.
The buttons are redundantly placed on the base as large buttons like what
you'd see on a fight/arcade stick. Also with Start and Select.
There is also a physical analog mode switch,
not a button like on dual shock.
|
| Memory Card Read/Write Commands |
Send Reply Comment 81h N/A Memory Card Access (unlike 01h=Controller access), dummy response 52h FLAG Send Read Command (ASCII "R"), Receive FLAG Byte 00h 5Ah Receive Memory Card ID1 00h 5Dh Receive Memory Card ID2 MSB (00h) Send Address MSB ;\sector number (0..3FFh) LSB (pre) Send Address LSB ;/ 00h 5Ch Receive Command Acknowledge 1 ;<-- late /ACK after this byte-pair 00h 5Dh Receive Command Acknowledge 2 00h MSB Receive Confirmed Address MSB 00h LSB Receive Confirmed Address LSB 00h ... Receive Data Sector (128 bytes) 00h CHK Receive Checksum (MSB xor LSB xor Data bytes) 00h 47h Receive Memory End Byte (should be always 47h="G"=Good for Read) |
Send Reply Comment 81h N/A Memory Card Access (unlike 01h=Controller access), dummy response 57h FLAG Send Write Command (ASCII "W"), Receive FLAG Byte 00h 5Ah Receive Memory Card ID1 00h 5Dh Receive Memory Card ID2 MSB (00h) Send Address MSB ;\sector number (0..3FFh) LSB (pre) Send Address LSB ;/ ... (pre) Send Data Sector (128 bytes) CHK (pre) Send Checksum (MSB xor LSB xor Data bytes) 00h 5Ch Receive Command Acknowledge 1 00h 5Dh Receive Command Acknowledge 2 00h 4xh Receive Memory End Byte (47h=Good, 4Eh=BadChecksum, FFh=BadSector) |
Send Reply Comment 81h N/A Memory Card Access (unlike 01h=Controller access), dummy response 53h FLAG Send Get ID Command (ASCII "S"), Receive FLAG Byte 00h 5Ah Receive Memory Card ID1 00h 5Dh Receive Memory Card ID2 00h 5Ch Receive Command Acknowledge 1 00h 5Dh Receive Command Acknowledge 2 00h 04h Receive 04h 00h 00h Receive 00h 00h 00h Receive 00h 00h 80h Receive 80h |
Send Reply Comment 81h N/A Memory Card Access (unlike 01h=Controller access), dummy response xxh FLAG Send Invalid Command (anything else than "R", "W", or "S") |
| Memory Card Data Format |
Total Memory 128KB = 131072 bytes = 20000h bytes 1 Block 8KB = 8192 bytes = 2000h bytes 1 Frame 128 bytes = 80h bytes |
00h-01h Memory Card ID (ASCII "MC") 02h-7Eh Unused (zero) 7Fh Checksum (all above bytes XORed with each other) (usually 0Eh) |
00h-03h Block Allocation State
00000051h - In use ;first-or-only block of a file
00000052h - In use ;middle block of a file (if 3 or more blocks)
00000053h - In use ;last block of a file (if 2 or more blocks)
000000A0h - Free ;freshly formatted
000000A1h - Free ;deleted (first-or-only block of file)
000000A2h - Free ;deleted (middle block of file)
000000A3h - Free ;deleted (last block of file)
04h-07h Filesize in bytes (2000h..1E000h; in multiples of 8Kbytes)
08h-09h Pointer to the NEXT block number (minus 1) used by the file
(ie. 0..14 for Block Number 1..15) (or FFFFh if last-or-only block)
0Ah-1Eh Filename in ASCII, terminated by 00h (max 20 chars, plus ending 00h)
1Fh Zero (unused)
20h-7Eh Garbage (usually 00h-filled)
7Fh Checksum (all above bytes XORed with each other)
|
"BI"=Japan, "BE"=Europe, "BA"=America |
in "AAAA-NNNNN" form ;for Pocketstation executables replace "-" by "P" |
"abcdefgh" |
00h-03h Broken Sector Number (Block*64+Frame) (FFFFFFFFh=None) 04h-7Eh Garbage (usually 00h-filled) (some cards have [08h..09h]=FFFFh) 7Fh Checksum (all above bytes XORed with each other) |
00h-7Fh Data (usually FFh-filled, if there's no broken sector) |
00h-7Fh Unused (usually FFh-filled) |
00h-01h ID (ASCII "SC")
02h Icon Display Flag
11h...Icon has 1 frame (static) (same image shown forever)
12h...Icon has 2 frames (animated) (changes every 16 PAL frames)
13h...Icon has 3 frames (animated) (changes every 11 PAL frames)
Values other than 11h..13h seem to be treated as corrupted file
(causing the file not to be listed in the bootmenu)
03h Block Number (1-15) "icon block count" Uh?
(usually 01h or 02h... might be block number within
files that occupy 2 or more blocks)
(actually, that kind of files seem to HAVE title frames
in ALL of their blocks; not only in their FIRST block)
(at least SOME seem to have such duplicated title frame,
but not all?)
04h-43h Title in Shift-JIS format (64 bytes = max 32 characters)
44h-4Fh Reserved (00h)
50h-5Fh Reserved (00h) ;<-- this region is used for the Pocketstation
60h-7Fh Icon 16 Color Palette Data (each entry is 16bit CLUT)
|
00h-7Fh Icon Bitmap (16x16 pixels, 4bit color depth) |
00h-7Fh Data |
81h,40h --> SPC 81h,43h..97h --> punctuation marks 82h,4Fh..58h --> "0..9" 82h,60h..79h --> "A..Z" 82h,81h..9Ah --> "a..z" |
| Memory Card Images |
SmartLink .PSM, WinPSM .PS, DataDeck .DDF, FPSX .MCR, ePSXe .MCD... |
Connectix Virtual Game Station format (.MEM): "VgsM", 64 bytes
PlayStation Magazine format (.PSX): "PSV", 256 bytes
|
00h..14h Filename in ASCII, terminated by 00h (max 20 chars, plus ending 00h) 15h..35h Title in ASCII, terminated by 00h (max 32 chars, plus ending 00h) 36h.. File Block(s) (starting with the Title sector) |
000h 12 ASCII String "123-456-STD",00h 00Ch 4 Usually zerofilled (or meaningless garbage in some files) 010h 5 Always 00h,00h,01h,00h,01h 015h 16 Copy of Sector 0..15 byte[00h] ;"M", followed by allocation states 025h 16 Copy of Sector 0..15 byte[08h] ;00h, followed by next block values 035h 11 Usually zerofilled (or meaningless garbage in some files) 040h F00h Fifteen Description Strings (each one 100h bytes, padded with 00h) F40h 128K Memory Card Image (128K) (unused sectors 00h or FFh filled) |
| Memory Card Notes |
Send Reply Comment 21h N/A? Probably replies HighZ (ie. probably reads FFh)? 53h 0xh? Replies unknown 8bit value (upper 4bit are known to be zero)? |
| Pocketstation |
| Pocketstation Overview |
CPU ARM7TDMI (32bit RISC Processor) (variable clock, max 7.995MHz)
Memory 2Kbytes SRAM (battery backed), 16Kbytes BIOS ROM, 128Kbytes FLASH
Display 32x32 pixel LCD (black and white) (without any grayscales)
Sound Mini Speaker "(12bit PCM) x 1 unit" / "8bit PCM with 12bit range"
Controls 5 input buttons, plus 1 reset button
Infrared Bi-directional (IrDA based)
Connector Playstation memory card interface
RTC Battery backed Real-Time Clock with time/date function
Supply CR2032 Battery (3VDC) (used in handheld mode, and for SRAM/RTC)
_________
/ _______ \
| | | |
| | LCD | | __
| |_______| | Side Views | _|
|\_________/| || <-------- Button Cover
| O | (Closed) (Open) ||
| O O O | ____________ _____|| .------- Reset Button
| O | | LCD \____ | | LCD \|__|_
|___________| |___________|| |___________| <--- Memory card plug
|
| Pocketstation I/O Map |
00000000h RAM (2KB RAM) (first 512 bytes bytes reserved for kernel) 02000000h FLASH1 Flash ROM (virtual file-mapped addresses in this region) 04000000h BIOS_ROM Kernel and GUI (16KB) 06000000h F_CTRL Control of Flash ROM 06000004h F_STAT Unknown? 06000008h F_BANK_FLG FLASH virtual bank mapping enable flags(16 bits)(R/W) 0600000Ch F_WAIT1 waitstates...? 06000010h F_WAIT2 waitstates, and FLASH-Write-Control-and-Status...? 06000100h F_BANK_VAL FLASH virtual bank mapping addresses (16 words) (R/W) 06000300h F_EXTRA Extra FLASH (256 bytes, including below F_SN, F_CAL) 06000300h F_SN_LO Extra FLASH Serial Number LSBs (nocash: 6BE7h) 06000302h F_SN_HI Extra FLASH Serial Number MSBs (nocash: 426Ch) 06000304h F_? Extra FLASH Unknown ? (nocash: 05CAh) 06000306h F_UNUSED1 Extra FLASH Unused halfword (nocash: FFFFh) 06000308h F_CAL Extra FLASH LCD Calibration (nocash: 001Ah) 0600030Ah F_UNUSED2 Extra FLASH Unused halfword (nocash: FFFFh) 0600030Ch F_? Extra FLASH Unknown ? (nocash: 0010h) 0600030Eh F_UNUSED3 Extra FLASH Unused halfword (nocash: FFFFh) 06000310h F_UNUSED4 Extra FLASH Unused (310..3FFh) (nocash: FFFFh-filled) 08000000h FLASH2 Flash ROM (128KB) (physical addresses in this region) 08002A54h F_KEY1 Flash Unlock Address 1 (W) 080055AAh F_KEY2 Flash Unlock Address 2 (W) |
0A000000h INT_LATCH Interrupt hold (R) 0A000004h INT_INPUT Interrupt Status (R) 0A000008h INT_MASK_READ Read Interrupt Mask (R) 0A000008h INT_MASK_SET Set Interrupt Mask (W) 0A00000Ch INT_MASK_CLR Clear Interrupt Mask (W) 0A000010h INT_ACK Clear Interrupt hold (W) 0A800000h T0_RELOAD Timer 0 Maximum value 0A800004h T0_COUNT Timer 0 Current value 0A800008h T0_MODE Timer 0 Mode 0A800010h T1_RELOAD Timer 1 Maximum value 0A800014h T1_COUNT Timer 1 Current value 0A800018h T1_MODE Timer 1 Mode 0A800020h T2_RELOAD Timer 2 Maximum value 0A800024h T2_COUNT Timer 2 Current value 0A800028h T2_MODE Timer 2 Mode 0B000000h CLK_MODE Clock control (CPU and Timer Speed) (R/W) 0B000004h CLK_STOP Clock stop (Sleep Mode) 0B800000h RTC_MODE RTC Mode 0B800004h RTC_ADJUST RTC Adjust 0B800008h RTC_TIME RTC Time (R) 0B80000Ch RTC_DATE RTC Date (R) |
0C000000h COM_MODE Com Mode 0C000004h COM_STAT1 Com Status Register 1 (Bit1=Error) 0C000008h COM_DATA Com RX Data (R) and TX Data (W) 0C000010h COM_CTRL1 Com Control Register 1 0C000014h COM_STAT2 Com Status Register 2 (Bit0=Ready) 0C000018h COM_CTRL2 Com Control Register 2 0C800000h IRDA_MODE Infrared Control (R/W) 0C800004h IRDA_DATA Infrared TX Data 0C80000Ch IRDA_MISC Infrared Unknown/Reserved 0D000000h LCD_MODE Video Control (R/W) 0D000004h LCD_CAL Video Calibration (?) 0D000100h LCD_VRAM Video RAM (80h bytes; 32x32bit) (R/W) 0D800000h IOP_CTRL IOP control 0D800004h IOP_STAT Read Current Start/Stop bits? (R) 0D800004h IOP_STOP Stop bits? (W) 0D800008h IOP_START Start bits? (W) 0D80000Ch IOP_DATA IOP data? (not used by bios) 0D800010h DAC_CTRL DAC Control (R/W) 0D800014h DAC_DATA DAC data 0D800020h BATT_CTRL Battery Monitor Control |
WRAM 1 cycle (for ARM and THUMB) FLASH 2 cycles (for ARM), or 1 cycle (for THUMB) BIOS ? |
WRAM (and some F_xxx ports) 1 cycle VIRT/PHYS/XTRA_FLASH, BIOS, VRAM, I/O 2 cycles |
00000800h-00FFFFFFh Mirrors of 00000000h-000007FFh (2K RAM) 01000000h-01FFFFFFh Invalid (read causes data abort) (unused 16MB area) 020xxxxxh-0201FFFFh Invalid (read causes data abort) (disabled FLASH banks) 02020000h-02FFFFFFh Invalid (read causes data abort) (no Virt FLASH mirrors) 03000000h-03FFFFFFh Invalid (read causes data abort) (unused 16MB area) 04004000h-04FFFFFFh Mirrors of 04000000h-04003FFFh (16K BIOS) 05000000h-05FFFFFFh Invalid (read causes data abort) 06000014h-060000FFh Zerofilled (or maybe mirror of a ZERO port?) (F_xxx) 06000140h-060002FFh Zerofilled (or maybe mirror of a ZERO port?) (F_xxx) 06000400h-06FFFFFFh Zerofilled (or maybe mirror of a ZERO port?) (F_xxx) 07000000h-07FFFFFFh Invalid (read causes data abort) (unused 16MB area) 08020000h-08FFFFFFh Mirrors of 08000000h-0801FFFFh (128K Physical FLASH) 09000000h-09FFFFFFh Invalid (read causes data abort) (unused 16MB area) 0A000014h-0A7FFFFFh Mirrors of 0A000008h-0A00000Bh (INT_MASK_READ) (I_xxx) 0A80000Ch Mirror of 0A800000h-0A800003h (T0_RELOAD) (T0_xxx) 0A80001Ch Mirror of 0A800000h-0A800003h (T0_RELOAD) (T1_xxx) 0A80002Ch Mirror of 0A800000h-0A800003h (T0_RELOAD) (T2_xxx) 0A800030h-0AFFFFFFh Mirrors of 0A800000h-0A800003h (T0_RELOAD) (T_xxx) 0B000008h-0B7FFFFFh Mirrors of .... ? (CLK_xxx) 0B800010h-0BFFFFFFh Mirrors of 0B800008h-0B80000Bh (RTC_TIME) 0C00000Ch-0C00000Fh Zero (COM_xxx) 0C00001Ch-0C7FFFFFh Zerofilled (or maybe mirror of a ZERO port?) (COM_xxx) 0C800008h-0CFFFFFFh ? (IRDA_xxx) 0D000008h-0D0000FFh Zerofilled (or maybe mirror of a ZERO port?) (LCD_xxx) 0D000180h-0D7FFFFFh Zerofilled (or maybe mirror of a ZERO port?) (LCD_xxx) 0D800018h ? (DAC_xxx) 0D80001Ch ? (DAC_xxx) 0D800024h-0DFFFFFFh Zerofilled (or maybe mirror of a ZERO port?) (BATT_xxx) 0E000000h-FFFFFFFFh Invalid (read causes data abort) (unused 3872MB area) |
02000000h-0201FFFFh VIRT_FLASH ;\ 04000000h-04FFFFFFh BIOS_ROM ; "garbage_byte" (see below) 06000300h-060003FFh EXTRA_FLASH ; 08000000h-08FFFFFFh PHYS_FLASH ;/ 0A800001h-0AFFFFFFh Timer area, odd addresses (with A0=1) mirror to 0A800001h 0B800001h-0BFFFFFFh RTC area, odd addresses (with A0=1) mirror to ...? |
0B800002h-0BFFFFFEh RTC area, odd addresses (with A1=1) mirror to 0B80000Ah |
garbage_word = (prefetch OR (ramdata AND FFFFFFD0h)) garbage_byte = (garbage_word shr (8*(addr and 3))) AND FFh |
prefetch.bit0-31 = [curr_arm_opcode_addr+8] ;-eg. from arm LDRB |
prefetch.bit0-15 = [recent_arm_opcode_addr+8] ;-eg. from arm BX to thumb prefetch.bit16-31 = [curr_thumb_opcode_addr+4] ;-eg. from thumb LDRB |
ramdata.bit0-31 = [recent_ram_read_addr] ;-eg. from LDR/POP from RAM |
| Pocketstation Memory Map |
00000000h RAM RAM (2K) (or mirror of BIOS ROM upon reset) 02000000h FLASH1 Flash ROM (virtual file-mapped addresses in this region) 04000000h BIOS_ROM BIOS (16K) (Kernel and GUI) 06000300h F_SN... Seems to contain a bunch of additional FLASH bytes? 08000000h FLASH2 Flash ROM (128K) (physical addresses in this region) 0D000100h LCD_VRAM Video RAM (128 bytes) (32x32 pixels, 1bit per pixel) |
0000000h 20h Exception handler opcodes (filled with LDR R15,[$+20h] opcodes) 0000020h 20h Exception handler addresses (in ARM state, no THUMB bit here) 0000040h 80h Sector buffer (and BU command parameter work space) 00000C0h 8 ComFlags (see GetPtrToComFlags(), SWI 06h for details) 00000C8h 2 BU Command FUNC3 Address (see GetPtrToFunc3addr() aka SWI 17h) 00000CAh 1 Value from BU Command_50h, reset by SWI 05h (sense_auto_com) 00000CBh 2 Not used 00000CDh 1 Old Year (BCD, 00h..99h) (for sensing wrapping to new century) 00000CEh 1 Alternate dir_index (when [0D0h]=0) (see SWI 15h and SWI 16h) 00000CFh 1 Current Century (BCD, 00h..99h) (see GetBcdDate() aka SWI 0Dh) 00000D0h 2 Current dir_index (for currently executed file, or 0=GUI) 00000D2h 2 New dir_index (PrepareExecute(flag,dir_index,param), SWI 08h) 00000D4h 4 New param (PrepareExecute(flag,dir_index,param), SWI 08h) 00000D8h 8 Alarm Setting (see GetPtrToAlarmSetting() aka SWI 13h) 00000E0h 4 Pointer to SWI table (see GetPtrToPtrToSwiTable() aka SWI 14h) 00000E4h 3x4 Memory Card BU Command variables 00000F0h 1 Memory Card FLAG byte (bit3=new_card, bit2=write_error) 00000F1h 1 Memory Card Error offhold (0=none, 1=once) 00000F2h 6 Not used 00000F8h 4x4 Callback Addresses (set via SetCallbacks(index,proc), SWI 01h) 0000108h 4 Snapshot ID (0xh,00h,"SE") 000010Ch 74h IRQ and SWI stack (stacktop at 180h) 0000180h 80h FIQ stack (stacktop at 200h) |
4000000h 1E00h Begin of Kernel (usually 1E00h bytes) 4000014h 4 BCD Date in YYYYMMDDh format (19981023h for ALL versions) 4001DFCh 4 Core Kernel Version (usually "C061" or "C110") 4001E00h 2200h Begin of GUI (usually 2200h bytes) 4003FFCh 4 Japanese GUI Version (usually "J061" or "J110") |
| Pocketstation IO Video and Audio |
0-2 Draw mode; seems to turn off bits of the screen;
0: All 32 rows on ;\
1: First 8 rows on ;
2: Second 8 rows on ;
3: Third 8 rows on ; (these are not necessarily all correct?)
4: Fourth 8 rows on ;
5: First 16 rows on ;
6: Middle 16 rows on ;
7: Bottom 16 rows on ;/
3 CPEN (0=Does some weird fade out of the screen, 1=Normal)
4-5 Refresh rate
0: Makes a single blue (yes, blue, yes, on a black/white display)
line appear at the top or middle of the screen - don't use!
1: 64Hz? (might be 32Hz too, like 2)
2: 32Hz
3: 16Hz (results in less intensity on black pixels)
6 Display active (0=Off, 1=On)
7 Rotate display by 180 degrees (0=For Handheld Mode, 1=For Docked Mode)
8-31 Unknown (should be zero)
|
[D000100h]=Top, through [D00017Ch]=Bottom-most scanline |
Bit0=Left, through Bit31=Right-most Pixel (0=White, 1=Black) |
0 Audio Enable enable (0=Off, 1=On) 1-31 Unknown, usually zero |
0-7 Probably unused, usually zero (or fractional part when lowered volume) 8-15 Signed Audio Output Level (usually -7Fh..+7Fh)(probably -80h works too) 16-31 Probably unused, usually sign-expanded from bit15 |
| Pocketstation IO Interrupts and Buttons |
Bit Type Meaning
0 IRQ Button Fire (0=Released, 1=Pressed)
1 IRQ Button Right (0=Released, 1=Pressed)
2 IRQ Button Left (0=Released, 1=Pressed)
3 IRQ Button Down (0=Released, 1=Pressed)
4 IRQ Button Up (0=Released, 1=Pressed)
5 ? Unknown? (?)
6 FIQ (!) COM ;for the COM_registers? (via /SEL Pin?)
7 IRQ Timer 0
8 IRQ Timer 1
9 IRQ RTC (square wave) (usually 1Hz) (when RTC paused: 4096Hz)
10 IRQ Battery Low (0=Normal, 1=Battery Low)
11 IRQ Docked ("IOP") (0=Undocked, 1=Docked to PSX) (via VCC Pin?)
12 IRQ Infrared Rx
13 FIQ (!) Timer 2
14-15 N/A Not used
|
INT_MASK_SET Enable Interrupt Flags (0=No change, 1=Enable) (W) INT_MASK_CLR Disable Interrupt Flags (0=No change, 1=Disable) (W) INT_MASK_READ Current Interrupt Enable Flags (0=Disabled, 1=Enabled) (R) |
INT_LATCH Latched Interrupt Requests (0=None, 1=Interrupt Request) (R) INT_ACK Clear Interrupt Requests (0=No change, 1=Acknowledge) (W) |
| Pocketstation IO Timers and Real-Time Clock |
INT_INPUT.7 Timer 0 IRQ ;used as 30Hz frame rate IRQ by GUI INT_INPUT.8 Timer 1 IRQ ;used as Audio square wave IRQ by GUI INT_INPUT.13 Timer 2 FIQ (this one via FIQ vector, not IRQ vector) INT_INPUT.9 RTC IRQ (usually 1Hz) (or 4096Hz when RTC paused) |
0-15 Reload Value (when timer becomes less than zero) |
0-15 Current value (decrementing) |
0-1 Timer Divider (0=Div2, 1=Div32, 2=Div512, 3=Div2 too) 2 Timer Enable (0=Stop, 1=Decrement) 3-15 Unknown (should be zero) |
0 Pause RTC (0=Run/1Hz, 1=Pause/4096Hz) 1-3 Select value to be modified via RTC_ADJUST 4-31 Not used? |
00h = Second ;\ 01h = Minute ; 02h = Hour ; used in combination with RTC_ADJUST 03h = Day of Week ; while RTC is paused 04h = Day ; 05h = Month ; 06h = Year ;/ 07h = Unknown ;-usually used when RTC isn't paused |
0-7 Seconds (00h..59h, BCD) 8-15 Minutes (00h..59h, BCD) 16-23 Hours (00h..23h, BCD) 24-31 Day of week (1=Sunday, ..., 7=Saturday) |
0-7 Day (01h..31h, BCD) 8-11 Month (01h..12h, BCD) 16-23 Year (00h..99h, BCD) 24-31 Unknown? (this is NOT used as century) |
| Pocketstation IO Infrared |
0 Transfer Direction (0=Receive, 1=Transmit) 1 Disable IRDA (0=Enable, 1=Disable) 2 Unknown (reportedly IR_SEND_READY, uh?) 3 Unknown (reportedly IR_RECV_READY, uh?) 4-31 Unknown (should be zero) |
0 Transmit Data in Send Direction (0=LED Off, 1=LED On) 1-31 Unknown (should be zero) |
___------------------___ One HIGH bit send as SINGLE-LONG-ON pulse (BAD) ___-_-_-_-_-_-_-_-_-____ One HIGH bit send as MULTIPLE-ON-OFF pulses (OK) |
| Pocketstation IO Memory-Control |
0-31 Unknown |
00000000h Used when disabling all virtual flash banks 00000001h Used before setting new virtual bank values 00000002h Used after setting virtual bank enable bits 03h Replace ROM at 00000000h by RAM (used after reset) |
0-31 Unknown |
0-15 Enable physical banks 0..15 in virtual region (0=Disable, 1=Enable) 16-31 Unknown (should be zero) |
0-3 Virtual bank number 4-31 Should be 0 |
0..3 Unknown/not tested 4 hangs hardware? but that bit is used in some cases! 5..31 Unknown/not tested |
F_WAIT1=00000000h when CPU Speed = 00h..07h F_WAIT1=00000010h when CPU Speed = 08h..0Fh |
0 no effect? but that bit is used in some cases! maybe write-enable? 1 hangs hardware? 2 no effect? READ: indicates 0=write-busy, 1=ready? (R) 3 hangs hardware? 4 makes FLASH slower? 5 makes WRAM and F_xxx as slow as other memory (0=1 cycle, 1=2 cycles) 6 hangs hardware? but that bit is used in some cases! 7 no effect? 8..31 Unknown/not tested |
F_WAIT2=00000000h when CPU Speed = 00h..07h ;\same as F_WAIT1 F_WAIT2=00000010h when CPU Speed = 08h..0Fh ;/ |
F_WAIT2=00000021h ;SWI 10h, FlashWritePhysical(sector,src) F_WAIT2=00000041h ;SWI 0Fh, FlashWriteSerial(serial_number) |
wait until reading returns F_WAIT2.Bit2 = 1 and then set F_WAIT2=00000000h |
if write_sector ;\
F_WAIT2=00000021h ; write enable or so
if write_header ;
F_WAIT2=00000041h ;/
[80055AAh]=FFAAh ;\
[8002A54h]=FF55h ; unlock flash
[80055AAh]=FFA0h ;/
if write_sector ;\
for i=0 to 3Fh ;
[8000000h+sector*80h+i*2]=src[i*2] ; write data
if write_header ;
[8000000h]=new F_SN_LO value ;
[8000002h]=new F_SN_HI value ;
[8000008h]=new F_CAL value ;/
first, wait 4000 clock cycles ;\wait
then, wait until F_WAIT2.Bit2=1 ;/
F_WAIT2=00000000h ;-write disable or so
|
0-15 Data |
| Pocketstation IO Communication Ports |
0 Data Output Enable (0=None/HighZ, 1=Output Data Bits) 1 /ACK Output Level (0=None/HighZ, 1=Output LOW) 2 Unknown (should be set when expecting a NEW command...?) 3-31 Unknown (should be zero) |
0-7 Data (Write: to be transmitted to PSX, Read: been received from PSX) 8-31 Unknown |
0 Unknown 1 Error flag or so (0=Okay, 1=Error) 2-31 Unknown |
0 Ready flag (0=Busy, 1=Ready) (when 8bits have been transferred) 1-31 Unknown |
0 Unknown (should be set AT BEGIN OF A NEW command...?) 1 Unknown (0=Disable something, 1=Enable something) 2-31 Unknown (should be zero) |
00000000h = unknown? disable 00000002h = unknown? enable 00000003h = unknown? at BEGIN of a new command |
0 Unknown (should be set, probably starts or acknowledges something) 1 Unknown (should be set when expecting a NEW command...?) 2-31 Unknown (should be zero) |
00000001h = unknown? used before AND after each byte-transfer 00000003h = unknown? used after LAST byte of command (and when init/reset) |
(via FIQ vector, not IRQ vector) |
| Pocketstation IO Power Control |
0-3 Clock Ratio (01h..08h, see below) (usually 7 = 3.99MHz) (R/W) 4 Clock Change State (0=Busy, 1=Ready) (Read-only) 5-15 ? |
00h = hangs hardware ;-don't use 01h = 0.063488 MHz ;\ 02h = 0.126976 MHz ; 03h = 0.253952 MHz ; 31*8000h / 1,2,4,8,16 04h = 0.507904 MHz ; 05h = 1.015808 MHz ;/ 06h = 1.998848 MHz ;\ 07h = 3.997696 MHz ; 61*8000h * 1,2,4 08h = 7.995392 MHz ;/ 09h..0Fh = same as 08h ;-aliases |
0 Stop Clock (1=Stop) 1-15 ? |
DAC_CTRL=0 ;\disable sound IOP_STOP=20h ;/ LCD_MODE=0 ;-disable video IRDA=whatever ;-disable infrared (if it was used) BATT_CTRL=BATT_CTRL AND FFFFFFFCh ;-do whatever INT_MASK_SET=801h ;-enable Docking/Fire wakeup interrupts |
0-3 Probably Direction for IOP_DATA bit0..3 (0=Input, 1=Output) 4-31 Unknown/Unused (seems to be always zero) |
0 Unknown, STARTED by Kernel upon reset 1 Red LED, Communication related (START=Whatever, STOP=Whatelse) (?) 2 Unknown, STARTED by Kernel upon reset 3 Unknown, STARTED by Kernel upon reset 4 Never STARTED nor STOPPED by BIOS (maybe an INPUT, read via IOP_DATA) 5 Sound Enable (START=On, STOP=Off) 6 Unknown, STOPPED by Kernel upon reset 7-31 Unknown, never STARTED nor STOPPED by BIOS |
0 ? 1 Red LED (0=On, 1=Off) 2 ? 3 ? 4 Seems to be always 1 (maybe Infrared input?) 5-31 Unknown/Unused (seems to be always zero) |
INT_INPUT.10 IRQ Battery Low (0=Normal, 1=Battery Low) |
| Pocketstation SWI Function Summary |
SWI 00h - Reset() ;don't use out: everything destroyed SWI 01h - SetCallbacks(index,proc) out: old proc SWI 02h - CustomSwi2(r0..r6,r8..r10) out: r0 SWI 03h - FlashWriteVirtual(sector,src) out: 0=okay, 1=failed SWI 04h - SetCpuSpeed(speed) out: old_speed SWI 05h - SenseAutoCom() out: garbage SWI 06h - GetPtrToComFlags() out: ptr (usually 0C0h) SWI 07h - ChangeAutoDocking(flags.16-18) out: incoming flags AND 70000h SWI 08h - PrepareExecute(flag,dir_index,param) out: dir_index (new or old) SWI 09h - DoExecute(snapshot_saving_flag) out: r0=r0 (failed) or r0=param SWI 0Ah - FlashReadSerial() out: F_SN SWI 0Bh - ClearComFlagsBit10() out: new [ComFlags] (with bit10=0) SWI 0Ch - SetBcdDateTime(date,time) out: garbage (RTC_DATE/10000h) SWI 0Dh - GetBcdDate() out: date (with century in MSBs) SWI 0Eh - GetBcdTime() out: time and day-of-week SWI 0Fh - FlashWriteSerial(serial_number) out: garbage (r0=0) ;old BIOS only! SWI 10h - FlashWritePhysical(sector,src) out: 0=okay, 1=failed SWI 11h - SetComOnOff(flag) out: garbage retadr to swi handler SWI 12h - TestSnapshot(dir_index) out: 0=normal, 1=MCX1 with 1,0,"SE" SWI 13h - GetPtrToAlarmSetting() out: ptr to alarm_setting SWI 14h - GetPtrToPtrToSwiTable() out: ptr-to-ptr to swi_table SWI 15h - MakeAlternateDirIndex(flag,dir_index) out: alt_dir_index (new/old) SWI 16h - GetDirIndex() out: dir_index (or alternate) SWI 17h - GetPtrToFunc3addr() out: ptr to func3 address SWI 18h - FlashReadWhateverByte(sector) out: [8000000h+sector*80h+7Eh] SWI 19h..FFh - garbage SWI 100h..FFFFFFh - mirrors of SWI 00h..FFh |
| Pocketstation SWI Misc Functions |
r0=0 Set SWI 02h callback (r1=proc, or r1=0=reset/default) r0=1 Set IRQ callback (r1=proc, or r1=0=none/default) r0=2 Set FIQ callback (r1=proc, or r1=0=none/default) r0=3 Set Download Notification callback (r1=proc, or r1=0=bugged/default) |
| Pocketstation SWI Communication Functions |
0-3 Whatever (set/cleared when docked/undocked, and modified by bu_cmd's) 4-7 Not used (should be zero) 8 IRQ-11 (IOP) occurred (set by irq handler, checked/cleared by SWI 05h) 9 Communication Enabled And Docked (0=No, 1=Yes; prevents DoExecute) 10 Reject writes to Broken Sector Region (sector 16..55) (0=No, 1=Yes) 11 Start file request (set by bu_cmd_59h, processed by GUI, not by Kernel) 12-15 Not used (should be zero) 16 Automatically power-down DAC audio on insert/removal (0=No, 1=Yes) 17 Automatically power-down IRDA infrared on insert/removal (0=No, 1=Yes) 18 Automatically adjust LCD screen rotate on insert/removal (0=No, 1=Yes) 19-27 Not used (should be zero) 28 Indicates if a standard bu_cmd (52h/53h/57h) was received (0=No, 1=Yes) 29 Set date/time request (set by bu_cmd FUNC0, processed by BIOS) 30 Destroy RTC and Start GUI request (set by bu_cmd_59h, dir_index=FFFEh) 31 Not used (should be zero) |
0-15 Not used (should be zero) 16 Automatically power-down DAC audio on insert/removal (0=No, 1=Yes) 17 Automatically power-down IRDA infrared on insert/removal (0=No, 1=Yes) 18 Automatically adjust LCD screen rotate on insert/removal (0=No, 1=Yes) 19-31 Not used (should be zero) |
| Pocketstation SWI Execute Functions |
0-7 Command number (see below, MSBs=Primary command, LSBs=another dir_index) 8 Do not store Alarm setting in Kernel RAM (0=Normal, 1=Don't store) 9-31 Not used (should be zero) |
Command 0xh --> Erase RTC time/date Command 1xh --> Enter GUI Time Screen with speaker symbol Command 20h --> Enter GUI Time Screen with alarm symbol Command 2xh --> Prompt for new Date/Time, then start dir_index (x) Command 3xh --> Enter GUI File Selection Screen, with dir_index (x) selected Command xxh --> Erase RTC time/date (same as Command 0xh) |
| Pocketstation SWI Date/Time/Alarm Functions |
0-7 Day (01h..31h, BCD) 8-11 Month (01h..12h, BCD) 16-31 Year (0000h..9999h, BCD) |
0-7 Seconds (00h..59h, BCD) 8-15 Minutes (00h..59h, BCD) 16-23 Hours (00h..23h, BCD) 24-31 Day of week (1=Sunday, ..., 7=Saturday) |
0-7 Alarm Minute (00h..59h, BCD) 8-15 Alarm Hour (00h..23h, BCD) 16 Alarm Enable (0=Off, 1=On) 17 Button Lock (0=Normal, 1=Lock) (pressing all 5 buttons in GUI) 18-19 Volume Shift (0=Normal/Loud, 1=Medium/Div4, 2=Mute/Off) 20-22 Not used (should be zero) 23 RTC Initialized (0=Not yet, 1=Yes, was initialized from within GUI) 24-31 Not used (should be zero) 32-63 Pointer to 8x8 BIOS Charset (characters "0"..."9" plus strange symbols) |
CHR(00h..09h) = Digits "0..9" CHR(0Ah) = Space " " CHR(0Bh) = Colon ":" CHR(0Ch) = Button Lock (used by Final Fantasy 8's Chocobo World) CHR(0Dh) = Speaker Medium; or loud if followed by chr(0Eh) CHR(0Eh) = Speaker Loud; to be appended to chr(0Dh) CHR(0Fh) = Speaker Off CHR(10h) = Battery Low (used by PocketMuuMuu's Cars) CHR(11h) = Alarm Off CHR(12h) = Alarm On CHR(13h) = Memory Card symbol |
| Pocketstation SWI Flash Functions |
| Pocketstation SWI Useless Functions |
| Pocketstation BU Command Summary |
50h Change a FUNC 03h related value or so 51h N/A 52h Standard Read Sector command 53h Standard Get ID command 54h N/A 55h N/A 56h N/A 57h Standard Write Sector command 58h Get an ID or Version value or so 59h Prepare File Execution with Dir_index, and Parameter 5Ah Get Dir_index, ComFlags, F_SN, Date, and Time 5Bh Execute Function and transfer data from Pocketstation to PSX 5Ch Execute Function and transfer data from PSX to Pocketstation 5Dh Execute Custom Download Notification Function ;via SWI 01h with r0=3 5Eh Get-and-Send ComFlags.bit1,3,2 5Fh Get-and-Send ComFlags.bit0 |
FUNC 00h - Get or Set Date/Time FUNC 01h - Get or Set Memory Block FUNC 02h - Get or Set Alarm/Flags FUNC 03h - Custom Function 3 ;via SWI 17h, GetPtrToFunc3addr() FUNC 80h..FFh - Custom Functions 80h..FFh ;via Function Table in File Header |
| Pocketstation BU Standard Memory Card Commands |
FDh Reject write to Directory Entries of currently executed file FEh Reject write to write-protected Broken Sector region (sector 16..55) |
| Pocketstation BU Basic Pocketstation Commands |
Send Reply Comment 81h N/A Memory Card Access 50h FLAG Send Command 50h VAL 00h Send new [0CAh], receive length of following data (00h) |
Send Reply Comment 81h N/A Memory Card Access 58h FLAG Send Command 58h (0) 02h Send dummy/zero, receive length of following data (02h) (0) 01h Send dummy/zero, receive whatever value (01h) (0) 01h Send dummy/zero, receive another value (01h) |
Send Reply Comment 81h N/A Memory Card Access 59h FLAG Send Command 59h (0) 06h Send dummy/zero, receive length of following data (06h) NEW OLD Send new dir_index.8-15, receive old dir_index.8-15 NEW OLD Send new dir_index.0-7, receive old dir_index.0-7 PAR (0) Send exec_parameter.0-7, receive dummy/zero PAR (0) Send exec_parameter.8-15, receive dummy/zero PAR (0) Send exec_parameter.16-23, receive dummy/zero PAR (0) Send exec_parameter.24-31, receive dummy/zero |
0000h..000Fh --> Request to Start GUI or File (with above parameter bits) 0010h..FFFDh --> Not used, acts same as FFFFh (see below) FFFEh --> Request to Destroy RTC and Start GUI (with parameter 00000000h) FFFFh --> Do nothing (transfer all bytes, but don't store the new values) |
Send Reply Comment 81h N/A Memory Card Access 5Ah FLAG Send Command 5Ah (0) 12h Send dummy/zero, receive length of following data (12h) (0) INDX Send dummy/zero, receive curr_dir_index.bit8-15 (00h) (0) INDX Send dummy/zero, receive curr_dir_index.bit0-7 (00h..0Fh) (0) FLG Send dummy/zero, receive ComFlags.bit0 (00h or 01h) (0) FLG Send dummy/zero, receive ComFlags.bit1 (00h or 01h) (0) FLG Send dummy/zero, receive ComFlags.bit3 (00h or 01h) (0) FLG Send dummy/zero, receive ComFlags.bit2 (00h or 01h) (0) SN Send dummy/zero, receive F_SN.bit0-7 (whatever) (0) SN Send dummy/zero, receive F_SN.bit8-15 (whatever) (0) SN Send dummy/zero, receive F_SN.bit16-23 (whatever) (0) SN Send dummy/zero, receive F_SN.bit24-31 (whatever) (0) DATE Send dummy/zero, receive BCD Day (01h..31h) (0) DATE Send dummy/zero, receive BCD Month (01h..12h) (0) DATE Send dummy/zero, receive BCD Year (00h..99h) (0) DATE Send dummy/zero, receive BCD Century (00h..99h) (0) TIME Send dummy/zero, receive BCD Second (00h..59h) (0) TIME Send dummy/zero, receive BCD Minute (00h..59h) (0) TIME Send dummy/zero, receive BCD Hour (00h..23h) (0) TIME Send dummy/zero, receive BCD Day of Week (01h..07h) |
Send Reply Comment 81h N/A Memory Card Access 5Eh FLAG Send Command 5Eh (0) 03h Send dummy/zero, receive length of following data (03h) NEW OLD Send new ComFlags.bit1, receive old ComFlags.bit1 (00h or 01h) NEW OLD Send new ComFlags.bit3, receive old ComFlags.bit3 (00h or 01h) NEW OLD Send new ComFlags.bit2, receive old ComFlags.bit2 (00h or 01h) |
Send Reply Comment 81h N/A Memory Card Access 5Fh FLAG Send Command 5Fh (0) 01h Send dummy/zero, receive length of following data (01h) NEW OLD Send new ComFlags.bit0, receive old ComFlags.bit0 (00h or 01h) |
| Pocketstation BU Custom Pocketstation Commands |
Send Reply Comment 81h N/A Memory Card Access 5Bh FLAG Send Command 5Bh FUNC FFh Send Function Number, receive FFh (indicating variable length) (0) LEN1 Send dummy/zero, receive length of parameters (depending on FUNC) ... (0) Send parameters (LEN1 bytes), and receive dummy/zero <-------- at this point, the function is executed for the first time (0) LEN2 Send dummy/zero, receive length of data (depending on FUNC) (0) ... Send dummy/zero, receive data (LEN2 bytes) from pocketstation (0) FFh Send dummy/zero, receive FFh <-------- at this point, the function is executed for the second time |
Send Reply Comment 81h N/A Memory Card Access 5Ch FLAG Send Command 5Ch FUNC FFh Send Function Number, receive FFh (indicating variable length) (0) LEN1 Send dummy/zero, receive length of parameters (depending on FUNC) ... (0) Send parameters (LEN1 bytes), and receive dummy/zero <-------- at this point, the function is executed for the first time (0) LEN2 Send dummy/zero, receive length of data (depending on FUNC) ... (0) Send data (LEN2 bytes) to pocketstation, receive dummy/zero (0) FFh Send dummy/zero, receive FFh <-------- at this point, the function is executed for the second time |
Send Reply Comment 81h N/A Memory Card Access 5Dh FLAG Send Command 5Dh (0) 03h Send dummy/zero, receive length of following data (03h) VAL (0) Send receive value.16-23 (whatever), receive dummy/zero VAL (0) Send receive value.8-15 (download flags), receive dummy/zero VAL (0) Send receive value.0-7 (download duration), receive dummy/zero |
If value.8-15 = 00h, then ComFlags.bit10=1, else ComFlags.bit10=0. If download_callback<>0 then call download_callback with r0=value.0-23. |
bit0-7 download duration (in whatever units... 30Hz, RTC, seconds...?) bit8 download finished (0=no, 1=yes, cancel any old/busy duration) bit9-23 not used by gui |
DATE Get or Send BCD Day (01h..31h) DATE Get or Send BCD Month (01h..12h) DATE Get or Send BCD Year (00h..99h) DATE Get or Send BCD Century (00h..99h) TIME Get or Send BCD Second (00h..59h) TIME Get or Send BCD Minute (00h..59h) TIME Get or Send BCD Hour (00h..23h) TIME Get or Send BCD Day of Week (01h..07h) |
ADDR Send Pocketstation Memory Address.bit0-7 ADDR Send Pocketstation Memory Address.bit8-15 ADDR Send Pocketstation Memory Address.bit16-23 ADDR Send Pocketstation Memory Address.bit24-31 LEN2 Send Desired Data Length (00h..80h, automatically clipped to max=80h) |
... Get or Send LEN2 Data byte(s), max 80h bytes |
DATA Get or Send Alarm.bit0-7, Alarm Minute (00h..59h, BCD) DATA Get or Send Alarm.bit8-15, Alarm Hour (00h..23h, BCD) DATA Get or Send Alarm.bit16-23, Flags, see SWI 13h, GetPtrToAlarmSetting() DATA Get or Send Alarm.bit24-31, Not used (usually 00h) DATA Get or Send Alarm.bit32-39, BIOS Charset Address.0-7 DATA Get or Send Alarm.bit40-47, BIOS Charset Address.8-15 DATA Get or Send Alarm.bit48-55, BIOS Charset Address.16-23 DATA Get or Send Alarm.bit56-63, BIOS Charset Address.24-31 |
VAL Send Parameter Value.bit0-7 VAL Send Parameter Value.bit8-15 VAL Send Parameter Value.bit16-23 VAL Send Parameter Value.bit24-31 |
... Get or Send LEN2 Data byte(s) |
... Send LEN1 Parameter Value(s), max 80h bytes (destroys Kernel when >80h) |
... Get or Send LEN2 Data byte(s), max 80h bytes (clipped to max=80h) |
;above LEN1 should be 00h..80h (the parameters are stored
;in a 80h-byte buffer in kernel RAM, so len LEN1=81h..FFh would
;destroy the kernel RAM that is located after that buffer)
|
r0=flags (09h=Pre-Data to PSX, or 0Ah=Pre-Data from PSX) r1=pointer to parameter buffer (which contains LEN1 bytes) (in Kernel RAM) |
r0 = Pointer to 64bit memory location (or r0=00000000h=Failed) |
0-31 BUF2 address of data buffer (src/dst) 32-63 LEN2 (00000000h..00000080h) (clipped to max 00000080h if bigger) |
r0=flags (11h=Post-Data to PSX, 12h=Post-Data from PSX; plus 04h if Bad-Data) r1=pointer to data buffer (which contains LEN2 bytes) (BUF2 address) |
There's no return value required on 2nd call (although the kernel functions seem to return the same stuff as on 1st call). |
0 To-PSX (when used by Command 5Bh) 1 From-PSX (when used by Command 5Ch) 2 Error occurred during Data transfer 3 Pre-Data 4 Post-Data 5-31 Not used (zero) |
09h Pre-Data to PSX 0Ah Pre-Data from PSX 11h Post-Data to PSX 12h Post-Data from PSX 15h Post-Bad-Data to PSX 16h Post-Bad-Data from PSX |
| Pocketstation File Header/Icons |
PSX Title Sector ;80h bytes PSX Colored Icon(s) ;(hdr[02h] AND 0Fh)*80h bytes Pocketstation Saved Snapshot ;800h bytes if hdr[52h]="MCX1", else 0 bytes Pocketstation Function Table ;(hdr[57h]*8+7Fh) AND NOT 7Fh bytes Pocketstation File Viewer Mono Icon ;hdr[50h]*80h bytes Pocketstation Executable Mono Icon List ;hdr[56h]*8 bytes Body (Pocketstation Executable Code/Data, PSX Game Position, Exec-Icons) |
50h 2 Number of File Viewer Mono Icon Frames (or 0000h=Use Exec-Icons)
52h 4 Pocketstation Identifier ("MCX0"=Normal, "MCX1"=With Snapshot)
56h 1 Number of entries in Executable Mono Icon List (01h..FFh)
57h 1 Number of BU Command 5Bh/5Ch Get/Set Functions (00h..7Fh, usually 00h)
58h 4 Reserved (zero)
5Ch 4 Entrypoint in FLASH1 (ie. Fileoffset plus 02000000h) (bit0=THUMB)
|
000h r1..r12 (ie. without r0) 030h r13_usr (sp_usr) 034h r14_usr (lr_usr) 038h r15 (pc) 03Ch psr_fc 040h Snapshot ID (0xh,00h,"SE") 044h unused (3Ch bytes) 200h Copy of user RAM at 200h..7FFh |
00h 4 LEN1 (00000000h..00000080h) (destroys Kernel RAM if bigger) 04h 4 Function Address (bit0 can be set for THUMB code) |
1st word = top-most scanline, 31st word = bottom-most scanline bit0 = left-most pixel, bit31 = right-most pixel (0=white, 1=black) |
00h 2 Animation Length (0001h..any number) (icon frames) 02h 2 Animation Delay (N 30Hz units per icon frame) 04h 4 Address of icon frame(s) in Virtual FLASH (at 02000000h and up) |
| Pocketstation File Images |
It seems as if the file (including the 4-byte ID) is intended to be
mapped to address 02000000h, and that the entrypoint is fixed at
02000004h (in ARM state).
Since the File doesn't have a valid file header with "SC" and "MCXn" IDs,
it won't be recognized by real hardware, the PSX BIOS would treat it as
a corrupted/deleted file, the Pocketstation BIOS would treat it as a
non-executable file.
So, that fileformat is apparently working only on whatever emulators,
apparently on the one developed by SN Systems.
If one should want to use that files on real hardware, one could add
a 2000h byte stub at the begin of the file; with valid headers, and
with a small executable that remaps the "SN" stuff to 02000000h via
the F_BANK_VAL registers.
Ah, and the "SN" files seem to access RAM at 01000000h and up, unknown
if RAM is mirrored to that location on real hardware, reportedly that
region is unused... and doesn't contain RAM...?
Some games use The Undefined Instruction for TTY Output.
Most games do strange 8bit writes to LCD_MODE+0 and LCD_MODE+1
The games usually don't allow to return to the GUI (except by Reset).
|
| Pocketstation XBOO Cable |
Pin CNTR DB25 Pocketstation _______________________ ACK 10 10 --------- 1 JOYDTA | | | | D0 2 2 --------- 2 JOYCMD | 9 7 6 | 5 4 3 | 2 1 | CARD GND 19-30 18-25 ------- 4 GND |_______|_______|_______| D1 3 3 --------- 6 /JOYSEL _______________________ D2 4 4 --------- 7 JOYCLK | | | | PE 12 12 --------- 9 /JOYACK (/IRQ7) | 9 8 7 | 6 5 4 | 3 2 1 | PAD NC -------------------- 8 /JOYGUN (/IRQ10) \______|_______|______/ NC -------------------- 3 7.5V (rumble.supply) SUPPLY.5V --|>|---|>|-- 5 3.5V (VCC) (eg. PC's +5V via two 1N4001 diodes) SUPPLY.0V ------------- 4 GND (not needed when same as GND on CNTR/DB25) |
TitleSector[58h] = "TTY+" |
;------------------
.data?
org 200h
...
tty_bufsiz equ 128 ;max=128=fastest (can be smaller if you are short of RAM)
func3_info: ;\ ;\
func3_buf_base dd 0 ;fixed="func3_buf" ; ; func3_info+00h
func3_buf_len dd 0 ;range=0..128 ;/ ; func3_info+04h
func3_stack dd 0 ; func3_info+08h
func3_buffer: defs tty_bufsiz ;/ func3_info+0Ch
ptr_to_comflags dd 0
...
.code
...
;------------------
tty_wrchr: ;in: r0=char
dd 0e6000010h ;=undef opcode ;-Write chr(r0) to TTY
bx lr
;------------------
init_tty: ;in: r0=param (from entrypoint)
ldr r1,=2B595454h ;"TTY+" ;\check if xboo-cable present
cmp r1,r0 ; (r0=incoming param from
beq @@tty_by_xboo_cable ;/executable's entrypoint)
;- - -
mov r1,0 ;\dummy und_handler
ldr r2,=0e1b0f00eh ;=movs r15,r14 ; (just return from exception,
str r2,[r1,04h] ;und_handler ;/for normal cable-less mode)
b @@finish
;---
@@tty_by_xboo_cable:
swi 17h ;GetPtrToFunc3addr() ;\
ldr r1,=(tty_func3_handler AND 0ffffh) ; init FUNC3 aka TTY handler
strh r1,[r0] ;/
ldr r1,=func3_info ;\
mov r0,0 ;\ ; mark TTY as len=empty
str r0,[r1,4] ;func3_buf_len ;/ ; and
add r0,r1,0ch ;=func3_buffer ;\ ; init func3 base
str r0,[r1,0] ;func3_buf_base ;/ ;/
mov r1,0 ;\
ldr r2,=0e59ff018h ;=ldr r15,[pc,NN] ;
str r2,[r1,04h] ;und_handler ; special xboo und_handler
add r2,=tty_xboo_und_handler ;
str r2,[r1,24h] ;und_vector ;/
@@finish:
swi 06h ;GetPtrToComFlags() ;\
ldr r1,=ptr_to_comflags ; get ptr to ComFlags
str r0,[r1] ;/
bx lr
;------------------
tty_xboo_und_handler: ;in: r0=char
ldr r13,=func3_info ;aka sp_und ;-base address (in sp_und)
str r12,[r13,8] ;func3_stack ;-push r12
@@wait_if_buffer_full: ;\
ldr r12,=ptr_to_comflags ; ;\exit if execute file request
ldr r12,[r12] ;ptr to ComFlags ; ; ComFlg.Bit11 ("bu_cmd_59h"),
ldr r12,[r12] ;read ComFlags ; ; ie. allow that flag to be
tst r12,1 shl 11 ;test bit11 ; ; processed by main program,
bne @@exit ; ;/without hanging here
ldrb r12,[r13,4] ;func3_buf_len ; wait if buffer full
cmp r12,tty_bufsiz ; (until drained by FIQ)
beq @@wait_if_buffer_full ;/
mov r12,1bh+0c0h ;mode=und, FIQ/IRQ=off ;\disable FIQ (no COMMUNICATION
mov cpsr_ctl,r12 ;/interrupt during buffer write)
ldrb r12,[r13,4] ;func3_buf_len ;\
add r12,1 ;raise len ; write char to buffer
strb r12,[r13,4] ;func3_buf_len ; and raise buffer length
add r12,0ch-1 ;=func3_buffer+INDEX ;
strb r0,[r13,r12] ;append char to buf ;/
@@exit:
ldr r12,[r13,8] ;func3_stack ;-pop r12
movs r15,r14 ;return from exception (and restore old IRQ/FIQ state)
;------------------
tty_func3_handler: ;in: r0=flags, r1=ptr
tst r0,10h ;test if PRE/POST data (pre: Z, post: NZ)
;ldreq r1,[r1] ;read 32bit param (aka the four LEN1 bytes of FUNC3)
ldr r0,=func3_info ;ptr to two 32bit values (FUNC3 return value)
movne r1,0 ;\for POST data: mark buffer empty
strne r1,[r0,4] ;func3_buf_len=0 ;/
bx lr ;-for PRE data: return r0=func3_info
|
| Serial Port (SIO) |
0-7 Data to be sent 8-31 Not used |
0-7 Received Data (1st RX FIFO entry) (oldest entry) 8-15 Preview (2nd RX FIFO entry) 16-23 Preview (3rd RX FIFO entry) 24-31 Preview (4th RX FIFO entry) (5th..8th cannot be previewed) |
0 TX Ready Flag 1 (1=Ready/Started) (depends on CTS) (TX requires CTS) 1 RX FIFO Not Empty (0=Empty, 1=Not Empty) 2 TX Ready Flag 2 (1=Ready/Finished) (depends on TXEN and on CTS) 3 RX Parity Error (0=No, 1=Error; Wrong Parity, when enabled) (sticky) 4 RX FIFO Overrun (0=No, 1=Error; Received more than 8 bytes) (sticky) 5 RX Bad Stop Bit (0=No, 1=Error; Bad Stop Bit) (when RXEN) (sticky) 6 RX Input Level (0=Normal, 1=Inverted) ;only AFTER receiving Stop Bit 7 DSR Input Level (0=Off, 1=On) (remote DTR) ;DSR not required to be on 8 CTS Input Level (0=Off, 1=On) (remote RTS) ;CTS required for TX 9 Interrupt Request (0=None, 1=IRQ) (sticky) 10 Unknown (always zero) 11-25 Baudrate Timer (15bit timer, decrementing at 33MHz) 26-31 Unknown (usually zero, sometimes all bits set) |
0-1 Baudrate Reload Factor (1=MUL1, 2=MUL16, 3=MUL64) (or 0=STOP) 2-3 Character Length (0=5bits, 1=6bits, 2=7bits, 3=8bits) 4 Parity Enable (0=No, 1=Enable) 5 Parity Type (0=Even, 1=Odd) (seems to be vice-versa...?) 6-7 Stop bit length (0=Reserved/1bit, 1=1bit, 2=1.5bits, 3=2bits) 8-15 Not used (always zero) |
0 TX Enable (TXEN) (0=Disable, 1=Enable, when CTS=On) 1 DTR Output Level (0=Off, 1=On) 2 RX Enable (RXEN) (0=Disable, 1=Enable) ;Disable also clears RXFIFO 3 TX Output Level (0=Normal, 1=Inverted, during Inactivity & Stop bits) 4 Acknowledge (0=No change, 1=Reset SIO_STAT.Bits 3,4,5,9) (W) 5 RTS Output Level (0=Off, 1=On) 6 Reset (0=No change, 1=Reset most SIO_registers to zero) (W) 7 Unknown? (read/write-able when FACTOR non-zero) (otherwise always zero) 8-9 RX Interrupt Mode (0..3 = IRQ when RX FIFO contains 1,2,4,8 bytes) 10 TX Interrupt Enable (0=Disable, 1=Enable) ;when SIO_STAT.0-or-2 ;Ready 11 RX Interrupt Enable (0=Disable, 1=Enable) ;when N bytes in RX FIFO 12 DSR Interrupt Enable (0=Disable, 1=Enable) ;when SIO_STAT.7 ;DSR=On 13-15 Not used (always zero) |
0-15 Baudrate Reload value for decrementing Baudrate Timer |
BitsPerSecond = (44100Hz*300h) / MIN(((Reload*Factor) AND NOT 1),Factor) |
JOY_BAUD is multiplied by Factor, and does then ellapse "2" times per bit. SIO_BAUD is NOT multiplied, and, instead, ellapses "2*Factor" times per bit. |
| Expansion Port (PIO) |
| EXP1 Expansion ROM Header |
Address Size Content
1F000000h 4 Post-Boot Entrypoint (eg. 1F000100h and up)
1F000004h 2Ch Post-Boot ID ("Licensed by Sony Computer Entertainment Inc.")
1F000030h 50h Post-Boot TTY Message (must contain at least one 00h byte)
1F000080h 4 Pre-Boot Entrypoint (eg. 1F000100h and up)
1F000084h 2Ch Pre-Boot ID ("Licensed by Sony Computer Entertainment Inc.")
1F0000B0h 50h Not used (should be zero, but may contain code/data/io)
1F000100h .. Code, Data, I/O Ports, etc.
|
| EXP2 Dual Serial Port (for TTY Debug Terminal) |
7-0 Data (aka Character) |
7 RxRTS Control (0=No, 1=Yes) 6 RxINT Select (0=RxRDY, 1=FFULL) 5 Error Mode (0=Char, 1=Block) 4-3 Parity Mode (0=With Parity, 1=Force Parity, 2=No Parity, 3=Multidrop) 2 Parity Type (0=Even, 1=Odd) 1-0 Bits per Character (0=5bit, 1=6bit, 2=7bit, 3=8bit) |
7-6 Channel Mode (0=Normal, 1=Auto-Echo, 2=Local loop, 3=Remote loop) 5 TxRTS Control (0=No, 1=Yes) (when 1 --> OP0=RTSA / OP1=RTSB) 4 CTS Enable (0=No, 1=Yes) (when 1 --> IP0=CTSA / IP1=CTSB) 3-0 Tx Stop Bit Length (00h..0Fh = see below) |
0=0.563 1=0.625 2=0.688 3=0.750 4=0.813 5=0.875 6=0.938 7=1.000 8=1.563 9=1.625 A=1.688 B=1.750 C=1.813 D=1.875 E=1.938 F=2.000 |
7-4 Rx Clock Select (0..0Ch=See Table, 0Dh=Timer, 0Eh=16xIP, 0Fh=1xIP) 3-0 Tx Clock Select (0..0Ch=See Table, 0Dh=Timer, 0Eh=16xIP, 0Fh=1xIP) |
Rate 00h 01h 02h 03h 04h 05h 06h 07h 08h 09h 0Ah 0Bh 0Ch Set1 50 110 134.5 200 300 600 1200 1050 2400 4800 7200 9600 38400 Set2 75 110 134.5 150 300 600 1200 2000 2400 4800 1800 9600 19200 Set3 4800 880 1076 19200 28800 57600 115200 1050 57600 4800 57600 9600 38400 Set4 7200 880 1076 14400 28800 57600 115200 2000 57600 4800 14400 9600 19200 |
7 Not used (should be 0) 6-4 Miscellaneous Commands (0..7 = see below) 3 Disable Tx (0=No change, 1=Disable) 2 Enable Tx (0=No change, 1=Enable) ;Don't use with Command 3 (Reset Rx) 1 Disable Rx (0=No change, 1=Disable) 0 Enable Rx (0=No change, 1=Enable) ;Don't use with Command 2 (Reset Tx) |
0 No command ;no effect 1 Reset MR pointer ;force "FirstAccess" state for MR1A (or MR1B) access 2 Reset receiver ;reset RxA (or RxB) registers, disable Rx, flush Fifo 3 Reset transmitter ;reset TxA (or TxB) registers 4 Reset Error Flags ;reset SRA.7-4 (or SRB.7-4) to zero 5 Reset Break-Change IRQ Flag ;reset ISR.2 (or ISR.6) to zero 6 Start break ;after current char, pause Tx with TxDA=Low (or TxDB=Low) 7 Stop break ;output one High bit, then continue Tx (ie. undo pause) |
7 Input Port Change (0=No, 1=Yes) (Ack via reading IPCR) ;see ACR.3-0 6 Break Change B (0=No, 1=Yes) (Ack via CRB/Command5) 5 RxRDYB/FFULLB (0=No, 1=Yes) (Ack via reading data) ;see MR1B.6 4 THRB Empty (TxRDYB) (0=No, 1=Yes) (Ack via writing data) ;same as SRB.2 3 Counter Ready (0=No, 1=Yes) (Ack via CT_STOP) 2 Break Change A (0=No, 1=Yes) (Ack via CRA/Command5) 1 RxRDYA/FFULLA (0=No, 1=Yes) (Ack via reading data) ;see MR1A.6 0 THRA Empty (TxRDYA) (0=No, 1=Yes) (Ack via writing data) ;same as SRA.2 |
7 Rx Received Break* (0=No, 1=Yes) ;received 00h without stop bit 6 Rx Framing Error* (0=No, 1=Yes) ;received data without stop bit 5 Rx Parity Error* (0=No, 1=Yes) ;received data with bad parity 4 Rx Overrun Error (0=No, 1=Yes) ;Rx FIFO full + RxShiftReg full 3 Tx Underrun (TxEMT) (0=No, 1=Yes) ;both TxShiftReg and THR empty 2 Tx THR Empty (TxRDY) (0=No, 1=Yes) ;same as ISR.0 / ISR.4 1 Rx FIFO Full (FFULL) (0=No, 1=Yes) ;set upon 3 or more characters 0 Rx FIFO Not Empty (RxRDY) (0=No, 1=Yes) ;set upon 1 or more characters |
7 Select Baud Rate Generator (BRG) Set (0=Set1/Set3, 1=Set2/Set4) 6-4 Counter/Timer Mode and Source (see below) 3-0 IP3..IP0 Change Interrupt Enable Flags (0=Off, 1=On) |
Num Mode Clock Source 0h Counter External (IP2) 1h Counter TxCA - 1x clock of Channel A transmitter 2h Counter TxCB - 1x clock of Channel B transmitter 3h Counter Crystal or external clock (x1/CLK) divided by 16 4h Timer External (IP2) 5h Timer External (IP2) divided by 16 6h Timer Crystal or external clock (x1/CLK) 7h Timer Crystal or external clock (x1/CLK) divided by 16 |
7-4 IP3..IP0 Change Occured Flags (0=No, 1=Yes) ;auto reset after read 3-0 Current IP3-IP0 Input states (0=Low, 1=High) ;Same as IP.3-0 |
7 Not used (always 1) 6-0 Current IP6-IP0 Input states (0=Low, 1=High) ;LSBs = Same as IPCR.3-0 |
IP6 External RxB Clock ;see CSRB.7-4 IP5 External TxB Clock ;see CSRB.3-0 IP4 External RxA Clock ;see CSRA.7-4 IP3 External TxA Clock ;see CSRA.3-0 IP2 External Timer Input ;see AUX.6-4 IP1 Clear to Send B (CTSB) ;see MR2B.5 IP0 Clear to Send A (CTSA) ;see MR2A.5 |
7-0 Change "OPR" OP7-OP0 Output states (0=No change, 1=Set/Reset) |
7 OP7 (0=OPR.7, 1=TxRDYB) 6 OP6 (0=OPR.6, 1=TxRDYA) 5 OP5 (0=OPR.5, 1=RxRDY/FFULLB) 4 OP4 (0=OPR.4, 1=RxRDY/FFULLA) 3-2 OP3 (0=OPR.3, 1=Clock/Timer Output, 2=TxCB(1x), 3=RxCB(1x)) 1-0 OP2 (0=OPR.2, 1=TxCA(16x), 2=TxCA(1x), 3=RxCA(1x)) |
7-0 Not used (just issue a dummy-read to toggle the test mode on/off) |
7-0 Not used (just issue a dummy-read to strobe start/stop command) |
24pin basic cut-down version ;without IP0-1/OP0-1 = without CTS/RTS 28pin additional IP2,OP0,OP1,X2 ;without IP0-1 = without CTS 40pin additional IP0-IP6,OP0-OP7,X2 ;full version 44pin same as 40pin with four NC pins ;full version (SMD) |
| EXP2 DTL-H2000 I/O Ports |
0 Unknown, used for something 1 Unknown/unused 2 Unknown, used for something 3 TTY/Atcons TX Ready (0=Busy, 1=Ready) 4 TTY/Atcons RX Available (0=None, 1=Yes) 5-7 Unknown/unused |
0-7 TTY/Atcons RX/TX Data |
0-15 Data...? |
0 ... used for something 1 Lightgun IRQ (write: 0=No change, 1=Acknowledge) (read: 0=None, 1=IRQ) 2-3 Unknown/unused (write: 0=Normal) 4 ... acknowledged at 1FA00B04h, otherwise unused 5 ... TTY RX ? 6-7 Unknown/unused (write: 0=Normal) 8-31 Not used by DTL-H2000 BIOS (but Lightgun games write 0 to these bits) |
IF [BFC00104h]=00002000h then Port 1F802030h does exist (DTL-H2000) IF [BFC00104h]=00002500h then Port 1F802030h does NOT exist IF [BFC00104h]=00000003h then Port 1F802030h does NOT exist (default) IF [BFC00104h]= <other> then Port 1F802030h does NOT exist |
0 Used for something (CLEARED on some occassions) 1-3 Unknown/unused 4 Used for something (SET on some occassions) 5-7 Unknown/unused |
0-7 DIP Value (00h..FFh, but should be usually 00h..02h) |
DIP=0 --> .. long delay before TTY? with "PSX>" prompt, throws CDROM cmds DIP=1 --> .. long delay before TTY? no "PSX>" prompt PSY-Q? DIP=2 --> .. instant TTY? with "PSX>" prompt DIP=3 --> Lockup DIP=04h..FFh --> Lockup with POST=04h..FFh |
| EXP2 Post Registers |
0-3 Current Boot Status (00h..0Fh) 4-7 Not used by BIOS (always set to 0) |
0-7 Post/LED value |
| EXP2 Nocash Emulation Expansion |
0 CDROM Turbo (0=Normal, 1=Turbo) 1 Memory Card Turbo (0=Normal, 1=Turbo) 2 Controller Turbo (0=Normal, 1=Turbo) 3-6 Reserved (must be zero) 7 VRAM Viewer (0=Normal, 1=Disable Swap Buffers; for testing) |
| Memory Control |
0-23 Base Address (Read/Write) 24-31 Fixed (Read only, always 1Fh) |
0-3 Unknown (R/W) 4-7 Access Time (00h..0Fh=00h..0Fh Cycles) 8 Use COM0 Time (0=No, 1=Yes, add to Access Time) 9 Use COM1 Time (0=No, 1=Probably Yes, but has no effect?) 10 Use COM2 Time (0=No, 1=Yes, add to Access Time) 11 Use COM3 Time (0=No, 1=Yes, clip to MIN=(COM3+6) or so?) 12 Data Bus-width (0=8bit, 1=16bit) 13-15 Unknown (R/W) 16-20 Memory Window Size (1 SHL N bytes) (0..1Fh = 1 byte ... 2 gigabytes) 21-23 Unknown (always zero) 24-27 Unknown (R/W) ;must be non-zero for SPU-RAM reads 28 Unknown (always zero) 29 Unknown (R/W) 30 Unknown (always zero) 31 Unknown (R/W) (Port 1F801008h only; always zero for other ports) |
0-3 COM0 - Offset A ;used for SPU/EXP2 (and for adjusted CDROM timings) 4-7 COM1 - No effect? ;used for EXP2 8-11 COM2 - Offset B ;used for BIOS/EXP1/EXP2 12-15 COM3 - Min Value ;used for CDROM 16-17 COM? - Unknown ;used for whatever 18-31 Unknown/unused (read: always 0000h) |
1ST=0, SEQ=0, MIN=0 IF Use_COM0 THEN 1ST=1ST+COM0-1, SEQ=SEQ+COM0-1 IF Use_COM2 THEN 1ST=1ST+COM2, SEQ=SEQ+COM2 IF Use_COM3 THEN MIN=COM3 IF 1ST<6 THEN 1ST=1ST+1 ;(somewhat like so) 1ST=1ST+AccessTime+2, SEQ=SEQ+AccessTime+2 IF 1ST<(MIN+6) THEN 1ST=(MIN+6) IF SEQ<(MIN+2) THEN SEQ=(MIN+2) |
0-2 Unknown (no effect) 3 Crashes when zero (except PU-7 and EARLY-PU-8, which <do> use bit3=0) 4-6 Unknown (no effect) 7 Delay on simultaneous CODE+DATA fetch from RAM (0=None, 1=One Cycle) 8 Unknown (no effect) (should be set for 8MB, cleared for 2MB) 9-11 Define 8MB Memory Window (first 8MB of KUSEG,KSEG0,KSEG1) 12-15 Unknown (no effect) 16-31 Unknown (Garbage) |
0 = 1MB Memory + 7MB Locked 1 = 4MB Memory + 4MB Locked 2 = 1MB Memory + 1MB HighZ + 6MB Locked 3 = 4MB Memory + 4MB HighZ 4 = 2MB Memory + 6MB Locked ;<--- would be correct for PSX 5 = 8MB Memory ;<--- default by BIOS init 6 = 2MB Memory + 2MB HighZ + 4MB Locked ;<-- HighZ = Second /RAS 7 = 8MB Memory |
0-2 Unknown (Read/Write) (R/W) 3 Scratchpad Enable 1 (0=Disable, 1=Enable when Bit7 is set, too) (R/W) 4-5 Unknown (Read/Write) (R/W) 6 Unknown (read=always zero) (R) or (W) or unused..? 7 Scratchpad Enable 2 (0=Disable, 1=Enable when Bit3 is set, too) (R/W) 8 Unknown (R/W) 9 Crash (0=Normal, 1=Crash if code-cache enabled) (R/W) 10 Unknown (read=always zero) (R) or (W) or unused..? 11 Code-Cache Enable (0=Disable, 1=Enable) (R/W) 12-31 Unknown (R/W) |
Init Cache Step 1: [FFFE0130h]=00000804h, then set cop0_sr=00010000h, then zerofill each FOURTH word at [0000..0FFFh], then set cop0_sr=zero. Init Cache Step 2: [FFFE0130h]=00000800h, then set cop0_sr=00010000h, then zerofill ALL words at [0000h..0FFFh], then set cop0_sr=zero. Finish Initialization: read 8 times 32bit from [A0000000h], then set [FFFE0130h]=0001E988h |
0 LOCK Lock Mode 1 INV Invalidate Mode 2 TAG Tag Test Mode 3 RAM Scratchpad RAM 4-5 DBLKSZ D-Cache Refill Size 6 0 Zero 7 DS D-Cache Enable 8-9 IBLKSZ I-Cache Refill Size (IS USED, crashes when bit9=1) 10 IS0 I-Cache Set 0 (unused? should be 0) 11 IS1 I-Cache Set 1 IRAM Enable (aka code cache) 12 INTP Interrupt Polarity (unused? should be 0) 13 RDPRI Read Priority 14 NOPAD No Waitstate 15 BGNT Bus Grant (unused? should be 0) 16 LDSCH Load Scheduling (1=Enable) 17 NOSTR No Streaming (unused? should be 0) 18-31 R Reserved (should be 0) |
| Unpredictable Things |
Address Content W.8bit W.16bit W.32bit 00000000h-00xFFFFFh Main RAM OK OK OK 1F800000h-1F8003FFh Scratchpad OK OK OK 1F801000h-1F801023h MEMCTRL (w32) (w32) OK 1F80104xh JOY_xxx (w16) OK CROP 1F80105xh SIO_xxx (w16) OK CROP 1F801060h-1F801063h RAM_SIZE (w32) (w32) OK (with crash) 1F801070h-1F801077h IRQCTRL (w32) (w32) OK 1F8010x0h-1F8010x3h DMAx.ADDR (w32) (w32) OK 1F8010x4h-1F8010x7h DMAx.LEN OK OK OK 1F8010x8h-1F8010xFh DMAx.CTRL/MIRR (w32) (w32) OK 1F8010F0h-1F8010F7h DMA.DPCR/DICR (w32) (w32) OK 1F8010F8h-1F8010FFh DMA.unknown IGNORE IGNORE IGNORE 1F801100h-1F80110Bh Timer 0 (w32) (w32) OK 1F801110h-1F80111Bh Timer 1 (w32) (w32) OK 1F801120h-1F80112Bh Timer 2 (w32) (w32) OK 1F801800h-1F801803h CDROM OK ? ? 1F801810h-1F801813h GPU.GP0 ? ? OK 1F801814h-1F801817h GPU.GP1 ? ? OK 1F801820h-1F801823h MDEC.CMD/DTA ? ? OK 1F801824h-1F801827h MDEC.CTRL ? ? OK 1F801C00h-1F801E7Fh SPU (i16) OK LOSSY 1F801E80h-1F801FFFh SPU.UNUSED IGNORE IGNORE IGNORE 1F802020h-1F80202Fh DUART OK ? ? 1F802041h POST OK ? ? FFFE0130h-FFFE0133h CACHE.CTRL (i32) (i32) OK |
OK works LOSSY works often, but may leave lower 16bit unchanged at 1:8 chance (w32) write full 32bits (left-shifted if address isn't word-aligned) (w16) write full 16bits (left-shifted if address isn't halfword-aligned) (i32) write full 32bits (ignored if address isn't word-aligned) (i16) write full 16bits (ignored if address isn't halfword-aligned) CROP write only lower 16bit (and leave upper 16bit unchanged) |
FFFE0130h-FFFE0133h 8bit (+16bit?) read works ONLY from word-aligned address |
00800000h ;-when Main RAM configured to end at 7FFFFFh 1F080000h 780000h ;-when Expansion 1 configured to end at 7FFFFh 1F800400h C00h ;-region after Scratchpad 1F801024h 1Ch ;\ 1F801064h 0Ch ; 1F801078h 08h ; 1F801140h 6C0h ; gaps in I/O region 1F801804h 0Ch ; 1F801818h 08h ; 1F801828h 3D8h ;/ 1F802080h 3FDF80h ;-when Expansion 2 configured to end at 7Fh 1FC80000h 60380000h ;-when BIOS ROM configured to end at 7FFFFh C0000000h 1FFE0000h ;\ FFFE0020h E0h ; gaps in KSEG2 (cache control region) FFFE0140h 1FEC0h ;/ |
1F80108Ch+N*10h - D#_CHCR Mirrors - (N=0..6, for DMA channel 0..6) |
1F801062h (2 bytes) ;\ 1F801072h (2 bytes) ; unused addresses in Memory and Interrupt Control area 1F801076h (2 bytes) ;/ 1F801102h (2 bytes) ;\ 1F801106h (2 bytes) ; unused addresses in Timer 0 area 1F80110Ah (6 bytes) ;/ 1F801112h (2 bytes) ;\ 1F801116h (2 bytes) ; unused addresses in Timer 1 area 1F80111Ah (6 bytes) ;/ 1F801122h (2 bytes) ;\ 1F801126h (2 bytes) ; unused addresses in Timer 2 area and next some bytes 1F80112Ah (6 bytes) ; 1F801130h (16 bytes) ;/ 1F801820h (4 bytes) ;-read MDEC Data-Out port (if there is no data) FFFE0000h (32 bytes) ;\ FFFE0100h (48 bytes) ; unused addresses in Cache control area FFFE0132h (2 bytes) ; (including write-only upper 16bit of Port FFFE0130h) FFFE0134h (12 bytes) ;/ |
| CPU Specifications |
| CPU Registers |
Name Alias Common Usage (R0) zero Constant (always 0) (this one isn't a real register) R1 at Assembler temporary (destroyed by some pseudo opcodes!) R2-R3 v0-v1 Subroutine return values, may be changed by subroutines R4-R7 a0-a3 Subroutine arguments, may be changed by subroutines R8-R15 t0-t7 Temporaries, may be changed by subroutines R16-R23 s0-s7 Static variables, must be saved by subs R24-R25 t8-t9 Temporaries, may be changed by subroutines R26-R27 k0-k1 Reserved for kernel (destroyed by some IRQ handlers!) R28 gp Global pointer (rarely used) R29 sp Stack pointer R30 fp(s8) Frame Pointer, or 9th Static variable, must be saved R31 ra Return address (used so by JAL,BLTZAL,BGEZAL opcodes) - pc Program counter - hi,lo Multiply/divide results, may be changed by subroutines |
sub sp,20h mov [sp+14h],ra mov [sp+18h],r16 mov [sp+1Ch],r17 |
[sp+00h..0Fh] wasted stack (may, or may not, be used by sub-functions) [sp+10h..13h] 8-byte alignment padding (not used) [sp+14h..1Fh] pushed registers |
| CPU Opcode Encoding |
00h=SPECIAL 08h=ADDI 10h=COP0 18h=N/A 20h=LB 28h=SB 30h=LWC0 38h=SWC0 01h=BcondZ 09h=ADDIU 11h=COP1 19h=N/A 21h=LH 29h=SH 31h=LWC1 39h=SWC1 02h=J 0Ah=SLTI 12h=COP2 1Ah=N/A 22h=LWL 2Ah=SWL 32h=LWC2 3Ah=SWC2 03h=JAL 0Bh=SLTIU 13h=COP3 1Bh=N/A 23h=LW 2Bh=SW 33h=LWC3 3Bh=SWC3 04h=BEQ 0Ch=ANDI 14h=N/A 1Ch=N/A 24h=LBU 2Ch=N/A 34h=N/A 3Ch=N/A 05h=BNE 0Dh=ORI 15h=N/A 1Dh=N/A 25h=LHU 2Dh=N/A 35h=N/A 3Dh=N/A 06h=BLEZ 0Eh=XORI 16h=N/A 1Eh=N/A 26h=LWR 2Eh=SWR 36h=N/A 3Eh=N/A 07h=BGTZ 0Fh=LUI 17h=N/A 1Fh=N/A 27h=N/A 2Fh=N/A 37h=N/A 3Fh=N/A |
00h=SLL 08h=JR 10h=MFHI 18h=MULT 20h=ADD 28h=N/A 30h=N/A 38h=N/A 01h=N/A 09h=JALR 11h=MTHI 19h=MULTU 21h=ADDU 29h=N/A 31h=N/A 39h=N/A 02h=SRL 0Ah=N/A 12h=MFLO 1Ah=DIV 22h=SUB 2Ah=SLT 32h=N/A 3Ah=N/A 03h=SRA 0Bh=N/A 13h=MTLO 1Bh=DIVU 23h=SUBU 2Bh=SLTU 33h=N/A 3Bh=N/A 04h=SLLV 0Ch=SYSCALL 14h=N/A 1Ch=N/A 24h=AND 2Ch=N/A 34h=N/A 3Ch=N/A 05h=N/A 0Dh=BREAK 15h=N/A 1Dh=N/A 25h=OR 2Dh=N/A 35h=N/A 3Dh=N/A 06h=SRLV 0Eh=N/A 16h=N/A 1Eh=N/A 26h=XOR 2Eh=N/A 36h=N/A 3Eh=N/A 07h=SRAV 0Fh=N/A 17h=N/A 1Fh=N/A 27h=NOR 2Fh=N/A 37h=N/A 3Fh=N/A |
31..26 |25..21|20..16|15..11|10..6 | 5..0 | 6bit | 5bit | 5bit | 5bit | 5bit | 6bit | -------+------+------+------+------+--------+------------ 000000 | N/A | rt | rd | imm5 | 0000xx | shift-imm 000000 | rs | rt | rd | N/A | 0001xx | shift-reg 000000 | rs | N/A | N/A | N/A | 001000 | jr 000000 | rs | N/A | rd | N/A | 001001 | jalr 000000 | <-----comment20bit------> | 00110x | sys/brk 000000 | N/A | N/A | rd | N/A | 0100x0 | mfhi/mflo 000000 | rs | N/A | N/A | N/A | 0100x1 | mthi/mtlo 000000 | rs | rt | N/A | N/A | 0110xx | mul/div 000000 | rs | rt | rd | N/A | 10xxxx | alu-reg 000001 | rs | 00000| <--immediate16bit--> | bltz 000001 | rs | 00001| <--immediate16bit--> | bgez 000001 | rs | 10000| <--immediate16bit--> | bltzal 000001 | rs | 10001| <--immediate16bit--> | bgezal 000001 | rs | xxxx0| <--immediate16bit--> | bltz ;\undocumented dupes 000001 | rs | xxxx1| <--immediate16bit--> | bgez ;/(when bit17-19=nonzero) 00001x | <---------immediate26bit---------> | j/jal 00010x | rs | rt | <--immediate16bit--> | beq/bne 00011x | rs | N/A | <--immediate16bit--> | blez/bgtz 001xxx | rs | rt | <--immediate16bit--> | alu-imm 001111 | N/A | rt | <--immediate16bit--> | lui-imm 100xxx | rs | rt | <--immediate16bit--> | load rt,[rs+imm] 101xxx | rs | rt | <--immediate16bit--> | store rt,[rs+imm] x1xxxx | <------coprocessor specific------> | coprocessor (see below) |
31..26 |25..21|20..16|15..11|10..6 | 5..0 | 6bit | 5bit | 5bit | 5bit | 5bit | 6bit | -------+------+------+------+------+--------+------------ 0100nn |0|0000| rt | rd | N/A | 000000 | MFCn rt,rd_dat ;rt = dat 0100nn |0|0010| rt | rd | N/A | 000000 | CFCn rt,rd_cnt ;rt = cnt 0100nn |0|0100| rt | rd | N/A | 000000 | MTCn rt,rd_dat ;dat = rt 0100nn |0|0110| rt | rd | N/A | 000000 | CTCn rt,rd_cnt ;cnt = rt 0100nn |0|1000|00000 | <--immediate16bit--> | BCnF target ;jump if false 0100nn |0|1000|00001 | <--immediate16bit--> | BCnT target ;jump if true 0100nn |1| <--------immediate25bit--------> | COPn imm25 010000 |1|0000| N/A | N/A | N/A | 000001 | COP0 01h ;=TLBR ;\if any 010000 |1|0000| N/A | N/A | N/A | 000010 | COP0 02h ;=TLBWI ; (not on 010000 |1|0000| N/A | N/A | N/A | 000110 | COP0 06h ;=TLBWR ; psx) 010000 |1|0000| N/A | N/A | N/A | 001000 | COP0 08h ;=TLBP ;/ 010000 |1|0000| N/A | N/A | N/A | 010000 | COP0 10h ;=RFE 1100nn | rs | rt | <--immediate16bit--> | LWCn rt_dat,[rs+imm] 1110nn | rs | rt | <--immediate16bit--> | SWCn rt_dat,[rs+imm] |
| CPU Load/Store Opcodes |
movbs rt,[imm+rs] lb rt,imm(rs) rt=[imm+rs] ;byte sign-extended movb rt,[imm+rs] lbu rt,imm(rs) rt=[imm+rs] ;byte zero-extended movhs rt,[imm+rs] lh rt,imm(rs) rt=[imm+rs] ;halfword sign-extended movh rt,[imm+rs] lhu rt,imm(rs) rt=[imm+rs] ;halfword zero-extended mov rt,[imm+rs] lw rt,imm(rs) rt=[imm+rs] ;word |
movb [imm+rs],rt sb rt,imm(rs) [imm+rs]=(rt AND FFh) ;store 8bit movh [imm+rs],rt sh rt,imm(rs) [imm+rs]=(rt AND FFFFh) ;store 16bit mov [imm+rs],rt sw rt,imm(rs) [imm+rs]=rt ;store 32bit |
movr rt,[imm+rs] lwr rt,imm(rs) load rt.LSBs from memory (usually imm+0) movl rt,[imm+rs] lwl rt,imm(rs) load rt.MSBs from memory (usually imm+3) movr [imm+rs],rt swr rt,imm(rs) store rt.LSBs to memory (usually imm+0) movl [imm+rs],rt swl rt,imm(rs) store rt.MSBs to memory (usually imm+3) |
lwl r2,$0003(t0) ;\no delay required between these lwr r2,$0000(t0) ;/(although both access r2) nop ;-requires load delay HERE (before reading from r2) and r2,r2,0ffffh ;-access r2 (eg. reducing it to unaligned 16bit data) |
lwr/swr [N*4+0] transfer whole 32bit of Rt to/from [N*4+0..3] lwr/swr [N*4+1] transfer lower 24bit of Rt to/from [N*4+1..3] lwr/swr [N*4+2] transfer lower 16bit of Rt to/from [N*4+2..3] lwr/swr [N*4+3] transfer lower 8bit of Rt to/from [N*4+3] |
lwl/swl [N*4+0] transfer upper 8bit of Rt to/from [N*4+0] lwl/swl [N*4+1] transfer upper 16bit of Rt to/from [N*4+0..1] lwl/swl [N*4+2] transfer upper 24bit of Rt to/from [N*4+0..2] lwl/swl [N*4+3] transfer whole 32bit of Rt to/from [N*4+0..3] |
| CPU ALU Opcodes |
addt rd,rs,rt add rd,rs,rt rd=rs+rt (with overflow trap) add rd,rs,rt addu rd,rs,rt rd=rs+rt subt rd,rs,rt sub rd,rs,rt rd=rs-rt (with overflow trap) sub rd,rs,rt subu rd,rs,rt rd=rs-rt addt rt,rs,imm addi rt,rs,imm rt=rs+(-8000h..+7FFFh) (with ov.trap) add rt,rs,imm addiu rt,rs,imm rt=rs+(-8000h..+7FFFh) |
setlt slt rd,rs,rt if rs<rt then rd=1 else rd=0 (signed) setb sltu rd,rs,rt if rs<rt then rd=1 else rd=0 (unsigned) setlt slti rt,rs,imm if rs<(-8000h..+7FFFh) then rt=1 else rt=0 (signed) setb sltiu rt,rs,imm if rs<(FFFF8000h..7FFFh) then rt=1 else rt=0(unsigned) |
and rd,rs,rt and rd,rs,rt rd = rs AND rt or rd,rs,rt or rd,rs,rt rd = rs OR rt xor rd,rs,rt xor rd,rs,rt rd = rs XOR rt nor rd,rs,rt nor rd,rs,rt rd = FFFFFFFFh XOR (rs OR rt) and rt,rs,imm andi rt,rs,imm rt = rs AND (0000h..FFFFh) or rt,rs,imm ori rt,rs,imm rt = rs OR (0000h..FFFFh) xor rt,rs,imm xori rt,rs,imm rt = rs XOR (0000h..FFFFh) |
shl rd,rt,rs sllv rd,rt,rs rd = rt SHL (rs AND 1Fh) shr rd,rt,rs srlv rd,rt,rs rd = rt SHR (rs AND 1Fh) sar rd,rt,rs srav rd,rt,rs rd = rt SAR (rs AND 1Fh) shl rd,rt,imm sll rd,rt,imm rd = rt SHL (00h..1Fh) shr rd,rt,imm srl rd,rt,imm rd = rt SHR (00h..1Fh) sar rd,rt,imm sra rd,rt,imm rd = rt SAR (00h..1Fh) mov rt,i*10000h lui rt,imm rt = (0000h..FFFFh) SHL 16 |
smul rs,rt mult rs,rt hi:lo = rs*rt (signed) umul rs,rt multu rs,rt hi:lo = rs*rt (unsigned) sdiv rs,rt div rs,rt lo = rs/rt, hi=rs mod rt (signed) udiv rs,rt divu rs,rt lo = rs/rt, hi=rs mod rt (unsigned) mov rd,hi mfhi rd rd=hi ;move from hi mov rd,lo mflo rd rd=lo ;move from lo mov hi,rs mthi rs hi=rs ;move to hi mov lo,rs mtlo rs lo=rs ;move to lo |
__umul_execution_time_____________________________________________________ Fast (6 cycles) rs = 00000000h..000007FFh Med (9 cycles) rs = 00000800h..000FFFFFh Slow (13 cycles) rs = 00100000h..FFFFFFFFh __smul_execution_time_____________________________________________________ Fast (6 cycles) rs = 00000000h..000007FFh, or rs = FFFFF800h..FFFFFFFFh Med (9 cycles) rs = 00000800h..000FFFFFh, or rs = FFF00000h..FFFFF801h Slow (13 cycles) rs = 00100000h..7FFFFFFFh, or rs = 80000000h..FFF00001h __udiv/sdiv_execution_time________________________________________________ Fixed (36 cycles) no matter of rs and rt values |
Opcode Rs Rd Hi/Remainder Lo/Result udiv 0..FFFFFFFFh 0 --> Rs FFFFFFFFh sdiv 0..+7FFFFFFFh 0 --> Rs -1 sdiv -80000000h..-1 0 --> Rs +1 sdiv -80000000h -1 --> 0 -80000000h |
| CPU Jump Opcodes |
jmp dest j dest pc=(pc and F0000000h)+(imm26bit*4) call dest jal dest pc=(pc and F0000000h)+(imm26bit*4),ra=$+8 jmp rs jr rs pc=rs call rs,ret=rd jalr (rd,)rs(,rd) pc=rs, rd=$+8 ;see caution je rs,rt,dest beq rs,rt,dest if rs=rt then pc=$+4+(-8000h..+7FFFh)*4 jne rs,rt,dest bne rs,rt,dest if rs<>rt then pc=$+4+(-8000h..+7FFFh)*4 js rs,dest bltz rs,dest if rs<0 then pc=$+4+(-8000h..+7FFFh)*4 jns rs,dest bgez rs,dest if rs>=0 then pc=$+4+(-8000h..+7FFFh)*4 jgtz rs,dest bgtz rs,dest if rs>0 then pc=$+4+(-8000h..+7FFFh)*4 jlez rs,dest blez rs,dest if rs<=0 then pc=$+4+(-8000h..+7FFFh)*4 calls rs,dest bltzal rs,dest ra=$+8, if rs<0 then pc=$+4+(..)*4 callns rs,dest bgezal rs,dest ra=$+8, if rs>=0 then pc=$+4+(..)*4 |
syscall imm20 generates a system call exception break imm20 generates a breakpoint exception |
| CPU Coprocessor Opcodes |
mov rt,cop#Rd(0-31) mfc# rt,rd ;rt = cop#datRd ;data regs mov rt,cop#Rd(32-63) cfc# rt,rd ;rt = cop#cntRd ;control regs mov cop#Rd(0-31),rt mtc# rt,rd ;cop#datRd = rt ;data regs mov cop#Rd(32-63),rt ctc# rt,rd ;cop#cntRd = rt ;control regs mov cop#cmd,imm25 cop# imm25 ;exec cop# command 0..1FFFFFFh mov cop#Rt(0-31),[rs+imm] lwc# rt,imm(rs) ;cop#dat_rt = [rs+imm] ;word mov [rs+imm],cop#Rt(0-31) swc# rt,imm(rs) ;[rs+imm] = cop#dat_rt ;word jf cop#flg,dest bc#f dest ;if cop#flg=false then pc=$+disp jt cop#flg,dest bc#t dest ;if cop#flg=true then pc=$+disp rfe rfe ;return from exception (COP0) tlb<xx> tlb<xx> ;virtual memory related (COP0) |
| CPU Pseudo Opcodes |
nop ;alias for sll r0,r0,0 move rd,rs ;alias for addu rd,rs,r0 la rx,imm32 ;load address (alias for lui rx / addiu rx) li rx,imm32 ;load immediate (alias for lui rx / ori rx) li rx,imm16 ;load immediate (alias for ori, range 0..FFFFh) li rx,-imm15 ;load immediate (alias for addiu, range -1..-8000h) li rx,imm16*10000h ;load immediate (alias for lui) lw rx,imm32 ;load from address (lui rx / lw rx,rx) sw rx,imm32 ;store to address (lui r1 / sw rx,r1) (destroys r1!) lb,lh,lwl,lwr,lbu,lhu;as above pseudo lw sb,sh,swl,swr ;as above pseudo sw (ie. also destroys r1!) alu rx,op ;alias for alu rx,rx,op alu(u) rx,rx,imm ;alias for alui(u) rx,rx,imm jalr rx ;alias for jalr (RA,)rx(,RA) subi(u) rt,rs,imm ;alias for addi(u) rt,rs,-imm beqz rx,dest ;alias for beq rx,r0,dest bnez rx,dest ;alias for bne rx,r0,dest b dest ;alias for beq r0,r0,dest (jump relative/spasm) bra dest ;alias for ...? (jump relative/gnu) bal dest ;alias for ...? (call relative/spasm) |
mov rx,NNNN0000h ;alias for lui rx,NNNNh mov rx,0000NNNNh ;alias for or rx,r0,NNNNh ;max +FFFFh mov rx,-imm15 ;alias for add rx,r0,-NNNNh ;min -8000h mov rx,ry ;alias for or rx,ry,0 (or "addiu") nop ;alias for shl r0,r0,0 jrel dest ;alias for blez R0,dest ;relative jump crel dest ;alias for callns R0,dest ;relative call jz rx,dest ;alias for je rx,R0,dest jnz rx,dest ;alias for jne rx,R0,dest call rx ;alias for call rx,ret=RA ret ;alias for jmp ra subt rt,rs,imm ;alias for addt rt,rs,-imm sub rt,rs,imm ;alias for add rt,rs,-imm alu rx,op ;alias for alu rx,rx,op neg(t) rx,ry ;alias for sub(t) rx,R0,ry not rx,ry ;alias for nor rx,R0,ry neg(t)/not rx ;alias for neg(t)/not rx,rx setz rx,ry ;alias for setb rx,ry,1 (set if zero) setnz rx,ry ;alias for setb rx,R0,ry (set if nonzero) syscall/break ;alias for syscall/break 000000h |
movp rx,imm32 ;alias for lui rx,imm16 -plus- ori rx,rx,imm16) movpa rx,imm32 ;alias for lui rx,imm16 -plus- addiu rx,rx,imm16) mov(bhs)p rx,[imm32] ;load from address (lui rx,imm16 / mov rx,[rx+imm16]) movu [rs+imm] ;alias for lwr/swr [rs+imm] plus lwl/swl [rs+imm+3] reti ;alias for jmp k0 plus rfe |
push rlist ;alias for sub sp,n*4 -- mov [sp+(1..n)*4],r1..rn pop rlist ;alias for mov r1..rn,[sp+(1..n)*4] -- add sp,n*4 pop pc,rlist ;alias for pop ra,rlist -- jmp ra |
call x0000000h ;call y0000000h (could be half-working for mem mirrors?) setae,setge ;--> setb,setlt with swapped operands |
.mips ;select MIPS instruction set (alternately .hc05 for MC68HC05) .bios ;create a .ROM file (instead of .EXE) .auto_nop ;append NOPs to jumps ;unless next opcode starts with a + .auto_nop_off ;don't append NOPs to jumps org imm ;assume following code to be originated at address "imm" db n(,n(..))) ;define 8bit data values(s) or quoted ASCII strings dw n(,n(..))) ;define 16bit data values(s) (not 32bit data!) dd n(,n(..))) ;define 32bit data values(s) .align imm 0 ;alias for immediate 0 and register R0 (whichever fits) |
org imm ;self-explaining (but, default=$80010000 for spasm!) align imm ;self-explaining (probably zeropadded?) db n(,n(..))) ;define 8bit data values(s) or quoted ASCII strings dh n(,n(..))) ;define 16bit data values(s) dw n(,n(..))) ;define 32bit data values(s) (not 16bit data!) dcb len,value ;fill <len> bytes by <value> (different as DCB on ARM CPUs) xyz ;define label "xyz" at current address (without colon) xyz equ n ;assign value n to xyz xyz = n ;probably same/sililar as "equ" ;xyz ;comments invoked with semicolon (spasm) incbin file.bin ;import binary file include file.asm ;import asm file zero ;alias for r0 >imm32 ;alias for (i-(i AND 8000h))/10000h, and/or i/10000h ? <imm32 ;alias for (i AND 0FFFFh), used for SW(+/-) and ORI(+)? end ;N/A ;no "end" or ".end" directive needed/used by spasm r1 aka at ;N/A ;some assemblers may (optionally) reject to use r1/at |
| COP0 - Register Summary |
cop0r0-r2 - N/A cop0r3 - BPC - Breakpoint on execute (R/W) cop0r4 - N/A cop0r5 - BDA - Breakpoint on data access (R/W) cop0r6 - JUMPDEST - Randomly memorized jump address (R) cop0r7 - DCIC - Breakpoint control (R/W) cop0r8 - BadVaddr - Bad Virtual Address (R) cop0r9 - BDAM - Data Access breakpoint mask (R/W) cop0r10 - N/A cop0r11 - BPCM - Execute breakpoint mask (R/W) cop0r12 - SR - System status register (R/W) cop0r13 - CAUSE - (R) Describes the most recently recognised exception cop0r14 - EPC - Return Address from Trap (R) cop0r15 - PRID - Processor ID (R) cop0r16-r31 - Garbage cop0r32-r63 - N/A - None such (Control regs) |
| COP0 - Exception Handling |
0-1 - Not used (zero)
2-6 Excode Describes what kind of exception occured:
00h INT Interrupt
01h MOD Tlb modification (none such in PSX)
02h TLBL Tlb load (none such in PSX)
03h TLBS Tlb store (none such in PSX)
04h AdEL Address error, Data load or Instruction fetch
05h AdES Address error, Data store
The address errors occur when attempting to read
outside of KUseg in user mode and when the address
is misaligned. (See also: BadVaddr register)
06h IBE Bus error on Instruction fetch
07h DBE Bus error on Data load/store
08h Syscall Generated unconditionally by syscall instruction
09h BP Breakpoint - break instruction
0Ah RI Reserved instruction
0Bh CpU Coprocessor unusable
0Ch Ov Arithmetic overflow
0Dh-1Fh Not used
7 - Not used (zero)
8-15 Ip Interrupt pending field. Bit 8 and 9 are R/W, and
contain the last value written to them. As long
as any of the bits are set they will cause an
interrupt if the corresponding bit is set in IM.
16-27 - Not used (zero)
28-29 CE Opcode Bit26-27 (aka coprocessor number in case of COP opcodes)
30 - Not used (zero) / Undoc: When BD=1, Branch condition (0=False)
31 BD Branch Delay (set when last exception points to the branch
instruction instead of the instruction in the branch delay
slot, where the exception occurred)
|
0 IEc Current Interrupt Enable (0=Disable, 1=Enable) ;rfe pops IUp here
1 KUc Current Kernal/User Mode (0=Kernel, 1=User) ;rfe pops KUp here
2 IEp Previous Interrupt Disable ;rfe pops IUo here
3 KUp Previous Kernal/User Mode ;rfe pops KUo here
4 IEo Old Interrupt Disable ;left unchanged by rfe
5 KUo Old Kernal/User Mode ;left unchanged by rfe
6-7 - Not used (zero)
8-15 Im 8 bit interrupt mask fields. When set the corresponding
interrupts are allowed to cause an exception.
16 Isc Isolate Cache (0=No, 1=Isolate)
When isolated, all load and store operations are targetted
to the Data cache, and never the main memory.
(Used by PSX Kernel, in combination with Port FFFE0130h)
17 Swc Swapped cache mode (0=Normal, 1=Swapped)
Instruction cache will act as Data cache and vice versa.
Use only with Isc to access & invalidate Instr. cache entries.
(Not used by PSX Kernel)
18 PZ When set cache parity bits are written as 0.
19 CM Shows the result of the last load operation with the D-cache
isolated. It gets set if the cache really contained data
for the addressed memory location.
20 PE Cache parity error (Does not cause exception)
21 TS TLB shutdown. Gets set if a programm address simultaneously
matches 2 TLB entries.
(initial value on reset allows to detect extended CPU version?)
22 BEV Boot exception vectors in RAM/ROM (0=RAM/KSEG0, 1=ROM/KSEG1)
23-24 - Not used (zero)
25 RE Reverse endianness (0=Normal endianness, 1=Reverse endianness)
Reverses the byte order in which data is stored in
memory. (lo-hi -> hi-lo)
(Has affect only to User mode, not to Kernal mode) (?)
(The bit doesn't exist in PSX ?)
26-27 - Not used (zero)
28 CU0 COP0 Enable (0=Enable only in Kernal Mode, 1=Kernal and User Mode)
29 CU1 COP1 Enable (0=Disable, 1=Enable) (none such in PSX)
30 CU2 COP2 Enable (0=Disable, 1=Enable) (GTE in PSX)
31 CU3 COP3 Enable (0=Disable, 1=Enable) (none such in PSX)
|
0-31 Return Address from Exception |
if (cause AND 7Ch)=00h ;if excode=interrupt
if ([epc] AND FE000000h)=4A000000h ;and opcode=cop2cmd
epc=epc+4 ;then skip that opcode
|
mov k0,epc ;get return address push k0 ;save epc in memory (if you expect nested exceptions) ... ;whatever (ie. process CAUSE) pop k0 ;restore from memory (if you expect nested exceptions) jmp k0 ;jump to K0 (after executing the next opcode) +rfe ;move SR bit4/5 --> bit2/3 --> bit0/1 |
Exception BEV=0 BEV=1 Reset BFC00000h BFC00000h (Reset) UTLB Miss 80000000h BFC00100h (Virtual memory, none such in PSX) COP0 Break 80000040h BFC00140h (Debug Break) General 80000080h BFC00180h (General Interrupts & Exceptions) |
Reset At any time (highest) ;-reset AdEL Memory (Load instruction) ;\ AdES Memory (Store instruction) ; memory (data load/store) DBE Memory (Load or store) ;/ MOD ALU (Data TLB) ;\ TLBL ALU (DTLB Miss) ; none such TLBS ALU (DTLB Miss) ;/ Ovf ALU ;-overflow Int ALU ;-interrupt Sys RD (Instruction Decode) ;\ Bp RD (Instruction Decode) ; RI RD (Instruction Decode) ; CpU RD (Instruction Decode) ;/ TLBL I-Fetch (ITLB Miss) ;-none such AdEL IVA (Instruction Virtual Address) ;\memory (opcode fetch) IBE RD (end of I-Fetch, lowest) ;/ |
| COP0 - Misc |
0-7 Revision 8-15 Implementation 16-31 Not used |
jump condition seems to be always false (jf jumps always, jt jumps never) mov [mem],cop0reg - stores garbage (next opcode) in memory mov cop0reg,[mem] - does dummy memory read without changing cop0reg? |
| COP0 - Debug Registers |
0 Automatically set by hardware upon Any break (R/W) 1 Automatically set by hardware upon BPC Code break (R/W) 2 Automatically set by hardware upon BDA Data break (R/W) 3 Automatically set by hardware upon BDA Data-Read break (R/W) 4 Automatically set by hardware upon BDA Data-Write break (R/W) 5 Automatically set by hardware upon any-jump break (R/W) 6-11 Not used (always zero) 12-13 Jump Redirection (0=Disable, 1..3=Enable) (see note) (R/W) 14-15 Unknown? (R/W) 16-22 Not used (always zero) 23 Super-Master Enable 1 for bit24-29 24 Execution breakpoint (0=Disabled, 1=Enabled) (see BPC, BPCM) 25 Data access breakpoint (0=Disabled, 1=Enabled) (see BDA, BDAM) 26 Break on Data-Read (0=No, 1=Break/when Bit25=1) 27 Break on Data-Write (0=No, 1=Break/when Bit25=1) 28 Break on any-jump (0=No, 1=Break on branch/jump/call/etc.) 29 Master Enable for bit28 (..and/or exec-break at address>=80000000h?) 30 Master Enable for bit24-27 31 Super-Master Enable 2 for bit24-29 |
mov rx,[mem] ;load rx from memory ... ;one or more opcodes that do not change rx jmp/call rx ;jump or call to rx |
| Kernel (BIOS) |
| BIOS Overview |
| BIOS Memory Map |
BFC00000h Kernel Part 1 (code/data executed in uncached ROM) BFC10000h Kernel Part 2 (code/data relocated to cached RAM) BFC18000h Intro/Bootmenu (code/data decompressed and relocated to RAM) BFC64000h Character Sets |
BFC00100h Kernel BCD date (YYYYMMDDh) BFC00104h Console Type (see Port 1F802030h, Secondary IRQ10 Controller) BFC00108h Kernel Maker/Version Strings (separated by one or more 00h bytes) BFC7FF32h GUI Version/Copyright Strings (if any) (separated by one 00h byte) |
00000000h 10h Garbage Area (see notes below) 00000010h 30h Unused/reserved 00000040h 20h COP0 debug-break vector (not used by Kernel) (in KSEG0) 00000060h 4 RAM Size (in megabytes) (2 or 8) 00000064h 4 Unknown (set to 00000000h) 00000068h 4 Unknown (set to 000000FFh) 0000006Ch 14h Unused/reserved 00000080h 10h Exception vector (actually in KSEG0, ie. at 80000080h) 00000090h 10h Unused/reserved 000000A0h 10h A(nnh) Function Vector 000000B0h 10h B(nnh) Function Vector 000000C0h 10h C(nnh) Function Vector 000000D0h 30h Unused/reserved 00000100h 58h Table of Tables (BIOS Control Blocks) (see below) 00000158h 28h Unused/reserved 00000180h 80h Command line argument from SYSTEM.CNF; BOOT = fname argument 00000200h 300h A(nnh) Jump Table 00000500h ... Kernel Code/Data (relocated from ROM) 0000Cxxxh ... Unused/reserved (C160h and up; depends on kernel versions) 0000DF80h 80h Used for BIOS Patches (ie. used by games, not used by BIOS) 0000DFFCh 4 Response value from Intro/Bootmenu 0000E000h 2000h Kernel Memory; ExCBs, EvCBs, and TCBs allocated via B(00h) |
00010000h ... Begin of User RAM (Exefile, Data, Heap, Stack, etc.) 001FFF00h ... Default Stacktop (usually in KSEG0) 1F800000h 400h Scratchpad (Data-Cache mis-used as Fast RAM) |
00000100h ExCB Exception Chain Entrypoints (addr=var, size=4*08h) 00000108h PCB Process Control Block (addr=var, size=1*04h) 00000110h TCB Thread Control Blocks (addr=var, size=N*C0h) 00000118h - Unused/reserved 00000120h EvCB Event Control Blocks (addr=var, size=N*1Ch) 00000128h - Unused/reserved 00000130h - Unused/reserved 00000138h - Unused/reserved 00000140h FCB File Control Blocks (addr=fixed, size=10h*2Ch) 00000148h - Unused/reserved 00000150h DCB Device Control Blocks (addr=fixed, size=0Ah*50h) |
[00000000h]=3C1A0000h ;<-- but overwritten by 00000003h after soon [00000004h]=275A0C80h ;<-- or 275A0C50h (in older BIOS) [00000008h]=03400008h [0000000Ch]=00000000h |
| BIOS Function Summary |
A(00h) or B(32h) FileOpen(filename,accessmode) A(01h) or B(33h) FileSeek(fd,offset,seektype) A(02h) or B(34h) FileRead(fd,dst,length) A(03h) or B(35h) FileWrite(fd,src,length) A(04h) or B(36h) FileClose(fd) A(05h) or B(37h) FileIoctl(fd,cmd,arg) A(06h) or B(38h) exit(exitcode) A(07h) or B(39h) FileGetDeviceFlag(fd) A(08h) or B(3Ah) FileGetc(fd) A(09h) or B(3Bh) FilePutc(char,fd) A(0Ah) todigit(char) A(0Bh) atof(src) ;Does NOT work - uses (ABSENT) cop1 !!! A(0Ch) strtoul(src,src_end,base) A(0Dh) strtol(src,src_end,base) A(0Eh) abs(val) A(0Fh) labs(val) A(10h) atoi(src) A(11h) atol(src) A(12h) atob(src,num_dst) A(13h) SaveState(buf) A(14h) RestoreState(buf,param) A(15h) strcat(dst,src) A(16h) strncat(dst,src,maxlen) A(17h) strcmp(str1,str2) A(18h) strncmp(str1,str2,maxlen) A(19h) strcpy(dst,src) A(1Ah) strncpy(dst,src,maxlen) A(1Bh) strlen(src) A(1Ch) index(src,char) A(1Dh) rindex(src,char) A(1Eh) strchr(src,char) ;exactly the same as "index" A(1Fh) strrchr(src,char) ;exactly the same as "rindex" A(20h) strpbrk(src,list) A(21h) strspn(src,list) A(22h) strcspn(src,list) A(23h) strtok(src,list) ;use strtok(0,list) in further calls A(24h) strstr(str,substr) - buggy A(25h) toupper(char) A(26h) tolower(char) A(27h) bcopy(src,dst,len) A(28h) bzero(dst,len) A(29h) bcmp(ptr1,ptr2,len) ;Bugged A(2Ah) memcpy(dst,src,len) A(2Bh) memset(dst,fillbyte,len) A(2Ch) memmove(dst,src,len) ;Bugged A(2Dh) memcmp(src1,src2,len) ;Bugged A(2Eh) memchr(src,scanbyte,len) A(2Fh) rand() A(30h) srand(seed) A(31h) qsort(base,nel,width,callback) A(32h) strtod(src,src_end) ;Does NOT work - uses (ABSENT) cop1 !!! A(33h) malloc(size) A(34h) free(buf) A(35h) lsearch(key,base,nel,width,callback) A(36h) bsearch(key,base,nel,width,callback) A(37h) calloc(sizx,sizy) ;SLOW! A(38h) realloc(old_buf,new_siz) ;SLOW! A(39h) InitHeap(addr,size) A(3Ah) SystemErrorExit(exitcode) A(3Bh) or B(3Ch) std_in_getchar() A(3Ch) or B(3Dh) std_out_putchar(char) A(3Dh) or B(3Eh) std_in_gets(dst) A(3Eh) or B(3Fh) std_out_puts(src) A(3Fh) printf(txt,param1,param2,etc.) A(40h) SystemErrorUnresolvedException() A(41h) LoadExeHeader(filename,headerbuf) A(42h) LoadExeFile(filename,headerbuf) A(43h) DoExecute(headerbuf,param1,param2) A(44h) FlushCache() A(45h) init_a0_b0_c0_vectors A(46h) GPU_dw(Xdst,Ydst,Xsiz,Ysiz,src) A(47h) gpu_send_dma(Xdst,Ydst,Xsiz,Ysiz,src) A(48h) SendGP1Command(gp1cmd) A(49h) GPU_cw(gp0cmd) ;send GP0 command word A(4Ah) GPU_cwp(src,num) ;send GP0 command word and parameter words A(4Bh) send_gpu_linked_list(src) A(4Ch) gpu_abort_dma() A(4Dh) GetGPUStatus() A(4Eh) gpu_sync() A(4Fh) SystemError A(50h) SystemError A(51h) LoadAndExecute(filename,stackbase,stackoffset) A(52h) SystemError ----OR---- "GetSysSp()" ? A(53h) SystemError ;PS2: set_ioabort_handler(src) A(54h) or A(71h) CdInit() A(55h) or A(70h) _bu_init() ;DTL-H2000: SystemError A(56h) or A(72h) CdRemove() A(57h) return 0 A(58h) return 0 A(59h) return 0 A(5Ah) return 0 A(5Bh) dev_tty_init() ;PS2: SystemError A(5Ch) dev_tty_open(fcb,and unused:"path\name",accessmode) ;PS2: SystemError A(5Dh) dev_tty_in_out(fcb,cmd) ;PS2: SystemError A(5Eh) dev_tty_ioctl(fcb,cmd,arg) ;PS2: SystemError A(5Fh) dev_cd_open(fcb,"path\name",accessmode) A(60h) dev_cd_read(fcb,dst,len) A(61h) dev_cd_close(fcb) A(62h) dev_cd_firstfile(fcb,"path\name",direntry) A(63h) dev_cd_nextfile(fcb,direntry) A(64h) dev_cd_chdir(fcb,"path") A(65h) dev_card_open(fcb,"path\name",accessmode) ;\ A(66h) dev_card_read(fcb,dst,len) ; A(67h) dev_card_write(fcb,src,len) ; SystemError A(68h) dev_card_close(fcb) ; on A(69h) dev_card_firstfile(fcb,"path\name",direntry) ; DTL-H2000 A(6Ah) dev_card_nextfile(fcb,direntry) ; A(6Bh) dev_card_erase(fcb,"path\name") ; A(6Ch) dev_card_undelete(fcb,"path\name") ; A(6Dh) dev_card_format(fcb) ; A(6Eh) dev_card_rename(fcb1,"path\name1",fcb2,"path\name2") ; A(6Fh) dev_card_clear_error_or_so(fcb) ;[r4+18h]=00000000h ; A(70h) or A(55h) _bu_init() ;/ A(71h) or A(54h) CdInit() A(72h) or A(56h) CdRemove() A(73h) return 0 A(74h) return 0 A(75h) return 0 A(76h) return 0 A(77h) return 0 A(78h) CdAsyncSeekL(src) A(79h) return 0 ;DTL-H2000: CdAsyncSeekP(src) A(7Ah) return 0 ;DTL-H2000: CdAsyncGetlocL(dst?) A(7Bh) return 0 ;DTL-H2000: CdAsyncGetlocP(dst?) A(7Ch) CdAsyncGetStatus(dst) A(7Dh) return 0 ;DTL-H2000: CdAsyncGetParam(dst?) A(7Eh) CdAsyncReadSector(count,dst,mode) A(7Fh) return 0 ;DTL-H2000: CdAsyncReadWithNewMode(mode) A(80h) return 0 ;DTL-H2000: CdAsyncReadFinalCount1(r4) A(81h) CdAsyncSetMode(mode) A(82h) return 0 ;DTL-H2000: CdAsyncMotorOn() A(83h) return 0 ;DTL-H2000: CdAsyncPause() A(84h) return 0 ;DTL-H2000: CdAsyncPlayOrReadS() A(85h) return 0 ;DTL-H2000: CdAsyncStop() A(86h) return 0 ;DTL-H2000: CdAsyncMute() A(87h) return 0 ;DTL-H2000: CdAsyncDemute() A(88h) return 0 ;DTL-H2000: CdSetAudioVolume(src) ;4-byte src A(89h) return 0 ;DTL-H2000: CdAsyncSetSession1(dst) A(8Ah) return 0 ;DTL-H2000: CdAsyncSetSession(session,dst) A(8Bh) return 0 ;DTL-H2000: CdAsyncForward() A(8Ch) return 0 ;DTL-H2000: CdAsyncBackward() A(8Dh) return 0 ;DTL-H2000: CdAsyncPlay() A(8Eh) return 0 ;DTL-H2000: CdAsyncGetStatSpecial(r4,r5) A(8Fh) return 0 ;DTL-H2000: CdAsyncGetID(r4,r5) A(90h) CdromIoIrqFunc1() A(91h) CdromDmaIrqFunc1() A(92h) CdromIoIrqFunc2() A(93h) CdromDmaIrqFunc2() A(94h) CdromGetInt5errCode(dst1,dst2) A(95h) CdInitSubFunc() A(96h) AddCDROMDevice() A(97h) AddMemCardDevice() ;DTL-H2000: SystemError A(98h) AddDuartTtyDevice() ;DTL-H2000: AddAdconsTtyDevice ;PS2: SystemError A(99h) AddDummyTtyDevice() A(9Ah) SystemError ;DTL-H: AddMessageWindowDevice A(9Bh) SystemError ;DTL-H: AddCdromSimDevice A(9Ch) SetConf(num_EvCB,num_TCB,stacktop) A(9Dh) GetConf(num_EvCB_dst,num_TCB_dst,stacktop_dst) A(9Eh) SetCdromIrqAutoAbort(type,flag) A(9Fh) SetMemSize(megabytes) |
A(A0h) WarmBoot() A(A1h) SystemErrorBootOrDiskFailure(type,errorcode) A(A2h) EnqueueCdIntr() ;with prio=0 (fixed) A(A3h) DequeueCdIntr() A(A4h) CdGetLbn(filename) ;get 1st sector number (or garbage when not found) A(A5h) CdReadSector(count,sector,buffer) A(A6h) CdGetStatus() A(A7h) bu_callback_okay() A(A8h) bu_callback_err_write() A(A9h) bu_callback_err_busy() A(AAh) bu_callback_err_eject() A(ABh) _card_info(port) A(ACh) _card_async_load_directory(port) A(ADh) set_card_auto_format(flag) A(AEh) bu_callback_err_prev_write() A(AFh) card_write_test(port) ;CEX-1000: jump_to_00000000h A(B0h) return 0 ;CEX-1000: jump_to_00000000h A(B1h) return 0 ;CEX-1000: jump_to_00000000h A(B2h) ioabort_raw(param) ;CEX-1000: jump_to_00000000h A(B3h) return 0 ;CEX-1000: jump_to_00000000h A(B4h) GetSystemInfo(index) ;CEX-1000: jump_to_00000000h A(B5h..BFh) N/A ;jump_to_00000000h |
B(00h) alloc_kernel_memory(size) B(01h) free_kernel_memory(buf) B(02h) init_timer(t,reload,flags) B(03h) get_timer(t) B(04h) enable_timer_irq(t) B(05h) disable_timer_irq(t) B(06h) restart_timer(t) B(07h) DeliverEvent(class, spec) B(08h) OpenEvent(class,spec,mode,func) B(09h) CloseEvent(event) B(0Ah) WaitEvent(event) B(0Bh) TestEvent(event) B(0Ch) EnableEvent(event) B(0Dh) DisableEvent(event) B(0Eh) OpenThread(reg_PC,reg_SP_FP,reg_GP) B(0Fh) CloseThread(handle) B(10h) ChangeThread(handle) B(11h) jump_to_00000000h B(12h) InitPad(buf1,siz1,buf2,siz2) B(13h) StartPad() B(14h) StopPad() B(15h) OutdatedPadInitAndStart(type,button_dest,unused,unused) B(16h) OutdatedPadGetButtons() B(17h) ReturnFromException() B(18h) SetDefaultExitFromException() B(19h) SetCustomExitFromException(addr) B(1Ah) SystemError ;PS2: return 0 B(1Bh) SystemError ;PS2: return 0 B(1Ch) SystemError ;PS2: return 0 B(1Dh) SystemError ;PS2: return 0 B(1Eh) SystemError ;PS2: return 0 B(1Fh) SystemError ;PS2: return 0 B(20h) UnDeliverEvent(class,spec) B(21h) SystemError ;PS2: return 0 B(22h) SystemError ;PS2: return 0 B(23h) SystemError ;PS2: return 0 B(24h) jump_to_00000000h B(25h) jump_to_00000000h B(26h) jump_to_00000000h B(27h) jump_to_00000000h B(28h) jump_to_00000000h B(29h) jump_to_00000000h B(2Ah) SystemError ;PS2: return 0 B(2Bh) SystemError ;PS2: return 0 B(2Ch) jump_to_00000000h B(2Dh) jump_to_00000000h B(2Eh) jump_to_00000000h B(2Fh) jump_to_00000000h B(30h) jump_to_00000000h B(31h) jump_to_00000000h B(32h) or A(00h) FileOpen(filename,accessmode) B(33h) or A(01h) FileSeek(fd,offset,seektype) B(34h) or A(02h) FileRead(fd,dst,length) B(35h) or A(03h) FileWrite(fd,src,length) B(36h) or A(04h) FileClose(fd) B(37h) or A(05h) FileIoctl(fd,cmd,arg) B(38h) or A(06h) exit(exitcode) B(39h) or A(07h) FileGetDeviceFlag(fd) B(3Ah) or A(08h) FileGetc(fd) B(3Bh) or A(09h) FilePutc(char,fd) B(3Ch) or A(3Bh) std_in_getchar() B(3Dh) or A(3Ch) std_out_putchar(char) B(3Eh) or A(3Dh) std_in_gets(dst) B(3Fh) or A(3Eh) std_out_puts(src) B(40h) chdir(name) B(41h) FormatDevice(devicename) B(42h) firstfile(filename,direntry) B(43h) nextfile(direntry) B(44h) FileRename(old_filename,new_filename) B(45h) FileDelete(filename) B(46h) FileUndelete(filename) B(47h) AddDevice(device_info) ;subfunction for AddXxxDevice functions B(48h) RemoveDevice(device_name_lowercase) B(49h) PrintInstalledDevices() |
B(4Ah) InitCard(pad_enable) ;uses/destroys k0/k1 !!! B(4Bh) StartCard() B(4Ch) StopCard() B(4Dh) _card_info_subfunc(port) ;subfunction for "_card_info" B(4Eh) write_card_sector(port,sector,src) B(4Fh) read_card_sector(port,sector,dst) B(50h) allow_new_card() B(51h) Krom2RawAdd(shiftjis_code) B(52h) SystemError ;PS2: return 0 B(53h) Krom2Offset(shiftjis_code) B(54h) GetLastError() B(55h) GetLastFileError(fd) B(56h) GetC0Table B(57h) GetB0Table B(58h) get_bu_callback_port() B(59h) testdevice(devicename) B(5Ah) SystemError ;PS2: return 0 B(5Bh) ChangeClearPad(int) B(5Ch) get_card_status(slot) B(5Dh) wait_card_status(slot) B(5Eh..FFh) N/A ;jump_to_00000000h ;CEX-1000: B(5Eh..F6h) only B(100h....) N/A ;garbage ;CEX-1000: B(F7h.....) and up |
C(00h) EnqueueTimerAndVblankIrqs(priority) ;used with prio=1 C(01h) EnqueueSyscallHandler(priority) ;used with prio=0 C(02h) SysEnqIntRP(priority,struc) C(03h) SysDeqIntRP(priority,struc) C(04h) get_free_EvCB_slot() C(05h) get_free_TCB_slot() C(06h) ExceptionHandler() C(07h) InstallExceptionHandlers() ;destroys/uses k0/k1 C(08h) SysInitMemory(addr,size) C(09h) SysInitKernelVariables() C(0Ah) ChangeClearRCnt(t,flag) C(0Bh) SystemError ;PS2: return 0 C(0Ch) InitDefInt(priority) ;used with prio=3 C(0Dh) SetIrqAutoAck(irq,flag) C(0Eh) return 0 ;DTL-H2000: dev_sio_init C(0Fh) return 0 ;DTL-H2000: dev_sio_open C(10h) return 0 ;DTL-H2000: dev_sio_in_out C(11h) return 0 ;DTL-H2000: dev_sio_ioctl C(12h) InstallDevices(ttyflag) C(13h) FlushStdInOutPut() C(14h) return 0 ;DTL-H2000: SystemError C(15h) tty_cdevinput(circ,char) C(16h) tty_cdevscan() C(17h) tty_circgetc(circ) ;uses r5 as garbage txt for ioabort C(18h) tty_circputc(char,circ) C(19h) ioabort(txt1,txt2) C(1Ah) set_card_find_mode(mode) ;0=normal, 1=find deleted files C(1Bh) KernelRedirect(ttyflag) ;PS2: ttyflag=1 causes SystemError C(1Ch) AdjustA0Table() C(1Dh) get_card_find_mode() C(1Eh..7Fh) N/A ;jump_to_00000000h C(80h.....) N/A ;mirrors to B(00h.....) |
SYS(00h) NoFunction() SYS(01h) EnterCriticalSection() SYS(02h) ExitCriticalSection() SYS(03h) ChangeThreadSubFunction(addr) ;syscall with r4=03h, r5=addr SYS(04h..FFFFFFFFh) calls DeliverEvent(F0000010h,4000h) |
BRK(1C00h) Division by zero (commonly checked/invoked by software) BRK(1800h) Division overflow (-80000000h/-1, sometimes checked by software) |
BRK(1h) Whatever lockup or so? BRK(101h) PCInit() Inits the fileserver BRK(102h) PCCreat(filename, fileattributes) BRK(103h) PCOpen(filename, accessmode) BRK(104h) PCClose(filehandle) BRK(105h) PCRead(filehandle, length, memory_destination_address) BRK(106h) PCWrite(filehandle, length, memory_source_address) BRK(107h) PClSeek(filehandle, file_offset, seekmode) BRK(3C400h) User has typed "break" command in debug console |
| BIOS File Functions |
out: V0 File handle (00h..0Fh), or -1 if error. |
bit0 1=Read ;\These bits aren't actually used by the BIOS, however, at bit1 1=Write ;/least 1 should be set; won't work when all 32bits are zero bit2 1=Exit without waiting for incoming data (when TTY buffer empty) bit9 0=Open Existing File, 1=Create New file (memory card only) bit15 1=Asynchronous mode (memory card only; don't wait for completion) bit16-31 Number of memory card blocks for a new file on the memory card |
seektype 0 = from start of file (with positive offset)
1 = from current file pointer (with positive/negative offset)
2 = Bugs. Should be from end of file.
|
out: V0 Number of bytes actually read, -1 if failed. |
out: V0 Number of bytes written. |
out: R2=character (sign-expanded) or FFFFFFFFh=error |
out: R2=Number of bytes actually written, -1 if failed |
in: A0 Pointer to new directory path (eg. "cdrom:\path") |
00h 14h Filename, terminated with 00h 14h 4 File attribute (always 0 for cdrom) (50h=norm or A0h=del for card) 18h 4 File size 1Ch 4 Pointer to next direntry? (not used?) 20h 4 First Sector Number 24h 4 Reserved (not used) |
00h okay (though many successful functions leave old error code unchanged) 02h file not found 06h bad device port number (tty2 and up) 09h invalid or unused file handle 10h general error (physical I/O error, unformatted, disk changed for old fcb) 11h file already exists error (create/undelete/rename) 12h tried to rename a file from one device to another device 13h unknown device name 16h sector alignment error, or fpos>=filesize, unknown seektype or ioctl cmd 18h not enough free file handles 1Ch not enough free memory card blocks FFFFFFFFh invalid or unused file handle passed to B(55h) function |
| BIOS File Execute and Flush Cache |
load_file A(42h) load_exec A(51h) add_device B(47h) (and all "add_xxx_device" functions) init_card B(4Ah) and by intro/boot code |
| BIOS CDROM Functions |
| BIOS Memory Card Functions |