Browse code

Cleaned up font example

neauoire authored on 03/07/2021 16:11:29
Showing 1 changed files
... ...
@@ -10,9 +10,6 @@
10 10
 %INCR { SWP #01 ADD SWP }
11 11
 %GET-ITERATORS { SWP2k POP SWP POP }
12 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 13
 ( devices )
17 14
 
18 15
 |00 @System     [ &vector $2 &pad    $6 &r      $2 &g     $2 &b      $2 ]
... ...
@@ -40,141 +37,53 @@
40 37
 
41 38
 	( load font )
42 39
 	#4000 .File/length DEO2
43
-	;fontpath .File/name DEO2
40
+	;font-path .File/name DEO2
44 41
 	;font-data .File/load DEO2
45 42
 
46
-	#0000 #0030 ;sometext #21 ;draw-label JSR2
43
+	( draw label )
44
+	#0000 #0030 ;body #21 ;draw-uf2 JSR2
47 45
 	
48 46
 BRK
49 47
 
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 -- )
48
+@draw-uf2 ( x* y* text* color -- )
71 49
 	
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 50
 	STH 
105
-	STH2
106
-	.Screen/y DEO2
107
-	.Screen/x DEO2
108
-	STH2r
51
+	SWP2 .Screen/y DEO2
52
+	SWP2 DUP2 .Screen/x DEO2 SWP2
109 53
 	&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 ++
54
+		LDAk 
55
+		DUP #0a ! ,&no-linebreak JCN
56
+			( move down ) OVR2 .Screen/x DEO2
57
+			( incr y ) .Screen/y DEI2 #0010 ++ .Screen/y DEO2 
58
+			POP ,&continue JMP &no-linebreak
59
+		STHkr ,&sprite JSR
60
+		&continue
61
+		( incr addr ) #0001 ++
117 62
 		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
63
+	POP2 POP2 POPr
64
+	RTN
164 65
 
165
-@print-hex ( value -- )
166
-	
167
-	STHk #04 SFT ,&parse JSR .Console/write DEO
168
-	STHr #0f AND ,&parse JSR .Console/write DEO
66
+	&sprite ( char color -- )
67
+		STH
68
+		( get addr ) STHk TOS #0020 ** ;font-data #0100 ++ ++ .Screen/addr DEO2
69
+		SWPr
70
+			( top-left ) STHkr .Screen/color DEO
71
+			.Screen/y DEI2 #0008 ++ .Screen/y DEO2
72
+			.Screen/addr DEI2 #0010 ++ .Screen/addr DEO2
73
+			( bottom-left ) STHkr .Screen/color DEO
74
+			.Screen/x DEI2 #0008 ++ .Screen/x DEO2
75
+			.Screen/addr DEI2 #0008 ++ .Screen/addr DEO2
76
+			( bottom-right ) STHkr .Screen/color DEO
77
+			.Screen/y DEI2 #0008 -- .Screen/y DEO2
78
+			.Screen/addr DEI2 #0010 -- .Screen/addr DEO2
79
+			( top-right ) STHkr .Screen/color DEO
80
+		SWPr
81
+		( get width ) STHkr TOS ;font-data ++ LDA TOS .Screen/x DEI2 ++ #0008 -- .Screen/x DEO2
82
+		POPr POPr
169 83
 	RTN
170
-	&parse ( value -- char )
171
-		DUP #09 GTH ,&above JCN #30 ADD RTN &above #09 SUB #60 ADD RTN
172 84
 
173 85
 RTN
174 86
 
175
-@cursor 
176
-	ffff ffff ffff ffff
177
-
178 87
 @font-hex 
179 88
 	003c 464a 5262 3c00 0018 0808 0808 1c00
180 89
 	003c 4202 3c40 7e00 003c 421c 0242 3c00
... ...
@@ -185,7 +94,7 @@ RTN
185 94
 	003c 4240 4042 3c00 007c 4242 4242 7c00
186 95
 	007e 4078 4040 7e00 007e 4078 4040 4000 
187 96
 
188
-@sometext 
97
+@body 
189 98
 	4927 6c6c 206d 616b 6520 6120 736f 756e
190 99
 	6420 7468 6174 2773 2073 6f20 616c 6f6e
191 100
 	6520 0a74 6861 7420 6e6f 206f 6e65 2063
... ...
@@ -201,6 +110,6 @@ RTN
201 110
 	6974 2069 6e20 7468 6520 6469 7374 616e
202 111
 	7420 746f 776e 732e 20 $1
203 112
 
204
-@fontpath "projects/fonts/venice14.uf2
113
+@font-path "projects/fonts/venice14.uf2
205 114
 
206 115
 @font-data
207 116
\ No newline at end of file