@@ -19,42 +19,42 @@ Decompress::
|
||||
|
||||
; This function decompresses lz-compressed data from hl to de.
|
||||
|
||||
LZ_END EQU $ff ; Compressed data is terminated with $ff.
|
||||
DEF LZ_END EQU $ff ; Compressed data is terminated with $ff.
|
||||
|
||||
; A typical control command consists of:
|
||||
|
||||
LZ_CMD EQU %11100000 ; command id (bits 5-7)
|
||||
LZ_LEN EQU %00011111 ; length n (bits 0-4)
|
||||
DEF LZ_CMD EQU %11100000 ; command id (bits 5-7)
|
||||
DEF LZ_LEN EQU %00011111 ; length n (bits 0-4)
|
||||
|
||||
; Additional parameters are read during command execution.
|
||||
|
||||
; Commands:
|
||||
|
||||
LZ_LITERAL EQU 0 << 5 ; Read literal data for n bytes.
|
||||
LZ_ITERATE EQU 1 << 5 ; Write the same byte for n bytes.
|
||||
LZ_ALTERNATE EQU 2 << 5 ; Alternate two bytes for n bytes.
|
||||
LZ_ZERO EQU 3 << 5 ; Write 0 for n bytes.
|
||||
DEF LZ_LITERAL EQU 0 << 5 ; Read literal data for n bytes.
|
||||
DEF LZ_ITERATE EQU 1 << 5 ; Write the same byte for n bytes.
|
||||
DEF LZ_ALTERNATE EQU 2 << 5 ; Alternate two bytes for n bytes.
|
||||
DEF LZ_ZERO EQU 3 << 5 ; Write 0 for n bytes.
|
||||
|
||||
; Another class of commands reuses data from the decompressed output.
|
||||
LZ_RW EQU 2 + 5 ; bit
|
||||
DEF LZ_RW EQU 2 + 5 ; bit
|
||||
|
||||
; These commands take a signed offset to start copying from.
|
||||
; Wraparound is simulated.
|
||||
; Positive offsets (15-bit) are added to the start address.
|
||||
; Negative offsets (7-bit) are subtracted from the current position.
|
||||
|
||||
LZ_REPEAT EQU 4 << 5 ; Repeat n bytes from the offset.
|
||||
LZ_FLIP EQU 5 << 5 ; Repeat n bitflipped bytes.
|
||||
LZ_REVERSE EQU 6 << 5 ; Repeat n bytes in reverse.
|
||||
DEF LZ_REPEAT EQU 4 << 5 ; Repeat n bytes from the offset.
|
||||
DEF LZ_FLIP EQU 5 << 5 ; Repeat n bitflipped bytes.
|
||||
DEF LZ_REVERSE EQU 6 << 5 ; Repeat n bytes in reverse.
|
||||
|
||||
; If the value in the count needs to be larger than 5 bits,
|
||||
; LZ_LONG can be used to expand the count to 10 bits.
|
||||
LZ_LONG EQU 7 << 5
|
||||
DEF LZ_LONG EQU 7 << 5
|
||||
|
||||
; A new control command is read in bits 2-4.
|
||||
; The top two bits of the length are bits 0-1.
|
||||
; Another byte is read containing the bottom 8 bits.
|
||||
LZ_LONG_HI EQU %00000011
|
||||
DEF LZ_LONG_HI EQU %00000011
|
||||
|
||||
; In other words, the structure of the command becomes
|
||||
; 111xxxyy yyyyyyyy
|
||||
|
Reference in New Issue
Block a user