From f89c327501a841d5bdcb5d26be065819e0e13229 Mon Sep 17 00:00:00 2001 From: "Juan J. Martinez" Date: Mon, 22 May 2023 12:52:47 +0100 Subject: Add hiscore, WIP HUD --- game/main.asm | 67 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 64 insertions(+), 3 deletions(-) diff --git a/game/main.asm b/game/main.asm index 5be96a6..87e2f97 100644 --- a/game/main.asm +++ b/game/main.asm @@ -38,6 +38,7 @@ game_loop: call stars_update call entities_update call entities_draw + call update_hud ; read controller 1 ld b, 0xf0 @@ -68,6 +69,17 @@ init_game: ld y, 104 ld [a : x], y + ; clear score + ld x, score + ld y, 6 + ld b, 0 +init_score_loop: + ld [a : x], b + dec y + bnz + jmp init_score_loop + halt call clear_screen @@ -75,6 +87,23 @@ init_game: ret +update_hud: + ; 6 digits + ld x, 6 + push x + + ; addr of the BCD number + ld x, score + ; where we want the text + ld b, 100 + ld y, 4 + + call put_bcd_number + + pop x + ret + ; ; Helper to clear the screen ; @@ -99,6 +128,28 @@ fill_loop: ; Draws the menu ; menu_draw: + ; hiscore + ld x, hiscore_text + ld b, 44 + ld y, 10 + call put_text + + ; 6 digits + ld x, 6 + push x + + ; addr of the BCD number + ld x, hiscore + ; where we want the text + ld b, 60 + ld y, 10 + + call put_bcd_number + + pop x + ; settings mode ld y, 128 ld b, 0xb0 @@ -132,8 +183,8 @@ menu_draw: ld y, 3 port b, y - ld x, press_start + ld x, press_start_text ld b, 40 ld y, 84 call put_text @@ -200,6 +251,12 @@ int_handler: .include "player.asm" .include "bullet.asm" +; in unpacked BCD format +hiscore: + .db 0, 1, 0, 0, 0, 0 +score: + .db 0, 0, 0, 0, 0, 0 + ; ; entity data ; @@ -281,6 +338,10 @@ usebox: .incpng "assets/usebox.png" ; texts -press_start: +press_start_text: .str "PRESS START!" .db 0 +hiscore_text: + .str "HI:" + .db 0 + -- cgit v1.2.3