Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- oh_look_it_accesses_the_disk_but_its_not_the_loader
- lea ($54D7A).l,a0
- bsr.w main_part
- rts
- main_part move.l a0,($7758).w ;disk_buffer
- bsr.w turn_off_dma_ints
- bsr.w drive_0_motor_on
- bsr.w move_to_track_0
- bsr.w read_track_0_side_1
- bsr.w motor_off_restore_ints
- bra.w check_disk_buffer
- turn_off_dma_ints move.w (_custom+intenar).l,($775C).w ;save_intena
- move.w (_custom+intreqr).l,($775E).w ;save_intreq
- move.w (_custom+dmaconr).l,($7760).w ;save_dmacon
- move.w (_custom+adkconr).l,($7762).w ;save_adkcon
- move.w #DMAF_DISK,(_custom+dmacon).l
- move.w #INTF_DSKBLK,(_custom+intreq).l
- 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
- move.w #(ADKF_FAST|ADKF_SETCLR),(_custom+adkcon).l
- ori.b #(CIAF_DSKSEL0|CIAF_DSKSEL1|CIAF_DSKSEL2|CIAF_DSKSEL3),(_ciab+ciaprb).l
- rts
- drive_0_motor_on bclr #CIAB_DSKMOTOR,(_ciab+ciaprb).l
- moveq #100,d0
- .loop bclr #CIAB_DSKSEL0,(_ciab+ciaprb).l
- dbra d0,.loop
- bsr.w wait_dskrdy
- rts
- wait_dskrdy move.w #3000,d6
- .busyloop dbra d6,.busyloop ;dont do this kids, use vbl or cia timer
- .wait btst #CIAB_DSKRDY,(_ciaa).l
- bne.b .wait
- rts
- move_to_track_0 btst #CIAB_DSKTRACK0,(_ciaa).l
- beq.b .done
- bset #CIAB_DSKDIREC,(_ciab+ciaprb).l
- bclr #CIAB_DSKSTEP,(_ciab+ciaprb).l
- bset #CIAB_DSKSTEP,(_ciab+ciaprb).l
- bsr.b wait_dskrdy
- bra.b move_to_track_0
- .done rts
- move_to_track btst #CIAB_DSKTRACK0,(_ciaa).l ;d2 = track to move to
- beq.b .at_0
- bsr.b move_to_track_0
- bra.b move_to_track
- .at_0 move.w #0,d2
- .loop tst.w d2
- beq.b .done
- bclr #CIAB_DSKDIREC,(_ciab+ciaprb).l
- nop
- nop
- nop
- bclr #CIAB_DSKSTEP,(_ciab+ciaprb).l
- nop
- nop
- nop
- bset #CIAB_DSKSTEP,(_ciab+ciaprb).l
- bsr.b wait_dskrdy
- subq.w #1,d2
- bra.b .loop
- .done rts
- read_track_0_side_1 bsr.b move_to_track
- .retry bclr #CIAB_DSKSIDE,(_ciab+ciaprb).l
- move.w #(DMAF_DISK|DMAF_MASTER|DMAF_SETCLR),(_custom+dmacon).l
- move.l (disk_buffer,pc),(_custom+dskpt).l
- clr.w (_custom+dsklen).l
- bsr.w wait_index_hole
- move.w #$4000,(_custom+dsklen).l
- move.w #$B778,(_custom+dsklen).l ;read $3778 = 14200 words
- move.w #$B778,(_custom+dsklen).l
- move.l #200000,d1
- .wait_for_int move.w (_custom+intreqr).l,d0
- subq.l #1,d1
- beq.b .retry
- btst #INTB_DSKBLK,d0
- beq.b .wait_for_int
- move.w #INTF_DSKBLK,(_custom+intreq).l
- rts
- wait_index_hole move.b (_ciab+ciaicr).l,d6
- .wait move.b (_ciab+ciaicr).l,d6
- btst #CIAICRB_FLG,d6
- beq.b .wait
- rts
- motor_off_restore_ints
- bset #CIAB_DSKMOTOR,(_ciab+ciaprb).l
- bset #CIAB_DSKSEL0,(_ciab+ciaprb).l
- bclr #CIAB_DSKSEL0,(_ciab+ciaprb).l
- move.w (save_intena,pc),d0
- bset #INTB_SETCLR,d0
- move.w d0,(_custom+intena).l
- move.w (save_dmacon,pc),d0
- bset #DMAB_SETCLR,d0
- move.w d0,(_custom+dmacon).l
- move.w (save_adkcon,pc),d0
- bset #ADKB_SETCLR,d0
- move.w d0,(_custom+adkcon).l
- rts
- check_disk_buffer movea.l (disk_buffer,pc),a0
- move.l #14200,d3 ;search up to 14200 words
- .next_word move.l (a0),d0
- addq.l #2,a0
- move.l #15,d2 ;look at buffer shifted 0-15 bits
- .next_bit move.l d0,d1
- swap d1
- cmpi.w #$4454,d1 ;sync word found?
- beq.b .found
- add.l d0,d0
- dbra d2,.next_bit
- dbra d3,.next_word
- bra.w DIE_PIRATE_SCUM
- .found moveq #0,d5 ;start counting how far away the next one is
- .next_word2 move.l (a0),d0
- addq.l #2,a0
- move.l #15,d2
- .next_bit2 move.l d0,d1
- swap d1
- cmpi.w #$4454,d1 ;sync word found?
- beq.b .found2
- add.l d0,d0
- dbra d2,.next_bit2
- addq.l #1,d5
- dbra d3,.next_word2
- bra.b DIE_PIRATE_SCUM
- .found2 subi.l #6700,d5 ;were these sync matches AT LEAST 6700 words apart?
- bmi.b DIE_PIRATE_SCUM ;if not, DIE PIRATE SCUM!!!
- clr.w d0
- rts
- DIE_PIRATE_SCUM move.w #0,d0
- divu.w #0,d0
- .forever bra.b .forever
- ;fiX Label expected
- rts
- copper_list dc.w $180
- lbW001EEE dc.w 0
- dc.w $182
- dc.w $444
- dc.w $184
- dc.w $70
- dc.w $186
- dc.w $A80
- dc.w $188
- dc.w $BBB
- dc.w $18A
- dc.w $AAA
- dc.w $18C
- dc.w $999
- dc.w $18E
- dc.w $888
- dc.w $190
- dc.w 0
Advertisement
Add Comment
Please, Sign In to add comment