From 0c0d2fd7c950b3eaa04b01e5a3f1644839e5318a Mon Sep 17 00:00:00 2001 From: Lukas Krickl Date: Fri, 4 Oct 2024 06:41:47 +0200 Subject: [PATCH] Added basic ui drawing code --- src/main.s | 1 + src/map.s | 2 -- src/strings.s | 7 +++++++ src/ui.s | 42 ++++++++++++++++++++++++++++++++++++++++++ src/video.s | 5 +---- tiles/tileset1.inc | 46 +++++++++++++++++++++++----------------------- 6 files changed, 74 insertions(+), 29 deletions(-) create mode 100644 src/ui.s 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 -- 2.30.2