root/platform/g7x/sub/100d/filewrite.c

/* [<][>][^][v][top][bottom][index][help] */

DEFINITIONS

This source file includes following definitions.
  1. log_fwt_msg
  2. log_fwt_start
  3. filewritetask
  4. sub_fc06b50a_my
  5. sub_fc06b556_my
  6. sub_fc06b0cc_my
  7. sub_fc06b5aa_my
  8. sub_fc06b602_my
  9. sub_fc06b1f2_my

   1 #include "lolevel.h"
   2 #include "platform.h"
   3 // debug
   4 //#define FILEWRITE_DEBUG_LOG 1
   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; //camera specific structure
  11 
  12 #define MAX_CHUNKS_FOR_FWT 7 // filewritetask is prepared for this many chunks
  13                               // corresponds to filewritetask() jump table entries 0-6
  14 /*
  15  * fwt_data_struct: defined here as it's camera dependent
  16  * unneeded members are designated with unkn
  17  * file_offset, full_size, seek_flag only needs to be defined for cameras with CAM_FILEWRITETASK_SEEK/CAM_FILEWRITETASK_MULTIPASS
  18  * pdc is always required
  19  * name is not currently used
  20  */
  21 typedef struct
  22 {
  23     int unkn1; // message number
  24     int file_offset;
  25     int maybe_full_size; // TODO doesn't seem to actually be full size for jpeg, instead round number somewhat smaller
  26     int unkn2, unkn3;
  27     int unkn4;
  28     cam_ptp_data_chunk pdc[MAX_CHUNKS_FOR_FWT];
  29     int maybe_seek_flag;      // from fc06b0cc 0x50, not clear if ever used to indicate seek. 0x3 raw, 0x83 jpeg, 0x200 CacheFlush, 0x100 create dir
  30     int unkn5, unkn6;
  31     char name[32];      //from fc06b0cc offset from start 0x5c = 92 bytes = 23 words
  32 } fwt_data_struct;
  33 
  34 /*
  35 g7x observed message sequences
  36 canon raw + jpeg
  37 CR2
  38 12 full_size = 0x010dad6d (actual size), seek_flag = 0x3
  39  0 chunk 0-0x9aa00
  40  1 chunk 0x9aa00-0x010dad6d
  41  2 chunk 0-0
  42  7 close
  43 JPEG
  44 12 full_size = 32b200 (actual size = 0x35bbae), seek_flag = 0x83
  45  0 chunk 0-0x35bbae
  46  1 chunk 0-0
  47  7 close
  48 10 seek_flag = 0x200, name = A/CacheFlush
  49 
  50 single jpeg only, high detail scene
  51 12 full_size = 0x00c41400 (actual size = 0xCD0F69) seek_flag = 0x83
  52  0 0-0xcd0f69
  53  1 0-0
  54  7 close
  55 10 seek_flag = 0x200, name = A/CacheFlush
  56 
  57 continuous jpeg
  58 shot 1
  59 12 full_size = 0x369000 (actual 0x39af87) seek_flag = 0x83
  60  0 chunk 0-0x39af87
  61  1 chunk 0-0
  62  7 close
  63 shot 2
  64 12 full_size=0x00369200 (acutal 0x39b022) seek_flag = 0x83
  65  0 chunk 0-39b022
  66  1 chunk 0-0
  67  7 close
  68 10 seek_flag = 0x200, name = A/CacheFlush
  69 10 seek_flag = 0x200, name = A/CacheFlush
  70 (really twice, no obvious difference in params)
  71 
  72 canon raw only
  73 12 full_size = 0x010dce4a (actual size) seek_flag 3
  74  0 chunk 0-0x87200
  75  1 chunk 0x87200-0x010dce4a
  76  2 0-0
  77  7 close
  78 10 seek_flag = 0x200, name = A/CacheFlush
  79 
  80 new directory
  81 11 seek_flag = 0x100
  82 before m 12 for shot, after raw hook in capt_seq but before
  83 spytask calls remotecap_raw_available due to sleep loops
  84 
  85 bypassing PrepareDirectory_0 seems to cause hang on switch to play mode
  86 */
  87 
  88 #include "../../../generic/filewrite.c"
  89 
  90 #ifdef FILEWRITE_DEBUG_LOG
  91 void log_fwt_msg(fwt_data_struct *fwd)
  92 {
  93     int m=fwd->unkn1;
  94     _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);
  95     _LogCameraEvent(0x60,"fw %s",fwd->name);
  96     if(m >= 0 && m <=6) {
  97         _LogCameraEvent(0x60,"fw chunk adr:0x%08x l:0x%08x",fwd->pdc[m].address,fwd->pdc[m].length);
  98     }
  99     _LogCameraEvent(0x60,"fw u %08x %08x %08x %08x %08x %08x",fwd->unkn2,fwd->unkn3,fwd->unkn4,fwd->unkn5,fwd->unkn6);
 100 }
 101 
 102 void log_fwt_start(void)
 103 {
 104     _LogCameraEvent(0x60,"fw start");
 105 }
 106 #endif
 107 
 108 /*************************************************************/
 109 // task_FileWrite 0xfc06b31d  -s=task_FileWrite -c=43 -f=chdk
 110 void __attribute__((naked,noinline)) filewritetask() {
 111 asm volatile (
 112 "    push    {r3, r4, r5, r6, r7, lr}\n"
 113 #ifdef FILEWRITE_DEBUG_LOG
 114 "bl log_fwt_start\n"
 115 #endif
 116 "    ldr     r6, =0x09200001\n"
 117 "    movw    r7, #0x428\n"
 118 "    ldr     r5, =0x00026560\n"
 119 "    adds    r6, #0x12\n"
 120 "loc_fc06b328:\n"
 121 "    mov     r1, sp\n"
 122 "    movs    r2, #0\n"
 123 "    ldr     r0, [r5, #0x10]\n"
 124 "    blx     sub_fc2ef8ec\n" // j_ReceiveMessageQueue
 125 "    cbz     r0, loc_fc06b33e\n"
 126 "    movs    r0, #0\n"
 127 "    mov     r2, r7\n"
 128 "    ldr     r1, =0xfc06b450\n" //  *"dwFWrite.c"
 129 "    blx     sub_fc2ef9e4\n" // j_DebugAssert
 130 "loc_fc06b33e:\n"
 131 #ifdef FILEWRITE_DEBUG_LOG
 132 "ldr     r0, [sp]\n"
 133 "bl log_fwt_msg\n"
 134 #endif
 135 "    ldr     r0, [sp]\n"
 136 "    ldr     r1, [r0]\n"
 137 "    cmp     r1, #0xd\n"
 138 "    bhs     loc_fc06b328\n"
 139 "    tbb     [pc, r1]\n" // (jumptable r1 13 elements)
 140 "branchtable_fc06b34a:\n"
 141 "    .byte((loc_fc06b38c - branchtable_fc06b34a) / 2)\n" // (case 0)
 142 "    .byte((loc_fc06b38c - branchtable_fc06b34a) / 2)\n" // (case 1)
 143 "    .byte((loc_fc06b38c - branchtable_fc06b34a) / 2)\n" // (case 2)
 144 "    .byte((loc_fc06b38c - branchtable_fc06b34a) / 2)\n" // (case 3)
 145 "    .byte((loc_fc06b38c - branchtable_fc06b34a) / 2)\n" // (case 4)
 146 "    .byte((loc_fc06b38c - branchtable_fc06b34a) / 2)\n" // (case 5)
 147 "    .byte((loc_fc06b38c - branchtable_fc06b34a) / 2)\n" // (case 6)
 148 "    .byte((loc_fc06b392 - branchtable_fc06b34a) / 2)\n" // (case 7)
 149 "    .byte((loc_fc06b358 - branchtable_fc06b34a) / 2)\n" // (case 8)
 150 "    .byte((loc_fc06b36a - branchtable_fc06b34a) / 2)\n" // (case 9)
 151 "    .byte((loc_fc06b386 - branchtable_fc06b34a) / 2)\n" // (case 10)
 152 "    .byte((loc_fc06b35e - branchtable_fc06b34a) / 2)\n" // (case 11)
 153 "    .byte((loc_fc06b364 - branchtable_fc06b34a) / 2)\n" // (case 12)
 154 ".align 1\n"
 155 "loc_fc06b358:\n"   // case 8 - calls close, not seen in normal shooting
 156 "    bl      sub_fc06b50a\n"
 157 "    b       loc_fc06b328\n"
 158 "loc_fc06b35e:\n"   // case 11 - create dir, TODO not patched
 159 "    bl      sub_fc06b556\n"
 160 "    b       loc_fc06b328\n"
 161 "loc_fc06b364:\n"   // case 12 - patch for open, main hoook
 162 "    bl      sub_fc06b0cc_my\n"
 163 "    b       loc_fc06b328\n"
 164 "loc_fc06b36a:\n"   // case 9 - not seen in normal shooting
 165 "    ldr     r1, [r0, #4]\n"
 166 "    movs    r2, #0\n"
 167 "    mov     r4, r0\n"
 168 "    ldr     r0, [r5, #4]\n"
 169 "    bl      _lseek\n" // -> fwt_lseek ?
 170 "    adds    r0, r0, #1\n"
 171 "    bne     loc_fc06b328\n"
 172 "    movs    r0, #7\n"
 173 "    mov     r1, r4\n"
 174 "    str     r6, [r4, #0x14]\n"
 175 "    bl      sub_fc06b054\n"
 176 "    b       loc_fc06b328\n"
 177 "loc_fc06b386:\n"   // case 10 - cache flush, patch for ignore write
 178 "    bl      sub_fc06b5aa\n"
 179 "    b       loc_fc06b328\n"
 180 "loc_fc06b38c:\n"   // case 0-6  - write stage
 181 "    bl      sub_fc06b602_my\n"
 182 "    b       loc_fc06b328\n"
 183 "loc_fc06b392:\n"   // case 7 - close stage
 184 "    bl      sub_fc06b1f2_my\n"
 185 "    b       loc_fc06b328\n"
 186 ".ltorg\n"
 187     );
 188 }
 189 
 190 #if 0
 191 // -s=0xfc06b50b -c=30 -f=chdk
 192 void __attribute__((naked,noinline)) sub_fc06b50a_my() {
 193 asm volatile (
 194 "    push    {r2, r3, r4, lr}\n"
 195 "    ldr     r4, =0x00026560\n"
 196 "    movs    r0, #0\n"
 197 "    str     r0, [sp]\n"
 198 "loc_fc06b512:\n"
 199 "    mov     r1, sp\n"
 200 "    ldr     r0, [r4, #0x10]\n"
 201 "    blx     sub_fc2ef8e4\n" // j_GetNumberOfPostedMessages
 202 "    ldr     r0, [sp]\n"
 203 "    cbz     r0, loc_fc06b52a\n"
 204 "    ldr     r0, [r4, #0x10]\n"
 205 "    movs    r2, #0\n"
 206 "    add     r1, sp, #4\n"
 207 "    blx     sub_fc2ef8ec\n" // j_ReceiveMessageQueue
 208 "    b       loc_fc06b512\n"
 209 "loc_fc06b52a:\n"
 210 "    ldr     r0, [r4, #4]\n"
 211 "    adds    r1, r0, #1\n"
 212 "    beq     loc_fc06b54e\n"
 213 "    bl      sub_fc3580fc\n" // j_Close_FW
 214 "    mov.w   r0, #-1\n"
 215 "    str     r0, [r4, #4]\n"
 216 "    movs    r1, #0\n"
 217 "    movs    r0, #0x48\n"
 218 "    bl      sub_fc351f1c\n"
 219 "    ldr     r0, =0x001c83a0\n"
 220 "    bl      sub_fc357e84\n"
 221 "    movs    r1, #0\n"
 222 "    bl      sub_fc073c34\n"
 223 "loc_fc06b54e:\n"
 224 "    ldr     r0, [r4, #0xc]\n"
 225 "    blx     sub_fc2ef96c\n"
 226 "    pop     {r2, r3, r4, pc}\n"
 227 ".ltorg\n"
 228     );
 229 }
 230 #endif
 231 
 232 #if 0
 233 // -s=0xfc06b557 -c=32 -f=chdk
 234 void __attribute__((naked,noinline)) sub_fc06b556_my() {
 235 asm volatile (
 236 "    push    {r4, r5, r6, lr}\n"
 237 "    ldr     r5, =0x00026560\n"
 238 "    mov     r4, r0\n"
 239 "    ldr     r0, [r5, #0x18]\n"
 240 "    cbz     r0, loc_fc06b562\n"
 241 "    blx     r0\n"
 242 "loc_fc06b562:\n"
 243 "    add.w   r0, r4, #0x5c\n"
 244 "    mov     r6, r0\n"
 245 "    bl      sub_fc357e84\n" // mounter.c
 246 "    movs    r1, #0\n"
 247 "    bl      sub_fc073bd6\n" // fileio semaphore
 248 "    movs    r1, #0\n"
 249 "    movs    r0, #0x47\n"
 250 "    bl      sub_fc351f1c\n" // DSIC:0x47,0
 251 "    ldr     r0, [r4, #0x10]\n"
 252 "    bl      sub_fc0cfdae\n"
 253 "    mov     r0, r6\n"
 254 "    bl      sub_fc35849e\n" // PrepareDirectory_0
 255 "    movs    r1, #0\n"
 256 "    movs    r0, #0x48\n"
 257 "    bl      sub_fc351f1c\n" // DSIC:0x48,0
 258 "    mov     r0, r6\n"
 259 "    bl      sub_fc357e84\n"
 260 "    ldr     r1, [r5, #0x1c]\n"
 261 "    bl      sub_fc073c34\n"
 262 "    ldr     r1, [r5, #0x14]\n"
 263 "    cmp     r1, #0\n"
 264 "    beq     loc_fc06b5a8\n"
 265 "    ldr     r0, [r4, #0x14]\n"
 266 "    pop.w   {r4, r5, r6, lr}\n"
 267 "    bx      r1\n"
 268 "loc_fc06b5a8:\n"
 269 "    pop     {r4, r5, r6, pc}\n"
 270 ".ltorg\n"
 271     );
 272 }
 273 #endif
 274 
 275 // -s=0xfc06b0cd -c=121 -f=chdk
 276 void __attribute__((naked,noinline)) sub_fc06b0cc_my() {
 277 asm volatile (
 278 "    push.w  {r4, r5, r6, r7, r8, sb, lr}\n"
 279 "    mov     r4, r0\n"
 280 //hook placed here to avoid conditional branch a few instructions below (watch out for registers!)
 281 //"  mov   r0, r4\n"      //data block start, commented out as R0 is already holding what we need
 282 "    bl filewrite_main_hook\n"
 283 "    mov     r0, r4\n"      //restore register(s)
 284 "    ldr     r0, [r0, #0x50]\n"
 285 "    sub     sp, #0x3c\n"
 286 "    lsls    r1, r0, #0x1f\n"
 287 "    bne     loc_fc06b0de\n"
 288 "    lsls    r0, r0, #0x1d\n"
 289 "    bpl     loc_fc06b1ce\n"
 290 "loc_fc06b0de:\n"
 291 "    ldr     r7, =0x00026560\n"
 292 "    ldr     r0, [r7, #0x18]\n"
 293 "    cbz     r0, loc_fc06b0e6\n"
 294 "    blx     r0\n"
 295 "loc_fc06b0e6:\n"
 296 "    add.w   r0, r4, #0x5c\n"
 297 "    mov     r8, r0\n"
 298 "    bl      sub_fc357e84\n"
 299 "    movs    r1, #0\n"
 300 "    bl      sub_fc073bd6\n"
 301 "    movs    r1, #0\n"
 302 "    movs    r0, #0x47\n"
 303 "    bl      sub_fc351f1c\n"
 304 "    ldr     r0, [r4, #0x50]\n"
 305 "    lsls    r0, r0, #0x1f\n"
 306 "    beq     loc_fc06b1ce\n"
 307 "    ldr     r0, [r4, #0x10]\n"
 308 "    bl      sub_fc0cfdae\n"
 309 "    ldr     r0, [r4, #0x50]\n"
 310 "    movw    r5, #0x301\n"
 311 "    lsls    r1, r0, #0x1b\n"
 312 "    bpl     loc_fc06b118\n"
 313 "    movs    r5, #9\n"
 314 "    b       loc_fc06b11e\n"
 315 "loc_fc06b118:\n"
 316 "    lsls    r1, r0, #0x19\n"
 317 "    bpl     loc_fc06b11e\n"
 318 "    movs    r5, #1\n"
 319 "loc_fc06b11e:\n"
 320 "    lsls    r0, r0, #0x1a\n"
 321 "    bmi     loc_fc06b128\n"
 322 "    ldr     r0, [r4, #0x58]\n"
 323 "    cmp     r0, #1\n"
 324 "    bne     loc_fc06b12c\n"
 325 "loc_fc06b128:\n"
 326 "    orr     r5, r5, #0x8000\n"
 327 "loc_fc06b12c:\n"
 328 "    movw    sb, #0x1b6\n"
 329 "    ldr     r6, [r4, #0x10]\n"
 330 "    mov     r2, sb\n"
 331 "    mov     r1, r5\n"
 332 "    mov     r0, r8\n"
 333 //"    bl      sub_fc3580fa\n" // j_Open_FW
 334 "    bl      fwt_open\n" // +
 335 "    adds    r1, r0, #1\n"
 336 "    bne     loc_fc06b17a\n"
 337 "    mov     r0, r8\n"
 338 "    bl      sub_fc35849e\n" // PrepareDirectory_0
 339 "    movs    r2, #0xf\n"
 340 "    mov     r1, r8\n"
 341 "    add     r0, sp, #4\n"
 342 "    blx     sub_fc2efa14\n"
 343 "    movs    r0, #0\n"
 344 "    strb.w  r0, [sp, #0x13]\n"
 345 "    movw    r1, #0x41ff\n"
 346 "    str     r1, [sp, #0x24]\n"
 347 "    strd    r0, r6, [sp, #0x2c]\n"
 348 "    movs    r1, #0x10\n"
 349 "    str     r6, [sp, #0x34]\n"
 350 "    add     r0, sp, #4\n"
 351 "    str     r6, [sp, #0x38]\n"
 352 "    str     r1, [sp, #0x28]\n"
 353 "    add     r1, sp, #0x24\n"
 354 "    bl      sub_fc0fc21e\n"
 355 "    mov     r2, sb\n"
 356 "    mov     r1, r5\n"
 357 "    mov     r0, r8\n"
 358 "    bl      _Open\n" // j_Open_FW
 359 "loc_fc06b17a:\n"
 360 "    mov     r5, r0\n"
 361 "    str     r0, [r7, #4]\n"
 362 "    adds    r0, r0, #1\n"
 363 "    bne     loc_fc06b1a6\n"
 364 "    movs    r1, #0\n"
 365 "    movs    r0, #0x48\n"
 366 "    bl      sub_fc351f1c\n" // "DSIC:0x48,0"
 367 "    mov     r0, r8\n"
 368 "    bl      sub_fc357e84\n"
 369 "    ldr     r1, [r7, #0x1c]\n"
 370 "    bl      sub_fc073c34\n"
 371 "    ldr     r1, [r7, #0x14]\n"
 372 "    cmp     r1, #0\n"
 373 "    beq     loc_fc06b1ec\n"
 374 "    add     sp, #0x3c\n"
 375 "    ldr     r0, =0x09200001\n"
 376 "    pop.w   {r4, r5, r6, r7, r8, sb, lr}\n"
 377 "    bx      r1\n"
 378 "loc_fc06b1a6:\n"
 379 "    ldr     r0, =0x001c83a0\n"
 380 "    movs    r2, #0x20\n"
 381 "    mov     r1, r8\n"
 382 "    blx     sub_fc2efa1c\n" // j_dry_memcpy
 383 // TODO looks equivalent to elph130, not verified that it's required
 384 //mod start
 385 "    LDR R3, =current_write_ignored\n"
 386 "    LDR R3, [R3]\n"
 387 "    cbnz r3,loc_C\n" // jump over the next block
 388 //mod end
 389 "    ldr     r0, [r4, #0x50]\n"
 390 "    lsls    r0, r0, #0x18\n"
 391 "    bpl     loc_fc06b1ce\n"
 392 "    ldr     r1, [r4, #0xc]\n"
 393 "    mov     r0, r5\n"
 394 "    bl      sub_fc3582b4\n"
 395 "    cbnz    r0, loc_fc06b1cc\n"
 396 "    ldr     r0, =0x09200001\n"
 397 "    mov     r1, r4\n"
 398 "    adds    r0, #0x16\n"
 399 "    str     r0, [r4, #0x14]\n"
 400 "    movs    r0, #7\n"
 401 "    b       loc_fc06b1e4\n"
 402 "loc_fc06b1cc:\n"
 403 "    b       loc_fc06b1ce\n"
 404 "loc_fc06b1ce:\n"
 405 "loc_C:\n"
 406 "    ldr     r0, [r4, #0x50]\n"
 407 "    lsls    r0, r0, #0x19\n"
 408 "    bmi     loc_fc06b1d8\n"
 409 "    ldr     r0, [r4, #4]\n"
 410 "    cbz     r0, loc_fc06b1e0\n"
 411 "loc_fc06b1d8:\n"
 412 "    movs    r0, #9\n"
 413 "    mov     r1, r4\n"
 414 "    bl      sub_fc06b054\n"
 415 "loc_fc06b1e0:\n"
 416 "    movs    r0, #0\n"
 417 "    mov     r1, r4\n"
 418 "loc_fc06b1e4:\n"
 419 "    add     sp, #0x3c\n"
 420 "    pop.w   {r4, r5, r6, r7, r8, sb, lr}\n"
 421 //"    b.w     loc_fc06b054\n"
 422 "    ldr     pc,=0xfc06b055\n" // avoid stub
 423 "loc_fc06b1ec:\n"
 424 "    add     sp, #0x3c\n"
 425 "    pop.w   {r4, r5, r6, r7, r8, sb, pc}\n"
 426 ".ltorg\n"
 427     );
 428 }
 429 
 430 #if 0
 431 // -s=0xfc06b5ab -c=35 -f=chdk
 432 void __attribute__((naked,noinline)) sub_fc06b5aa_my() {
 433 asm volatile (
 434 "    push    {r3, r4, r5, r6, r7, lr}\n"
 435 "    ldrsb.w r1, [r0, #0x5c]\n"
 436 "    mov     r4, r0\n"
 437 "    cmp     r1, #0\n"
 438 "    beq     loc_fc06b600\n"
 439 "    ldr     r5, =0x00026560\n"
 440 "    movs    r0, #0\n"
 441 "    strb.w  r1, [sp]\n"
 442 "    strb.w  r0, [sp, #1]\n"
 443 "    ldr     r1, [r5, #0x18]\n"
 444 "    cbz     r1, loc_fc06b5c8\n"
 445 "    blx     r1\n"
 446 "loc_fc06b5c8:\n"
 447 "    add.w   r0, r4, #0x5c\n"
 448 "    mov     r6, r0\n"
 449 "    bl      sub_fc357e84\n"
 450 "    movs    r1, #0\n"
 451 "    bl      sub_fc073bd6\n"
 452 "    mov     r0, sp\n"
 453 "    bl      sub_fc0cfdba\n"
 454 "    mov     r4, r0\n"
 455 "    mov     r0, r6\n"
 456 "    bl      sub_fc357e84\n"
 457 "    ldr     r1, [r5, #0x1c]\n"
 458 "    bl      sub_fc073c34\n"
 459 "    ldr     r1, [r5, #0x14]\n"
 460 "    cmp     r1, #0\n"
 461 "    beq     loc_fc06b600\n"
 462 "    cmp     r4, #1\n"
 463 "    bne     loc_fc06b5fa\n"
 464 "    ldr     r0, =0x09200006\n"
 465 "    b       loc_fc06b5fe\n"
 466 "loc_fc06b5fa:\n"
 467 "    ldr     r0, =0x09200006\n"
 468 "    subs    r0, r0, #1\n"
 469 "loc_fc06b5fe:\n"
 470 "    blx     r1\n"
 471 "loc_fc06b600:\n"
 472 "    pop     {r3, r4, r5, r6, r7, pc}\n"
 473 ".ltorg\n"
 474     );
 475 }
 476 #endif
 477 
 478 // message 0-6 - filewrite chunks
 479 // -s=0xfc06b603 -c=65 -f=chdk
 480 void __attribute__((naked,noinline)) sub_fc06b602_my() {
 481 asm volatile (
 482 "    push.w  {r4, r5, r6, r7, r8, sb, sl, lr}\n"
 483 "    mov     r5, r0\n"
 484 "    ldr     r0, [r0]\n"
 485 "    cmp     r0, #6\n"
 486 "    bhi     loc_fc06b61a\n"
 487 "    add.w   r0, r5, r0, lsl #3\n"
 488 "    ldrd    r7, r6, [r0, #0x18]\n"
 489 "    cbnz    r6, loc_fc06b62e\n"
 490 "    b       loc_fc06b628\n"
 491 "loc_fc06b61a:\n"
 492 "    movw    r2, #0x36d\n"
 493 "    ldr     r1, =0xfc06b450\n" //  *"dwFWrite.c"
 494 "    movs    r0, #0\n"
 495 "    blx     sub_fc2ef9e4\n" // j_DebugAssert
 496 "loc_fc06b628:\n"
 497 "    movs    r0, #7\n"
 498 "    mov     r1, r5\n"
 499 "    b       loc_fc06b69e\n"
 500 "loc_fc06b62e:\n"
 501 "    ldr.w   sl, =0x00026560\n"
 502 "    mov.w   sb, #0x1000000\n"
 503 "    mov     r4, r6\n"
 504 "loc_fc06b638:\n"
 505 "    ldr     r0, [r5, #4]\n"
 506 "    cmp     r4, sb\n"
 507 "    mov     r1, sb\n"
 508 "    bhi     loc_fc06b642\n"
 509 "    mov     r1, r4\n"
 510 "loc_fc06b642:\n"
 511 "    lsls    r2, r0, #8\n"
 512 "    beq     loc_fc06b654\n"
 513 "    bic     r0, r0, #0xff000000\n"
 514 "    rsb.w   r0, r0, #0x1000000\n"
 515 "    cmp     r1, r0\n"
 516 "    bls     loc_fc06b654\n"
 517 "    mov     r1, r0\n"
 518 "loc_fc06b654:\n"
 519 "    ldr.w   r0, [sl, #4]\n"
 520 "    mov     r8, r1\n"
 521 "    mov     r2, r1\n"
 522 "    mov     r1, r7\n"
 523 //"    bl      sub_fc3581a2\n" // j_Write_FW
 524 "    bl      fwt_write\n" // +
 525 "    ldr     r1, [r5, #4]\n"
 526 "    cmp     r8, r0\n"
 527 "    add     r1, r0\n"
 528 "    str     r1, [r5, #4]\n"
 529 "    beq     loc_fc06b67e\n"
 530 "    adds    r0, r0, #1\n"
 531 "    bne     loc_fc06b676\n"
 532 "    ldr     r0, =0x09200006\n"
 533 "    subs    r0, r0, #1\n"
 534 "    b       loc_fc06b67a\n"
 535 "loc_fc06b676:\n"
 536 "    ldr     r0, =0x09200006\n"
 537 "    adds    r0, #0xf\n"
 538 "loc_fc06b67a:\n"
 539 "    str     r0, [r5, #0x14]\n"
 540 "    b       loc_fc06b628\n"
 541 "loc_fc06b67e:\n"
 542 "    subs    r4, r4, r0\n"
 543 "    cmp     r4, r6\n"
 544 "    add     r7, r0\n"
 545 "    blo     loc_fc06b694\n"
 546 "    movw    r2, #0x398\n"
 547 "    ldr     r1, =0xfc06b450\n" //  *"dwFWrite.c"
 548 "    movs    r0, #0\n"
 549 "    blx     sub_fc2ef9e4\n" // j_DebugAssert
 550 "loc_fc06b694:\n"
 551 "    cmp     r4, #0\n"
 552 "    bne     loc_fc06b638\n"
 553 "    ldr     r0, [r5]\n"
 554 "    mov     r1, r5\n"
 555 "    adds    r0, r0, #1\n"
 556 "loc_fc06b69e:\n"
 557 "    pop.w   {r4, r5, r6, r7, r8, sb, sl, lr}\n"
 558 //"    b       loc_fc06b054\n"
 559 "    ldr     pc,=0xfc06b055\n"
 560 ".ltorg\n"
 561     );
 562 }
 563 
 564 // message 7 - close
 565 // -s=0xfc06b1f3 -c=127 -f=chdk
 566 void __attribute__((naked,noinline)) sub_fc06b1f2_my() {
 567 asm volatile (
 568 "    push    {r4, r5, r6, lr}\n"
 569 "    mov     r4, r0\n"
 570 "    ldr     r0, [r0, #0x50]\n"
 571 "    ldr     r5, =0x00026560\n"
 572 "    sub     sp, #0x38\n"
 573 "    lsls    r1, r0, #0x1e\n"
 574 "    bmi     loc_fc06b206\n"
 575 "    lsls    r0, r0, #0x1c\n"
 576 "    bpl     loc_fc06b302\n"
 577 "    b       loc_fc06b248\n"
 578 "loc_fc06b206:\n"
 579 "    lsls    r0, r0, #0x18\n"
 580 "    bpl     loc_fc06b224\n"
 581 "    ldrd    r1, r0, [r4, #8]\n"
 582 "    cmp     r1, r0\n"
 583 "    beq     loc_fc06b224\n"
 584 "    ldr     r0, [r5, #4]\n"
 585 "    bl      sub_fc3582b4\n"
 586 "    cbnz    r0, loc_fc06b220\n"
 587 "    ldr     r0, =0x09200001\n"
 588 "    adds    r0, #0x16\n"
 589 "    str     r0, [r4, #0x14]\n"
 590 "loc_fc06b220:\n"
 591 "    ldr     r0, [r4, #8]\n"
 592 "    str     r0, [sp, #0x28]\n"
 593 "loc_fc06b224:\n"
 594 "    ldr     r0, [r5, #4]\n"
 595 "    adds    r1, r0, #1\n"
 596 "    beq     loc_fc06b248\n"
 597 "    ldr     r6, =0x09200001\n"
 598 "    ldr     r1, [r4, #0x58]\n"
 599 "    adds    r6, r6, #2\n"
 600 "    cmp     r1, #1\n"
 601 "    bne     loc_fc06b23a\n"
 602 //mod start
 603 "    LDR R3, =current_write_ignored\n"
 604 "    LDR R3, [R3]\n"
 605 "    cbnz R3,loc_D\n" // jump over the next block
 606 //mod end
 607 "    bl      sub_fc3580fe\n"
 608 "    b       loc_fc06b23e\n"
 609 "loc_fc06b23a:\n"
 610 "loc_D:\n"
 611 //"    bl      sub_fc3580fc\n" // j_Close_FW
 612 "    bl      fwt_close\n" // +
 613 "loc_fc06b23e:\n"
 614 "    cbz     r0, loc_fc06b242\n"
 615 "    str     r6, [r4, #0x14]\n"
 616 "loc_fc06b242:\n"
 617 "    mov.w   r0, #-1\n"
 618 "    str     r0, [r5, #4]\n"
 619 "loc_fc06b248:\n"
 620 "    add.w   r6, r4, #0x5c\n"
 621 "    ldr     r0, [r4, #0x14]\n"
 622 "    lsls    r0, r0, #0x1f\n"
 623 "    bne     loc_fc06b2f0\n"
 624 "    ldr     r0, [r4, #0x50]\n"
 625 "    lsls    r1, r0, #0x1f\n"
 626 "    beq     loc_fc06b274\n"
 627 "    movw    r0, #0x81ff\n"
 628 "    str     r0, [sp, #0x20]\n"
 629 "    movs    r0, #0x20\n"
 630 "    str     r0, [sp, #0x24]\n"
 631 "    ldr     r0, [r4, #4]\n"
 632 "    str     r0, [sp, #0x28]\n"
 633 "    ldr     r0, [r4, #0x10]\n"
 634 "    str     r0, [sp, #0x2c]\n"
 635 "    ldr     r0, [r4, #0x10]\n"
 636 "    str     r0, [sp, #0x30]\n"
 637 "    ldr     r0, [r4, #0x10]\n"
 638 "    str     r0, [sp, #0x34]\n"
 639 "    b       loc_fc06b296\n"
 640 "loc_fc06b274:\n"
 641 "    lsls    r0, r0, #0x1b\n"
 642 "    bpl     loc_fc06b296\n"
 643 "    add     r1, sp, #0x20\n"
 644 "    mov     r0, r6\n"
 645 "    bl      sub_fc0fc1a8\n"
 646 "    cbnz    r0, loc_fc06b28e\n"
 647 "    movs    r0, #0\n"
 648 "    movw    r2, #0x3ee\n"
 649 "    ldr     r1, =0xfc06b450\n" //  *"dwFWrite.c"
 650 "    blx     sub_fc2ef9e4\n" // j_DebugAssert
 651 "loc_fc06b28e:\n"
 652 "    ldr     r0, [sp, #0x28]\n"
 653 "    ldr     r1, [r4, #4]\n"
 654 "    add     r0, r1\n"
 655 "    str     r0, [sp, #0x28]\n"
 656 "loc_fc06b296:\n"
 657 "    ldr     r0, [r4, #0x50]\n"
 658 "    lsls    r0, r0, #0x19\n"
 659 "    bmi     loc_fc06b2a4\n"
 660 "    add     r1, sp, #0x20\n"
 661 "    mov     r0, r6\n"
 662 "    bl      sub_fc0fc21e\n"
 663 "loc_fc06b2a4:\n"
 664 "    ldr     r0, [r4, #0x50]\n"
 665 "    lsls    r1, r0, #0x1e\n"
 666 "    bpl     loc_fc06b2f0\n"
 667 "    lsls    r0, r0, #0x1a\n"
 668 "    bpl     loc_fc06b2f0\n"
 669 "    movs    r2, #0x20\n"
 670 "    mov     r1, r6\n"
 671 "    mov     r0, sp\n"
 672 "    blx     sub_fc2efa1c\n" // j_dry_memcpy
 673 "    mov     r0, sp\n"
 674 "    bl      _strlen\n"
 675 "    add     r0, sp, r0\n"
 676 "    movs    r1, #0x54\n"
 677 "    strb    r1, [r0, #-0x3]!\n"
 678 "    movs    r1, #0x4d\n"
 679 "    strb    r1, [r0, #1]\n"
 680 "    movs    r1, #0x50\n"
 681 "    strb    r1, [r0, #2]\n"
 682 "    mov     r1, sp\n"
 683 "    mov     r0, r6\n"
 684 "    bl      sub_fc0cff86\n"
 685 "    cbnz    r0, loc_fc06b2e4\n"
 686 "    movs    r0, #0\n"
 687 "    movw    r2, #0x179\n"
 688 "    ldr     r1, =0xfc06b450\n" //  *"dwFWrite.c"
 689 "    blx     sub_fc2ef9e4\n" // j_DebugAssert
 690 "loc_fc06b2e4:\n"
 691 "    mov     r0, sp\n"
 692 "    bl      sub_fc0fc510\n"
 693 "    mov     r0, r6\n"
 694 "    bl      sub_fc0fc510\n"
 695 "loc_fc06b2f0:\n"
 696 "    movs    r1, #0\n"
 697 "    movs    r0, #0x48\n"
 698 "    bl      sub_fc351f1c\n"
 699 "    mov     r0, r6\n"
 700 "    bl      sub_fc357e84\n"
 701 "    ldr     r1, [r5, #0x1c]\n"
 702 "    b       loc_fc06b304\n"
 703 "loc_fc06b302:\n"
 704 "    b       loc_fc06b30a\n"
 705 "loc_fc06b304:\n"
 706 "    bl      sub_fc073c34\n"
 707 "    b       loc_fc06b30e\n"
 708 "loc_fc06b30a:\n"
 709 "    ldr     r0, [r5, #0x1c]\n"
 710 "    blx     r0\n"
 711 "loc_fc06b30e:\n"
 712 "    ldr     r1, [r5, #0x14]\n"
 713 "    cmp     r1, #0\n"
 714 "    beq     loc_fc06b318\n"
 715 "    ldr     r0, [r4, #0x14]\n"
 716 "    blx     r1\n"
 717 "loc_fc06b318:\n"
 718 "    add     sp, #0x38\n"
 719 "    pop     {r4, r5, r6, pc}\n"
 720 ".ltorg\n"
 721     );
 722 }

/* [<][>][^][v][top][bottom][index][help] */