Advertisement
Guest User

Untitled

a guest
Oct 17th, 2013
397
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. 08074624
  2.     push {r4-r7,lr}
  3.     mov r7, r10
  4.     mov r6, r9
  5.     mov r5, r8
  6.     push {r5-r7}
  7.     add sp, -0x8
  8.     lsl r0, r0, 0x18
  9.    
  10.     ; r0 = 0 means checksum the save?
  11.     cmp r0, 0x0
  12.     bne _0x08074654
  13.    
  14.     ; pointer to SRAM
  15.     ldr r2, =0x08754bc8
  16.     ldr r0, =0x03000c1e
  17.     ; aligning 0x02038000 to save data (this is 0x02038000 + saveID*0x1220 + 0x80)
  18.     mov r1, 0x0
  19.     ldrh r1, [r0, r1]
  20.     lsl r0, r1, 0x3
  21.     add r0, r0, r1
  22.     lsl r0, r0, 0x4
  23.     add r0, r0, r1
  24.     lsl r0, r0, 0x5
  25.     add r0, 0x80
  26.     b _0x0807466a
  27.    
  28.     ; r4 has save pointer
  29.     ldr r1, [r2, 0x0]
  30.     add r4, r1, r0
  31.    
  32.     mov r1, r4
  33.     mov r2, 0x0
  34.     ldr r6, [r4, 0x10]
  35.     mov r12, r6
  36.     ldr r7, =0x08411410
  37.     ldrb r0, [r4, 0x0]
  38.     mov r9, r0
  39.     ldr r6, =0x08411420
  40.     mov r8, r6
  41.     mov r6, r4
  42.     add r6, 0x4f
  43.     ldr r0, =0x08411430
  44.     mov r10, r0
  45.  
  46.     ; ?
  47.     mov r0, 0x94
  48.     lsl r0, r0, 0x2
  49.     add r0, r4, r0
  50.     str r0, [sp, 0x4]
  51.    
  52.     ; r3 = loop counter
  53.     ; r1 is pointed at the start of save data
  54.     ; r2 is initialized at 0
  55.     mov r3, 0x90
  56. _0x08074692:
  57.     ; add the 0x91 words
  58.     ldmia r1!, {r0}
  59.     add r2, r2, r0
  60.     ldmia r1!, {r0}
  61.     add r2, r2, r0
  62.     ldmia r1!, {r0}
  63.     add r2, r2, r0
  64.     ldmia r1!, {r0}
  65.     add r2, r2, r0
  66.     ldmia r1!, {r0}
  67.     add r2, r2, r0
  68.     ldmia r1!, {r0}
  69.     add r2, r2, r0
  70.     ldmia r1!, {r0}
  71.     add r2, r2, r0
  72.     ldmia r1!, {r0}
  73.     add r2, r2, r0
  74.     sub r3, 0x1
  75.     cmp r3, 0x0
  76.     bge _0x08074692
  77.    
  78.     mov r5, 0x0
  79.    
  80.     ; check if the sum = the value in r12 (0x10 relative to save pointer)
  81.     cmp r12, r2
  82.     bne _0x080746c6
  83.    
  84.     ; second checksum
  85.     ldr r0, [r4, 0x14]
  86.     mvn r0, r0
  87.     cmp r2, r0
  88.     beq _0x08046c8
  89.    
  90. _0x080746c6:
  91.     mov r5, 0x1
  92.    
  93. _0x080746c8:
  94.     mov r2, 0x0
  95.     mov r3, 0x0
  96.     ldrb r0, [r7, 0x0]
  97.     cmp r0, r9
  98.     beq _0x080746f0
  99.    
  100.     mov r2, 0x1
  101.     b _0x08074706
  102.    
  103. _0x080746f0:
  104.     add r3, 0x1
  105.     cmp r3, 0xf
  106.     bgt _0x08074706
  107.    
  108.     ; check if two strings match
  109.     add r0, r3, r7
  110.     add r1, r4, r3
  111.     ldrb r0, [r0, 0x0]
  112.     ldrb r1, [r1, 0x0]
  113.     cmp r0, r1
  114.     beq _0x080746f0
  115.    
  116.     mov r0, 0x1
  117.     orr r2, r0
  118.    
  119. _0x08074706:
  120.     mov r3, 0x0
  121.     mov r1, r8
  122.     ldrb r0, [r1, 0x0]
  123.     ldrb r1, [r6, 0x0]
  124.     b _0x08074720
  125.    
  126. _0x0874710:
  127.     add r3, 0x1
  128.     cmp r3, 0xf
  129.     bgt _0x08074728
  130.    
  131.     ; check if two strings match
  132.     mov r1, r8
  133.     add r0, r3, r1
  134.     add r1, r6, r3
  135.     ldrb r0, [r0, 0x0]
  136.     ldrb r1, [r1, 0x0]
  137.    
  138. _0x08074720:
  139.     cmp r0, r1
  140.     beq _0x08074710
  141.    
  142.     mov r0, 0x2
  143.     orr r2, r0
  144.    
  145. _0x08074728:
  146.     mov r3, 0x0
  147.     mov r6, r10
  148.     ldrb r0, [r6, 0x0]
  149.     ldr r1, [sp, 0x4]
  150.     b _0x08074746
  151.    
  152. _0x08074732:
  153.     add r3, 0x1
  154.     cmp r3, 0xf
  155.     bgt _0x08074750
  156.    
  157.     ; check if two strings match
  158.     mov r6, r10
  159.     add r0, r3, r6
  160.     mov r6, 0x94
  161.     lsl r6, r6, 0x2
  162.     add r1, r4, r6
  163.     add r1, r1, r3
  164.     ldrb r0, [r0, 0x0]
  165.    
  166. _0x08074746:
  167.     ldrb r1, [r1, 0x0]
  168.     cmp r0, r1
  169.     beq _0x08074732
  170.     mov r0, 0x4
  171.     orr r2, r0
  172.    
  173. _0x08074750:
  174.     ; checks if the 3 strings are intact
  175.     cmp r2, 0x0
  176.     beq _0x08074760
  177.    
  178.     cmp r2, 0x7
  179.     bne _0x0807475c
  180.    
  181.     ; if all strings are damaged
  182.     mov r0, 0x2
  183.     b _0x0807475e
  184.    
  185. _0x0807475c:
  186.     mov r0, 0x1
  187.    
  188. _0x0807475e:
  189.     orr r5, r0
  190. _0x08074760:
  191.     cmp r5, 0x1
  192.     ble _0x08074776
  193.    
  194.     ; code is not executed if all strings are damaged
  195.     ; otherwise it is executed
  196.     ldr r1, =0xffff
  197.     mov r3, 0x91
  198.     lsl r3, r3, 0x5
  199.     mov r0, 0x10
  200.     str r0, [sp, 0x0]
  201.     mov r0, 0x3
  202.     mov r2, r4
  203.     bl 0x080032b4
  204.    
  205. _0x08074776:
  206.     ; r5 = 1 (corrupted data)
  207.     ; if the original checksum is messed up
  208.     ; if the words at 0x10 and 0x14 are not negs of each other
  209.     ; r5 = 2 if all the strings are messed up
  210.     ; r5 = 1 + 2 if both occur
  211.     ; 2 and 3 cause data to not be loaded
  212.     mov r0, r5
  213.     add sp, 0x8
  214.     pop {r3-r5}
  215.     mov r8, r3
  216.     mov r9, r4
  217.     mov r10, r5
  218.     pop {r4-r7}
  219.     pop {r1}
  220.     bx r1
Advertisement
Advertisement
Advertisement
RAW Paste Data Copied
Advertisement