git.y1.nz

gbdk-2020

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

commit 3a47d33f9a97b3e44c6871385cc41e934db26b40
parent 90c45dc4935939803654e62448e9e88ded5b0b5e
Author: toxa <untoxa@mail.ru>
Date:   Wed,  2 Dec 2020 18:26:58 +0300

loading of 1bit data fixed, also now it is possible to specify pixel color

Diffstat:
Mgbdk-lib/include/gb/gb.h6++++--
Mgbdk-lib/libc/gb/set_1bit_data.s47+++++++++++++++++++++++++++++++++++++++++++----
2 files changed, 47 insertions(+), 6 deletions(-)

diff --git a/gbdk-lib/include/gb/gb.h b/gbdk-lib/include/gb/gb.h @@ -634,19 +634,21 @@ void set_bkg_data(UINT8 first_tile, @param first_tile Index of the first Tile to write @param nb_tiles Number of Tiles to write @param data Pointer to (1bpp) source Tile Pattern data + @param color Color Similar to @ref set_bkg_data, except source data is 1 bit-per-pixel which gets expanded into 2 bits-per-pixel. For a given bit that represent a pixel: \li 0 will be expanded into color 0 - \li 1 will be expanded into color 3 + \li 1 will be expanded into color 1, 2 or 3 depending on color argument @see SHOW_BKG, HIDE_BKG, set_bkg_tiles */ void set_bkg_1bit_data(UINT8 first_tile, UINT8 nb_tiles, - unsigned char *data) NONBANKED __preserves_regs(b, c); + unsigned char *data, + UINT8 color) NONBANKED __preserves_regs(b, c); /** Copies from Background / Window VRAM Tile Pattern data into a buffer diff --git a/gbdk-lib/libc/gb/set_1bit_data.s b/gbdk-lib/libc/gb/set_1bit_data.s @@ -12,7 +12,12 @@ _set_sprite_1bit_data:: ld d, #0x80 .copy_1bit_tiles: push bc - lda hl, 4(sp) + + lda hl, 8(sp) + ld a, (hl) + push af + + lda hl, 6(sp) ld a, (hl+) ; ID of 1st tile ld e, a ld a, (hl+) ; Nb of tiles @@ -37,18 +42,52 @@ _set_sprite_1bit_data:: jr z, 2$ res 4, d 2$: - ld b, #16 + ld b, #8 3$: + pop af + push af + + dec a + jr z, 4$ + dec a + jr z, 5$ + + WAIT_STAT + ld a, (hl) + ld (de), a + inc de WAIT_STAT ld a, (hl+) ld (de), a inc de - + jr 6$ +4$: + WAIT_STAT + ld a, (hl+) + ld (de), a + inc de + WAIT_STAT + xor a + ld (de), a + inc de + jr 6$ +5$: + WAIT_STAT + xor a + ld (de), a + inc de + WAIT_STAT + ld a, (hl+) + ld (de), a + inc de +6$: dec b jr nz, 3$ dec c jr nz, 1$ - + + pop af + 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.