summaryrefslogtreecommitdiff
path: root/arm9/asm/CTRDG_backup.s
blob: f5ed989dc5e60dd2f092e1a7d1625a817e18e425 (plain)
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
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
	.include "asm/macros.inc"
	.include "global.inc"

	.extern CTRDGi_EraseFlash4KBAT
	.extern CTRDGi_EraseFlash4KBAsyncAT
	.extern CTRDGi_EraseFlashChipAT
	.extern CTRDGi_EraseFlashChipAsyncAT
	.extern CTRDGi_EraseFlashChipAsyncLE
	.extern CTRDGi_EraseFlashChipAsyncMX
	.extern CTRDGi_EraseFlashChipLE
	.extern CTRDGi_EraseFlashChipMX
	.extern CTRDGi_EraseFlashSectorAT
	.extern CTRDGi_EraseFlashSectorAsyncAT
	.extern CTRDGi_EraseFlashSectorAsyncLE
	.extern CTRDGi_EraseFlashSectorAsyncMX
	.extern CTRDGi_EraseFlashSectorMX
	.extern CTRDGi_PollingSR1MCOMMON
	.extern CTRDGi_PollingSR512kCOMMON
	.extern CTRDGi_WriteFlash4KBAT
	.extern CTRDGi_WriteFlash4KBAsyncAT
	.extern CTRDGi_WriteFlashSectorAT
	.extern CTRDGi_WriteFlashSectorAsyncAT
	.extern CTRDGi_WriteFlashSectorAsyncLE
	.extern CTRDGi_WriteFlashSectorAsyncMX
	.extern CTRDGi_WriteFlashSectorLE
	.extern CTRDGi_WriteFlashSectorMX
	.extern CTRDGi_WriteFlashSectorAsyncMX5
	.extern CTRDGi_WriteFlashSectorMX5
	.extern UNK_021D6B14
	.extern UNK_021D6B30
	.extern UNK_021D6B28
	.extern UNK_021D6B1C
	.extern UNK_021D6B24
	.extern UNK_021D6B20
	.extern UNK_021D6B0C
	.extern UNK_021D6B34
	.extern UNK_021D6B2C
	.extern UNK_021D6B18

	.section .rodata

	.global UNK_02103FE4
UNK_02103FE4: ; 0x02103FE4
	.byte 0x14, 0x00, 0x00, 0x00

	.global UNK_02103FE8
UNK_02103FE8: ; 0x02103FE8
	.word UNK_02104150
	.word UNK_0210408C
	.word UNK_0210418C

	.global UNK_02103FF4
UNK_02103FF4: ; 0x02103FF4
	.word UNK_0210410C
	.word UNK_0210400C
	.word UNK_021041D0
	.word UNK_021040D0

	.global UNK_02104004
UNK_02104004: ; 0x02104004
	.byte 0x0A, 0x00, 0x28, 0x00, 0x00, 0x00, 0x28, 0x00

	.global UNK_0210400C
UNK_0210400C: ; 0x0210400C
	.word CTRDGi_WriteFlash4KBAT
	.word CTRDGi_EraseFlashChipAT
	.word CTRDGi_EraseFlash4KBAT
	.word CTRDGi_WriteFlash4KBAsyncAT
	.word CTRDGi_EraseFlashChipAsyncAT
	.word CTRDGi_EraseFlash4KBAsyncAT
	.word CTRDGi_PollingSR512kCOMMON
	.word UNK_02104004
	.byte 0x00, 0x00, 0x01, 0x00, 0x00, 0x10, 0x00, 0x00, 0x0C, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00
	.byte 0x03, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x1F, 0x00, 0x3D, 0x00

	.global UNK_02104048
UNK_02104048: ; 0x02104048
	.word CTRDGi_WriteFlashSectorAT
	.word CTRDGi_EraseFlashChipAT
	.word CTRDGi_EraseFlashSectorAT
	.word CTRDGi_WriteFlashSectorAsyncAT
	.word CTRDGi_EraseFlashChipAsyncAT
	.word CTRDGi_EraseFlashSectorAsyncAT
	.word CTRDGi_PollingSR512kCOMMON
	.word UNK_02104004
	.byte 0x00, 0x00, 0x01, 0x00, 0x80, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00
	.byte 0x03, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x1F, 0x00, 0x3D, 0x00

	.global UNK_02104084
UNK_02104084: ; 0x02104084
	.byte 0x0A, 0x00, 0x0A, 0x00, 0xD0, 0x07, 0x88, 0x13

	.global UNK_0210408C
UNK_0210408C: ; 0x0210408C
	.word CTRDGi_WriteFlashSectorMX
	.word CTRDGi_EraseFlashChipMX
	.word CTRDGi_EraseFlashSectorMX
	.word CTRDGi_WriteFlashSectorAsyncMX
	.word CTRDGi_EraseFlashChipAsyncMX
	.word CTRDGi_EraseFlashSectorAsyncMX
	.word CTRDGi_PollingSR1MCOMMON
	.word UNK_02104084
	.byte 0x00, 0x00, 0x02, 0x00, 0x00, 0x10, 0x00, 0x00, 0x0C, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00
	.byte 0x03, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x62, 0x00, 0x13, 0x00

	.global UNK_021040C8
UNK_021040C8: ; 0x021040C8
	.byte 0x0A, 0x00, 0x0A, 0x00, 0x28, 0x00, 0xC8, 0x00

	.global UNK_021040D0
UNK_021040D0: ; 0x021040D0
	.word CTRDGi_WriteFlashSectorLE
	.word CTRDGi_EraseFlashChipLE
	.word CTRDGi_EraseFlashSectorLE
	.word CTRDGi_WriteFlashSectorAsyncLE
	.word CTRDGi_EraseFlashChipAsyncLE
	.word CTRDGi_EraseFlashSectorAsyncLE
	.word CTRDGi_PollingSR512kCOMMON
	.word UNK_021040C8
	.byte 0x00, 0x00, 0x01, 0x00, 0x00, 0x10, 0x00, 0x00, 0x0C, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00
	.byte 0x01, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00

	.global UNK_0210410C
UNK_0210410C: ; 0x0210410C
	.word CTRDGi_WriteFlashSectorLE
	.word CTRDGi_EraseFlashChipLE
	.word CTRDGi_EraseFlashSectorLE
	.word CTRDGi_WriteFlashSectorAsyncLE
	.word CTRDGi_EraseFlashChipAsyncLE
	.word CTRDGi_EraseFlashSectorAsyncLE
	.word CTRDGi_PollingSR512kCOMMON
	.word UNK_021040C8
	.byte 0x00, 0x00, 0x01, 0x00, 0x00, 0x10, 0x00, 0x00, 0x0C, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00
	.byte 0x01, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0xBF, 0x00, 0xD4, 0x00

	.global UNK_02104148
UNK_02104148: ; 0x02104148
	.byte 0x0A, 0x00, 0x0A, 0x00, 0xD0, 0x07, 0xD0, 0x07

	.global UNK_02104150
UNK_02104150: ; 0x02104150
	.word CTRDGi_WriteFlashSectorMX
	.word CTRDGi_EraseFlashChipMX
	.word CTRDGi_EraseFlashSectorMX
	.word CTRDGi_WriteFlashSectorAsyncMX
	.word CTRDGi_EraseFlashChipAsyncMX
	.word CTRDGi_EraseFlashSectorAsyncMX
	.word CTRDGi_PollingSR1MCOMMON
	.word UNK_02104148
	.byte 0x00, 0x00, 0x02, 0x00, 0x00, 0x10, 0x00, 0x00, 0x0C, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00
	.byte 0x03, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0xC2, 0x00, 0x09, 0x00

	.global UNK_0210418C
UNK_0210418C: ; 0x0210418C
	.word CTRDGi_WriteFlashSectorMX
	.word CTRDGi_EraseFlashChipMX
	.word CTRDGi_EraseFlashSectorMX
	.word CTRDGi_WriteFlashSectorAsyncMX
	.word CTRDGi_EraseFlashChipAsyncMX
	.word CTRDGi_EraseFlashSectorAsyncMX
	.word CTRDGi_PollingSR1MCOMMON
	.word UNK_02104148
	.byte 0x00, 0x00, 0x02, 0x00, 0x00, 0x10, 0x00, 0x00, 0x0C, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00
	.byte 0x03, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00

	.global UNK_021041C8
UNK_021041C8: ; 0x021041C8
	.byte 0x0A, 0x00, 0x0A, 0x00, 0xF4, 0x01, 0xF4, 0x01

	.global UNK_021041D0
UNK_021041D0: ; 0x021041D0
	.word CTRDGi_WriteFlashSectorMX5
	.word CTRDGi_EraseFlashChipLE
	.word CTRDGi_EraseFlashSectorLE
	.word CTRDGi_WriteFlashSectorAsyncMX5
	.word CTRDGi_EraseFlashChipAsyncLE
	.word CTRDGi_EraseFlashSectorAsyncLE
	.word CTRDGi_PollingSR512kCOMMON
	.word UNK_021041C8
	.byte 0x00, 0x00, 0x01, 0x00, 0x00, 0x10, 0x00, 0x00, 0x0C, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00
	.byte 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x32, 0x00, 0x1B, 0x00

	.section .bss

	.global UNK_021D6B4C
UNK_021D6B4C: ; 0x021D6B4C
	.space 0x4

    .text

	arm_func_start CTRDG_IdentifyAgbBackup
CTRDG_IdentifyAgbBackup: ; 0x020DBD50
	stmdb sp!, {r4-r7,lr}
	sub sp, sp, #0x4
	mov r7, r0
	cmp r7, #0x1
	mov r0, #0x1
	bhi _020DBEAC
	bl OS_GetLockID
	ldr r1, _020DBED8 ; =UNK_021D6B0C
	strh r0, [r1, #0x0]
	ldrh r0, [r1, #0x0]
	bl OS_LockCartridge
	ldr r6, _020DBEDC ; =0x04000204
	ldr r1, _020DBEE0 ; =UNK_02103FE4
	ldrh r3, [r6, #0x0]
	ldrh r2, [r6, #0x0]
	ldr r0, _020DBEE4 ; =UNK_021D6B28
	and r4, r3, #0x3
	bic r2, r2, #0x3
	orr r2, r2, #0x3
	strh r2, [r6, #0x0]
	str r1, [r0, #0x0]
	bl CTRDGi_ReadFlashID
	ldr r2, _020DBEDC ; =0x04000204
	mov r6, r0
	ldrh r1, [r2, #0x0]
	cmp r7, #0x0
	ldreq r5, _020DBEE8 ; =UNK_02103FF4
	bic r1, r1, #0x3
	orr r1, r1, r4
	cmp r7, #0x1
	ldr r0, _020DBED8 ; =UNK_021D6B0C
	strh r1, [r2, #0x0]
	ldrh r0, [r0, #0x0]
	ldreq r5, _020DBEEC ; =UNK_02103FE8
	bl OS_UnlockCartridge
	ldr r2, [r5, #0x0]
	mov r0, #0x1
	ldrh r1, [r2, #0x38]
	cmp r1, #0x0
	beq _020DBE14
	and r3, r6, #0xff
_020DBDF4:
	ldrh r1, [r2, #0x38]
	cmp r3, r1
	moveq r0, #0x0
	beq _020DBE14
	ldr r2, [r5, #0x4]!
	ldrh r1, [r2, #0x38]
	cmp r1, #0x0
	bne _020DBDF4
_020DBE14:
	ldr r2, [r2, #0x0]
	ldr r1, _020DBEF0 ; =UNK_021D6B14
	ldr r3, _020DBEF4 ; =UNK_021D6B34
	str r2, [r1, #0x0]
	ldr r1, [r5, #0x0]
	ldr r2, _020DBEF8 ; =UNK_021D6B2C
	ldr r4, [r1, #0x4]
	ldr r1, _020DBEFC ; =UNK_021D6B18
	str r4, [r3, #0x0]
	ldr r3, [r5, #0x0]
	ldr r6, _020DBF00 ; =UNK_021D6B1C
	ldr r3, [r3, #0x8]
	ldr r4, _020DBF04 ; =UNK_021D6B30
	str r3, [r2, #0x0]
	ldr r2, [r5, #0x0]
	ldr r3, _020DBF08 ; =UNK_021D6B24
	ldr r7, [r2, #0xc]
	ldr r2, _020DBEE4 ; =UNK_021D6B28
	str r7, [r1, #0x0]
	ldr r7, [r5, #0x0]
	ldr r1, _020DBF0C ; =UNK_021D6B20
	ldr r7, [r7, #0x10]
	add sp, sp, #0x4
	str r7, [r6, #0x0]
	ldr r6, [r5, #0x0]
	ldr r6, [r6, #0x14]
	str r6, [r4, #0x0]
	ldr r4, [r5, #0x0]
	ldr r4, [r4, #0x18]
	str r4, [r3, #0x0]
	ldr r3, [r5, #0x0]
	ldr r3, [r3, #0x1c]
	str r3, [r2, #0x0]
	ldr r2, [r5, #0x0]
	add r2, r2, #0x20
	str r2, [r1, #0x0]
	ldmia sp!, {r4-r7,lr}
	bx lr
_020DBEAC:
	cmp r7, #0x2
	addne sp, sp, #0x4
	ldmneia sp!, {r4-r7,lr}
	bxne lr
	bl OS_GetLockID
	ldr r1, _020DBF10 ; =UNK_021D6B4C
	strh r0, [r1, #0x0]
	mov r0, #0x0
	add sp, sp, #0x4
	ldmia sp!, {r4-r7,lr}
	bx lr
	.balign 4
_020DBED8: .word UNK_021D6B0C
_020DBEDC: .word 0x04000204
_020DBEE0: .word UNK_02103FE4
_020DBEE4: .word UNK_021D6B28
_020DBEE8: .word UNK_02103FF4
_020DBEEC: .word UNK_02103FE8
_020DBEF0: .word UNK_021D6B14
_020DBEF4: .word UNK_021D6B34
_020DBEF8: .word UNK_021D6B2C
_020DBEFC: .word UNK_021D6B18
_020DBF00: .word UNK_021D6B1C
_020DBF04: .word UNK_021D6B30
_020DBF08: .word UNK_021D6B24
_020DBF0C: .word UNK_021D6B20
_020DBF10: .word UNK_021D6B4C