72 lines
2.0 KiB
Common Lisp
72 lines
2.0 KiB
Common Lisp
((code
|
|
(label main
|
|
; Open screen
|
|
; use load immediate because it is a pointer to a string, not a value
|
|
(load-immediate $18 &screen-namespace)
|
|
(syscall OPEN $0 $18 $11) ; open(out Plex screen, in namespace, in flags)
|
|
|
|
(nat-to-string $5 $0)
|
|
(call &pln ($5) nil)
|
|
|
|
(load-offset-32 $20 $0 8) ; load width
|
|
|
|
(nat-to-string $5 $20)
|
|
(call &pln ($5) nil)
|
|
|
|
(load-offset-32 $22 $0 12) ; load size
|
|
|
|
(nat-to-string $5 $22)
|
|
(call &pln ($5) nil)
|
|
|
|
(load-immediate $1 16) ; offset for screen buffer
|
|
(add-nat $21 $0 $1)
|
|
|
|
(nat-to-string $5 $21)
|
|
(call &pln ($5) nil)
|
|
|
|
; open mouse
|
|
(load-immediate $16 &mouse-namespace)
|
|
(syscall OPEN $15 $16 $11) ; open(out Plex mouse, in namespace, in flags)
|
|
|
|
(syscall WRITE $0 $21 $22) ; redraw
|
|
|
|
(label draw-loop
|
|
; load mouse click data
|
|
(syscall REFRESH $15)
|
|
(load-offset-8 $9 $15 16) ; load btn1 pressed
|
|
|
|
(jump-eq-nat &draw-loop $9 $11)
|
|
|
|
(load-offset-32 $7 $15 8) ; load x
|
|
(load-offset-32 $8 $15 12) ; load y
|
|
|
|
; Compute start address: y*width + x
|
|
(mul-nat $30 $8 $20) ; $15 = y * width
|
|
(add-nat $30 $30 $7) ; $15 += x
|
|
(add-nat $30 $30 $21) ; $15 += pixel_offset
|
|
(load-immediate $1 4) ; need to add offset for fat pointer size
|
|
(add-nat $30 $30 $1)
|
|
|
|
(load-absolute-32 $3 &WHITE) ; color
|
|
(store-absolute-8 $30 $3) ; draw color at screen [x,y]
|
|
(syscall WRITE $0 $21 $22) ; redraw
|
|
|
|
(jump &draw-loop))
|
|
(halt 0))
|
|
(label pln
|
|
(load-immediate $1 &terminal-namespace) ; get terminal device
|
|
(load-immediate $11 0)
|
|
(syscall OPEN $1 $1 $11)
|
|
(load-immediate $3 &new-line)
|
|
(string-length $2 $0)
|
|
(syscall WRITE $1 $0 $2)
|
|
(string-length $4 $3)
|
|
(syscall WRITE $1 $3 $4)
|
|
(return nil)))
|
|
(data
|
|
(label screen-namespace "/dev/screen/0")
|
|
(label mouse-namespace "/dev/mouse/0")
|
|
(label terminal-namespace "/dev/term/0")
|
|
(label new-line "\n")
|
|
(label WHITE 255)))
|