Browse code

Improving the font example

neauoire authored on 03/07/2021 17:24:23
Showing 1 changed files
... ...
@@ -7,17 +7,23 @@
7 7
 
8 8
 %RTN { JMP2r }
9 9
 %TOS { #00 SWP }
10
+%INCR { SWP #01 ADD SWP }
11
+%GET-ITERATORS { SWP2k POP SWP POP }
10 12
 
11 13
 ( devices )
12 14
 
13
-|00 @System     [ &vector $2 &pad    $6 &r      $2 &g     $2 &b      $2 ]
14
-|20 @Screen     [ &vector $2 &width  $2 &height $2 &pad   $2 &x      $2 &y $2 &addr $2 &color $1 ]
15
-|a0 @File       [ &vector $2 &success $2 &offset $2 &pad $2 &name $2 &length $2 &load $2 &save $2 ]
15
+|00 @System  &vector $2 &pad     $6 &r      $2 &g     $2 &b      $2
16
+|20 @Screen  &vector $2 &width   $2 &height $2 &pad   $2 &x      $2 &y      $2 &addr $2 &color $1
17
+|a0 @File    &vector $2 &success $2 &offset $2 &pad   $2 &name   $2 &length $2 &load $2 &save  $2
16 18
 
17 19
 ( variables )
18 20
 
19 21
 |0000
20 22
 
23
+@position
24
+	&x $2
25
+	&y $2
26
+
21 27
 ( init )
22 28
 
23 29
 |0100 ( -> )
... ...
@@ -29,14 +35,75 @@
29 35
 
30 36
 	( load font )
31 37
 	#4000 .File/length DEO2
32
-	;font-path .File/name DEO2
38
+	;font-path-large .File/name DEO2
39
+	;font-data .File/load DEO2
40
+
41
+	( draw label )
42
+	#0000 #0020 ;title #21 ;draw-uf3 JSR2
43
+
44
+	( load font )
45
+	#4000 .File/length DEO2
46
+	;font-path-medium .File/name DEO2
47
+	;font-data .File/load DEO2
48
+
49
+	( draw label )
50
+	#0000 #0048 ;body #21 ;draw-uf2 JSR2
51
+
52
+	( load font )
53
+	#4000 .File/length DEO2
54
+	;font-path-small .File/name DEO2
33 55
 	;font-data .File/load DEO2
34 56
 
35 57
 	( draw label )
36
-	#0000 #0030 ;body #21 ;draw-uf2 JSR2
58
+	#0010 #00b8 ;footer #21 ;draw-uf2 JSR2
37 59
 	
38 60
 BRK
39 61
 
62
+@draw-uf3 ( x* y* text* color -- )
63
+		
64
+	STH 
65
+	STH2
66
+	.Screen/y DEO2
67
+	.Screen/x DEO2
68
+	STH2r
69
+	&loop
70
+		LDAk #0a ! ,&no-linebreak JCN
71
+			#0000 .Screen/x DEO2
72
+			.Screen/y DEI2 #0018 ++ .Screen/y DEO2
73
+		&no-linebreak
74
+		LDAk STHkr ,&sprite JSR
75
+		#0001 ++
76
+		LDAk ,&loop JCN
77
+	POP2 POPr
78
+	RTN
79
+
80
+	&sprite ( char color -- )
81
+		POP 
82
+		DUP TOS #0048 ** ;font-data #0100 ++ ++ .Screen/addr DEO2
83
+		.Screen/x DEI2 .position/x STZ2
84
+		.Screen/y DEI2 .position/y STZ2
85
+		#00 #03
86
+		&ver
87
+			#00 #03
88
+			&hor
89
+				GET-ITERATORS
90
+				TOS #0008 ** .position/y LDZ2 ++ .Screen/y DEO2
91
+				TOS #0008 ** .position/x LDZ2 ++ .Screen/x DEO2
92
+				#21 .Screen/color DEO
93
+				.Screen/addr DEI2 #0008 ++ .Screen/addr DEO2
94
+				INCR
95
+				LTHk ,&hor JCN
96
+			POP2
97
+
98
+			INCR
99
+			LTHk ,&ver JCN
100
+		POP2
101
+		TOS ;font-data ++ LDA TOS .position/x LDZ2 ++ .Screen/x DEO2
102
+		.position/y LDZ2 .Screen/y DEO2
103
+	RTN
104
+
105
+RTN
106
+
40 107
 @draw-uf2 ( x* y* text* color -- )
41 108
 	
42 109
 	STH 
... ...
@@ -80,6 +147,9 @@ BRK
80 147
 
81 148
 RTN
82 149
 
150
+@title
151
+	5468 6520 466f 6720 486f 726e $1
152
+
83 153
 @body 
84 154
 	4927 6c6c 206d 616b 6520 6120 736f 756e
85 155
 	6420 7468 6174 2773 2073 6f20 616c 6f6e
... ...
@@ -96,6 +166,15 @@ RTN
96 166
 	6974 2069 6e20 7468 6520 6469 7374 616e
97 167
 	7420 746f 776e 732e 20 $1
98 168
 
99
-@font-path "projects/fonts/venice14.uf2
169
+@footer
170
+	2d20 4279 2052 6179 2042 7261 6462 7572 
171
+	79 $1
172
+
173
+@font-path-large  
174
+	"projects/fonts/newyork24.uf3 $1
175
+@font-path-medium 
176
+	"projects/fonts/venice14.uf2 $1
177
+@font-path-small  
178
+	"projects/fonts/geneva12.uf2 $1
100 179
 
101 180
 @font-data
102 181
\ No newline at end of file