Guest User

Leander original retail disk copy protection

a guest
May 24th, 2024
138
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.04 KB | None | 0 0
  1. oh_look_it_accesses_the_disk_but_its_not_the_loader
  2. lea ($54D7A).l,a0
  3. bsr.w main_part
  4. rts
  5.  
  6. main_part move.l a0,($7758).w ;disk_buffer
  7. bsr.w turn_off_dma_ints
  8. bsr.w drive_0_motor_on
  9. bsr.w move_to_track_0
  10. bsr.w read_track_0_side_1
  11. bsr.w motor_off_restore_ints
  12. bra.w check_disk_buffer
  13.  
  14. turn_off_dma_ints move.w (_custom+intenar).l,($775C).w ;save_intena
  15. move.w (_custom+intreqr).l,($775E).w ;save_intreq
  16. move.w (_custom+dmaconr).l,($7760).w ;save_dmacon
  17. move.w (_custom+adkconr).l,($7762).w ;save_adkcon
  18. move.w #DMAF_DISK,(_custom+dmacon).l
  19. move.w #INTF_DSKBLK,(_custom+intreq).l
  20. move.w #(ADKF_USE0V1|ADKF_USE1V2|ADKF_USE2V3|ADKF_USE3VN|ADKF_USE0P1|ADKF_USE1P2|ADKF_USE2P3|ADKF_USE3PN|ADKF_FAST|ADKF_MSBSYNC|ADKF_WORDSYNC|ADKF_UARTBRK|ADKF_MFMPREC|ADKF_PRECOMP0|ADKF_PRECOMP1),(_custom+adkcon).l
  21. move.w #(ADKF_FAST|ADKF_SETCLR),(_custom+adkcon).l
  22. ori.b #(CIAF_DSKSEL0|CIAF_DSKSEL1|CIAF_DSKSEL2|CIAF_DSKSEL3),(_ciab+ciaprb).l
  23. rts
  24.  
  25. drive_0_motor_on bclr #CIAB_DSKMOTOR,(_ciab+ciaprb).l
  26. moveq #100,d0
  27. .loop bclr #CIAB_DSKSEL0,(_ciab+ciaprb).l
  28. dbra d0,.loop
  29. bsr.w wait_dskrdy
  30. rts
  31.  
  32. wait_dskrdy move.w #3000,d6
  33. .busyloop dbra d6,.busyloop ;dont do this kids, use vbl or cia timer
  34. .wait btst #CIAB_DSKRDY,(_ciaa).l
  35. bne.b .wait
  36. rts
  37.  
  38. move_to_track_0 btst #CIAB_DSKTRACK0,(_ciaa).l
  39. beq.b .done
  40. bset #CIAB_DSKDIREC,(_ciab+ciaprb).l
  41. bclr #CIAB_DSKSTEP,(_ciab+ciaprb).l
  42. bset #CIAB_DSKSTEP,(_ciab+ciaprb).l
  43. bsr.b wait_dskrdy
  44. bra.b move_to_track_0
  45.  
  46. .done rts
  47.  
  48. move_to_track btst #CIAB_DSKTRACK0,(_ciaa).l ;d2 = track to move to
  49. beq.b .at_0
  50. bsr.b move_to_track_0
  51. bra.b move_to_track
  52.  
  53. .at_0 move.w #0,d2
  54. .loop tst.w d2
  55. beq.b .done
  56. bclr #CIAB_DSKDIREC,(_ciab+ciaprb).l
  57. nop
  58. nop
  59. nop
  60. bclr #CIAB_DSKSTEP,(_ciab+ciaprb).l
  61. nop
  62. nop
  63. nop
  64. bset #CIAB_DSKSTEP,(_ciab+ciaprb).l
  65. bsr.b wait_dskrdy
  66. subq.w #1,d2
  67. bra.b .loop
  68.  
  69. .done rts
  70.  
  71. read_track_0_side_1 bsr.b move_to_track
  72. .retry bclr #CIAB_DSKSIDE,(_ciab+ciaprb).l
  73. move.w #(DMAF_DISK|DMAF_MASTER|DMAF_SETCLR),(_custom+dmacon).l
  74. move.l (disk_buffer,pc),(_custom+dskpt).l
  75. clr.w (_custom+dsklen).l
  76. bsr.w wait_index_hole
  77. move.w #$4000,(_custom+dsklen).l
  78. move.w #$B778,(_custom+dsklen).l ;read $3778 = 14200 words
  79. move.w #$B778,(_custom+dsklen).l
  80. move.l #200000,d1
  81. .wait_for_int move.w (_custom+intreqr).l,d0
  82. subq.l #1,d1
  83. beq.b .retry
  84. btst #INTB_DSKBLK,d0
  85. beq.b .wait_for_int
  86. move.w #INTF_DSKBLK,(_custom+intreq).l
  87. rts
  88.  
  89. wait_index_hole move.b (_ciab+ciaicr).l,d6
  90. .wait move.b (_ciab+ciaicr).l,d6
  91. btst #CIAICRB_FLG,d6
  92. beq.b .wait
  93. rts
  94.  
  95. motor_off_restore_ints
  96. bset #CIAB_DSKMOTOR,(_ciab+ciaprb).l
  97. bset #CIAB_DSKSEL0,(_ciab+ciaprb).l
  98. bclr #CIAB_DSKSEL0,(_ciab+ciaprb).l
  99. move.w (save_intena,pc),d0
  100. bset #INTB_SETCLR,d0
  101. move.w d0,(_custom+intena).l
  102. move.w (save_dmacon,pc),d0
  103. bset #DMAB_SETCLR,d0
  104. move.w d0,(_custom+dmacon).l
  105. move.w (save_adkcon,pc),d0
  106. bset #ADKB_SETCLR,d0
  107. move.w d0,(_custom+adkcon).l
  108. rts
  109.  
  110. check_disk_buffer movea.l (disk_buffer,pc),a0
  111. move.l #14200,d3 ;search up to 14200 words
  112. .next_word move.l (a0),d0
  113. addq.l #2,a0
  114. move.l #15,d2 ;look at buffer shifted 0-15 bits
  115. .next_bit move.l d0,d1
  116. swap d1
  117. cmpi.w #$4454,d1 ;sync word found?
  118. beq.b .found
  119. add.l d0,d0
  120. dbra d2,.next_bit
  121. dbra d3,.next_word
  122. bra.w DIE_PIRATE_SCUM
  123.  
  124. .found moveq #0,d5 ;start counting how far away the next one is
  125. .next_word2 move.l (a0),d0
  126. addq.l #2,a0
  127. move.l #15,d2
  128. .next_bit2 move.l d0,d1
  129. swap d1
  130. cmpi.w #$4454,d1 ;sync word found?
  131. beq.b .found2
  132. add.l d0,d0
  133. dbra d2,.next_bit2
  134. addq.l #1,d5
  135. dbra d3,.next_word2
  136. bra.b DIE_PIRATE_SCUM
  137.  
  138. .found2 subi.l #6700,d5 ;were these sync matches AT LEAST 6700 words apart?
  139. bmi.b DIE_PIRATE_SCUM ;if not, DIE PIRATE SCUM!!!
  140. clr.w d0
  141. rts
  142.  
  143. DIE_PIRATE_SCUM move.w #0,d0
  144. divu.w #0,d0
  145. .forever bra.b .forever
  146.  
  147. ;fiX Label expected
  148. rts
  149.  
  150. copper_list dc.w $180
  151. lbW001EEE dc.w 0
  152. dc.w $182
  153. dc.w $444
  154. dc.w $184
  155. dc.w $70
  156. dc.w $186
  157. dc.w $A80
  158. dc.w $188
  159. dc.w $BBB
  160. dc.w $18A
  161. dc.w $AAA
  162. dc.w $18C
  163. dc.w $999
  164. dc.w $18E
  165. dc.w $888
  166. dc.w $190
  167. dc.w 0
  168.  
Advertisement
Add Comment
Please, Sign In to add comment