This source file includes following definitions.
- filewritetask
- sub_FF3483B8_my
- sub_FF348A98_my
- sub_FF348550_my
1
2
3
4 #include "lolevel.h"
5 #include "platform.h"
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
22 typedef struct
23 {
24 int unkn1;
25 int file_offset;
26 int full_size;
27 int unkn2, unkn3;
28 cam_ptp_data_chunk pdc[MAX_CHUNKS_FOR_FWT];
29 int seek_flag;
30 int unkn4, unkn5;
31 char name[32];
32 } fwt_data_struct;
33
34
35
36
37
38 #define FWT_MUSTSEEK 0x40
39 #define FWT_SEEKMASK 0x40
40
41 #include "../../../generic/filewrite.c"
42
43
44
45 void __attribute__((naked,noinline)) filewritetask() {
46 asm volatile (
47 " STMFD SP!, {R1-R7,LR} \n"
48 " LDR R5, =0xE53C \n"
49 " MOV R6, #0 \n"
50
51 "loc_FF3486E4:\n"
52 " LDR R0, [R5, #0x10] \n"
53 " MOV R2, #0 \n"
54 " ADD R1, SP, #8 \n"
55 " BL sub_006B84B8 /*_ReceiveMessageQueue*/ \n"
56 " CMP R0, #0 \n"
57 " LDRNE R2, =0x3F5 \n"
58 " LDRNE R1, =0xFF3488A4 /*'dwFWrite.c'*/ \n"
59 " MOVNE R0, #0 \n"
60 " BLNE _DebugAssert \n"
61 " LDR R0, [SP, #8] \n"
62 " LDR R1, [R0] \n"
63 " CMP R1, #0xD \n"
64 " ADDCC PC, PC, R1, LSL#2 \n"
65 " B loc_FF3486E4 \n"
66 " B loc_FF348870 \n"
67 " B loc_FF348870 \n"
68 " B loc_FF348870 \n"
69 " B loc_FF348870 \n"
70 " B loc_FF348870 \n"
71 " B loc_FF348870 \n"
72 " B loc_FF348870 \n"
73 " B loc_FF348878 \n"
74 " B loc_FF348750 \n"
75 " B loc_FF3487EC \n"
76 " B loc_FF34881C \n"
77 " B loc_FF3487B8 \n"
78 " B loc_FF3487E4 \n"
79
80 "loc_FF348750:\n"
81 " MOV R4, R5 \n"
82 " STR R6, [SP] \n"
83
84 "loc_FF348758:\n"
85 " LDR R0, [R4, #0x10] \n"
86 " MOV R1, SP \n"
87 " BL sub_006B8710 /*_GetNumberOfPostedMessages*/ \n"
88 " LDR R0, [SP] \n"
89 " CMP R0, #0 \n"
90 " BEQ loc_FF348784 \n"
91 " LDR R0, [R4, #0x10] \n"
92 " MOV R2, #0 \n"
93 " ADD R1, SP, #4 \n"
94 " BL sub_006B84B8 /*_ReceiveMessageQueue*/ \n"
95 " B loc_FF348758 \n"
96
97 "loc_FF348784:\n"
98 " LDR R0, [R4, #4] \n"
99 " CMN R0, #1 \n"
100 " BEQ loc_FF3487AC \n"
101 " BL fwt_close \n"
102 " MVN R0, #0 \n"
103 " STR R0, [R4, #4] \n"
104 " LDR R0, =0x125CCC \n"
105 " BL sub_FF010DA8 \n"
106 " MOV R1, #0 \n"
107 " BL sub_FF00EC58 \n"
108
109 "loc_FF3487AC:\n"
110 " LDR R0, [R4, #0xC] \n"
111 " BL _GiveSemaphore \n"
112 " B loc_FF3486E4 \n"
113
114 "loc_FF3487B8:\n"
115 " MOV R4, R0 \n"
116 " ADD R0, R0, #0x58 \n"
117 " BL sub_FF010DA8 \n"
118 " MOV R1, #0 \n"
119 " BL sub_FF00EB18 \n"
120 " LDR R0, [R4, #0xC] \n"
121 " BL sub_FF00D9D8 \n"
122 " ADD R0, R4, #0x58 \n"
123
124
125 " LDR R3, =ignore_current_write\n"
126 " LDR R3, [R3]\n"
127 " CMP R3, #0\n"
128 " BNE loc_A\n"
129
130 " BL sub_FF007918 \n"
131 " ADD R0, R4, #0x58 \n"
132 " B loc_FF348850 \n"
133
134 "loc_FF3487E4:\n"
135 " BL sub_FF3483B8_my \n"
136 " B loc_FF3486E4 \n"
137
138 "loc_FF3487EC:\n"
139 " LDR R1, [R0, #4] \n"
140 " MOV R4, R0 \n"
141 " LDR R0, [R5, #4] \n"
142 " MOV R2, #0 \n"
143 " BL fwt_lseek \n"
144 " CMN R0, #1 \n"
145 " LDREQ R0, =0x9200013 \n"
146 " MOVEQ R1, R4 \n"
147 " STREQ R0, [R4, #0x10] \n"
148 " MOVEQ R0, #7 \n"
149 " BLEQ sub_FF3482F8 \n"
150 " B loc_FF3486E4 \n"
151
152 "loc_FF34881C:\n"
153 " MOV R4, R0 \n"
154 " LDRSB R0, [R0, #0x58] \n"
155 " CMP R0, #0 \n"
156 " BEQ loc_FF3486E4 \n"
157 " STRB R0, [SP, #4] \n"
158 " ADD R0, R4, #0x58 \n"
159 " STRB R6, [SP, #5] \n"
160 " BL sub_FF010DA8 \n"
161 " MOV R1, #0 \n"
162 " BL sub_FF00EB18 \n"
163
164
165 " LDR R3, =ignore_current_write\n"
166 " LDR R3, [R3]\n"
167 " CMP R3, #0\n"
168 " BNE loc_B\n"
169
170
171 " ADD R0, SP, #4 \n"
172 " BL sub_FF00D9F0 \n"
173 "loc_B:\n"
174 " ADD R0, R4, #0x58 \n"
175
176 "loc_FF348850:\n"
177 "loc_A:\n"
178 " BL sub_FF010DA8 \n"
179 " LDR R1, [R5, #0x1C] \n"
180 " BL sub_FF00EC58 \n"
181 " LDR R1, [R5, #0x14] \n"
182 " CMP R1, #0 \n"
183 " LDRNE R0, [R4, #0x10] \n"
184 " BLXNE R1 \n"
185 " B loc_FF3486E4 \n"
186
187 "loc_FF348870:\n"
188 " BL sub_FF348A98_my \n"
189 " B loc_FF3486E4 \n"
190
191 "loc_FF348878:\n"
192 " BL sub_FF348550_my \n"
193 " B loc_FF3486E4 \n"
194 );
195 }
196
197
198
199 void __attribute__((naked,noinline)) sub_FF3483B8_my() {
200 asm volatile (
201 " STMFD SP!, {R4-R9,LR} \n"
202 " MOV R4, R0 \n"
203
204
205 " BL filewrite_main_hook\n"
206 " MOV R0, R4\n"
207
208 " LDR R0, [R0, #0x4C] \n"
209 " SUB SP, SP, #0x3C \n"
210 " TST R0, #1 \n"
211 " BEQ loc_FF348520 \n"
212 " LDR R7, =0xE53C \n"
213 " LDR R0, [R7, #0x18] \n"
214 " CMP R0, #0 \n"
215 " BLXNE R0 \n"
216 " ADD R0, R4, #0x58 \n"
217 " BL sub_FF010DA8 \n"
218 " MOV R1, #0 \n"
219 " BL sub_FF00EB18 \n"
220 " LDR R0, [R4, #0xC] \n"
221 " BL sub_FF00D9D8 \n"
222 " LDR R0, [R4, #0x4C] \n"
223 " LDR R5, =0x301 \n"
224 " TST R0, #0x10 \n"
225 " MOVNE R5, #9 \n"
226 " BNE loc_FF348414 \n"
227 " TST R0, #0x40 \n"
228 " MOVNE R5, #1 \n"
229
230 "loc_FF348414:\n"
231 " TST R0, #0x20 \n"
232 " BNE loc_FF348428 \n"
233 " LDR R0, [R4, #0x54] \n"
234 " CMP R0, #1 \n"
235 " BNE loc_FF34842C \n"
236
237 "loc_FF348428:\n"
238 " ORR R5, R5, #0x8000 \n"
239
240 "loc_FF34842C:\n"
241 " LDR R9, =0x1B6 \n"
242 " ADD R8, R4, #0x58 \n"
243 " LDR R6, [R4, #0xC] \n"
244 " MOV R2, R9 \n"
245 " MOV R1, R5 \n"
246 " MOV R0, R8 \n"
247 " BL fwt_open \n"
248 " CMN R0, #1 \n"
249 " BNE loc_FF3484AC \n"
250 " MOV R0, R8 \n"
251 " BL sub_FF007918 \n"
252 " MOV R2, #0xF \n"
253 " MOV R1, R8 \n"
254 " ADD R0, SP, #4 \n"
255 " BL sub_006D4A08 \n"
256 " MOV R0, #0 \n"
257 " LDR R1, =0x41FF \n"
258 " STRB R0, [SP, #0x13] \n"
259 " STR R1, [SP, #0x24] \n"
260 " MOV R1, #0x10 \n"
261 " STR R0, [SP, #0x2C] \n"
262 " STR R1, [SP, #0x28] \n"
263 " ADD R1, SP, #0x24 \n"
264 " ADD R0, SP, #4 \n"
265 " STR R6, [SP, #0x30] \n"
266 " STR R6, [SP, #0x34] \n"
267 " STR R6, [SP, #0x38] \n"
268 " BL sub_FF00E47C \n"
269 " MOV R2, R9 \n"
270 " MOV R1, R5 \n"
271 " MOV R0, R8 \n"
272 " BL fwt_open \n"
273
274 "loc_FF3484AC:\n"
275 " CMN R0, #1 \n"
276 " MOV R5, R0 \n"
277 " STR R0, [R7, #4] \n"
278 " BNE loc_FF3484E8 \n"
279 " ADD R0, R4, #0x58 \n"
280 " BL sub_FF010DA8 \n"
281 " LDR R1, [R7, #0x1C] \n"
282 " BL sub_FF00EC58 \n"
283 " LDR R1, [R7, #0x14] \n"
284 " CMP R1, #0 \n"
285 " BEQ loc_FF348548 \n"
286 " ADD SP, SP, #0x3C \n"
287 " LDMFD SP!, {R4-R9,LR} \n"
288 " LDR R0, =0x9200001 \n"
289 " BX R1 \n"
290
291 "loc_FF3484E8:\n"
292 " LDR R0, =0x125CCC \n"
293 " MOV R2, #0x20 \n"
294 " ADD R1, R4, #0x58 \n"
295 " BL sub_006D4BF0 \n"
296
297
298 " LDR R3, =current_write_ignored\n"
299 " LDR R3, [R3]\n"
300 " CMP R3, #0\n"
301 " BNE loc_C\n"
302
303
304 " LDR R0, [R4, #0x4C] \n"
305 " TST R0, #0x80 \n"
306 " BEQ loc_FF348520 \n"
307 " LDR R1, [R4, #8] \n"
308 " MOV R0, R5 \n"
309 " BL sub_FF0075E8 \n"
310 " CMP R0, #0 \n"
311 " MOVEQ R1, R4 \n"
312 " MOVEQ R0, #7 \n"
313 " BEQ loc_FF348544 \n"
314
315 "loc_FF348520:\n"
316 "loc_C:\n"
317 " LDR R0, [R4, #0x4C] \n"
318 " TST R0, #0x40 \n"
319 " LDREQ R0, [R4, #4] \n"
320 " CMPEQ R0, #0 \n"
321 " MOVNE R1, R4 \n"
322 " MOVNE R0, #9 \n"
323 " BLNE sub_FF3482F8 \n"
324 " MOV R1, R4 \n"
325 " MOV R0, #0 \n"
326
327 "loc_FF348544:\n"
328 " BL sub_FF3482F8 \n"
329
330 "loc_FF348548:\n"
331 " ADD SP, SP, #0x3C \n"
332 " LDMFD SP!, {R4-R9,PC} \n"
333 );
334 }
335
336
337
338 void __attribute__((naked,noinline)) sub_FF348A98_my() {
339 asm volatile (
340 " STMFD SP!, {R4-R10,LR} \n"
341 " MOV R5, R0 \n"
342 " LDR R0, [R0] \n"
343 " CMP R0, #6 \n"
344 " BHI loc_FF348AC4 \n"
345 " ADD R0, R5, R0, LSL#3 \n"
346 " LDR R8, [R0, #0x14]! \n"
347 " LDR R7, [R0, #4] \n"
348 " CMP R7, #0 \n"
349 " BNE loc_FF348AE0 \n"
350 " B loc_FF348AD4 \n"
351
352 "loc_FF348AC4:\n"
353 " LDR R2, =0x34A \n"
354 " LDR R1, =0xFF3488A4 /*'dwFWrite.c'*/ \n"
355 " MOV R0, #0 \n"
356 " BL _DebugAssert \n"
357
358 "loc_FF348AD4:\n"
359 " MOV R1, R5 \n"
360 " MOV R0, #7 \n"
361 " B loc_FF348B78 \n"
362
363 "loc_FF348AE0:\n"
364 " LDR R9, =0xE53C \n"
365 " MOV R4, R7 \n"
366
367 "loc_FF348AE8:\n"
368 " LDR R0, [R5, #4] \n"
369 " CMP R4, #0x1000000 \n"
370 " MOVLS R6, R4 \n"
371 " MOVHI R6, #0x1000000 \n"
372 " BIC R1, R0, #0xFF000000 \n"
373 " CMP R1, #0 \n"
374 " BICNE R0, R0, #0xFF000000 \n"
375 " RSBNE R0, R0, #0x1000000 \n"
376 " CMPNE R6, R0 \n"
377 " MOVHI R6, R0 \n"
378 " LDR R0, [R9, #4] \n"
379 " MOV R2, R6 \n"
380 " MOV R1, R8 \n"
381 " BL fwt_write \n"
382 " LDR R1, [R5, #4] \n"
383 " CMP R6, R0 \n"
384 " ADD R1, R1, R0 \n"
385 " STR R1, [R5, #4] \n"
386 " BEQ loc_FF348B48 \n"
387 " CMN R0, #1 \n"
388 " LDRNE R0, =0x9200015 \n"
389 " LDREQ R0, =0x9200005 \n"
390 " STR R0, [R5, #0x10] \n"
391 " B loc_FF348AD4 \n"
392
393 "loc_FF348B48:\n"
394 " SUB R4, R4, R0 \n"
395 " CMP R4, R7 \n"
396 " LDRCS R2, =0x375 \n"
397 " ADD R8, R8, R0 \n"
398 " LDRCS R1, =0xFF3488A4 /*'dwFWrite.c'*/ \n"
399 " MOVCS R0, #0 \n"
400 " BLCS _DebugAssert \n"
401 " CMP R4, #0 \n"
402 " BNE loc_FF348AE8 \n"
403 " LDR R0, [R5] \n"
404 " MOV R1, R5 \n"
405 " ADD R0, R0, #1 \n"
406
407 "loc_FF348B78:\n"
408 " LDMFD SP!, {R4-R10,LR} \n"
409 " B sub_FF3482F8 \n"
410 " .ltorg\n"
411 );
412 }
413
414
415
416 void __attribute__((naked,noinline)) sub_FF348550_my() {
417 asm volatile (
418 " STMFD SP!, {R4-R6,LR} \n"
419 " MOV R4, R0 \n"
420 " LDR R0, [R0, #0x4C] \n"
421 " LDR R5, =0xE53C \n"
422 " TST R0, #2 \n"
423 " SUB SP, SP, #0x38 \n"
424 " BEQ sub_FF3486B8 \n"
425 " LDR R0, [R5, #4] \n"
426 " CMN R0, #1 \n"
427 " BEQ sub_FF3485A4 \n"
428 " LDR R1, [R4, #0x54] \n"
429 " LDR R6, =0x9200003 \n"
430 " CMP R1, #1 \n"
431 " BNE loc_FF348590 \n"
432
433 " LDR R3, =current_write_ignored\n"
434 " LDR R3, [R3]\n"
435 " CMP R3, #0\n"
436 " BNE loc_D\n"
437
438
439 " BL sub_FF00733C \n"
440 " B sub_FF348594 \n"
441
442 "loc_FF348590:\n"
443 "loc_D:\n"
444 " BL fwt_close \n"
445 " LDR PC, =0xFF348594 \n"
446 );
447 }