This source file includes following definitions.
- log_fwt_msg
- log_fwt_start
- filewritetask
- sub_fc063664_my
- sub_fc063ac6_my
- sub_fc063768_my
1 #include "lolevel.h"
2 #include "platform.h"
3
4 extern void _LogCameraEvent(int id,const char *fmt,...);
5
6 typedef struct {
7 unsigned int address;
8 unsigned int length;
9 } cam_ptp_data_chunk;
10
11 #define MAX_CHUNKS_FOR_FWT 7
12
13
14
15
16
17
18
19 typedef struct
20 {
21 int unkn1;
22 int file_offset;
23 int maybe_full_size;
24 int unkn2, unkn3;
25 cam_ptp_data_chunk pdc[MAX_CHUNKS_FOR_FWT];
26 int maybe_seek_flag;
27 int unkn5, unkn6;
28 char name[32];
29 } fwt_data_struct;
30
31 #include "../../../generic/filewrite.c"
32
33 void log_fwt_msg(fwt_data_struct *fwd)
34 {
35 int m=fwd->unkn1;
36 _LogCameraEvent(0x60,"fw m:%d o:0x%08x fs:0x%08x sf:0x%x",m,fwd->file_offset,fwd->maybe_full_size,fwd->maybe_seek_flag);
37 _LogCameraEvent(0x60,"fw %s",fwd->name);
38 if(m >= 0 && m <=6) {
39 _LogCameraEvent(0x60,"fw chunk adr:0x%08x l:0x%08x",fwd->pdc[m].address,fwd->pdc[m].length);
40 }
41 _LogCameraEvent(0x60,"fw u %08x %08x %08x %08x %08x",fwd->unkn2,fwd->unkn3,fwd->unkn5,fwd->unkn6);
42 }
43
44 void log_fwt_start(void)
45 {
46 _LogCameraEvent(0x60,"fw start");
47 }
48
49
50
51
52 void __attribute__((naked,noinline)) filewritetask() {
53 asm volatile (
54 " push {r2, r3, r4, r5, r6, lr}\n"
55 " ldr r5, =0x000220dc\n"
56 "loc_fc063862:\n"
57 " movs r2, #0\n"
58 " add r1, sp, #4\n"
59 " ldr r0, [r5, #0x10]\n"
60 " blx sub_fc2a15d0\n"
61 " cbz r0, loc_fc06387a\n"
62 " movs r0, #0\n"
63 " movw r2, #0x3f5\n"
64 " ldr r1, =0xfc0639f4\n"
65 " blx sub_fc2a1670\n"
66 "loc_fc06387a:\n"
67 " ldr r0, [sp, #4]\n"
68 " ldr r1, [r0]\n"
69 " cmp r1, #0xd\n"
70 " bhs loc_fc063862\n"
71 " tbb [pc, r1]\n"
72 "branchtable_fc063886:\n"
73 " .byte((loc_fc063920 - branchtable_fc063886) / 2)\n"
74 " .byte((loc_fc063920 - branchtable_fc063886) / 2)\n"
75 " .byte((loc_fc063920 - branchtable_fc063886) / 2)\n"
76 " .byte((loc_fc063920 - branchtable_fc063886) / 2)\n"
77 " .byte((loc_fc063920 - branchtable_fc063886) / 2)\n"
78 " .byte((loc_fc063920 - branchtable_fc063886) / 2)\n"
79 " .byte((loc_fc063920 - branchtable_fc063886) / 2)\n"
80 " .byte((loc_fc063926 - branchtable_fc063886) / 2)\n"
81 " .byte((loc_fc063894 - branchtable_fc063886) / 2)\n"
82 " .byte((loc_fc0638be - branchtable_fc063886) / 2)\n"
83 " .byte((loc_fc0638de - branchtable_fc063886) / 2)\n"
84 " .byte((loc_fc06389a - branchtable_fc063886) / 2)\n"
85 " .byte((loc_fc0638b8 - branchtable_fc063886) / 2)\n"
86 ".align 1\n"
87 "loc_fc063894:\n"
88 " bl sub_fc063a82\n"
89 " b loc_fc063862\n"
90
91 "loc_fc06389a:\n"
92 " mov r4, r0\n"
93 " adds r0, #0x58\n"
94 " mov r6, r0\n"
95 " bl sub_fc3095b2\n"
96 " movs r1, #0\n"
97 " bl sub_fc06c066\n"
98 " ldr r0, [r4, #0xc]\n"
99 " bl sub_fc0a2596\n"
100 " mov r0, r6\n"
101 " bl sub_fc309c6a\n"
102 " b loc_fc063908\n"
103
104 "loc_fc0638b8:\n"
105
106 " bl sub_fc063664_my\n"
107 " b loc_fc063862\n"
108
109 "loc_fc0638be:\n"
110 " ldr r1, [r0, #4]\n"
111 " movs r2, #0\n"
112 " mov r4, r0\n"
113 " ldr r0, [r5, #4]\n"
114 " bl _lseek\n"
115 " adds r0, r0, #1\n"
116 " bne loc_fc063862\n"
117 " ldr r0, =0x09200001\n"
118 " mov r1, r4\n"
119 " adds r0, #0x12\n"
120 " str r0, [r4, #0x10]\n"
121 " movs r0, #7\n"
122 " bl sub_fc0635f0\n"
123 " b loc_fc063862\n"
124
125 "loc_fc0638de:\n"
126 " mov r4, r0\n"
127 " ldrsb.w r0, [r0, #0x58]\n"
128 " cmp r0, #0\n"
129 " beq loc_fc063862\n"
130 " strb.w r0, [sp]\n"
131 " movs r0, #0\n"
132 " strb.w r0, [sp, #1]\n"
133 " add.w r0, r4, #0x58\n"
134 " mov r6, r0\n"
135 " bl sub_fc3095b2\n"
136 " movs r1, #0\n"
137 " bl sub_fc06c066\n"
138 " mov r0, sp\n"
139 " bl sub_fc0a25a2\n"
140 "loc_fc063908:\n"
141 " mov r0, r6\n"
142 " bl sub_fc3095b2\n"
143 " ldr r1, [r5, #0x1c]\n"
144 " bl sub_fc06c0c4\n"
145 " ldr r1, [r5, #0x14]\n"
146 " cmp r1, #0\n"
147 " beq loc_fc063862\n"
148 " ldr r0, [r4, #0x10]\n"
149 " blx r1\n"
150 " b loc_fc063862\n"
151
152 "loc_fc063920:\n"
153
154 " bl sub_fc063ac6_my\n"
155 " b loc_fc063862\n"
156
157 "loc_fc063926:\n"
158
159 " bl sub_fc063768_my\n"
160 " b loc_fc063862\n"
161
162 ".ltorg\n"
163 );
164 }
165
166
167
168 void __attribute__((naked,noinline)) sub_fc063664_my() {
169 asm volatile (
170 " push.w {r4, r5, r6, r7, r8, sb, lr}\n"
171 " mov r4, r0\n"
172
173
174
175 " BL filewrite_main_hook\n"
176 " mov r0, r4\n"
177
178 " ldr r0, [r0, #0x4c]\n"
179 " sub sp, #0x3c\n"
180 " lsls r0, r0, #0x1f\n"
181 " beq loc_fc063744\n"
182 " ldr r7, =0x000220dc\n"
183 " ldr r0, [r7, #0x18]\n"
184 " cbz r0, loc_fc06367a\n"
185 " blx r0\n"
186 "loc_fc06367a:\n"
187 " add.w r0, r4, #0x58\n"
188 " mov r8, r0\n"
189 " bl sub_fc3095b2\n"
190 " movs r1, #0\n"
191 " bl sub_fc06c066\n"
192 " ldr r0, [r4, #0xc]\n"
193 " bl sub_fc0a2596\n"
194 " ldr r0, [r4, #0x4c]\n"
195 " movw r5, #0x301\n"
196 " lsls r1, r0, #0x1b\n"
197 " bpl loc_fc06369e\n"
198 " movs r5, #9\n"
199 " b loc_fc0636a4\n"
200 "loc_fc06369e:\n"
201 " lsls r1, r0, #0x19\n"
202 " bpl loc_fc0636a4\n"
203 " movs r5, #1\n"
204 "loc_fc0636a4:\n"
205 " lsls r0, r0, #0x1a\n"
206 " bmi loc_fc0636ae\n"
207 " ldr r0, [r4, #0x54]\n"
208 " cmp r0, #1\n"
209 " bne loc_fc0636b2\n"
210 "loc_fc0636ae:\n"
211 " orr r5, r5, #0x8000\n"
212 "loc_fc0636b2:\n"
213 " movw sb, #0x1b6\n"
214 " ldr r6, [r4, #0xc]\n"
215 " mov r2, sb\n"
216 " mov r1, r5\n"
217 " mov r0, r8\n"
218
219
220 " bl fwt_open\n"
221
222 " adds r1, r0, #1\n"
223 " bne loc_fc063700\n"
224 " mov r0, r8\n"
225 " bl sub_fc309c6a\n"
226 " movs r2, #0xf\n"
227 " mov r1, r8\n"
228 " add r0, sp, #4\n"
229 " blx sub_fc2a1688\n"
230 " movs r0, #0\n"
231 " strb.w r0, [sp, #0x13]\n"
232 " movw r1, #0x41ff\n"
233 " str r1, [sp, #0x24]\n"
234 " strd r0, r6, [sp, #0x2c]\n"
235 " movs r1, #0x10\n"
236 " str r6, [sp, #0x34]\n"
237 " add r0, sp, #4\n"
238 " str r6, [sp, #0x38]\n"
239 " str r1, [sp, #0x28]\n"
240 " add r1, sp, #0x24\n"
241 " bl sub_fc10db0a\n"
242 " mov r2, sb\n"
243 " mov r1, r5\n"
244 " mov r0, r8\n"
245
246
247 " bl _Open\n"
248
249 "loc_fc063700:\n"
250 " mov r5, r0\n"
251 " str r0, [r7, #4]\n"
252 " adds r0, r0, #1\n"
253 " bne loc_fc063724\n"
254 " mov r0, r8\n"
255 " bl sub_fc3095b2\n"
256 " ldr r1, [r7, #0x1c]\n"
257 " bl sub_fc06c0c4\n"
258 " ldr r1, [r7, #0x14]\n"
259 " cmp r1, #0\n"
260 " beq loc_fc063762\n"
261 " add sp, #0x3c\n"
262 " ldr r0, =0x09200001\n"
263 " pop.w {r4, r5, r6, r7, r8, sb, lr}\n"
264 " bx r1\n"
265 "loc_fc063724:\n"
266 " ldr r0, =0x0014eadc\n"
267 " movs r2, #0x20\n"
268 " mov r1, r8\n"
269 " blx sub_fc2a1690\n"
270
271 " LDR R3, =current_write_ignored\n"
272 " LDR R3, [R3]\n"
273 " cbnz r3,loc_C\n"
274
275 " ldr r0, [r4, #0x4c]\n"
276 " lsls r0, r0, #0x18\n"
277 " bpl loc_fc063744\n"
278 " ldr r1, [r4, #8]\n"
279 " mov r0, r5\n"
280 " bl sub_fc309a80\n"
281 " cbnz r0, loc_fc063744\n"
282 " movs r0, #7\n"
283 " mov r1, r4\n"
284 " b loc_fc06375a\n"
285 "loc_fc063744:\n"
286 "loc_C:\n"
287 " ldr r0, [r4, #0x4c]\n"
288 " lsls r0, r0, #0x19\n"
289 " bmi loc_fc06374e\n"
290 " ldr r0, [r4, #4]\n"
291 " cbz r0, loc_fc063756\n"
292 "loc_fc06374e:\n"
293 " movs r0, #9\n"
294 " mov r1, r4\n"
295 " bl sub_fc0635f0\n"
296 "loc_fc063756:\n"
297 " movs r0, #0\n"
298 " mov r1, r4\n"
299 "loc_fc06375a:\n"
300 " add sp, #0x3c\n"
301 " pop.w {r4, r5, r6, r7, r8, sb, lr}\n"
302
303
304 " ldr pc,=0xfc0635f1\n"
305
306 "loc_fc063762:\n"
307 " add sp, #0x3c\n"
308 " pop.w {r4, r5, r6, r7, r8, sb, pc}\n"
309
310 ".ltorg\n"
311 );
312 }
313
314
315
316 void __attribute__((naked,noinline)) sub_fc063ac6_my() {
317 asm volatile (
318 " push.w {r4, r5, r6, r7, r8, sb, sl, lr}\n"
319 " mov r5, r0\n"
320 " ldr r0, [r0]\n"
321 " cmp r0, #6\n"
322 " bhi loc_fc063ade\n"
323 " add.w r0, r5, r0, lsl #3\n"
324 " ldrd r7, r6, [r0, #0x14]\n"
325 " cbnz r6, loc_fc063af2\n"
326 " b loc_fc063aec\n"
327 "loc_fc063ade:\n"
328 " movw r2, #0x34a\n"
329 " ldr r1, =0xfc0639f4\n"
330 " movs r0, #0\n"
331 " blx sub_fc2a1670\n"
332 "loc_fc063aec:\n"
333 " movs r0, #7\n"
334 " mov r1, r5\n"
335 " b loc_fc063b60\n"
336 "loc_fc063af2:\n"
337 " ldr.w sl, =0x000220dc\n"
338 " mov.w sb, #0x1000000\n"
339 " mov r4, r6\n"
340 "loc_fc063afc:\n"
341 " ldr r0, [r5, #4]\n"
342 " cmp r4, sb\n"
343 " mov r1, sb\n"
344 " bhi loc_fc063b06\n"
345 " mov r1, r4\n"
346 "loc_fc063b06:\n"
347 " lsls r2, r0, #8\n"
348 " beq loc_fc063b18\n"
349 " bic r0, r0, #0xff000000\n"
350 " rsb.w r0, r0, #0x1000000\n"
351 " cmp r1, r0\n"
352 " bls loc_fc063b18\n"
353 " mov r1, r0\n"
354 "loc_fc063b18:\n"
355 " ldr.w r0, [sl, #4]\n"
356 " mov r8, r1\n"
357 " mov r2, r1\n"
358 " mov r1, r7\n"
359
360
361 " bl fwt_write\n"
362
363 " ldr r1, [r5, #4]\n"
364 " cmp r8, r0\n"
365 " add r1, r0\n"
366 " str r1, [r5, #4]\n"
367 " beq loc_fc063b40\n"
368 " adds r0, r0, #1\n"
369 " bne loc_fc063b38\n"
370 " ldr r0, =0x09200005\n"
371 " b loc_fc063b3c\n"
372 "loc_fc063b38:\n"
373 " ldr r0, =0x09200005\n"
374 " adds r0, #0x10\n"
375 "loc_fc063b3c:\n"
376 " str r0, [r5, #0x10]\n"
377 " b loc_fc063aec\n"
378 "loc_fc063b40:\n"
379 " subs r4, r4, r0\n"
380 " cmp r4, r6\n"
381 " add r7, r0\n"
382 " blo loc_fc063b56\n"
383 " movw r2, #0x375\n"
384 " ldr r1, =0xfc0639f4\n"
385 " movs r0, #0\n"
386 " blx sub_fc2a1670\n"
387 "loc_fc063b56:\n"
388 " cmp r4, #0\n"
389 " bne loc_fc063afc\n"
390 " ldr r0, [r5]\n"
391 " mov r1, r5\n"
392 " adds r0, r0, #1\n"
393 "loc_fc063b60:\n"
394 " pop.w {r4, r5, r6, r7, r8, sb, sl, lr}\n"
395
396
397 " ldr pc,=0xfc0635f1\n"
398
399 ".ltorg\n"
400 );
401 }
402
403
404
405 void __attribute__((naked,noinline)) sub_fc063768_my() {
406 asm volatile (
407 " push {r4, r5, r6, lr}\n"
408 " mov r4, r0\n"
409 " ldr r0, [r0, #0x4c]\n"
410 " ldr r5, =0x000220dc\n"
411 " sub sp, #0x38\n"
412 " lsls r0, r0, #0x1e\n"
413 " bpl loc_fc06384c\n"
414 " ldr r0, [r5, #4]\n"
415 " adds r1, r0, #1\n"
416 " beq loc_fc06379a\n"
417 " ldr r6, =0x09200001\n"
418 " ldr r1, [r4, #0x54]\n"
419 " adds r6, r6, #2\n"
420 " cmp r1, #1\n"
421 " bne loc_fc06378c\n"
422
423 " LDR R3, =current_write_ignored\n"
424 " LDR R3, [R3]\n"
425 " cbnz R3,loc_D\n"
426
427 " bl sub_fc3098ca\n"
428 " b loc_fc063790\n"
429 "loc_fc06378c:\n"
430 "loc_D:\n"
431
432
433 " bl fwt_close\n"
434
435 "loc_fc063790:\n"
436 " cbz r0, loc_fc063794\n"
437 " str r6, [r4, #0x10]\n"
438 "loc_fc063794:\n"
439 " mov.w r0, #-1\n"
440 " str r0, [r5, #4]\n"
441 "loc_fc06379a:\n"
442 " add.w r6, r4, #0x58\n"
443 " ldr r0, [r4, #0x10]\n"
444 " lsls r0, r0, #0x1f\n"
445 " bne loc_fc06383e\n"
446 " ldr r0, [r4, #0x4c]\n"
447 " lsls r1, r0, #0x1f\n"
448 " beq loc_fc0637c6\n"
449 " movw r0, #0x81ff\n"
450 " str r0, [sp, #0x20]\n"
451 " movs r0, #0x20\n"
452 " str r0, [sp, #0x24]\n"
453 " ldr r0, [r4, #4]\n"
454 " str r0, [sp, #0x28]\n"
455 " ldr r0, [r4, #0xc]\n"
456 " str r0, [sp, #0x2c]\n"
457 " ldr r0, [r4, #0xc]\n"
458 " str r0, [sp, #0x30]\n"
459 " ldr r0, [r4, #0xc]\n"
460 " str r0, [sp, #0x34]\n"
461 " b loc_fc0637e8\n"
462 "loc_fc0637c6:\n"
463 " lsls r0, r0, #0x1b\n"
464 " bpl loc_fc0637e8\n"
465 " add r1, sp, #0x20\n"
466 " mov r0, r6\n"
467 " bl sub_fc10da94\n"
468 " cbnz r0, loc_fc0637e0\n"
469 " movs r0, #0\n"
470 " movw r2, #0x3bc\n"
471 " ldr r1, =0xfc0639f4\n"
472 " blx sub_fc2a1670\n"
473 "loc_fc0637e0:\n"
474 " ldr r0, [sp, #0x28]\n"
475 " ldr r1, [r4, #4]\n"
476 " add r0, r1\n"
477 " str r0, [sp, #0x28]\n"
478 "loc_fc0637e8:\n"
479 " ldr r0, [r4, #0x4c]\n"
480 " lsls r0, r0, #0x19\n"
481 " bmi loc_fc0637f6\n"
482 " add r1, sp, #0x20\n"
483 " mov r0, r6\n"
484 " bl sub_fc10db0a\n"
485 "loc_fc0637f6:\n"
486 " ldr r0, [r4, #0x4c]\n"
487 " lsls r0, r0, #0x1a\n"
488 " bpl loc_fc06383e\n"
489 " movs r2, #0x20\n"
490 " mov r1, r6\n"
491 " mov r0, sp\n"
492 " blx sub_fc2a1690\n"
493 " mov r0, sp\n"
494 " bl _strlen\n"
495 " add r0, sp, r0\n"
496 " movs r1, #0x54\n"
497 " strb r1, [r0, #-0x3]!\n"
498 " movs r1, #0x4d\n"
499 " strb r1, [r0, #1]\n"
500 " movs r1, #0x50\n"
501 " strb r1, [r0, #2]\n"
502 " mov r1, sp\n"
503 " mov r0, r6\n"
504 " bl sub_fc0a276e\n"
505 " cbnz r0, loc_fc063832\n"
506 " movs r0, #0\n"
507 " movw r2, #0x167\n"
508 " ldr r1, =0xfc0639f4\n"
509 " blx sub_fc2a1670\n"
510 "loc_fc063832:\n"
511 " mov r0, sp\n"
512 " bl sub_fc10ddfc\n"
513 " mov r0, r6\n"
514 " bl sub_fc10ddfc\n"
515 "loc_fc06383e:\n"
516 " mov r0, r6\n"
517 " bl sub_fc3095b2\n"
518 " ldr r1, [r5, #0x1c]\n"
519 " bl sub_fc06c0c4\n"
520 " b loc_fc063850\n"
521 "loc_fc06384c:\n"
522 " ldr r0, [r5, #0x1c]\n"
523 " blx r0\n"
524 "loc_fc063850:\n"
525 " ldr r1, [r5, #0x14]\n"
526 " cmp r1, #0\n"
527 " beq loc_fc06385a\n"
528 " ldr r0, [r4, #0x10]\n"
529 " blx r1\n"
530 "loc_fc06385a:\n"
531 " add sp, #0x38\n"
532 " pop {r4, r5, r6, pc}\n"
533
534 ".ltorg\n"
535 );
536 }