root/platform/g7x/sub/100c/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_JPEG 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_JPEG];
  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"
 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 (NOT Patched)
 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 // from 100d, not checked
 191 #if 0
 192 // -s=0xfc06b50b -c=30 -f=chdk
 193 void __attribute__((naked,noinline)) sub_fc06b50a_my() {
 194 asm volatile (
 195 "    push    {r2, r3, r4, lr}\n"
 196 "    ldr     r4, =0x00026560\n"
 197 "    movs    r0, #0\n"
 198 "    str     r0, [sp]\n"
 199 "loc_fc06b512:\n"
 200 "    mov     r1, sp\n"
 201 "    ldr     r0, [r4, #0x10]\n"
 202 "    blx     sub_fc2ef8e4\n" // j_GetNumberOfPostedMessages
 203 "    ldr     r0, [sp]\n"
 204 "    cbz     r0, loc_fc06b52a\n"
 205 "    ldr     r0, [r4, #0x10]\n"
 206 "    movs    r2, #0\n"
 207 "    add     r1, sp, #4\n"
 208 "    blx     sub_fc2ef8ec\n" // j_ReceiveMessageQueue
 209 "    b       loc_fc06b512\n"
 210 "loc_fc06b52a:\n"
 211 "    ldr     r0, [r4, #4]\n"
 212 "    adds    r1, r0, #1\n"
 213 "    beq     loc_fc06b54e\n"
 214 "    bl      sub_fc3580fc\n" // j_Close_FW
 215 "    mov.w   r0, #-1\n"
 216 "    str     r0, [r4, #4]\n"
 217 "    movs    r1, #0\n"
 218 "    movs    r0, #0x48\n"
 219 "    bl      sub_fc351f1c\n"
 220 "    ldr     r0, =0x001c83a0\n"
 221 "    bl      sub_fc357e84\n"
 222 "    movs    r1, #0\n"
 223 "    bl      sub_fc073c34\n"
 224 "loc_fc06b54e:\n"
 225 "    ldr     r0, [r4, #0xc]\n"
 226 "    blx     sub_fc2ef96c\n"
 227 "    pop     {r2, r3, r4, pc}\n"
 228 ".ltorg\n"
 229     );
 230 }
 231 #endif
 232 
 233 #if 0
 234 // -s=0xfc06b557 -c=32 -f=chdk
 235 void __attribute__((naked,noinline)) sub_fc06b556_my() {
 236 asm volatile (
 237 "    push    {r4, r5, r6, lr}\n"
 238 "    ldr     r5, =0x00026560\n"
 239 "    mov     r4, r0\n"
 240 "    ldr     r0, [r5, #0x18]\n"
 241 "    cbz     r0, loc_fc06b562\n"
 242 "    blx     r0\n"
 243 "loc_fc06b562:\n"
 244 "    add.w   r0, r4, #0x5c\n"
 245 "    mov     r6, r0\n"
 246 "    bl      sub_fc357e84\n" // mounter.c
 247 "    movs    r1, #0\n"
 248 "    bl      sub_fc073bd6\n" // fileio semaphore
 249 "    movs    r1, #0\n"
 250 "    movs    r0, #0x47\n"
 251 "    bl      sub_fc351f1c\n" // DSIC:0x47,0
 252 "    ldr     r0, [r4, #0x10]\n"
 253 "    bl      sub_fc0cfdae\n"
 254 "    mov     r0, r6\n"
 255 "    bl      sub_fc35849e\n" // PrepareDirectory_0
 256 "    movs    r1, #0\n"
 257 "    movs    r0, #0x48\n"
 258 "    bl      sub_fc351f1c\n" // DSIC:0x48,0
 259 "    mov     r0, r6\n"
 260 "    bl      sub_fc357e84\n"
 261 "    ldr     r1, [r5, #0x1c]\n"
 262 "    bl      sub_fc073c34\n"
 263 "    ldr     r1, [r5, #0x14]\n"
 264 "    cmp     r1, #0\n"
 265 "    beq     loc_fc06b5a8\n"
 266 "    ldr     r0, [r4, #0x14]\n"
 267 "    pop.w   {r4, r5, r6, lr}\n"
 268 "    bx      r1\n"
 269 "loc_fc06b5a8:\n"
 270 "    pop     {r4, r5, r6, pc}\n"
 271 ".ltorg\n"
 272     );
 273 }
 274 #endif
 275 
 276 // -s=0xfc06b0cd -c=121 -f=chdk
 277 void __attribute__((naked,noinline)) sub_fc06b0cc_my() {
 278 asm volatile (
 279 "    push.w  {r4, r5, r6, r7, r8, sb, lr}\n"
 280 "    mov     r4, r0\n"
 281 //hook placed here to avoid conditional branch a few instructions below (watch out for registers!)
 282 //"  mov   r0, r4\n"      //data block start, commented out as R0 is already holding what we need
 283 "    bl filewrite_main_hook\n"
 284 "    mov     r0, r4\n"      //restore register(s)
 285 "    ldr     r0, [r0, #0x50]\n"
 286 "    sub     sp, #0x3c\n"
 287 "    lsls    r1, r0, #0x1f\n"
 288 "    bne     loc_fc06b0de\n"
 289 "    lsls    r0, r0, #0x1d\n"
 290 "    bpl     loc_fc06b1ce\n"
 291 "loc_fc06b0de:\n"
 292 "    ldr     r7, =0x00026560\n"
 293 "    ldr     r0, [r7, #0x18]\n"
 294 "    cbz     r0, loc_fc06b0e6\n"
 295 "    blx     r0\n"
 296 "loc_fc06b0e6:\n"
 297 "    add.w   r0, r4, #0x5c\n"
 298 "    mov     r8, r0\n"
 299 "    bl      sub_fc357e84\n"
 300 "    movs    r1, #0\n"
 301 "    bl      sub_fc073bd6\n"
 302 "    movs    r1, #0\n"
 303 "    movs    r0, #0x47\n"
 304 "    bl      sub_fc351f1c\n"
 305 "    ldr     r0, [r4, #0x50]\n"
 306 "    lsls    r0, r0, #0x1f\n"
 307 "    beq     loc_fc06b1ce\n"
 308 "    ldr     r0, [r4, #0x10]\n"
 309 "    bl      sub_fc0cfdae\n"
 310 "    ldr     r0, [r4, #0x50]\n"
 311 "    movw    r5, #0x301\n"
 312 "    lsls    r1, r0, #0x1b\n"
 313 "    bpl     loc_fc06b118\n"
 314 "    movs    r5, #9\n"
 315 "    b       loc_fc06b11e\n"
 316 "loc_fc06b118:\n"
 317 "    lsls    r1, r0, #0x19\n"
 318 "    bpl     loc_fc06b11e\n"
 319 "    movs    r5, #1\n"
 320 "loc_fc06b11e:\n"
 321 "    lsls    r0, r0, #0x1a\n"
 322 "    bmi     loc_fc06b128\n"
 323 "    ldr     r0, [r4, #0x58]\n"
 324 "    cmp     r0, #1\n"
 325 "    bne     loc_fc06b12c\n"
 326 "loc_fc06b128:\n"
 327 "    orr     r5, r5, #0x8000\n"
 328 "loc_fc06b12c:\n"
 329 "    movw    sb, #0x1b6\n"
 330 "    ldr     r6, [r4, #0x10]\n"
 331 "    mov     r2, sb\n"
 332 "    mov     r1, r5\n"
 333 "    mov     r0, r8\n"
 334 //"    bl      sub_fc3580fa\n" // j_Open_FW
 335 "    bl      fwt_open\n" // +
 336 "    adds    r1, r0, #1\n"
 337 "    bne     loc_fc06b17a\n"
 338 "    mov     r0, r8\n"
 339 "    bl      sub_fc35849e\n" // PrepareDirectory_0
 340 "    movs    r2, #0xf\n"
 341 "    mov     r1, r8\n"
 342 "    add     r0, sp, #4\n"
 343 "    blx     sub_fc2efa14\n"
 344 "    movs    r0, #0\n"
 345 "    strb.w  r0, [sp, #0x13]\n"
 346 "    movw    r1, #0x41ff\n"
 347 "    str     r1, [sp, #0x24]\n"
 348 "    strd    r0, r6, [sp, #0x2c]\n"
 349 "    movs    r1, #0x10\n"
 350 "    str     r6, [sp, #0x34]\n"
 351 "    add     r0, sp, #4\n"
 352 "    str     r6, [sp, #0x38]\n"
 353 "    str     r1, [sp, #0x28]\n"
 354 "    add     r1, sp, #0x24\n"
 355 "    bl      sub_fc0fc21e\n"
 356 "    mov     r2, sb\n"
 357 "    mov     r1, r5\n"
 358 "    mov     r0, r8\n"
 359 "    bl      _Open\n" // j_Open_FW
 360 "loc_fc06b17a:\n"
 361 "    mov     r5, r0\n"
 362 "    str     r0, [r7, #4]\n"
 363 "    adds    r0, r0, #1\n"
 364 "    bne     loc_fc06b1a6\n"
 365 "    movs    r1, #0\n"
 366 "    movs    r0, #0x48\n"
 367 "    bl      sub_fc351f1c\n"
 368 "    mov     r0, r8\n"
 369 "    bl      sub_fc357e84\n"
 370 "    ldr     r1, [r7, #0x1c]\n"
 371 "    bl      sub_fc073c34\n"
 372 "    ldr     r1, [r7, #0x14]\n"
 373 "    cmp     r1, #0\n"
 374 "    beq     loc_fc06b1ec\n"
 375 "    add     sp, #0x3c\n"
 376 "    ldr     r0, =0x09200001\n"
 377 "    pop.w   {r4, r5, r6, r7, r8, sb, lr}\n"
 378 "    bx      r1\n"
 379 "loc_fc06b1a6:\n"
 380 "    ldr     r0, =0x001c83a0\n"
 381 "    movs    r2, #0x20\n"
 382 "    mov     r1, r8\n"
 383 "    blx     sub_fc2efa1c\n" // j_dry_memcpy
 384 // TODO looks equivalent to elph130, not verified that it's required
 385 //mod start
 386 "    LDR R3, =current_write_ignored\n"
 387 "    LDR R3, [R3]\n"
 388 "    cbnz r3,loc_C\n" // jump over the next block
 389 //mod end
 390 "    ldr     r0, [r4, #0x50]\n"
 391 "    lsls    r0, r0, #0x18\n"
 392 "    bpl     loc_fc06b1ce\n"
 393 "    ldr     r1, [r4, #0xc]\n"
 394 "    mov     r0, r5\n"
 395 "    bl      sub_fc3582b4\n"
 396 "    cbnz    r0, loc_fc06b1cc\n"
 397 "    ldr     r0, =0x09200001\n"
 398 "    mov     r1, r4\n"
 399 "    adds    r0, #0x16\n"
 400 "    str     r0, [r4, #0x14]\n"
 401 "    movs    r0, #7\n"
 402 "    b       loc_fc06b1e4\n"
 403 "loc_fc06b1cc:\n"
 404 "    b       loc_fc06b1ce\n"
 405 "loc_fc06b1ce:\n"
 406 "loc_C:\n"
 407 "    ldr     r0, [r4, #0x50]\n"
 408 "    lsls    r0, r0, #0x19\n"
 409 "    bmi     loc_fc06b1d8\n"
 410 "    ldr     r0, [r4, #4]\n"
 411 "    cbz     r0, loc_fc06b1e0\n"
 412 "loc_fc06b1d8:\n"
 413 "    movs    r0, #9\n"
 414 "    mov     r1, r4\n"
 415 "    bl      sub_fc06b054\n"
 416 "loc_fc06b1e0:\n"
 417 "    movs    r0, #0\n"
 418 "    mov     r1, r4\n"
 419 "loc_fc06b1e4:\n"
 420 "    add     sp, #0x3c\n"
 421 "    pop.w   {r4, r5, r6, r7, r8, sb, lr}\n"
 422 //"    b       loc_fc06b054\n"
 423 "    ldr     pc,=0xfc06b055\n" // avoid stub
 424 "loc_fc06b1ec:\n"
 425 "    add     sp, #0x3c\n"
 426 "    pop.w   {r4, r5, r6, r7, r8, sb, pc}\n"
 427 ".ltorg\n"
 428     );
 429 }
 430 
 431 // from 100d, not checked
 432 #if 0
 433 // -s=0xfc06b5ab -c=35 -f=chdk
 434 void __attribute__((naked,noinline)) sub_fc06b5aa_my() {
 435 asm volatile (
 436 "    push    {r3, r4, r5, r6, r7, lr}\n"
 437 "    ldrsb.w r1, [r0, #0x5c]\n"
 438 "    mov     r4, r0\n"
 439 "    cmp     r1, #0\n"
 440 "    beq     loc_fc06b600\n"
 441 "    ldr     r5, =0x00026560\n"
 442 "    movs    r0, #0\n"
 443 "    strb.w  r1, [sp]\n"
 444 "    strb.w  r0, [sp, #1]\n"
 445 "    ldr     r1, [r5, #0x18]\n"
 446 "    cbz     r1, loc_fc06b5c8\n"
 447 "    blx     r1\n"
 448 "loc_fc06b5c8:\n"
 449 "    add.w   r0, r4, #0x5c\n"
 450 "    mov     r6, r0\n"
 451 "    bl      sub_fc357e84\n"
 452 "    movs    r1, #0\n"
 453 "    bl      sub_fc073bd6\n"
 454 "    mov     r0, sp\n"
 455 "    bl      sub_fc0cfdba\n"
 456 "    mov     r4, r0\n"
 457 "    mov     r0, r6\n"
 458 "    bl      sub_fc357e84\n"
 459 "    ldr     r1, [r5, #0x1c]\n"
 460 "    bl      sub_fc073c34\n"
 461 "    ldr     r1, [r5, #0x14]\n"
 462 "    cmp     r1, #0\n"
 463 "    beq     loc_fc06b600\n"
 464 "    cmp     r4, #1\n"
 465 "    bne     loc_fc06b5fa\n"
 466 "    ldr     r0, =0x09200006\n"
 467 "    b       loc_fc06b5fe\n"
 468 "loc_fc06b5fa:\n"
 469 "    ldr     r0, =0x09200006\n"
 470 "    subs    r0, r0, #1\n"
 471 "loc_fc06b5fe:\n"
 472 "    blx     r1\n"
 473 "loc_fc06b600:\n"
 474 "    pop     {r3, r4, r5, r6, r7, pc}\n"
 475 ".ltorg\n"
 476     );
 477 }
 478 #endif
 479 
 480 // message 0-6 - filewrite chunks
 481 // -s=0xfc06b603 -c=65 -f=chdk
 482 void __attribute__((naked,noinline)) sub_fc06b602_my() {
 483 asm volatile (
 484 "    push.w  {r4, r5, r6, r7, r8, sb, sl, lr}\n"
 485 "    mov     r5, r0\n"
 486 "    ldr     r0, [r0]\n"
 487 "    cmp     r0, #6\n"
 488 "    bhi     loc_fc06b61a\n"
 489 "    add.w   r0, r5, r0, lsl #3\n"
 490 "    ldrd    r7, r6, [r0, #0x18]\n"
 491 "    cbnz    r6, loc_fc06b62e\n"
 492 "    b       loc_fc06b628\n"
 493 "loc_fc06b61a:\n"
 494 "    movw    r2, #0x36d\n"
 495 "    ldr     r1, =0xfc06b450\n" //  *"dwFWrite.c"
 496 "    movs    r0, #0\n"
 497 "    blx     sub_fc2ef9e4\n" // j_DebugAssert
 498 "loc_fc06b628:\n"
 499 "    movs    r0, #7\n"
 500 "    mov     r1, r5\n"
 501 "    b       loc_fc06b69e\n"
 502 "loc_fc06b62e:\n"
 503 "    ldr.w   sl, =0x00026560\n"
 504 "    mov.w   sb, #0x1000000\n"
 505 "    mov     r4, r6\n"
 506 "loc_fc06b638:\n"
 507 "    ldr     r0, [r5, #4]\n"
 508 "    cmp     r4, sb\n"
 509 "    mov     r1, sb\n"
 510 "    bhi     loc_fc06b642\n"
 511 "    mov     r1, r4\n"
 512 "loc_fc06b642:\n"
 513 "    lsls    r2, r0, #8\n"
 514 "    beq     loc_fc06b654\n"
 515 "    bic     r0, r0, #0xff000000\n"
 516 "    rsb.w   r0, r0, #0x1000000\n"
 517 "    cmp     r1, r0\n"
 518 "    bls     loc_fc06b654\n"
 519 "    mov     r1, r0\n"
 520 "loc_fc06b654:\n"
 521 "    ldr.w   r0, [sl, #4]\n"
 522 "    mov     r8, r1\n"
 523 "    mov     r2, r1\n"
 524 "    mov     r1, r7\n"
 525 //"    bl      sub_fc3581a2\n" // j_Write_FW
 526 "    bl      fwt_write\n" // +
 527 "    ldr     r1, [r5, #4]\n"
 528 "    cmp     r8, r0\n"
 529 "    add     r1, r0\n"
 530 "    str     r1, [r5, #4]\n"
 531 "    beq     loc_fc06b67e\n"
 532 "    adds    r0, r0, #1\n"
 533 "    bne     loc_fc06b676\n"
 534 "    ldr     r0, =0x09200006\n"
 535 "    subs    r0, r0, #1\n"
 536 "    b       loc_fc06b67a\n"
 537 "loc_fc06b676:\n"
 538 "    ldr     r0, =0x09200006\n"
 539 "    adds    r0, #0xf\n"
 540 "loc_fc06b67a:\n"
 541 "    str     r0, [r5, #0x14]\n"
 542 "    b       loc_fc06b628\n"
 543 "loc_fc06b67e:\n"
 544 "    subs    r4, r4, r0\n"
 545 "    cmp     r4, r6\n"
 546 "    add     r7, r0\n"
 547 "    blo     loc_fc06b694\n"
 548 "    movw    r2, #0x398\n"
 549 "    ldr     r1, =0xfc06b450\n" //  *"dwFWrite.c"
 550 "    movs    r0, #0\n"
 551 "    blx     sub_fc2ef9e4\n" // j_DebugAssert
 552 "loc_fc06b694:\n"
 553 "    cmp     r4, #0\n"
 554 "    bne     loc_fc06b638\n"
 555 "    ldr     r0, [r5]\n"
 556 "    mov     r1, r5\n"
 557 "    adds    r0, r0, #1\n"
 558 "loc_fc06b69e:\n"
 559 "    pop.w   {r4, r5, r6, r7, r8, sb, sl, lr}\n"
 560 //"    b       loc_fc06b054\n"
 561 "    ldr     pc,=0xfc06b055\n"
 562 ".ltorg\n"
 563     );
 564 }
 565 
 566 // message 7 - close
 567 // -s=0xfc06b1f3 -c=127 -f=chdk
 568 void __attribute__((naked,noinline)) sub_fc06b1f2_my() {
 569 asm volatile (
 570 "    push    {r4, r5, r6, lr}\n"
 571 "    mov     r4, r0\n"
 572 "    ldr     r0, [r0, #0x50]\n"
 573 "    ldr     r5, =0x00026560\n"
 574 "    sub     sp, #0x38\n"
 575 "    lsls    r1, r0, #0x1e\n"
 576 "    bmi     loc_fc06b206\n"
 577 "    lsls    r0, r0, #0x1c\n"
 578 "    bpl     loc_fc06b302\n"
 579 "    b       loc_fc06b248\n"
 580 "loc_fc06b206:\n"
 581 "    lsls    r0, r0, #0x18\n"
 582 "    bpl     loc_fc06b224\n"
 583 "    ldrd    r1, r0, [r4, #8]\n"
 584 "    cmp     r1, r0\n"
 585 "    beq     loc_fc06b224\n"
 586 "    ldr     r0, [r5, #4]\n"
 587 "    bl      sub_fc3582b4\n"
 588 "    cbnz    r0, loc_fc06b220\n"
 589 "    ldr     r0, =0x09200001\n"
 590 "    adds    r0, #0x16\n"
 591 "    str     r0, [r4, #0x14]\n"
 592 "loc_fc06b220:\n"
 593 "    ldr     r0, [r4, #8]\n"
 594 "    str     r0, [sp, #0x28]\n"
 595 "loc_fc06b224:\n"
 596 "    ldr     r0, [r5, #4]\n"
 597 "    adds    r1, r0, #1\n"
 598 "    beq     loc_fc06b248\n"
 599 "    ldr     r6, =0x09200001\n"
 600 "    ldr     r1, [r4, #0x58]\n"
 601 "    adds    r6, r6, #2\n"
 602 "    cmp     r1, #1\n"
 603 "    bne     loc_fc06b23a\n"
 604 //mod start
 605 "    LDR R3, =current_write_ignored\n"
 606 "    LDR R3, [R3]\n"
 607 "    cbnz R3,loc_D\n" // jump over the next block
 608 //mod end
 609 "    bl      sub_fc3580fe\n"
 610 "    b       loc_fc06b23e\n"
 611 "loc_fc06b23a:\n"
 612 "loc_D:\n"
 613 //"    bl      sub_fc3580fc\n" // j_Close_FW
 614 "    bl      fwt_close\n" // +
 615 "loc_fc06b23e:\n"
 616 "    cbz     r0, loc_fc06b242\n"
 617 "    str     r6, [r4, #0x14]\n"
 618 "loc_fc06b242:\n"
 619 "    mov.w   r0, #-1\n"
 620 "    str     r0, [r5, #4]\n"
 621 "loc_fc06b248:\n"
 622 "    add.w   r6, r4, #0x5c\n"
 623 "    ldr     r0, [r4, #0x14]\n"
 624 "    lsls    r0, r0, #0x1f\n"
 625 "    bne     loc_fc06b2f0\n"
 626 "    ldr     r0, [r4, #0x50]\n"
 627 "    lsls    r1, r0, #0x1f\n"
 628 "    beq     loc_fc06b274\n"
 629 "    movw    r0, #0x81ff\n"
 630 "    str     r0, [sp, #0x20]\n"
 631 "    movs    r0, #0x20\n"
 632 "    str     r0, [sp, #0x24]\n"
 633 "    ldr     r0, [r4, #4]\n"
 634 "    str     r0, [sp, #0x28]\n"
 635 "    ldr     r0, [r4, #0x10]\n"
 636 "    str     r0, [sp, #0x2c]\n"
 637 "    ldr     r0, [r4, #0x10]\n"
 638 "    str     r0, [sp, #0x30]\n"
 639 "    ldr     r0, [r4, #0x10]\n"
 640 "    str     r0, [sp, #0x34]\n"
 641 "    b       loc_fc06b296\n"
 642 "loc_fc06b274:\n"
 643 "    lsls    r0, r0, #0x1b\n"
 644 "    bpl     loc_fc06b296\n"
 645 "    add     r1, sp, #0x20\n"
 646 "    mov     r0, r6\n"
 647 "    bl      sub_fc0fc1a8\n"
 648 "    cbnz    r0, loc_fc06b28e\n"
 649 "    movs    r0, #0\n"
 650 "    movw    r2, #0x3ee\n"
 651 "    ldr     r1, =0xfc06b450\n" //  *"dwFWrite.c"
 652 "    blx     sub_fc2ef9e4\n" // j_DebugAssert
 653 "loc_fc06b28e:\n"
 654 "    ldr     r0, [sp, #0x28]\n"
 655 "    ldr     r1, [r4, #4]\n"
 656 "    add     r0, r1\n"
 657 "    str     r0, [sp, #0x28]\n"
 658 "loc_fc06b296:\n"
 659 "    ldr     r0, [r4, #0x50]\n"
 660 "    lsls    r0, r0, #0x19\n"
 661 "    bmi     loc_fc06b2a4\n"
 662 "    add     r1, sp, #0x20\n"
 663 "    mov     r0, r6\n"
 664 "    bl      sub_fc0fc21e\n"
 665 "loc_fc06b2a4:\n"
 666 "    ldr     r0, [r4, #0x50]\n"
 667 "    lsls    r1, r0, #0x1e\n"
 668 "    bpl     loc_fc06b2f0\n"
 669 "    lsls    r0, r0, #0x1a\n"
 670 "    bpl     loc_fc06b2f0\n"
 671 "    movs    r2, #0x20\n"
 672 "    mov     r1, r6\n"
 673 "    mov     r0, sp\n"
 674 "    blx     sub_fc2efa1c\n" // j_dry_memcpy
 675 "    mov     r0, sp\n"
 676 "    bl      _strlen\n"
 677 "    add     r0, sp, r0\n"
 678 "    movs    r1, #0x54\n"
 679 "    strb    r1, [r0, #-0x3]!\n"
 680 "    movs    r1, #0x4d\n"
 681 "    strb    r1, [r0, #1]\n"
 682 "    movs    r1, #0x50\n"
 683 "    strb    r1, [r0, #2]\n"
 684 "    mov     r1, sp\n"
 685 "    mov     r0, r6\n"
 686 "    bl      sub_fc0cff86\n"
 687 "    cbnz    r0, loc_fc06b2e4\n"
 688 "    movs    r0, #0\n"
 689 "    movw    r2, #0x179\n"
 690 "    ldr     r1, =0xfc06b450\n" //  *"dwFWrite.c"
 691 "    blx     sub_fc2ef9e4\n" // j_DebugAssert
 692 "loc_fc06b2e4:\n"
 693 "    mov     r0, sp\n"
 694 "    bl      sub_fc0fc510\n"
 695 "    mov     r0, r6\n"
 696 "    bl      sub_fc0fc510\n"
 697 "loc_fc06b2f0:\n"
 698 "    movs    r1, #0\n"
 699 "    movs    r0, #0x48\n"
 700 "    bl      sub_fc351f1c\n"
 701 "    mov     r0, r6\n"
 702 "    bl      sub_fc357e84\n"
 703 "    ldr     r1, [r5, #0x1c]\n"
 704 "    b       loc_fc06b304\n"
 705 "loc_fc06b302:\n"
 706 "    b       loc_fc06b30a\n"
 707 "loc_fc06b304:\n"
 708 "    bl      sub_fc073c34\n"
 709 "    b       loc_fc06b30e\n"
 710 "loc_fc06b30a:\n"
 711 "    ldr     r0, [r5, #0x1c]\n"
 712 "    blx     r0\n"
 713 "loc_fc06b30e:\n"
 714 "    ldr     r1, [r5, #0x14]\n"
 715 "    cmp     r1, #0\n"
 716 "    beq     loc_fc06b318\n"
 717 "    ldr     r0, [r4, #0x14]\n"
 718 "    blx     r1\n"
 719 "loc_fc06b318:\n"
 720 "    add     sp, #0x38\n"
 721 "    pop     {r4, r5, r6, pc}\n"
 722 ".ltorg\n"
 723     );
 724 }

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