git.y1.nz

gbdk-2020

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

commit 611058b85d2f1627093c1951c6171d8e6203e1a9
parent 1d8c1a127065f5ec02fd90334ffcbd0acd54d4ee
Author: Toxa <untoxa@mail.ru>
Date:   Fri,  9 Dec 2022 22:17:39 +0300

SMS/GG: split metasprites.s into the two objects in the library

Diffstat:
Mgbdk-lib/examples/cross-platform/metasprites/src/metasprites.c1+
Mgbdk-lib/libc/targets/z80/gg/Makefile2+-
Mgbdk-lib/libc/targets/z80/sms/Makefile2+-
Mgbdk-lib/libc/targets/z80/sms_metasprites.s21+--------------------
Agbdk-lib/libc/targets/z80/sms_metasprites_flip.s86+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
5 files changed, 90 insertions(+), 22 deletions(-)

diff --git a/gbdk-lib/examples/cross-platform/metasprites/src/metasprites.c b/gbdk-lib/examples/cross-platform/metasprites/src/metasprites.c @@ -96,6 +96,7 @@ void set_tile(UBYTE tile_idx, UBYTE* data, UBYTE flip_x, UBYTE flip_y) uint8_t get_tile_offset(uint8_t flipx, uint8_t flipy) { + flipx; flipy; // suppress compiler warnings uint8_t offset = 0; #if !HARDWARE_SPRITE_CAN_FLIP_Y offset += flipy ? num_tiles : 0; diff --git a/gbdk-lib/libc/targets/z80/gg/Makefile b/gbdk-lib/libc/targets/z80/gg/Makefile @@ -16,7 +16,7 @@ ASSRC = set_interrupts.s \ coords_to_address.s \ set_tile.s \ sms_fill_rect.s sms_fill_rect_xy.s sms_fill_rect_compat.s sms_fill_rect_xy_compat.s \ - sms_metasprites.s sms_metasprites_hide.s sms_metasprites_hide_spr.s \ + sms_metasprites.s sms_metasprites_flip.s sms_metasprites_hide.s sms_metasprites_hide_spr.s \ f_ibm_full.s f_ibm_sh.s f_italic.s f_min.s f_spect.s \ font.s color.s \ putchar.s \ diff --git a/gbdk-lib/libc/targets/z80/sms/Makefile b/gbdk-lib/libc/targets/z80/sms/Makefile @@ -16,7 +16,7 @@ ASSRC = set_interrupts.s \ coords_to_address.s \ set_tile.s \ sms_fill_rect.s sms_fill_rect_xy.s sms_fill_rect_compat.s sms_fill_rect_xy_compat.s \ - sms_metasprites.s sms_metasprites_hide.s sms_metasprites_hide_spr.s \ + sms_metasprites.s sms_metasprites_flip.s sms_metasprites_hide.s sms_metasprites_hide_spr.s \ f_ibm_full.s f_ibm_sh.s f_italic.s f_min.s f_spect.s \ font.s color.s \ putchar.s \ diff --git a/gbdk-lib/libc/targets/z80/sms_metasprites.s b/gbdk-lib/libc/targets/z80/sms_metasprites.s @@ -21,7 +21,7 @@ ___render_shadow_OAM:: ; uint8_t __move_metasprite(uint8_t id, uint8_t x, uint8_t y) __z88dk_callee __preserves_regs(iyh,iyl); -.macro MOVE_METASPRITE_BODY neg_dx neg_dy +___move_metasprite:: ld hl, #4 add hl, sp @@ -40,9 +40,6 @@ ___render_shadow_OAM:: inc hl cp #0x80 jp z, 2$ -.ifne neg_dy - neg ; apply flipy (or no-op) -.endif add b ld b, a cp #0xD0 @@ -60,9 +57,6 @@ ___render_shadow_OAM:: ld a, (hl) ; dx inc hl -.ifne neg_dx - neg ; apply flipx (or no-op) -.endif add c ld c, a ld (de), a @@ -86,16 +80,3 @@ ___render_shadow_OAM:: sub c ld l, a ret -.endm - -___move_metasprite:: - MOVE_METASPRITE_BODY 0,0 - -___move_metasprite_flipx:: - MOVE_METASPRITE_BODY 1,0 - -___move_metasprite_flipy:: - MOVE_METASPRITE_BODY 0,1 - -___move_metasprite_flipxy:: - MOVE_METASPRITE_BODY 1,1 diff --git a/gbdk-lib/libc/targets/z80/sms_metasprites_flip.s b/gbdk-lib/libc/targets/z80/sms_metasprites_flip.s @@ -0,0 +1,86 @@ + .include "global.s" + + .title "Metasprites" + .module Metasprites + + .area _DATA + + .globl ___current_metasprite, ___current_base_tile, ___render_shadow_OAM + + .area _CODE + +.macro MOVE_METASPRITE_BODY neg_dx neg_dy + ld hl, #4 + add hl, sp + + ld b, (hl) + dec hl + ld c, (hl) + dec hl + ld e, (hl) + + ld hl, (___current_metasprite) + + ld a, (___render_shadow_OAM) + ld d, a +1$: + ld a, (hl) ; dy + inc hl + cp #0x80 + jp z, 2$ +.ifne neg_dy + neg ; apply flipy (or no-op) +.endif + add b + ld b, a + cp #0xD0 + jp nz, 3$ + ld a, #0xC0 +3$: + ld (de), a + + push de + + ld a, e + add a + add #0x40 + ld e, a + + ld a, (hl) ; dx + inc hl +.ifne neg_dx + neg ; apply flipx (or no-op) +.endif + add c + ld c, a + ld (de), a + inc e + + ld a, (___current_base_tile) + add (hl) ; tile + inc hl + ld (de), a + + pop de + inc e + + jp 1$ +2$: + pop hl + pop bc + inc sp + push hl + ld a, e + sub c + ld l, a + ret +.endm + +___move_metasprite_flipx:: + MOVE_METASPRITE_BODY 1,0 + +___move_metasprite_flipy:: + MOVE_METASPRITE_BODY 0,1 + +___move_metasprite_flipxy:: + MOVE_METASPRITE_BODY 1,1

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