1 | 1 |
new file mode 100644 |
... | ... |
@@ -0,0 +1,166 @@ |
1 |
+( repl |
|
2 |
+ |
|
3 |
+ implemented: hardly anything |
|
4 |
+ |
|
5 |
+ yet to implement: practically everything |
|
6 |
+) |
|
7 |
+ |
|
8 |
+( devices ) |
|
9 |
+ |
|
10 |
+|00 @System &vector $2 &pad $6 &r $2 &g $2 &b $2 |
|
11 |
+|20 @Screen &vector $2 &width $2 &height $2 &pad $2 &x $2 &y $2 &addr $2 &color $1 |
|
12 |
+|a0 @File &vector $2 &success $2 &offset $2 &pad $2 &name $2 &length $2 &load $2 &save $2 |
|
13 |
+ |
|
14 |
+( variables ) |
|
15 |
+ |
|
16 |
+|0000 |
|
17 |
+ @font [ &height $1 &cells $1 ] |
|
18 |
+ |
|
19 |
+( init ) |
|
20 |
+ |
|
21 |
+|0100 ( -> ) |
|
22 |
+ |
|
23 |
+ ( theme ) |
|
24 |
+ #0fa7 .System/r DEO2 |
|
25 |
+ #0fa7 .System/g DEO2 |
|
26 |
+ #0fa7 .System/b DEO2 |
|
27 |
+ |
|
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 |
|
38 |
+ |
|
39 |
+ ;body ;write JSR2 POP2 |
|
40 |
+ #0000 .Screen/x DEO2 |
|
41 |
+ #00 .font/height LDZ .Screen/y DEO2 |
|
42 |
+ ;body ;write JSR2 POP2 |
|
43 |
+ BRK |
|
44 |
+ |
|
45 |
+@load-font ( filename* -- ) |
|
46 |
+ DUP2 .File/name DEO2 |
|
47 |
+ ( find end of string for suffix ) |
|
48 |
+ &loop |
|
49 |
+ #0001 ADD2 |
|
50 |
+ LDAk ,&loop JCN |
|
51 |
+ ( suffix is cell size ) |
|
52 |
+ #0001 SUB2 LDAk #0f AND .font/cells STZ |
|
53 |
+ ( search backwards for number ) |
|
54 |
+ &loop2 |
|
55 |
+ #0001 SUB2 |
|
56 |
+ LDAk DUP #2f GTH STH #3a LTH STHr #0101 NEQ2 ,&loop2 JCN |
|
57 |
+ ( parse number to find font height ) |
|
58 |
+ #0001 STH2 |
|
59 |
+ &loop3 |
|
60 |
+ LDAk DUPk #2f GTH STH #3a LTH STHr #0101 NEQ2 ,&end-loop3 JCN |
|
61 |
+ #30 SUB STHr MULk STH ADDr #0a MUL STH POP |
|
62 |
+ #0001 SUB2 |
|
63 |
+ ,&loop3 JMP |
|
64 |
+ &end-loop3 |
|
65 |
+ STH2r POP .font/height STZ |
|
66 |
+ POP |
|
67 |
+ POP2 |
|
68 |
+ |
|
69 |
+ .font/cells LDZ DUP MUL #08 MUL #01 ADD #00 .File/length DEO2 |
|
70 |
+ ;font-data .File/load DEO2 |
|
71 |
+ |
|
72 |
+ JMP2r |
|
73 |
+ |
|
74 |
+@get-word-width ( string* -- string* width* ) |
|
75 |
+ DUP2 LIT2r 0000 |
|
76 |
+ &loop |
|
77 |
+ LDAk DUP #20 GTH ,¬-end JCN |
|
78 |
+ POP |
|
79 |
+ POP2 STH2r |
|
80 |
+ JMP2r |
|
81 |
+ |
|
82 |
+ ¬-end |
|
83 |
+ #00 SWP ;font-data ADD2 LDA |
|
84 |
+ LITr 00 STH ADD2r |
|
85 |
+ #0001 ADD2 |
|
86 |
+ ,&loop JMP |
|
87 |
+ |
|
88 |
+@wrapped-write ( string* -- ) |
|
89 |
+ LDAk ,¬-end JCN |
|
90 |
+ POP2 |
|
91 |
+ JMP2r |
|
92 |
+ |
|
93 |
+ ¬-end |
|
94 |
+ ,get-word-width JSR .Screen/x DEI2 ADD2 .Screen/width DEI2 LTH2 ,&no-cr JCN |
|
95 |
+ ,cr JSR |
|
96 |
+ &no-cr |
|
97 |
+ ,write JSR |
|
98 |
+ ,wrapped-write JMP |
|
99 |
+ |
|
100 |
+@cr ( -- ) |
|
101 |
+ #0000 .Screen/x DEO2 |
|
102 |
+ .Screen/y DEI2 #00 .font/height LDZ ADD2 .Screen/y DEO2 |
|
103 |
+ JMP2r |
|
104 |
+ |
|
105 |
+@write ( string* -- end-of-string* ) |
|
106 |
+ LDAk DUP ,¬-end JCN |
|
107 |
+ POP |
|
108 |
+ JMP2r |
|
109 |
+ |
|
110 |
+ ¬-end |
|
111 |
+ #00 SWP #00 .font/cells LDZ MUL2k MUL2 #0008 MUL2 #0100 ADD2 ( string* char* tile* ) |
|
112 |
+ ;font-data ADD2 .Screen/addr DEO2 |
|
113 |
+ .font/cells LDZ |
|
114 |
+ &outer |
|
115 |
+ DUP #00 EQU ,&end-outer JCN |
|
116 |
+ .font/cells LDZ |
|
117 |
+ &inner |
|
118 |
+ DUP #00 EQU ,&end-inner JCN |
|
119 |
+ #21 .Screen/color DEO |
|
120 |
+ #0008 DUP2 |
|
121 |
+ .Screen/x DEI2 ADD2 .Screen/x DEO2 |
|
122 |
+ .Screen/addr DEI2 ADD2 .Screen/addr DEO2 |
|
123 |
+ #01 SUB |
|
124 |
+ ,&inner JMP |
|
125 |
+ &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 |
+ POP |
|
129 |
+ #01 SUB |
|
130 |
+ ,&outer JMP |
|
131 |
+ &end-outer |
|
132 |
+ #00 .font/cells LDZ #fff8 MUL2 .Screen/y DEI2 ADD2 .Screen/y DEO2 |
|
133 |
+ 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 |
|
138 |
+ JMP2r |
|
139 |
+ |
|
140 |
+@body |
|
141 |
+ 4927 6c6c 206d 616b 6520 6120 736f 756e |
|
142 |
+ 6420 7468 6174 2773 2073 6f20 616c 6f6e |
|
143 |
+ 6520 74 6861 7420 6e6f 206f 6e65 2063 |
|
144 |
+ 616e 206d 6973 7320 6974 2c20 7468 6174 |
|
145 |
+ 2077 686f 6576 6572 20 6865 6172 7320 |
|
146 |
+ 6974 2077 696c 6c20 7765 6570 2069 6e20 |
|
147 |
+ 7468 6569 7220 736f 756c 732c 20 616e |
|
148 |
+ 6420 6865 6172 7468 7320 7769 6c6c 2073 |
|
149 |
+ 6565 6d20 7761 726d 6572 2c20 61 6e64 |
|
150 |
+ 2062 6569 6e67 2069 6e73 6964 6520 7769 |
|
151 |
+ 6c6c 2073 6565 6d20 6265 7474 6572 20 |
|
152 |
+ 746f 2061 6c6c 2077 686f 2068 6561 7220 |
|
153 |
+ 6974 2069 6e20 7468 6520 6469 7374 616e |
|
154 |
+ 7420 746f 776e 732e 20 $1 |
|
155 |
+ |
|
156 |
+@font1 |
|
157 |
+ "projects/fonts/geneva24.uf3 $1 |
|
158 |
+@font2 |
|
159 |
+ "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 |
+ |
|
166 |
+@font-data |