Added basic ui drawing code
authorLukas Krickl <lukas@krickl.dev>
Fri, 4 Oct 2024 04:41:47 +0000 (06:41 +0200)
committerLukas Krickl <lukas@krickl.dev>
Fri, 4 Oct 2024 04:41:47 +0000 (06:41 +0200)
src/main.s
src/map.s
src/strings.s
src/ui.s [new file with mode: 0644]
src/video.s
tiles/tileset1.inc

index fbe653db32643f1ac922681d360278ce5885a6da..2a059a3c63918348eaa1b83e30d93c182d0df82e 100644 (file)
@@ -39,6 +39,7 @@ main:
 #include "player.s"
 #include "update.s"
 #include "map.s"
+#include "ui.s"
 
 #include "tiles.inc"
 
index d66eead272b9205546740a1ffa85e4cb185fd799..9d2bf7fb2a0798084bb65bcd98b6aeb127a5dca3 100644 (file)
--- a/src/map.s
+++ b/src/map.s
@@ -119,8 +119,6 @@ room_draw:
   ld a, b
   cp a, 0
   jp nz, @loop
-   
-
 
   ret
 
index e2691bd03f1ba6b95bd118fb79471c781d8ad982..5bd025aa440952709af8235a3092d0574f4dfde8 100644 (file)
 
 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 (file)
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
index 7889b80bd35df06c1fb66d199513b25a44f2596c..e31532188c3d11cdf3c1cc13b9b3448d920b3c3f 100644 (file)
@@ -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
index 552865d6e5b62c791bb134e0c7db33486605277a..1f4e41fb0c82564db18582d7d1ad3e41ae82369b 100644 (file)
 .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