diff options
author | Juan J. Martinez <jjm@usebox.net> | 2023-05-06 19:21:47 +0100 |
---|---|---|
committer | Juan J. Martinez <jjm@usebox.net> | 2023-05-06 19:21:47 +0100 |
commit | 933b10c882a7b72a72a184d788d8fc67e829e0d6 (patch) | |
tree | c57cc1f1d0331d6dfdea926863ea00ed67125a7c /example.asm | |
parent | 5f6580a5ef2f756a2dde635b061456d04614d04c (diff) | |
download | tr8vm-933b10c882a7b72a72a184d788d8fc67e829e0d6.tar.gz tr8vm-933b10c882a7b72a72a184d788d8fc67e829e0d6.zip |
Will bounce the walls
Diffstat (limited to 'example.asm')
-rw-r--r-- | example.asm | 108 |
1 files changed, 95 insertions, 13 deletions
diff --git a/example.asm b/example.asm index cffef5e..48ee7db 100644 --- a/example.asm +++ b/example.asm @@ -19,30 +19,98 @@ ; enable interrupts cif - ; loop filling the screen with one - ; colour cycling the whole palette ld b, 0 loop: - call fill + call fill_screen + push b + + ; update sprite position + + ld a, >incx + ld x, <incx + ld y, [a : x] + inc x + bo + inc a + ; px + ld b, [a : x] + ; px + incx + add b, y + ; 128 - 16 + cmp b, 112 + bnc + jmp turn_x + + ; new x + ld [a : x], b + 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 + +update_y: + ld a, >incy + ld x, <incy + ld y, [a : x] + inc x + bo + inc a + ; py + ld b, [a : x] + ; py + incy + add b, y + ; 128 - 16 + cmp b, 112 + bnc + jmp turn_y + + ; new y + ld [a : x], b + 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 + +update_done: + call draw_sprite - pop b - ; wait 1 second - ld x, 60 -wait_loop: + ; wait 1 frame halt - dec x - bnz - jmp wait_loop + pop b jmp loop ; fill frame-buffer with a color in reg b -fill: +fill_screen: ld a, 0xbf ld x, 0 ld y, 0x40 @@ -60,6 +128,7 @@ fill_loop: int_handler: iret + ; draw sprite getting coordinates from px, py draw_sprite: ; blitter in settings mode ld x, 128 @@ -73,9 +142,13 @@ draw_sprite: port a, x ld x, >sprite port a, x - ; destination (56, 56) - ld x, 56 + ld y, <px + ld b, >px + ld x, [b : y] port a, x + ld y, <py + ld b, >py + ld x, [b : y] port a, x ; size 16x16 ld x, 16 @@ -92,3 +165,12 @@ draw_sprite: sprite: .incpng "assets/icon.png" +incx: + .db 1 +px: + .db 18 +incy: + .db 1 +py: + .db 64 + |