Browse code

Font example

neauoire authored on 02/07/2021 17:57:50
Showing 9 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,206 @@
1
+( font )
2
+
3
+%+  { ADD } %-   { SUB }  %*  { MUL }  %/  { DIV }
4
+%<  { LTH } %>   { GTH }  %=  { EQU }  %!  { NEQ }
5
+%++ { ADD2 } %-- { SUB2 } %** { MUL2 } %// { DIV2 }
6
+%<< { LTH2 } %>> { GTH2 } %== { EQU2 } %!! { NEQ2 }
7
+
8
+%RTN { JMP2r }
9
+%TOS { #00 SWP }
10
+%INCR { SWP #01 ADD SWP }
11
+%GET-ITERATORS { SWP2k POP SWP POP }
12
+
13
+%DEBUG  { ;print-hex JSR2 #0a .Console/write DEO }
14
+%DEBUG2 { SWP ;print-hex JSR2 ;print-hex JSR2 #0a .Console/write DEO }
15
+
16
+( devices )
17
+
18
+|00 @System     [ &vector $2 &pad    $6 &r      $2 &g     $2 &b      $2 ]
19
+|10 @Console    [ &vector $2 &read     $1 &pad    $5 &write $1 ]
20
+|20 @Screen     [ &vector $2 &width  $2 &height $2 &pad   $2 &x      $2 &y $2 &addr $2 &color $1 ]
21
+|80 @Controller [ &vector $2 &button $1 &key    $1 ]
22
+|a0 @File       [ &vector $2 &success $2 &offset $2 &pad $2 &name $2 &length $2 &load $2 &save $2 ]
23
+
24
+( variables )
25
+
26
+|0000
27
+
28
+@position
29
+	&x $2
30
+	&y $2
31
+
32
+( init )
33
+
34
+|0100 ( -> )
35
+
36
+	( theme ) 
37
+	#0f73 .System/r DEO2 
38
+	#0fe3 .System/g DEO2 
39
+	#0fc3 .System/b DEO2
40
+
41
+	( load font )
42
+	#4000 .File/length DEO2
43
+	;fontpath .File/name DEO2
44
+	;font-data .File/load DEO2
45
+
46
+	#0000 #0030 ;sometext #21 ;draw-uf3 JSR2
47
+	
48
+BRK
49
+
50
+@draw-uf3 ( x* y* text* color -- )
51
+		
52
+	STH 
53
+	STH2
54
+	.Screen/y DEO2
55
+	.Screen/x DEO2
56
+	STH2r
57
+	&loop
58
+		LDAk #0a ! ,&no-linebreak JCN
59
+			#0000 .Screen/x DEO2
60
+			.Screen/y DEI2 #0018 ++ .Screen/y DEO2
61
+		&no-linebreak
62
+		LDAk STHkr ;draw-letter3 JSR2
63
+		#0001 ++
64
+		LDAk ,&loop JCN
65
+	POP2
66
+	POPr
67
+
68
+RTN
69
+
70
+@draw-letter3 ( char color -- )
71
+	
72
+	POP 
73
+
74
+	DUP TOS #0048 ** ;font-data #0100 ++ ++ .Screen/addr DEO2
75
+
76
+	.Screen/x DEI2 .position/x STZ2
77
+	.Screen/y DEI2 .position/y STZ2
78
+
79
+	#00 #03
80
+	&ver
81
+		#00 #03
82
+		&hor
83
+			GET-ITERATORS
84
+			TOS #0008 ** .position/y LDZ2 ++ .Screen/y DEO2
85
+			TOS #0008 ** .position/x LDZ2 ++ .Screen/x DEO2
86
+			#21 .Screen/color DEO
87
+			.Screen/addr DEI2 #0008 ++ .Screen/addr DEO2
88
+			INCR
89
+			LTHk ,&hor JCN
90
+		POP2
91
+
92
+		INCR
93
+		LTHk ,&ver JCN
94
+	POP2
95
+
96
+	TOS ;font-data ++ LDA TOS .position/x LDZ2 ++ .Screen/x DEO2
97
+
98
+	.position/y LDZ2 .Screen/y DEO2
99
+
100
+RTN
101
+
102
+@draw-label ( x* y* text* color -- )
103
+		
104
+	STH 
105
+	STH2
106
+	.Screen/y DEO2
107
+	.Screen/x DEO2
108
+	STH2r
109
+	&loop
110
+		LDAk #0a ! ,&no-linebreak JCN
111
+			#0000 .Screen/x DEO2
112
+			.Screen/y DEI2 #0010 ++ .Screen/y DEO2
113
+
114
+		&no-linebreak
115
+		LDAk STHkr ;draw-letter JSR2
116
+		#0001 ++
117
+		LDAk ,&loop JCN
118
+	POP2
119
+	POPr
120
+
121
+RTN
122
+
123
+@draw-letter ( char color -- )
124
+
125
+	STH
126
+
127
+	STHk TOS #0020 ** ;font-data #0100 ++ ++ .Screen/addr DEO2
128
+	OVRr STHr .Screen/color DEO
129
+
130
+	.Screen/y DEI2 #0008 ++ .Screen/y DEO2
131
+	.Screen/addr DEI2 #0010 ++ .Screen/addr DEO2
132
+	OVRr STHr .Screen/color DEO
133
+
134
+	.Screen/x DEI2 #0008 ++ .Screen/x DEO2
135
+	.Screen/addr DEI2 #0008 ++ .Screen/addr DEO2
136
+	OVRr STHr .Screen/color DEO
137
+
138
+	.Screen/y DEI2 #0008 -- .Screen/y DEO2
139
+	.Screen/addr DEI2 #0010 -- .Screen/addr DEO2
140
+	OVRr STHr .Screen/color DEO
141
+
142
+	STHkr TOS ;font-data ++ LDA TOS .Screen/x DEI2 ++ #0008 -- .Screen/x DEO2
143
+
144
+	POPr POPr
145
+
146
+RTN
147
+
148
+@draw-short ( short* color -- )
149
+
150
+	STH SWP 
151
+	DUP #04 SFT TOS #0008 ** ;font-hex ++ .Screen/addr DEO2
152
+	( draw ) STHkr .Screen/color DEO
153
+	#0f AND TOS #0008 ** ;font-hex ++ .Screen/addr DEO2
154
+	.Screen/x DEI2 #0008 ++ .Screen/x DEO2
155
+	( draw ) STHkr .Screen/color DEO
156
+	DUP #04 SFT TOS #0008 ** ;font-hex ++ .Screen/addr DEO2
157
+	.Screen/x DEI2 #0008 ++ .Screen/x DEO2
158
+	( draw ) STHkr .Screen/color DEO
159
+	#0f AND TOS #0008 ** ;font-hex ++ .Screen/addr DEO2
160
+	.Screen/x DEI2 #0008 ++ .Screen/x DEO2
161
+	( draw ) STHr .Screen/color DEO
162
+
163
+RTN
164
+
165
+@print-hex ( value -- )
166
+	
167
+	STHk #04 SFT ,&parse JSR .Console/write DEO
168
+	STHr #0f AND ,&parse JSR .Console/write DEO
169
+	RTN
170
+	&parse ( value -- char )
171
+		DUP #09 GTH ,&above JCN #30 ADD RTN &above #09 SUB #60 ADD RTN
172
+
173
+RTN
174
+
175
+@cursor 
176
+	ffff ffff ffff ffff
177
+
178
+@font-hex 
179
+	003c 464a 5262 3c00 0018 0808 0808 1c00
180
+	003c 4202 3c40 7e00 003c 421c 0242 3c00
181
+	000c 1424 447e 0400 007e 407c 0242 3c00
182
+	003c 407c 4242 3c00 007e 0204 0810 1000
183
+	003c 423c 4242 3c00 003c 4242 3e02 3c00
184
+	003c 4242 7e42 4200 007c 427c 4242 7c00
185
+	003c 4240 4042 3c00 007c 4242 4242 7c00
186
+	007e 4078 4040 7e00 007e 4078 4040 4000 
187
+
188
+@sometext 
189
+	4927 6c6c 206d 616b 6520 6120 736f 756e
190
+	6420 7468 6174 2773 2073 6f20 616c 6f6e
191
+	6520 0a74 6861 7420 6e6f 206f 6e65 2063
192
+	616e 206d 6973 7320 6974 2c20 7468 6174
193
+	2077 686f 6576 6572 200a 6865 6172 7320
194
+	6974 2077 696c 6c20 7765 6570 2069 6e20
195
+	7468 6569 7220 736f 756c 732c 200a 616e
196
+	6420 6865 6172 7468 7320 7769 6c6c 2073
197
+	6565 6d20 7761 726d 6572 2c20 0a61 6e64
198
+	2062 6569 6e67 2069 6e73 6964 6520 7769
199
+	6c6c 2073 6565 6d20 6265 7474 6572 200a
200
+	746f 2061 6c6c 2077 686f 2068 6561 7220
201
+	6974 2069 6e20 7468 6520 6469 7374 616e
202
+	7420 746f 776e 732e 20 $1
203
+
204
+@fontpath "projects/fonts/newyork18.uf3
205
+
206
+@font-data
0 207
\ No newline at end of file
1 208
new file mode 100644
2 209
Binary files /dev/null and b/projects/fonts/chicago12.uf2 differ
3 210
new file mode 100644
4 211
Binary files /dev/null and b/projects/fonts/courier12.uf2 differ
5 212
new file mode 100644
6 213
Binary files /dev/null and b/projects/fonts/geneva12.uf2 differ
7 214
new file mode 100644
8 215
Binary files /dev/null and b/projects/fonts/helvetica12.uf2 differ
9 216
new file mode 100644
10 217
Binary files /dev/null and b/projects/fonts/newyork18.uf3 differ
11 218
new file mode 100644
12 219
Binary files /dev/null and b/projects/fonts/palatino12.uf2 differ
13 220
new file mode 100644
14 221
Binary files /dev/null and b/projects/fonts/times12.uf2 differ
15 222
new file mode 100644
16 223
Binary files /dev/null and b/projects/fonts/venice14.uf3 differ