Skip to content

Commit

Permalink
Another optimisation, saves about 1% (inline one branch rather than c…
Browse files Browse the repository at this point in the history
…ompute the jump)
  • Loading branch information
maxim-zhao committed Nov 17, 2024
1 parent c819e88 commit 13bf10a
Showing 1 changed file with 21 additions and 18 deletions.
39 changes: 21 additions & 18 deletions decompressors/WBMW decompressor.asm
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
WBMWDecompressTiles:
ld b, 4 ; bitplanes
-:push bc
---:
push bc
; Set VRAM address
ld c, $bf
out (c), e
Expand All @@ -11,15 +12,30 @@ WBMWDecompressTiles:
inc hl
or a
jp m, _Raw
jr nz, _RLE
jr z, +

_RLE:
; a = number of bytes
ld b, a
; Get value to write
ld a, (hl)
inc hl
-: ; Output byte to VRAM
out (c), a
in f, (c) ; Skip 3 bytes
in f, (c)
in f, (c)
djnz - ; Repeat until done
jp -- ; Then get next byte
+:
; Zero means end of bitplane
inc de ; Move to next bitplane
pop bc
djnz -
djnz ---
ret
_Raw:
; Merker byte is the negated count -1..-128
; Marker byte is the negated count -1..-128
neg
ld b, a
-:; Write a byte
Expand All @@ -29,17 +45,4 @@ _Raw:
in a, ($be)
jp nz, - ; Repeat until done
jp -- ; Then get next byte
_RLE:
; a = number of bytes
ld b, a
; Get value to write
ld a, (hl)
inc hl
-:; Output byte to VRAM
out (c), a
in f, (c) ; Skip 3 bytes
in f, (c)
in f, (c)
djnz - ; Repeat until done
jp -- ; Then get next byte

0 comments on commit 13bf10a

Please sign in to comment.