From: Lukas Krickl Date: Fri, 4 Oct 2024 04:41:47 +0000 (+0200) Subject: Added basic ui drawing code X-Git-Url: https://git.krickl.dev/?a=commitdiff_plain;h=0c0d2fd7c950b3eaa04b01e5a3f1644839e5318a;p=gbrg%2F.git Added basic ui drawing code --- diff --git a/src/main.s b/src/main.s index fbe653d..2a059a3 100644 --- a/src/main.s +++ b/src/main.s @@ -39,6 +39,7 @@ main: #include "player.s" #include "update.s" #include "map.s" +#include "ui.s" #include "tiles.inc" diff --git a/src/map.s b/src/map.s index d66eead..9d2bf7f 100644 --- a/src/map.s +++ b/src/map.s @@ -119,8 +119,6 @@ room_draw: ld a, b cp a, 0 jp nz, @loop - - ret diff --git a/src/strings.s b/src/strings.s index e2691bd..5bd025a 100644 --- a/src/strings.s +++ b/src/strings.s @@ -10,6 +10,13 @@ STR_TITLE: .str "game" +.db 0 + +STR_HP: +.str "hp" +.db 0 +STR_MP: +.str "MP" .db 0 ; print a string 0-terminated to the screen diff --git a/src/ui.s b/src/ui.s new file mode 100644 index 0000000..4a36d2d --- /dev/null +++ b/src/ui.s @@ -0,0 +1,42 @@ +#define THP_ICON 0x33 +#define TMP_ICON 0x37 + + ; update the UI + ; this should only be called + ; during blanking +ui_draw: + ; draw hp string + ld hl, STR_HP + ld de, SCRN0_UI + call puts + + ; draw mp string + ld hl, STR_MP + ld de, SCRN0_UI+10 + call puts + + ; draw hp UI + ld a, THP_ICON + ld hl, SCRN0_UI+SCRN_W + ld [hl+], a + inc a + ld [hl+], a + inc a + ld [hl+], a + inc a + ld [hl+], a + + ; draw mp UI + ld a, TMP_ICON + ld hl, SCRN0_UI+SCRN_W+10 + ld [hl+], a + + ld a, THP_ICON+1 ; the bar + + ld [hl+], a + inc a + ld [hl+], a + inc a + ld [hl+], a + + ret diff --git a/src/video.s b/src/video.s index 7889b80..e315321 100644 --- a/src/video.s +++ b/src/video.s @@ -6,10 +6,7 @@ vblank: ; get inputs call poll_inputs - ; test puts - ld hl, STR_TITLE - ld de, SCRN0_UI - call puts + call ui_draw ld a, 1 ld [frame_ready], a diff --git a/tiles/tileset1.inc b/tiles/tileset1.inc index 552865d..1f4e41f 100644 --- a/tiles/tileset1.inc +++ b/tiles/tileset1.inc @@ -494,39 +494,39 @@ .chr 00000000 .chr 00000000 ; tile 55 -.chr 00000000 -.chr 00000000 -.chr 00000000 -.chr 00000000 -.chr 00000000 -.chr 00000000 -.chr 00000000 -.chr 00000000 +.chr 00333300 +.chr 00311300 +.chr 03322330 +.chr 32222223 +.chr 32222223 +.chr 30000003 +.chr 32222223 +.chr 03333330 ; tile 56 .chr 00000000 -.chr 00000000 -.chr 00000000 -.chr 00000000 -.chr 00000000 -.chr 00000000 +.chr 00333333 +.chr 03000000 +.chr 03000000 +.chr 03000000 +.chr 00333333 .chr 00000000 .chr 00000000 ; tile 57 .chr 00000000 -.chr 00000000 -.chr 00000000 -.chr 00000000 -.chr 00000000 -.chr 00000000 +.chr 33333333 +.chr 20000002 +.chr 20000002 +.chr 20000002 +.chr 33333333 .chr 00000000 .chr 00000000 ; tile 58 .chr 00000000 -.chr 00000000 -.chr 00000000 -.chr 00000000 -.chr 00000000 -.chr 00000000 +.chr 33333300 +.chr 00000030 +.chr 00000030 +.chr 00000030 +.chr 33333300 .chr 00000000 .chr 00000000 ; tile 59