| ... | ... |
@@ -9,37 +9,83 @@ |
| 9 | 9 |
|
| 10 | 10 |
|00 @System &vector $2 &pad $6 &r $2 &g $2 &b $2 |
| 11 | 11 |
|20 @Screen &vector $2 &width $2 &height $2 &pad $2 &x $2 &y $2 &addr $2 &color $1 |
| 12 |
+|80 @Controller [ &vector $2 &button $1 &key $1 ] |
|
| 12 | 13 |
|a0 @File &vector $2 &success $2 &offset $2 &pad $2 &name $2 &length $2 &load $2 &save $2 |
| 13 | 14 |
|
| 14 |
-( variables ) |
|
| 15 |
- |
|
| 16 |
-|0000 |
|
| 17 |
- @font [ &height $1 &cells $1 ] |
|
| 18 |
- |
|
| 19 | 15 |
( init ) |
| 20 | 16 |
|
| 21 | 17 |
|0100 ( -> ) |
| 18 |
+@user-program |
|
| 19 |
+ ;init ;repl/fn STA2 |
|
| 20 |
+ #2000 JMP2 |
|
| 21 |
+ &erase-end |
|
| 22 |
+ |
|
| 23 |
+|2000 ( -> ) |
|
| 24 |
+ &end |
|
| 25 |
+ ,repl/fn LDR2 JSR2 |
|
| 26 |
+ BRK |
|
| 27 |
+ |
|
| 28 |
+@repl [ &fn $2 &font-height $1 &font-cells $1 ] |
|
| 29 |
+@buffer [ &cursor $2 &end $2 ] |
|
| 22 | 30 |
|
| 31 |
+@init |
|
| 23 | 32 |
( theme ) |
| 24 | 33 |
#0fa7 .System/r DEO2 |
| 25 | 34 |
#0fa7 .System/g DEO2 |
| 26 | 35 |
#0fa7 .System/b DEO2 |
| 27 | 36 |
|
| 28 |
- ;font1 ;load-font JSR2 |
|
| 29 |
- ;body ;wrapped-write JSR2 |
|
| 30 |
- ;cr JSR2 |
|
| 31 |
- ;font2 ;load-font JSR2 |
|
| 32 |
- ;body ;wrapped-write JSR2 |
|
| 33 |
- ;cr JSR2 |
|
| 34 |
- ;font3 ;load-font JSR2 |
|
| 35 |
- ;body ;wrapped-write JSR2 |
|
| 36 |
- ;cr JSR2 |
|
| 37 |
- BRK |
|
| 37 |
+ ( vectors ) |
|
| 38 |
+ #2000 .Screen/vector DEO2 |
|
| 39 |
+ ;on-key .Controller/vector DEO2 |
|
| 38 | 40 |
|
| 39 |
- ;body ;write JSR2 POP2 |
|
| 40 |
- #0000 .Screen/x DEO2 |
|
| 41 |
- #00 .font/height LDZ .Screen/y DEO2 |
|
| 42 |
- ;body ;write JSR2 POP2 |
|
| 41 |
+ ( default function ) |
|
| 42 |
+ ;main ,repl/fn STR2 |
|
| 43 |
+ |
|
| 44 |
+ ( buffer ) |
|
| 45 |
+ ;ring-buffer |
|
| 46 |
+ DUP2 ,buffer/cursor STR2 |
|
| 47 |
+ ,buffer/end STR2 |
|
| 48 |
+ |
|
| 49 |
+ ( clear out user-program ) |
|
| 50 |
+ ;user-program/erase-end ;user-program |
|
| 51 |
+ &clear-loop |
|
| 52 |
+ #0000 OVR2 STA2 |
|
| 53 |
+ #0002 ADD2 |
|
| 54 |
+ GTH2k ,&clear-loop JCN |
|
| 55 |
+ POP2 POP2 |
|
| 56 |
+ |
|
| 57 |
+ ( load font ) |
|
| 58 |
+ ;font ;load-font JMP2 ( tail call ) |
|
| 59 |
+ |
|
| 60 |
+@main ( -- ) |
|
| 61 |
+ JMP2r |
|
| 62 |
+ |
|
| 63 |
+@on-key ( -> ) |
|
| 64 |
+ .Controller/button DEI #01 AND ,&skip JCN |
|
| 65 |
+ .Controller/key DEI |
|
| 66 |
+ DUP #e0 AND ,&append JCN |
|
| 67 |
+ DUP #08 EQU ,&backspace JCN |
|
| 68 |
+ DUP #0d EQU ,&execute JCN |
|
| 69 |
+ POP &skip BRK |
|
| 70 |
+ |
|
| 71 |
+ &append |
|
| 72 |
+ ;buffer/cursor LDA2 |
|
| 73 |
+ STH2k STA |
|
| 74 |
+ STH2r #0001 ADD2 ;ring-buffer ORA2 ;buffer/cursor STA2 |
|
| 75 |
+ ,&draw JMP |
|
| 76 |
+ |
|
| 77 |
+ &backspace |
|
| 78 |
+ &execute |
|
| 79 |
+ DUP EOR |
|
| 80 |
+ ;buffer/cursor LDA2 |
|
| 81 |
+ #0001 SUB2 ;ring-buffer ORA2 DUP2 ;buffer/cursor STA2 |
|
| 82 |
+ STA |
|
| 83 |
+ |
|
| 84 |
+ &draw |
|
| 85 |
+ #0000 DUP2 .Screen/x DEO2 .Screen/y DEO2 |
|
| 86 |
+ ;ring-buffer ;wrapped-write JSR2 |
|
| 87 |
+ |
|
| 88 |
+ #20 ;draw-glyph JSR2 |
|
| 43 | 89 |
BRK |
| 44 | 90 |
|
| 45 | 91 |
@load-font ( filename* -- ) |
| ... | ... |
@@ -49,7 +95,7 @@ |
| 49 | 95 |
#0001 ADD2 |
| 50 | 96 |
LDAk ,&loop JCN |
| 51 | 97 |
( suffix is cell size ) |
| 52 |
- #0001 SUB2 LDAk #0f AND .font/cells STZ |
|
| 98 |
+ #0001 SUB2 LDAk #0f AND ;repl/font-cells STA |
|
| 53 | 99 |
( search backwards for number ) |
| 54 | 100 |
&loop2 |
| 55 | 101 |
#0001 SUB2 |
| ... | ... |
@@ -62,11 +108,11 @@ |
| 62 | 108 |
#0001 SUB2 |
| 63 | 109 |
,&loop3 JMP |
| 64 | 110 |
&end-loop3 |
| 65 |
- STH2r POP .font/height STZ |
|
| 111 |
+ STH2r POP ;repl/font-height STA |
|
| 66 | 112 |
POP |
| 67 | 113 |
POP2 |
| 68 | 114 |
|
| 69 |
- .font/cells LDZ DUP MUL #08 MUL #01 ADD #00 .File/length DEO2 |
|
| 115 |
+ ;repl/font-cells LDA DUP MUL #08 MUL #01 ADD #00 .File/length DEO2 |
|
| 70 | 116 |
;font-data .File/load DEO2 |
| 71 | 117 |
|
| 72 | 118 |
JMP2r |
| ... | ... |
@@ -99,7 +145,7 @@ |
| 99 | 145 |
|
| 100 | 146 |
@cr ( -- ) |
| 101 | 147 |
#0000 .Screen/x DEO2 |
| 102 |
- .Screen/y DEI2 #00 .font/height LDZ ADD2 .Screen/y DEO2 |
|
| 148 |
+ .Screen/y DEI2 #00 ;repl/font-height LDA ADD2 .Screen/y DEO2 |
|
| 103 | 149 |
JMP2r |
| 104 | 150 |
|
| 105 | 151 |
@write ( string* -- end-of-string* ) |
| ... | ... |
@@ -108,33 +154,39 @@ |
| 108 | 154 |
JMP2r |
| 109 | 155 |
|
| 110 | 156 |
¬-end |
| 111 |
- #00 SWP #00 .font/cells LDZ MUL2k MUL2 #0008 MUL2 #0100 ADD2 ( string* char* tile* ) |
|
| 157 |
+ #00 SWP #00 ;repl/font-cells LDA MUL2k MUL2 #0008 MUL2 #0100 ADD2 ( string* char* tile* ) |
|
| 112 | 158 |
;font-data ADD2 .Screen/addr DEO2 |
| 113 |
- .font/cells LDZ |
|
| 159 |
+ #2d ,draw-glyph JSR |
|
| 160 |
+ #00 ;repl/font-cells LDA #fff8 MUL2 .Screen/y DEI2 ADD2 .Screen/y DEO2 |
|
| 161 |
+ ;font-data ADD2 LDA #00 SWP .Screen/x DEI2 ADD2 .Screen/x DEO2 |
|
| 162 |
+ LDAk STH |
|
| 163 |
+ #0001 ADD2 |
|
| 164 |
+ STHr #20 GTH ;write JCN2 |
|
| 165 |
+ JMP2r |
|
| 166 |
+ |
|
| 167 |
+@draw-glyph ( color -- ) |
|
| 168 |
+ STH |
|
| 169 |
+ ;repl/font-cells LDA |
|
| 114 | 170 |
&outer |
| 115 | 171 |
DUP #00 EQU ,&end-outer JCN |
| 116 |
- .font/cells LDZ |
|
| 172 |
+ ;repl/font-cells LDA |
|
| 117 | 173 |
&inner |
| 118 | 174 |
DUP #00 EQU ,&end-inner JCN |
| 119 |
- #21 .Screen/color DEO |
|
| 175 |
+ STHkr .Screen/color DEO |
|
| 120 | 176 |
#0008 DUP2 |
| 121 | 177 |
.Screen/x DEI2 ADD2 .Screen/x DEO2 |
| 122 | 178 |
.Screen/addr DEI2 ADD2 .Screen/addr DEO2 |
| 123 | 179 |
#01 SUB |
| 124 | 180 |
,&inner JMP |
| 125 | 181 |
&end-inner |
| 126 |
- #00 .font/cells LDZ #fff8 MUL2 .Screen/x DEI2 ADD2 .Screen/x DEO2 |
|
| 127 |
- #0008 .Screen/y DEI2 ADD2 .Screen/y DEO2 |
|
| 128 | 182 |
POP |
| 183 |
+ #00 ;repl/font-cells LDA #fff8 MUL2 .Screen/x DEI2 ADD2 .Screen/x DEO2 |
|
| 184 |
+ #0008 .Screen/y DEI2 ADD2 .Screen/y DEO2 |
|
| 129 | 185 |
#01 SUB |
| 130 | 186 |
,&outer JMP |
| 131 | 187 |
&end-outer |
| 132 |
- #00 .font/cells LDZ #fff8 MUL2 .Screen/y DEI2 ADD2 .Screen/y DEO2 |
|
| 133 | 188 |
POP |
| 134 |
- ;font-data ADD2 LDA #00 SWP .Screen/x DEI2 ADD2 .Screen/x DEO2 |
|
| 135 |
- LDAk STH |
|
| 136 |
- #0001 ADD2 |
|
| 137 |
- STHr #20 GTH ;write JCN2 |
|
| 189 |
+ POPr |
|
| 138 | 190 |
JMP2r |
| 139 | 191 |
|
| 140 | 192 |
@body |
| ... | ... |
@@ -153,14 +205,10 @@ |
| 153 | 205 |
6974 2069 6e20 7468 6520 6469 7374 616e |
| 154 | 206 |
7420 746f 776e 732e 20 $1 |
| 155 | 207 |
|
| 156 |
-@font1 |
|
| 157 |
- "projects/fonts/geneva24.uf3 $1 |
|
| 158 |
-@font2 |
|
| 208 |
+@font |
|
| 159 | 209 |
"projects/fonts/venice14.uf2 $1 |
| 160 |
-@font3 |
|
| 161 |
- "projects/fonts/orca8.uf1 $1 |
|
| 162 |
- "projects/fonts/left8.uf1 $1 |
|
| 163 |
- "projects/fonts/specter8.uf1 $1 |
|
| 164 |
- "projects/fonts/atari8.uf1 $1 |
|
| 165 | 210 |
|
| 166 | 211 |
@font-data |
| 212 |
+ |
|
| 213 |
+|fe00 @ring-buffer |
|
| 214 |
+ |