aboutsummaryrefslogtreecommitdiff
path: root/game/main.asm
diff options
context:
space:
mode:
authorJuan J. Martinez <jjm@usebox.net>2023-05-09 22:43:33 +0100
committerJuan J. Martinez <jjm@usebox.net>2023-05-09 22:43:33 +0100
commitd532317c011b9e5653241d50b961ee8caa710144 (patch)
treecb9fb308b9a92aa667ee626c8474b3e1e9f6f083 /game/main.asm
parent741561787cc2df547d5f520a142beaff234c488e (diff)
downloadtr8vm-d532317c011b9e5653241d50b961ee8caa710144.tar.gz
tr8vm-d532317c011b9e5653241d50b961ee8caa710144.zip
Playground
Potential example game.
Diffstat (limited to 'game/main.asm')
-rw-r--r--game/main.asm75
1 files changed, 75 insertions, 0 deletions
diff --git a/game/main.asm b/game/main.asm
new file mode 100644
index 0000000..3062ead
--- /dev/null
+++ b/game/main.asm
@@ -0,0 +1,75 @@
+.org 0
+
+.equ INT_VECTOR 0xff00
+
+ call init
+
+game_loop:
+ halt
+
+ call entities_erase
+ call entities_update
+ call entities_draw
+
+ jmp game_loop
+
+init:
+ ; setup an int handler so we
+ ; can use the frame int to sync
+ ld a, >INT_VECTOR
+ ld x, <INT_VECTOR
+ ld b, <int_handler
+ ld [a : x], b
+ inc x
+ ld b, >int_handler
+ ld [a : x], b
+
+ ; enable interrupts
+ cif
+
+ halt
+
+ ; pattern for the BG
+ ld b, 15
+ ld a, 0xbf
+ ld x, 0
+ ld y, 0x40
+fill_loop:
+ ld [a : x], b
+ xor b, 5
+ inc x
+ bno
+ jmp fill_loop
+ inc a
+ dec y
+ bnz
+ jmp fill_loop
+
+ call entities_draw
+
+ ret
+
+int_handler:
+ iret
+
+.include "entities.asm"
+.include "player.asm"
+
+;
+; entity data
+;
+entities:
+ ; type
+ .db ET_PLAYER
+ ; x, y
+ .db 0, 0
+ .dw player_sprite
+ .dw player_update
+
+ ; end of list
+ .db ET_END
+
+; sprite data
+player_sprite:
+ .incpng "assets/player.png"
+