Here's what I got:
Code: Select all
; A fast horizontal RLE decompression routine, note: don't make your data end with a run
; Inputs are
; a -> runflag,
; bc -> size of compressed data,
; de -> ptr to place to put decompressed data,
; hl -> ptr to compressed data
; Run data is runflag, byte, size
; Destroyes flags, bc, de, hl (bc=0, de and hl point after their structures)
-- push bc ; {1} [11]
inc hl ; {1} [6]
ld c, (hl) ; {1} [7]
inc hl ; {1} [6]
ld b, (hl) ; {1} [7]
inc hl ; {1} [6]
ex de, hl ; {1} [4]
- ld (hl), c ; {1} [7]
inc hl ; {1} [6]
djnz {-} ; {2} [8/13]
ex de, hl ; {1} [4]
pop bc ; {1} [10]
dec bc ; {1} [6]
dec bc ; {1} [6]
dec bc ; {1} [6]
decompress_hrle:
cp (hl) ; {1} [7]
jp z, {--} ; {3} [10]
ldi ; {2} [16]
jp pe, decompress_hrle ; {3} [10]
ret ; {1} [10]
43 tstates for every (non-run) byte
91 tstates for every run
26 tstates for every (run) byte
10 tstates to return
Feel free to optimize , tough I don't think there's much you can optimize