gbdk-2020 | GameBoy Development Kit |
| download: https://git.y1.nz/archives/gbdk.tar.gz | |
| README | Files | Log | Refs | LICENSE |
commit cf215fde947968e0220ee3436d17de9b8845132c parent 1b2e703fe811b251dc964d3f1f9fc8fd80043b75 Author: Toxa <untoxa@mail.ru> Date: Fri, 16 Jul 2021 19:42:44 +0300 hide_sprites_range() and example Diffstat:
| M | gbdk-lib/examples/gb/metasprites/metasprites.c | 2 | +- |
| M | gbdk-lib/include/gb/metasprites.h | 6 | ++++++ |
| M | gbdk-lib/libc/gb/Makefile | 2 | +- |
| A | gbdk-lib/libc/gb/metasprites_hide_spr.s | 68 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
4 files changed, 76 insertions(+), 2 deletions(-)
diff --git a/gbdk-lib/examples/gb/metasprites/metasprites.c b/gbdk-lib/examples/gb/metasprites/metasprites.c @@ -127,7 +127,7 @@ void main(void) { }; // Hide rest of the hardware sprites, because amount of sprites differ between animation frames. - for (uint8_t i = hiwater; i < 40; i++) shadow_OAM[i].y = 0; + hide_sprites_range(hiwater, 40); // Y Axis: update velocity (reduce speed) if no U/D button pressed if (!(PosF & ACC_Y)) { diff --git a/gbdk-lib/include/gb/metasprites.h b/gbdk-lib/include/gb/metasprites.h @@ -95,6 +95,12 @@ static uint8_t __move_metasprite_hflip(uint8_t id, uint8_t x, uint8_t y); static uint8_t __move_metasprite_hvflip(uint8_t id, uint8_t x, uint8_t y); static void __hide_metasprite(uint8_t id); +/** + * Hides all hardware sprites in range from <= X < to + * @param from start OAM index + * @param to finish OAM index + */ +void hide_sprites_range(UINT8 from, UINT8 to) __preserves_regs(b, c); /** Moves metasprite to the absolute position x and y diff --git a/gbdk-lib/libc/gb/Makefile b/gbdk-lib/libc/gb/Makefile @@ -31,7 +31,7 @@ ASSRC = cgb.s cgb_palettes.s cgb_compat.s \ mode.s clock.s \ get_t.s set_t.s init_vram.s \ fill_rect.s fill_rect_bk.s fill_rect_wi.s \ - metasprites.s metasprites_flip.s metasprites_hide.s \ + metasprites.s metasprites_flip.s metasprites_hide.s metasprites_hide_spr.s \ set_tile_submap.s set_win_tile_submap.s \ gb_decompress.s gb_decompress_tiles.s \ heap.s \ diff --git a/gbdk-lib/libc/gb/metasprites_hide_spr.s b/gbdk-lib/libc/gb/metasprites_hide_spr.s @@ -0,0 +1,68 @@ + .include "global.s" + + .title "Metasprites" + .module Metasprites + + .globl ___render_shadow_OAM + + .area _CODE + +; void hide_sprites_range(UINT8 from, UINT8 to) + +_hide_sprites_range:: + ldhl sp, #2 + ld a, (hl+) + + add a + add a + ld e, a + + ld a, (hl-) + sub (hl) + + ret c + ret z + + ld hl, #___render_shadow_OAM + ld h, (hl) + ld l, e + + ld de, #4 + + rra ; carry is never set here, because of ret c above + jr nc, 0$ + + ld (hl), d + add hl, de + + ret z ; z is not affected by 16-bit add + +0$: + rra ; carry is never set here, because of ret c above + jr nc, 1$ + + ld (hl), d + add hl, de + + ld (hl), d + add hl, de + + ret z ; z is not affected by 16-bit add + +1$: + ld (hl), d + add hl, de + + ld (hl), d + add hl, de + + ld (hl), d + add hl, de + + ld (hl), d + add hl, de + + dec a + jr nz, 1$ + + 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.