git.y1.nz

gbdk-2020

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

commit 672c8d9ecb417ee5b31ea9a3b0bccabbfb62e835
parent 831266884b9bd17e5401f9b852e1c02d912c6ac0
Author: Toxa <untoxa@mail.ru>
Date:   Fri, 10 Sep 2021 16:18:07 +0300

SMS/GG: rename set_tile_data() into set_native_tile_data() to avoid intersection with GB function

Diffstat:
Mgbdk-lib/include/gb/gb.h10+++++++++-
Mgbdk-lib/include/sms/sms.h6+++---
Mgbdk-lib/libc/targets/z80/font.s4++--
Mgbdk-lib/libc/targets/z80/gg/Makefile2+-
Dgbdk-lib/libc/targets/z80/set_data.s51---------------------------------------------------
Agbdk-lib/libc/targets/z80/set_native_data.s51+++++++++++++++++++++++++++++++++++++++++++++++++++
Mgbdk-lib/libc/targets/z80/sms/Makefile2+-
7 files changed, 67 insertions(+), 59 deletions(-)

diff --git a/gbdk-lib/include/gb/gb.h b/gbdk-lib/include/gb/gb.h @@ -777,7 +777,6 @@ uint8_t get_vram_byte(uint8_t * addr) __preserves_regs(b, c); */ uint8_t * get_bkg_xy_addr(uint8_t x, uint8_t y) __preserves_regs(b, c); - #define COMPAT_PALETTE(C0,C1,C2,C3) (((C3) << 6) | ((C2) << 4) | ((C1) << 2) | (C0)) /** Sets palette for 2bpp color translation for GG/SMS, does nothing on GB @@ -1571,6 +1570,15 @@ void get_tiles(uint8_t x, uint8_t *tiles) NONBANKED __preserves_regs(b, c); +/** Sets VRAM Tile Pattern data in the native format + */ +inline void set_native_tile_data(uint16_t first_tile, uint8_t nb_tiles, const uint8_t *data) { + if (first_tile < 256) { + set_bkg_data(first_tile, nb_tiles, data); + } else { + set_sprite_data(first_tile - 256, nb_tiles, data); + } +} /** Initializes the entire Window Tile Map with Tile Number __c__ diff --git a/gbdk-lib/include/sms/sms.h b/gbdk-lib/include/sms/sms.h @@ -512,12 +512,12 @@ void set_palette_entry(uint8_t palette, uint8_t entry, uint16_t rgb_data) __z88d #define set_sprite_palette(first_palette,nb_palettes,rgb_data) set_palette(1,1,rgb_data) void set_palette(uint8_t first_palette, uint8_t nb_palettes, palette_entry_t *rgb_data) __z88dk_callee; -void set_tile_data(uint16_t start, uint16_t ntiles, const void *src) __z88dk_callee __preserves_regs(iyh,iyl); +void set_native_tile_data(uint16_t start, uint16_t ntiles, const void *src) __z88dk_callee __preserves_regs(iyh,iyl); inline void set_bkg_4bpp_data(uint16_t start, uint16_t ntiles, const void *src) { - set_tile_data(start, ntiles, src); + set_native_tile_data(start, ntiles, src); } inline void set_sprite_4bpp_data(uint16_t start, uint16_t ntiles, const void *src) { - set_tile_data((uint8_t)(start) + 0x100u, ntiles, src); + set_native_tile_data((uint8_t)(start) + 0x100u, ntiles, src); } #define COMPAT_PALETTE(C0,C1,C2,C3) (((uint16_t)(C3) << 12) | ((uint16_t)(C2) << 8) | ((uint16_t)(C1) << 4) | (uint16_t)(C0)) diff --git a/gbdk-lib/libc/targets/z80/font.s b/gbdk-lib/libc/targets/z80/font.s @@ -6,7 +6,7 @@ .globl .memset_small .globl _font_ibm .globl __current_1bpp_colors, .fg_colour, .bg_colour - .globl _set_tile_data, _set_tile_1bpp_data + .globl _set_native_tile_data, _set_tile_1bpp_data ; Structure offsets sfont_handle_sizeof = 3 @@ -166,5 +166,5 @@ load_font_tiles: push hl push de push bc - call _set_tile_data + call _set_native_tile_data ret diff --git a/gbdk-lib/libc/targets/z80/gg/Makefile b/gbdk-lib/libc/targets/z80/gg/Makefile @@ -10,7 +10,7 @@ CSRC = ASSRC = set_interrupts.s \ outi.s vmemcpy.s \ refresh_oam.s \ - set_data.s set_1bpp_data.s set_2bpp_data.s \ + set_native_data.s set_1bpp_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 \ coords_to_address.s \ diff --git a/gbdk-lib/libc/targets/z80/set_data.s b/gbdk-lib/libc/targets/z80/set_data.s @@ -1,51 +0,0 @@ - .include "global.s" - - .title "VRAM utilities" - .module VRAMUtils - .area _HOME - -; void set_tile_data(uint16_t start, uint16_t ntiles, const void *src) __z88dk_callee __preserves_regs(iyh,iyl); -_set_tile_data:: - pop de ; pop ret address - pop hl - - add hl, hl - add hl, hl - add hl, hl - add hl, hl - add hl, hl - - ld bc, #.VDP_VRAM - add hl, bc - - DISABLE_VBLANK_COPY ; switch OFF copy shadow SAT - - SMS_WRITE_VDP_CMD h, l - - pop bc - pop hl - push de - - ld e, c - ld d, b - - ld c, #.VDP_DATA - inc d - inc e - jr 2$ - -1$: - ld b, #32 -3$: - outi - jr nz, 3$ -2$: - dec e - jr nz, 1$ - - dec d - jr nz, 1$ - - ENABLE_VBLANK_COPY ; switch ON copy shadow SAT - - ret diff --git a/gbdk-lib/libc/targets/z80/set_native_data.s b/gbdk-lib/libc/targets/z80/set_native_data.s @@ -0,0 +1,51 @@ + .include "global.s" + + .title "VRAM utilities" + .module VRAMUtils + .area _HOME + +; void set_native_tile_data(uint16_t start, uint16_t ntiles, const void *src) __z88dk_callee __preserves_regs(iyh,iyl); +_set_native_tile_data:: + pop de ; pop ret address + pop hl + + add hl, hl + add hl, hl + add hl, hl + add hl, hl + add hl, hl + + ld bc, #.VDP_VRAM + add hl, bc + + DISABLE_VBLANK_COPY ; switch OFF copy shadow SAT + + SMS_WRITE_VDP_CMD h, l + + pop bc + pop hl + push de + + ld e, c + ld d, b + + ld c, #.VDP_DATA + inc d + inc e + jr 2$ + +1$: + ld b, #32 +3$: + outi + jr nz, 3$ +2$: + dec e + jr nz, 1$ + + dec d + jr nz, 1$ + + ENABLE_VBLANK_COPY ; switch ON copy shadow SAT + + ret diff --git a/gbdk-lib/libc/targets/z80/sms/Makefile b/gbdk-lib/libc/targets/z80/sms/Makefile @@ -10,7 +10,7 @@ CSRC = ASSRC = set_interrupts.s \ outi.s vmemcpy.s \ refresh_oam.s \ - set_data.s set_1bpp_data.s set_2bpp_data.s \ + set_native_data.s set_1bpp_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 \ coords_to_address.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.