From c09a85ef9da7c1608b9d78c41975b4fdbbadf3e4 Mon Sep 17 00:00:00 2001 From: "Juan J. Martinez" Date: Mon, 22 May 2023 07:13:54 +0100 Subject: Use a bitmap font --- game/assets/font.png | Bin 0 -> 6627 bytes game/main.asm | 79 ++++++++---------------------------------- game/text.asm | 95 +++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 109 insertions(+), 65 deletions(-) create mode 100644 game/assets/font.png create mode 100644 game/text.asm (limited to 'game') diff --git a/game/assets/font.png b/game/assets/font.png new file mode 100644 index 0000000..4b0fbf0 Binary files /dev/null and b/game/assets/font.png differ diff --git a/game/main.asm b/game/main.asm index 365e381..5be96a6 100644 --- a/game/main.asm +++ b/game/main.asm @@ -8,12 +8,6 @@ ; Menu entry point ; menu: - ; reset the blink flag - ld x, blink - ld y, 0 - ld [a : x], y - call clear_screen menu_loop: @@ -31,7 +25,6 @@ menu_loop: bnz jmp menu_loop - ; ; Gameplay entry point ; @@ -102,12 +95,6 @@ fill_loop: jmp fill_loop ret -; -; Controls the blink of the "press start" text -; -blink: - .db 0 - ; ; Draws the menu ; @@ -145,59 +132,15 @@ menu_draw: ld y, 3 port b, y - ; settings mode - ld y, 128 - port b, y - - ; setup - inc b - - ld x, blink - ld y, [a : x] - inc y - and y, 31 - ld [a : x], y - cmp y, 10 - bnc - jmp menu_draw_start - - ; addr: black to erase sprite - ld y, 0 - port b, y - ld y, 0xa0 - port b, y - jmp menu_continue_start - -menu_draw_start: - ; addr: press start sprite - ld y, press - port b, y - -menu_continue_start: - ; x - ld y, 36 - port b, y - - ; y - ld y, 80 - port b, y - - ld y, 56 - port b, y - ld y, 8 - port b, y - - ; blit - dec b - ; write, transparent - ld y, 3 - port b, y + ld x, press_start + ld b, 40 + ld y, 84 + call put_text ; settings mode ld y, 128 + ld b, 0xb0 port b, y ; setup @@ -250,6 +193,7 @@ init: int_handler: iret +.include "text.asm" .include "random.asm" .include "starfield.asm" .include "entities.asm" @@ -331,7 +275,12 @@ stars: ; menu data title: .incpng "assets/title.png" -press: - .incpng "assets/press.png" +font: + .incpng "assets/font.png" usebox: .incpng "assets/usebox.png" + +; texts +press_start: + .str "PRESS START!" + .db 0 diff --git a/game/text.asm b/game/text.asm new file mode 100644 index 0000000..06a40b3 --- /dev/null +++ b/game/text.asm @@ -0,0 +1,95 @@ +; +; Bitmap font +; + +; +; Write text on screen +; +; Expects a 4x8 font on "font" label. +; +; in: a : x: text to write +; b, y : (x, y) dst coords +put_text: + push y + push b + +put_text_loop: + ld y, [a : x] + cmp y, 0 + bz + jmp put_text_exit + + sub y, 32 + + push a + push x + + rol y, 5 + ld x, y + and x, 31 + and y, 224 + + ld a, >font + add a, x + + ld x,