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, =0x0003d64c\n"
118 " adds r6, #0x12\n"
119 " loc_fc068b94:\n"
120 " mov r1, sp\n"
121 " movs r2, #0\n"
122 " ldr r0, [r5,#20]\n"
123 " blx sub_fc3022b0\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_fc302410\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_fc068bb2:\n"
140 " .byte((loc_fc068bf8 - branchtable_fc068bb2) / 2)\n"
141 " .byte((loc_fc068bf8 - branchtable_fc068bb2) / 2)\n"
142 " .byte((loc_fc068bf8 - branchtable_fc068bb2) / 2)\n"
143 " .byte((loc_fc068bf8 - branchtable_fc068bb2) / 2)\n"
144 " .byte((loc_fc068bf8 - branchtable_fc068bb2) / 2)\n"
145 " .byte((loc_fc068bf8 - branchtable_fc068bb2) / 2)\n"
146 " .byte((loc_fc068bf8 - branchtable_fc068bb2) / 2)\n"
147 " .byte((loc_fc068bfe - branchtable_fc068bb2) / 2)\n"
148 " .byte((loc_fc068bc4 - branchtable_fc068bb2) / 2)\n"
149 " .byte((loc_fc068bd6 - branchtable_fc068bb2) / 2)\n"
150 " .byte((loc_fc068bf2 - branchtable_fc068bb2) / 2)\n"
151 " .byte((loc_fc068bca - branchtable_fc068bb2) / 2)\n"
152 " .byte((loc_fc068bd0 - branchtable_fc068bb2) / 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_fc37a65c\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, r9, 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, 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, =0x0003d64c\n"
205 " ldr r0, [r7,#28]\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_fc37a26c\n"
212 " movs r1, #0\n"
213 " bl sub_fc06e242\n"
214 " movs r1, #0\n"
215 " movs r0, #0x47\n"
216 " bl sub_fc35dcc0\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.w r5, r5, #0x8000\n"
240 " loc_fc068964:\n"
241 " movw r9, #0x1b6\n"
242 " ldr r6, [r4,#0x10]\n"
243 " mov r2, r9\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_fc37a91a\n"
252 " movs r2, #0xf\n"
253 " mov r1, r8\n"
254 " add r0, sp, #4\n"
255 " blx sub_fc302408\n"
256 " movs r0, #0\n"
257 " strb.w r0, [sp,#19]\n"
258 " movw r1, #0x41ff\n"
259 " str r1, [sp,#36]\n"
260 " strd.w r0, r6, [sp,#0x2c]\n"
261 " movs r1, #0x10\n"
262 " str r6, [sp,#52]\n"
263 " add r0, sp, #4\n"
264 " str r6, [sp,#56]\n"
265 " str r1, [sp,#40]\n"
266 " add r1, sp, #36\n"
267 " bl sub_fc10f10e\n"
268 " mov r2, r9\n"
269 " mov r1, r5\n"
270 " mov r0, r8\n"
271 " bl sub_fc37a576\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_fc35dcc0\n"
280 " mov r0, r8\n"
281 " bl sub_fc37a26c\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, sp, #0x3c\n"
293 " mov r0, r5\n"
294 " pop.w {r4, r5, r6, r7, r8, r9,lr}\n"
295 " bx r1\n"
296 " loc_fc0689ea:\n"
297 " ldr r0, =0x0023bddc\n"
298 " movs r2, #0x20\n"
299 " mov r1, r8\n"
300 " blx sub_fc3023f0\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_fc37a730\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, sp, #0x3c\n"
338 " pop.w {r4, r5, r6, r7, r8, r9,lr}\n"
339
340 " ldr pc, =0xfc06888b\n"
341 " loc_fc068a30:\n"
342 " add sp, sp, #0x3c\n"
343 " pop.w {r4, r5, r6, r7, r8,r9,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, r9, r10, 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.w 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_fc302410\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 r10, =0x0003d64c\n"
371 " mov.w r9, #0x1000000\n"
372 " mov r4, r6\n"
373 " loc_fc068ec8:\n"
374 " ldr r0, [r5,#4]\n"
375 " cmp r4, r9\n"
376 " mov r1, r9\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.w 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, [r10,#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, =0x9200006\n"
402 " subs r0, r0, #1\n"
403 " b loc_fc068f0a\n"
404 " loc_fc068f06:\n"
405 " ldr r0, =0x9200006\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 " bcc loc_fc068f24\n"
415 " movw r2, #0x3de\n"
416 " ldr r1, =0xfc068c54\n"
417 " movs r0, #0\n"
418 " blx sub_fc302410\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, r9, r10, 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 " push {r4, r5, r6, r7, lr}\n"
437 " mov r4, r0\n"
438 " ldr r0, [r0,#0x50]\n"
439 " ldr r5, =0x0003d64c\n"
440 " sub sp, sp, #0x3c\n"
441 " add.w r7, r4, #0x5c\n"
442 " lsls r1, r0, #0x1e\n"
443 " bmi loc_fc068a4e\n"
444 " lsls r0, r0, #0x1c\n"
445 " bpl loc_fc068b4a\n"
446 " b loc_fc068aa2\n"
447 " loc_fc068a4e:\n"
448 " lsls r0, r0, #0x18\n"
449 " bpl loc_fc068a7e\n"
450 " ldrd.w r1, r0, [r4,#8]\n"
451 " cmp r1, r0\n"
452 " beq loc_fc068a7e\n"
453 " ldr r0, [r5,#8]\n"
454 " bl sub_fc37a730\n"
455 " cbnz r0, loc_fc068a6a\n"
456 " ldr r0, =0x09200001\n"
457 " adds r0, #0x16\n"
458 " str r0, [r4,#0x14]\n"
459 " b loc_fc068a7e\n"
460 " loc_fc068a6a:\n"
461 " ldr r0, [r4,#8]\n"
462 " add r1, sp, #36\n"
463 " str r0, [r4,#4]\n"
464 " mov r0, r7\n"
465 " bl sub_fc10f098\n"
466 " cmp r0, #1\n"
467 " bne loc_fc068a7e\n"
468 " ldr r0, [r4,#4]\n"
469 " str r0, [sp,#44]\n"
470 " loc_fc068a7e:\n"
471 " ldr r0, [r5,#8]\n"
472 " adds r1, r0, #1\n"
473 " beq loc_fc068aa2\n"
474 " ldr r6, =0x09200001\n"
475 " ldr r1, [r4,#0x58]\n"
476 " adds r6, r6, #2\n"
477 " cmp r1, #1\n"
478 " bne loc_fc068a94\n"
479
480 " LDR R3, =current_write_ignored\n"
481 " LDR R3, [R3]\n"
482 " cbnz R3,loc_D\n"
483
484 " bl sub_fc37a57a\n"
485 " b loc_fc068a98\n"
486 " loc_fc068a94:\n"
487 "loc_D:\n"
488
489 " bl fwt_close\n"
490 " loc_fc068a98:\n"
491 " cbz r0, loc_fc068a9c\n"
492 " str r6, [r4,#0x14]\n"
493 " loc_fc068a9c:\n"
494 " mov.w r0, #0xffffffff\n"
495 " str r0, [r5,#8]\n"
496 " loc_fc068aa2:\n"
497 " ldr r0, [r4,#0x14]\n"
498 " lsls r0, r0, #0x1f\n"
499 " bne loc_fc068b56\n"
500 " ldr r0, [r4,#0x50]\n"
501 " lsls r1, r0, #0x1f\n"
502 " beq loc_fc068aca\n"
503 " movw r0, #0x81ff\n"
504 " str r0, [sp,#36]\n"
505 " movs r0, #0x20\n"
506 " str r0, [sp,#40]\n"
507 " ldr r0, [r4,#4]\n"
508 " str r0, [sp,#44]\n"
509 " ldr r0, [r4,#0x10]\n"
510 " str r0, [sp,#48]\n"
511 " ldr r0, [r4,#0x10]\n"
512 " str r0, [sp,#52]\n"
513 " ldr r0, [r4,#0x10]\n"
514 " str r0, [sp,#56]\n"
515 " b loc_fc068aec\n"
516 " loc_fc068aca:\n"
517 " lsls r0, r0, #0x1b\n"
518 " bpl loc_fc068af2\n"
519 " add r1, sp, #36\n"
520 " mov r0, r7\n"
521 " bl sub_fc10f098\n"
522 " cbnz r0, loc_fc068ae4\n"
523 " movs r0, #0\n"
524 " movw r2, #0x43a\n"
525 " ldr r1, =0xfc068c54\n"
526 " blx sub_fc302410\n"
527 " loc_fc068ae4:\n"
528 " ldr r0, [sp,#44]\n"
529 " ldr r1, [r4,#4]\n"
530 " add r0, r1\n"
531 " str r0, [sp,#44]\n"
532 " loc_fc068aec:\n"
533 " ldr r0, [r4,#0x50]\n"
534 " lsls r0, r0, #0x1f\n"
535 " bne loc_fc068afc\n"
536 " loc_fc068af2:\n"
537 " ldr r0, [r4,#0x50]\n"
538 " lsls r1, r0, #0x1e\n"
539 " bmi loc_fc068afc\n"
540 " lsls r0, r0, #0x1b\n"
541 " bpl loc_fc068b56\n"
542 " loc_fc068afc:\n"
543 " add r1, sp, #36\n"
544 " mov r0, r7\n"
545 " bl sub_fc10f10e\n"
546 " ldr r0, [r4,#0x50]\n"
547 " lsls r1, r0, #0x1e\n"
548 " bpl loc_fc068b56\n"
549 " lsls r0, r0, #0x1a\n"
550 " bpl loc_fc068b56\n"
551 " movs r2, #0x20\n"
552 " mov r1, r7\n"
553 " add r0, sp, #4\n"
554 " blx sub_fc3023f0\n"
555 " add r0, sp, #4\n"
556 " bl sub_fc380062\n"
557 " add r2, sp, #4\n"
558 " add r0, r2\n"
559 " movs r1, #0x54\n"
560 " strb.w r1, [r0,#-3]!\n"
561 " movs r1, #0x4d\n"
562 " strb r1, [r0,#1]\n"
563 " movs r1, #0x50\n"
564 " strb r1, [r0,#2]\n"
565 " add r1, sp, #4\n"
566 " mov r0, r7\n"
567 " bl sub_fc0da5e6\n"
568 " cbnz r0, loc_fc068b46\n"
569 " movs r0, #0\n"
570 " movw r2, #0x1bd\n"
571 " ldr r1, =0xfc068c54\n"
572 " blx sub_fc302410\n"
573 " loc_fc068b46:\n"
574 " add r0, sp, #4\n"
575 " b loc_fc068b4c\n"
576 " loc_fc068b4a:\n"
577 " b loc_fc068b6c\n"
578 " loc_fc068b4c:\n"
579 " bl sub_fc10f400\n"
580 " mov r0, r7\n"
581 " bl sub_fc10f400\n"
582 " loc_fc068b56:\n"
583 " movs r1, #0\n"
584 " movs r0, #0x48\n"
585 " bl sub_fc35dcc0\n"
586 " mov r0, r7\n"
587 " bl sub_fc37a26c\n"
588 " ldr r1, [r5,#0x20]\n"
589 " bl sub_fc06e2a0\n"
590 " b loc_fc068b70\n"
591 " loc_fc068b6c:\n"
592 " ldr r0, [r5,#32]\n"
593 " blx r0\n"
594 " loc_fc068b70:\n"
595 " ldr r0, [r5,#0x18]\n"
596 " cmp r0, #0\n"
597 " beq loc_fc068b84\n"
598 " ldr r1, [r4,#0x14]\n"
599 " mov r0, r4\n"
600 " bl sub_fc068850\n"
601 " ldr r1, [r5,#0x18]\n"
602 " ldr r0, [r4,#0x14]\n"
603 " blx r1\n"
604 " loc_fc068b84:\n"
605 " add sp, sp, #0x3c\n"
606 " pop {r4, r5, r6, r7, pc}\n"
607 ".ltorg\n"
608 );
609 }
610