-
Notifications
You must be signed in to change notification settings - Fork 1
/
StringFixer_290.pbp
60 lines (53 loc) · 1.24 KB
/
StringFixer_290.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
; Fix broken utf8 strings.
; By default, such strings are not displayed at all.
; This patch cuts them after last valid character,
; so at least part of the string will be shown.
#ver 290
; utf8_validate_do proc
@ 13 b5 08 b9 00 20 12 e0 00 23 01 93 8d f8 03 30 {
; was: PUSH {R0,R1,R4,LR}
PUSH {R0,R1,R4,R5,LR}
}
13 b5 08 b9 00 20 12 e0 00 23 01 93 8d f8 03 30
04 46 20 46 @ 14 f8 01 2b {
B.W my_code1
global cont1
}
13 b5 08 b9 00 20 12 e0 00 23 01 93 8d f8 03 30
04 46 20 46 14 f8 01 2b 2a b1 0d f1 03 00 01 a9
?4 f5 e7 @ 9d f8 03 30 {
B.W my_code2
global cont2
}
13 b5 08 b9 00 20 12 e0 00 23 01 93 8d f8 03 30
04 46 20 46 14 f8 01 2b 2a b1 0d f1 03 00 01 a9
?4 f5 e7 9d f8 03 30 00 2b ea d1 02 b0 @ 10 bd {
; ending sequence
POP {R4,R5,PC}
}
{
proc my_code1
LDRB R1, [SP, 3] ; state
CBNZ R1, nosave
MOV R5, R4 ; for each 0-state (when str is valid) save its ending pos
nosave:
LDRB R2, [R4], 1
B.W cont1
ALIGN 4
proc my_code2
LDR R4, ramaddr
CMP R5, R4
BLE rom
; now that string is in ram, rewrite ending byte
MOV R3, 0 ; now state is definitely 0=good
STRB R3, [R5]
B done
rom:
; string is in rom -> cannot fix, so just repeat overwritten code
LDRB R3, [SP, 3] ; state
done:
B.W cont2
ALIGN 4
ramaddr:
DCD 0x20000000
}