root/platform/s100/sub/102a/boot.c

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

DEFINITIONS

This source file includes following definitions.
  1. taskHook
  2. boot
  3. sub_FF000364_my
  4. sub_FF0011BC_my
  5. sub_FF005F38_my
  6. taskcreate_Startup_my
  7. sub_FF00FD84_my
  8. sub_FF00FDDC_my
  9. task_Startup_my
  10. taskcreatePhySw_my
  11. spytask
  12. CreateTask_spytask
  13. init_file_modules_task
  14. JogDial_task_my

   1 #include "lolevel.h"
   2 #include "platform.h"
   3 #include "core.h"
   4 #include "dryos31.h"
   5 
   6 #define offsetof(TYPE, MEMBER) ((int) &((TYPE *)0)->MEMBER)
   7 
   8 const char * const new_sa = &_end;
   9 
  10 // Forward declarations
  11 void CreateTask_PhySw();
  12 void CreateTask_spytask();
  13 extern volatile int jogdial_stopped;
  14 void JogDial_task_my(void);
  15 
  16 extern void task_CaptSeq();
  17 extern void task_InitFileModules();
  18 extern void task_RotaryEncoder();
  19 extern void task_MovieRecord();
  20 extern void task_ExpDrv();
  21 
  22 void taskHook(context_t **context)
  23 { 
  24         task_t *tcb=(task_t*)((char*)context-offsetof(task_t, context));
  25 
  26         // Replace firmware task addresses with ours
  27         if(tcb->entry == (void*)task_CaptSeq)                   tcb->entry = (void*)capt_seq_task; 
  28         if(tcb->entry == (void*)task_InitFileModules)   tcb->entry = (void*)init_file_modules_task;
  29         if(tcb->entry == (void*)task_RotaryEncoder)     tcb->entry = (void*)JogDial_task_my;
  30         if(tcb->entry == (void*)task_MovieRecord)               tcb->entry = (void*)movie_record_task;
  31         if(tcb->entry == (void*)task_ExpDrv)                    tcb->entry = (void*)exp_drv_task;
  32 }
  33 
  34 /*----------------------------------------------------------------------
  35         boot()
  36 
  37         Main entry point for the CHDK code
  38 -----------------------------------------------------------------------*/
  39 //** boot  @ 0xFF00000C 
  40 
  41 void __attribute__((naked,noinline)) boot(  ) { 
  42 asm volatile (
  43 "    LDR     R1, =0xC0410000\n"
  44 "    MOV     R0, #0\n"
  45 "    STR     R0, [R1]\n"
  46 "    MOV     R1, #0x78\n"
  47 "    MCR     p15, 0, R1, c1, c0\n"
  48 "    MOV     R1, #0\n"
  49 "    MCR     p15, 0, R1, c7, c10, 4\n"
  50 "    MCR     p15, 0, R1, c7, c5\n"
  51 "    MCR     p15, 0, R1, c7, c6\n"
  52 "    MOV     R0, #0x3D\n"
  53 "    MCR     p15, 0, R0, c6, c0\n"
  54 "    MOV     R0, #0xC000002F\n"
  55 "    MCR     p15, 0, R0, c6, c1\n"
  56 "    MOV     R0, #0x37\n"
  57 "    MCR     p15, 0, R0, c6, c2\n"
  58 "    MOV     R0, #0x40000037\n"
  59 "    MCR     p15, 0, R0, c6, c3\n"
  60 "    MOV     R0, #0x80000017\n"
  61 "    MCR     p15, 0, R0, c6, c4\n"
  62 "    LDR     R0, =0xFF00002F\n"
  63 "    MCR     p15, 0, R0, c6, c5\n"
  64 "    LDR     R0, =0xD000002B\n"
  65 "    MCR     p15, 0, R0, c6, c7\n"
  66 "    MOV     R0, #0x34\n"
  67 "    MCR     p15, 0, R0, c2, c0\n"
  68 "    MOV     R0, #0x34\n"
  69 "    MCR     p15, 0, R0, c2, c0, 1\n"
  70 "    MOV     R0, #0x34\n"
  71 "    MCR     p15, 0, R0, c3, c0\n"
  72 "    LDR     R0, =0x33333330\n"
  73 "    MCR     p15, 0, R0, c5, c0, 2\n"
  74 "    LDR     R0, =0x33333330\n"
  75 "    MCR     p15, 0, R0, c5, c0, 3\n"
  76 "    MRC     p15, 0, R0, c1, c0\n"
  77 "    ORR     R0, R0, #0x1000\n"
  78 "    ORR     R0, R0, #4\n"
  79 "    ORR     R0, R0, #1\n"
  80 "    MCR     p15, 0, R0, c1, c0\n"
  81 "    MOV     R1, #0x80000006\n"
  82 "    MCR     p15, 0, R1, c9, c1\n"
  83 "    MOV     R1, #6\n"
  84 "    MCR     p15, 0, R1, c9, c1, 1\n"
  85 "    MRC     p15, 0, R1, c1, c0\n"
  86 "    ORR     R1, R1, #0x50000\n"
  87 "    MCR     p15, 0, R1, c1, c0\n"
  88 "    LDR     R2, =0xC0200000\n"
  89 "    MOV     R1, #1\n"
  90 "    STR     R1, [R2, #0x10C]\n"
  91 "    MOV     R1, #0xFF\n"
  92 "    STR     R1, [R2, #0xC]\n"
  93 "    STR     R1, [R2, #0x1C]\n"
  94 "    STR     R1, [R2, #0x2C]\n"
  95 "    STR     R1, [R2, #0x3C]\n"
  96 "    STR     R1, [R2, #0x4C]\n"
  97 "    STR     R1, [R2, #0x5C]\n"
  98 "    STR     R1, [R2, #0x6C]\n"
  99 "    STR     R1, [R2, #0x7C]\n"
 100 "    STR     R1, [R2, #0x8C]\n"
 101 "    STR     R1, [R2, #0x9C]\n"
 102 "    STR     R1, [R2, #0xAC]\n"
 103 "    STR     R1, [R2, #0xBC]\n"
 104 "    STR     R1, [R2, #0xCC]\n"
 105 "    STR     R1, [R2, #0xDC]\n"
 106 "    STR     R1, [R2, #0xEC]\n"
 107 "    STR     R1, [R2, #0xFC]\n"
 108 "    LDR     R1, =0xC0400008\n"
 109 "    LDR     R2, =0x430005\n"
 110 "    STR     R2, [R1]\n"
 111 "    MOV     R1, #1\n"
 112 "    LDR     R2, =0xC0243100\n"
 113 "    STR     R2, [R1]\n"
 114 "    LDR     R2, =0xC0242010\n"
 115 "    LDR     R1, [R2]\n"
 116 "    ORR     R1, R1, #1\n"
 117 "    STR     R1, [R2]\n"
 118 "    LDR     R0, =0xFF64BECC\n"
 119 "    LDR     R1, =0x1900\n"
 120 "    LDR     R3, =0x148A8\n"
 121 "loc_FF000144:\n"
 122 "    CMP     R1, R3\n"
 123 "    LDRCC   R2, [R0], #4\n"
 124 "    STRCC   R2, [R1], #4\n"
 125 "    BCC     loc_FF000144\n"
 126 "    LDR     R1, =0x195D34\n"
 127 "    MOV     R2, #0\n"
 128 "loc_FF00015C:\n"
 129 "    CMP     R3, R1\n"
 130 "    STRCC   R2, [R3], #4\n"
 131 "    BCC     loc_FF00015C\n"
 132 "    B       sub_FF000364_my \n"
 133         );
 134 }
 135 
 136 
 137 //** sub_FF000364_my  @ 0xFF000364
 138 
 139 void __attribute__((naked,noinline)) sub_FF000364_my() {
 140 
 141         //http://chdk.setepontos.com/index.php/topic,4194.0.html
 142         *(int*)0x1938=(int)taskHook;
 143         *(int*)0x193C=(int)taskHook; // need this for startup in Playback mode (otherwise init_file_modules_task doesn't hook properly)
 144 
 145         *(int*)(0x26E0+0x4) = (*(int*)0xC022F48C)&4 ? 0x200000 : 0x100000;
 146 
 147 asm volatile (
 148 "    LDR     R0, =0xFF0003DC\n"
 149 "    MOV     R1, #0\n"
 150 "    LDR     R3, =0xFF000414\n"
 151 "loc_FF000370:\n"
 152 "    CMP     R0, R3\n"
 153 "    LDRCC   R2, [R0], #4\n"
 154 "    STRCC   R2, [R1], #4\n"
 155 "    BCC     loc_FF000370\n"
 156 "    LDR     R0, =0xFF000414\n"
 157 "    MOV     R1, #0x4B0\n"
 158 "    LDR     R3, =0xFF000628\n"
 159 "loc_FF00038C:\n"
 160 "    CMP     R0, R3\n"
 161 "    LDRCC   R2, [R0], #4\n"
 162 "    STRCC   R2, [R1], #4\n"
 163 "    BCC     loc_FF00038C\n"
 164 "    MOV     R0, #0xD2\n"
 165 "    MSR     CPSR_cxsf, R0\n"
 166 "    MOV     SP, #0x1000\n"
 167 "    MOV     R0, #0xD3\n"
 168 "    MSR     CPSR_cxsf, R0\n"
 169 "    MOV     SP, #0x1000\n"
 170 "    LDR     R0, =0x6C4\n"
 171 "    LDR     R2, =0xEEEEEEEE\n"
 172 "    MOV     R3, #0x1000\n"
 173 "loc_FF0003C0:\n"
 174 "    CMP     R0, R3\n"
 175 "    STRCC   R2, [R0], #4\n"
 176 "    BCC     loc_FF0003C0\n"
 177 "    BL      sub_FF0011BC_my \n"  //--> 
 178         );
 179 }
 180 
 181 
 182 //** sub_FF0011BC_my  @ 0xFF0011BC 
 183 
 184 void __attribute__((naked,noinline)) sub_FF0011BC_my(  ) { 
 185 asm volatile (
 186 "    STR     LR, [SP, #-4]!\n"
 187 "    SUB     SP, SP, #0x74\n"
 188 "    MOV     R1, #0x74\n"
 189 "    MOV     R0, SP\n"
 190 "    BL      sub_FF44E0F0\n"
 191 "    MOV     R0, #0x67000\n"
 192 "    STR     R0, [SP, #4]\n"
 193 #if defined(CHDK_NOT_IN_CANON_HEAP)
 194 "    LDR     R0, =0x195D34 \n"  // use original heap offset since CHDK is loaded in high memory
 195 #else
 196 "    LDR     R0, =new_sa\n"   // otherwise use patched value
 197 "    LDR     R0, [R0]\n"      // 
 198 #endif
 199 "    LDR     R2, =0x55D788\n"
 200 "    STR     R0, [SP, #8]\n"
 201 "    SUB     R0, R2, R0\n"
 202 "    STR     R0, [SP, #0xC]\n"
 203 "    MOV     R0, #0x22\n"
 204 "    STR     R0, [SP, #0x18]\n"
 205 "    MOV     R0, #0x72\n"
 206 "    STR     R0, [SP, #0x1C]\n"
 207 "    LDR     R1, =0x565C00\n"
 208 "    LDR     R0, =0x1CD\n"
 209 "    STR     R1, [SP]\n"
 210 "    STR     R0, [SP, #0x20]\n"
 211 "    MOV     R0, #0x96\n"
 212 "    STR     R2, [SP, #0x10]\n"
 213 "    STR     R1, [SP, #0x14]\n"
 214 "    STR     R0, [SP, #0x24]\n"
 215 "    STR     R0, [SP, #0x28]\n"
 216 "    MOV     R0, #0x64\n"
 217 "    STR     R0, [SP, #0x2C]\n"
 218 "    MOV     R0, #0\n"
 219 "    STR     R0, [SP, #0x30]\n"
 220 "    STR     R0, [SP, #0x34]\n"
 221 "    MOV     R0, #0x10\n"
 222 "    STR     R0, [SP, #0x5C]\n"
 223 "    MOV     R0, #0x800\n"
 224 "    STR     R0, [SP, #0x60]\n"
 225 "    MOV     R0, #0xA0\n"
 226 "    STR     R0, [SP, #0x64]\n"
 227 "    MOV     R0, #0x280\n"
 228 "    STR     R0, [SP, #0x68]\n"
 229 "    LDR     R1, =sub_FF005F38_my \n" // -->
 230 "    MOV     R2, #0\n"
 231 "    MOV     R0, SP\n"
 232 "    BL      sub_FF0034D0\n"
 233 "    ADD     SP, SP, #0x74\n"
 234 "    LDR     PC, [SP], #4\n"
 235         );
 236 }
 237 
 238 
 239 //** sub_FF005F38_my  @ 0xFF005F38 
 240 
 241 void __attribute__((naked,noinline)) sub_FF005F38_my(  ) { 
 242 asm volatile (
 243 "    STMFD   SP!, {R4,LR}\n"
 244 "    BL      sub_FF000B34\n"
 245 "    BL      sub_FF00A390\n"
 246 "    CMP     R0, #0\n"
 247 "    LDRLT   R0, =0xFF00604C\n"
 248 "    BLLT    sub_FF00602C\n"
 249 "    BL      sub_FF005B70\n"
 250 "    CMP     R0, #0\n"
 251 "    LDRLT   R0, =0xFF006054\n"
 252 "    BLLT    sub_FF00602C\n"
 253 "    LDR     R0, =0xFF006064\n"
 254 "    BL      sub_FF005C58\n"
 255 "    CMP     R0, #0\n"
 256 "    LDRLT   R0, =0xFF00606C\n"
 257 "    BLLT    sub_FF00602C\n"
 258 "    LDR     R0, =0xFF006064\n"
 259 "    BL      sub_FF003CB4\n"
 260 "    CMP     R0, #0\n"
 261 "    LDRLT   R0, =0xFF006080\n"
 262 "    BLLT    sub_FF00602C\n"
 263 "    BL      sub_FF009CF8\n"
 264 "    CMP     R0, #0\n"
 265 "    LDRLT   R0, =0xFF00608C\n"
 266 "    BLLT    sub_FF00602C\n"
 267 "    BL      sub_FF00169C\n"
 268 "    CMP     R0, #0\n"
 269 "    LDRLT   R0, =0xFF006098\n"
 270 "    BLLT    sub_FF00602C\n"
 271 "    LDMFD   SP!, {R4,LR}\n"
 272 //"    B       sub_FF00FDAC \n" 
 273 "    B       taskcreate_Startup_my \n" // patched
 274         );
 275 }
 276 
 277 
 278 //** taskcreate_Startup_my  @ 0xFF00FDAC 
 279 
 280 void __attribute__((naked,noinline)) taskcreate_Startup_my(  ) { 
 281 asm volatile (
 282 "    STMFD   SP!, {R3,LR}\n"
 283 "    BL      sub_FF02B598\n"
 284 "    BL      sub_FF02B7B0\n"
 285 "    MOV     R3, #0\n"
 286 "    STR     R3, [SP]\n"
 287 "    LDR     R3, =sub_FF00FD84_my \n" //-->
 288 "    MOV     R2, #0x200\n"
 289 "    MOV     R1, #0x19\n"
 290 "    LDR     R0, =0xFF00FEBC\n"
 291 "    BL      sub_FF00EAF0\n"
 292 "    MOV     R0, #0\n"
 293 "    LDMFD   SP!, {R3,PC}\n"
 294         );
 295 }
 296 
 297 
 298 //** sub_FF00FD84_my  @ 0xFF00FD84 
 299 
 300 void __attribute__((naked,noinline)) sub_FF00FD84_my(  ) { 
 301 asm volatile (
 302 "    STMFD   SP!, {R4,LR}\n"
 303 "    BL      sub_FF024AEC\n"
 304 "    BL      sub_FF025C00\n"
 305 "    BL      sub_FF023768\n"
 306 "    BL      sub_FF02D9CC\n"
 307 "    BL      sub_FF023EDC\n"
 308 "    BL      sub_FF022C24\n"
 309 "    BL      sub_FF022BB0\n"
 310 "    LDMFD   SP!, {R4,LR}\n"
 311 "    B       sub_FF00FDDC_my \n" //-->
 312         );
 313 }
 314 
 315 
 316 //** sub_FF00FDDC_my  @ 0xFF00FDDC 
 317 
 318 void __attribute__((naked,noinline)) sub_FF00FDDC_my(  ) { 
 319 asm volatile (
 320 "    STMFD   SP!, {R3-R7,LR}\n"
 321 "    MOV     R6, #0\n"
 322 "    BL      sub_FF02D73C\n"
 323 "    MOVS    R7, R0\n"
 324 "    BNE     loc_FF00FE48\n"
 325 "    BL      sub_FF0264BC\n"
 326 "    CMP     R0, #0\n"
 327 "    BEQ     loc_FF00FE48\n"
 328 "    MOV     R0, #0x37\n"
 329 "    BL      sub_FF02BC18\n"
 330 "    RSBS    R5, R0, #1\n"
 331 "    MOVCC   R5, #0\n"
 332 "    MOV     R0, #0x36\n"
 333 "    BL      sub_FF02BC18\n"
 334 "    RSBS    R4, R0, #1\n"
 335 "    MOVCC   R4, #0\n"
 336 "    BL      sub_FF022BD8\n"
 337 "    CMP     R0, #1\n"
 338 "    MOVEQ   R6, #1\n"
 339 "    ORR     R0, R4, R5\n"
 340 "    ORRS    R0, R0, R6\n"
 341 "    BNE     loc_FF00FE68\n"
 342 "    BL      sub_FF0238F0\n"
 343 "    LDR     R1, =0x83DC00\n"
 344 "    MOV     R0, #0x54\n"
 345 "    BL      sub_FF02BC08\n"
 346 "loc_FF00FE44:\n"
 347 "    B       loc_FF00FE44\n"
 348 "loc_FF00FE48:\n"
 349 "    MOV     R0, #0x36\n"
 350 "    BL      sub_FF02BC18\n"
 351 "    RSBS    R4, R0, #1\n"
 352 "    MOVCC   R4, #0\n"
 353 "    MOV     R0, #0x37\n"
 354 "    BL      sub_FF02BC18\n"
 355 "    RSBS    R5, R0, #1\n"
 356 "    MOVCC   R5, #0\n"
 357 "loc_FF00FE68:\n"
 358 "    MOV     R3, R6\n"
 359 "    MOV     R2, R7\n"
 360 "    MOV     R1, R5\n"
 361 "    MOV     R0, R4\n"
 362 //"    BL      sub_FF024AF4 \n" // power button & startup, see sub_FF000364_my
 363 "    BL      sub_FF024AF0\n"
 364 "    BL      sub_FF02B598\n"
 365 "    LDR     R1, =0x5CE000\n"
 366 "    MOV     R0, #0\n"
 367 "    BL      sub_FF02BA08\n"
 368 "    BL      sub_FF02B7B0\n"
 369 "    MOV     R3, #0\n"
 370 "    STR     R3, [SP]\n"
 371 //"    LDR     R3, =0xFF00FD34 \n" 
 372 "    LDR     R3, =task_Startup_my \n" // -->
 373 "    MOV     R2, #0\n"
 374 "    MOV     R1, #0x19\n"
 375 "    LDR     R0, =0xFF00FED0\n"
 376 "    BL      sub_FF00EAF0\n"
 377 "    MOV     R0, #0\n"
 378 "    LDMFD   SP!, {R3-R7,PC}\n"
 379         );
 380 }
 381 
 382 
 383 //** task_Startup_my  @ 0xFF00FD34 
 384 
 385 void __attribute__((naked,noinline)) task_Startup_my(  ) { 
 386 asm volatile (
 387 "    STMFD   SP!, {R4,LR}\n"
 388 "    BL      sub_FF0065E8\n"
 389 //"    BL      sub_FF02D7E0 \n" // NULLSUB
 390 //"    BL      sub_FF02D874 \n" // don't start DISKBOOT.BIN again
 391 "    BL      sub_FF02DB88\n"
 392 "    BL      sub_FF02D9FC\n"
 393 "    BL      sub_FF02AD3C\n"
 394 "    BL      sub_FF02DB8C\n"
 395 //"    BL      sub_FF02496C \n" // PhySw
 396 "    BL      CreateTask_spytask \n" // added
 397 "    BL      taskcreatePhySw_my \n"  // we do this here rather than hook so we don't waste the original stack
 398 "    BL      sub_FF028504\n"
 399 "    BL      sub_FF02DBA4\n"
 400 "    BL      sub_FF0217BC\n"
 401 "    BL      sub_FF02250C\n"
 402 "    BL      sub_FF02D40C\n"
 403 "    BL      sub_FF022B64\n"
 404 "    BL      sub_FF0224A8\n"
 405 "    BL      sub_FF02E830\n"
 406 "    BL      sub_FF02246C\n"
 407 "    LDMFD   SP!, {R4,LR}\n"
 408 "    B       sub_FF006708\n"
 409         );
 410 }
 411 
 412 
 413 //** taskcreatePhySw_my  @ 0xFF02496C 
 414 
 415 void __attribute__((naked,noinline)) taskcreatePhySw_my(  ) { 
 416 asm volatile (
 417 "    STMFD   SP!, {R3-R5,LR}\n"
 418 "    LDR     R4, =0x1C3C\n"
 419 "    LDR     R0, [R4, #4]\n"
 420 "    CMP     R0, #0\n"
 421 "    BNE     loc_FF0249A0\n"
 422 "    MOV     R3, #0\n"
 423 "    STR     R3, [SP]\n"
 424 //"    LDR     R3, =0xFF024938 \n" 
 425 //"    MOV     R2, #0x800 \n" 
 426 "    LDR     R3, =mykbd_task \n" // task_PhySw
 427 "    MOV     R2, #0x2000 \n" // stack size for new task_PhySw so we don't have to do stack switch
 428 "    MOV     R1, #0x17\n"
 429 "    LDR     R0, =0xFF024BEC\n"
 430 "    BL      sub_FF02B808\n"
 431 "    STR     R0, [R4, #4]\n"
 432 "loc_FF0249A0:\n"
 433 "    BL      sub_FF0595A4\n"
 434 "    BL      sub_FF08FBB8\n"
 435 "    BL      sub_FF02640C\n"
 436 "    CMP     R0, #0\n"
 437 "    BNE     loc_FF0249C0\n"
 438 "    LDR     R1, =0x386C8\n"
 439 "    MOV     R0, #0\n"
 440 "    BL      sub_FF08FB28\n"
 441 "loc_FF0249C0:\n"
 442 "    LDMFD   SP!, {R3-R5,PC}\n"
 443         );
 444 }
 445 
 446 /*----------------------------------------------------------------------
 447         spytask
 448 -----------------------------------------------------------------------*/
 449 void spytask(long ua, long ub, long uc, long ud, long ue, long uf)
 450 {
 451     core_spytask();
 452 }
 453 
 454 /*----------------------------------------------------------------------
 455         CreateTask_spytask
 456 -----------------------------------------------------------------------*/
 457 void CreateTask_spytask() {
 458         _CreateTask("SpyTask", 0x19, 0x2000, spytask, 0);
 459 }
 460 
 461 /*----------------------------------------------------------------------
 462         init_file_modules_task
 463 -----------------------------------------------------------------------*/
 464 //** init_file_modules_task  @ 0xFF09CDF8 
 465 
 466 void __attribute__((naked,noinline)) init_file_modules_task(  ) { 
 467 asm volatile (
 468 "    STMFD   SP!, {R4-R6,LR}\n"
 469 "    BL      sub_FF092164\n"
 470 "    LDR     R5, =0x5006\n"
 471 "    MOVS    R4, R0\n"
 472 "    MOVNE   R1, #0\n"
 473 "    MOVNE   R0, R5\n"
 474 "    BLNE    sub_FF096768\n"
 475 "    BL      sub_FF092190\n"
 476 "    BL      core_spytask_can_start\n"      // CHDK: Set "it's-safe-to-start" flag for spytask
 477 "    CMP     R4, #0\n"
 478 "    LDMNEFD SP!, {R4-R6,PC}\n"
 479 "    MOV     R0, R5\n"
 480 "    LDMFD   SP!, {R4-R6,LR}\n"
 481 "    MOV     R1, #0\n"
 482 "    B       sub_FF096768\n"
 483         );
 484 }
 485 
 486 /*----------------------------------------------------------------------
 487         Jogdial
 488 */
 489 // Pointer to stack location where jogdial task records previous and current
 490 // jogdial positions
 491 short *jog_position;
 492 
 493 //** JogDial_task_my  @ 0xFF05927C 
 494 
 495 void __attribute__((naked,noinline)) JogDial_task_my(  ) { 
 496 asm volatile (
 497 "    STMFD   SP!, {R4-R11,LR}\n"
 498 "    SUB     SP, SP, #0x24\n"
 499 "    BL      sub_FF059610 \n" 
 500 "    LDR     R12, =0x2700\n"
 501 "    LDR     R6, =0xFF4538DC\n"
 502 "    MOV     R0, #0\n"
 503 // Save pointer for kbd.c routine - like sx40hs
 504 " ADD R10, SP, #0x10 \n"
 505 " LDR R9, =jog_position \n"
 506 " STR R10, [R9] \n"
 507 // -- 
 508 "    ADD     R10, SP, #8\n"
 509 "    ADD     R9, SP, #0x10\n"
 510 "loc_FF05929C:\n"
 511 "    ADD     R2, SP, #0x1C\n"
 512 "    MOV     R1, #0\n"
 513 "    ADD     R4, R2, R0, LSL #1\n"
 514 "    ADD     R3, SP, #0x18\n"
 515 "    STRH    R1, [R4]\n"
 516 "    ADD     R4, R3, R0, LSL #1\n"
 517 "    STRH    R1, [R4]\n"
 518 "    STR     R1, [R9, R0, LSL #2]\n"
 519 "    STR     R1, [R10, R0, LSL #2]\n"
 520 "    ADD     R0, R0, #1\n"
 521 "    CMP     R0, #2\n"
 522 "    BLT     loc_FF05929C\n"
 523 "loc_FF0592CC:\n"
 524 "    LDR     R0, =0x2700\n"
 525 "    MOV     R2, #0\n"
 526 "    LDR     R0, [R0, #8]\n"
 527 "    MOV     R1, SP\n"
 528 "    BL      sub_FF02AFD0\n"
 529 "    CMP     R0, #0\n"
 530 "    LDRNE   R1, =0x256\n"
 531 "    LDRNE   R0, =0xFF05952C\n"
 532 "    BLNE    sub_FF00EDC8\n"
 533 "    LDR     R0, [SP]\n"
 534 "    AND     R4, R0, #0xFF\n"
 535 "    AND     R0, R0, #0xFF00\n"
 536 "    CMP     R0, #0x100\n"
 537 "    BEQ     loc_FF05933C\n"
 538 "    CMP     R0, #0x200\n"
 539 "    BEQ     loc_FF059374\n"
 540 "    CMP     R0, #0x300\n"
 541 "    BEQ     loc_FF059574\n"
 542 "    CMP     R0, #0x400\n"
 543 "    BNE     loc_FF0592CC\n"
 544 "    CMP     R4, #0\n"
 545 "    LDRNE   R1, =0x2E1\n"
 546 "    LDRNE   R0, =0xFF05952C\n"
 547 "    BLNE    sub_FF00EDC8\n"
 548 "    RSB     R0, R4, R4, LSL #3\n"
 549 "    LDR     R0, [R6, R0, LSL #2]\n"
 550 "loc_FF059334:\n"
 551 "    BL      sub_FF0595F4 \n" 
 552 "    B       loc_FF0592CC\n"
 553 "loc_FF05933C:\n"
 554 //------------------  added code ---------------------
 555 "labelA:\n"
 556                 "LDR     R0, =jogdial_stopped\n"
 557                 "LDR     R0, [R0]\n"
 558                 "CMP     R0, #1\n"
 559                 "BNE     labelB\n"
 560                 "MOV     R0, #40\n"
 561                 "BL      _SleepTask\n" //sleep
 562                 "B       labelA\n"
 563 "labelB:\n"
 564 //------------------  original code ------------------
 565 "    LDR     R0, =0x2710\n"
 566 "    LDR     R0, [R0, R4, LSL #2]\n"
 567 "    BL      sub_FF02C1F4\n"
 568 "    LDR     R2, =0xFF0591C8\n"
 569 "    ORR     R3, R4, #0x200\n"
 570 "    ADD     R1, R2, #0\n"
 571 "    MOV     R0, #0x28\n"
 572 "    BL      sub_FF02C110\n"
 573 "    TST     R0, #1\n"
 574 "    CMPNE   R0, #0x15\n"
 575 "    STR     R0, [R10, R4, LSL #2]\n"
 576 "    BEQ     loc_FF0592CC\n"
 577 "    MOV     R1, #0x268\n"
 578 "    B       loc_FF059518\n"
 579 "loc_FF059374:\n"
 580 "    RSB     R5, R4, R4, LSL #3\n"
 581 "    LDR     R0, [R6, R5, LSL #2]\n"
 582 "    LDR     R1, =0xC0240000\n"
 583 "    ADD     R0, R1, R0, LSL #8\n"
 584 "    LDR     R0, [R0, #0x104]\n"
 585 "    MOV     R1, R0, ASR #0x10\n"
 586 "    ADD     R0, SP, #0x1C\n"
 587 "    ADD     R11, R0, R4, LSL #1\n"
 588 "    ADD     R0, SP, #0x18\n"
 589 "    ADD     R0, R0, R4, LSL #1\n"
 590 "    STRH    R1, [R11]\n"
 591 "    STR     R0, [SP, #0x20]\n"
 592 "    LDRSH   R3, [R0]\n"
 593 "    SUB     R2, R1, R3\n"
 594 "    CMP     R2, #0\n"
 595 "    BNE     loc_FF0593F8\n"
 596 "    LDR     R0, [R9, R4, LSL #2]\n"
 597 "    CMP     R0, #0\n"
 598 "    BEQ     loc_FF0594D4\n"
 599 "    LDR     R7, =0x2710\n"
 600 "    LDR     R0, [R7, R4, LSL #2]\n"
 601 "    BL      sub_FF02C1F4\n"
 602 "    LDR     R2, =0xFF0591D4\n"
 603 "    ORR     R3, R4, #0x300\n"
 604 "    ADD     R1, R2, #0\n"
 605 "    MOV     R0, #0x1F4\n"
 606 "    BL      sub_FF02C110\n"
 607 "    TST     R0, #1\n"
 608 "    CMPNE   R0, #0x15\n"
 609 "    STR     R0, [R7, R4, LSL #2]\n"
 610 "    BEQ     loc_FF0594D4\n"
 611 "    LDR     R1, =0x281\n"
 612 "    B       loc_FF0594CC\n"
 613 "loc_FF0593F8:\n"
 614 "    MOV     R0, R2\n"
 615 "    RSBLT   R0, R0, #0\n"
 616 "    MOVLE   R7, #0\n"
 617 "    MOVGT   R7, #1\n"
 618 "    CMP     R0, #0xFF\n"
 619 "    BLS     loc_FF059434\n"
 620 "    LDR     R0, =0x7FFF\n"
 621 "    CMP     R2, #0\n"
 622 "    SUBLE   R0, R0, R3\n"
 623 "    ADDLE   R0, R0, R1\n"
 624 "    SUBGT   R0, R0, R1\n"
 625 "    ADDGT   R0, R0, R3\n"
 626 "    MVN     R1, #0x8000\n"
 627 "    SUB     R0, R0, R1\n"
 628 "    EOR     R7, R7, #1\n"
 629 "loc_FF059434:\n"
 630 "    STR     R0, [SP, #4]\n"
 631 "    LDR     R0, [R9, R4, LSL #2]\n"
 632 "    CMP     R0, #0\n"
 633 "    ADDEQ   R0, R6, R5, LSL #2\n"
 634 "    LDREQ   R0, [R0, #8]\n"
 635 "    BEQ     loc_FF05946C\n"
 636 "    ADD     R8, R6, R5, LSL #2\n"
 637 "    ADD     R1, R8, R7, LSL #2\n"
 638 "    LDR     R1, [R1, #0x10]\n"
 639 "    CMP     R1, R0\n"
 640 "    BEQ     loc_FF059470\n"
 641 "    LDR     R0, [R8, #0xC]\n"
 642 "    BL      sub_FF0249C4\n"
 643 "    LDR     R0, [R8, #8]\n"
 644 "loc_FF05946C:\n"
 645 "    BL      sub_FF0249C4\n"
 646 "loc_FF059470:\n"
 647 "    ADD     R0, R6, R5, LSL #2\n"
 648 "    ADD     R7, R0, R7, LSL #2\n"
 649 "    LDR     R0, [R7, #0x10]\n"
 650 "    LDR     R1, [SP, #4]\n"
 651 "    BL      sub_FF0249D4\n"
 652 "    LDR     R0, [R7, #0x10]\n"
 653 "    LDR     R7, =0x2710\n"
 654 "    STR     R0, [R9, R4, LSL #2]\n"
 655 "    LDRH    R1, [R11]\n"
 656 "    LDR     R0, [SP, #0x20]\n"
 657 "    STRH    R1, [R0]\n"
 658 "    LDR     R0, [R7, R4, LSL #2]\n"
 659 "    BL      sub_FF02C1F4\n"
 660 "    LDR     R2, =0xFF0591D4\n"
 661 "    ORR     R3, R4, #0x300\n"
 662 "    ADD     R1, R2, #0\n"
 663 "    MOV     R0, #0x1F4\n"
 664 "    BL      sub_FF02C110\n"
 665 "    TST     R0, #1\n"
 666 "    CMPNE   R0, #0x15\n"
 667 "    STR     R0, [R7, R4, LSL #2]\n"
 668 "    BEQ     loc_FF0594D4\n"
 669 "    LDR     R1, =0x2C3\n"
 670 "loc_FF0594CC:\n"
 671 "    LDR     R0, =0xFF05952C\n"
 672 "    BL      sub_FF00EDC8\n"
 673 "loc_FF0594D4:\n"
 674 "    ADD     R0, R6, R5, LSL #2\n"
 675 "    LDR     R0, [R0, #0x18]\n"
 676 "    CMP     R0, #1\n"
 677 "    BNE     loc_FF05956C\n"
 678 "    LDR     R0, =0x2700\n"
 679 "    LDR     R0, [R0, #0xC]\n"
 680 "    CMP     R0, #0\n"
 681 "    BEQ     loc_FF05956C\n"
 682 "    LDR     R2, =0xFF0591C8\n"
 683 "    ORR     R3, R4, #0x400\n"
 684 "    ADD     R1, R2, #0\n"
 685 "    BL      sub_FF02C110\n"
 686 "    TST     R0, #1\n"
 687 "    CMPNE   R0, #0x15\n"
 688 "    STR     R0, [R10, R4, LSL #2]\n"
 689 "    BEQ     loc_FF0592CC\n"
 690 "    LDR     R1, =0x2CA\n"
 691 "loc_FF059518:\n"
 692 "    LDR     R0, =0xFF05952C\n"
 693 "    BL      sub_FF00EDC8\n"
 694 "    B       loc_FF0592CC\n"
 695 "loc_FF05956C:\n"
 696 "    LDR     R0, [R6, R5, LSL #2]\n"
 697 "    B       loc_FF059334\n"
 698 "loc_FF059574:\n"
 699 "    LDR     R0, [R9, R4, LSL #2]\n"
 700 "    CMP     R0, #0\n"
 701 "    MOVEQ   R1, #0x2D4\n"
 702 "    LDREQ   R0, =0xFF05952C\n"
 703 "    BLEQ    sub_FF00EDC8\n"
 704 "    RSB     R0, R4, R4, LSL #3\n"
 705 "    ADD     R0, R6, R0, LSL #2\n"
 706 "    LDR     R0, [R0, #0xC]\n"
 707 "    BL      sub_FF0249C4\n"
 708 "    MOV     R0, #0\n"
 709 "    STR     R0, [R9, R4, LSL #2]\n"
 710 "    B       loc_FF0592CC\n"
 711         );
 712 }
 713 /*-----------------------------------------------------------------------*/

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