-
Notifications
You must be signed in to change notification settings - Fork 25
/
text.asm
235 lines (199 loc) · 3.93 KB
/
text.asm
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
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
Wait:
_
ld a,(mpIntMaskedStatus)
rra
ret c
ld a,(mpKeypadGrp6)
rra
jr c,-_
_
ld a,(mpIntMaskedStatus)
rra
ret c
ld a,(mpKeypadGrp6)
rra
jr nc,-_
ret
#ifdef DEBUG
debug_printf:
ld ix,text_buffer
ex (sp),ix
call _sprintf
pop hl
push ix
debug_print:
; HL points to string
_
ld a,(hl)
inc hl
ld (mpCEmuDbg),a
or a
jr nz,-_
ret
#endif
SetEmulatorMessage:
ld a,120
; Call like printf, DE=format string (offset into appvar), A=duration
SetEmulatorMessageWithDuration:
ld ix,(ArcBase)
add ix,de
ex (sp),ix
ld hl,emulatorMessageDuration
ld (hl),a
inc hl ;emulatorMessageText
push hl
ld a,(GameMessageDisplay)
cp $FF
jr nz,_
ld a,(MessageDisplay)
_
or a
call nz,_sprintf
pop hl
ex (sp),ix
jp reset_preserved_area
PutEmulatorMessage:
ld a,BLACK
call SetStringBgColor
; Modify PutChar to use a 160-pixel wide buffer
push hl
xor a
ld hl,PutChar_SmallBufferSMC1
ld (hl),a ; nop
#if (PutChar_SmallBufferSMC1>>8)!=(PutChar_SmallBufferSMC2>>8)
.error "(PutChar_SmallBufferSMC1>>8)!=(PutChar_SmallBufferSMC2>>8)"
#endif
ld l,PutChar_SmallBufferSMC2&$FF
ld (hl),(160-8)/2
ld c,a
ld b,a
ld a,WHITE
ex (sp),hl
ACALL(PutStringColorXY)
pop hl
; Restore PutChar to use a 320-pixel wide buffer
ld (hl),(320-8)/2
ld l,PutChar_SmallBufferSMC1&$FF
ld (hl),$09 ; add hl,bc
ld a,BLUE
call SetStringBgColor
ld hl,(cursorCol)
add hl,hl
ld h,10
jp PutEmulatorMessageRet
; Call like printf, A=color, D=x (column), E=y
PutStringFormatColorXYIgnoreInvalid:
ld hl,PutChar_DefaultInvalidSMC
ld (hl),1
ex de,hl
; Call like printf, A=color, H=x (column), L=y
PutStringFormatColorXY:
ld (cursorRowCol),hl
; Call like printf, A=color
PutStringFormatColor:
call SetStringColor
; Call like printf
PutStringFormat:
ld ix,text_buffer
ex (sp),ix
call _sprintf
pop hl
push ix
jr PutString
; HL points to string, A=color, B=x (column), C=y
PutStringColorXY:
ld (cursorRowCol),bc
; HL points to string, A=color
PutStringColor:
call SetStringColor
; HL points to string
PutString:
ld a,(hl)
inc hl
or a
jr z,_
push hl
call PutChar
pop hl
jr PutString
_
ld (PutChar_DefaultInvalidSMC),a
ret
PutNStringColorXY:
ld (cursorRowCol),bc
PutNStringColor:
call SetStringColor
PutNString:
ld b,(hl)
inc hl
PutNString_B:
push bc
ld a,(hl)
inc hl
push hl
ld b,2 ; Display invalid characters as boxes
call PutCharSpecifyInvalid
pop hl
pop bc
djnz PutNString_B
ret
PutNewLine:
ld hl,cursorRowCol+1
ld (hl),1
dec hl
ld a,(hl)
cp a,240
ret nc
add a,10
ld (hl),a
ret
font:
#import "font.bin"
digits_encoded:
.db %11101010,%10101010,%11100000
.db %01001100,%01000100,%11100000
.db %11000010,%01001000,%11100000
.db %11000010,%01000010,%11000000
.db %10101010,%11100010,%00100000
.db %11101000,%11000010,%11000000
.db %01101000,%11101010,%11100000
.db %11100010,%01001000,%10000000
.db %11101010,%11101010,%11100000
.db %11101010,%11100010,%11000000
.db %10100010,%01001000,%10100000
#ifdef DEBUG
StartText:
.db "Starting!\n",0
WaitLoopSearchMessage:
.db "Searching for waitloop at %04X.\n",0
WaitLoopIdentifiedMessage:
.db "Setting waitloop at %04X, var %04X.\n",0
ByteFormat:
.db "%02X",0
LookupGBMessage:
.db "Looking up GB address from %04X\n",0
LookupGBFoundMessage:
.db "Found GB %04X @ %04X\n",0
FlushMessage:
.db "Flushing recompiled code\n",0
CacheMissMessage:
.db "Cache miss at %06X\n",0
LookupMessage:
.db "Looking up GB code at %06X\n",0
RecompileMessage:
.db "Recompiling %06X to %04X\n",0
RecompileRamMessage:
.db "Recompiling RAM:%06X to %04X\n",0
CoherencyFailedMessage:
.db "RAM coherency failed at %06X, routine=%04X\n",0
PaddingUpdateMessage:
.db "RAM block padding increased to %06X\n",0
RuntimeErrorMessage:
.db "Runtime error occurred!\n",0
InvalidOpcodeErrorMessage:
.db "Encountered invalid opcode at %04X\n",0
#ifdef SCHEDULER_LOG
SchedulerLogMessage:
.db "%06X: AF=%04X, BC=%04X, DE=%04X, HL=%04X, SP=%04X\n",0
#endif
#endif