Skip to content

Instantly share code, notes, and snippets.

@badlogic
Last active May 1, 2022 23:32
Show Gist options
  • Save badlogic/07cfe6828a92fe4ea13bd770dbc25be4 to your computer and use it in GitHub Desktop.
Save badlogic/07cfe6828a92fe4ea13bd770dbc25be4 to your computer and use it in GitHub Desktop.

Revisions

  1. badlogic revised this gist May 1, 2022. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion program.ul
    Original file line number Diff line number Diff line change
    @@ -4,7 +4,7 @@ loop:
    rand r1
    mulf r1, 255, r1
    f2i r1, r1
    and r1, 0xff000000, r1
    or r1, 0xff000000, r1
    push r1
    call _gfx_clear
    call _gfx_show
  2. badlogic revised this gist May 1, 2022. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions program.ul
    Original file line number Diff line number Diff line change
    @@ -4,6 +4,7 @@ loop:
    rand r1
    mulf r1, 255, r1
    f2i r1, r1
    and r1, 0xff000000, r1
    push r1
    call _gfx_clear
    call _gfx_show
  3. badlogic revised this gist May 1, 2022. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion program.ul
    Original file line number Diff line number Diff line change
    @@ -2,7 +2,7 @@ include "utils.ul"

    loop:
    rand r1
    mul r1, 255, r1
    mulf r1, 255, r1
    f2i r1, r1
    push r1
    call _gfx_clear
  4. badlogic revised this gist May 1, 2022. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion program.ul
    Original file line number Diff line number Diff line change
    @@ -3,7 +3,7 @@ include "utils.ul"
    loop:
    rand r1
    mul r1, 255, r1
    f2i
    f2i r1, r1
    push r1
    call _gfx_clear
    call _gfx_show
  5. badlogic revised this gist May 1, 2022. 1 changed file with 4 additions and 1 deletion.
    5 changes: 4 additions & 1 deletion program.ul
    Original file line number Diff line number Diff line change
    @@ -1,7 +1,10 @@
    include "utils.ul"

    loop:
    push 0xff00ff00
    rand r1
    mul r1, 255, r1
    f2i
    push r1
    call _gfx_clear
    call _gfx_show
    jmp loop
  6. badlogic revised this gist May 1, 2022. 1 changed file with 5 additions and 6 deletions.
    11 changes: 5 additions & 6 deletions program.ul
    Original file line number Diff line number Diff line change
    @@ -1,8 +1,7 @@
    include "utils.ul"

    push 0xff00ff00
    call _gfx_clear

    call _gfx_show

    halt
    loop:
    push 0xff00ff00
    call _gfx_clear
    call _gfx_show
    jmp loop
  7. badlogic revised this gist May 1, 2022. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion program.ul
    Original file line number Diff line number Diff line change
    @@ -1,6 +1,6 @@
    include "utils.ul"

    push 0xffff0000
    push 0xff00ff00
    call _gfx_clear

    call _gfx_show
  8. badlogic revised this gist May 1, 2022. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions utils.ul
    Original file line number Diff line number Diff line change
    @@ -29,6 +29,7 @@ _gfx_clear:
    _gfx_show:
    push _gfx_buffer
    syscall 0x1
    ret

    _utils_ul_end:
    nop
  9. badlogic revised this gist May 1, 2022. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion program.ul
    Original file line number Diff line number Diff line change
    @@ -1,6 +1,6 @@
    include "utils.ul"

    push 0xffffffff
    push 0xffff0000
    call _gfx_clear

    call _gfx_show
  10. badlogic revised this gist May 1, 2022. 1 changed file with 2 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions program.ul
    Original file line number Diff line number Diff line change
    @@ -3,4 +3,6 @@ include "utils.ul"
    push 0xffffffff
    call _gfx_clear

    call _gfx_show

    halt
  11. badlogic revised this gist May 1, 2022. 1 changed file with 3 additions and 1 deletion.
    4 changes: 3 additions & 1 deletion program.ul
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,6 @@
    include "utils.ul"

    push 0xffffffff
    call _gfx_clear
    call _gfx_clear

    halt
  12. badlogic revised this gist May 1, 2022. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion utils.ul
    Original file line number Diff line number Diff line change
    @@ -11,7 +11,7 @@ jmp _utils_ul_end
    _gfx_clear:
    pusha

    ld sp, 15 * 4, r1
    ld sp, 16 * 4, r1
    mov _gfx_buffer, r2

    _gfx_clear_loop:
  13. badlogic revised this gist May 1, 2022. 1 changed file with 6 additions and 1 deletion.
    7 changes: 6 additions & 1 deletion utils.ul
    Original file line number Diff line number Diff line change
    @@ -1,6 +1,8 @@
    # 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
    #
    @@ -26,4 +28,7 @@ _gfx_clear:
    #--------------------------------------------------
    _gfx_show:
    push _gfx_buffer
    syscall 0x1
    syscall 0x1

    _utils_ul_end:
    nop
  14. badlogic revised this gist May 1, 2022. 1 changed file with 2 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions program.ul
    Original file line number Diff line number Diff line change
    @@ -1,2 +1,4 @@
    include "utils.ul"

    push 0xffffffff
    call _gfx_clear
  15. badlogic revised this gist May 1, 2022. 1 changed file with 9 additions and 0 deletions.
    9 changes: 9 additions & 0 deletions utils.ul
    Original file line number Diff line number Diff line change
    @@ -1,5 +1,11 @@
    # The frame buffer, 320x240 pixels, RGBA
    _gfx_buffer: reserve int x 320 * 240

    #--------------------------------------------------
    # Clears the frame buffer with the given color
    #
    # [SP + 0]: color
    #--------------------------------------------------
    _gfx_clear:
    pusha

    @@ -15,6 +21,9 @@ _gfx_clear:
    popa
    retn 1

    #--------------------------------------------------
    # Blits the frame buffer to the screen
    #--------------------------------------------------
    _gfx_show:
    push _gfx_buffer
    syscall 0x1
  16. badlogic revised this gist May 1, 2022. 2 changed files with 5 additions and 2 deletions.
    1 change: 0 additions & 1 deletion program.ul
    Original file line number Diff line number Diff line change
    @@ -1,3 +1,2 @@
    include "utils.ul"

    halt
    6 changes: 5 additions & 1 deletion utils.ul
    Original file line number Diff line number Diff line change
    @@ -13,4 +13,8 @@ _gfx_clear:
    jl r4, _gfx_clear_loop

    popa
    retn 1
    retn 1

    _gfx_show:
    push _gfx_buffer
    syscall 0x1
  17. badlogic revised this gist May 1, 2022. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion utils.ul
    Original file line number Diff line number Diff line change
    @@ -7,7 +7,7 @@ _gfx_clear:
    mov _gfx_buffer, r2

    _gfx_clear_loop:
    sto r3, r1, r2
    sto r1, r2, 0
    add r2, 4, r2
    cmp r2, _gfx_buffer + 320 * 240 * 4, r4
    jl r4, _gfx_clear_loop
  18. badlogic revised this gist May 1, 2022. 1 changed file with 6 additions and 5 deletions.
    11 changes: 6 additions & 5 deletions utils.ul
    Original file line number Diff line number Diff line change
    @@ -5,11 +5,12 @@ _gfx_clear:

    ld sp, 15 * 4, r1
    mov _gfx_buffer, r2
    clear_buffer_loop:
    sto r3, r1, r2
    add r2, 4, r2
    cmp r2, 320 * 240 * 4, r4
    jl r4, clear_buffer_loop

    _gfx_clear_loop:
    sto r3, r1, r2
    add r2, 4, r2
    cmp r2, _gfx_buffer + 320 * 240 * 4, r4
    jl r4, _gfx_clear_loop

    popa
    retn 1
  19. badlogic revised this gist May 1, 2022. No changes.
  20. badlogic created this gist May 1, 2022.
    3 changes: 3 additions & 0 deletions program.ul
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,3 @@
    include "utils.ul"

    halt
    15 changes: 15 additions & 0 deletions utils.ul
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,15 @@
    _gfx_buffer: reserve int x 320 * 240

    _gfx_clear:
    pusha

    ld sp, 15 * 4, r1
    mov _gfx_buffer, r2
    clear_buffer_loop:
    sto r3, r1, r2
    add r2, 4, r2
    cmp r2, 320 * 240 * 4, r4
    jl r4, clear_buffer_loop

    popa
    retn 1