-
Notifications
You must be signed in to change notification settings - Fork 1
/
SpecialFonts.pbp
176 lines (147 loc) · 3.2 KB
/
SpecialFonts.pbp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
; This patch allows using different colors for different characters
; graphics_draw_text, beginning
82 b0 f0 b5 @ 93 b0 04 46 {
; was:
; SUB SP,SP,0x4C
; MOV R4, R0
; free to use: R4-R7
B.W my_gdc
global cont_gdc
}
; graphics_draw_text, ending
13 b0 @ bd e8 f0 40 02 b0 70 47 {
;ADD SP,SP,0x4C
; was:
;POP.W {R4-R7,LR}
;ADD SP,SP,8
;BX LR
B.W my_gdce
}
; text_layout_render_char proc, ending
05 9b ea 68 30 46 21 46 bd e8 70 40 02 b0 @ ?4 {
; was: B.W text_render_draw_char
B.W my1
}
82 b0 2d e9 f0 4f 99 b0 {
proc text_render_draw_char
}
{
global my_gdc
; save current graphics context values which we'll overwrite into stack
LDRB R4, [R0, 0x2d] ; stroke color
PUSH {R4}
; store current text color in stroke color byte (fixme?)
LDRB R4, [R0, 0x2f] ; text color
STRB R4, [R0, 0x2d] ; save it as stroke color
; reexec..
SUB SP,SP,0x4C
MOV R4, R0
B.W cont_gdc
;--
ALIGN 4
global my_gdce
; restore graphics context
; here R4 is graphics context, and R1-R3,R5-R7 are free to use
POP {R1}
STRB R1, [R4, 0x2d] ; stroke color
; reexecute
POP {R4-R7,LR}
ADD SP,SP,8
BX LR
;--
ALIGN 4
global my1
; R0: ctx
; R1: codepoint
; R2: ?
; R3: origin pos
#ifdef CodeAc
PUSH {R1,R4-R7}
; mapping table based on codepoint
CMP R1, 0x41 ; A
BCC default ; <
CMP R1, 0x7A ; z
BHI default
CMP R1, 0x5A ; Z
BLS uppercase
CMP R1, 0x61 ; a
BCC default ; in between
lowercase:
SUB R1, 0x20 ; convert to uppercase
uppercase:
SUB R1, 0x41 ; A
ADR R4, table
LDRB R4, [R4, R1] ; color = table[letter]
; check for bg color
LDRB R5, [R0, 0x2e] ; fill color - we suppose it equals to bg. FIXME?
CMP R5, R4 ; TODO: fuzzy comparsion
BEQ default ; if new fg == bg then use default fg instead
B setcolor
default:
LDRB R4, [R0, 0x2d] ; load pre-saved default color
; set that color as font color
setcolor:
STRB R4, [R0, 0x2f]
POP {R1,R4-R7}
B.W text_render_draw_char
ALIGN 4
table:
; black: c0, red: f0, blue: c3
db c0 f0 c0 c3 ; abcd
db f0 c0 c3 f0 ; efgh
db c3 c3 c3 c0 ; ijkl
db f0 c3 c3 f0 ; mnop
db c0 c3 f0 c3 ; qrst
db f0 c0 c0 f0 ; uvwx
db f0 c0 ; yz
#else
#ifdef CodeB
; R0: ctx
; R1: codepoint
; R2: ?
; R3: origin pos
PUSH {R1,R4-R7}
; TODO
POP {R1,R4-R7}
B.W text_render_draw_char
#else
#ifdef CodeC
; R0: ctx
; R1: codepoint
; R2: ?
; R3: origin pos
PUSH {R1,R4-R7}
; TODO
#ifdef _comment
init {
prev_bottom = 0;
prev_width = 0;
}
get_char_meta after {
have: new_top, new_left, new_width, new_height
have: prev_bottom, perv_width
ret_width = new_width ; for now
if new_top > prev_bottom:
ret_width = -prev_width ; is it possible?
prev_width = new_width
prev_bottom = new_top + new_height ; for next time
return: new_top, new_left, *ret_width*, new_height
}
draw_char before {
draw gray rect on new char rect? (but don't overwrite prev char)
draw white line on lower third of that same rect
}
; 0. on start: reset prev char top & width
; 1. draw bg and/or lower line
; 1a. if curr/prev char is 'q', skip drawing line?
; FIX: how to avoid overwriting prev char? Maybe check for fg color?
; 2. when determining char metadata, check prev char;
#endif
POP {R1,R4-R7}
B.W text_render_draw_char
#else
Error: please specify desired coding
#endif
#endif
#endif
}