This source file includes following definitions.
- log_fwt_msg
- log_fwt_start
- filewritetask
- sub_fc068904_my
- sub_fc068e92_my
- sub_fc068a36_my
1 #include "lolevel.h"
2 #include "platform.h"
3
4
5
6
7 extern void _LogCameraEvent(int id,const char *fmt,...);
8
9 typedef struct {
10 unsigned int address;
11 unsigned int length;
12 } cam_ptp_data_chunk;
13
14 #define MAX_CHUNKS_FOR_FWT 7
15
16
17
18
19
20
21
22
23 typedef struct
24 {
25 int unkn1;
26 int file_offset;
27 int maybe_full_size;
28 int unkn2, unkn3;
29 int unkn4;
30 cam_ptp_data_chunk pdc[MAX_CHUNKS_FOR_FWT];
31 int maybe_seek_flag;
32 int unkn5, unkn6;
33 char name[32];
34 } fwt_data_struct;
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 #include "../../../generic/filewrite.c"
91
92 #ifdef FILEWRITE_DEBUG_LOG
93 void log_fwt_msg(fwt_data_struct *fwd)
94 {
95 int m=fwd->unkn1;
96 _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);
97 _LogCameraEvent(0x60,"fw %s",fwd->name);
98 if(m >= 0 && m <=6) {
99 _LogCameraEvent(0x60,"fw chunk adr:0x%08x l:0x%08x",fwd->pdc[m].address,fwd->pdc[m].length);
100 }
101 _LogCameraEvent(0x60,"fw u %08x %08x %08x %08x %08x %08x",fwd->unkn2,fwd->unkn3,fwd->unkn4,fwd->unkn5,fwd->unkn6);
102 }
103
104 void log_fwt_start(void)
105 {
106 _LogCameraEvent(0x60,"fw start");
107 }
108 #endif
109
110
111 void __attribute__((naked,noinline)) filewritetask() {
112 asm volatile (
113
114 " push {r3, r4, r5, r6, r7, lr}\n"
115 " ldr r6, =0x09200001\n"
116 " movw r7, #0x477\n"
117 " ldr r5, =0x0003d674\n"
118 " adds r6, #0x12\n"
119 "loc_fc068b94:\n"
120 " mov r1, sp\n"
121 " movs r2, #0\n"
122 " ldr r0, [r5, #0x14]\n"
123 " blx sub_fc302304\n"
124 " cbz r0, loc_fc068baa\n"
125 " movs r0, #0\n"
126 " mov r2, r7\n"
127 " ldr r1, =0xfc068c54\n"
128 " blx sub_fc302464\n"
129 "loc_fc068baa:\n"
130 #ifdef FILEWRITE_DEBUG_LOG
131 " ldr r0, [sp]\n"
132 "bl log_fwt_msg\n"
133 #endif
134 " ldr r0, [sp]\n"
135 " ldr r1, [r0]\n"
136 " cmp r1, #0xd\n"
137 " bcs loc_fc068b94\n"
138 " tbb.w [pc, r1]\n"
139 "branchtable_fc068bb6:\n"
140 " .byte((loc_fc068bf8 - branchtable_fc068bb6) / 2)\n"
141 " .byte((loc_fc068bf8 - branchtable_fc068bb6) / 2)\n"
142 " .byte((loc_fc068bf8 - branchtable_fc068bb6) / 2)\n"
143 " .byte((loc_fc068bf8 - branchtable_fc068bb6) / 2)\n"
144 " .byte((loc_fc068bf8 - branchtable_fc068bb6) / 2)\n"
145 " .byte((loc_fc068bf8 - branchtable_fc068bb6) / 2)\n"
146 " .byte((loc_fc068bf8 - branchtable_fc068bb6) / 2)\n"
147 " .byte((loc_fc068bfe - branchtable_fc068bb6) / 2)\n"
148 " .byte((loc_fc068bc4 - branchtable_fc068bb6) / 2)\n"
149 " .byte((loc_fc068bd6 - branchtable_fc068bb6) / 2)\n"
150 " .byte((loc_fc068bf2 - branchtable_fc068bb6) / 2)\n"
151 " .byte((loc_fc068bca - branchtable_fc068bb6) / 2)\n"
152 " .byte((loc_fc068bd0 - branchtable_fc068bb6) / 2)\n"
153 ".align 1\n"
154 "loc_fc068bc4:\n"
155 " bl sub_fc068d76\n"
156 " b loc_fc068b94\n"
157 "loc_fc068bca:\n"
158 " bl sub_fc068dc2\n"
159 " b loc_fc068b94\n"
160 "loc_fc068bd0:\n"
161 " bl sub_fc068904_my\n"
162 " b loc_fc068b94\n"
163 "loc_fc068bd6:\n"
164 " ldr r1, [r0, #4]\n"
165 " movs r2, #0\n"
166 " mov r4, r0\n"
167 " ldr r0, [r5, #8]\n"
168 " bl sub_fc37a9fc\n"
169 " adds r0, r0, #1\n"
170 " bne loc_fc068b94\n"
171 " movs r0, #7\n"
172 " mov r1, r4\n"
173 " str r6, [r4, #0x14]\n"
174 " bl sub_fc06888a\n"
175 " b loc_fc068b94\n"
176 "loc_fc068bf2:\n"
177 " bl sub_fc068e20\n"
178 " b loc_fc068b94\n"
179 "loc_fc068bf8:\n"
180 " bl sub_fc068e92_my\n"
181 " b loc_fc068b94\n"
182 "loc_fc068bfe:\n"
183 " bl sub_fc068a36_my\n"
184 " b loc_fc068b94\n"
185 ".ltorg\n"
186 );
187 }
188
189 void __attribute__((naked,noinline)) sub_fc068904_my() {
190 asm volatile (
191 " push.w {r4, r5, r6, r7, r8, sb, lr}\n"
192 " mov r4, r0\n"
193
194
195 " BL filewrite_main_hook\n"
196 " mov r0, r4\n"
197 " ldr r0, [r0, #0x50]\n"
198 " sub sp, #0x3c\n"
199 " lsls r1, r0, #0x1f\n"
200 " bne loc_fc068916\n"
201 " lsls r0, r0, #0x1d\n"
202 " bpl loc_fc068a12\n"
203 "loc_fc068916:\n"
204 " ldr r7, =0x0003d674\n"
205 " ldr r0, [r7, #0x1c]\n"
206 " cbz r0, loc_fc06891e\n"
207 " blx r0\n"
208 "loc_fc06891e:\n"
209 " add.w r0, r4, #0x5c\n"
210 " mov r8, r0\n"
211 " bl sub_fc37a60c\n"
212 " movs r1, #0\n"
213 " bl sub_fc06e242\n"
214 " movs r1, #0\n"
215 " movs r0, #0x47\n"
216 " bl sub_fc35dedc\n"
217 " ldr r0, [r4, #0x50]\n"
218 " lsls r0, r0, #0x1f\n"
219 " beq loc_fc068a12\n"
220 " ldr r0, [r4, #0x10]\n"
221 " bl sub_fc0da40e\n"
222 " ldr r0, [r4, #0x50]\n"
223 " movw r5, #0x301\n"
224 " lsls r1, r0, #0x1b\n"
225 " bpl loc_fc068950\n"
226 " movs r5, #9\n"
227 " b loc_fc068956\n"
228 "loc_fc068950:\n"
229 " lsls r1, r0, #0x19\n"
230 " bpl loc_fc068956\n"
231 " movs r5, #1\n"
232 "loc_fc068956:\n"
233 " lsls r0, r0, #0x1a\n"
234 " bmi loc_fc068960\n"
235 " ldr r0, [r4, #0x58]\n"
236 " cmp r0, #1\n"
237 " bne loc_fc068964\n"
238 "loc_fc068960:\n"
239 " orr r5, r5, #0x8000\n"
240 "loc_fc068964:\n"
241 " movw sb, #0x1b6\n"
242 " ldr r6, [r4, #0x10]\n"
243 " mov r2, sb\n"
244 " mov r1, r5\n"
245 " mov r0, r8\n"
246
247 " bl fwt_open\n"
248 " adds r1, r0, #1\n"
249 " bne loc_fc0689b2\n"
250 " mov r0, r8\n"
251 " bl sub_fc37acba\n"
252 " movs r2, #0xf\n"
253 " mov r1, r8\n"
254 " add r0, sp, #4\n"
255 " blx sub_fc30245c\n"
256 " movs r0, #0\n"
257 " strb.w r0, [sp, #0x13]\n"
258 " movw r1, #0x41ff\n"
259 " str r1, [sp, #0x24]\n"
260 " strd r0, r6, [sp, #0x2c]\n"
261 " movs r1, #0x10\n"
262 " str r6, [sp, #0x34]\n"
263 " add r0, sp, #4\n"
264 " str r6, [sp, #0x38]\n"
265 " str r1, [sp, #0x28]\n"
266 " add r1, sp, #0x24\n"
267 " bl sub_fc10f1fe\n"
268 " mov r2, sb\n"
269 " mov r1, r5\n"
270 " mov r0, r8\n"
271 " bl sub_fc37a916\n"
272 "loc_fc0689b2:\n"
273 " mov r5, r0\n"
274 " str r0, [r7, #8]\n"
275 " adds r0, r0, #1\n"
276 " bne loc_fc0689ea\n"
277 " movs r1, #0\n"
278 " movs r0, #0x48\n"
279 " bl sub_fc35dedc\n"
280 " mov r0, r8\n"
281 " bl sub_fc37a60c\n"
282 " ldr r1, [r7, #0x20]\n"
283 " bl sub_fc06e2a0\n"
284 " ldr r0, [r7, #0x18]\n"
285 " cmp r0, #0\n"
286 " beq loc_fc068a30\n"
287 " ldr r5, =0x09200001\n"
288 " mov r0, r4\n"
289 " mov r1, r5\n"
290 " bl sub_fc068850\n"
291 " ldr r1, [r7, #0x18]\n"
292 " add sp, #0x3c\n"
293 " mov r0, r5\n"
294 " pop.w {r4, r5, r6, r7, r8, sb, lr}\n"
295 " bx r1\n"
296 "loc_fc0689ea:\n"
297 " ldr r0, =0x0023be20\n"
298 " movs r2, #0x20\n"
299 " mov r1, r8\n"
300 " blx sub_fc302444\n"
301
302
303 " LDR R3, =current_write_ignored\n"
304 " LDR R3, [R3]\n"
305 " cbnz r3,loc_C\n"
306
307 " ldr r0, [r4, #0x50]\n"
308 " lsls r0, r0, #0x18\n"
309 " bpl loc_fc068a12\n"
310 " ldr r1, [r4, #0xc]\n"
311 " mov r0, r5\n"
312 " bl sub_fc37aad0\n"
313 " cbnz r0, loc_fc068a10\n"
314 " ldr r0, =0x09200001\n"
315 " mov r1, r4\n"
316 " adds r0, #0x16\n"
317 " str r0, [r4, #0x14]\n"
318 " movs r0, #7\n"
319 " b loc_fc068a28\n"
320 "loc_fc068a10:\n"
321 " b loc_fc068a12\n"
322 "loc_fc068a12:\n"
323 "loc_C:\n"
324 " ldr r0, [r4, #0x50]\n"
325 " lsls r0, r0, #0x19\n"
326 " bmi loc_fc068a1c\n"
327 " ldr r0, [r4, #4]\n"
328 " cbz r0, loc_fc068a24\n"
329 "loc_fc068a1c:\n"
330 " movs r0, #9\n"
331 " mov r1, r4\n"
332 " bl sub_fc06888a\n"
333 "loc_fc068a24:\n"
334 " movs r0, #0\n"
335 " mov r1, r4\n"
336 "loc_fc068a28:\n"
337 " add sp, #0x3c\n"
338 " pop.w {r4, r5, r6, r7, r8, sb, lr}\n"
339
340 " ldr pc, =0xfc06888b\n"
341 "loc_fc068a30:\n"
342 " add sp, #0x3c\n"
343 " pop.w {r4, r5, r6, r7, r8, sb, pc}\n"
344 ".ltorg\n"
345 );
346 }
347
348
349 void __attribute__((naked,noinline)) sub_fc068e92_my() {
350 asm volatile (
351 " push.w {r4, r5, r6, r7, r8, sb, sl, lr}\n"
352 " mov r5, r0\n"
353 " ldr r0, [r0]\n"
354 " cmp r0, #6\n"
355 " bhi loc_fc068eaa\n"
356 " add.w r0, r5, r0, lsl #3\n"
357 " ldrd r7, r6, [r0, #0x18]\n"
358 " cbnz r6, loc_fc068ebe\n"
359 " b loc_fc068eb8\n"
360 "loc_fc068eaa:\n"
361 " movw r2, #0x3b4\n"
362 " ldr r1, =0xfc068c54\n"
363 " movs r0, #0\n"
364 " blx sub_fc302464\n"
365 "loc_fc068eb8:\n"
366 " movs r0, #7\n"
367 " mov r1, r5\n"
368 " b loc_fc068f2e\n"
369 "loc_fc068ebe:\n"
370 " ldr.w sl, =0x0003d674\n"
371 " mov.w sb, #0x1000000\n"
372 " mov r4, r6\n"
373 "loc_fc068ec8:\n"
374 " ldr r0, [r5, #4]\n"
375 " cmp r4, sb\n"
376 " mov r1, sb\n"
377 " bhi loc_fc068ed2\n"
378 " mov r1, r4\n"
379 "loc_fc068ed2:\n"
380 " lsls r2, r0, #8\n"
381 " beq loc_fc068ee4\n"
382 " bic r0, r0, #0xff000000\n"
383 " rsb.w r0, r0, #0x1000000\n"
384 " cmp r1, r0\n"
385 " bls loc_fc068ee4\n"
386 " mov r1, r0\n"
387 "loc_fc068ee4:\n"
388 " ldr.w r0, [sl, #8]\n"
389 " mov r8, r1\n"
390 " mov r2, r1\n"
391 " mov r1, r7\n"
392
393 " bl fwt_write\n"
394 " ldr r1, [r5, #4]\n"
395 " cmp r8, r0\n"
396 " add r1, r0\n"
397 " str r1, [r5, #4]\n"
398 " beq loc_fc068f0e\n"
399 " adds r0, r0, #1\n"
400 " bne loc_fc068f06\n"
401 " ldr r0, =0x09200006\n"
402 " subs r0, r0, #1\n"
403 " b loc_fc068f0a\n"
404 "loc_fc068f06:\n"
405 " ldr r0, =0x09200006\n"
406 " adds r0, #0xf\n"
407 "loc_fc068f0a:\n"
408 " str r0, [r5, #0x14]\n"
409 " b loc_fc068eb8\n"
410 "loc_fc068f0e:\n"
411 " subs r4, r4, r0\n"
412 " cmp r4, r6\n"
413 " add r7, r0\n"
414 " blo loc_fc068f24\n"
415 " movw r2, #0x3de\n"
416 " ldr r1, =0xfc068c54\n"
417 " movs r0, #0\n"
418 " blx sub_fc302464\n"
419 "loc_fc068f24:\n"
420 " cmp r4, #0\n"
421 " bne loc_fc068ec8\n"
422 " ldr r0, [r5]\n"
423 " mov r1, r5\n"
424 " adds r0, r0, #1\n"
425 "loc_fc068f2e:\n"
426 " pop.w {r4, r5, r6, r7, r8, sb, sl, lr}\n"
427
428 " ldr pc,=0xfc06888b\n"
429 ".ltorg\n"
430 );
431 }
432
433
434 void __attribute__((naked,noinline)) sub_fc068a36_my() {
435 asm volatile (
436 "loc_fc068a36:\n"
437 " push {r4, r5, r6, r7, lr}\n"
438 " mov r4, r0\n"
439 " ldr r0, [r0, #0x50]\n"
440 " ldr r5, =0x0003d674\n"
441 " sub sp, #0x3c\n"
442 " add.w r7, r4, #0x5c\n"
443 " lsls r1, r0, #0x1e\n"
444 " bmi loc_fc068a4e\n"
445 " lsls r0, r0, #0x1c\n"
446 " bpl loc_fc068b4a\n"
447 " b loc_fc068aa2\n"
448 "loc_fc068a4e:\n"
449 " lsls r0, r0, #0x18\n"
450 " bpl loc_fc068a7e\n"
451 " ldrd r1, r0, [r4, #8]\n"
452 " cmp r1, r0\n"
453 " beq loc_fc068a7e\n"
454 " ldr r0, [r5, #8]\n"
455 " bl sub_fc37aad0\n"
456 " cbnz r0, loc_fc068a6a\n"
457 " ldr r0, =0x09200001\n"
458 " adds r0, #0x16\n"
459 " str r0, [r4, #0x14]\n"
460 " b loc_fc068a7e\n"
461 "loc_fc068a6a:\n"
462 " ldr r0, [r4, #8]\n"
463 " add r1, sp, #0x24\n"
464 " str r0, [r4, #4]\n"
465 " mov r0, r7\n"
466 " bl sub_fc10f188\n"
467 " cmp r0, #1\n"
468 " bne loc_fc068a7e\n"
469 " ldr r0, [r4, #4]\n"
470 " str r0, [sp, #0x2c]\n"
471 "loc_fc068a7e:\n"
472 " ldr r0, [r5, #8]\n"
473 " adds r1, r0, #1\n"
474 " beq loc_fc068aa2\n"
475 " ldr r6, =0x09200001\n"
476 " ldr r1, [r4, #0x58]\n"
477 " adds r6, r6, #2\n"
478 " cmp r1, #1\n"
479 " bne loc_fc068a94\n"
480
481 " LDR R3, =current_write_ignored\n"
482 " LDR R3, [R3]\n"
483 " cbnz R3,loc_D\n"
484
485 " bl sub_fc37a91a\n"
486 " b loc_fc068a98\n"
487 "loc_fc068a94:\n"
488 "loc_D:\n"
489
490 " bl fwt_close\n"
491 "loc_fc068a98:\n"
492 " cbz r0, loc_fc068a9c\n"
493 " str r6, [r4, #0x14]\n"
494 "loc_fc068a9c:\n"
495 " mov.w r0, #-1\n"
496 " str r0, [r5, #8]\n"
497 "loc_fc068aa2:\n"
498 " ldr r0, [r4, #0x14]\n"
499 " lsls r0, r0, #0x1f\n"
500 " bne loc_fc068b56\n"
501 " ldr r0, [r4, #0x50]\n"
502 " lsls r1, r0, #0x1f\n"
503 " beq loc_fc068aca\n"
504 " movw r0, #0x81ff\n"
505 " str r0, [sp, #0x24]\n"
506 " movs r0, #0x20\n"
507 " str r0, [sp, #0x28]\n"
508 " ldr r0, [r4, #4]\n"
509 " str r0, [sp, #0x2c]\n"
510 " ldr r0, [r4, #0x10]\n"
511 " str r0, [sp, #0x30]\n"
512 " ldr r0, [r4, #0x10]\n"
513 " str r0, [sp, #0x34]\n"
514 " ldr r0, [r4, #0x10]\n"
515 " str r0, [sp, #0x38]\n"
516 " b loc_fc068aec\n"
517 "loc_fc068aca:\n"
518 " lsls r0, r0, #0x1b\n"
519 " bpl loc_fc068af2\n"
520 " add r1, sp, #0x24\n"
521 " mov r0, r7\n"
522 " bl sub_fc10f188\n"
523 " cbnz r0, loc_fc068ae4\n"
524 " movs r0, #0\n"
525 " movw r2, #0x43a\n"
526 " ldr r1, =0xfc068c54\n"
527 " blx sub_fc302464\n"
528 "loc_fc068ae4:\n"
529 " ldr r0, [sp, #0x2c]\n"
530 " ldr r1, [r4, #4]\n"
531 " add r0, r1\n"
532 " str r0, [sp, #0x2c]\n"
533 "loc_fc068aec:\n"
534 " ldr r0, [r4, #0x50]\n"
535 " lsls r0, r0, #0x1f\n"
536 " bne loc_fc068afc\n"
537 "loc_fc068af2:\n"
538 " ldr r0, [r4, #0x50]\n"
539 " lsls r1, r0, #0x1e\n"
540 " bmi loc_fc068afc\n"
541 " lsls r0, r0, #0x1b\n"
542 " bpl loc_fc068b56\n"
543 "loc_fc068afc:\n"
544 " add r1, sp, #0x24\n"
545 " mov r0, r7\n"
546 " bl sub_fc10f1fe\n"
547 " ldr r0, [r4, #0x50]\n"
548 " lsls r1, r0, #0x1e\n"
549 " bpl loc_fc068b56\n"
550 " lsls r0, r0, #0x1a\n"
551 " bpl loc_fc068b56\n"
552 " movs r2, #0x20\n"
553 " mov r1, r7\n"
554 " add r0, sp, #4\n"
555 " blx sub_fc302444\n"
556 " add r0, sp, #4\n"
557 " bl sub_fc380402\n"
558 " add r2, sp, #4\n"
559 " add r0, r2\n"
560 " movs r1, #0x54\n"
561 " strb r1, [r0, #-0x3]!\n"
562 " movs r1, #0x4d\n"
563 " strb r1, [r0, #1]\n"
564 " movs r1, #0x50\n"
565 " strb r1, [r0, #2]\n"
566 " add r1, sp, #4\n"
567 " mov r0, r7\n"
568 " bl sub_fc0da5e6\n"
569 " cbnz r0, loc_fc068b46\n"
570 " movs r0, #0\n"
571 " movw r2, #0x1bd\n"
572 " ldr r1, =0xfc068c54\n"
573 " blx sub_fc302464\n"
574 "loc_fc068b46:\n"
575 " add r0, sp, #4\n"
576 " b loc_fc068b4c\n"
577 "loc_fc068b4a:\n"
578 " b loc_fc068b6c\n"
579 "loc_fc068b4c:\n"
580 " bl sub_fc10f4f0\n"
581 " mov r0, r7\n"
582 " bl sub_fc10f4f0\n"
583 "loc_fc068b56:\n"
584 " movs r1, #0\n"
585 " movs r0, #0x48\n"
586 " bl sub_fc35dedc\n"
587 " mov r0, r7\n"
588 " bl sub_fc37a60c\n"
589 " ldr r1, [r5, #0x20]\n"
590 " bl sub_fc06e2a0\n"
591 " b loc_fc068b70\n"
592 "loc_fc068b6c:\n"
593 " ldr r0, [r5, #0x20]\n"
594 " blx r0\n"
595 "loc_fc068b70:\n"
596 " ldr r0, [r5, #0x18]\n"
597 " cmp r0, #0\n"
598 " beq loc_fc068b84\n"
599 " ldr r1, [r4, #0x14]\n"
600 " mov r0, r4\n"
601 " bl sub_fc068850\n"
602 " ldr r1, [r5, #0x18]\n"
603 " ldr r0, [r4, #0x14]\n"
604 " blx r1\n"
605 "loc_fc068b84:\n"
606 " add sp, #0x3c\n"
607 " pop {r4, r5, r6, r7, pc}\n"
608 ".ltorg\n"
609 );
610 }
611