mirror of
https://github.com/exoticorn/upkr.git
synced 2026-01-20 11:36:42 +01:00
z80_unpacker: optimisations: shorter >>4 in probs update
This commit is contained in:
@@ -239,19 +239,16 @@ decode_bit:
|
|||||||
jr c,.bit_is_1
|
jr c,.bit_is_1
|
||||||
ld d,-16 ; 0xF0
|
ld d,-16 ; 0xF0
|
||||||
.bit_is_1: ; D:E = -prob_offset:prob, A = prob
|
.bit_is_1: ; D:E = -prob_offset:prob, A = prob
|
||||||
;FIXME and + 4x rra will be probably shorter!
|
and $F8
|
||||||
srl a
|
rra
|
||||||
srl a
|
rra
|
||||||
srl a
|
rra
|
||||||
srl a
|
rra
|
||||||
adc a,d ; A = -prob_offset + ((prob + 8) >> 4)
|
adc a,d ; A = -prob_offset + ((prob + 8) >> 4)
|
||||||
neg
|
neg
|
||||||
add a,e ; A = prob_offset + prob - ((prob + 8) >> 4)
|
add a,e ; A = prob_offset + prob - ((prob + 8) >> 4)
|
||||||
ld (bc),a ; update probs[context_index]
|
ld (bc),a ; update probs[context_index]
|
||||||
pop af ; restore resulting CF = bit
|
pop af ; restore resulting CF = bit
|
||||||
; TODO: check if it's possible to `cpl` instead of neg, have +1 on original prob,
|
|
||||||
; and get correct CF=bit from `add a,e` then (without extra push+pop AF)
|
|
||||||
; !!! I think this will **NOT** work, because clamping of prob ends with +-0 at both ends (cpl 0 -> 255 -> CF=1)
|
|
||||||
pop de
|
pop de
|
||||||
ret
|
ret
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user