git.y1.nz

gbdk-2020

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

commit f56adc152366b4ed5e99fb69efa36e7d19c5d598
parent 49429638d169e791ec6d197916fd481c0502d7e6
Author: Toxa <untoxa@mail.ru>
Date:   Mon, 30 Aug 2021 14:02:58 +0300

expose refresh_OAM(); SMS/GG: fix fill_rect_compat(); SMS/GG: fix clear screen dimensions in metasprites cross-platform example

Diffstat:
Mgbdk-lib/examples/cross-platform/metasprites/src/metasprites.c3++-
Mgbdk-lib/include/gb/gb.h4+++-
Mgbdk-lib/include/sms/sms.h4++++
Mgbdk-lib/libc/targets/gbz80/ap/crt0.s8+++++++-
Mgbdk-lib/libc/targets/gbz80/gb/crt0.s8+++++++-
Mgbdk-lib/libc/targets/z80/fill_rect_compat.s2+-
Mgbdk-lib/libc/targets/z80/gg/Makefile1+
Agbdk-lib/libc/targets/z80/refresh_oam.s35+++++++++++++++++++++++++++++++++++
Mgbdk-lib/libc/targets/z80/sms/Makefile1+
9 files changed, 61 insertions(+), 5 deletions(-)

diff --git a/gbdk-lib/examples/cross-platform/metasprites/src/metasprites.c b/gbdk-lib/examples/cross-platform/metasprites/src/metasprites.c @@ -31,8 +31,9 @@ uint8_t idx; // main funxction void main(void) { DISPLAY_OFF; + // Fill the screen background with a single tile pattern - fill_bkg_rect(0, 0, 20, 18, 0); + fill_bkg_rect(0, 0, DEVICE_SCREEN_WIDTH, DEVICE_SCREEN_HEIGHT, 0); // set tile data for background set_bkg_data(0, 1, pattern); diff --git a/gbdk-lib/include/gb/gb.h b/gbdk-lib/include/gb/gb.h @@ -625,6 +625,9 @@ void wait_vbl_done(void) NONBANKED __preserves_regs(b, c, d, e, h, l); */ void display_off(void) NONBANKED __preserves_regs(b, c, d, e, h, l); +/** Copies data from shadow OAM to OAM + */ +void refresh_OAM() NONBANKED; /** Copies data from somewhere in the lower address space to part of hi-ram. @@ -637,7 +640,6 @@ void hiramcpy(uint8_t dst, uint8_t n) NONBANKED __preserves_regs(b, c); - /** Turns the display back on. @see display_off, DISPLAY_OFF */ diff --git a/gbdk-lib/include/sms/sms.h b/gbdk-lib/include/sms/sms.h @@ -201,6 +201,10 @@ inline void display_off(void) { #define DISPLAY_OFF \ display_off(); +/** Copies data from shadow OAM to OAM + */ +void refresh_OAM(); + /** Blanks leftmost column, so it is not garbaged when you use horizontal scroll @see SHOW_LEFT_COLUMN */ diff --git a/gbdk-lib/libc/targets/gbz80/ap/crt0.s b/gbdk-lib/libc/targets/gbz80/ap/crt0.s @@ -101,6 +101,12 @@ __standard_VBL_handler:: LDH (.vbl_done),A RET +_refresh_OAM:: + LD HL, #((.refresh_OAM_DMA - .start_refresh_OAM) + .refresh_OAM) + WAIT_STAT + LD A, #>_shadow_OAM + JP (HL) + ;; GameBoy Header ;; DO NOT CHANGE... @@ -276,7 +282,7 @@ _set_interrupts:: LDH A,(__shadow_OAM_base) OR A RET Z - +.refresh_OAM_DMA: LDH (.DMA),A ; Put A into DMA registers LD A,#0x28 ; We need to wait 160 ns 1$: diff --git a/gbdk-lib/libc/targets/gbz80/gb/crt0.s b/gbdk-lib/libc/targets/gbz80/gb/crt0.s @@ -101,6 +101,12 @@ __standard_VBL_handler:: LDH (.vbl_done),A RET +_refresh_OAM:: + LD HL, #((.refresh_OAM_DMA - .start_refresh_OAM) + .refresh_OAM) + WAIT_STAT + LD A, #>_shadow_OAM + JP (HL) + ;; GameBoy Header ;; DO NOT CHANGE... @@ -281,7 +287,7 @@ _set_interrupts:: LDH A,(__shadow_OAM_base) OR A RET Z - +.refresh_OAM_DMA: LDH (.DMA),A ; Put A into DMA registers LD A,#0x28 ; We need to wait 160 ns 1$: diff --git a/gbdk-lib/libc/targets/z80/fill_rect_compat.s b/gbdk-lib/libc/targets/z80/fill_rect_compat.s @@ -27,4 +27,4 @@ _fill_rect_compat:: ld c, e ld e, a ; BC = data, DE = YX - jp .set_tile_map_xy_compat + jp .fill_rect_xy_compat diff --git a/gbdk-lib/libc/targets/z80/gg/Makefile b/gbdk-lib/libc/targets/z80/gg/Makefile @@ -9,6 +9,7 @@ CSRC = ASSRC = set_interrupts.s \ outi.s vmemcpy.s \ + refresh_oam.s \ set_data.s set_2bpp_data.s \ set_tile_map.s set_tile_map_xy.s set_tile_map_compat.s set_tile_map_xy_compat.s \ set_tile_submap.s set_tile_submap_compat.s \ diff --git a/gbdk-lib/libc/targets/z80/refresh_oam.s b/gbdk-lib/libc/targets/z80/refresh_oam.s @@ -0,0 +1,34 @@ + .include "global.s" + + .title "VRAM utilities" + .module VRAMUtils + + .globl __shadow_OAM_base + + .ez80 + + .area _HOME + +; void refresh_OAM(); +_refresh_OAM:: + DISABLE_VBLANK_COPY ; switch OFF copy shadow SAT + ld de, #.VDP_SAT + SMS_WRITE_VDP_CMD d, e + + ld h, #>_shadow_OAM + ld l, #0 + ld c, #.VDP_DATA + ld b, #64 +1$: + outi + jp nz, 1$ + + ld de, #(.VDP_SAT + 0x80) + SMS_WRITE_VDP_CMD d, e + ld b, #128 +2$: + outi + jp nz, 2$ + + ENABLE_VBLANK_COPY ; switch OFF copy shadow SAT + ret + diff --git a/gbdk-lib/libc/targets/z80/sms/Makefile b/gbdk-lib/libc/targets/z80/sms/Makefile @@ -9,6 +9,7 @@ CSRC = ASSRC = set_interrupts.s \ outi.s vmemcpy.s \ + refresh_oam.s \ set_data.s set_2bpp_data.s \ set_tile_map.s set_tile_map_xy.s set_tile_map_compat.s set_tile_map_xy_compat.s \ set_tile_submap.s set_tile_submap_compat.s \

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