Last active
May 1, 2022 23:32
-
-
Save badlogic/07cfe6828a92fe4ea13bd770dbc25be4 to your computer and use it in GitHub Desktop.
Starfield
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
include "utils.ul" | |
loop: | |
rand r1 | |
mulf r1, 255, r1 | |
f2i r1, r1 | |
or r1, 0xff000000, r1 | |
push r1 | |
call _gfx_clear | |
call _gfx_show | |
jmp loop |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# The frame buffer, 320x240 pixels, RGBA | |
_gfx_buffer: reserve int x 320 * 240 | |
jmp _utils_ul_end | |
#-------------------------------------------------- | |
# Clears the frame buffer with the given color | |
# | |
# [SP + 0]: color | |
#-------------------------------------------------- | |
_gfx_clear: | |
pusha | |
ld sp, 16 * 4, r1 | |
mov _gfx_buffer, r2 | |
_gfx_clear_loop: | |
sto r1, r2, 0 | |
add r2, 4, r2 | |
cmp r2, _gfx_buffer + 320 * 240 * 4, r4 | |
jl r4, _gfx_clear_loop | |
popa | |
retn 1 | |
#-------------------------------------------------- | |
# Blits the frame buffer to the screen | |
#-------------------------------------------------- | |
_gfx_show: | |
push _gfx_buffer | |
syscall 0x1 | |
ret | |
_utils_ul_end: | |
nop |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment