Advertisement
TheBlad768

CheckSumCheck

Jun 8th, 2018
522
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ; ---------------------------------------------------------------------------
  2. ; CheckSum Check by Markey Jester (Fast)
  3. ; ---------------------------------------------------------------------------
  4.  
  5. ; =============== S U B R O U T I N E =======================================
  6.  
  7. CheckSumCheck:
  8.         movea.w #$200,a0            ; prepare start address
  9.         move.l  ($1A4).w,d7         ; load size
  10.         sub.l   a0,d7               ; minus start address
  11.         move.b  d7,d5               ; copy end nybble
  12.         andi.w  #$F,d5              ; get only the remaining nybble
  13.         lsr.l   #4,d7                   ; divide the size by 20
  14.         move.w  d7,d6               ; load lower word size
  15.         swap    d7                  ; get upper word size
  16.         moveq   #0,d0               ; clear d0
  17. -   rept 8
  18.         add.w   (a0)+,d0                ; modular checksum (8 words)
  19.     endm
  20.         dbf d6,-                        ; repeat until all main block sections are done
  21.         dbf d7,-
  22.         subq.w  #1,d5               ; decrease remaining nybble for dbf
  23.         bpl.s   +                   ; if there is no remaining nybble, branch
  24. -       add.w   (a0)+,d0                ; add remaining words
  25.         dbf d5,-                        ; repeat until the remaining words are done
  26. +       cmp.w   ($18E).w,d0         ; does the checksum match?
  27.         bne.s   CheckSumError
  28. ; ---------------------------------------------------------------------------
  29. ; CheckSum Check from Side Pocket (Fast)
  30. ; ---------------------------------------------------------------------------
  31.  
  32. ; =============== S U B R O U T I N E =======================================
  33.  
  34. CheckSumCheck:
  35.         movea.w #$200,a0
  36.         move.l  ($1A4).w,d7
  37.         sub.l   a0,d7
  38.         lsr.l   #6,d7
  39.         moveq   #0,d0
  40. -   rept 32
  41.         add.w   (a0)+,d0
  42.     endm
  43.         dbf d7,-
  44.         cmp.w   ($18E).w,d0
  45.         bne.s   CheckSumError
  46. ; ---------------------------------------------------------------------------
  47. ; CheckSum Check from Sonic 2 (Slow)
  48. ; ---------------------------------------------------------------------------
  49.  
  50. ; =============== S U B R O U T I N E =======================================
  51.  
  52. CheckSumCheck:
  53.         movea.l #$200,a6
  54.         move.l  ($1A4).w,d6
  55.         moveq   #0,d7
  56. -       add.w   (a6)+,d7
  57.         cmp.l   a6,d6
  58.         bhs.s   -
  59.         cmp.w   ($18E).w,d7
  60.         bne.s   CheckSumError
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement