This source file includes following definitions.
- log_fwt_msg
- log_fwt_start
- filewritetask
- sub_fc3f7a0c_my
- sub_fc3f7f9a_my
- sub_fc3f7b3e_my
1 #include "lolevel.h"
2 #include "platform.h"
3
4
5 extern void _LogCameraEvent(int id,const char *fmt,...);
6
7 typedef struct {
8 unsigned int address;
9 unsigned int length;
10 } cam_ptp_data_chunk;
11
12 #define MAX_CHUNKS_FOR_FWT 7
13
14
15
16
17
18
19
20
21 typedef struct
22 {
23 int unkn1;
24 int file_offset;
25 int maybe_full_size;
26 int unkn2, unkn3;
27 int unkn4;
28 cam_ptp_data_chunk pdc[MAX_CHUNKS_FOR_FWT];
29 int maybe_seek_flag;
30 int unkn5, unkn6;
31 char name[32];
32 } fwt_data_struct;
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50 #include "../../../generic/filewrite.c"
51
52 #ifdef FILEWRITE_DEBUG_LOG
53 void log_fwt_msg(fwt_data_struct *fwd)
54 {
55 int m=fwd->unkn1;
56 _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);
57 _LogCameraEvent(0x60,"fw %s",fwd->name);
58 if(m >= 0 && m <=6) {
59 _LogCameraEvent(0x60,"fw chunk adr:0x%08x l:0x%08x",fwd->pdc[m].address,fwd->pdc[m].length);
60 }
61 _LogCameraEvent(0x60,"fw u %08x %08x %08x %08x %08x %08x",fwd->unkn2,fwd->unkn3,fwd->unkn4,fwd->unkn5,fwd->unkn6);
62 }
63
64 void log_fwt_start(void)
65 {
66 _LogCameraEvent(0x60,"fw start");
67 }
68 #endif
69
70
71
72 void __attribute__((naked,noinline)) filewritetask() {
73 asm volatile (
74
75 " push {r3, r4, r5, r6, r7, lr}\n"
76 #ifdef FILEWRITE_DEBUG_LOG
77 "bl log_fwt_start\n"
78 #endif
79 " ldr r6, =0x09200001\n"
80 " movw r7, #0x477\n"
81 " ldr r5, =0x0002008c\n"
82 " adds r6, #0x12\n"
83 "loc_fc3f7c9c:\n"
84 " mov r1, sp\n"
85 " movs r2, #0\n"
86 " ldr r0, [r5, #0x14]\n"
87 " blx sub_fc2c7ca0\n"
88 " cbz r0, loc_fc3f7cb2\n"
89 " movs r0, #0\n"
90 " mov r2, r7\n"
91 " ldr r1, =0xfc3f7d5c\n"
92 " blx sub_fc2c7de0\n"
93 "loc_fc3f7cb2:\n"
94 #ifdef FILEWRITE_DEBUG_LOG
95 "ldr r0, [sp]\n"
96 "bl log_fwt_msg\n"
97 #endif
98 " ldr r0, [sp]\n"
99 " ldr r1, [r0]\n"
100 " cmp r1, #0xd\n"
101 " bhs loc_fc3f7c9c\n"
102 " tbb [pc, r1]\n"
103 "branchtable_fc3f7cbe:\n"
104 " .byte((loc_fc3f7d00 - branchtable_fc3f7cbe) / 2)\n"
105 " .byte((loc_fc3f7d00 - branchtable_fc3f7cbe) / 2)\n"
106 " .byte((loc_fc3f7d00 - branchtable_fc3f7cbe) / 2)\n"
107 " .byte((loc_fc3f7d00 - branchtable_fc3f7cbe) / 2)\n"
108 " .byte((loc_fc3f7d00 - branchtable_fc3f7cbe) / 2)\n"
109 " .byte((loc_fc3f7d00 - branchtable_fc3f7cbe) / 2)\n"
110 " .byte((loc_fc3f7d00 - branchtable_fc3f7cbe) / 2)\n"
111 " .byte((loc_fc3f7d06 - branchtable_fc3f7cbe) / 2)\n"
112 " .byte((loc_fc3f7ccc - branchtable_fc3f7cbe) / 2)\n"
113 " .byte((loc_fc3f7cde - branchtable_fc3f7cbe) / 2)\n"
114 " .byte((loc_fc3f7cfa - branchtable_fc3f7cbe) / 2)\n"
115 " .byte((loc_fc3f7cd2 - branchtable_fc3f7cbe) / 2)\n"
116 " .byte((loc_fc3f7cd8 - branchtable_fc3f7cbe) / 2)\n"
117 ".align 1\n"
118 "loc_fc3f7ccc:\n"
119 " bl sub_fc3f7e7e\n"
120 " b loc_fc3f7c9c\n"
121 "loc_fc3f7cd2:\n"
122 " bl sub_fc3f7eca\n"
123 " b loc_fc3f7c9c\n"
124 "loc_fc3f7cd8:\n"
125 " bl sub_fc3f7a0c_my\n"
126 " b loc_fc3f7c9c\n"
127 "loc_fc3f7cde:\n"
128 " ldr r1, [r0, #4]\n"
129 " movs r2, #0\n"
130 " mov r4, r0\n"
131 " ldr r0, [r5, #8]\n"
132 " bl _lseek\n"
133 " adds r0, r0, #1\n"
134 " bne loc_fc3f7c9c\n"
135 " movs r0, #7\n"
136 " mov r1, r4\n"
137 " str r6, [r4, #0x14]\n"
138 " bl sub_fc3f7992\n"
139 " b loc_fc3f7c9c\n"
140 "loc_fc3f7cfa:\n"
141 " bl sub_fc3f7f28\n"
142 " b loc_fc3f7c9c\n"
143 "loc_fc3f7d00:\n"
144 " bl sub_fc3f7f9a_my\n"
145 " b loc_fc3f7c9c\n"
146 "loc_fc3f7d06:\n"
147 " bl sub_fc3f7b3e_my\n"
148 " b loc_fc3f7c9c\n"
149 ".ltorg\n"
150 );
151 }
152
153
154
155 void __attribute__((naked,noinline)) sub_fc3f7a0c_my() {
156 asm volatile (
157 " push.w {r4, r5, r6, r7, r8, sb, lr}\n"
158 " mov r4, r0\n"
159
160
161 " bl filewrite_main_hook\n"
162 " mov r0, r4\n"
163 " ldr r0, [r0, #0x50]\n"
164 " sub sp, #0x3c\n"
165 " lsls r1, r0, #0x1f\n"
166 " bne loc_fc3f7a1e\n"
167 " lsls r0, r0, #0x1d\n"
168 " bpl loc_fc3f7b1a\n"
169 "loc_fc3f7a1e:\n"
170 " ldr r7, =0x0002008c\n"
171 " ldr r0, [r7, #0x1c]\n"
172 " cbz r0, loc_fc3f7a26\n"
173 " blx r0\n"
174 "loc_fc3f7a26:\n"
175 " add.w r0, r4, #0x5c\n"
176 " mov r8, r0\n"
177 " bl sub_fc316ffc\n"
178 " movs r1, #0\n"
179 " bl sub_fc0710aa\n"
180 " movs r1, #0\n"
181 " movs r0, #0x47\n"
182 " bl sub_fc305b50\n"
183 " ldr r0, [r4, #0x50]\n"
184 " lsls r0, r0, #0x1f\n"
185 " beq loc_fc3f7b1a\n"
186 " ldr r0, [r4, #0x10]\n"
187 " bl sub_fc16fd22\n"
188 " ldr r0, [r4, #0x50]\n"
189 " movw r5, #0x301\n"
190 " lsls r1, r0, #0x1b\n"
191 " bpl loc_fc3f7a58\n"
192 " movs r5, #9\n"
193 " b loc_fc3f7a5e\n"
194 "loc_fc3f7a58:\n"
195 " lsls r1, r0, #0x19\n"
196 " bpl loc_fc3f7a5e\n"
197 " movs r5, #1\n"
198 "loc_fc3f7a5e:\n"
199 " lsls r0, r0, #0x1a\n"
200 " bmi loc_fc3f7a68\n"
201 " ldr r0, [r4, #0x58]\n"
202 " cmp r0, #1\n"
203 " bne loc_fc3f7a6c\n"
204 "loc_fc3f7a68:\n"
205 " orr r5, r5, #0x8000\n"
206 "loc_fc3f7a6c:\n"
207 " movw sb, #0x1b6\n"
208 " ldr r6, [r4, #0x10]\n"
209 " mov r2, sb\n"
210 " mov r1, r5\n"
211 " mov r0, r8\n"
212
213 " bl fwt_open\n"
214 " adds r1, r0, #1\n"
215 " bne loc_fc3f7aba\n"
216 " mov r0, r8\n"
217 " bl sub_fc317616\n"
218 " movs r2, #0xf\n"
219 " mov r1, r8\n"
220 " add r0, sp, #4\n"
221 " blx sub_fc2c7d80\n"
222 " movs r0, #0\n"
223 " strb.w r0, [sp, #0x13]\n"
224 " movw r1, #0x41ff\n"
225 " str r1, [sp, #0x24]\n"
226 " strd r0, r6, [sp, #0x2c]\n"
227 " movs r1, #0x10\n"
228 " str r6, [sp, #0x34]\n"
229 " add r0, sp, #4\n"
230 " str r6, [sp, #0x38]\n"
231 " str r1, [sp, #0x28]\n"
232 " add r1, sp, #0x24\n"
233 " bl sub_fc1702ca\n"
234 " mov r2, sb\n"
235 " mov r1, r5\n"
236 " mov r0, r8\n"
237 " bl _Open\n"
238 "loc_fc3f7aba:\n"
239 " mov r5, r0\n"
240 " str r0, [r7, #8]\n"
241 " adds r0, r0, #1\n"
242 " bne loc_fc3f7af2\n"
243 " movs r1, #0\n"
244 " movs r0, #0x48\n"
245 " bl sub_fc305b50\n"
246 " mov r0, r8\n"
247 " bl sub_fc316ffc\n"
248 " ldr r1, [r7, #0x20]\n"
249 " bl sub_fc071108\n"
250 " ldr r0, [r7, #0x18]\n"
251 " cmp r0, #0\n"
252 " beq loc_fc3f7b38\n"
253 " ldr r5, =0x09200001\n"
254 " mov r0, r4\n"
255 " mov r1, r5\n"
256 " bl sub_fc3f7958\n"
257 " ldr r1, [r7, #0x18]\n"
258 " add sp, #0x3c\n"
259 " mov r0, r5\n"
260 " pop.w {r4, r5, r6, r7, r8, sb, lr}\n"
261 " bx r1\n"
262 "loc_fc3f7af2:\n"
263 " ldr r0, =0x001c7acc\n"
264 " movs r2, #0x20\n"
265 " mov r1, r8\n"
266 " blx sub_fc2c7d78\n"
267
268
269 " LDR R3, =current_write_ignored\n"
270 " LDR R3, [R3]\n"
271 " cbnz r3,loc_C\n"
272
273 " ldr r0, [r4, #0x50]\n"
274 " lsls r0, r0, #0x18\n"
275 " bpl loc_fc3f7b1a\n"
276 " ldr r1, [r4, #0xc]\n"
277 " mov r0, r5\n"
278 " bl sub_fc31742c\n"
279 " cbnz r0, loc_fc3f7b18\n"
280 " ldr r0, =0x09200001\n"
281 " mov r1, r4\n"
282 " adds r0, #0x16\n"
283 " str r0, [r4, #0x14]\n"
284 " movs r0, #7\n"
285 " b loc_fc3f7b30\n"
286 "loc_fc3f7b18:\n"
287 " b loc_fc3f7b1a\n"
288 "loc_fc3f7b1a:\n"
289 "loc_C:\n"
290 " ldr r0, [r4, #0x50]\n"
291 " lsls r0, r0, #0x19\n"
292 " bmi loc_fc3f7b24\n"
293 " ldr r0, [r4, #4]\n"
294 " cbz r0, loc_fc3f7b2c\n"
295 "loc_fc3f7b24:\n"
296 " movs r0, #9\n"
297 " mov r1, r4\n"
298 " bl sub_fc3f7992\n"
299 "loc_fc3f7b2c:\n"
300 " movs r0, #0\n"
301 " mov r1, r4\n"
302 "loc_fc3f7b30:\n"
303 " add sp, #0x3c\n"
304 " pop.w {r4, r5, r6, r7, r8, sb, lr}\n"
305
306 " ldr pc,=0xfc3f7993\n"
307 "loc_fc3f7b38:\n"
308 " add sp, #0x3c\n"
309 " pop.w {r4, r5, r6, r7, r8, sb, pc}\n"
310 ".ltorg\n"
311 );
312 }
313
314
315
316
317 void __attribute__((naked,noinline)) sub_fc3f7f9a_my() {
318 asm volatile (
319 " push.w {r4, r5, r6, r7, r8, sb, sl, lr}\n"
320 " mov r5, r0\n"
321 " ldr r0, [r0]\n"
322 " cmp r0, #6\n"
323 " bhi loc_fc3f7fb2\n"
324 " add.w r0, r5, r0, lsl #3\n"
325 " ldrd r7, r6, [r0, #0x18]\n"
326 " cbnz r6, loc_fc3f7fc6\n"
327 " b loc_fc3f7fc0\n"
328 "loc_fc3f7fb2:\n"
329 " movw r2, #0x3b4\n"
330 " ldr r1, =0xfc3f7d5c\n"
331 " movs r0, #0\n"
332 " blx sub_fc2c7de0\n"
333 "loc_fc3f7fc0:\n"
334 " movs r0, #7\n"
335 " mov r1, r5\n"
336 " b loc_fc3f8036\n"
337 "loc_fc3f7fc6:\n"
338 " ldr.w sl, =0x0002008c\n"
339 " mov.w sb, #0x1000000\n"
340 " mov r4, r6\n"
341 "loc_fc3f7fd0:\n"
342 " ldr r0, [r5, #4]\n"
343 " cmp r4, sb\n"
344 " mov r1, sb\n"
345 " bhi loc_fc3f7fda\n"
346 " mov r1, r4\n"
347 "loc_fc3f7fda:\n"
348 " lsls r2, r0, #8\n"
349 " beq loc_fc3f7fec\n"
350 " bic r0, r0, #0xff000000\n"
351 " rsb.w r0, r0, #0x1000000\n"
352 " cmp r1, r0\n"
353 " bls loc_fc3f7fec\n"
354 " mov r1, r0\n"
355 "loc_fc3f7fec:\n"
356 " ldr.w r0, [sl, #8]\n"
357 " mov r8, r1\n"
358 " mov r2, r1\n"
359 " mov r1, r7\n"
360
361 " bl fwt_write\n"
362 " ldr r1, [r5, #4]\n"
363 " cmp r8, r0\n"
364 " add r1, r0\n"
365 " str r1, [r5, #4]\n"
366 " beq loc_fc3f8016\n"
367 " adds r0, r0, #1\n"
368 " bne loc_fc3f800e\n"
369 " ldr r0, =0x09200006\n"
370 " subs r0, r0, #1\n"
371 " b loc_fc3f8012\n"
372 "loc_fc3f800e:\n"
373 " ldr r0, =0x09200006\n"
374 " adds r0, #0xf\n"
375 "loc_fc3f8012:\n"
376 " str r0, [r5, #0x14]\n"
377 " b loc_fc3f7fc0\n"
378 "loc_fc3f8016:\n"
379 " subs r4, r4, r0\n"
380 " cmp r4, r6\n"
381 " add r7, r0\n"
382 " blo loc_fc3f802c\n"
383 " movw r2, #0x3de\n"
384 " ldr r1, =0xfc3f7d5c\n"
385 " movs r0, #0\n"
386 " blx sub_fc2c7de0\n"
387 "loc_fc3f802c:\n"
388 " cmp r4, #0\n"
389 " bne loc_fc3f7fd0\n"
390 " ldr r0, [r5]\n"
391 " mov r1, r5\n"
392 " adds r0, r0, #1\n"
393 "loc_fc3f8036:\n"
394 " pop.w {r4, r5, r6, r7, r8, sb, sl, lr}\n"
395
396 " ldr pc,=0xfc3f7993\n"
397 ".ltorg\n"
398 );
399 }
400
401
402
403 void __attribute__((naked,noinline)) sub_fc3f7b3e_my() {
404 asm volatile (
405 " push {r4, r5, r6, r7, lr}\n"
406 " mov r4, r0\n"
407 " ldr r0, [r0, #0x50]\n"
408 " ldr r5, =0x0002008c\n"
409 " sub sp, #0x3c\n"
410 " add.w r7, r4, #0x5c\n"
411 " lsls r1, r0, #0x1e\n"
412 " bmi loc_fc3f7b56\n"
413 " lsls r0, r0, #0x1c\n"
414 " bpl loc_fc3f7c52\n"
415 " b loc_fc3f7baa\n"
416 "loc_fc3f7b56:\n"
417 " lsls r0, r0, #0x18\n"
418 " bpl loc_fc3f7b86\n"
419 " ldrd r1, r0, [r4, #8]\n"
420 " cmp r1, r0\n"
421 " beq loc_fc3f7b86\n"
422 " ldr r0, [r5, #8]\n"
423 " bl sub_fc31742c\n"
424 " cbnz r0, loc_fc3f7b72\n"
425 " ldr r0, =0x09200001\n"
426 " adds r0, #0x16\n"
427 " str r0, [r4, #0x14]\n"
428 " b loc_fc3f7b86\n"
429 "loc_fc3f7b72:\n"
430 " ldr r0, [r4, #8]\n"
431 " add r1, sp, #0x24\n"
432 " str r0, [r4, #4]\n"
433 " mov r0, r7\n"
434 " bl sub_fc170254\n"
435 " cmp r0, #1\n"
436 " bne loc_fc3f7b86\n"
437 " ldr r0, [r4, #4]\n"
438 " str r0, [sp, #0x2c]\n"
439 "loc_fc3f7b86:\n"
440 " ldr r0, [r5, #8]\n"
441 " adds r1, r0, #1\n"
442 " beq loc_fc3f7baa\n"
443 " ldr r6, =0x09200001\n"
444 " ldr r1, [r4, #0x58]\n"
445 " adds r6, r6, #2\n"
446 " cmp r1, #1\n"
447 " bne loc_fc3f7b9c\n"
448
449 " LDR R3, =current_write_ignored\n"
450 " LDR R3, [R3]\n"
451 " cbnz R3,loc_D\n"
452
453 " bl sub_fc317276\n"
454 " b loc_fc3f7ba0\n"
455 "loc_fc3f7b9c:\n"
456 "loc_D:\n"
457
458 " bl fwt_close\n"
459 "loc_fc3f7ba0:\n"
460 " cbz r0, loc_fc3f7ba4\n"
461 " str r6, [r4, #0x14]\n"
462 "loc_fc3f7ba4:\n"
463 " mov.w r0, #-1\n"
464 " str r0, [r5, #8]\n"
465 "loc_fc3f7baa:\n"
466 " ldr r0, [r4, #0x14]\n"
467 " lsls r0, r0, #0x1f\n"
468 " bne loc_fc3f7c5e\n"
469 " ldr r0, [r4, #0x50]\n"
470 " lsls r1, r0, #0x1f\n"
471 " beq loc_fc3f7bd2\n"
472 " movw r0, #0x81ff\n"
473 " str r0, [sp, #0x24]\n"
474 " movs r0, #0x20\n"
475 " str r0, [sp, #0x28]\n"
476 " ldr r0, [r4, #4]\n"
477 " str r0, [sp, #0x2c]\n"
478 " ldr r0, [r4, #0x10]\n"
479 " str r0, [sp, #0x30]\n"
480 " ldr r0, [r4, #0x10]\n"
481 " str r0, [sp, #0x34]\n"
482 " ldr r0, [r4, #0x10]\n"
483 " str r0, [sp, #0x38]\n"
484 " b loc_fc3f7bf4\n"
485 "loc_fc3f7bd2:\n"
486 " lsls r0, r0, #0x1b\n"
487 " bpl loc_fc3f7bfa\n"
488 " add r1, sp, #0x24\n"
489 " mov r0, r7\n"
490 " bl sub_fc170254\n"
491 " cbnz r0, loc_fc3f7bec\n"
492 " movs r0, #0\n"
493 " movw r2, #0x43a\n"
494 " ldr r1, =0xfc3f7d5c\n"
495 " blx sub_fc2c7de0\n"
496 "loc_fc3f7bec:\n"
497 " ldr r0, [sp, #0x2c]\n"
498 " ldr r1, [r4, #4]\n"
499 " add r0, r1\n"
500 " str r0, [sp, #0x2c]\n"
501 "loc_fc3f7bf4:\n"
502 " ldr r0, [r4, #0x50]\n"
503 " lsls r0, r0, #0x1f\n"
504 " bne loc_fc3f7c04\n"
505 "loc_fc3f7bfa:\n"
506 " ldr r0, [r4, #0x50]\n"
507 " lsls r1, r0, #0x1e\n"
508 " bmi loc_fc3f7c04\n"
509 " lsls r0, r0, #0x1b\n"
510 " bpl loc_fc3f7c5e\n"
511 "loc_fc3f7c04:\n"
512 " add r1, sp, #0x24\n"
513 " mov r0, r7\n"
514 " bl sub_fc1702ca\n"
515 " ldr r0, [r4, #0x50]\n"
516 " lsls r1, r0, #0x1e\n"
517 " bpl loc_fc3f7c5e\n"
518 " lsls r0, r0, #0x1a\n"
519 " bpl loc_fc3f7c5e\n"
520 " movs r2, #0x20\n"
521 " mov r1, r7\n"
522 " add r0, sp, #4\n"
523 " blx sub_fc2c7d78\n"
524 " add r0, sp, #4\n"
525 " bl _strlen\n"
526 " add r2, sp, #4\n"
527 " add r0, r2\n"
528 " movs r1, #0x54\n"
529 " strb r1, [r0, #-0x3]!\n"
530 " movs r1, #0x4d\n"
531 " strb r1, [r0, #1]\n"
532 " movs r1, #0x50\n"
533 " strb r1, [r0, #2]\n"
534 " add r1, sp, #4\n"
535 " mov r0, r7\n"
536 " bl sub_fc16fefa\n"
537 " cbnz r0, loc_fc3f7c4e\n"
538 " movs r0, #0\n"
539 " movw r2, #0x1bd\n"
540 " ldr r1, =0xfc3f7d5c\n"
541 " blx sub_fc2c7de0\n"
542 "loc_fc3f7c4e:\n"
543 " add r0, sp, #4\n"
544 " b loc_fc3f7c54\n"
545 "loc_fc3f7c52:\n"
546 " b loc_fc3f7c74\n"
547 "loc_fc3f7c54:\n"
548 " bl sub_fc1705bc\n"
549 " mov r0, r7\n"
550 " bl sub_fc1705bc\n"
551 "loc_fc3f7c5e:\n"
552 " movs r1, #0\n"
553 " movs r0, #0x48\n"
554 " bl sub_fc305b50\n"
555 " mov r0, r7\n"
556 " bl sub_fc316ffc\n"
557 " ldr r1, [r5, #0x20]\n"
558 " bl sub_fc071108\n"
559 " b loc_fc3f7c78\n"
560 "loc_fc3f7c74:\n"
561 " ldr r0, [r5, #0x20]\n"
562 " blx r0\n"
563 "loc_fc3f7c78:\n"
564 " ldr r0, [r5, #0x18]\n"
565 " cmp r0, #0\n"
566 " beq loc_fc3f7c8c\n"
567 " ldr r1, [r4, #0x14]\n"
568 " mov r0, r4\n"
569 " bl sub_fc3f7958\n"
570 " ldr r1, [r5, #0x18]\n"
571 " ldr r0, [r4, #0x14]\n"
572 " blx r1\n"
573 "loc_fc3f7c8c:\n"
574 " add sp, #0x3c\n"
575 " pop {r4, r5, r6, r7, pc}\n"
576 ".ltorg\n"
577 );
578 }