root/platform/sx280hs/sub/102c/movie_rec.c

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

DEFINITIONS

This source file includes following definitions.
  1. movie_record_task
  2. sub_fc1a5b74_my
  3. sub_fc1a499c_my
  4. sub_fc02167a_my
  5. getchunkinfo
  6. replace_apendstrm

   1 
   2 // byte offset of bitrate constants inside the fw struct passed to set_quality()
   3 #define BR_LOW_OFS 0x2c
   4 #define BR_MID_OFS 0x30
   5 #define BR_HI_OFS  0x28
   6 
   7 // maximum allowed bitrate that doesn't crash the camera
   8 #define MAX_VIDEO_BITRATE 35040
   9 
  10 #define FW_SHORT_TIME_LIMIT 30      // unlocking fw time limits below this require user permission (seconds)
  11 #define SHORT_TIME_LIMIT 300        // raised time limit for movie modes that have more restricted fw time limits
  12 #define LONG_TIME_LIMIT (3*60*60)   // raised time limit for all other movie kinds
  13 
  14 #include "../../../generic/movie_rec.c"
  15 
  16 void __attribute__((naked,noinline)) movie_record_task() {
  17     asm volatile (
  18 // capdis -f=chdk -s=task_MovieRecord -c=85 -stubs PRIMARY.BIN 0xfc000000
  19 // task_MovieRecord 0xfc1a5d1d
  20 "    push.w  {r2, r3, r4, r5, r6, r7, r8, lr}\n"
  21 "    ldr     r5, =0x00010b08\n"
  22 "    movs    r6, #0\n"
  23 "    movw    r7, #0xaea\n"
  24 "    movw    r8, #0x2710\n"
  25 "    sub.w   r4, r5, #0x80\n"
  26 "loc_fc1a5d30:\n"
  27 "    movs    r2, #0\n"
  28 "    add     r1, sp, #4\n"
  29 "    ldr     r0, [r4, #0xc]\n"
  30 "    blx     sub_fc251c84\n" // j_ReceiveMessageQueue
  31 "    ldr     r0, [sp, #4]\n"
  32 "    ldr     r0, [r0]\n"
  33 "    cmp     r0, #6\n"
  34 "    bhs     loc_fc1a5de4\n"
  35 "    tbb     [pc, r0]\n" // (jumptable r0 6 elements)
  36 "branchtable_fc1a5d46:\n"
  37 "    .byte((loc_fc1a5d4c - branchtable_fc1a5d46) / 2)\n" // (case 0)
  38 "    .byte((loc_fc1a5d6a - branchtable_fc1a5d46) / 2)\n" // (case 1)
  39 "    .byte((loc_fc1a5d8c - branchtable_fc1a5d46) / 2)\n" // (case 2)
  40 "    .byte((loc_fc1a5d92 - branchtable_fc1a5d46) / 2)\n" // (case 3)
  41 "    .byte((loc_fc1a5db2 - branchtable_fc1a5d46) / 2)\n" // (case 4)
  42 "    .byte((loc_fc1a5dc4 - branchtable_fc1a5d46) / 2)\n" // (case 5)
  43 ".align 1\n"
  44 "loc_fc1a5d4c:\n"
  45 "    bl      replace_apendstrm\n"   // +
  46 "    ldr     r0, [r5, #0x1c]\n"
  47 "    cbz     r0, loc_fc1a5d56\n"
  48 "loc_fc1a5d50:\n"
  49 "    bl      sub_fc1a4618\n"
  50 "    b       loc_fc1a5de4\n"
  51 "loc_fc1a5d56:\n"
  52 "    ldr     r0, [r4, #0x5c]\n"
  53 "    cbnz    r0, loc_fc1a5d5e\n"
  54 "    bl      sub_fc1a63c8\n"
  55 "loc_fc1a5d5e:\n"
  56 "    bl      sub_fc1a5b74_my\n"     // ->
  57 "loc_fc1a5d62:\n"
  58 "    cmp     r0, #0\n"
  59 "    str     r0, [r5, #0x1c]\n"
  60 "    bne     loc_fc1a5d50\n"
  61 "    b       loc_fc1a5de4\n"
  62 "loc_fc1a5d6a:\n"
  63 "    bl      sub_fc1a599a\n"
  64 "    str     r0, [r5, #0x1c]\n"
  65 "    ldr     r1, [r4, #0x5c]\n"
  66 "    cbnz    r1, loc_fc1a5d82\n"
  67 "    lsls    r0, r0, #0x1f\n"
  68 "    bne     loc_fc1a5d7e\n"
  69 "    bl      sub_fc1a582c\n"
  70 "    str     r0, [r5, #0x1c]\n"
  71 "loc_fc1a5d7e:\n"
  72 "    bl      sub_fc1a63e6\n"
  73 "loc_fc1a5d82:\n"
  74 "    ldr     r0, [r5, #0x1c]\n"
  75 "    b       loc_fc1a5dac\n"
  76 "loc_fc1a5d86:\n"
  77 "    ldr     r1, [r5, #0x30]\n"
  78 "    ldr     r0, [r5, #0x44]\n"
  79 "    b       loc_fc1a5dc0\n"
  80 "loc_fc1a5d8c:\n"
  81 "    bl      sub_fc1a6612\n"
  82 "    b       loc_fc1a5d62\n"
  83 "loc_fc1a5d92:\n"
  84 "    bl      sub_fc1a63c8\n"
  85 "    bl      sub_fc1a5632\n"
  86 "    cmp     r0, #0\n"
  87 "    str     r0, [r5, #0x1c]\n"
  88 "    bne     loc_fc1a5d50\n"
  89 "    ldr     r0, [r4, #0x6c]\n"
  90 "    cmp     r0, #0\n"
  91 "    beq     loc_fc1a5d86\n"
  92 "    bl      sub_fc1a54d0\n"
  93 "    str     r0, [r5, #0x1c]\n"
  94 "loc_fc1a5dac:\n"
  95 "    cmp     r0, #0\n"
  96 "    beq     loc_fc1a5d86\n"
  97 "    b       loc_fc1a5d50\n"
  98 "loc_fc1a5db2:\n"
  99 "    bl      sub_fc1a54d0\n"
 100 "    cmp     r0, #0\n"
 101 "    str     r0, [r5, #0x1c]\n"
 102 "    bne     loc_fc1a5d50\n"
 103 "    ldr     r1, [r5, #0x38]\n"
 104 "    ldr     r0, [r5, #0x4c]\n"
 105 "loc_fc1a5dc0:\n"
 106 "    blx     r1\n"
 107 "    b       loc_fc1a5de4\n"
 108 "loc_fc1a5dc4:\n"
 109 "    bl      sub_fc1a5efe\n"
 110 "    lsls    r0, r0, #0x1f\n"
 111 "    beq     loc_fc1a5dd0\n"
 112 "    movs    r0, #1\n"
 113 "    b       loc_fc1a5dd8\n"
 114 "loc_fc1a5dd0:\n"
 115 "    str     r6, [r4, #0x34]\n"
 116 "    mov     r0, r6\n"
 117 "    str     r6, [r4, #0x5c]\n"
 118 "    str     r6, [r4, #0x58]\n"
 119 "loc_fc1a5dd8:\n"
 120 "    str     r0, [r5, #0x1c]\n"
 121 "    cbz     r0, loc_fc1a5de4\n"
 122 "    mov.w   r0, #0xa0000\n"
 123 "    bl      sub_fc07b032\n" // HardwareDefect_FW
 124 "loc_fc1a5de4:\n"
 125 "    ldr     r1, [sp, #4]\n"
 126 "    mov     r2, r8\n"
 127 "    ldr     r3, =0xfc1a4a18\n" //  **"MovieRecorder.c"
 128 "    str     r6, [r1]\n"
 129 "    str     r7, [sp]\n"
 130 "    ldr     r0, [r4, #0x14]\n"
 131 "    blx     sub_fc251b84\n" // j_PostMessageQueueStrictly
 132 "    b       loc_fc1a5d30\n"
 133 ".ltorg\n"
 134     );
 135 }
 136 
 137 void __attribute__((naked,noinline)) sub_fc1a5b74_my() {
 138     asm volatile (
 139 // capdis -f=chdk -s=0xFC1A5B75 -c=13 -stubs PRIMARY.BIN 0xfc000000
 140 "    push.w  {r4, r5, r6, r7, r8, lr}\n"
 141 "    ldr     r5, =0x00010a88\n"
 142 "    sub     sp, #0xf0\n"
 143 "    add     r1, sp, #0x18\n"
 144 "    add     r0, sp, #0x84\n"
 145 "    mov     r4, r1\n"
 146 "    ldr     r2, [r5, #0x5c]\n"
 147 "    bl      sub_fc1a484e\n"
 148 "    add     r0, sp, #0x84\n"
 149 "    bl      sub_fc23e530\n"
 150 "    add     r0, sp, #4\n"
 151 "    mov     r1, r4\n"
 152 "    bl      sub_fc1a499c_my\n"     // ->
 153 "    ldr     pc, =0xFC1A5B97\n"     // + back to rom
 154 ".ltorg\n"
 155     );
 156 }
 157 
 158 void __attribute__((naked,noinline)) sub_fc1a499c_my() {
 159     asm volatile (
 160 // capdis -f=chdk -s=0xFC1A499d -c=497 -stubs PRIMARY.BIN 0xfc000000
 161 "    push.w  {r0, r1, r2, r3, r4, r5, r6, r7, r8, sb, sl, fp, ip, lr}\n"
 162 "    movs    r6, #0\n"
 163 "    ldr.w   r8, =0x00010a88\n"
 164 "    mov.w   fp, #1\n"
 165 "    mov     r5, r0\n"
 166 "    add.w   r8, r8, #0x80\n"
 167 "    mov     r4, r1\n"
 168 "    strd    fp, r6, [sp]\n"
 169 "    strb.w  fp, [r0]\n"
 170 "    mov     sl, r6\n"
 171 "    strb    r6, [r0, #1]\n"
 172 "    ldr.w   r0, [r8, #0x20]\n"
 173 "    bl      sub_fc2a46b2\n" // GetDrive_ClusterSize
 174 "    ldr     r7, =0x00010a88\n"
 175 "    str     r0, [r7, #0x40]\n"
 176 "    str     r0, [r5, #8]\n"
 177 "    strb.w  sl, [r5, #4]\n"
 178 "    ldr.w   r0, [r8, #0x20]\n"
 179 "    bl      sub_fc2a4e14\n"
 180 "    cbz     r0, loc_fc1a4a08\n"
 181 "    ldr.w   r0, [r8, #0x20]\n"
 182 "    bl      sub_fc2a464c\n" // get_fstype
 183 "    cmp     r0, #4\n"
 184 "    bne     loc_fc1a49ea\n"
 185 "    mov     r0, fp\n"
 186 "    b       loc_fc1a49ec\n"
 187 "loc_fc1a49ea:\n"
 188 "    mov     r0, sl\n"
 189 "loc_fc1a49ec:\n"
 190 "    strb    r0, [r7]\n"
 191 "    uxtb    r0, r0\n"
 192 "    mov     sb, r7\n"
 193 "    cmp     r0, #2\n"
 194 "    strb    r0, [r5, #6]\n"
 195 "    beq     loc_fc1a4ab4\n"
 196 "    add.w   r2, r5, #0x10\n"
 197 "    ldr.w   r0, [r8, #0x20]\n"
 198 "    subs    r1, r2, #4\n"
 199 "    bl      sub_fc2a4d3a\n"
 200 "    b       loc_fc1a4abc\n"
 201 "loc_fc1a4a08:\n"
 202 //"    b       loc_fc1a4ab0\n"
 203 // literal pool removed
 204 //"loc_fc1a4ab0:\n"
 205 "    movs    r0, #2\n"
 206 "    b       loc_fc1a49ec\n"
 207 "loc_fc1a4ab4:\n"
 208 "    ldr.w   r0, [sb, #0x40]\n"
 209 "    str     r0, [r5, #0xc]\n"
 210 "    str     r0, [r5, #0x10]\n"
 211 "loc_fc1a4abc:\n"
 212 "    add.w   r4, r4, #0x1c\n"
 213 "    movs    r0, #0x64\n"
 214 "    movw    r1, #0xbb80\n"
 215 "    mov     r7, fp\n"
 216 "    strb    r0, [r4, #3]\n"
 217 "    strb.w  sl, [r4, #8]\n"
 218 "    strb.w  sl, [r4, #6]\n"
 219 "    strb.w  fp, [r4, #9]\n"
 220 "    strb.w  fp, [r4, #0xb]\n"
 221 "    str     sl, [r4, #-0x10]\n"
 222 "    strb.w  sl, [r4, #5]\n"
 223 "    strb.w  fp, [r4, #7]\n"
 224 "    strb.w  fp, [r4, #0x1c]\n"
 225 "    str     r1, [r4, #0x30]\n"
 226 "    mov.w   r1, #0x10\n"
 227 "    strh    r1, [r4, #0x34]\n"
 228 "    mov.w   r1, #0x1f400\n"
 229 "    str     r1, [r4, #0x3c]\n"
 230 "    mov.w   r1, #0x300000\n"
 231 "    strb.w  sl, [r4, #0x38]\n"
 232 "    sub.w   r4, r4, #0x1c\n"
 233 "    ldr.w   r0, [sb, #0x40]\n"
 234 "    cmp     r0, r1\n"
 235 "    bls     loc_fc1a4b10\n"
 236 "    str     r0, [r4, #0x14]\n"
 237 "    b       loc_fc1a4b12\n"
 238 ".ltorg\n"                      // +
 239 "loc_fc1a4b10:\n"
 240 "    str     r1, [r4, #0x14]\n"
 241 "loc_fc1a4b12:\n"
 242 "    movs    r2, #0xf\n"
 243 "    ldr.w   r3, [r8, #0x60]\n"
 244 "    movw    r0, #0x3e9\n"
 245 "    ldr.w   lr, =0x00010006\n"
 246 "    movw    r1, #0xbb5\n"
 247 "    cmp     r3, #0xc\n"
 248 "    movw    ip, #0x7530\n"
 249 "    mov.w   fp, #3\n"
 250 "    bhs     loc_fc1a4bfa\n"
 251 "    tbb     [pc, r3]\n" // (jumptable r3 12 elements)
 252 "branchtable_fc1a4b34:\n"
 253 "    .byte((loc_fc1a4b94 - branchtable_fc1a4b34) / 2)\n" // (case 0)
 254 "    .byte((loc_fc1a4bfa - branchtable_fc1a4b34) / 2)\n" // (case 1)
 255 "    .byte((loc_fc1a4bfa - branchtable_fc1a4b34) / 2)\n" // (case 2)
 256 "    .byte((loc_fc1a4b78 - branchtable_fc1a4b34) / 2)\n" // (case 3)
 257 "    .byte((loc_fc1a4b68 - branchtable_fc1a4b34) / 2)\n" // (case 4)
 258 "    .byte((loc_fc1a4b40 - branchtable_fc1a4b34) / 2)\n" // (case 5)
 259 "    .byte((loc_fc1a4bfa - branchtable_fc1a4b34) / 2)\n" // (case 6)
 260 "    .byte((loc_fc1a4bfa - branchtable_fc1a4b34) / 2)\n" // (case 7)
 261 "    .byte((loc_fc1a4bfa - branchtable_fc1a4b34) / 2)\n" // (case 8)
 262 "    .byte((loc_fc1a4ba6 - branchtable_fc1a4b34) / 2)\n" // (case 9)
 263 "    .byte((loc_fc1a4bb6 - branchtable_fc1a4b34) / 2)\n" // (case 10)
 264 "    .byte((loc_fc1a4bd8 - branchtable_fc1a4b34) / 2)\n" // (case 11)
 265 ".align 1\n"
 266 "loc_fc1a4b40:\n"
 267 "    ldr     r2, =0x00010006\n"
 268 "    movw    r1, #0x176a\n"
 269 "    strh    r1, [r4, #0x1c]\n"
 270 "    movs    r1, #0x1e\n"
 271 "    strb    r1, [r4, #1]\n"
 272 "    adds    r2, #0x36\n"
 273 "    str     r2, [r4, #0x34]\n"
 274 "    movw    r3, #0xea60\n"
 275 "    strb.w  r7, [r4, #0x22]\n"
 276 "    strb    r1, [r5, #5]\n"
 277 "    strd    r3, r0, [r8, #8]\n"
 278 "    strd    r0, r3, [sp]\n"
 279 "    strh.w  r1, [sb, #2]\n"
 280 "    b       loc_fc1a4c08\n"
 281 "loc_fc1a4b68:\n"
 282 "    strh    r1, [r4, #0x1c]\n"
 283 "    ldr     r1, =0x00010006\n"
 284 "    strb    r2, [r4, #1]\n"
 285 "    adds    r1, #0x72\n"
 286 "    str     r1, [r4, #0x34]\n"
 287 "    ldr     r1, =0x0001d4c0\n"
 288 "    strb    r2, [r5, #5]\n"
 289 "    b       loc_fc1a4b86\n"
 290 "loc_fc1a4b78:\n"
 291 "    strh    r1, [r4, #0x1c]\n"
 292 "    ldr     r1, =0x00010006\n"
 293 "    strb    r2, [r4, #1]\n"
 294 "    adds    r1, #0xea\n"
 295 "    str     r1, [r4, #0x34]\n"
 296 "    ldr     r1, =0x0003a980\n"
 297 "    strb    r2, [r5, #5]\n"
 298 "loc_fc1a4b86:\n"
 299 "    strd    r1, r0, [r8, #8]\n"
 300 "loc_fc1a4b8a:\n"
 301 "    strd    r0, ip, [sp]\n"
 302 "    mov     r0, sb\n"
 303 "loc_fc1a4b90:\n"
 304 "    strh    r2, [r0, #2]\n"
 305 "    b       loc_fc1a4c08\n"
 306 "loc_fc1a4b94:\n"
 307 "    strh    r1, [r4, #0x1c]\n"
 308 "    ldr     r1, =0x00010006\n"
 309 "    strb    r2, [r4, #1]\n"
 310 "    adds    r1, #0x18\n"
 311 "    str     r1, [r4, #0x34]\n"
 312 "    strb    r2, [r5, #5]\n"
 313 "    strd    ip, r0, [r8, #8]\n"
 314 "    b       loc_fc1a4b8a\n"
 315 "loc_fc1a4ba6:\n"
 316 "    strh    r1, [r4, #0x1c]\n"
 317 "    movw    r1, #0x1770\n"
 318 "    strb    r2, [r4, #1]\n"
 319 "    str.w   lr, [r4, #0x34]\n"
 320 "    strb    r2, [r5, #5]\n"
 321 "    b       loc_fc1a4b86\n"
 322 "loc_fc1a4bb6:\n"
 323 "    strh    r1, [r4, #0x1c]\n"
 324 "    movw    r1, #0xbb8\n"
 325 "    strb    r2, [r4, #1]\n"
 326 "    str.w   lr, [r4, #0x34]\n"
 327 "    strb    r2, [r5, #5]\n"
 328 "    strd    r1, r0, [r8, #8]\n"
 329 "    strd    r0, ip, [sp]\n"
 330 "    str.w   r7, [sb, #0x78]\n"
 331 "    mov     r0, sb\n"
 332 "    str.w   r7, [sb, #0x7c]\n"
 333 "    b       loc_fc1a4b90\n"
 334 "loc_fc1a4bd8:\n"
 335 "    strh    r1, [r4, #0x1c]\n"
 336 "    movw    r1, #0x5dc\n"
 337 "    strb    r2, [r4, #1]\n"
 338 "    str.w   lr, [r4, #0x34]\n"
 339 "    strb    r2, [r5, #5]\n"
 340 "    strd    r1, r0, [r8, #8]\n"
 341 "    strd    r0, ip, [sp]\n"
 342 "    str.w   fp, [sb, #0x78]\n"
 343 "    mov     r0, sb\n"
 344 "    str.w   fp, [sb, #0x7c]\n"
 345 "    b       loc_fc1a4b90\n"
 346 "loc_fc1a4bfa:\n"
 347 "    movw    r2, #0x3b9\n"
 348 "    ldr     r1, =0xfc1a4a18\n" //  *"MovieRecorder.c"
 349 "    movs    r0, #0\n"
 350 "    blx     sub_fc251d9c\n" // j_DebugAssert
 351 "loc_fc1a4c08:\n"
 352 "    movs    r0, #2\n"
 353 "    strb    r0, [r4]\n"
 354 "    strb.w  sl, [r4, #0x26]\n"
 355 "    mov     r1, sl\n"
 356 "    ldr.w   r0, [sb, #0x58]\n"
 357 "    cbz     r0, loc_fc1a4c30\n"
 358 "    strb    r1, [r4]\n"
 359 "    strb    r7, [r4, #1]\n"
 360 "    strb.w  r7, [r4, #0x26]\n"
 361 "    strb.w  r7, [r4, #0x22]\n"
 362 "    ldr     r2, =0x00010ba0\n"
 363 "    strh.w  r7, [sb, #2]\n"
 364 "    str.w   r2, [r8, #0x10]\n"
 365 "    b       loc_fc1a4c34\n"
 366 "loc_fc1a4c30:\n"
 367 "    str.w   r1, [r8, #0x10]\n"
 368 "loc_fc1a4c34:\n"
 369 "    movs    r1, #0\n"
 370 "    ldr     r2, =0x001a0800\n"
 371 "    movs    r3, #6\n"
 372 "    movw    ip, #0x140\n"
 373 "    movw    lr, #0xffff\n"
 374 "    strd    r2, r1, [r4, #0x3c]\n"
 375 "    lsls    r1, r2, #0x10\n"
 376 "    str     r1, [r4, #0x44]\n"
 377 "    movs    r2, #5\n"
 378 "    movw    sl, #0xe0f\n"
 379 "    asrs    r1, r1, #0x10\n"
 380 "    str     r1, [r4, #0x48]\n"
 381 "    ldr.w   r1, [r8, #0x58]\n"
 382 "    cmp     r1, ip\n"
 383 "    beq     loc_fc1a4d52\n"
 384 "    movw    ip, #0x280\n"
 385 "    cmp     r1, ip\n"
 386 "    beq     loc_fc1a4d20\n"
 387 "    lsls    r3, r2, #8\n"
 388 "    mov.w   ip, #0x29\n"
 389 "    cmp     r1, r3\n"
 390 "    movw    r2, #0x707\n"
 391 "    beq     loc_fc1a4cce\n"
 392 "    movw    r0, #0x780\n"
 393 "    cmp     r1, r0\n"
 394 "    bne     loc_fc1a4d54\n"
 395 "    strh    r0, [r4, #4]\n"
 396 "    movw    r1, #0x438\n"
 397 "    strh    r1, [r4, #2]\n"
 398 "    strh    r0, [r4, #8]\n"
 399 "    strh    r1, [r4, #6]\n"
 400 "    strb.w  r7, [r4, #0x20]\n"
 401 "    strb.w  r7, [r4, #0x39]\n"
 402 "    strb.w  r7, [r4, #0x3a]\n"
 403 "    strb.w  r7, [r4, #0x3b]\n"
 404 "    strh.w  r7, [sb, #6]\n"
 405 "    ldr.w   r0, [r8, #0x60]\n"
 406 "    cmp     r0, #5\n"
 407 "    bne     loc_fc1a4cb8\n"
 408 "    movw    r0, #0x88b8\n"
 409 "    str     r0, [r4, #0x28]\n"
 410 "    movw    r0, #0x8854\n"
 411 "    str     r0, [r4, #0x30]\n"
 412 "    movw    r0, #0x87f0\n"
 413 "    str     r0, [r4, #0x2c]\n"
 414 "    movs    r0, #0x2a\n"
 415 "    b       loc_fc1a4d1c\n"
 416 "loc_fc1a4cb8:\n"
 417 "    movw    r0, #0x5dc0\n"
 418 "    str     r0, [r4, #0x28]\n"
 419 "    movw    r0, #0x5d5c\n"
 420 "    str     r0, [r4, #0x30]\n"
 421 "    movw    r0, #0x5cf8\n"
 422 "    b       loc_fc1a4d00\n"
 423 "loc_fc1a4cca:\n"
 424 "    mov     r6, r2\n"
 425 "    b       loc_fc1a4de8\n"
 426 "loc_fc1a4cce:\n"
 427 "    strh    r3, [r4, #4]\n"
 428 "    movw    r1, #0x2d0\n"
 429 "    strh    r1, [r4, #2]\n"
 430 "    strh    r3, [r4, #8]\n"
 431 "    strh    r1, [r4, #6]\n"
 432 "    strb.w  r7, [r4, #0x20]\n"
 433 "    strb.w  r7, [r4, #0x39]\n"
 434 "    strb.w  r7, [r4, #0x3a]\n"
 435 "    strb.w  r7, [r4, #0x3b]\n"
 436 "    strh.w  r7, [sb, #6]\n"
 437 "    cbz     r0, loc_fc1a4d08\n"
 438 "    movw    r0, #0x9c40\n"
 439 "    str     r0, [r4, #0x28]\n"
 440 "    movw    r0, #0x9bdc\n"
 441 "    str     r0, [r4, #0x30]\n"
 442 "    movw    r0, #0x9b78\n"
 443 "loc_fc1a4d00:\n"
 444 "    str     r0, [r4, #0x2c]\n"
 445 "    strb.w  ip, [r4, #0x1e]\n"
 446 "    b       loc_fc1a4cca\n"
 447 "loc_fc1a4d08:\n"
 448 "    movw    r0, #0x1f40\n"
 449 "    str     r0, [r4, #0x28]\n"
 450 "    movw    r0, #0x1edc\n"
 451 "    str     r0, [r4, #0x30]\n"
 452 "    movw    r0, #0x1e78\n"
 453 "    str     r0, [r4, #0x2c]\n"
 454 "    movs    r0, #0x1f\n"
 455 "loc_fc1a4d1c:\n"
 456 "    strb    r0, [r4, #0x1e]\n"
 457 "    b       loc_fc1a4cca\n"
 458 "loc_fc1a4d20:\n"
 459 "    strh.w  ip, [r4, #4]\n"
 460 "    movw    r0, #0x1e0\n"
 461 "    strh    r0, [r4, #2]\n"
 462 "    strh.w  ip, [r4, #8]\n"
 463 "    strh    r0, [r4, #6]\n"
 464 "    add.w   r4, r4, #0x20\n"
 465 "    ldr.w   r0, [r8, #0x60]\n"
 466 "    cmp     r0, #1\n"
 467 "    beq     loc_fc1a4d56\n"
 468 "    strb    r3, [r4]\n"
 469 "    strb.w  fp, [r4, #0x19]\n"
 470 "    strb    r7, [r4, #0x1a]\n"
 471 "    strb.w  fp, [r4, #0x1b]\n"
 472 "    sub.w   r4, r4, #0x20\n"
 473 "    strh.w  r3, [sb, #6]\n"
 474 "    b       loc_fc1a4d68\n"
 475 "loc_fc1a4d52:\n"
 476 "    b       loc_fc1a4d7e\n"
 477 "loc_fc1a4d54:\n"
 478 "    b       loc_fc1a4dda\n"
 479 "loc_fc1a4d56:\n"
 480 "    strb    r2, [r4]\n"
 481 "    movs    r0, #2\n"
 482 "    strb    r0, [r4, #0x19]\n"
 483 "    strb    r7, [r4, #0x1a]\n"
 484 "    strb    r0, [r4, #0x1b]\n"
 485 "    sub.w   r4, r4, #0x20\n"
 486 "    strh.w  lr, [sb, #6]\n"
 487 "loc_fc1a4d68:\n"
 488 "    movw    r0, #0xbb8\n"
 489 "    str     r0, [r4, #0x28]\n"
 490 "    movw    r0, #0xb54\n"
 491 "    str     r0, [r4, #0x30]\n"
 492 "    movw    r0, #0xaf0\n"
 493 "    str     r0, [r4, #0x2c]\n"
 494 "    movs    r0, #0x1e\n"
 495 "    b       loc_fc1a4dd4\n"
 496 "loc_fc1a4d7e:\n"
 497 "    strh.w  ip, [r4, #4]\n"
 498 "    movs    r0, #0xf0\n"
 499 "    strh    r0, [r4, #2]\n"
 500 "    strh.w  ip, [r4, #8]\n"
 501 "    strh    r0, [r4, #6]\n"
 502 "    add.w   r4, r4, #0x20\n"
 503 "    ldr.w   r0, [r8, #0x60]\n"
 504 "    cmp     r0, #1\n"
 505 "    beq     loc_fc1a4dae\n"
 506 "    strb    r3, [r4]\n"
 507 "    strb.w  fp, [r4, #0x19]\n"
 508 "    strb    r7, [r4, #0x1a]\n"
 509 "    strb.w  fp, [r4, #0x1b]\n"
 510 "    sub.w   r4, r4, #0x20\n"
 511 "    strh.w  r3, [sb, #6]\n"
 512 "    b       loc_fc1a4dc0\n"
 513 "loc_fc1a4dae:\n"
 514 "    strb    r2, [r4]\n"
 515 "    movs    r0, #2\n"
 516 "    strb    r0, [r4, #0x19]\n"
 517 "    strb    r7, [r4, #0x1a]\n"
 518 "    strb    r0, [r4, #0x1b]\n"
 519 "    sub.w   r4, r4, #0x20\n"
 520 "    strh.w  lr, [sb, #6]\n"
 521 "loc_fc1a4dc0:\n"
 522 "    movw    r0, #0x3e8\n"
 523 "    str     r0, [r4, #0x28]\n"
 524 "    movw    r0, #0x384\n"
 525 "    str     r0, [r4, #0x30]\n"
 526 "    movw    r0, #0x320\n"
 527 "    str     r0, [r4, #0x2c]\n"
 528 "    movs    r0, #0x14\n"
 529 "loc_fc1a4dd4:\n"
 530 "    mov     r6, sl\n"
 531 "    strb    r0, [r4, #0x1e]\n"
 532 "    b       loc_fc1a4de8\n"
 533 "loc_fc1a4dda:\n"
 534 "    movw    r2, #0x443\n"
 535 "    ldr     r1, =0xfc1a4a18\n" //  *"MovieRecorder.c"
 536 "    movs    r0, #0\n"
 537 "    blx     sub_fc251d9c\n" // j_DebugAssert
 538 "loc_fc1a4de8:\n"
 539 "    ldr.w   r0, [r8, #0x60]\n"
 540 "    cmp     r0, #4\n"
 541 "    beq     loc_fc1a4df4\n"
 542 "    cmp     r0, #3\n"
 543 "    bne     loc_fc1a4dfa\n"
 544 "loc_fc1a4df4:\n"
 545 "    movs    r6, #0x1e\n"
 546 "    str.w   r7, [sb, #0x60]\n"
 547 "loc_fc1a4dfa:\n"
 548 
 549 // movie time limit modification, r0...r3 does not seem to carry anything useful here, so they are not backed up
 550 "    mov     r0, r6\n"                  // + original limit is in r6
 551 "    bl      set_movie_time_limit\n"    // +
 552 "    mov     r6, r0\n"                  // +
 553 // bitrate mod
 554 "    mov     r0, r4\n"                  // + addr of struct with bitrates is in r4
 555 "    bl      set_quality\n"             // +
 556 
 557 "    ldr     r1, =0x00010ba0\n"
 558 "    mov.w   r8, #0\n"
 559 "    subs    r1, #0x98\n"
 560 "    ldr     r0, [r1, #8]\n"
 561 "    str     r0, [sp, #0xc]\n"
 562 "    mul     r2, r6, r0\n"
 563 "    ldr     r0, [r1, #0xc]\n"
 564 "    mov     sl, r0\n"
 565 "    udiv    r0, r2, r0\n"
 566 "    mvn     r2, #9\n"
 567 "    str     r0, [r1, #0x6c]\n"
 568 "    str     r0, [sp, #8]\n"
 569 "    adds    r0, r6, r2\n"
 570 "    str.w   r0, [sb, #0x50]\n"
 571 "    adc     r1, r8, #-1\n"
 572 "    ldr.w   r0, [sb, #0x74]\n"
 573 "    mov     r1, sb\n"
 574 "    cbnz    r0, loc_fc1a4e38\n"
 575 "    ldr     r0, [sp, #0xc]\n"
 576 "    add     r0, sl\n"
 577 "    subs    r0, r0, #1\n"
 578 "    udiv    r0, r0, sl\n"
 579 "    str     r0, [r1, #0x74]\n"
 580 "loc_fc1a4e38:\n"
 581 "    ldr     r0, [r1, #0x5c]\n"
 582 "    cbz     r0, loc_fc1a4e4e\n"
 583 "    strb    r7, [r5, #2]\n"
 584 "    movs    r0, #8\n"
 585 "    strb.w  r8, [r5, #7]\n"
 586 "    str     r0, [r4, #0x10]\n"
 587 "    movw    r0, #0x780\n"
 588 "    str     r0, [r4, #0x18]\n"
 589 "    b       loc_fc1a4e74\n"
 590 "loc_fc1a4e4e:\n"
 591 "    strb.w  r8, [r5, #2]\n"
 592 "    ldrb    r0, [r5, #6]\n"
 593 "    cmp     r0, #2\n"
 594 "    beq     loc_fc1a4e5c\n"
 595 "    strb    r7, [r5, #7]\n"
 596 "    b       loc_fc1a4e60\n"
 597 "loc_fc1a4e5c:\n"
 598 "    strb.w  r8, [r5, #7]\n"
 599 "loc_fc1a4e60:\n"
 600 "    ldrh    r0, [r1, #2]\n"
 601 "    ldr     r2, [sp, #8]\n"
 602 "    str.w   r8, [r4, #0x18]\n"
 603 "    add     r2, r0\n"
 604 "    subs    r2, r2, #1\n"
 605 "    udiv    r0, r2, r0\n"
 606 "    adds    r0, r0, #1\n"
 607 "    str     r0, [r4, #0x10]\n"
 608 "loc_fc1a4e74:\n"
 609 "    movs    r0, #2\n"
 610 "    strh.w  r0, [r4, #0x52]\n"
 611 "    strh    r0, [r1, #4]\n"
 612 "    mov     r6, r1\n"
 613 "    ldr     r0, [r1, #0x64]\n"
 614 "    cbz     r0, loc_fc1a4e86\n"
 615 "    strb    r7, [r5, #3]\n"
 616 "    b       loc_fc1a4e8a\n"
 617 "loc_fc1a4e86:\n"
 618 "    strb.w  r8, [r5, #3]\n"
 619 "loc_fc1a4e8a:\n"
 620 "    movs    r3, #2\n"
 621 "    ldr     r5, =0x00010ba0\n"
 622 "    movs    r1, #0xa9\n"
 623 "    add     r2, sp, #4\n"
 624 "    subs    r5, #0x98\n"
 625 "    ldr     r0, [r5, #0x24]\n"
 626 "    bl      sub_fc297bc6\n"
 627 "    ldr     r0, [r5, #0x24]\n"
 628 "    movs    r3, #2\n"
 629 "    movs    r1, #0xa8\n"
 630 "    mov     r2, sp\n"
 631 "    bl      sub_fc297bc6\n"
 632 "    ldr     r0, [r5, #0x24]\n"
 633 "    movs    r3, #4\n"
 634 "    movs    r1, #0xa2\n"
 635 "    add.w   r2, r5, #8\n"
 636 "    bl      sub_fc297bc6\n"
 637 "    ldr     r0, [r5, #0x24]\n"
 638 "    movs    r3, #4\n"
 639 "    movs    r1, #0xa3\n"
 640 "    add.w   r2, r5, #0xc\n"
 641 "    bl      sub_fc297bc6\n"
 642 "    ldr     r0, [r4, #0x28]\n"
 643 "    lsls    r0, r0, #7\n"
 644 "    movs    r2, #0xa\n"
 645 "    umull   r2, r3, r0, r2\n"
 646 "    strd    r0, r2, [r6, #0x44]\n"
 647 "    umull   r0, r2, r0, fp\n"
 648 "    str     r0, [r6, #0x4c]\n"
 649 "    pop.w   {r0, r1, r2, r3, r4, r5, r6, r7, r8, sb, sl, fp, ip, pc}\n"
 650 ".ltorg\n"
 651     );
 652 }
 653 
 654 // below functions are for getting bitrate information during recording
 655 // filesystem info only updates after recording stops
 656 
 657 void __attribute__((naked,noinline)) sub_fc02167a_my() { // "APENDSTRM"
 658 asm volatile (
 659 "    push   {r0, lr}\n"
 660 "    ldr    r0, [r0, #8]\n"
 661 "    ldr    r0, [r0, #4]\n"
 662 "    bl     getchunkinfo\n"
 663 "    pop    {r0, lr}\n"
 664 "    ldr    pc, =0xfc02167b\n"
 665 );
 666 }
 667 
 668 void getchunkinfo(int *r0) { // for each model, firmware struct needs to be verified
 669     int m;
 670     unsigned int lsum = 0;
 671     m = *r0; // num of chunks
 672     int *cl = (int*)(*(r0+1));
 673     while (m>0) {
 674         // chunk properties, 3 words: addr, size, unknown
 675         lsum += *(cl+1);
 676         cl+=3;
 677         m--;
 678     }
 679     bitrate_calc(lsum);
 680 }
 681 
 682 // pointer to APENDSTRM handler is located in RAM
 683 void replace_apendstrm() {
 684     *(int*)0x10E20 = (int)sub_fc02167a_my | 1;
 685 }
 686 

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