z80_unpacker: optimisations: -1B by decode_length returning CF=0

This commit is contained in:
Peter Helcmanovsky (Ped)
2022-09-13 23:25:03 +02:00
parent ea5c0b1b15
commit 919a892ef0

View File

@@ -135,8 +135,7 @@ unpack:
exx exx
push hl push hl
.offset+*: ld de,0 .offset+*: ld de,0
or a sbc hl,de ; CF=0 from decode_length
sbc hl,de
pop de pop de
pop bc pop bc
ldir ldir
@@ -268,8 +267,8 @@ decode_length:
; IX = upkr_data_ptr ; IX = upkr_data_ptr
; BC = probs+context_index ; BC = probs+context_index
; A' = upkr_current_byte (!!! init to 0x80 at start, not 0x00) ; A' = upkr_current_byte (!!! init to 0x80 at start, not 0x00)
; return length in DE ; return length in DE, CF=0
ld de,$8000 ; length = 0 with positional-stop-bit ld de,$7FFF ; length = 0 with positional-stop-bit
jr .loop_entry jr .loop_entry
.loop: .loop:
inc bc ; context_index + 1 ; TODO can be just `inc c` for 257.. and 257+64.. contexts inc bc ; context_index + 1 ; TODO can be just `inc c` for 257.. and 257+64.. contexts
@@ -280,12 +279,12 @@ decode_length:
.loop_entry: .loop_entry:
call decode_bit call decode_bit
jr c,.loop jr c,.loop
scf ; will become this final `| (1 << bit_pos)` bit
.fix_bit_pos: .fix_bit_pos:
ccf ; NC will become this final `| (1 << bit_pos)` bit
rr d rr d
rr e rr e
jr nc,.fix_bit_pos ; until stop bit is reached (all bits did land to correct position) jr c,.fix_bit_pos ; until stop bit is reached (all bits did land to correct position)
ret ret ; return with CF=0 (important for unpack routine)
DISPLAY "upkr.unpack total size: ",/D,$-unpack DISPLAY "upkr.unpack total size: ",/D,$-unpack