git.y1.nz

gbdk-2020

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

commit 2f8d3304c9f733229c04dcbda0936e655a215a2a
parent e0ee5b3e4900ceca69c68f6d6b7c729295f01756
Author: Phidias618 <126189685+Phidias618@users.noreply.github.com>
Date:   Wed,  6 May 2026 23:03:57 +0200

Minor optimizations to the rle_decompress for the sm83
Diffstat:
Mgbdk-lib/libc/targets/sm83/rle_decompress.s62+++++++++++++++++++++++++++++---------------------------------
1 file changed, 29 insertions(+), 33 deletions(-)

diff --git a/gbdk-lib/libc/targets/sm83/rle_decompress.s b/gbdk-lib/libc/targets/sm83/rle_decompress.s @@ -15,10 +15,10 @@ rle_current: _rle_init:: ld hl, #rle_cursor - ld (hl), e - inc hl - ld (hl), d - inc hl + ld a, e + ld (hl+), a + ld a, d + ld (hl+), a xor a ld (hl+), a ld (hl), a @@ -38,58 +38,55 @@ _rle_decompress:: ld a, (rle_counter) or a + jr z, 0$ + ld c, a - jr z, 1$ - + add a ld a, (rle_current) - bit 7, c - jr nz, 10$ - jr 11$ -1$: + jr c, 2$ + jr 5$ +0$: ;; Fetch the run - ld c, (hl) - inc hl + ld a, (hl+) + ld c, a ;; Negative means a run -8$: - bit 7, c - jr z, 2$ + add a + jr nc, 3$ ;; Expanding a run ld a, (hl+) -3$: +1$: ld (de), a inc de dec b - jr z, 6$ -10$: - inc c - jr nz, 3$ - jr 1$ + jr z, 7$ 2$: - ;; Zero means end of a block inc c - dec c - jr z, 4$ + jr nz, 1$ + jr 0$ +3$: + ;; Zero means end of a block + jr z, 6$ ;; Expanding a block -5$: +4$: ld a, (hl+) ld (de), a inc de dec b - jr z, 6$ -11$: + jr z, 7$ +5$: dec c - jr nz, 5$ - jr 1$ -4$: + jr nz, 4$ + jr 0$ +6$: ;; save state and exit ld hl, #rle_cursor xor a ld (hl+), a ld (hl), a ret ; return 0 -6$: +7$: ;; save state and exit ld d, h ld e, l @@ -101,4 +98,4 @@ _rle_decompress:: ld (hl-), a ld (hl), e ld a, #1 - ret ; return 1 - + ret ; return 1

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