mirror of
https://github.com/exoticorn/upkr.git
synced 2026-01-20 11:36:42 +01:00
z80_unpacker: optimisations: -1B by keeping write_ptr in DE'
This commit is contained in:
@@ -24,9 +24,9 @@ start:
|
|||||||
ldi a,(ix) ; fake: ld a,(ix) : inc ix
|
ldi a,(ix) ; fake: ld a,(ix) : inc ix
|
||||||
out (254),a
|
out (254),a
|
||||||
; call unpack of next image directly into VRAM
|
; call unpack of next image directly into VRAM
|
||||||
ld hl,$4000 ; target VRAM
|
ld de,$4000 ; target VRAM
|
||||||
exx
|
exx
|
||||||
; IX = packed data, HL' = destination ($4000)
|
; IX = packed data, DE' = destination ($4000)
|
||||||
; returned IX will point right after the packed data
|
; returned IX will point right after the packed data
|
||||||
call upkr.unpack
|
call upkr.unpack
|
||||||
; do some busy loop with CPU to delay between images
|
; do some busy loop with CPU to delay between images
|
||||||
|
|||||||
@@ -10,7 +10,7 @@
|
|||||||
;; public API:
|
;; public API:
|
||||||
;;
|
;;
|
||||||
;; upkr.unpack
|
;; upkr.unpack
|
||||||
;; IN: IX = packed data, HL' (shadow HL) = destination
|
;; IN: IX = packed data, DE' (shadow DE) = destination
|
||||||
;; OUT: IX = after packed data
|
;; OUT: IX = after packed data
|
||||||
;; modifies: all registers except IY, requires 14 bytes of stack space
|
;; modifies: all registers except IY, requires 14 bytes of stack space
|
||||||
;;
|
;;
|
||||||
@@ -64,7 +64,7 @@ int upkr_unpack(void* destination, void* compressed_data) {
|
|||||||
return write_ptr - (u8*)destination;
|
return write_ptr - (u8*)destination;
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
; IN: IX = compressed_data, HL' = destination
|
; IN: IX = compressed_data, DE' = destination
|
||||||
unpack:
|
unpack:
|
||||||
; ** reset probs to 0x80, also reset HL (state) to zero, and set BC to probs+context 0
|
; ** reset probs to 0x80, also reset HL (state) to zero, and set BC to probs+context 0
|
||||||
ld hl,probs.c>>1
|
ld hl,probs.c>>1
|
||||||
@@ -97,8 +97,8 @@ unpack:
|
|||||||
jr nc,.decode_byte ; while(byte < 256)
|
jr nc,.decode_byte ; while(byte < 256)
|
||||||
ld a,e
|
ld a,e
|
||||||
exx
|
exx
|
||||||
ld (hl),a ; *write_ptr++ = byte;
|
ld (de),a ; *write_ptr++ = byte;
|
||||||
inc hl
|
inc de
|
||||||
exx
|
exx
|
||||||
jr .decompress_data_reset_match
|
jr .decompress_data_reset_match
|
||||||
|
|
||||||
@@ -133,13 +133,12 @@ unpack:
|
|||||||
call decode_length ; length = upkr_decode_length(257 + 64);
|
call decode_length ; length = upkr_decode_length(257 + 64);
|
||||||
push de
|
push de
|
||||||
exx
|
exx
|
||||||
push hl
|
ld h,d ; DE = write_ptr
|
||||||
.offset+*: ld de,0
|
ld l,e
|
||||||
sbc hl,de ; CF=0 from decode_length
|
.offset+*: ld bc,0
|
||||||
pop de
|
sbc hl,bc ; CF=0 from decode_length ; HL = write_ptr - offset
|
||||||
pop bc
|
pop bc ; BC = length
|
||||||
ldir
|
ldir
|
||||||
ex de,hl
|
|
||||||
exx
|
exx
|
||||||
ld d,b ; prev_was_match = non-zero
|
ld d,b ; prev_was_match = non-zero
|
||||||
djnz .decompress_data ; adjust context_index back to 0..255 range, go to main loop
|
djnz .decompress_data ; adjust context_index back to 0..255 range, go to main loop
|
||||||
|
|||||||
Reference in New Issue
Block a user