home
editor
login
login
register
x1
open in editor
Drawing thingy
1 month ago
@adminus
// // Simple drawing thingy. // // Controls: // LMB - Draw // RMB - Erase // Q/W/E - Choose a color // var byte color var short mouse-x var short mouse-y fun on-reset ( -> ) { 256* Screen.width output 256* Screen.height output 0xf07f* System.red output 0xf0d6* System.green output 0xf0b2* System.blue output 0x5 -> color &on-mouse Screen.vector output &on-controller Controller.vector output } fun on-mouse ( -> ) { // Draw brush cursor. &cursor Screen.addr output mouse-x Screen.x output mouse-y Screen.y output 0b01000000 Screen.sprite output Mouse.x input2 4* sub { dup -> mouse-x } Screen.x output Mouse.y input2 4* sub { dup -> mouse-y } Screen.y output 0b01000000 color or Screen.sprite output // Drawing. &brush Screen.addr output Mouse.state input : (button) (button)dup 1 eq if { color Screen.sprite output } elif (button)dup 4 eq { 0b00000000 Screen.sprite output } (button) pop } fun on-controller ( -> ) { Controller.key input : (key) (key)dup 'q' eq if { 5 -> color } elif (key)dup 'w' eq { 10 -> color } elif (key)dup 'e' eq { 15 -> color } (key) pop } data brush { 0b00111100 0b01111110 0b11111111 0b11111111 0b11111111 0b11111111 0b01111110 0b00111100 } data cursor { 0b00111100 0b01000010 0b10000001 0b10000001 0b10000001 0b10000001 0b01000010 0b00111100 } // Here is all the devices you need to start doing things: alias enum byte System { expansion { 0x02 } wst { 0x04 } rst { 0x05 } metadata { 0x06 } red { 0x08 } green { 0x0a } blue { 0x0c } debug { 0x0e } state { 0x0f } } alias enum byte Screen { vector { 0x20 } width { 0x22 } height { 0x24 } auto { 0x26 } x { 0x28 } y { 0x2a } addr { 0x2c } pixel { 0x2e } sprite { 0x2f } } alias enum byte Controller { vector { 0x80 } button { 0x82 } key { 0x83 } } alias enum byte Mouse { vector { 0x90 } x { 0x92 } y { 0x94 } state { 0x96 } scrollx { 0x9a } scrolly { 0x9c } }
0 comments
~ log in to leave a comment ~
0 people gave a flower
~ log in to give a flower ~
The pile is empty...