diff options
author | Juan J. Martinez <jjm@usebox.net> | 2023-05-22 12:52:47 +0100 |
---|---|---|
committer | Juan J. Martinez <jjm@usebox.net> | 2023-05-22 12:52:47 +0100 |
commit | f89c327501a841d5bdcb5d26be065819e0e13229 (patch) | |
tree | 1473266113dee7c5d621dc21ae0a45efdc187708 /game | |
parent | 7fdecfff5dc39c14e7cc02cf38c327284f10cc7d (diff) | |
download | tr8vm-f89c327501a841d5bdcb5d26be065819e0e13229.tar.gz tr8vm-f89c327501a841d5bdcb5d26be065819e0e13229.zip |
Add hiscore, WIP HUD
Diffstat (limited to 'game')
-rw-r--r-- | game/main.asm | 67 |
1 files 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 a, >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 + ld a, >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 a, >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 + ld a, >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 a, >press_start + ld x, <press_start_text + ld a, >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 + |