git.y1.nz

gbdk-2020

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

commit 37821f14ab0b82c031154ffd61e72d144ace6f24
parent 668af23ba29af23f2aebe9736b3a8d8e366c38a2
Author: Toxa <untoxa@mail.ru>
Date:   Mon, 13 Mar 2023 16:37:02 +0300

GB: convert gb_decompress routines to the new calling convention

Diffstat:
Mgbdk-lib/include/gb/gbdecompress.h8++++----
Mgbdk-lib/libc/targets/sm83/gb_decompress.s22++++++++--------------
Mgbdk-lib/libc/targets/sm83/gb_decompress_tiles.s28+++++++++++-----------------
3 files changed, 23 insertions(+), 35 deletions(-)

diff --git a/gbdk-lib/include/gb/gbdecompress.h b/gbdk-lib/include/gb/gbdecompress.h @@ -23,7 +23,7 @@ @see gb_decompress_bkg_data, gb_decompress_win_data, gb_decompress_sprite_data, rle_decompress */ -uint16_t gb_decompress(const uint8_t * sour, uint8_t * dest) OLDCALL PRESERVES_REGS(b, c); +uint16_t gb_decompress(const uint8_t * sour, uint8_t * dest); /** gb-decompress background tiles into VRAM @@ -40,7 +40,7 @@ uint16_t gb_decompress(const uint8_t * sour, uint8_t * dest) OLDCALL PRESERVES_R @see gb_decompress_bkg_data, gb_decompress_win_data, gb_decompress_sprite_data */ -void gb_decompress_bkg_data(uint8_t first_tile, const uint8_t * sour) OLDCALL PRESERVES_REGS(b, c); +void gb_decompress_bkg_data(uint8_t first_tile, const uint8_t * sour); /** gb-decompress window tiles into VRAM @@ -60,7 +60,7 @@ void gb_decompress_bkg_data(uint8_t first_tile, const uint8_t * sour) OLDCALL PR @see gb_decompress, gb_decompress_bkg_data, gb_decompress_sprite_data */ -void gb_decompress_win_data(uint8_t first_tile, const uint8_t * sour) OLDCALL PRESERVES_REGS(b, c); +void gb_decompress_win_data(uint8_t first_tile, const uint8_t * sour); /** gb-decompress sprite tiles into VRAM @@ -77,6 +77,6 @@ void gb_decompress_win_data(uint8_t first_tile, const uint8_t * sour) OLDCALL PR @see gb_decompress, gb_decompress_bkg_data, gb_decompress_win_data */ -void gb_decompress_sprite_data(uint8_t first_tile, const uint8_t * sour) OLDCALL PRESERVES_REGS(b, c); +void gb_decompress_sprite_data(uint8_t first_tile, const uint8_t * sour); #endif diff --git a/gbdk-lib/libc/targets/sm83/gb_decompress.s b/gbdk-lib/libc/targets/sm83/gb_decompress.s @@ -9,18 +9,13 @@ .area _CODE _gb_decompress:: - lda hl,5(SP) - ld a,(hl-) - ld d,a - ld a,(hl-) - ld e,a - ld a,(hl-) - ld l,(hl) - ld h,a + ld h,d + ld l,e + ld d,b + ld e,c ; hl = source; de = dest gb_decompress:: - push bc push de 1$: ld a,(hl+) ; load command @@ -88,7 +83,7 @@ gb_decompress:: and #63 inc a ld b,a -8$: +8$: ld a,(hl+) ld (de),a inc de @@ -99,10 +94,9 @@ gb_decompress:: pop hl ld a, e sub l - ld e, a + ld c, a ld a, d sbc h - ld d, a - pop bc - + ld b, a + ret diff --git a/gbdk-lib/libc/targets/sm83/gb_decompress_tiles.s b/gbdk-lib/libc/targets/sm83/gb_decompress_tiles.s @@ -25,35 +25,30 @@ loc: _gb_decompress_bkg_data:: _gb_decompress_win_data:: - ld d, #0x90 - ldh a, (.LCDC) - and #LCDCF_BG8000 - jr z, .load_params + ld b, #0x90 + ld hl, #.LCDC + bit LCDCF_B_BG8000, (hl) + jr nz, .load_params _gb_decompress_sprite_data:: - ld d, #0x80 + ld b, #0x80 .load_params: - ldhl sp, #2 - ld a, (hl+) - + ld h, d + ld l, e + ; Compute dest ptr swap a ; *16 (size of a tile) ld e, a and #0x0F ; Get high bits - add d ; Add base offset of target tile "block" + add b ; Add base offset of target tile "block" ld d, a ld a, e and #0xF0 ; Get low bits only ld e, a WRAP_VRAM d - ld a, (hl+) - ld h, (hl) - ld l, a - ; hl = source; de = dest gb_decompress_vram:: - push bc push de 1$: ld a,(hl+) ; load command @@ -78,7 +73,7 @@ gb_decompress_vram:: dec c jr nz,2$ jr 1$ ; next command - + 3$: ; RLE word and #63 inc a @@ -98,7 +93,7 @@ gb_decompress_vram:: WRAP_VRAM d dec c jr nz,4$ - inc hl + inc hl jr 1$ ; next command 5$: @@ -161,5 +156,4 @@ gb_decompress_vram:: jp 1$ ; next command 9$: pop de - pop bc ret

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