Browse code

Repaired dev.keys example

neauoire authored on 22/03/2021 19:33:15
Showing 4 changed files
... ...
@@ -61,8 +61,8 @@ RTN
61 61
 @text1 [ Welcome 20 to 20 UxnVM 0a00 ]
62 62
 @text2 [ Hello 20 World 0a00 ] 
63 63
 
64
-|c000 @FRAME
65
-|d000 @ERROR 
64
+@FRAME BRK
65
+@ERROR BRK 
66 66
 ```
67 67
 
68 68
 ## TODOs
... ...
@@ -32,6 +32,5 @@ RTN
32 32
 @text1 [ Welcome 20 to 20 UxnVM 0a00 ]
33 33
 @text2 [ Hello 20 World 0a00 ] 
34 34
 
35
-|c000 @FRAME
36
-|d000 @ERROR 
37
-
35
+@FRAME BRK
36
+@ERROR BRK 
38 37
\ No newline at end of file
... ...
@@ -1,175 +1,35 @@
1 1
 ( Keys )
2 2
 
3
-;mouse { x 2 y 2 }
4
-;textarea { x1 2 y1 2 x2 2 y2 2 color 1 addr 2 cursor 1 }
5
-;rect { x1 2 y1 2 x2 2 y2 2 }
6
-;color { byte 1 }
7
-;blink { byte 1 } 
8
-;timer { byte 1 }
3
+%8+  { #0008 ADD2 }
4
+%8*  { #0030 SFT2 }
9 5
 
10
-|0100 @RESET 
11
-	
12
-	#0080 =textarea.x1 #0060 =textarea.y1 #00c0 =textarea.x2 #0090 =textarea.y2 ,body =textarea.addr
13
-	,redraw JSR2
14
-	,redraw-window JSR2
15
-
16
-BRK
17
-
18
-|0200 @FRAME
19
-
20
-	,do-cursor JSR2
21
-	,do-textarea JSR2
22
-
23
-BRK
24
-
25
-@redraw-window
26
-	
27
-	#0000 #0000 ~Screen.width ~Screen.height #01 ,pattern ,tile-rect JSR2
28
-	( dropshadow )
29
-	~textarea.x2 #0001 ADD2 ~textarea.y1 ~textarea.x2 #0004 ADD2 ~textarea.y2 #0004 ADD2 #01 ,fill-rect JSR2
30
-	~textarea.x1 ~textarea.y2 #0001 ADD2 ~textarea.x2 #0001 ADD2 ~textarea.y2 #0004 ADD2 #01 ,fill-rect JSR2
31
-	~textarea.x1 #0001 SUB2 ~textarea.y1 #0001 SUB2 ~textarea.x2 ~textarea.y2 #00 ,line-rect JSR2
32
-	~textarea.x1 #0002 SUB2 ~textarea.y1 #0002 SUB2 ~textarea.x2 #0001 ADD2 ~textarea.y2 #0001 ADD2 #01 ,line-rect JSR2
33
-
34
-RTN
35
-
36
-@redraw
37
-		
38
-	~textarea.x1 ~textarea.y1 ~textarea.x2 ~textarea.y2 #01 ,fill-rect JSR2
39
-	~textarea.x1 ~textarea.y1 #04 ~textarea.addr ,draw-textarea JSR2
40
-	
41
-RTN
42
-
43
-@blink-cursor
44
-	
45
-	,skip ~timer #10 LTH JMP2?
46
-		#00 =timer
47
-		~blink #00 EQU =blink
48
-		,cursor =Sprite.addr
49
-		#05 ~blink ADD =Sprite.color
50
-	@skip 
51
-	~timer #01 ADD =timer
52
-
53
-RTN
54
-
55
-@tile-rect ( x1 y1 x2 y2 color addr )
56
-
57
-	=Sprite.addr =color =rect.y2 =rect.x2 DUP2 =Sprite.y =rect.y1 DUP2 =Sprite.x =rect.x1
58
-
59
-	$ver
60
-		~rect.x1 =Sprite.x
61
-		$hor
62
-			( draw ) ~color =Sprite.color
63
-			( incr ) ~Sprite.x #0008 ADD2 =Sprite.x
64
-			,$hor ~Sprite.x ~rect.x2 LTH2 JMP2?
65
-		( incr ) ~Sprite.y #0008 ADD2 =Sprite.y
66
-		,$ver ~Sprite.y ~rect.y2 LTH2 JMP2?
67
-
68
-RTN
6
+|0100 ;Console { pad 8 char 1 byte 1 short 2 }
7
+|0110 ;Screen { width 2 height 2 pad 4 y 2 x 2 color 1 }
8
+|0120 ;Sprite { pad 8 x 2 y 2 addr 2 color 1 }
9
+|0130 ;Controller { buttons 1 }
10
+|0140 ;Keys { key 1 }
11
+|01F0 .RESET .FRAME .ERROR ( vectors )
12
+|01F8 [ 0daf 02ff 035f ] ( palette )
69 13
 
70
-@fill-rect ( x1 y1 x2 y2 color )
14
+|0200 @RESET BRK
71 15
 
72
-	( load ) =color =rect.y2 =rect.x2 DUP2 =Screen.y =rect.y1 DUP2 =Screen.x =rect.x1
73
-	$ver
74
-		~rect.x1 =Screen.x
75
-		$hor
76
-			( draw ) ~color =Screen.color
77
-			( incr ) ~Screen.x #0001 ADD2 =Screen.x
78
-			,$hor ~Screen.x ~rect.x2 LTH2 JMP2?
79
-		( incr ) ~Screen.y #0001 ADD2 =Screen.y
80
-		,$ver ~Screen.y ~rect.y2 LTH2 JMP2?
81
-
82
-RTN
83
-
84
-@line-rect ( x1 y1 x2 y2 color )
85
-
86
-	( load ) =color =rect.y2 =rect.x2 DUP2 =Screen.y =rect.y1 DUP2 =Screen.x =rect.x1
87
-	$hor
88
-		( incr ) ~Screen.x #0001 ADD2 =Screen.x
89
-		( draw ) ~rect.y1 =Screen.y ~color =Screen.color
90
-		( draw ) ~rect.y2 =Screen.y ~color =Screen.color
91
-		,$hor ~Screen.x ~rect.x2 LTH2 JMP2?
92
-	~rect.y1 =Screen.y
93
-	$ver
94
-		( draw ) ~rect.x1 =Screen.x ~color =Screen.color
95
-		( draw ) ~rect.x2 =Screen.x ~color =Screen.color
96
-		( incr ) ~Screen.y #0001 ADD2 =Screen.y
97
-		,$ver ~Screen.y ~rect.y2 #0001 ADD2 LTH2 JMP2?
98
-
99
-RTN
100
-
101
-@draw-textarea ( x y color addr )
16
+@FRAME
102 17
 	
103
-	( load ) =textarea.addr =textarea.color =Sprite.y =Sprite.x 
104
-	~textarea.addr
105
-	$loop
106
-		( draw ) DUP2 LDR #00 SWP #0008 MUL2 ,font ADD2 =Sprite.addr ~textarea.color =Sprite.color
107
-		( detect linebreaks )
108
-		DUP2 LDR #0d NEQ ,$no-return ROT JMP2?
109
-			~textarea.x1 =Sprite.x 
110
-			( incr ) ~Sprite.y #0008 ADD2 =Sprite.y
111
-			( decr ) ~Sprite.x #0008 SUB2 =Sprite.x
112
-		$no-return
113
-		( incr ) #0001 ADD2
114
-		( incr ) ~Sprite.x #0008 ADD2 =Sprite.x
115
-		DUP2 LDR #00 NEQ ,$loop ROT JMP2?
116
-	POP2
117
-
118
-RTN
119
-
120
-@do-textarea
121
-
122
-	( ,blink-cursor JSR2 )
123
-	,do-textarea-end ~Keys #00 EQU JMP2? ( skip on no key )
124
-	( backspace )
125
-	,any-key ~Keys #08 NEQ JMP2?
126
-		,input-end ~textarea.cursor #00 EQU JMP2?
127
-			( decr ) ~textarea.cursor #01 SUB =textarea.cursor
128
-			#00 ~textarea.addr #00 ~textarea.cursor ADD2 STR
129
-			,input-end JMP2
130
-	@any-key
131
-	~Keys ~textarea.addr #00 ~textarea.cursor ADD2 STR
132
-	( incr ) ~textarea.cursor #01 ADD =textarea.cursor
133
-	@input-end
134
-	#00 =Keys ( release key )
135
-	,redraw JSR2
136
-	( add cursor )
137
-	,cursor =Sprite.addr
138
-	#06 =Sprite.color
139
-	@do-textarea-end
140
-
141
-RTN
142
-
143
-@do-cursor
18
+	~Keys #00 EQU BRK?
144 19
 
145
-	,skip-drag ~Mouse.state #01 NEQ JMP2?
146
-		~mouse.x =textarea.x1 ~mouse.y =textarea.y1 
147
-		,redraw-window JSR2
148
-		,redraw JSR2
149
-	@skip-drag 
20
+	,$no-return ~Keys #0d NEQ JMP2?
21
+		#0000 =Sprite.x
22
+		( incr ) ~Sprite.y 8+ =Sprite.y
23
+		( release ) #00 =Keys
24
+		BRK
25
+	$no-return
150 26
 
151
-	~mouse.x ~Mouse.x NEQU2
152
-	~mouse.y ~Mouse.y NEQU2
27
+	,font #00 ~Keys 8* ADD2 =Sprite.addr
28
+	( draw ) #01 =Sprite.color
29
+	( incr ) ~Sprite.x 8+ =Sprite.x
30
+	( release ) #00 =Keys
153 31
 
154
-	#0000 EQU2 RTN? ( Return if unchanged )
155
-
156
-	( clear last cursor )
157
-	#10 ,clear_icn ~mouse.x ~mouse.y ,draw-sprite JSR2
158
-	( record mouse positions )
159
-	~Mouse.x =mouse.x ~Mouse.y =mouse.y
160
-	#12 ,cursor_icn ~mouse.x ~mouse.y ,draw-sprite JSR2
161
-
162
-
163
-RTN
164
-
165
-@draw-sprite
166
-
167
-	=Sprite.y
168
-	=Sprite.x
169
-	=Sprite.addr
170
-	=Sprite.color
171
-
172
-RTN
32
+BRK
173 33
 
174 34
 @font ( spectrum-zx font ) 
175 35
 [
... ...
@@ -207,18 +67,6 @@ RTN
207 67
 	0008 0808 0808 0800 0030 1008 0810 3000 0000 0032 4c00 0000 3c42 99a1 a199 423c
208 68
 ]
209 69
 
210
-@clear_icn   [ 0000 0000 0000 0000 ]
211
-@cursor_icn  [ 80c0 e0f0 f8e0 1000 ]
212
-@pattern     [ aa55 aa55 aa55 aa55 ]
213
-@cursor      [ 7e7e 7e7e 7e7e 7e7e ]
214
-@body        [ ]
215
-
216
-|d000 @ERROR BRK 
217
-
218
-|FF10 ;Screen { width 2 height 2 pad 4 x 2 y 2 color 1 }
219
-|FF20 ;Sprite { pad 8 x 2 y 2 addr 2 color 1 }
220
-|FF40 ;Keys   { key 1 }
221
-|FF50 ;Mouse  { x 2 y 2 state 1 chord 1 }
70
+;text { body 512 }
222 71
 
223
-|FFF0 .RESET .FRAME .ERROR ( vectors )
224
-|FFF8 [ f0ff f000 f00f ] ( palette )
72
+@ERROR BRK 
... ...
@@ -695,7 +695,6 @@ RTN
695 695
 	0000 7e02 3c40 7e00 000c 0810 1008 0c00
696 696
 	0008 0808 0808 0800 0030 1008 0810 3000
697 697
 	0000 0032 4c00 0000 3c42 99a1 a199 423c
698
-
699 698
 ]
700 699
 
701 700
 @mouse00icn  [ 0000 0000 0000 0000 ]