Skip to content

Instantly share code, notes, and snippets.

@badlogic
Last active May 1, 2022 23:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save badlogic/07cfe6828a92fe4ea13bd770dbc25be4 to your computer and use it in GitHub Desktop.
Save badlogic/07cfe6828a92fe4ea13bd770dbc25be4 to your computer and use it in GitHub Desktop.
Starfield
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
# 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