RefPack compression

From Sega Retro

RefPack is a compression format made by Frank Barchard of EA Canada. It is a variation of the LZSS algorithm, with byte oriented coding. Compressed data can be identified by the magic byte 0xFB at offset 2.

Usage

Was found in the following Sega Mega Drive / Genesis games developed by EA Sports:

Other uses can be found with the following unix shell command:

LANG=C grep -laP '\x41\xef\x00\x04\x48\xe7\xff\x7e\x2c\x48\x20\x5e\x22\x5e\x20\x1e\x3e\x1e\x24\x00\x2c\x40\x06\x80\x00\x00\x00\xff\x42\x00\x26\x40\x90\x82\x0c\x40\x00\x80\x6c\x00\x00\x06\x4d\xeb\x03\x00\x16\x18\x0c\x18\x00\xfb\x66\x00\x06\x52\x08\x03\x00\x00\x67\x00\x00\x04\x56\x48' *

Listing

Partial decompression function (until the magic byte 0xFB check):

; A0 = input_buffer
; A1 = output_buffer

41 ef 00 04     lea        (0x4,SP),A0
48 e7 ff 7e     movem.l    {  A6 A5 A4 A3 A2 A1 D7 D6 D5 D4 D3 D2 D1 D0}
2c 48           movea.l    A0,A6
20 5e           movea.l    (A6)+,A0
22 5e           movea.l    (A6)+,A1
20 1e           move.l     (A6)+,D0
3e 1e           move.w     (A6)+,D7w
24 00           move.l     D0,D2
2c 40           movea.l    D0,A6
06 80 00        addi.l     #0xff,D0
00 00 ff
42 00           clr.b      D0b
26 40           movea.l    D0,A3
90 82           sub.l      D2,D0
0c 40 00 80     cmpi.w     #0x80,D0w
6c 00 00 06     bge.w      check_magic
4d eb 03 00     lea        (0x300,A3),A6
            check_magic
16 18           move.b     (A0)+,D3b
0c 18 00 fb     cmpi.b     #DAT_0000fffb,(A0)+