git.y1.nz

gbdk-2020

GameBoy Development Kit
download: https://git.y1.nz/archives/gbdk.tar.gz
README | Files | Log | Refs | LICENSE

commit 5eba9417bec4dcdeff303932abe9e60a1c16f1e4
parent c88c809624a33f8d4ee8ef371635a64c36ad1944
Author: Toxa <56631470+untoxa@users.noreply.github.com>
Date:   Tue,  5 Dec 2023 21:36:52 +0300

Merge pull request #600 from SelvinPL/develop

Z80 jumps optimization for rle/gb decompressors
Diffstat:
Mgbdk-lib/libc/targets/z80/gb_decompress.s22+++++++++++-----------
Mgbdk-lib/libc/targets/z80/rle_decompress.s18+++++++++---------
2 files changed, 20 insertions(+), 20 deletions(-)

diff --git a/gbdk-lib/libc/targets/z80/gb_decompress.s b/gbdk-lib/libc/targets/z80/gb_decompress.s @@ -20,9 +20,9 @@ _gb_decompress:: ld a, (hl) ; load command inc hl or a - jr z, 9$ ; exit, if last byte + jr z, 7$ ; exit, if last byte bit 7, a - jr nz, 5$ ; string functions + jp nz, 5$ ; string functions bit 6, a jr nz, 3$ ; RLE byte @@ -35,8 +35,8 @@ _gb_decompress:: ld (de), a inc de dec b - jr nz, 2$ - jr 1$ ; next command + jp nz, 2$ + jp 1$ ; next command 3$: ; RLE word and #63 inc a @@ -51,12 +51,12 @@ _gb_decompress:: ld (hl), b inc hl dec a - jr nz, 4$ + jp nz, 4$ ex de, hl - jr 1$ ; next command + jp 1$ ; next command 5$: bit 6, a - jr nz, 7$ + jr nz, 6$ ; string repeat and #63 inc a @@ -73,15 +73,15 @@ _gb_decompress:: pop hl inc hl inc hl - jr 1$ ; next command -7$: ; string copy + jp 1$ ; next command +6$: ; string copy and #63 inc a ld c, a ld b, #0 ldir - jr 1$ ; next command -9$: + jp 1$ ; next command +7$: pop hl ex de, hl or a ; clear carry flag diff --git a/gbdk-lib/libc/targets/z80/rle_decompress.s b/gbdk-lib/libc/targets/z80/rle_decompress.s @@ -44,14 +44,14 @@ _rle_decompress:: ld a, (rle_current) bit 7, c - jr nz, 10$ - jr 11$ + jr nz, 7$ + jp 8$ 1$: ;; Fetch the run ld c, (hl) inc hl + ;; Negative means a run -8$: bit 7, c jr z, 2$ ;; Expanding a run @@ -63,10 +63,10 @@ _rle_decompress:: dec b jr z, 6$ -10$: +7$: inc c - jr NZ, 3$ - jr 1$ + jp NZ, 3$ + jp 1$ 2$: ;; Zero means end of a block inc c @@ -79,10 +79,10 @@ _rle_decompress:: dec b jr z, 6$ -11$: +8$: dec c - jr NZ, 5$ - jr 1$ + jp NZ, 5$ + jp 1$ 4$: ;; save state and exit ld hl, #0

This webpage is intended to be an accessible preview of this repository. To get a fuller picture, clone it and use the git CLI.