From db1c7d2d14c11631e7113621f56a2d88e1b8b36e Mon Sep 17 00:00:00 2001 From: "Peter Helcmanovsky (Ped)" Date: Mon, 19 Sep 2022 11:49:53 +0200 Subject: [PATCH] z80_unpacker: optimisation: -1B in decode_number (fwd 171B / rev 168B) --- z80_unpacker/example/example.sna | Bin 49179 -> 49179 bytes z80_unpacker/unpack.asm | 9 +++++---- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/z80_unpacker/example/example.sna b/z80_unpacker/example/example.sna index 608c82a0cd10aa8ef47756414fd76847ca067304..e3e730a6542a30c1ad427059d407fb98c5464bff 100644 GIT binary patch delta 167 zcmbQ;z&yKwd4u>u#4)R<*U85kt(XPODw~pbia{t?`PZg8r zFEr+5KU?_lwA5*7AZ77o^23D=qWq75Cd53tdQ*{sLGs|+9YF0zcqW@Jas#TBd<0f2 S`N-nS=B`DrWF{BwUkL!@3s7YM delta 165 zcmbQ;z&yKwd4u>u#&eS;7FzfhKC}?vIa~Pfw4lMy%9}#MHv=SIR4qiQ7qaeW1uE2J;j^VCy|J$rj<&zgI zH0I|38z^;J8bn)sn*3m)1EauX#YMuCO&7U|17)Qiod(NFJ+k;@4`N#UJh@Tvm-t45 L7c7%Y_Adtj`%g_n diff --git a/z80_unpacker/unpack.asm b/z80_unpacker/unpack.asm index a2d1fc9..4cd5829 100644 --- a/z80_unpacker/unpack.asm +++ b/z80_unpacker/unpack.asm @@ -187,6 +187,9 @@ int upkr_decode_bit(int context_index) { return bit; } */ +inc_c_decode_bit: + ; ++low(context_index) before decode_bit (to get -1B by two calls in decode_number) + inc c decode_bit: ; HL = upkr_state ; IX = upkr_data_ptr @@ -298,13 +301,11 @@ decode_number: ld de,$7FFF ; length = 0 with positional-stop-bit jr .loop_entry .loop: - inc c ; context_index + 1 - call decode_bit + call inc_c_decode_bit ; context_index + 1 rr d rr e ; DE = length = (length >> 1) | (bit << 15); .loop_entry: - inc c ; context_index += 2 - call decode_bit + call inc_c_decode_bit ; context_index += 2 jr c,.loop .fix_bit_pos: ccf ; NC will become this final `| (1 << bit_pos)` bit