gbdk-2020 | GameBoy Development Kit |
| download: https://git.y1.nz/archives/gbdk.tar.gz | |
| README | Files | Log | Refs | LICENSE |
commit 038e699195de289972164b134af99ccf03640a75 parent 114ca88e3367286ff74cec93975ebaeb7da307d3 Author: Toxa <untoxa@mail.ru> Date: Thu, 19 Aug 2021 23:53:59 +0300 SMS/GG: font_load() respects background and foreground color Diffstat:
| M | gbdk-lib/examples/sms/fonts/fonts.c | 2 | -- |
| M | gbdk-lib/include/sms/sms.h | 20 | ++++++++++++++++++++ |
| M | gbdk-lib/libc/targets/z80/font.s | 78 | ++++++++++++++++++++++++++++++++++++++++++++++++++---------------------------- |
3 files changed, 70 insertions(+), 30 deletions(-)
diff --git a/gbdk-lib/examples/sms/fonts/fonts.c b/gbdk-lib/examples/sms/fonts/fonts.c @@ -19,8 +19,6 @@ void main(void) font_t ibm_font, italic_font, min_font; int i; - DISPLAY_ON; - /* First, init the font system */ font_init(); diff --git a/gbdk-lib/include/sms/sms.h b/gbdk-lib/include/sms/sms.h @@ -156,6 +156,26 @@ inline void display_off(void) { #define SHOW_LEFT_COLUMN \ __WRITE_VDP_REG(VDP_R0, __READ_VDP_REG(VDP_R0) &= (~R0_LCB)) +/** Turns on the background layer. + Not yet implemented +*/ +#define SHOW_BKG + +/** Turns off the background layer. + Not yet implemented +*/ +#define HIDE_BKG + +/** Turns on the window layer + Not yet implemented +*/ +#define SHOW_WIN + +/** Turns off the window layer. + Not yet implemented +*/ +#define HIDE_WIN + /** Turns on the sprites layer. Not yet implemented */ diff --git a/gbdk-lib/libc/targets/z80/font.s b/gbdk-lib/libc/targets/z80/font.s @@ -44,6 +44,14 @@ font_first_free_tile: ; Table containing descriptors for all of the fonts font_table: .ds (sfont_handle_sizeof*.MAX_FONTS) +plane0: + .ds 1 +plane1: + .ds 1 +plane2: + .ds 1 +plane3: + .ds 1 .end_font_vars: .area _GSINIT @@ -196,43 +204,60 @@ load_font_tiles: jp z, 2$ ; font_copy_compressed - ld c, #.VDP_DATA - inc d inc e - xor a jr 7$ - + 8$: - ld b, #8 -9$: - outi - jr 10$ -10$: - nop - out (c), a - jr 11$ -11$: - nop - out (c), a - jr 12$ -12$: - nop - nop - out (c), a - nop + ld d, #8 +9$: + ld b, (hl) + inc hl + + push hl + ld c, #8 +21$: + rlc b + ld a, (.bg_colour) + jr nc, 20$ + ld a, (.fg_colour) +20$: + ld hl, #plane0 + .rept 3 + rra + rl (hl) + inc hl + .endm + rra + rl (hl) + dec c + jr nz, 21$ + pop hl + + ld a, (plane0) + out (.VDP_DATA), a + jr 22$ +22$: + ld a, (plane1) + out (.VDP_DATA), a + jr 23$ +23$: + ld a, (plane2) + out (.VDP_DATA), a + jr 24$ +24$: + ld a, (plane3) + out (.VDP_DATA), a + + dec d jr nz, 9$ 7$: dec e jr nz, 8$ - dec d - jr nz, 8$ - jp 6$ 2$: ; font_copy_uncompressed ld c, #.VDP_DATA - inc d inc e jr 5$ 3$: @@ -244,9 +269,6 @@ load_font_tiles: dec e jp nz, 3$ - dec d - jp nz, 3$ - 6$: ENABLE_VBLANK_COPY ; switch ON copy shadow SAT
This webpage is intended to be an accessible preview of this repository. To get a fuller picture, clone it and use the git CLI.