From 681ba9adf948ebdc909b08979c76251053af7a9e Mon Sep 17 00:00:00 2001 From: "Juan J. Martinez" Date: Thu, 11 May 2023 20:57:55 +0100 Subject: Add starfield effect --- game/starfield.asm | 70 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) create mode 100644 game/starfield.asm (limited to 'game/starfield.asm') diff --git a/game/starfield.asm b/game/starfield.asm new file mode 100644 index 0000000..e8b8ed1 --- /dev/null +++ b/game/starfield.asm @@ -0,0 +1,70 @@ +; +; Simple starfield effect +; +stars_update: + ld x, stars + +stars_update_loop: + ld y, [a : x] + inc x + bo + inc a + ld b, [a : x] + ; is the end of list? + cmp b, 0xff + bz + ret + + push a + push x + + ; erase old + ld x, 0 + ld [b : y], x + ld x, [sp + 0] + + ; update address + inc x + bo + inc a + push x + ld x, [a : x] +stars_update_addr: + add y, 128 + bo + inc b + cmp b, 0xfe + bnz + jmp stars_no_wrap + cmp y, 0x80 + bc + ld b, 0xbf +stars_no_wrap: + dec x + bnz + jmp stars_update_addr + pop x + + ; draw new: color + inc x + bo + inc a + ld x, [a : x] + ld [b : y], x + + pop x + pop a + + ; save new address + ld [a : x], b + dec x + bo + dec a + ld [a : x], y + + ; next star + add x, 4 + bo + inc a + jmp stars_update_loop -- cgit v1.2.3