ITL compression

From Sega Retro

Compression algorithm created by I.T.L company. Was found in the following Sega Mega Drive / Genesis games:


Description

Was developed to compress tiles data.

Uses temporary 32 bytes (1 tile) buffer in ram.

Compression scheme uses 8 bits token (1 - use byte from input stream, 0 - use 0x00 as input byte).

All data is xored by dwords: dword N is xored with the N-1'th dword, then N-1'th dword is xored with N-2'th dword, etc.


Listing

Full decompression algo listing:

; =============== S U B R O U T I N E =======================================
; a6 = data
; d7 = dest tiles
unpack_to_vram:
	     movem.l d1-d4/a1-a2,-(sp)
loop1:
	     moveq   #0,d1
	     moveq   #3,d4
	     lea     (tmp_unpack).l,a1
loop2:
	     move.b  (a6)+,d2
	     moveq   #7,d3
loop3:
	     lsl.b   #1,d2
	     bcc.w   loc_1162
	     move.b  (a6)+,(a1)+
	     bra.s   loc_1166
; ---------------------------------------------------------------------------
loc_1162:
	     move.b  #0,(a1)+
loc_1166:
	     dbf     d3,loop3
	     dbf     d4,loop2
	     lea     (tmp_unpack).l,a1
	     moveq   #7,d4
loop4:
	     eor.l   d1,(a1)
	     move.l  (a1)+,d1
	     dbf     d4,loop4
	     lea     (VDP_DATA).l,a1
	     lea     (tmp_unpack).l,a2
	     moveq   #$F,d4
loop5:
	     move.w  (a2)+,(a1)
	     dbf     d4,loop5
	     dbf     d7,loop1
	     movem.l (sp)+,d1-d4/a1-a2
	     rts
; End of function unpack_to_vram


Compressor/Decompressor