From d5acbcfc316ed0138e291abc4f8b959f5805c6ce Mon Sep 17 00:00:00 2001 From: Lukas Krickl Date: Fri, 21 Mar 2025 18:34:55 +0100 Subject: [PATCH] video: Added bg tileset cycles --- src/hw.inc | 1 + src/video.s | 12 ++++++++++++ tiles/tileset1.inc | 8 ++++---- 3 files changed, 17 insertions(+), 4 deletions(-) diff --git a/src/hw.inc b/src/hw.inc index c117709..c2f9aa0 100644 --- a/src/hw.inc +++ b/src/hw.inc @@ -13,6 +13,7 @@ #define LCDCF_BGON 0b00000001 #define LCDCF_ON 0b10000000 #define LCDCF_OBJON 0b00000010 +#define LCDCF_TILE_BANK 0b00010000 #define LCDF_WINDOWON 0b00100000 #define LCDF_OBJ_SIZE 0b00000100 #define LCDF_WINBANKSELECT 0b01000000 diff --git a/src/video.s b/src/video.s index d9ad061..efac8ef 100644 --- a/src/video.s +++ b/src/video.s @@ -1,5 +1,7 @@ #define BGP 0b11100100 +#define BG_CYCLE_FRAMES 7 + ; vblank handler vblank: ; dma previous frame's oam @@ -11,6 +13,16 @@ vblank: call scroll_write + ; cycle bg tiles for animations + ld a, [frame_count] + and a, BG_CYCLE_FRAMES + jr z, @skip_cycle REL + + ld a, [RLCD] + xor a, LCDCF_TILE_BANK + ld [RLCD], a +@skip_cycle: + ld a, 1 ld [frame_ready], a ret diff --git a/tiles/tileset1.inc b/tiles/tileset1.inc index 5c77aa9..c6cb263 100644 --- a/tiles/tileset1.inc +++ b/tiles/tileset1.inc @@ -1116,11 +1116,11 @@ .chr 22222222 ; tile 124 .chr 00000000 +.chr 01010000 +.chr 00101000 .chr 00000000 -.chr 00000000 -.chr 00000000 -.chr 00000000 -.chr 00000000 +.chr 01010100 +.chr 00101000 .chr 00000000 .chr 00000000 ; tile 125 -- 2.30.2