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

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

DEFINITIONS

This source file includes following definitions.
  1. spytask
  2. CreateTask_spytask
  3. boot
  4. CreateTask_my
  5. sub_fc064300_my
  6. sub_fc064490_my
  7. sub_fc064896_my
  8. task_Startup_my
  9. sub_fc0780e6_my
  10. init_file_modules_task
  11. init_required_fw_features
  12. kbd_p2_f_my
  13. sub_fc075c6e_my

   1 #include "lolevel.h"
   2 #include "platform.h"
   3 #include "core.h"
   4 
   5 const char * const new_sa = &_end;
   6 
   7 // Forward declarations
   8 
   9 extern void task_CaptSeq();
  10 extern void task_InitFileModules();
  11 extern void task_RotaryEncoder();
  12 extern void task_MovieRecord();
  13 extern void task_ExpDrv();
  14 
  15 extern void handle_jogdial();
  16 
  17 /*----------------------------------------------------------------------
  18     spytask
  19 -----------------------------------------------------------------------*/
  20 void spytask(long ua, long ub, long uc, long ud, long ue, long uf)
  21 {
  22     core_spytask();
  23 }
  24 
  25 /*----------------------------------------------------------------------
  26     CreateTask_spytask
  27 -----------------------------------------------------------------------*/
  28 void CreateTask_spytask()
  29 {
  30     _CreateTask("SpyTask", 0x19, 0x2000, spytask, 0);
  31 }
  32 
  33 
  34 /*----------------------------------------------------------------------
  35     boot()
  36 
  37     Main entry point for the CHDK code
  38 -----------------------------------------------------------------------*/
  39 
  40 /*************************************************************/
  41 void __attribute__((naked,noinline)) boot() {
  42     asm volatile ( // 0xfc02000c
  43 "    movw    r0, #0x4000\n"
  44 "    movt    r0, #0\n"
  45 "    mov     sp, r0\n"
  46 "    bl      sub_fc02006a\n"
  47 "    ldr     r2, =0xc0242010\n"
  48 "    ldr     r1, [r2]\n"
  49 "    orr     r1, r1, #1\n"
  50 "    str     r1, [r2]\n"
  51 "    ldr     r0, =0xfcd67030\n" // code copied from ROM
  52 "    ldr     r1, =0x010e1000\n" // to ram
  53 "    ldr     r3, =0x0110dc1c\n"
  54 "loc_fc02002a:\n"
  55 "    cmp     r1, r3\n"
  56 "    itt     lo\n"
  57 "    ldrlo   r2, [r0], #4\n"
  58 "    strlo   r2, [r1], #4\n"
  59 "    blo     loc_fc02002a\n"
  60 // Install CreateTask patch
  61 // use half words in case source or destination not word aligned
  62         "adr     r0, patch_CreateTask\n"    // src: Patch data
  63         "ldr     r1, =hook_CreateTask\n"    // dest: Address to patch (hook_ has thumb bit off)
  64         "add     r2, r0, #8\n" // two words
  65 "task_hook_loop:\n"
  66         "ldrh   r3, [r0],#2\n"
  67         "strh   r3, [r1],#2\n"
  68         "cmp    r0,r2\n"
  69         "blo    task_hook_loop\n"
  70 "    ldr     r0, =0x010e1000\n"
  71 "    ldr     r1, =0x0002cc1c\n"
  72 "    bl      sub_fc133dae\n" // cache stuff, function used in loader
  73 "    ldr     r0, =0xfcd39d78\n" // DATA copied
  74 "    ldr     r1, =0x00008000\n" // to RAM
  75 "    ldr     r3, =0x000352b8\n"
  76 "loc_fc020046:\n"
  77 "    cmp     r1, r3\n"
  78 "    itt     lo\n"
  79 "    ldrlo   r2, [r0], #4\n"
  80 "    strlo   r2, [r1], #4\n"
  81 "    blo     loc_fc020046\n"
  82 "    ldr     r3, =0x000352b8\n" // BSS
  83 "    ldr     r1, =0x0036a354\n"
  84 "    mov.w   r2, #0\n"
  85 "loc_fc02005c:\n"
  86 "    cmp     r3, r1\n"
  87 "    it      lo\n"
  88 "    strlo   r2, [r3], #4\n"
  89 "    blo     loc_fc02005c\n"
  90 "    b.w     sub_fc064300_my\n"
  91 
  92         "patch_CreateTask:\n"
  93         "ldr.w   pc, [pc,#0]\n"             // Do jump to absolute address CreateTask_my
  94         ".long   CreateTask_my + 1\n"           // has to be a thumb address
  95 );
  96 }
  97 
  98 /*************************************************************/
  99 void __attribute__((naked,noinline)) CreateTask_my() {
 100 asm volatile (
 101 "    push   {r0}\n"
 102 //R3 = Pointer to task function to create
 103 "    ldr     r0, =task_CaptSeq\n"       // DryOS original code function ptr.
 104 "    cmp     r0, r3\n"                  // is the given taskptr equal to our searched function?
 105 "    itt     eq\n"                      // EQ block
 106 "    ldreq   r3, =capt_seq_task\n"      // if so replace with our task function base ptr.
 107 "    orreq   r3, #1\n"                  // make sure it's a thumb address (may not be needed?)
 108 "    beq     exitHook\n"                // below compares not necessary if this check has found something.
 109 
 110 /*
 111 "    LDR     R0, =task_ExpDrv\n"
 112 "    CMP     R0, R3\n"
 113 "    itt     eq\n"
 114 "    LDREQ   R3, =exp_drv_task\n"
 115 "    orreq   r3, #1\n"
 116 "    BEQ     exitHook\n"
 117 
 118 "    LDR     R0, =task_DvlpSeqTask\n"
 119 "    CMP     R0, R3\n"
 120 "    itt     eq\n"
 121 "    LDREQ   R3, =developseq_task\n"
 122 "    orreq   r3, #1\n"
 123 "    BEQ     exitHook\n"
 124 */
 125 
 126 "    ldr     r0, =task_FileWrite\n"
 127 "    cmp     r0, r3\n"
 128 "    itt     eq\n"
 129 "    ldreq   r3, =filewritetask\n"
 130 "    orreq   r3, #1\n"
 131 "    beq     exitHook\n"
 132 
 133 /*
 134 "    LDR     R0, =task_MovieRecord\n"
 135 "    CMP     R0, R3\n"
 136 "    LDREQ   R3, =movie_record_task\n"
 137 "    BEQ     exitHook\n"
 138 */
 139 
 140 "    ldr     r0, =task_InitFileModules\n"
 141 "    cmp     r0, r3\n"
 142 "    itt     eq\n"
 143 "    ldreq   r3, =init_file_modules_task\n"
 144 "    orreq   r3, #1\n"
 145 "exitHook:\n" 
 146 // restore overwritten register(s)
 147 "    pop    {r0}\n"
 148 // Execute overwritten instructions from original code, then jump to firmware
 149 // NOTE number of instructions duplicated here depends on size of original ROM code
 150 // instructions. Must replace 8 bytes!
 151 "    stmdb   sp!, {r1, r2, r3, r4, r5, r6, r7, r8, r9, lr}\n"
 152 "    mov     r4, r0\n"
 153 "    ldr     r0, =0x8160\n"
 154 "    ldr.w   pc, =(hook_CreateTask + 8 + 1) \n"  // Continue in firmware (thumb bit set)
 155 ".ltorg\n"
 156 );
 157 }
 158 
 159 void __attribute__((naked,noinline)) sub_fc064300_my() {
 160 // no GPIO checks needed with 0x12345678 set, native fw handles long press
 161     asm volatile (
 162 "    push    {r4, lr}\n"
 163 #if defined(CHDK_NOT_IN_CANON_HEAP)
 164 "    ldr     r4, =0x0036a354\n"         // heap start, modify here
 165 #else
 166     "ldr     r4, =new_sa\n"             // +
 167     "ldr     r4, [r4]\n"                // +
 168 #endif
 169 "    sub     sp, #0x78\n"
 170 "    ldr     r0, =0x006ce000\n"
 171 "    ldr     r1, =0x0008fd8c\n"
 172 "    subs    r0, r0, r4\n"
 173 "    cmp     r0, r1\n"
 174 "    bhs     loc_fc064312\n"
 175 "loc_fc064310:\n"
 176 "    b       loc_fc064310\n"
 177 "loc_fc064312:\n"
 178 "    ldr     r1, =0x00008074\n"
 179 "    mov.w   r0, #0x80000\n"
 180 "    str     r0, [r1]\n"
 181 "    ldr     r1, =0x00008078\n"
 182 "    ldr     r0, =0x42a41000\n"
 183 "    str     r0, [r1]\n"
 184 "    ldr     r1, =0x0000807c\n"
 185 "    ldr     r0, =0x42a43000\n"
 186 "    str     r0, [r1]\n"
 187 "    movs    r1, #0x78\n"
 188 "    mov     r0, sp\n"
 189 "    blx     sub_fc2efa24\n"
 190 "    ldr     r0, =0x0062e000\n"
 191 "    mov.w   r1, #0xa0000\n"
 192 "    stm.w   sp, {r0, r1, r4}\n"
 193 "    ldr     r1, =0x00622274\n"
 194 "    subs    r2, r1, r4\n"
 195 "    strd    r2, r1, [sp, #0xc]\n"
 196 "    str     r0, [sp, #0x14]\n"
 197 "    movs    r0, #0x22\n"
 198 "    str     r0, [sp, #0x18]\n"
 199 "    movs    r0, #0x98\n"
 200 "    str     r0, [sp, #0x1c]\n"
 201 "    movw    r0, #0x24c\n"
 202 "    str     r0, [sp, #0x20]\n"
 203 "    movs    r0, #0xfa\n"
 204 "    str     r0, [sp, #0x24]\n"
 205 "    movs    r0, #0xe8\n"
 206 "    str     r0, [sp, #0x28]\n"
 207 "    movs    r0, #0x85\n"
 208 "    str     r0, [sp, #0x2c]\n"
 209 "    movs    r0, #0x40\n"
 210 "    str     r0, [sp, #0x30]\n"
 211 "    movs    r0, #4\n"
 212 "    str     r0, [sp, #0x34]\n"
 213 "    movs    r0, #0\n"
 214 "    str     r0, [sp, #0x38]\n"
 215 "    movs    r0, #0x10\n"
 216 "    str     r0, [sp, #0x5c]\n"
 217 "    movs    r2, #0\n"
 218 "    lsls    r0, r0, #8\n"
 219 "    str     r0, [sp, #0x60]\n"
 220 //"    ldr     r1, =0xfc064491\n"
 221 "    ldr     r1, =sub_fc064490_my\n"// -> continue here (init_task)
 222 "    asrs    r0, r0, #4\n"
 223 "    str     r0, [sp, #0x64]\n"
 224 "    lsls    r0, r0, #5\n"
 225 "    str     r0, [sp, #0x68]\n"
 226 "    mov     r0, sp\n"
 227 "    blx     sub_fc2eef7c\n"
 228 "    add     sp, #0x78\n"
 229 "    pop     {r4, pc}\n"
 230 ".ltorg\n"
 231     );
 232 }
 233 
 234 void __attribute__((naked,noinline)) sub_fc064490_my() {
 235     asm volatile (
 236 "    push    {r4, lr}\n"
 237 "    ldr     r4, =0xfc06453c\n" //  *"/_term"
 238 "    bl      sub_fc065764\n"
 239 "    ldr     r0, =0x000080ec\n"
 240 "    ldr     r1, [r0]\n"
 241 "    ldr     r0, =0x00008074\n"
 242 "    ldr     r0, [r0]\n"
 243 "    adds    r0, #0x10\n"
 244 "    cmp     r1, r0\n"
 245 "    bhs     loc_fc0644ac\n"
 246 "    ldr     r0, =0xfc06454c\n" //  *"USER_MEM size checking"
 247 "    bl      sub_fc064524\n"
 248 "loc_fc0644ac:\n"
 249 "    bl      sub_fc133e88\n" // disable IRQ
 250 "    ldr     r3, =0x80000800\n"
 251 // note capdis bad output
 252 //"    mov.w   r1, #-0x80000000\n"
 253 //"    mov.w   r2, #-0x11111112\n"
 254 "    mov.w   r1, #0x80000000\n"
 255 "    mov.w   r2, #0xeeeeeeee\n"
 256 "loc_fc0644ba:\n"
 257 "    stm     r1!, {r2}\n"
 258 "    cmp     r1, r3\n"
 259 "    blo     loc_fc0644ba\n"
 260 "    bl      sub_fc133e9a\n" // enable IRQ
 261 "    bl      sub_fc133f18\n"
 262 "    cmp     r0, #0\n"
 263 "    bge     loc_fc0644d2\n"
 264 "    ldr     r0, =0xfc064568\n" //  *"dmSetup"
 265 "    bl      sub_fc064524\n"
 266 "loc_fc0644d2:\n"
 267 "    bl      sub_fc064d18\n"
 268 "    cmp     r0, #0\n"
 269 "    bge     loc_fc0644e0\n"
 270 "    ldr     r0, =0xfc064570\n" //  *"termDriverInit"
 271 "    bl      sub_fc064524\n"
 272 "loc_fc0644e0:\n"
 273 "    mov     r0, r4\n"
 274 "    bl      sub_fc064da6\n"
 275 "    cmp     r0, #0\n"
 276 "    bge     loc_fc0644f0\n"
 277 "    ldr     r0, =0xfc064580\n" //  *"termDeviceCreate"
 278 "    bl      sub_fc064524\n"
 279 "loc_fc0644f0:\n"
 280 "    mov     r0, r4\n"
 281 "    bl      sub_fc0646c8\n"
 282 "    cmp     r0, #0\n"
 283 "    bge     loc_fc064500\n"
 284 "    ldr     r0, =0xfc064594\n" //  *"stdioSetup"
 285 "    bl      sub_fc064524\n"
 286 "loc_fc064500:\n"
 287 "    bl      sub_fc06480c\n"
 288 "    cmp     r0, #0\n"
 289 "    bge     loc_fc06450e\n"
 290 "    ldr     r0, =0xfc0645a0\n" //  *"stdlibSetup"
 291 "    bl      sub_fc064524\n"
 292 "loc_fc06450e:\n"
 293 "    bl      sub_fc0678ec\n"
 294 "    cmp     r0, #0\n"
 295 "    bge     loc_fc06451c\n"
 296 "    ldr     r0, =0xfc0645ac\n" //  *"extlib_setup"
 297 "    bl      sub_fc064524\n"
 298 "loc_fc06451c:\n"
 299 "    pop.w   {r4, lr}\n"
 300 //"    b.w     loc_fc064896\n"
 301 "    b.w     sub_fc064896_my\n"
 302     ".ltorg\n"
 303     );
 304 }
 305 void __attribute__((naked,noinline)) sub_fc064896_my() {
 306     asm volatile (
 307 "    push    {r3, lr}\n"
 308 "    bl      sub_fc0649b0\n"
 309 "    bl      sub_fc0bda32\n"
 310 "    cbnz    r0, loc_fc0648ac\n"
 311 "    bl      sub_fc079012\n" // IsNormalCameraMode_FW
 312 "    cbz     r0, loc_fc0648ac\n"
 313 "    movs    r0, #1\n"
 314 "    b       loc_fc0648ae\n"
 315 "loc_fc0648ac:\n"
 316 "    movs    r0, #0\n"
 317 "loc_fc0648ae:\n"
 318 "    bl      sub_fc0781f4\n" // power-on mode handling & startupchecks here, no override needed with 0x12345678 set
 319 "    cbnz    r0, loc_fc0648ba\n"
 320 "    bl      sub_fc06499e\n"
 321 "loc_fc0648b8:\n"
 322 "    b       loc_fc0648b8\n"
 323 "loc_fc0648ba:\n"
 324 "    blx     sub_fc2eefd4\n"
 325 "    ldr     r1, =0x006ce000\n"
 326 "    movs    r0, #0\n"
 327 "    bl      sub_fc360250\n"
 328 "    blx     sub_fc2ef53c\n"
 329 "    movs    r3, #0\n"
 330 "    str     r3, [sp]\n"
 331 //"    ldr     r3, =0xfc064831\n" //  task_Startup
 332 "    ldr     r3, =task_Startup_my\n" //  ->
 333 "    movs    r2, #0\n"
 334 "    movs    r1, #0x19\n"
 335 "    ldr     r0, =0xfc0648e8\n" //  *"Startup"
 336 "    bl      _CreateTask\n"
 337 //"    blx     sub_fc2ef5ac\n" // j_CreateTask
 338 "    movs    r0, #0\n"
 339 "    pop     {r3, pc}\n"
 340     ".ltorg\n"
 341     );
 342 }
 343 
 344 void __attribute__((naked,noinline)) task_Startup_my() {
 345     asm volatile (
 346 "    push    {r4, lr}\n"
 347 "    bl      sub_fc13515c\n" // CreateTask ClockSave
 348 "    bl      sub_fc06497c\n" // posixSetup etc
 349 //"    bl      sub_fc064b10\n" // ->nullsub
 350 "    bl      sub_fc0db5c4\n" // StartWDT ...
 351 // added for SD card UHS detection https://chdk.setepontos.com/index.php?topic=13089.msg132583#msg132583
 352 "bl sub_010e638b\n" // ref in sub_010e647c following SD1stInit create
 353 //"    bl      sub_fc064b66\n" // StartDiskboot
 354 "    bl      sub_fc091b6e\n"
 355 "    bl      sub_fc0db718\n"
 356 "    bl      sub_fc064c58\n"
 357 "    bl      sub_fc064a90\n" // InitExDrivers.c
 358 "    bl      sub_fc0db602\n"
 359 "    bl      sub_fc0bd780\n"
 360 "    bl      sub_fc0db71e\n"
 361 "    bl      sub_fc0780e6_my\n" // CreateTask PhySw
 362 "    bl      CreateTask_spytask\n" 
 363 "    bl      init_required_fw_features\n" // added
 364 "    bl      sub_fc282abc\n"
 365 "    bl      sub_fc0db734\n"
 366 "    bl      sub_fc0bd718\n"
 367 "    bl      sub_fc134f16\n"
 368 "    bl      sub_fc0bd8de\n"
 369 "    bl      sub_fc0db576\n"
 370 "    bl      sub_fc134ed2\n"
 371 "    bl      sub_fc064c5c\n"
 372 "    bl      sub_fc356c62\n"
 373 "    bl      sub_fc134ea6\n"
 374 "    pop.w   {r4, lr}\n"
 375 "    b.w     sub_fc135132\n"
 376     ".ltorg\n"
 377     );
 378 }
 379 
 380 // -f=chdk -s=0xfc0780e7 -c=18
 381 //taskcreate_physw
 382 void __attribute__((naked,noinline)) sub_fc0780e6_my() {
 383     asm volatile (
 384 "    push    {r3, r4, r5, lr}\n"
 385 "    bl      sub_fc076fb8\n"
 386 "    bl      sub_fc078f90\n" // IsFactoryMode_FW
 387 "    cbnz    r0, loc_fc0780f6\n"
 388 "    bl      sub_fc076f5c\n" // OpLog.Start_FW
 389 "loc_fc0780f6:\n"
 390 "    ldr     r4, =0x000082c8\n" //  physw_run
 391 "    ldr     r0, [r4, #4]\n"
 392 "    cmp     r0, #0\n"
 393 "    bne     loc_fc078112\n"
 394 "    movs    r3, #0\n"
 395 "    str     r3, [sp]\n"
 396 //"    ldr     r3, =0xfc0780c1\n" //  task_PhySw
 397 "    ldr     r3, =mykbd_task\n"
 398 "    movs    r1, #0x17\n"
 399 "    ldr     r0, =0xfc078140\n" //  *"PhySw"
 400 "    movw    r2, #0x2000\n" // adjusted 0x800 -> 0x2000
 401 "    blx     sub_fc2ef8fc\n" // j_CreateTaskStrictly
 402 "    str     r0, [r4, #4]\n"
 403 "loc_fc078112:\n"
 404 "    pop     {r3, r4, r5, pc}\n"
 405     ".ltorg\n"
 406     );
 407 }
 408  
 409 // -f=chdk -s=task_InitFileModules -c=16
 410 void __attribute__((naked,noinline)) init_file_modules_task() {
 411     asm volatile (
 412 // task_InitFileModules 0xfc0c22d1
 413 "    push    {r4, r5, r6, lr}\n"
 414 "    bl      sub_fc0c361c\n"
 415 "    movs    r4, r0\n"
 416 "    movw    r5, #0x5006\n"
 417 "    beq     loc_fc0c22e6\n"
 418 "    movs    r1, #0\n"
 419 "    mov     r0, r5\n"
 420 "    bl      _PostLogicalEventToUI\n"
 421 "loc_fc0c22e6:\n"
 422 "    bl      sub_fc0c3646\n"
 423 "    BL      core_spytask_can_start\n" // + CHDK: Set "it's-safe-to-start" flag for spytask
 424 "    cmp     r4, #0\n"
 425 "    bne     loc_fc0c22fa\n"
 426 "    mov     r0, r5\n"
 427 "    pop.w   {r4, r5, r6, lr}\n"
 428 "    movs    r1, #0\n"
 429 "    b.w     _PostLogicalEventToUI\n"
 430 "loc_fc0c22fa:\n"
 431 "    pop     {r4, r5, r6, pc}\n"
 432     ".ltorg\n"
 433     );
 434 }
 435 /*
 436     *** TEMPORARY? workaround ***
 437     Init stuff to avoid asserts on cameras running DryOS r54+
 438     https://chdk.setepontos.com/index.php?topic=12516.0
 439     Execute this only once
 440  */
 441 void init_required_fw_features(void) {
 442     extern void _init_focus_eventflag();
 443     extern void _init_nd_eventflag();
 444 //    extern void _init_nd_semaphore();
 445     //extern void _init_zoom_semaphore(); // for MoveZoomLensWithPoint
 446 
 447     _init_focus_eventflag();
 448     _init_nd_eventflag();
 449     // for MoveIrisWithAv, based on fc3d1a74 (but without registers eventprocs)
 450     extern int av_override_semaphore;
 451     extern int _CreateBinarySemaphoreStrictly(int x, int y);
 452     av_override_semaphore = _CreateBinarySemaphoreStrictly(0,0);
 453 //    _init_nd_semaphore();
 454 }
 455 
 456 // jogdial override code called from kbd task
 457 // -f=chdk -s=kbd_p2_f -c=77
 458 // kbd_p2_f 0xfc077e8d
 459 void __attribute__((naked,noinline)) kbd_p2_f_my() {
 460     asm volatile(
 461 "    push.w  {r4, r5, r6, r7, r8, lr}\n"
 462 "    ldr     r6, =0x00036c34\n"
 463 "    sub     sp, #0x18\n"
 464 "    add     r7, sp, #8\n"
 465 "    subs    r6, #0xc\n"
 466 "    b       loc_fc077ece\n"
 467 "loc_fc077e9a:\n"
 468 "    ldr     r1, =0x00036c34\n"
 469 "    add     r3, sp, #8\n"
 470 "    ldrb.w  r0, [sp, #4]\n"
 471 "    add     r2, sp, #0x14\n"
 472 "    subs    r1, #0x18\n"
 473 "    bl      sub_fc0760c4\n"
 474 "    cbnz    r0, loc_fc077eb4\n"
 475 "    ldr     r1, [sp, #0x14]\n"
 476 "    movs    r0, #0\n"
 477 "    bl      sub_fc077dfe\n"
 478 "loc_fc077eb4:\n"
 479 "    movs    r0, #2\n"
 480 "loc_fc077eb6:\n"
 481 "    ldr.w   r1, [r7, r0, lsl #2]\n"
 482 "    cbz     r1, loc_fc077ec6\n"
 483 "    ldr.w   r2, [r6, r0, lsl #2]\n"
 484 "    bics    r2, r1\n"
 485 "    str.w   r2, [r6, r0, lsl #2]\n"
 486 "loc_fc077ec6:\n"
 487 "    subs    r0, r0, #1\n"
 488 "    sxtb    r0, r0\n"
 489 "    cmp     r0, #0\n"
 490 "    bge     loc_fc077eb6\n"
 491 "loc_fc077ece:\n"
 492 "    ldr     r0, =0x00036c34\n"
 493 "    add     r1, sp, #4\n"
 494 "    subs    r0, #0xc\n"
 495 "    bl      sub_fc075dc4\n"
 496 "    cmp     r0, #0\n"
 497 "    bne     loc_fc077e9a\n"
 498 "    ldr.w   r8, =0x00036c34\n"
 499 "    movs    r4, #0\n"
 500 "loc_fc077ee2:\n"
 501 "    movs    r5, #0\n"
 502 "    ldr.w   r0, [r6, r4, lsl #2]\n"
 503 "    ldr.w   r1, [r8, r4, lsl #2]\n"
 504 "    ands    r0, r1\n"
 505 "    str.w   r0, [r6, r4, lsl #2]\n"
 506 "    b       loc_fc077f3a\n"
 507 "loc_fc077ef4:\n"
 508 "    lsrs    r0, r5\n"
 509 "    lsls    r0, r0, #0x1f\n"
 510 "    beq     loc_fc077f32\n"
 511 "    ldr     r1, =0x00036c34\n"
 512 "    add.w   r0, r5, r4, lsl #5\n"
 513 "    add     r3, sp, #8\n"
 514 "    subs    r1, #0x18\n"
 515 "    add     r2, sp, #0x14\n"
 516 "    uxtb    r0, r0\n"
 517 "    bl      sub_fc0760c4\n"
 518 "    cbnz    r0, loc_fc077f16\n"
 519 "    ldr     r1, [sp, #0x14]\n"
 520 "    movs    r0, #1\n"
 521 "    bl      sub_fc077dfe\n"
 522 "loc_fc077f16:\n"
 523 "    mov     r0, r4\n"
 524 "    b       loc_fc077f2e\n"
 525 "loc_fc077f1a:\n"
 526 "    ldr.w   r1, [r7, r0, lsl #2]\n"
 527 "    cbz     r1, loc_fc077f2a\n"
 528 "    ldr.w   r2, [r6, r0, lsl #2]\n"
 529 "    bics    r2, r1\n"
 530 "    str.w   r2, [r6, r0, lsl #2]\n"
 531 "loc_fc077f2a:\n"
 532 "    adds    r0, r0, #1\n"
 533 "    sxtb    r0, r0\n"
 534 "loc_fc077f2e:\n"
 535 "    cmp     r0, #3\n"
 536 "    blt     loc_fc077f1a\n"
 537 "loc_fc077f32:\n"
 538 "    ldr.w   r0, [r6, r4, lsl #2]\n"
 539 "    adds    r5, r5, #1\n"
 540 "    uxtb    r5, r5\n"
 541 "loc_fc077f3a:\n"
 542 "    cmp     r0, #0\n"
 543 "    bne     loc_fc077ef4\n"
 544 "    adds    r4, r4, #1\n"
 545 "    sxtb    r4, r4\n"
 546 "    cmp     r4, #3\n"
 547 "    blt     loc_fc077ee2\n"
 548 "    bl      sub_fc075c6e_my\n" // ->
 549 "    add     sp, #0x18\n"
 550 "    pop.w   {r4, r5, r6, r7, r8, pc}\n"
 551 ".ltorg\n"
 552     );
 553 }
 554 
 555 //  -f=chdk -s=0xfc075c6f -c=13
 556 void __attribute__((naked,noinline)) sub_fc075c6e_my() {
 557     asm volatile(
 558 "    push    {r4, lr}\n"
 559 "    ldr     r4, =0x00009800\n"
 560 "    ldr     r0, [r4, #0xc]\n"
 561 "    bl      sub_fc0771f0\n"
 562 "    ldr     r0, [r4, #0x10]\n"
 563 "    bl      sub_fc07727a\n"
 564 "    bl      sub_fc0f8224\n"
 565 "    ldr     r0, [r4, #0x14]\n"
 566 "    bl      sub_fc07710c\n"
 567 "    ldr     r0, [r4, #0x18]\n"
 568 "    bl      sub_fc07710c\n"
 569 // re-ordered
 570 //"    pop.w   {r4, lr}\n"
 571 //"    b.w     loc_fc0774e4\n"
 572 "    bl      handle_jogdial\n"  // +
 573 "    cmp     r0, #0\n"          // +
 574 "    beq     no_scroll\n"       // +
 575 "    bl      sub_fc0774e4\n"    // handles scrollwheel(s), void function, no args
 576 "no_scroll:\n"                  // +
 577 "    pop     {r4, pc}\n"        // +
 578 ".ltorg\n"
 579     );
 580 }

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