uxn

Varvara Ordinator, written in ANSI C(SDL2)
git clone https://git.eamoncaddigan.net/uxn.git
Log | Files | Refs | README | LICENSE

commit ad19620b823ae74ae841cebbdf25d986a415c45a
parent 98c32fd95c405e31e3fca697f9c82356b9433c64
Author: neauoire <aliceffekt@gmail.com>
Date:   Sat, 10 Apr 2021 19:39:32 -0700

Merged ctrl with text

Diffstat:
Mbuild.sh | 2+-
Mprojects/examples/blank.usm | 3+--
Mprojects/examples/dev.audio.usm | 9++++-----
Aprojects/examples/dev.controller.buttons.usm | 71+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Aprojects/examples/dev.controller.keys.usm | 86+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Dprojects/examples/dev.controller.usm | 71-----------------------------------------------------------------------
Dprojects/examples/dev.keys.usm | 89-------------------------------------------------------------------------------
Mprojects/examples/gui.hover.usm | 4----
Mprojects/examples/gui.label.usm | 24+++++++++++++-----------
Mprojects/examples/gui.picture.usm | 3---
Mprojects/examples/gui.shapes.usm | 4----
Mprojects/software/nasu.usm | 38+++++++++++++-------------------------
Mprojects/software/noodle.usm | 63+++++++++++++++++++++++++++------------------------------------
Mprojects/software/orca.usm | 22+++++++---------------
Msrc/emulator.c | 43++++++++++++++-----------------------------
15 files changed, 237 insertions(+), 295 deletions(-)

diff --git a/build.sh b/build.sh @@ -32,7 +32,7 @@ else fi echo "Assembling.." -./bin/assembler projects/examples/dev.screen.usm bin/boot.rom +./bin/assembler projects/examples/dev.controller.buttons.usm bin/boot.rom echo "Running.." if [ "${2}" = '--cli' ]; diff --git a/projects/examples/blank.usm b/projects/examples/blank.usm @@ -8,8 +8,7 @@ |0110 ;Console { vector 2 pad 6 char 1 byte 1 short 2 string 2 } |0120 ;Screen { vector 2 width 2 height 2 pad 2 x 2 y 2 addr 2 color 1 } |0130 ;Audio { wave 2 envelope 2 pad 4 volume 1 pitch 1 play 1 value 2 delay 2 finish 1 } -|0140 ;Controller { vector 2 player1 1 player2 1 player3 1 player4 1 } -|0150 ;Keyboard { vector 2 key 1 } +|0140 ;Controller { vector 2 button 1 key 1 } |0160 ;Mouse { vector 2 x 2 y 2 state 1 chord 1 } |0170 ;File { vector 2 pad 6 name 2 length 2 load 3 save 2 } |01a0 ;DateTime { year 2 month 1 day 1 hour 1 minute 1 second 1 dotw 1 doty 2 isdst 1 refresh 1 } diff --git a/projects/examples/dev.audio.usm b/projects/examples/dev.audio.usm @@ -30,8 +30,7 @@ |0110 ;Console { pad 8 char 1 byte 1 short 2 } |0120 ;Screen { vector 2 width 2 height 2 pad 2 x 2 y 2 addr 2 color 1 } |0130 ;Audio { wave 2 envelope 2 pad 4 volume 1 pitch 1 play 1 value 2 delay 2 finish 1 } -|0140 ;Controller { vector 2 button 1 } -|0150 ;Keys { vector 2 key 1 } +|0140 ;Controller { vector 2 button 1 key 1 } |0160 ;Mouse { vector 2 x 2 y 2 state 1 chord 1 } |0170 ;File { pad 8 name 2 length 2 load 2 save 2 } @@ -42,7 +41,7 @@ ( theme ) #e0fa =System.r #30fa =System.g #30fa =System.b ( vectors ) ,on-screen =Screen.vector ( vectors ) ,on-mouse =Mouse.vector - ( vectors ) ,on-key =Keys.vector + ( vectors ) ,on-button =Controller.vector ~Screen.width #0002 DIV2 DUP2 #0080 SUB2 =trkframe.x1 #0080 ADD2 =trkframe.x2 @@ -96,9 +95,9 @@ BRK BRK -@on-key ( -> ) +@on-button ( -> ) - ~Keys.key + ~Controller.key DUP #61 NEQ ^$no-c JNZ ,notes PEK2 ,play JSR2 $no-c DUP #73 NEQ ^$no-d JNZ diff --git a/projects/examples/dev.controller.buttons.usm b/projects/examples/dev.controller.buttons.usm @@ -0,0 +1,71 @@ +( Dev/Controller ) + +%++ { #0001 ADD2 } +%-- { #0001 SUB2 } +%2/ { #0002 DIV2 } + +( variables ) + +;slime { color 1 } + +( devices ) + +|0100 ;System { vector 2 pad 6 r 2 g 2 b 2 } +|0120 ;Screen { vector 2 width 2 height 2 pad 2 x 2 y 2 addr 2 color 1 } +|0140 ;Controller { vector 2 button 1 key 1 } + +|0200 + + ( theme ) #0daf =System.r #02ff =System.g #035f =System.b + ( vectors ) ,FRAME =Screen.vector + + ( set origin ) + ~Screen.width 2/ =Screen.x + ~Screen.height 2/ =Screen.y + ,default_icn =Screen.addr + #31 =Screen.color + #2a =slime + +BRK + +@FRAME + + #2a =slime + ,default_icn =Screen.addr + + ( hold ctrl key to change slime color ) + + ~Controller.button #0f AND + DUP #01 NEQ ^$no-ctrl JNZ #25 =slime $no-ctrl + DUP #02 NEQ ^$no-alt JNZ #2f =slime $no-alt + POP + + ( clear ) #30 =Screen.color + + ( detect movement ) + ~Controller.button #f0 AND + DUP #04 SFT #01 AND #01 NEQ ^$no-up JNZ + ( move ) ~Screen.y -- =Screen.y ,up_icn =Screen.addr $no-up + DUP #05 SFT #01 AND #01 NEQ ^$no-down JNZ + ( move ) ~Screen.y ++ =Screen.y ,down_icn =Screen.addr $no-down + DUP #06 SFT #01 AND #01 NEQ ^$no-left JNZ + ( move ) ~Screen.x -- =Screen.x ,left_icn =Screen.addr $no-left + DUP #07 SFT #01 AND #01 NEQ ^$no-right JNZ + ( move ) ~Screen.x ++ =Screen.x ,right_icn =Screen.addr $no-right + POP + + ( draw face ) + #31 =Screen.color + + ( draw slime ) + ,slime_icn =Screen.addr + ~slime =Screen.color + +BRK + +@default_icn [ 3c7e ffdb ffe7 7e3c ] +@up_icn [ 2466 e7db ffff 7e3c ] +@down_icn [ 3c7e ffff dbe7 6624 ] +@left_icn [ 3c7e ef1f 1fef 7e3c ] +@right_icn [ 3c7e f7f8 f8f7 7e3c ] +@slime_icn [ 0000 183c 3c18 0000 ] diff --git a/projects/examples/dev.controller.keys.usm b/projects/examples/dev.controller.keys.usm @@ -0,0 +1,86 @@ +( Dev/Keys ) + +%RTN { JMP2r } +%8+ { #0008 ADD2 } +%8* { #0030 SFT2 } + +|0100 ;System { vector 2 pad 6 r 2 g 2 b 2 } +|0110 ;Console { vector 2 pad 6 char 1 byte 1 short 2 } +|0120 ;Screen { vector 2 pad 6 x 2 y 2 addr 2 color 1 } +|0140 ;Controller { vector 2 button 1 key 1 } + +( program ) + +|0200 + + ( theme ) #0f73 =System.r #0fe3 =System.g #0fc3 =System.b + ( vectors ) ,on-button =Controller.vector + ,draw-cursor JSR2 + +BRK + +@on-button + + ~Controller.key #00 NEQ ^$skip JNZ BRK $skip + + ~Controller.key #0d NEQ ^$no-return JNZ + #20 =Screen.color + #0000 =Screen.x + ( incr ) ~Screen.y 8+ =Screen.y + ,draw-cursor JSR2 + BRK + $no-return + + ~Controller.key =Console.char + + ,cursor_icn =Screen.addr + ,font #00 ~Controller.key 8* ADD2 =Screen.addr + ( draw ) #21 =Screen.color + ~Screen.x 8+ =Screen.x + ,draw-cursor JSR2 + +BRK + +@draw-cursor + + ,cursor_icn =Screen.addr #22 =Screen.color + +RTN + +@cursor_icn [ ffff ffff ffff ffff ] + +@font ( spectrum-zx font ) +[ + 0000 0000 0000 0000 0000 2400 7e3c 0000 0000 2400 3c42 0000 0000 6c7c 7c38 1000 + 0010 387c 7c38 1000 0038 387c 6c10 3800 0010 387c 7c10 3800 0000 0018 1800 0000 + 007e 4242 4242 7e00 0000 1824 2418 0000 0018 2442 4224 1800 001e 063a 4a48 3000 + 0038 446c 107c 1000 0000 0000 0000 0000 003e 2222 2266 6600 0000 0822 0022 0800 + 0000 1018 1c18 1000 0000 0818 3818 0800 0008 1c00 001c 0800 0028 2828 2800 2800 + 003e 4a4a 3a0a 0a00 000c 3046 620c 3000 0000 0000 0000 ffff 0010 3800 3810 0038 + 0008 1c2a 0808 0800 0008 0808 2a1c 0800 0000 0804 7e04 0800 0000 1020 7e20 1000 + 0000 4040 7e00 0000 0000 0024 6624 0000 0000 1038 7c00 0000 0000 007c 3810 0000 + 0000 0000 0000 0000 0008 0808 0800 0800 0014 1400 0000 0000 0024 7e24 247e 2400 + 0008 1e28 1c0a 3c08 0042 0408 1020 4200 0030 4832 4c44 3a00 0008 1000 0000 0000 + 0004 0808 0808 0400 0010 0808 0808 1000 0000 1408 3e08 1400 0000 0808 3e08 0800 + 0000 0000 0008 0810 0000 0000 3c00 0000 0000 0000 0000 0800 0000 0204 0810 2000 + 003c 464a 5262 3c00 0018 2808 0808 3e00 003c 4202 3c40 7e00 003c 421c 0242 3c00 + 0008 1828 487e 0800 007e 407c 0242 3c00 003c 407c 4242 3c00 007e 0204 0810 1000 + 003c 423c 4242 3c00 003c 4242 3e02 3c00 0000 0008 0000 0800 0000 0800 0008 0810 + 0000 0810 2010 0800 0000 003e 003e 0000 0000 1008 0408 1000 003c 4202 0c00 0800 + 003c 425a 5442 3c00 0018 2442 7e42 4200 007c 427c 4242 7c00 003c 4240 4042 3c00 + 0078 4442 4244 7800 007e 407c 4040 7e00 003e 4040 7c40 4000 003c 4240 4e42 3c00 + 0042 427e 4242 4200 003e 0808 0808 3e00 0002 0202 4242 3c00 0044 4870 4844 4200 + 0040 4040 4040 7e00 0042 665a 4242 4200 0042 6252 4a46 4200 003c 4242 4242 3c00 + 007c 4242 7c40 4000 003c 4242 524a 3c00 007c 4242 7c44 4200 003c 403c 0242 3c00 + 00fe 1010 1010 1000 0042 4242 4242 3c00 0042 4242 4224 1800 0042 4242 5a66 4200 + 0042 2418 1824 4200 0082 4428 1010 1000 007e 0408 1020 7e00 000c 0808 0808 0c00 + 0040 2010 0804 0200 0018 0808 0808 1800 0008 1422 0000 0000 0000 0000 0000 7e00 + 0008 0400 0000 0000 0000 1c02 1e22 1e00 0020 203c 2222 3c00 0000 1e20 2020 1e00 + 0002 021e 2222 1e00 0000 1c22 3c20 1e00 000c 101c 1010 1000 0000 1c22 221e 021c + 0020 202c 3222 2200 0008 0018 0808 0400 0008 0008 0808 4830 0020 2428 3028 2400 + 0010 1010 1010 0c00 0000 6854 5454 5400 0000 5864 4444 4400 0000 3844 4444 3800 + 0000 7844 4478 4040 0000 3c44 443c 0406 0000 2c30 2020 2000 0000 3840 3804 7800 + 0010 103c 1010 0c00 0000 4444 4444 3800 0000 4444 2828 1000 0000 4454 5454 2800 + 0000 4428 1028 4400 0000 4444 443c 0438 0000 7c08 1020 7c00 000c 0810 1008 0c00 + 0008 0808 0808 0800 0030 1008 0810 3000 0000 0032 4c00 0000 3c42 99a1 a199 423c +] diff --git a/projects/examples/dev.controller.usm b/projects/examples/dev.controller.usm @@ -1,71 +0,0 @@ -( Dev/Controller ) - -%++ { #0001 ADD2 } -%-- { #0001 SUB2 } -%2/ { #0002 DIV2 } - -( variables ) - -;slime { color 1 } - -( devices ) - -|0100 ;System { vector 2 pad 6 r 2 g 2 b 2 } -|0120 ;Screen { vector 2 width 2 height 2 pad 2 x 2 y 2 addr 2 color 1 } -|0140 ;Controller { vector 2 p1 1 } - -|0200 - - ( theme ) #0daf =System.r #02ff =System.g #035f =System.b - ( vectors ) ,FRAME =Screen.vector - - ( set origin ) - ~Screen.width 2/ =Screen.x - ~Screen.height 2/ =Screen.y - ,default_icn =Screen.addr - #31 =Screen.color - #2a =slime - -BRK - -@FRAME - - #2a =slime - ,default_icn =Screen.addr - - ( hold ctrl key to change slime color ) - - ~Controller.p1 #0f AND - DUP #01 NEQ ^$no-ctrl JNZ #25 =slime $no-ctrl - DUP #02 NEQ ^$no-alt JNZ #2f =slime $no-alt - POP - - ( clear ) #30 =Screen.color - - ( detect movement ) - ~Controller.p1 #f0 AND - DUP #04 SFT #01 AND #01 NEQ ^$no-up JNZ - ( move ) ~Screen.y -- =Screen.y ,up_icn =Screen.addr $no-up - DUP #05 SFT #01 AND #01 NEQ ^$no-down JNZ - ( move ) ~Screen.y ++ =Screen.y ,down_icn =Screen.addr $no-down - DUP #06 SFT #01 AND #01 NEQ ^$no-left JNZ - ( move ) ~Screen.x -- =Screen.x ,left_icn =Screen.addr $no-left - DUP #07 SFT #01 AND #01 NEQ ^$no-right JNZ - ( move ) ~Screen.x ++ =Screen.x ,right_icn =Screen.addr $no-right - POP - - ( draw face ) - #31 =Screen.color - - ( draw slime ) - ,slime_icn =Screen.addr - ~slime =Screen.color - -BRK - -@default_icn [ 3c7e ffdb ffe7 7e3c ] -@up_icn [ 2466 e7db ffff 7e3c ] -@down_icn [ 3c7e ffff dbe7 6624 ] -@left_icn [ 3c7e ef1f 1fef 7e3c ] -@right_icn [ 3c7e f7f8 f8f7 7e3c ] -@slime_icn [ 0000 183c 3c18 0000 ] diff --git a/projects/examples/dev.keys.usm b/projects/examples/dev.keys.usm @@ -1,89 +0,0 @@ -( Dev/Keys ) - -%RTN { JMP2r } -%8+ { #0008 ADD2 } -%8* { #0030 SFT2 } - -|0100 ;System { vector 2 pad 6 r 2 g 2 b 2 } -|0120 ;Screen { vector 2 pad 6 x 2 y 2 addr 2 color 1 } -|0140 ;Controller { vector 2 button 1 } -|0150 ;Keys { vector 2 key 1 } - -( program ) - -|0200 - - ( theme ) #0f73 =System.r #0fe3 =System.g #0fc3 =System.b - ( vectors ) ,KEY =Keys.vector - ( vectors ) ,BUTTON =Controller.vector - ,draw-cursor JSR2 - -BRK - -@KEY - - ,cursor_icn =Screen.addr - ,font #00 ~Keys.key 8* ADD2 =Screen.addr - ( draw ) #21 =Screen.color - ~Screen.x 8+ =Screen.x - ( release ) #00 =Keys.key - ,draw-cursor JSR2 - -BRK - -@BUTTON - - ( enter key ) - ~Controller.button #08 NEQ ^$no-return JNZ - #20 =Screen.color - #0000 =Screen.x - ( incr ) ~Screen.y 8+ =Screen.y - ( release ) #00 =Controller.button - ,draw-cursor JSR2 - $no-return - -BRK - -@draw-cursor - - ,cursor_icn =Screen.addr #22 =Screen.color - -RTN - -@cursor_icn [ ffff ffff ffff ffff ] - -@font ( spectrum-zx font ) -[ - 0000 0000 0000 0000 0000 2400 7e3c 0000 0000 2400 3c42 0000 0000 6c7c 7c38 1000 - 0010 387c 7c38 1000 0038 387c 6c10 3800 0010 387c 7c10 3800 0000 0018 1800 0000 - 007e 4242 4242 7e00 0000 1824 2418 0000 0018 2442 4224 1800 001e 063a 4a48 3000 - 0038 446c 107c 1000 0000 0000 0000 0000 003e 2222 2266 6600 0000 0822 0022 0800 - 0000 1018 1c18 1000 0000 0818 3818 0800 0008 1c00 001c 0800 0028 2828 2800 2800 - 003e 4a4a 3a0a 0a00 000c 3046 620c 3000 0000 0000 0000 ffff 0010 3800 3810 0038 - 0008 1c2a 0808 0800 0008 0808 2a1c 0800 0000 0804 7e04 0800 0000 1020 7e20 1000 - 0000 4040 7e00 0000 0000 0024 6624 0000 0000 1038 7c00 0000 0000 007c 3810 0000 - 0000 0000 0000 0000 0008 0808 0800 0800 0014 1400 0000 0000 0024 7e24 247e 2400 - 0008 1e28 1c0a 3c08 0042 0408 1020 4200 0030 4832 4c44 3a00 0008 1000 0000 0000 - 0004 0808 0808 0400 0010 0808 0808 1000 0000 1408 3e08 1400 0000 0808 3e08 0800 - 0000 0000 0008 0810 0000 0000 3c00 0000 0000 0000 0000 0800 0000 0204 0810 2000 - 003c 464a 5262 3c00 0018 2808 0808 3e00 003c 4202 3c40 7e00 003c 421c 0242 3c00 - 0008 1828 487e 0800 007e 407c 0242 3c00 003c 407c 4242 3c00 007e 0204 0810 1000 - 003c 423c 4242 3c00 003c 4242 3e02 3c00 0000 0008 0000 0800 0000 0800 0008 0810 - 0000 0810 2010 0800 0000 003e 003e 0000 0000 1008 0408 1000 003c 4202 0c00 0800 - 003c 425a 5442 3c00 0018 2442 7e42 4200 007c 427c 4242 7c00 003c 4240 4042 3c00 - 0078 4442 4244 7800 007e 407c 4040 7e00 003e 4040 7c40 4000 003c 4240 4e42 3c00 - 0042 427e 4242 4200 003e 0808 0808 3e00 0002 0202 4242 3c00 0044 4870 4844 4200 - 0040 4040 4040 7e00 0042 665a 4242 4200 0042 6252 4a46 4200 003c 4242 4242 3c00 - 007c 4242 7c40 4000 003c 4242 524a 3c00 007c 4242 7c44 4200 003c 403c 0242 3c00 - 00fe 1010 1010 1000 0042 4242 4242 3c00 0042 4242 4224 1800 0042 4242 5a66 4200 - 0042 2418 1824 4200 0082 4428 1010 1000 007e 0408 1020 7e00 000c 0808 0808 0c00 - 0040 2010 0804 0200 0018 0808 0808 1800 0008 1422 0000 0000 0000 0000 0000 7e00 - 0008 0400 0000 0000 0000 1c02 1e22 1e00 0020 203c 2222 3c00 0000 1e20 2020 1e00 - 0002 021e 2222 1e00 0000 1c22 3c20 1e00 000c 101c 1010 1000 0000 1c22 221e 021c - 0020 202c 3222 2200 0008 0018 0808 0400 0008 0008 0808 4830 0020 2428 3028 2400 - 0010 1010 1010 0c00 0000 6854 5454 5400 0000 5864 4444 4400 0000 3844 4444 3800 - 0000 7844 4478 4040 0000 3c44 443c 0406 0000 2c30 2020 2000 0000 3840 3804 7800 - 0010 103c 1010 0c00 0000 4444 4444 3800 0000 4444 2828 1000 0000 4454 5454 2800 - 0000 4428 1028 4400 0000 4444 443c 0438 0000 7c08 1020 7c00 000c 0810 1008 0c00 - 0008 0808 0808 0800 0030 1008 0810 3000 0000 0032 4c00 0000 3c42 99a1 a199 423c -] diff --git a/projects/examples/gui.hover.usm b/projects/examples/gui.hover.usm @@ -1,7 +1,6 @@ ( GUI Hover ) %RTN { JMP2r } -%RTN? { #00 EQU #02 JNZ STH2r JMP2 } ;color { byte 1 } ;pointer { x 2 y 2 sprite 2 } @@ -11,10 +10,7 @@ ;r3 { x1 2 y1 2 x2 2 y2 2 } |0100 ;System { vector 2 pad 6 r 2 g 2 b 2 } -|0110 ;Console { pad 8 char 1 byte 1 short 2 } |0120 ;Screen { vector 2 width 2 height 2 pad 2 x 2 y 2 addr 2 color 1 } -|0140 ;Controller { vector 2 button 1 } -|0150 ;Keys { vector 2 key 1 } |0160 ;Mouse { vector 2 x 2 y 2 state 1 chord 1 } ( program ) diff --git a/projects/examples/gui.label.usm b/projects/examples/gui.label.usm @@ -6,18 +6,20 @@ ;center { x 2 y 2 } |0100 ;System { vector 2 pad 6 r 2 g 2 b 2 } -|0110 ;Console { pad 8 char 1 byte 1 short 2 } |0120 ;Screen { vector 2 width 2 height 2 pad 2 x 2 y 2 addr 2 color 1 } -|0140 ;Controller { vector 2 button 1 } -|0150 ;Keys { vector 2 key 1 } -|0160 ;Mouse { vector 2 x 2 y 2 state 1 chord 1 } ( program ) -|0200 @RESET +|0200 ( theme ) #0f0f =System.r #0fff =System.g #0ff0 =System.b + ,draw JSR2 + +BRK + +@draw ( -- ) + ( find screen center ) ~Screen.width #0002 DIV2 =center.x ~Screen.height #0002 DIV2 =center.y @@ -34,10 +36,10 @@ ~center.x ~center.y #0010 ADD2 #2c ,text3 ,draw-label-right JSR2 ~center.x ~center.y #0020 ADD2 #2c ,text4 ,draw-label-middle JSR2 ~center.x ~center.y #0030 ADD2 #2c ,text5 ,draw-label-middle JSR2 - -BRK -@draw-label-left ( x y color addr ) +RTN + +@draw-label-left ( x y color addr -- ) ( load ) =label.addr =label.color =Screen.y =Screen.x ~label.addr @@ -50,7 +52,7 @@ BRK RTN -@draw-label-middle ( x y color addr ) +@draw-label-middle ( x y color addr -- ) ( load ) =label.addr =label.color =Screen.y ( align ) ~label.addr ,get-text-length JSR2 #0008 MUL2 #0002 DIV2 SUB2 =Screen.x @@ -64,7 +66,7 @@ RTN RTN -@draw-label-right ( x y color addr ) +@draw-label-right ( x y color addr -- ) ( load ) =label.addr =label.color =Screen.y ( align ) ~label.addr ,get-text-length JSR2 #0008 MUL2 SUB2 #0008 SUB2 =Screen.x @@ -78,7 +80,7 @@ RTN RTN -@get-text-length ( label ) +@get-text-length ( label* -- length ) #0000 ( counter ) $loop diff --git a/projects/examples/gui.picture.usm b/projects/examples/gui.picture.usm @@ -6,10 +6,7 @@ ;pict { x 2 y 2 width 2 height 2 color 1 addr 2 } |0100 ;System { vector 2 pad 6 r 2 g 2 b 2 } -|0110 ;Console { pad 8 char 1 byte 1 short 2 } |0120 ;Screen { vector 2 width 2 height 2 pad 2 x 2 y 2 addr 2 color 1 } -|0140 ;Controller { vector 2 button 1 } -|0150 ;Keys { vector 2 key 1 } |0160 ;Mouse { vector 2 x 2 y 2 state 1 chord 1 } |0170 ;File { pad 8 name 2 length 2 load 2 save 2 } diff --git a/projects/examples/gui.shapes.usm b/projects/examples/gui.shapes.usm @@ -13,11 +13,7 @@ ;circle { xc 2 yc 2 x 2 y 2 r 2 d 2 } |0100 ;System { vector 2 pad 6 r 2 g 2 b 2 } -|0110 ;Console { pad 8 char 1 byte 1 short 2 } |0120 ;Screen { vector 2 width 2 height 2 pad 2 x 2 y 2 addr 2 color 1 } -|0140 ;Controller { vector 2 button 1 } -|0150 ;Keys { vector 2 key 1 } -|0160 ;Mouse { vector 2 x 2 y 2 state 1 chord 1 } ( program ) diff --git a/projects/software/nasu.usm b/projects/software/nasu.usm @@ -34,18 +34,16 @@ |0100 ;System { vector 2 pad 6 r 2 g 2 b 2 } |0110 ;Console { pad 8 char 1 byte 1 short 2 } |0120 ;Screen { vector 2 width 2 height 2 pad 2 x 2 y 2 addr 2 color 1 } -|0140 ;Controller { vector 2 button 1 } -|0150 ;Keys { vector 2 key 1 } +|0140 ;Controller { vector 2 button 1 key 1 } |0160 ;Mouse { vector 2 x 2 y 2 state 1 chord 1 } |0170 ;File { pad 8 name 2 length 2 load 2 save 2 } ( program ) -|0200 @RESET +|0200 ( theme ) #e0fc =System.r #30cc =System.g #30ac =System.b ( vectors ) ,on-button =Controller.vector - ( vectors ) ,on-key =Keys.vector ( vectors ) ,on-mouse =Mouse.vector ~Screen.width 2/ #008a SUB2 =bankview.x @@ -56,23 +54,13 @@ ~Screen.height 2/ #003f SUB2 =tileview.y ,bank #0448 ADD2 =tileview.addr - ,filepath ,load-file JSR2 + ,filepath1 =File.name #0800 =File.length ,bank =File.load + ,filepath2 =File.name #0800 =File.length ,bank #0800 ADD2 =File.load ,redraw JSR2 BRK -@on-key - - ~Keys.key #31 LTH ^$skip JNZ - ~Keys.key #33 GTH ^$skip JNZ - ( select ) ~Keys.key #31 SUB =bankview.mode - ( release ) #00 =Keys.key - ,redraw JSR2 - $skip - -BRK - @on-button ~Controller.button @@ -86,6 +74,11 @@ BRK ~tileview.addr 8- =tileview.addr $no-ctrl-right POP ~tileview.addr #0800 DIV2 #0800 MUL2 =bankview.addr + + ~Controller.key #31 LTH ^$skip JNZ + ~Controller.key #33 GTH ^$skip JNZ + ( select ) ~Controller.key #31 SUB =bankview.mode + $skip ,redraw JSR2 BRK @@ -105,12 +98,12 @@ BRK ,redraw JSR2 ,$click-end JMP2 $no-brush-click ~Mouse.x ~tileview.x SUB2 8/ #000e NEQ2 ^$no-load-click JNZ - ( load ) ,filepath =File.name #0800 =File.length ~bankview.addr =File.load + ( load ) ,filepath1 =File.name #0800 =File.length ~bankview.addr =File.load ( release ) #00 =Mouse.state ,redraw JSR2 ,$click-end JMP2 $no-load-click ~Mouse.x ~tileview.x SUB2 8/ #000f NEQ2 ^$no-save-click JNZ - ( save ) ,filepath =File.name #0800 =File.length ~bankview.addr =File.save + ( save ) ,filepath1 =File.name #0800 =File.length ~bankview.addr =File.save ( release ) #00 =Mouse.state ,redraw JSR2 ,$click-end JMP2 $no-save-click @@ -206,12 +199,6 @@ BRK BRK -@load-file ( path ) - - =File.name #0800 =File.length ,bank =File.load - -RTN - @op_shiftup ~tileview.addr PEK2 @@ -505,7 +492,8 @@ RTN @save_icn [ fe82 8282 848a f400 ] @moveup_icn [ 0010 387c fe10 1000 ] @movedown_icn [ 0010 1010 fe7c 3810 ] -@filepath [ projects/fonts/specter8.bit 00 ] +@filepath1 [ projects/fonts/specter8.bit 00 ] +@filepath2 [ projects/pictures/cibo.bit 00 ] @font_hex ( 0-F ) [ diff --git a/projects/software/noodle.usm b/projects/software/noodle.usm @@ -52,10 +52,9 @@ ( devices ) |0100 ;System { vector 2 pad 6 r 2 g 2 b 2 } -|0110 ;Console { pad 8 char 1 byte 1 short 2 } +|0110 ;Console { pad 8 char 1 byte 1 short 2 string 2 } |0120 ;Screen { vector 2 width 2 height 2 pad 2 x 2 y 2 addr 2 color 1 } -|0140 ;Controller { vector 2 button 1 } -|0150 ;Keys { vector 2 key 1 } +|0140 ;Controller { vector 2 button 1 key 1 } |0160 ;Mouse { vector 2 x 2 y 2 state 1 chord 1 } |0170 ;File { pad 8 name 2 length 2 load 2 save 2 } @@ -67,7 +66,6 @@ #e0fa =theme.r0 #30fa =theme.g0 #30fa =theme.b0 ( normal mode ) #00fe =theme.r1 #00f3 =theme.g1 #00f3 =theme.b1 ( presentation mode ) ( vectors ) ,on-screen =Screen.vector - ( vectors ) ,on-key =Keys.vector ( vectors ) ,on-button =Controller.vector ( vectors ) ,on-mouse =Mouse.vector @@ -283,55 +281,49 @@ BRK BRK -@on-button - +@on-button ( -> ) + ( if in renaming mode ) ~document.edit #01 NEQ ,$no-edit JNZ2 + ~Controller.key #00 EQU ,$no-edit JNZ2 ( enter ) - ~Controller.button #08 NEQ ^$no-edit-enter JNZ + ~Controller.key #0d NEQ ^$no-edit-enter JNZ #00 =document.edit ,redraw JSR2 BRK $no-edit-enter ( backspace ) - ~Controller.button #04 NEQ ^$no-edit-backspace JNZ + ~Controller.key #08 NEQ ^$no-edit-backspace JNZ ~path.length #00 EQU ^$edit-end JNZ ~path.length #01 SUB =path.length #00 ,path.name #00 ~path.length ADD2 POK2 BRK $no-edit-backspace - $edit-end - BRK - $no-edit - - ~Controller.button #f0 AND - DUP #04 SFT #01 AND #01 NEQ ^$no-up JNZ - ( move ) ~zoom.y -- =zoom.y $no-up - DUP #05 SFT #01 AND #01 NEQ ^$no-down JNZ - ( move ) ~zoom.y ++ =zoom.y $no-down - DUP #06 SFT #01 AND #01 NEQ ^$no-left JNZ - ( move ) ~zoom.x -- =zoom.x $no-left - DUP #07 SFT #01 AND #01 NEQ ^$no-right JNZ - ( move ) ~zoom.x ++ =zoom.x $no-right - #00 EQU #04 JNZ ,draw-canvas JSR2 - -BRK - -@on-key - - ( if in renaming mode ) - ~document.edit #01 NEQ ,$no-edit JNZ2 ( default ) ~path.length #1f EQU ^$edit-end JNZ - ~Keys.key ,path.name #00 ~path.length ADD2 POK2 + ~Controller.key ,path.name #00 ~path.length ADD2 POK2 ~path.length #01 ADD =path.length - $edit-end + ~Controller.key =Console.byte + $edit-end #00 ,path.name #00 ~path.length ADD2 POK2 - ( release ) #00 =Keys.key BRK $no-edit - - ~Keys.key + + ( control zoom ) + ~zoom.active #00 EQU ^$skip-zoom JNZ + ~Controller.button #f0 AND + DUP #04 SFT #01 AND #01 NEQ ^$no-up JNZ + ( move ) ~zoom.y -- =zoom.y $no-up + DUP #05 SFT #01 AND #01 NEQ ^$no-down JNZ + ( move ) ~zoom.y ++ =zoom.y $no-down + DUP #06 SFT #01 AND #01 NEQ ^$no-left JNZ + ( move ) ~zoom.x -- =zoom.x $no-left + DUP #07 SFT #01 AND #01 NEQ ^$no-right JNZ + ( move ) ~zoom.x ++ =zoom.x $no-right + #00 EQU #04 JNZ ,draw-canvas JSR2 + $skip-zoom + + ~Controller.key DUP #20 NEQ ^$no-space JNZ ( toggle zoom ) ~zoom.active #00 EQU =zoom.active ,redraw JSR2 $no-space DUP #08 NEQ ^$no-backspace JNZ @@ -348,9 +340,8 @@ BRK ( tool0 ) #04 =brush.tool ,draw-toolpane JSR2 $no-tkey DUP DUP #30 GTH SWP #39 LTH #0101 NEQ2 ^$no-numkey JNZ - ( size ) ~Keys.key #31 SUB =brush.size ,draw-sizepane JSR2 $no-numkey + ( size ) ~Controller.key #31 SUB =brush.size ,draw-sizepane JSR2 $no-numkey POP - ( release ) #00 =Keys.key BRK diff --git a/projects/software/orca.usm b/projects/software/orca.usm @@ -45,15 +45,13 @@ |0100 ;System { vector 2 pad 6 r 2 g 2 b 2 } |0110 ;Console { pad 8 char 1 byte 1 short 2 } |0120 ;Screen { vector 2 width 2 height 2 pad 2 x 2 y 2 addr 2 color 1 } -|0140 ;Controller { vector 2 button 1 } -|0150 ;Keys { vector 2 key 1 } +|0140 ;Controller { vector 2 button 1 key 1 } |0160 ;Mouse { vector 2 x 2 y 2 state 1 chord 1 } |0200 ( theme ) #08f3 =System.r #08fc =System.g #08f9 =System.b ( vectors ) ,on-button =Controller.vector - ( vectors ) ,on-key =Keys.vector ( vectors ) ,on-mouse =Mouse.vector ( vectors ) ,on-frame =Screen.vector @@ -82,20 +80,14 @@ BRK BRK -@on-key - - ( skip ) ~Keys.key #00 NEQ ^$continue JNZ BRK $continue - - ~selection.x1 ~selection.y1 ~Keys.key SET-CELL - - ( release ) #00 =Keys.key - - ,redraw JSR2 - -BRK - @on-button + ~Controller.key #00 EQU ^$no-key JNZ + ~selection.x1 ~selection.y1 ~Controller.key SET-CELL + ~Controller.key =Console.byte + ,redraw JSR2 + $no-key + ( arrows ) ~Controller.button #f0 AND DUP #04 SFT #01 AND #01 NEQ ^$no-up JNZ diff --git a/src/emulator.c b/src/emulator.c @@ -23,7 +23,7 @@ static SDL_Renderer *gRenderer; static SDL_Texture *gTexture; static Ppu ppu; static Apu apu; -static Device *devsystem, *devscreen, *devmouse, *devkey, *devctrl, *devapu; +static Device *devsystem, *devscreen, *devmouse, *devctrl, *devapu; Uint8 zoom = 0, debug = 0, reqdraw = 0; @@ -152,25 +152,9 @@ domouse(Uxn *u, SDL_Event *event) } void -dotext(Uxn *u, SDL_Event *event) -{ - int i; - Uint16 addr = devkey->addr + 2; - if(SDL_GetModState() & KMOD_LCTRL || SDL_GetModState() & KMOD_RCTRL) - return; - for(i = 0; i < SDL_TEXTINPUTEVENT_TEXT_SIZE; ++i) { - char c = event->text.text[i]; - if(c < ' ' || c > '~') - break; - u->ram.dat[addr] = c; - } -} - -void doctrl(Uxn *u, SDL_Event *event, int z) { Uint8 flag = 0x00; - Uint16 addr = devctrl->addr + 2; if(z && event->key.keysym.sym == SDLK_h) { if(SDL_GetModState() & KMOD_LCTRL) toggledebug(u); @@ -180,17 +164,19 @@ doctrl(Uxn *u, SDL_Event *event, int z) switch(event->key.keysym.sym) { case SDLK_LCTRL: flag = 0x01; break; case SDLK_LALT: flag = 0x02; break; - case SDLK_BACKSPACE: flag = 0x04; break; - case SDLK_RETURN: flag = 0x08; break; + case SDLK_ESCAPE: flag = 0x04; break; + case SDLK_LSHIFT: flag = 0x08; break; case SDLK_UP: flag = 0x10; break; case SDLK_DOWN: flag = 0x20; break; case SDLK_LEFT: flag = 0x40; break; case SDLK_RIGHT: flag = 0x80; break; } - if(z) - u->ram.dat[addr] |= flag; - else - u->ram.dat[addr] &= (~flag); + if(flag && z) + u->ram.dat[devctrl->addr + 2] |= flag; + else if(flag) + u->ram.dat[devctrl->addr + 2] &= (~flag); + if(z && event->key.keysym.sym < 20) + u->ram.dat[devctrl->addr + 3] = event->key.keysym.sym; } #pragma mark - Devices @@ -338,21 +324,20 @@ start(Uxn *u) case SDL_QUIT: quit(); break; + case SDL_TEXTINPUT: + if(event.text.text[0] >= ' ' || event.text.text[0] <= '~') + u->ram.dat[devctrl->addr + 3] = event.text.text[0]; case SDL_KEYDOWN: case SDL_KEYUP: doctrl(u, &event, event.type == SDL_KEYDOWN); evaluxn(u, devctrl->vector); - break; + u->ram.dat[devctrl->addr + 3] = 0; case SDL_MOUSEBUTTONUP: case SDL_MOUSEBUTTONDOWN: case SDL_MOUSEMOTION: domouse(u, &event); evaluxn(u, devmouse->vector); break; - case SDL_TEXTINPUT: - dotext(u, &event); - evaluxn(u, devkey->vector); - break; case SDL_WINDOWEVENT: if(event.window.event == SDL_WINDOWEVENT_EXPOSED) redraw(ppu.output, u); @@ -389,7 +374,7 @@ main(int argc, char **argv) devscreen = portuxn(&u, 0x02, "screen", screen_poke); devapu = portuxn(&u, 0x03, "audio", audio_poke); devctrl = portuxn(&u, 0x04, "controller", ppnil); - devkey = portuxn(&u, 0x05, "key", ppnil); + portuxn(&u, 0x05, "---", ppnil); devmouse = portuxn(&u, 0x06, "mouse", ppnil); portuxn(&u, 0x07, "file", file_poke); portuxn(&u, 0x08, "---", ppnil);