diff options
author | Juan J. Martinez <jjm@usebox.net> | 2023-05-22 07:13:54 +0100 |
---|---|---|
committer | Juan J. Martinez <jjm@usebox.net> | 2023-05-22 07:13:54 +0100 |
commit | c09a85ef9da7c1608b9d78c41975b4fdbbadf3e4 (patch) | |
tree | 710c0ca794e69d77a7e6ac5b035c1547c706a073 | |
parent | 82e506390d12a3ce30604e42af8cbccc448ad861 (diff) | |
download | tr8vm-c09a85ef9da7c1608b9d78c41975b4fdbbadf3e4.tar.gz tr8vm-c09a85ef9da7c1608b9d78c41975b4fdbbadf3e4.zip |
Use a bitmap font
-rw-r--r-- | game/assets/font.png | bin | 0 -> 6627 bytes | |||
-rw-r--r-- | game/main.asm | 79 | ||||
-rw-r--r-- | game/text.asm | 95 |
3 files changed, 109 insertions, 65 deletions
diff --git a/game/assets/font.png b/game/assets/font.png Binary files differnew file mode 100644 index 0000000..4b0fbf0 --- /dev/null +++ b/game/assets/font.png 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 a, >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 ; @@ -103,12 +96,6 @@ fill_loop: ret ; -; Controls the blink of the "press start" text -; -blink: - .db 0 - -; ; Draws the menu ; menu_draw: @@ -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 a, >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 - 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 a, >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, <font + add x, y + bo + inc a + + call put_text_c + + pop x + pop a + + inc x + bo + inc a + + pop b + add b, 4 + push b + + jmp put_text_loop + +put_text_exit: + pop b + pop y + ret + +put_text_c: + ; settings mode + ld y, 128 + ld b, 0xb0 + port b, y + + ; setup + inc b + + ; addr: char sprite + ld y, x + port b, y + ld y, a + port b, y + + ; x + ld y, [sp + 4] + port b, y + + ; y + ld y, [sp + 5] + port b, y + + ; w + ld y, 4 + port b, y + ; h + ld y, 8 + port b, y + + ; blit + dec b + ; write, transparent + ld y, 3 + port b, y + ret |