This source file includes following definitions.
- log_fwt_msg
- log_fwt_start
- filewritetask
- sub_fc063eac_my
- sub_fc064314_my
- sub_fc063fb6_my
1 #include "lolevel.h"
2 #include "platform.h"
3
4
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
34 #ifdef FILEWRITE_DEBUG_LOG
35 extern void _LogCameraEvent(int id,const char *fmt,...);
36 void log_fwt_msg(fwt_data_struct *fwd)
37 {
38 int m=fwd->unkn1;
39 _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);
40 _LogCameraEvent(0x60,"fw %s",fwd->name);
41 if(m >= 0 && m <=6) {
42 _LogCameraEvent(0x60,"fw chunk adr:0x%08x l:0x%08x",fwd->pdc[m].address,fwd->pdc[m].length);
43 }
44 _LogCameraEvent(0x60,"fw u %08x %08x %08x %08x %08x",fwd->unkn2,fwd->unkn3,fwd->unkn5,fwd->unkn6);
45 }
46
47 void log_fwt_start(void)
48 {
49 _LogCameraEvent(0x60,"fw start");
50 }
51 #endif
52
53
54
55
56 void __attribute__((naked,noinline)) filewritetask() {
57 asm volatile (
58 " push {r2, r3, r4, r5, r6, lr}\n"
59 " ldr r5, =0x00021500\n"
60 "loc_fc0640b0:\n"
61 " movs r2, #0\n"
62 " add r1, sp, #4\n"
63 " ldr r0, [r5, #0x10]\n"
64 " blx sub_fc29b440\n"
65 " cbz r0, loc_fc0640c8\n"
66 " movs r0, #0\n"
67 " movw r2, #0x3f6\n"
68 " ldr r1, =0xfc064230\n"
69 " blx sub_fc29b538\n"
70 "loc_fc0640c8:\n"
71 " ldr r0, [sp, #4]\n"
72 " ldr r1, [r0]\n"
73 " cmp r1, #0xd\n"
74 " bhs loc_fc0640b0\n"
75 " tbb [pc, r1]\n"
76 "branchtable_fc0640d4:\n"
77 " .byte((loc_fc06416e - branchtable_fc0640d4) / 2)\n"
78 " .byte((loc_fc06416e - branchtable_fc0640d4) / 2)\n"
79 " .byte((loc_fc06416e - branchtable_fc0640d4) / 2)\n"
80 " .byte((loc_fc06416e - branchtable_fc0640d4) / 2)\n"
81 " .byte((loc_fc06416e - branchtable_fc0640d4) / 2)\n"
82 " .byte((loc_fc06416e - branchtable_fc0640d4) / 2)\n"
83 " .byte((loc_fc06416e - branchtable_fc0640d4) / 2)\n"
84 " .byte((loc_fc064174 - branchtable_fc0640d4) / 2)\n"
85 " .byte((loc_fc0640e2 - branchtable_fc0640d4) / 2)\n"
86 " .byte((loc_fc06410c - branchtable_fc0640d4) / 2)\n"
87 " .byte((loc_fc06412c - branchtable_fc0640d4) / 2)\n"
88 " .byte((loc_fc0640e8 - branchtable_fc0640d4) / 2)\n"
89 " .byte((loc_fc064106 - branchtable_fc0640d4) / 2)\n"
90 ".align 1\n"
91 "loc_fc0640e2:\n"
92 " bl sub_fc0642d0\n"
93 " b loc_fc0640b0\n"
94 "loc_fc0640e8:\n"
95 " mov r4, r0\n"
96 " adds r0, #0x58\n"
97 " mov r6, r0\n"
98 " bl sub_fc307d3a\n"
99 " movs r1, #0\n"
100 " bl sub_fc06c0c6\n"
101 " ldr r0, [r4, #0xc]\n"
102 " bl sub_fc0ba11e\n"
103 " mov r0, r6\n"
104 " bl sub_fc3083f2\n"
105 " b loc_fc064156\n"
106 "loc_fc064106:\n"
107
108 " bl sub_fc063eac_my\n"
109 " b loc_fc0640b0\n"
110 "loc_fc06410c:\n"
111 " ldr r1, [r0, #4]\n"
112 " movs r2, #0\n"
113 " mov r4, r0\n"
114 " ldr r0, [r5, #4]\n"
115 " bl _lseek\n"
116 " adds r0, r0, #1\n"
117 " bne loc_fc0640b0\n"
118 " ldr r0, =0x09200001\n"
119 " mov r1, r4\n"
120 " adds r0, #0x12\n"
121 " str r0, [r4, #0x10]\n"
122 " movs r0, #7\n"
123 " bl sub_fc063e38\n"
124 " b loc_fc0640b0\n"
125 "loc_fc06412c:\n"
126 " mov r4, r0\n"
127 " ldrsb.w r0, [r0, #0x58]\n"
128 " cmp r0, #0\n"
129 " beq loc_fc0640b0\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_fc307d3a\n"
136 " movs r1, #0\n"
137 " bl sub_fc06c0c6\n"
138 " mov r0, sp\n"
139 " bl sub_fc0ba12a\n"
140 "loc_fc064156:\n"
141 " mov r0, r6\n"
142 " bl sub_fc307d3a\n"
143 " ldr r1, [r5, #0x1c]\n"
144 " bl sub_fc06c124\n"
145 " ldr r1, [r5, #0x14]\n"
146 " cmp r1, #0\n"
147 " beq loc_fc0640b0\n"
148 " ldr r0, [r4, #0x10]\n"
149 " blx r1\n"
150 " b loc_fc0640b0\n"
151 "loc_fc06416e:\n"
152
153 " bl sub_fc064314_my\n"
154 " b loc_fc0640b0\n"
155 "loc_fc064174:\n"
156
157 " bl sub_fc063fb6_my\n"
158 " b loc_fc0640b0\n"
159 ".ltorg\n"
160 );
161 }
162
163
164
165
166 void __attribute__((naked,noinline)) sub_fc063eac_my() {
167 asm volatile (
168 " push.w {r4, r5, r6, r7, r8, sb, lr}\n"
169 " mov r4, r0\n"
170
171
172 " BL filewrite_main_hook\n"
173 " mov r0, r4\n"
174
175 " ldr r0, [r0, #0x4c]\n"
176 " sub sp, #0x3c\n"
177 " lsls r0, r0, #0x1f\n"
178 " beq loc_fc063f92\n"
179 " ldr r7, =0x00021500\n"
180 " ldr r0, [r7, #0x18]\n"
181 " cbz r0, loc_fc063ec2\n"
182 " blx r0\n"
183 "loc_fc063ec2:\n"
184 " add.w r0, r4, #0x58\n"
185 " mov r8, r0\n"
186 " bl sub_fc307d3a\n"
187 " movs r1, #0\n"
188 " bl sub_fc06c0c6\n"
189 " ldr r0, [r4, #0xc]\n"
190 " bl sub_fc0ba11e\n"
191 " ldr r0, [r4, #0x4c]\n"
192 " movw r5, #0x301\n"
193 " lsls r1, r0, #0x1b\n"
194 " bpl loc_fc063ee6\n"
195 " movs r5, #9\n"
196 " b loc_fc063eec\n"
197 "loc_fc063ee6:\n"
198 " lsls r1, r0, #0x19\n"
199 " bpl loc_fc063eec\n"
200 " movs r5, #1\n"
201 "loc_fc063eec:\n"
202 " lsls r0, r0, #0x1a\n"
203 " bmi loc_fc063ef6\n"
204 " ldr r0, [r4, #0x54]\n"
205 " cmp r0, #1\n"
206 " bne loc_fc063efa\n"
207 "loc_fc063ef6:\n"
208 " orr r5, r5, #0x8000\n"
209 "loc_fc063efa:\n"
210 " movw sb, #0x1b6\n"
211 " ldr r6, [r4, #0xc]\n"
212 " mov r2, sb\n"
213 " mov r1, r5\n"
214 " mov r0, r8\n"
215
216 " bl fwt_open\n"
217 " adds r1, r0, #1\n"
218 " bne loc_fc063f48\n"
219 " mov r0, r8\n"
220 " bl sub_fc3083f2\n"
221 " movs r2, #0xf\n"
222 " mov r1, r8\n"
223 " add r0, sp, #4\n"
224 " blx sub_fc29b558\n"
225 " movs r0, #0\n"
226 " strb.w r0, [sp, #0x13]\n"
227 " movw r1, #0x41ff\n"
228 " str r1, [sp, #0x24]\n"
229 " strd r0, r6, [sp, #0x2c]\n"
230 " movs r1, #0x10\n"
231 " str r6, [sp, #0x34]\n"
232 " add r0, sp, #4\n"
233 " str r6, [sp, #0x38]\n"
234 " str r1, [sp, #0x28]\n"
235 " add r1, sp, #0x24\n"
236 " bl sub_fc0e7e4a\n"
237 " mov r2, sb\n"
238 " mov r1, r5\n"
239 " mov r0, r8\n"
240
241 " bl _Open\n"
242 "loc_fc063f48:\n"
243 " mov r5, r0\n"
244 " str r0, [r7, #4]\n"
245 " adds r0, r0, #1\n"
246 " bne loc_fc063f6c\n"
247 " mov r0, r8\n"
248 " bl sub_fc307d3a\n"
249 " ldr r1, [r7, #0x1c]\n"
250 " bl sub_fc06c124\n"
251 " ldr r1, [r7, #0x14]\n"
252 " cmp r1, #0\n"
253 " beq loc_fc063fb0\n"
254 " add sp, #0x3c\n"
255 " ldr r0, =0x09200001\n"
256 " pop.w {r4, r5, r6, r7, r8, sb, lr}\n"
257 " bx r1\n"
258 "loc_fc063f6c:\n"
259 " ldr r0, =0x001ba8d4\n"
260 " movs r2, #0x20\n"
261 " mov r1, r8\n"
262 " blx sub_fc29b560\n"
263
264 " LDR R3, =current_write_ignored\n"
265 " LDR R3, [R3]\n"
266 " cbnz r3,loc_C\n"
267
268 " ldr r0, [r4, #0x4c]\n"
269 " lsls r0, r0, #0x18\n"
270 " bpl loc_fc063f92\n"
271 " ldr r1, [r4, #8]\n"
272 " mov r0, r5\n"
273 " bl sub_fc308208\n"
274 " cbnz r0, loc_fc063f92\n"
275 " ldr r0, =0x09200001\n"
276 " mov r1, r4\n"
277 " adds r0, #0x16\n"
278 " str r0, [r4, #0x10]\n"
279 " movs r0, #7\n"
280 " b loc_fc063fa8\n"
281 "loc_fc063f92:\n"
282 "loc_C:\n"
283 " ldr r0, [r4, #0x4c]\n"
284 " lsls r0, r0, #0x19\n"
285 " bmi loc_fc063f9c\n"
286 " ldr r0, [r4, #4]\n"
287 " cbz r0, loc_fc063fa4\n"
288 "loc_fc063f9c:\n"
289 " movs r0, #9\n"
290 " mov r1, r4\n"
291 " bl sub_fc063e38\n"
292 "loc_fc063fa4:\n"
293 " movs r0, #0\n"
294 " mov r1, r4\n"
295 "loc_fc063fa8:\n"
296 " add sp, #0x3c\n"
297 " pop.w {r4, r5, r6, r7, r8, sb, lr}\n"
298
299 " ldr pc,=0xfc063e39\n"
300 "loc_fc063fb0:\n"
301 " add sp, #0x3c\n"
302 " pop.w {r4, r5, r6, r7, r8, sb, pc}\n"
303 ".ltorg\n"
304 );
305 }
306
307
308
309
310 void __attribute__((naked,noinline)) sub_fc064314_my() {
311 asm volatile (
312 " push.w {r4, r5, r6, r7, r8, sb, sl, lr}\n"
313 " mov r5, r0\n"
314 " ldr r0, [r0]\n"
315 " cmp r0, #6\n"
316 " bhi loc_fc06432c\n"
317 " add.w r0, r5, r0, lsl #3\n"
318 " ldrd r7, r6, [r0, #0x14]\n"
319 " cbnz r6, loc_fc064340\n"
320 " b loc_fc06433a\n"
321 "loc_fc06432c:\n"
322 " movw r2, #0x34b\n"
323 " ldr r1, =0xfc064230\n"
324 " movs r0, #0\n"
325 " blx sub_fc29b538\n"
326 "loc_fc06433a:\n"
327 " movs r0, #7\n"
328 " mov r1, r5\n"
329 " b loc_fc0643ae\n"
330 "loc_fc064340:\n"
331 " ldr.w sl, =0x00021500\n"
332 " mov.w sb, #0x1000000\n"
333 " mov r4, r6\n"
334 "loc_fc06434a:\n"
335 " ldr r0, [r5, #4]\n"
336 " cmp r4, sb\n"
337 " mov r1, sb\n"
338 " bhi loc_fc064354\n"
339 " mov r1, r4\n"
340 "loc_fc064354:\n"
341 " lsls r2, r0, #8\n"
342 " beq loc_fc064366\n"
343 " bic r0, r0, #0xff000000\n"
344 " rsb.w r0, r0, #0x1000000\n"
345 " cmp r1, r0\n"
346 " bls loc_fc064366\n"
347 " mov r1, r0\n"
348 "loc_fc064366:\n"
349 " ldr.w r0, [sl, #4]\n"
350 " mov r8, r1\n"
351 " mov r2, r1\n"
352 " mov r1, r7\n"
353
354 " bl fwt_write\n"
355 " ldr r1, [r5, #4]\n"
356 " cmp r8, r0\n"
357 " add r1, r0\n"
358 " str r1, [r5, #4]\n"
359 " beq loc_fc06438e\n"
360 " adds r0, r0, #1\n"
361 " bne loc_fc064386\n"
362 " ldr r0, =0x09200005\n"
363 " b loc_fc06438a\n"
364 "loc_fc064386:\n"
365 " ldr r0, =0x09200005\n"
366 " adds r0, #0x10\n"
367 "loc_fc06438a:\n"
368 " str r0, [r5, #0x10]\n"
369 " b loc_fc06433a\n"
370 "loc_fc06438e:\n"
371 " subs r4, r4, r0\n"
372 " cmp r4, r6\n"
373 " add r7, r0\n"
374 " blo loc_fc0643a4\n"
375 " movw r2, #0x376\n"
376 " ldr r1, =0xfc064230\n"
377 " movs r0, #0\n"
378 " blx sub_fc29b538\n"
379 "loc_fc0643a4:\n"
380 " cmp r4, #0\n"
381 " bne loc_fc06434a\n"
382 " ldr r0, [r5]\n"
383 " mov r1, r5\n"
384 " adds r0, r0, #1\n"
385 "loc_fc0643ae:\n"
386 " pop.w {r4, r5, r6, r7, r8, sb, sl, lr}\n"
387
388 " ldr pc,=0xfc063e39\n"
389 ".ltorg\n"
390 );
391 }
392
393
394
395 void __attribute__((naked,noinline)) sub_fc063fb6_my() {
396 asm volatile (
397 " push {r4, r5, r6, lr}\n"
398 " mov r4, r0\n"
399 " ldr r0, [r0, #0x4c]\n"
400 " ldr r5, =0x00021500\n"
401 " sub sp, #0x38\n"
402 " lsls r0, r0, #0x1e\n"
403 " bpl loc_fc06409a\n"
404 " ldr r0, [r5, #4]\n"
405 " adds r1, r0, #1\n"
406 " beq loc_fc063fe8\n"
407 " ldr r6, =0x09200001\n"
408 " ldr r1, [r4, #0x54]\n"
409 " adds r6, r6, #2\n"
410 " cmp r1, #1\n"
411 " bne loc_fc063fda\n"
412
413 " LDR R3, =current_write_ignored\n"
414 " LDR R3, [R3]\n"
415 " cbnz R3,loc_D\n"
416
417 " bl sub_fc308052\n"
418 " b loc_fc063fde\n"
419 "loc_fc063fda:\n"
420 "loc_D:\n"
421
422 " bl fwt_close\n"
423 "loc_fc063fde:\n"
424 " cbz r0, loc_fc063fe2\n"
425 " str r6, [r4, #0x10]\n"
426 "loc_fc063fe2:\n"
427 " mov.w r0, #-1\n"
428 " str r0, [r5, #4]\n"
429 "loc_fc063fe8:\n"
430 " add.w r6, r4, #0x58\n"
431 " ldr r0, [r4, #0x10]\n"
432 " lsls r0, r0, #0x1f\n"
433 " bne loc_fc06408c\n"
434 " ldr r0, [r4, #0x4c]\n"
435 " lsls r1, r0, #0x1f\n"
436 " beq loc_fc064014\n"
437 " movw r0, #0x81ff\n"
438 " str r0, [sp, #0x20]\n"
439 " movs r0, #0x20\n"
440 " str r0, [sp, #0x24]\n"
441 " ldr r0, [r4, #4]\n"
442 " str r0, [sp, #0x28]\n"
443 " ldr r0, [r4, #0xc]\n"
444 " str r0, [sp, #0x2c]\n"
445 " ldr r0, [r4, #0xc]\n"
446 " str r0, [sp, #0x30]\n"
447 " ldr r0, [r4, #0xc]\n"
448 " str r0, [sp, #0x34]\n"
449 " b loc_fc064036\n"
450 "loc_fc064014:\n"
451 " lsls r0, r0, #0x1b\n"
452 " bpl loc_fc064036\n"
453 " add r1, sp, #0x20\n"
454 " mov r0, r6\n"
455 " bl sub_fc0e7dd4\n"
456 " cbnz r0, loc_fc06402e\n"
457 " movs r0, #0\n"
458 " movw r2, #0x3bd\n"
459 " ldr r1, =0xfc064230\n"
460 " blx sub_fc29b538\n"
461 "loc_fc06402e:\n"
462 " ldr r0, [sp, #0x28]\n"
463 " ldr r1, [r4, #4]\n"
464 " add r0, r1\n"
465 " str r0, [sp, #0x28]\n"
466 "loc_fc064036:\n"
467 " ldr r0, [r4, #0x4c]\n"
468 " lsls r0, r0, #0x19\n"
469 " bmi loc_fc064044\n"
470 " add r1, sp, #0x20\n"
471 " mov r0, r6\n"
472 " bl sub_fc0e7e4a\n"
473 "loc_fc064044:\n"
474 " ldr r0, [r4, #0x4c]\n"
475 " lsls r0, r0, #0x1a\n"
476 " bpl loc_fc06408c\n"
477 " movs r2, #0x20\n"
478 " mov r1, r6\n"
479 " mov r0, sp\n"
480 " blx sub_fc29b560\n"
481 " mov r0, sp\n"
482 " bl _strlen\n"
483 " add r0, sp, r0\n"
484 " movs r1, #0x54\n"
485 " strb r1, [r0, #-0x3]!\n"
486 " movs r1, #0x4d\n"
487 " strb r1, [r0, #1]\n"
488 " movs r1, #0x50\n"
489 " strb r1, [r0, #2]\n"
490 " mov r1, sp\n"
491 " mov r0, r6\n"
492 " bl sub_fc0ba2f6\n"
493 " cbnz r0, loc_fc064080\n"
494 " movs r0, #0\n"
495 " movw r2, #0x167\n"
496 " ldr r1, =0xfc064230\n"
497 " blx sub_fc29b538\n"
498 "loc_fc064080:\n"
499 " mov r0, sp\n"
500 " bl sub_fc0e813c\n"
501 " mov r0, r6\n"
502 " bl sub_fc0e813c\n"
503 "loc_fc06408c:\n"
504 " mov r0, r6\n"
505 " bl sub_fc307d3a\n"
506 " ldr r1, [r5, #0x1c]\n"
507 " bl sub_fc06c124\n"
508 " b loc_fc06409e\n"
509 "loc_fc06409a:\n"
510 " ldr r0, [r5, #0x1c]\n"
511 " blx r0\n"
512 "loc_fc06409e:\n"
513 " ldr r1, [r5, #0x14]\n"
514 " cmp r1, #0\n"
515 " beq loc_fc0640a8\n"
516 " ldr r0, [r4, #0x10]\n"
517 " blx r1\n"
518 "loc_fc0640a8:\n"
519 " add sp, #0x38\n"
520 " pop {r4, r5, r6, pc}\n"
521 ".ltorg\n"
522 );
523 }