... | ... |
@@ -8,8 +8,7 @@ |
8 | 8 |
|0110 ;Console { vector 2 pad 6 char 1 byte 1 short 2 string 2 } |
9 | 9 |
|0120 ;Screen { vector 2 width 2 height 2 pad 2 x 2 y 2 addr 2 color 1 } |
10 | 10 |
|0130 ;Audio { wave 2 envelope 2 pad 4 volume 1 pitch 1 play 1 value 2 delay 2 finish 1 } |
11 |
-|0140 ;Controller { vector 2 player1 1 player2 1 player3 1 player4 1 } |
|
12 |
-|0150 ;Keyboard { vector 2 key 1 } |
|
11 |
+|0140 ;Controller { vector 2 button 1 key 1 } |
|
13 | 12 |
|0160 ;Mouse { vector 2 x 2 y 2 state 1 chord 1 } |
14 | 13 |
|0170 ;File { vector 2 pad 6 name 2 length 2 load 3 save 2 } |
15 | 14 |
|01a0 ;DateTime { year 2 month 1 day 1 hour 1 minute 1 second 1 dotw 1 doty 2 isdst 1 refresh 1 } |
... | ... |
@@ -30,8 +30,7 @@ |
30 | 30 |
|0110 ;Console { pad 8 char 1 byte 1 short 2 } |
31 | 31 |
|0120 ;Screen { vector 2 width 2 height 2 pad 2 x 2 y 2 addr 2 color 1 } |
32 | 32 |
|0130 ;Audio { wave 2 envelope 2 pad 4 volume 1 pitch 1 play 1 value 2 delay 2 finish 1 } |
33 |
-|0140 ;Controller { vector 2 button 1 } |
|
34 |
-|0150 ;Keys { vector 2 key 1 } |
|
33 |
+|0140 ;Controller { vector 2 button 1 key 1 } |
|
35 | 34 |
|0160 ;Mouse { vector 2 x 2 y 2 state 1 chord 1 } |
36 | 35 |
|0170 ;File { pad 8 name 2 length 2 load 2 save 2 } |
37 | 36 |
|
... | ... |
@@ -42,7 +41,7 @@ |
42 | 41 |
( theme ) #e0fa =System.r #30fa =System.g #30fa =System.b |
43 | 42 |
( vectors ) ,on-screen =Screen.vector |
44 | 43 |
( vectors ) ,on-mouse =Mouse.vector |
45 |
- ( vectors ) ,on-key =Keys.vector |
|
44 |
+ ( vectors ) ,on-button =Controller.vector |
|
46 | 45 |
|
47 | 46 |
~Screen.width #0002 DIV2 DUP2 #0080 SUB2 =trkframe.x1 |
48 | 47 |
#0080 ADD2 =trkframe.x2 |
... | ... |
@@ -96,9 +95,9 @@ BRK |
96 | 95 |
|
97 | 96 |
BRK |
98 | 97 |
|
99 |
-@on-key ( -> ) |
|
98 |
+@on-button ( -> ) |
|
100 | 99 |
|
101 |
- ~Keys.key |
|
100 |
+ ~Controller.key |
|
102 | 101 |
DUP #61 NEQ ^$no-c JNZ |
103 | 102 |
,notes PEK2 ,play JSR2 $no-c |
104 | 103 |
DUP #73 NEQ ^$no-d JNZ |
105 | 104 |
similarity index 93% |
106 | 105 |
rename from projects/examples/dev.controller.usm |
107 | 106 |
rename to projects/examples/dev.controller.buttons.usm |
... | ... |
@@ -12,7 +12,7 @@ |
12 | 12 |
|
13 | 13 |
|0100 ;System { vector 2 pad 6 r 2 g 2 b 2 } |
14 | 14 |
|0120 ;Screen { vector 2 width 2 height 2 pad 2 x 2 y 2 addr 2 color 1 } |
15 |
-|0140 ;Controller { vector 2 p1 1 } |
|
15 |
+|0140 ;Controller { vector 2 button 1 key 1 } |
|
16 | 16 |
|
17 | 17 |
|0200 |
18 | 18 |
|
... | ... |
@@ -35,7 +35,7 @@ BRK |
35 | 35 |
|
36 | 36 |
( hold ctrl key to change slime color ) |
37 | 37 |
|
38 |
- ~Controller.p1 #0f AND |
|
38 |
+ ~Controller.button #0f AND |
|
39 | 39 |
DUP #01 NEQ ^$no-ctrl JNZ #25 =slime $no-ctrl |
40 | 40 |
DUP #02 NEQ ^$no-alt JNZ #2f =slime $no-alt |
41 | 41 |
POP |
... | ... |
@@ -43,7 +43,7 @@ BRK |
43 | 43 |
( clear ) #30 =Screen.color |
44 | 44 |
|
45 | 45 |
( detect movement ) |
46 |
- ~Controller.p1 #f0 AND |
|
46 |
+ ~Controller.button #f0 AND |
|
47 | 47 |
DUP #04 SFT #01 AND #01 NEQ ^$no-up JNZ |
48 | 48 |
( move ) ~Screen.y -- =Screen.y ,up_icn =Screen.addr $no-up |
49 | 49 |
DUP #05 SFT #01 AND #01 NEQ ^$no-down JNZ |
50 | 50 |
similarity index 90% |
51 | 51 |
rename from projects/examples/dev.keys.usm |
52 | 52 |
rename to projects/examples/dev.controller.keys.usm |
... | ... |
@@ -5,43 +5,40 @@ |
5 | 5 |
%8* { #0030 SFT2 } |
6 | 6 |
|
7 | 7 |
|0100 ;System { vector 2 pad 6 r 2 g 2 b 2 } |
8 |
+|0110 ;Console { vector 2 pad 6 char 1 byte 1 short 2 } |
|
8 | 9 |
|0120 ;Screen { vector 2 pad 6 x 2 y 2 addr 2 color 1 } |
9 |
-|0140 ;Controller { vector 2 button 1 } |
|
10 |
-|0150 ;Keys { vector 2 key 1 } |
|
10 |
+|0140 ;Controller { vector 2 button 1 key 1 } |
|
11 | 11 |
|
12 | 12 |
( program ) |
13 | 13 |
|
14 | 14 |
|0200 |
15 | 15 |
|
16 | 16 |
( theme ) #0f73 =System.r #0fe3 =System.g #0fc3 =System.b |
17 |
- ( vectors ) ,KEY =Keys.vector |
|
18 |
- ( vectors ) ,BUTTON =Controller.vector |
|
17 |
+ ( vectors ) ,on-button =Controller.vector |
|
19 | 18 |
,draw-cursor JSR2 |
20 | 19 |
|
21 | 20 |
BRK |
22 | 21 |
|
23 |
-@KEY |
|
22 |
+@on-button |
|
24 | 23 |
|
25 |
- ,cursor_icn =Screen.addr |
|
26 |
- ,font #00 ~Keys.key 8* ADD2 =Screen.addr |
|
27 |
- ( draw ) #21 =Screen.color |
|
28 |
- ~Screen.x 8+ =Screen.x |
|
29 |
- ( release ) #00 =Keys.key |
|
30 |
- ,draw-cursor JSR2 |
|
24 |
+ ~Controller.key #00 NEQ ^$skip JNZ BRK $skip |
|
31 | 25 |
|
32 |
-BRK |
|
33 |
- |
|
34 |
-@BUTTON |
|
35 |
- |
|
36 |
- ( enter key ) |
|
37 |
- ~Controller.button #08 NEQ ^$no-return JNZ |
|
26 |
+ ~Controller.key #0d NEQ ^$no-return JNZ |
|
38 | 27 |
#20 =Screen.color |
39 | 28 |
#0000 =Screen.x |
40 | 29 |
( incr ) ~Screen.y 8+ =Screen.y |
41 |
- ( release ) #00 =Controller.button |
|
42 | 30 |
,draw-cursor JSR2 |
31 |
+ BRK |
|
43 | 32 |
$no-return |
44 | 33 |
|
34 |
+ ~Controller.key =Console.char |
|
35 |
+ |
|
36 |
+ ,cursor_icn =Screen.addr |
|
37 |
+ ,font #00 ~Controller.key 8* ADD2 =Screen.addr |
|
38 |
+ ( draw ) #21 =Screen.color |
|
39 |
+ ~Screen.x 8+ =Screen.x |
|
40 |
+ ,draw-cursor JSR2 |
|
41 |
+ |
|
45 | 42 |
BRK |
46 | 43 |
|
47 | 44 |
@draw-cursor |
... | ... |
@@ -1,7 +1,6 @@ |
1 | 1 |
( GUI Hover ) |
2 | 2 |
|
3 | 3 |
%RTN { JMP2r } |
4 |
-%RTN? { #00 EQU #02 JNZ STH2r JMP2 } |
|
5 | 4 |
|
6 | 5 |
;color { byte 1 } |
7 | 6 |
;pointer { x 2 y 2 sprite 2 } |
... | ... |
@@ -11,10 +10,7 @@ |
11 | 10 |
;r3 { x1 2 y1 2 x2 2 y2 2 } |
12 | 11 |
|
13 | 12 |
|0100 ;System { vector 2 pad 6 r 2 g 2 b 2 } |
14 |
-|0110 ;Console { pad 8 char 1 byte 1 short 2 } |
|
15 | 13 |
|0120 ;Screen { vector 2 width 2 height 2 pad 2 x 2 y 2 addr 2 color 1 } |
16 |
-|0140 ;Controller { vector 2 button 1 } |
|
17 |
-|0150 ;Keys { vector 2 key 1 } |
|
18 | 14 |
|0160 ;Mouse { vector 2 x 2 y 2 state 1 chord 1 } |
19 | 15 |
|
20 | 16 |
( program ) |
... | ... |
@@ -6,18 +6,20 @@ |
6 | 6 |
;center { x 2 y 2 } |
7 | 7 |
|
8 | 8 |
|0100 ;System { vector 2 pad 6 r 2 g 2 b 2 } |
9 |
-|0110 ;Console { pad 8 char 1 byte 1 short 2 } |
|
10 | 9 |
|0120 ;Screen { vector 2 width 2 height 2 pad 2 x 2 y 2 addr 2 color 1 } |
11 |
-|0140 ;Controller { vector 2 button 1 } |
|
12 |
-|0150 ;Keys { vector 2 key 1 } |
|
13 |
-|0160 ;Mouse { vector 2 x 2 y 2 state 1 chord 1 } |
|
14 | 10 |
|
15 | 11 |
( program ) |
16 | 12 |
|
17 |
-|0200 @RESET |
|
13 |
+|0200 |
|
18 | 14 |
|
19 | 15 |
( theme ) #0f0f =System.r #0fff =System.g #0ff0 =System.b |
20 | 16 |
|
17 |
+ ,draw JSR2 |
|
18 |
+ |
|
19 |
+BRK |
|
20 |
+ |
|
21 |
+@draw ( -- ) |
|
22 |
+ |
|
21 | 23 |
( find screen center ) |
22 | 24 |
~Screen.width #0002 DIV2 =center.x |
23 | 25 |
~Screen.height #0002 DIV2 =center.y |
... | ... |
@@ -34,10 +36,10 @@ |
34 | 36 |
~center.x ~center.y #0010 ADD2 #2c ,text3 ,draw-label-right JSR2 |
35 | 37 |
~center.x ~center.y #0020 ADD2 #2c ,text4 ,draw-label-middle JSR2 |
36 | 38 |
~center.x ~center.y #0030 ADD2 #2c ,text5 ,draw-label-middle JSR2 |
37 |
- |
|
38 |
-BRK |
|
39 | 39 |
|
40 |
-@draw-label-left ( x y color addr ) |
|
40 |
+RTN |
|
41 |
+ |
|
42 |
+@draw-label-left ( x y color addr -- ) |
|
41 | 43 |
|
42 | 44 |
( load ) =label.addr =label.color =Screen.y =Screen.x |
43 | 45 |
~label.addr |
... | ... |
@@ -50,7 +52,7 @@ BRK |
50 | 52 |
|
51 | 53 |
RTN |
52 | 54 |
|
53 |
-@draw-label-middle ( x y color addr ) |
|
55 |
+@draw-label-middle ( x y color addr -- ) |
|
54 | 56 |
|
55 | 57 |
( load ) =label.addr =label.color =Screen.y |
56 | 58 |
( align ) ~label.addr ,get-text-length JSR2 #0008 MUL2 #0002 DIV2 SUB2 =Screen.x |
... | ... |
@@ -64,7 +66,7 @@ RTN |
64 | 66 |
|
65 | 67 |
RTN |
66 | 68 |
|
67 |
-@draw-label-right ( x y color addr ) |
|
69 |
+@draw-label-right ( x y color addr -- ) |
|
68 | 70 |
|
69 | 71 |
( load ) =label.addr =label.color =Screen.y |
70 | 72 |
( align ) ~label.addr ,get-text-length JSR2 #0008 MUL2 SUB2 #0008 SUB2 =Screen.x |
... | ... |
@@ -78,7 +80,7 @@ RTN |
78 | 80 |
|
79 | 81 |
RTN |
80 | 82 |
|
81 |
-@get-text-length ( label ) |
|
83 |
+@get-text-length ( label* -- length ) |
|
82 | 84 |
|
83 | 85 |
#0000 ( counter ) |
84 | 86 |
$loop |
... | ... |
@@ -6,10 +6,7 @@ |
6 | 6 |
;pict { x 2 y 2 width 2 height 2 color 1 addr 2 } |
7 | 7 |
|
8 | 8 |
|0100 ;System { vector 2 pad 6 r 2 g 2 b 2 } |
9 |
-|0110 ;Console { pad 8 char 1 byte 1 short 2 } |
|
10 | 9 |
|0120 ;Screen { vector 2 width 2 height 2 pad 2 x 2 y 2 addr 2 color 1 } |
11 |
-|0140 ;Controller { vector 2 button 1 } |
|
12 |
-|0150 ;Keys { vector 2 key 1 } |
|
13 | 10 |
|0160 ;Mouse { vector 2 x 2 y 2 state 1 chord 1 } |
14 | 11 |
|0170 ;File { pad 8 name 2 length 2 load 2 save 2 } |
15 | 12 |
|
... | ... |
@@ -13,11 +13,7 @@ |
13 | 13 |
;circle { xc 2 yc 2 x 2 y 2 r 2 d 2 } |
14 | 14 |
|
15 | 15 |
|0100 ;System { vector 2 pad 6 r 2 g 2 b 2 } |
16 |
-|0110 ;Console { pad 8 char 1 byte 1 short 2 } |
|
17 | 16 |
|0120 ;Screen { vector 2 width 2 height 2 pad 2 x 2 y 2 addr 2 color 1 } |
18 |
-|0140 ;Controller { vector 2 button 1 } |
|
19 |
-|0150 ;Keys { vector 2 key 1 } |
|
20 |
-|0160 ;Mouse { vector 2 x 2 y 2 state 1 chord 1 } |
|
21 | 17 |
|
22 | 18 |
( program ) |
23 | 19 |
|
... | ... |
@@ -34,18 +34,16 @@ |
34 | 34 |
|0100 ;System { vector 2 pad 6 r 2 g 2 b 2 } |
35 | 35 |
|0110 ;Console { pad 8 char 1 byte 1 short 2 } |
36 | 36 |
|0120 ;Screen { vector 2 width 2 height 2 pad 2 x 2 y 2 addr 2 color 1 } |
37 |
-|0140 ;Controller { vector 2 button 1 } |
|
38 |
-|0150 ;Keys { vector 2 key 1 } |
|
37 |
+|0140 ;Controller { vector 2 button 1 key 1 } |
|
39 | 38 |
|0160 ;Mouse { vector 2 x 2 y 2 state 1 chord 1 } |
40 | 39 |
|0170 ;File { pad 8 name 2 length 2 load 2 save 2 } |
41 | 40 |
|
42 | 41 |
( program ) |
43 | 42 |
|
44 |
-|0200 @RESET |
|
43 |
+|0200 |
|
45 | 44 |
|
46 | 45 |
( theme ) #e0fc =System.r #30cc =System.g #30ac =System.b |
47 | 46 |
( vectors ) ,on-button =Controller.vector |
48 |
- ( vectors ) ,on-key =Keys.vector |
|
49 | 47 |
( vectors ) ,on-mouse =Mouse.vector |
50 | 48 |
|
51 | 49 |
~Screen.width 2/ #008a SUB2 =bankview.x |
... | ... |
@@ -56,23 +54,13 @@ |
56 | 54 |
~Screen.height 2/ #003f SUB2 =tileview.y |
57 | 55 |
,bank #0448 ADD2 =tileview.addr |
58 | 56 |
|
59 |
- ,filepath ,load-file JSR2 |
|
57 |
+ ,filepath1 =File.name #0800 =File.length ,bank =File.load |
|
58 |
+ ,filepath2 =File.name #0800 =File.length ,bank #0800 ADD2 =File.load |
|
60 | 59 |
|
61 | 60 |
,redraw JSR2 |
62 | 61 |
|
63 | 62 |
BRK |
64 | 63 |
|
65 |
-@on-key |
|
66 |
- |
|
67 |
- ~Keys.key #31 LTH ^$skip JNZ |
|
68 |
- ~Keys.key #33 GTH ^$skip JNZ |
|
69 |
- ( select ) ~Keys.key #31 SUB =bankview.mode |
|
70 |
- ( release ) #00 =Keys.key |
|
71 |
- ,redraw JSR2 |
|
72 |
- $skip |
|
73 |
- |
|
74 |
-BRK |
|
75 |
- |
|
76 | 64 |
@on-button |
77 | 65 |
|
78 | 66 |
~Controller.button |
... | ... |
@@ -86,6 +74,11 @@ BRK |
86 | 74 |
~tileview.addr 8- =tileview.addr $no-ctrl-right |
87 | 75 |
POP |
88 | 76 |
~tileview.addr #0800 DIV2 #0800 MUL2 =bankview.addr |
77 |
+ |
|
78 |
+ ~Controller.key #31 LTH ^$skip JNZ |
|
79 |
+ ~Controller.key #33 GTH ^$skip JNZ |
|
80 |
+ ( select ) ~Controller.key #31 SUB =bankview.mode |
|
81 |
+ $skip |
|
89 | 82 |
,redraw JSR2 |
90 | 83 |
|
91 | 84 |
BRK |
... | ... |
@@ -105,12 +98,12 @@ BRK |
105 | 98 |
,redraw JSR2 ,$click-end JMP2 |
106 | 99 |
$no-brush-click |
107 | 100 |
~Mouse.x ~tileview.x SUB2 8/ #000e NEQ2 ^$no-load-click JNZ |
108 |
- ( load ) ,filepath =File.name #0800 =File.length ~bankview.addr =File.load |
|
101 |
+ ( load ) ,filepath1 =File.name #0800 =File.length ~bankview.addr =File.load |
|
109 | 102 |
( release ) #00 =Mouse.state |
110 | 103 |
,redraw JSR2 ,$click-end JMP2 |
111 | 104 |
$no-load-click |
112 | 105 |
~Mouse.x ~tileview.x SUB2 8/ #000f NEQ2 ^$no-save-click JNZ |
113 |
- ( save ) ,filepath =File.name #0800 =File.length ~bankview.addr =File.save |
|
106 |
+ ( save ) ,filepath1 =File.name #0800 =File.length ~bankview.addr =File.save |
|
114 | 107 |
( release ) #00 =Mouse.state |
115 | 108 |
,redraw JSR2 ,$click-end JMP2 |
116 | 109 |
$no-save-click |
... | ... |
@@ -206,12 +199,6 @@ BRK |
206 | 199 |
|
207 | 200 |
BRK |
208 | 201 |
|
209 |
-@load-file ( path ) |
|
210 |
- |
|
211 |
- =File.name #0800 =File.length ,bank =File.load |
|
212 |
- |
|
213 |
-RTN |
|
214 |
- |
|
215 | 202 |
@op_shiftup |
216 | 203 |
|
217 | 204 |
~tileview.addr PEK2 |
... | ... |
@@ -505,7 +492,8 @@ RTN |
505 | 492 |
@save_icn [ fe82 8282 848a f400 ] |
506 | 493 |
@moveup_icn [ 0010 387c fe10 1000 ] |
507 | 494 |
@movedown_icn [ 0010 1010 fe7c 3810 ] |
508 |
-@filepath [ projects/fonts/specter8.bit 00 ] |
|
495 |
+@filepath1 [ projects/fonts/specter8.bit 00 ] |
|
496 |
+@filepath2 [ projects/pictures/cibo.bit 00 ] |
|
509 | 497 |
|
510 | 498 |
@font_hex ( 0-F ) |
511 | 499 |
[ |
... | ... |
@@ -52,10 +52,9 @@ |
52 | 52 |
( devices ) |
53 | 53 |
|
54 | 54 |
|0100 ;System { vector 2 pad 6 r 2 g 2 b 2 } |
55 |
-|0110 ;Console { pad 8 char 1 byte 1 short 2 } |
|
55 |
+|0110 ;Console { pad 8 char 1 byte 1 short 2 string 2 } |
|
56 | 56 |
|0120 ;Screen { vector 2 width 2 height 2 pad 2 x 2 y 2 addr 2 color 1 } |
57 |
-|0140 ;Controller { vector 2 button 1 } |
|
58 |
-|0150 ;Keys { vector 2 key 1 } |
|
57 |
+|0140 ;Controller { vector 2 button 1 key 1 } |
|
59 | 58 |
|0160 ;Mouse { vector 2 x 2 y 2 state 1 chord 1 } |
60 | 59 |
|0170 ;File { pad 8 name 2 length 2 load 2 save 2 } |
61 | 60 |
|
... | ... |
@@ -67,7 +66,6 @@ |
67 | 66 |
#e0fa =theme.r0 #30fa =theme.g0 #30fa =theme.b0 ( normal mode ) |
68 | 67 |
#00fe =theme.r1 #00f3 =theme.g1 #00f3 =theme.b1 ( presentation mode ) |
69 | 68 |
( vectors ) ,on-screen =Screen.vector |
70 |
- ( vectors ) ,on-key =Keys.vector |
|
71 | 69 |
( vectors ) ,on-button =Controller.vector |
72 | 70 |
( vectors ) ,on-mouse =Mouse.vector |
73 | 71 |
|
... | ... |
@@ -283,55 +281,49 @@ BRK |
283 | 281 |
|
284 | 282 |
BRK |
285 | 283 |
|
286 |
-@on-button |
|
287 |
- |
|
284 |
+@on-button ( -> ) |
|
285 |
+ |
|
288 | 286 |
( if in renaming mode ) |
289 | 287 |
~document.edit #01 NEQ ,$no-edit JNZ2 |
288 |
+ ~Controller.key #00 EQU ,$no-edit JNZ2 |
|
290 | 289 |
( enter ) |
291 |
- ~Controller.button #08 NEQ ^$no-edit-enter JNZ |
|
290 |
+ ~Controller.key #0d NEQ ^$no-edit-enter JNZ |
|
292 | 291 |
#00 =document.edit |
293 | 292 |
,redraw JSR2 |
294 | 293 |
BRK |
295 | 294 |
$no-edit-enter |
296 | 295 |
( backspace ) |
297 |
- ~Controller.button #04 NEQ ^$no-edit-backspace JNZ |
|
296 |
+ ~Controller.key #08 NEQ ^$no-edit-backspace JNZ |
|
298 | 297 |
~path.length #00 EQU ^$edit-end JNZ |
299 | 298 |
~path.length #01 SUB =path.length |
300 | 299 |
#00 ,path.name #00 ~path.length ADD2 POK2 |
301 | 300 |
BRK |
302 | 301 |
$no-edit-backspace |
303 |
- $edit-end |
|
304 |
- BRK |
|
305 |
- $no-edit |
|
306 |
- |
|
307 |
- ~Controller.button #f0 AND |
|
308 |
- DUP #04 SFT #01 AND #01 NEQ ^$no-up JNZ |
|
309 |
- ( move ) ~zoom.y -- =zoom.y $no-up |
|
310 |
- DUP #05 SFT #01 AND #01 NEQ ^$no-down JNZ |
|
311 |
- ( move ) ~zoom.y ++ =zoom.y $no-down |
|
312 |
- DUP #06 SFT #01 AND #01 NEQ ^$no-left JNZ |
|
313 |
- ( move ) ~zoom.x -- =zoom.x $no-left |
|
314 |
- DUP #07 SFT #01 AND #01 NEQ ^$no-right JNZ |
|
315 |
- ( move ) ~zoom.x ++ =zoom.x $no-right |
|
316 |
- #00 EQU #04 JNZ ,draw-canvas JSR2 |
|
317 |
- |
|
318 |
-BRK |
|
319 |
- |
|
320 |
-@on-key |
|
321 |
- |
|
322 |
- ( if in renaming mode ) |
|
323 |
- ~document.edit #01 NEQ ,$no-edit JNZ2 |
|
324 | 302 |
( default ) |
325 | 303 |
~path.length #1f EQU ^$edit-end JNZ |
326 |
- ~Keys.key ,path.name #00 ~path.length ADD2 POK2 |
|
304 |
+ ~Controller.key ,path.name #00 ~path.length ADD2 POK2 |
|
327 | 305 |
~path.length #01 ADD =path.length |
328 |
- $edit-end |
|
306 |
+ ~Controller.key =Console.byte |
|
307 |
+ $edit-end |
|
329 | 308 |
#00 ,path.name #00 ~path.length ADD2 POK2 |
330 |
- ( release ) #00 =Keys.key |
|
331 | 309 |
BRK |
332 | 310 |
$no-edit |
333 |
- |
|
334 |
- ~Keys.key |
|
311 |
+ |
|
312 |
+ ( control zoom ) |
|
313 |
+ ~zoom.active #00 EQU ^$skip-zoom JNZ |
|
314 |
+ ~Controller.button #f0 AND |
|
315 |
+ DUP #04 SFT #01 AND #01 NEQ ^$no-up JNZ |
|
316 |
+ ( move ) ~zoom.y -- =zoom.y $no-up |
|
317 |
+ DUP #05 SFT #01 AND #01 NEQ ^$no-down JNZ |
|
318 |
+ ( move ) ~zoom.y ++ =zoom.y $no-down |
|
319 |
+ DUP #06 SFT #01 AND #01 NEQ ^$no-left JNZ |
|
320 |
+ ( move ) ~zoom.x -- =zoom.x $no-left |
|
321 |
+ DUP #07 SFT #01 AND #01 NEQ ^$no-right JNZ |
|
322 |
+ ( move ) ~zoom.x ++ =zoom.x $no-right |
|
323 |
+ #00 EQU #04 JNZ ,draw-canvas JSR2 |
|
324 |
+ $skip-zoom |
|
325 |
+ |
|
326 |
+ ~Controller.key |
|
335 | 327 |
DUP #20 NEQ ^$no-space JNZ |
336 | 328 |
( toggle zoom ) ~zoom.active #00 EQU =zoom.active ,redraw JSR2 $no-space |
337 | 329 |
DUP #08 NEQ ^$no-backspace JNZ |
... | ... |
@@ -348,9 +340,8 @@ BRK |
348 | 340 |
( tool0 ) #04 =brush.tool ,draw-toolpane JSR2 $no-tkey |
349 | 341 |
DUP |
350 | 342 |
DUP #30 GTH SWP #39 LTH #0101 NEQ2 ^$no-numkey JNZ |
351 |
- ( size ) ~Keys.key #31 SUB =brush.size ,draw-sizepane JSR2 $no-numkey |
|
343 |
+ ( size ) ~Controller.key #31 SUB =brush.size ,draw-sizepane JSR2 $no-numkey |
|
352 | 344 |
POP |
353 |
- ( release ) #00 =Keys.key |
|
354 | 345 |
|
355 | 346 |
BRK |
356 | 347 |
|
... | ... |
@@ -45,15 +45,13 @@ |
45 | 45 |
|0100 ;System { vector 2 pad 6 r 2 g 2 b 2 } |
46 | 46 |
|0110 ;Console { pad 8 char 1 byte 1 short 2 } |
47 | 47 |
|0120 ;Screen { vector 2 width 2 height 2 pad 2 x 2 y 2 addr 2 color 1 } |
48 |
-|0140 ;Controller { vector 2 button 1 } |
|
49 |
-|0150 ;Keys { vector 2 key 1 } |
|
48 |
+|0140 ;Controller { vector 2 button 1 key 1 } |
|
50 | 49 |
|0160 ;Mouse { vector 2 x 2 y 2 state 1 chord 1 } |
51 | 50 |
|
52 | 51 |
|0200 |
53 | 52 |
|
54 | 53 |
( theme ) #08f3 =System.r #08fc =System.g #08f9 =System.b |
55 | 54 |
( vectors ) ,on-button =Controller.vector |
56 |
- ( vectors ) ,on-key =Keys.vector |
|
57 | 55 |
( vectors ) ,on-mouse =Mouse.vector |
58 | 56 |
( vectors ) ,on-frame =Screen.vector |
59 | 57 |
|
... | ... |
@@ -82,20 +80,14 @@ BRK |
82 | 80 |
|
83 | 81 |
BRK |
84 | 82 |
|
85 |
-@on-key |
|
86 |
- |
|
87 |
- ( skip ) ~Keys.key #00 NEQ ^$continue JNZ BRK $continue |
|
88 |
- |
|
89 |
- ~selection.x1 ~selection.y1 ~Keys.key SET-CELL |
|
90 |
- |
|
91 |
- ( release ) #00 =Keys.key |
|
92 |
- |
|
93 |
- ,redraw JSR2 |
|
94 |
- |
|
95 |
-BRK |
|
96 |
- |
|
97 | 83 |
@on-button |
98 | 84 |
|
85 |
+ ~Controller.key #00 EQU ^$no-key JNZ |
|
86 |
+ ~selection.x1 ~selection.y1 ~Controller.key SET-CELL |
|
87 |
+ ~Controller.key =Console.byte |
|
88 |
+ ,redraw JSR2 |
|
89 |
+ $no-key |
|
90 |
+ |
|
99 | 91 |
( arrows ) |
100 | 92 |
~Controller.button #f0 AND |
101 | 93 |
DUP #04 SFT #01 AND #01 NEQ ^$no-up JNZ |
... | ... |
@@ -23,7 +23,7 @@ static SDL_Renderer *gRenderer; |
23 | 23 |
static SDL_Texture *gTexture; |
24 | 24 |
static Ppu ppu; |
25 | 25 |
static Apu apu; |
26 |
-static Device *devsystem, *devscreen, *devmouse, *devkey, *devctrl, *devapu; |
|
26 |
+static Device *devsystem, *devscreen, *devmouse, *devctrl, *devapu; |
|
27 | 27 |
|
28 | 28 |
Uint8 zoom = 0, debug = 0, reqdraw = 0; |
29 | 29 |
|
... | ... |
@@ -151,26 +151,10 @@ domouse(Uxn *u, SDL_Event *event) |
151 | 151 |
} |
152 | 152 |
} |
153 | 153 |
|
154 |
-void |
|
155 |
-dotext(Uxn *u, SDL_Event *event) |
|
156 |
-{ |
|
157 |
- int i; |
|
158 |
- Uint16 addr = devkey->addr + 2; |
|
159 |
- if(SDL_GetModState() & KMOD_LCTRL || SDL_GetModState() & KMOD_RCTRL) |
|
160 |
- return; |
|
161 |
- for(i = 0; i < SDL_TEXTINPUTEVENT_TEXT_SIZE; ++i) { |
|
162 |
- char c = event->text.text[i]; |
|
163 |
- if(c < ' ' || c > '~') |
|
164 |
- break; |
|
165 |
- u->ram.dat[addr] = c; |
|
166 |
- } |
|
167 |
-} |
|
168 |
- |
|
169 | 154 |
void |
170 | 155 |
doctrl(Uxn *u, SDL_Event *event, int z) |
171 | 156 |
{ |
172 | 157 |
Uint8 flag = 0x00; |
173 |
- Uint16 addr = devctrl->addr + 2; |
|
174 | 158 |
if(z && event->key.keysym.sym == SDLK_h) { |
175 | 159 |
if(SDL_GetModState() & KMOD_LCTRL) |
176 | 160 |
toggledebug(u); |
... | ... |
@@ -180,17 +164,19 @@ doctrl(Uxn *u, SDL_Event *event, int z) |
180 | 164 |
switch(event->key.keysym.sym) { |
181 | 165 |
case SDLK_LCTRL: flag = 0x01; break; |
182 | 166 |
case SDLK_LALT: flag = 0x02; break; |
183 |
- case SDLK_BACKSPACE: flag = 0x04; break; |
|
184 |
- case SDLK_RETURN: flag = 0x08; break; |
|
167 |
+ case SDLK_ESCAPE: flag = 0x04; break; |
|
168 |
+ case SDLK_LSHIFT: flag = 0x08; break; |
|
185 | 169 |
case SDLK_UP: flag = 0x10; break; |
186 | 170 |
case SDLK_DOWN: flag = 0x20; break; |
187 | 171 |
case SDLK_LEFT: flag = 0x40; break; |
188 | 172 |
case SDLK_RIGHT: flag = 0x80; break; |
189 | 173 |
} |
190 |
- if(z) |
|
191 |
- u->ram.dat[addr] |= flag; |
|
192 |
- else |
|
193 |
- u->ram.dat[addr] &= (~flag); |
|
174 |
+ if(flag && z) |
|
175 |
+ u->ram.dat[devctrl->addr + 2] |= flag; |
|
176 |
+ else if(flag) |
|
177 |
+ u->ram.dat[devctrl->addr + 2] &= (~flag); |
|
178 |
+ if(z && event->key.keysym.sym < 20) |
|
179 |
+ u->ram.dat[devctrl->addr + 3] = event->key.keysym.sym; |
|
194 | 180 |
} |
195 | 181 |
|
196 | 182 |
#pragma mark - Devices |
... | ... |
@@ -338,21 +324,20 @@ start(Uxn *u) |
338 | 324 |
case SDL_QUIT: |
339 | 325 |
quit(); |
340 | 326 |
break; |
327 |
+ case SDL_TEXTINPUT: |
|
328 |
+ if(event.text.text[0] >= ' ' || event.text.text[0] <= '~') |
|
329 |
+ u->ram.dat[devctrl->addr + 3] = event.text.text[0]; |
|
341 | 330 |
case SDL_KEYDOWN: |
342 | 331 |
case SDL_KEYUP: |
343 | 332 |
doctrl(u, &event, event.type == SDL_KEYDOWN); |
344 | 333 |
evaluxn(u, devctrl->vector); |
345 |
- break; |
|
334 |
+ u->ram.dat[devctrl->addr + 3] = 0; |
|
346 | 335 |
case SDL_MOUSEBUTTONUP: |
347 | 336 |
case SDL_MOUSEBUTTONDOWN: |
348 | 337 |
case SDL_MOUSEMOTION: |
349 | 338 |
domouse(u, &event); |
350 | 339 |
evaluxn(u, devmouse->vector); |
351 | 340 |
break; |
352 |
- case SDL_TEXTINPUT: |
|
353 |
- dotext(u, &event); |
|
354 |
- evaluxn(u, devkey->vector); |
|
355 |
- break; |
|
356 | 341 |
case SDL_WINDOWEVENT: |
357 | 342 |
if(event.window.event == SDL_WINDOWEVENT_EXPOSED) |
358 | 343 |
redraw(ppu.output, u); |
... | ... |
@@ -389,7 +374,7 @@ main(int argc, char **argv) |
389 | 374 |
devscreen = portuxn(&u, 0x02, "screen", screen_poke); |
390 | 375 |
devapu = portuxn(&u, 0x03, "audio", audio_poke); |
391 | 376 |
devctrl = portuxn(&u, 0x04, "controller", ppnil); |
392 |
- devkey = portuxn(&u, 0x05, "key", ppnil); |
|
377 |
+ portuxn(&u, 0x05, "---", ppnil); |
|
393 | 378 |
devmouse = portuxn(&u, 0x06, "mouse", ppnil); |
394 | 379 |
portuxn(&u, 0x07, "file", file_poke); |
395 | 380 |
portuxn(&u, 0x08, "---", ppnil); |