Browse code

Progress on Orca

neauoire authored on 07/04/2021 17:35:39
Showing 1 changed files
... ...
@@ -1,13 +1,28 @@
1
-( Orca )
1
+( Orca 
2
+	
3
+	TODO
4
+		- Clamp selection to grid
5
+		- Chorded copy/paste
6
+		- Locking ports
7
+		- Detect capitalization
8
+		- Fill grid with . characters on start
9
+		- Display guides
10
+		- Draw Frame number in UI
11
+		- Comments
12
+		- Load/Save
13
+		- Copy/Paste
14
+)
2 15
 
3 16
 %RTN { JMP2r }
4 17
 %8* { #0008 MUL2 } %8/ { #0008 DIV2 }
18
+%MOD { DUP2 DIV MUL SUB }
5 19
 
6 20
 ( variables )
7 21
 
8 22
 ;timer { byte 1 frame 1 }
9 23
 ;grid { width 1 height 1 }
10 24
 ;selection { x1 1 y1 1 x2 1 y2 1 }
25
+;cursor { x 2 y 2 }
11 26
 
12 27
 ( devices )
13 28
 
... ...
@@ -17,18 +32,23 @@
17 32
 |0130 ;Sprite { vector 2 pad 6 x 2 y 2 addr 2 color 1 }
18 33
 |0140 ;Controller { vector 2 button 1 }
19 34
 |0150 ;Keys { vector 2 key 1 }
35
+|0160 ;Mouse  { vector 2 x 2 y 2 state 1 chord 1 }
20 36
 
21 37
 |0200
22 38
 
23 39
 	( theme ) #0faf =System.r #0fff =System.g #0f5f =System.b
24 40
 	( vectors ) ,on-button =Controller.vector
25 41
 	( vectors ) ,on-key =Keys.vector
42
+	( vectors ) ,on-mouse =Mouse.vector
26 43
 	( vectors ) ,on-frame =Screen.vector
27 44
 
28 45
 	( find size )
29 46
 	~Screen.width 8/ SWP POP =grid.width
30 47
 	~Screen.height 8/ SWP POP =grid.height
31 48
 
49
+	( fill grid with dots )
50
+
51
+	,start JSR2
32 52
 	,redraw JSR2
33 53
 
34 54
 BRK
... ...
@@ -75,10 +95,59 @@ BRK
75 95
 			~selection.x1 #01 ADD =selection.x1 
76 96
 			~selection.x2 #01 ADD =selection.x2 $no-right
77 97
 	POP
98
+
99
+	~Controller.button #04 NEQ ^$no-backspace JNZ
100
+		~Controller.button =Console.byte
101
+		~selection.x1 ~selection.y1 #2e ,put-char JSR2 ( put . char )
102
+	$no-backspace
103
+
78 104
 	,redraw JSR2
79 105
 
80 106
 BRK
81 107
 
108
+@on-mouse
109
+	
110
+	~Mouse.state #00 EQU ^$no-touch JNZ
111
+		~Mouse.x 8/ SWP POP =selection.x1
112
+		~Mouse.y 8/ SWP POP =selection.y1
113
+		,redraw JSR2
114
+	$no-touch
115
+
116
+	( clear last cursor )
117
+	~cursor.x =Sprite.x
118
+	~cursor.y =Sprite.y
119
+	,blank_icn =Sprite.addr
120
+	#10 =Sprite.color
121
+
122
+	( record cursor positions )
123
+	~Mouse.x =cursor.x 
124
+	~Mouse.y =cursor.y
125
+
126
+	( draw new cursor )
127
+	~cursor.x =Sprite.x
128
+	~cursor.y =Sprite.y
129
+	,cursor_icn =Sprite.addr
130
+	#12 ~Mouse.state #01 EQU ADD =Sprite.color
131
+	
132
+BRK
133
+
134
+@start ( -- )
135
+	
136
+	#00 ~grid.height
137
+	$ver
138
+		#00 ~grid.width
139
+		$hor
140
+			( get x,y ) SWP2 OVR STH SWP2 OVR STHr 
141
+			#2e ,put-char JSR2
142
+			( incr )    SWP #01 ADD SWP
143
+			DUP2 LTH ^$hor JNZ
144
+		POP2
145
+		( incr ) SWP #01 ADD SWP
146
+		DUP2 LTH ^$ver JNZ
147
+	POP2
148
+
149
+RTN
150
+
82 151
 @is-selected ( x y -- flag )
83 152
 	
84 153
 	~selection.x1 ~selection.y1 EQU2
... ...
@@ -103,9 +172,21 @@ RTN
103 172
 
104 173
 RTN
105 174
 
175
+@get-char-value ( char -- value )
176
+	
177
+	#00 SWP ,values ADD2 PEK2
178
+
179
+RTN
180
+
181
+@get-value-char ( value -- char )
182
+	
183
+	#00 SWP ,b36clc ADD2 PEK2
184
+	
185
+RTN
186
+
106 187
 @get-value ( x y -- value )
107 188
 	
108
-	POP2 #01
189
+	,get-char JSR2 #20 SUB ,get-char-value JSR2
109 190
 
110 191
 RTN
111 192
 
... ...
@@ -118,11 +199,12 @@ RTN
118 199
 @op-a ( x y char -- )
119 200
 
120 201
 	POP
121
-
122 202
 	( get left ) DUP2 SWP #01 SUB SWP ,get-value JSR2 STH
123 203
 	( get right ) DUP2 SWP #01 ADD SWP ,get-value JSR2 STH
124
-
125
-	#01 ADD ADDr STHr ( remove this extra addition -> ) #30 ADD ,put-char JSR2
204
+	( incr y ) #01 ADD 
205
+	( get result ) ADDr STHr 
206
+	,get-value-char JSR2 
207
+	,put-char JSR2
126 208
 
127 209
 RTN
128 210
 
... ...
@@ -136,7 +218,7 @@ RTN
136 218
 	
137 219
 	POP
138 220
 	#01 ADD
139
-	#30 ~timer.frame ADD ,put-char JSR2
221
+	#30 ~timer.frame #08 MOD ADD ,put-char JSR2
140 222
 
141 223
 RTN
142 224
 
... ...
@@ -165,7 +247,6 @@ RTN
165 247
 		( incr ) SWP #01 ADD SWP
166 248
 		DUP2 LTH ^$ver JNZ
167 249
 	POP2
168
-
169 250
 	,redraw JSR2
170 251
 
171 252
 RTN
... ...
@@ -190,7 +271,42 @@ RTN
190 271
 
191 272
 RTN
192 273
 
193
-@blank_icn [ ffff ffff ffff ffff ]
274
+( char to b36 )
275
+
276
+@values [
277
+	
278
+	00 00 00 00 00 00 00 00 
279
+	00 00 00 00 00 00 00 00 
280
+
281
+	00 01 02 03 04 05 06 07
282
+	08 09 00 00 00 00 00 00
283
+
284
+	00 0a 0b 0c 0d 0e 0f 10 
285
+	11 12 13 14 15 16 17 18
286
+	19 1a 1b 1c 1d 1e 1f 20
287
+	21 22 23 00 00 00 00 00
288
+
289
+	00 0a 0b 0c 0d 0e 0f 10 
290
+	11 12 13 14 15 16 17 18
291
+	19 1a 1b 1c 1d 1e 1f 20
292
+	21 22 23 00 00 00 00 00
293
+
294
+]
295
+
296
+( b36 to char-lc )
297
+
298
+@b36clc [
299
+	
300
+	30 31 32 33 34 35 36 37
301
+	38 39 61 62 63 64 65 66
302
+	67 68 69 6a 6b 6c 6d 6e
303
+	6f 70 71 72 73 74 75 76
304
+	77 78 79 7a
305
+
306
+]
307
+
308
+@cursor_icn [ 80c0 e0f0 f8e0 1000 ]
309
+@blank_icn  [ 0000 0000 0000 0000 ]
194 310
 
195 311
 @font ( specter8-frag font ) 
196 312
 [