aboutsummaryrefslogtreecommitdiff
path: root/example.asm
diff options
context:
space:
mode:
authorJuan J. Martinez <jjm@usebox.net>2023-05-06 19:35:19 +0100
committerJuan J. Martinez <jjm@usebox.net>2023-05-06 19:35:19 +0100
commit627e526d0a4631f6a65ca18ee6fdad5e0c51e24a (patch)
treee11f09ecd33a88c9f641ba9e59d8ca36b272239a /example.asm
parent933b10c882a7b72a72a184d788d8fc67e829e0d6 (diff)
downloadtr8vm-627e526d0a4631f6a65ca18ee6fdad5e0c51e24a.tar.gz
tr8vm-627e526d0a4631f6a65ca18ee6fdad5e0c51e24a.zip
Improve comments and refactored turn
Diffstat (limited to 'example.asm')
-rw-r--r--example.asm53
1 files changed, 25 insertions, 28 deletions
diff --git a/example.asm b/example.asm
index 48ee7db..6714543 100644
--- a/example.asm
+++ b/example.asm
@@ -46,21 +46,9 @@ loop:
jmp update_y
turn_x:
- ; update incx
- ; 1 -> -1
- ; -1 -> 1
ld a, >incx
ld x, <incx
- ld y, [a : x]
- ld b, 254
- xor y, b
- ld [a : x], y
-
- ; change color
- pop b
- inc b
- and b, 15
- push b
+ call turn
update_y:
ld a, >incy
@@ -83,21 +71,9 @@ update_y:
jmp update_done
turn_y:
- ; update incy
- ; 1 -> -1
- ; -1 -> 1
ld a, >incy
ld x, <incy
- ld y, [a : x]
- ld b, 254
- xor y, b
- ld [a : x], y
-
- ; change color
- pop b
- inc b
- and b, 15
- push b
+ call turn
update_done:
@@ -109,7 +85,26 @@ update_done:
pop b
jmp loop
- ; fill frame-buffer with a color in reg b
+ ; make the sprite change direction
+ ; in: [a : x] inc*
+turn:
+ ; 1 -> -1
+ ; -1 -> 1
+ ld y, [a : x]
+ ld b, 254
+ xor y, b
+ ld [a : x], y
+
+ ; change color
+ ld b, [sp + 2]
+ inc b
+ and b, 15
+ ld [sp + 2], b
+ ret
+
+
+ ; fill frame-buffer
+ ; in: reg b color
fill_screen:
ld a, 0xbf
ld x, 0
@@ -128,7 +123,8 @@ fill_loop:
int_handler:
iret
- ; draw sprite getting coordinates from px, py
+ ; draw sprite
+ ; in: coordinates in px, py
draw_sprite:
; blitter in settings mode
ld x, 128
@@ -142,6 +138,7 @@ draw_sprite:
port a, x
ld x, >sprite
port a, x
+ ; destination
ld y, <px
ld b, >px
ld x, [b : y]