Browse code

Fixed issue with controller.key

neauoire authored on 11/04/2021 03:55:31
Showing 5 changed files
... ...
@@ -32,7 +32,7 @@ else
32 32
 fi
33 33
 
34 34
 echo "Assembling.."
35
-./bin/assembler projects/examples/dev.controller.buttons.usm bin/boot.rom
35
+./bin/assembler projects/software/noodle.usm bin/boot.rom
36 36
 
37 37
 echo "Running.."
38 38
 if [ "${2}" = '--cli' ]; 
... ...
@@ -45,8 +45,7 @@
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
 |0170 ;File { pad 8 name 2 length 2 load 2 save 2 }
52 51
 
... ...
@@ -56,7 +55,6 @@
56 55
 	
57 56
 	( theme ) #e0fa =System.r #30fa =System.g #30fa =System.b
58 57
 	( vectors ) ,on-mouse =Mouse.vector
59
-	( vectors ) ,on-key =Keys.vector
60 58
 	( vectors ) ,on-button =Controller.vector
61 59
 
62 60
 	( load file )
... ...
@@ -70,38 +68,11 @@
70 68
 
71 69
 BRK
72 70
 
73
-@on-key
74
-
75
-	~Keys #08 NEQ ^$no-backspace JNZ
76
-		( erase )
77
-		~selection.to ~selection.from SUB2 #0001 NEQ2 ^$erase-multiple JNZ
78
-			~selection.to ~selection.from SUB2 ,shift-left JSR2
79
-			,$erase-end JMP2
80
-		$erase-multiple
81
-			~selection.from ++ =selection.from
82
-			~selection.to ~selection.from SUB2 ++ ,shift-left JSR2
83
-		$erase-end
84
-		~selection.from -- =selection.from
85
-		^$keys-end JMP
86
-	$no-backspace
87
-
88
-	( insert )
89
-	~selection.to ~selection.from SUB2 ,shift-right JSR2
90
-	~Keys ~selection.from POK2
91
-	~selection.from ++ =selection.from
92
-
93
-	$keys-end
94
-	~selection.from ++ =selection.to
95
-	( release ) #00 =Keys
96
-	,redraw JSR2
97
-
98
-BRK 
99
-
100 71
 @on-button ( -> )
101 72
 	
102 73
 	( alt + arrow )
103
-	~Controller #0f AND #02 NEQ ^$no-alt JNZ
104
-		~Controller #04 SFT 
74
+	~Controller.button #0f AND #02 NEQ ^$no-alt JNZ
75
+		~Controller.button #04 SFT 
105 76
 		DUP #01 NEQ ^$no-aup JNZ
106 77
 			( sel word ) ,find-wordstart JSR2 =selection.to $no-aup
107 78
 		DUP #02 NEQ ^$no-adown JNZ
... ...
@@ -117,8 +88,8 @@ BRK
117 88
 	$no-alt
118 89
 
119 90
 	( ctrl + arrow )
120
-	~Controller #0f AND #01 NEQ ^$no-ctrl JNZ
121
-		~Controller #04 SFT 
91
+	~Controller.button #0f AND #01 NEQ ^$no-ctrl JNZ
92
+		~Controller.button #04 SFT 
122 93
 		DUP #01 NEQ ^$no-cup JNZ
123 94
 			( jump scroll ) #0004 ,scroll-up JSR2 $no-cup
124 95
 		DUP #02 NEQ ^$no-cdown JNZ
... ...
@@ -133,8 +104,8 @@ BRK
133 104
 	$no-ctrl
134 105
 
135 106
 	( arrow )
136
-	~Controller #f0 AND #00 EQU ,$no-arrow JNZ2
137
-		~Controller #f0 AND
107
+	~Controller.button #f0 AND #00 EQU ,$no-arrow JNZ2
108
+		~Controller.button #f0 AND
138 109
 		DUP #10 NEQ ^$no-arrowup JNZ
139 110
 			( clamp ) ~position.y #0000 EQU2 ^$no-arrowup JNZ
140 111
 			,find-lineoffset JSR2 =position.x ~position.y -- =position.y 
... ...
@@ -156,6 +127,28 @@ BRK
156 127
 		,redraw JSR2 
157 128
 	$no-arrow
158 129
 
130
+	~Controller.key #08 NEQ ^$no-backspace JNZ
131
+		( erase )
132
+		~selection.to ~selection.from SUB2 #0001 NEQ2 ^$erase-multiple JNZ
133
+			~selection.to ~selection.from SUB2 ,shift-left JSR2
134
+			,$erase-end JMP2
135
+		$erase-multiple
136
+			~selection.from ++ =selection.from
137
+			~selection.to ~selection.from SUB2 ++ ,shift-left JSR2
138
+		$erase-end
139
+		~selection.from -- =selection.from
140
+		~selection.from ++ =selection.to
141
+		,redraw JSR2
142
+		BRK
143
+	$no-backspace
144
+
145
+	( insert )
146
+	~selection.to ~selection.from SUB2 ,shift-right JSR2
147
+	~Controller.key ~selection.from POK2
148
+	~selection.from ++ =selection.from
149
+	~selection.from ++ =selection.to
150
+	,redraw JSR2
151
+
159 152
 BRK
160 153
 
161 154
 @on-mouse ( -> )
... ...
@@ -199,7 +192,7 @@ BRK
199 192
 		BRK
200 193
 	$no-chords
201 194
 	( drag )
202
-	~Mouse.state ~touch.state NEQ ~Controller #0f AND #02 NEQ #0101 EQU2 ^$no-drag JNZ
195
+	~Mouse.state ~touch.state NEQ ~Controller.button #0f AND #02 NEQ #0101 EQU2 ^$no-drag JNZ
203 196
 		( on drag )
204 197
 		,find-selection JSR2 ++ =selection.to
205 198
 		,clamp-selection JSR2
... ...
@@ -303,7 +303,6 @@ BRK
303 303
 		~path.length #1f EQU ^$edit-end JNZ
304 304
 			~Controller.key ,path.name #00 ~path.length ADD2 POK2
305 305
 			~path.length #01 ADD =path.length
306
-			~Controller.key =Console.byte
307 306
 		$edit-end
308 307
 		#00 ,path.name #00 ~path.length ADD2 POK2
309 308
 		BRK
... ...
@@ -84,7 +84,6 @@ BRK
84 84
 	
85 85
 	~Controller.key #00 EQU ^$no-key JNZ
86 86
 		~selection.x1 ~selection.y1 ~Controller.key SET-CELL
87
-		~Controller.key =Console.byte
88 87
 		,redraw JSR2
89 88
 	$no-key
90 89
 
... ...
@@ -108,8 +107,7 @@ BRK
108 107
 			~selection.x2 #01 ADD =selection.x2 $no-right
109 108
 	POP
110 109
 
111
-	~Controller.button #04 NEQ ^$no-backspace JNZ
112
-		~Controller.button =Console.byte
110
+	~Controller.key #08 NEQ ^$no-backspace JNZ
113 111
 		~selection.x1 ~selection.y1 #2e SET-CELL ( put . char )
114 112
 	$no-backspace
115 113
 
... ...
@@ -164,8 +164,8 @@ doctrl(Uxn *u, SDL_Event *event, int z)
164 164
 	switch(event->key.keysym.sym) {
165 165
 	case SDLK_LCTRL: flag = 0x01; break;
166 166
 	case SDLK_LALT: flag = 0x02; break;
167
-	case SDLK_ESCAPE: flag = 0x04; break;
168
-	case SDLK_LSHIFT: flag = 0x08; break;
167
+	case SDLK_LSHIFT: flag = 0x04; break;
168
+	case SDLK_ESCAPE: flag = 0x08; break;
169 169
 	case SDLK_UP: flag = 0x10; break;
170 170
 	case SDLK_DOWN: flag = 0x20; break;
171 171
 	case SDLK_LEFT: flag = 0x40; break;
... ...
@@ -332,6 +332,7 @@ start(Uxn *u)
332 332
 				doctrl(u, &event, event.type == SDL_KEYDOWN);
333 333
 				evaluxn(u, devctrl->vector);
334 334
 				u->ram.dat[devctrl->addr + 3] = 0;
335
+				break;
335 336
 			case SDL_MOUSEBUTTONUP:
336 337
 			case SDL_MOUSEBUTTONDOWN:
337 338
 			case SDL_MOUSEMOTION: