gbdk-2020 | GameBoy Development Kit |
| download: https://git.y1.nz/archives/gbdk.tar.gz | |
| README | Files | Log | Refs | LICENSE |
commit 668af23ba29af23f2aebe9736b3a8d8e366c38a2 parent 3640fbdd76f07015b1ea4e1d369d2dfc7273a3d7 Author: Toxa <untoxa@mail.ru> Date: Mon, 13 Mar 2023 15:44:50 +0300 GB: convert rle_decompress routines to the new calling convention Diffstat:
| M | gbdk-lib/include/gbdk/rledecompress.h | 4 | ++-- |
| M | gbdk-lib/libc/targets/sm83/rle_decompress.s | 42 | +++++++++++++++--------------------------- |
2 files changed, 17 insertions(+), 29 deletions(-)
diff --git a/gbdk-lib/include/gbdk/rledecompress.h b/gbdk-lib/include/gbdk/rledecompress.h @@ -21,7 +21,7 @@ @see rle_decompress */ -uint8_t rle_init(void * data) OLDCALL; +uint8_t rle_init(void * data); /** Decompress RLE compressed data into __dest__ for length __len__ bytes @@ -37,7 +37,7 @@ uint8_t rle_init(void * data) OLDCALL; @see rle_init */ -uint8_t rle_decompress(void * dest, uint8_t len) OLDCALL; +uint8_t rle_decompress(void * dest, uint8_t len); #elif defined(__TARGET_sms) || defined(__TARGET_gg) uint8_t rle_init(void * data) Z88DK_FASTCALL; uint8_t rle_decompress(void * dest, uint8_t len) Z88DK_CALLEE; diff --git a/gbdk-lib/libc/targets/sm83/rle_decompress.s b/gbdk-lib/libc/targets/sm83/rle_decompress.s @@ -3,7 +3,7 @@ .module RLE_DECOMPRESS .area _DATA - + rle_cursor: .ds 0x02 rle_counter: @@ -14,38 +14,27 @@ rle_current: .area _CODE _rle_init:: - ldhl sp, #2 - ld a, (hl+) - ld e, (hl) ld hl, #rle_cursor - ld (hl+), a - ld a, e - ld (hl+), a + ld (hl), e + inc hl + ld (hl), d + inc hl xor a ld (hl+), a ld (hl), a - ld e, #1 + inc a ret _rle_decompress:: - ;; Pop the return address - ldhl sp, #2 - ld a, (hl+) - ld c, a - ld a, (hl+) - ld d, a ; de == dest - ld b, (hl) ; b == count - + ld b, a ; b == count + ld hl, #rle_cursor ld a, (hl+) ld h, (hl) ld l, a ; hl == cursor or h - ld e, a - ret z - - ld e, c + ret z ; return 0 ld a, (rle_counter) or a @@ -74,7 +63,7 @@ _rle_decompress:: jr z, 6$ 10$: inc c - jr NZ, 3$ + jr nz, 3$ jr 1$ 2$: ;; Zero means end of a block @@ -91,7 +80,7 @@ _rle_decompress:: jr z, 6$ 11$: dec c - jr NZ, 5$ + jr nz, 5$ jr 1$ 4$: ;; save state and exit @@ -99,8 +88,7 @@ _rle_decompress:: xor a ld (hl+), a ld (hl), a - ld e, a - ret + ret ; return 0 6$: ;; save state and exit ld d, h @@ -112,5 +100,5 @@ _rle_decompress:: ld a, d ld (hl-), a ld (hl), e - ld e, #1 - ret - + ld a, #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.