commit d6e707fd117068d7d5a25b0ef32255e8c847ba26
parent 09571b108423d6a747086002b72b575b8382ed43
Author: neauoire <aliceffekt@gmail.com>
Date: Wed, 7 Apr 2021 10:35:39 -0700
Progress on Orca
Diffstat:
1 file changed, 124 insertions(+), 8 deletions(-)
diff --git a/projects/software/orca.usm b/projects/software/orca.usm
@@ -1,13 +1,28 @@
-( Orca )
+( Orca
+
+ TODO
+ - Clamp selection to grid
+ - Chorded copy/paste
+ - Locking ports
+ - Detect capitalization
+ - Fill grid with . characters on start
+ - Display guides
+ - Draw Frame number in UI
+ - Comments
+ - Load/Save
+ - Copy/Paste
+)
%RTN { JMP2r }
%8* { #0008 MUL2 } %8/ { #0008 DIV2 }
+%MOD { DUP2 DIV MUL SUB }
( variables )
;timer { byte 1 frame 1 }
;grid { width 1 height 1 }
;selection { x1 1 y1 1 x2 1 y2 1 }
+;cursor { x 2 y 2 }
( devices )
@@ -17,18 +32,23 @@
|0130 ;Sprite { vector 2 pad 6 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 }
|0200
( theme ) #0faf =System.r #0fff =System.g #0f5f =System.b
( vectors ) ,on-button =Controller.vector
( vectors ) ,on-key =Keys.vector
+ ( vectors ) ,on-mouse =Mouse.vector
( vectors ) ,on-frame =Screen.vector
( find size )
~Screen.width 8/ SWP POP =grid.width
~Screen.height 8/ SWP POP =grid.height
+ ( fill grid with dots )
+
+ ,start JSR2
,redraw JSR2
BRK
@@ -75,10 +95,59 @@ BRK
~selection.x1 #01 ADD =selection.x1
~selection.x2 #01 ADD =selection.x2 $no-right
POP
+
+ ~Controller.button #04 NEQ ^$no-backspace JNZ
+ ~Controller.button =Console.byte
+ ~selection.x1 ~selection.y1 #2e ,put-char JSR2 ( put . char )
+ $no-backspace
+
,redraw JSR2
BRK
+@on-mouse
+
+ ~Mouse.state #00 EQU ^$no-touch JNZ
+ ~Mouse.x 8/ SWP POP =selection.x1
+ ~Mouse.y 8/ SWP POP =selection.y1
+ ,redraw JSR2
+ $no-touch
+
+ ( clear last cursor )
+ ~cursor.x =Sprite.x
+ ~cursor.y =Sprite.y
+ ,blank_icn =Sprite.addr
+ #10 =Sprite.color
+
+ ( record cursor positions )
+ ~Mouse.x =cursor.x
+ ~Mouse.y =cursor.y
+
+ ( draw new cursor )
+ ~cursor.x =Sprite.x
+ ~cursor.y =Sprite.y
+ ,cursor_icn =Sprite.addr
+ #12 ~Mouse.state #01 EQU ADD =Sprite.color
+
+BRK
+
+@start ( -- )
+
+ #00 ~grid.height
+ $ver
+ #00 ~grid.width
+ $hor
+ ( get x,y ) SWP2 OVR STH SWP2 OVR STHr
+ #2e ,put-char JSR2
+ ( incr ) SWP #01 ADD SWP
+ DUP2 LTH ^$hor JNZ
+ POP2
+ ( incr ) SWP #01 ADD SWP
+ DUP2 LTH ^$ver JNZ
+ POP2
+
+RTN
+
@is-selected ( x y -- flag )
~selection.x1 ~selection.y1 EQU2
@@ -103,9 +172,21 @@ RTN
RTN
+@get-char-value ( char -- value )
+
+ #00 SWP ,values ADD2 PEK2
+
+RTN
+
+@get-value-char ( value -- char )
+
+ #00 SWP ,b36clc ADD2 PEK2
+
+RTN
+
@get-value ( x y -- value )
- POP2 #01
+ ,get-char JSR2 #20 SUB ,get-char-value JSR2
RTN
@@ -118,11 +199,12 @@ RTN
@op-a ( x y char -- )
POP
-
( get left ) DUP2 SWP #01 SUB SWP ,get-value JSR2 STH
( get right ) DUP2 SWP #01 ADD SWP ,get-value JSR2 STH
-
- #01 ADD ADDr STHr ( remove this extra addition -> ) #30 ADD ,put-char JSR2
+ ( incr y ) #01 ADD
+ ( get result ) ADDr STHr
+ ,get-value-char JSR2
+ ,put-char JSR2
RTN
@@ -136,7 +218,7 @@ RTN
POP
#01 ADD
- #30 ~timer.frame ADD ,put-char JSR2
+ #30 ~timer.frame #08 MOD ADD ,put-char JSR2
RTN
@@ -165,7 +247,6 @@ RTN
( incr ) SWP #01 ADD SWP
DUP2 LTH ^$ver JNZ
POP2
-
,redraw JSR2
RTN
@@ -190,7 +271,42 @@ RTN
RTN
-@blank_icn [ ffff ffff ffff ffff ]
+( char to b36 )
+
+@values [
+
+ 00 00 00 00 00 00 00 00
+ 00 00 00 00 00 00 00 00
+
+ 00 01 02 03 04 05 06 07
+ 08 09 00 00 00 00 00 00
+
+ 00 0a 0b 0c 0d 0e 0f 10
+ 11 12 13 14 15 16 17 18
+ 19 1a 1b 1c 1d 1e 1f 20
+ 21 22 23 00 00 00 00 00
+
+ 00 0a 0b 0c 0d 0e 0f 10
+ 11 12 13 14 15 16 17 18
+ 19 1a 1b 1c 1d 1e 1f 20
+ 21 22 23 00 00 00 00 00
+
+]
+
+( b36 to char-lc )
+
+@b36clc [
+
+ 30 31 32 33 34 35 36 37
+ 38 39 61 62 63 64 65 66
+ 67 68 69 6a 6b 6c 6d 6e
+ 6f 70 71 72 73 74 75 76
+ 77 78 79 7a
+
+]
+
+@cursor_icn [ 80c0 e0f0 f8e0 1000 ]
+@blank_icn [ 0000 0000 0000 0000 ]
@font ( specter8-frag font )
[