home *** CD-ROM | disk | FTP | other *** search
- ùúùúÿüoÿüoÿüoÿüoÿüoÿüoÿüoÿüoÿüo
- incdir sys:include/
- include hardware/custom.i
-
- ReReads = 4
- ReSeeks = 2
-
- CIAAOffset = $F01
- ICR = $1C01
- CRA = $1D01
- TALO = $1301
- TAHI = $1401
-
- move.w intenar+$dff000,-(sp)
- move.w #$7fff,intena+$dff000
-
- lea dir,a0
- lea file,a1
- lea $c0000,a2
- move.l #$10000,d0
- bsr.w loadfile
-
- or.w #$8000,(sp)
- move.w (sp)+,intena+$dff000
- rts
-
- dir dc.b 4,"DEVS"
- file dc.b 10,"ALF.DEVICE"
-
-
- * ErrorCodes:
- * D0 = 0 means error, else D0 = destination, D1 = size
- * D1 = 0 : file error
- * D1 = -1 : Error in header checksum
- * D1 = -2 : Error in block checksum
- * D1 = -3 : Track not found error
- * D1 = -4 : Sector not found error
- * D1 = -5 : Sync-word missing error
-
- LoadFile: movem.l a5/a6,-(SP)
- lea $bfd100,a5
- lea $dff000+dsklen,a6
- bsr.w startmtr
- move.w #$7f00,adkcon-dsklen(a6)
- move.w #$8500,adkcon-dsklen(a6)
- move.w #$4489,dsksync-dsklen(a6)
- lea root(PC),A4
- movem.l d0/a0/a1/a2,(filesize-root)(a4)
- tst.b (rootvalid-root)(a4)
- bne.b rootok
-
- ReadRoot: clr.b (trackvalid-root)(a4)
- move.l #880,D0
- move.l (A4),A0
- bsr.w loadsector
- tst.l D0
- bmi.w mainerror
- st (rootvalid-root)(a4)
-
- move.l (A4),A0
- move.l drawer(PC),A1
- tst.l (drawer-root)(A4)
- beq.b .skipdrawer
- bsr.w seekhash
- tst.l D0
- beq.w mainerror
- move.l buffer(PC),A0
- move.l drawer(PC),A3
- bsr.w seekheader
- tst.l D0
- beq.w mainerror
- .SkipDrawer: move.l filename(PC),A1
- bsr.w seekhash
- tst.l D0
- beq.w mainerror
- bra.b seekfile
-
- RootOk: move.l (A4),A0
- move.l drawer(PC),A1
- tst.l (drawer-root)(A4)
- beq.b .skipdrawer
- bsr.w seekhash
- tst.l D0
- beq.b readroot
- move.l buffer(PC),A0
- move.l drawer(PC),A3
- bsr.b seekheader
- tst.l D0
- beq.b readroot
- .SkipDrawer: move.l filename(PC),A1
- bsr.w seekhash
- tst.l D0
- beq.b readroot
-
- SeekFile: move.l buffer(PC),A0
- move.l filename(PC),A3
- bsr.b seekheader
- tst.l D0
- beq.w mainerror
-
- move.l 324(A0),D0
- cmp.l filesize(PC),D0
- blo.b sizeok
- moveq #1,D0
- bra.w mainerror
- SizeOk: move.l D0,(filesize-root)(A4)
- move.l 16(A0),D0
- beq.w mainerror
- move.l destination(PC),A3
-
- LoadBlocks: bsr.w loadsector
- tst.l D0
- bmi.w mainerror
- move.w 14(A0),D0
- subq.w #1,D0
- lea 24(A0),A1
- CopyBlock: move.b (A1)+,(A3)+
- dbf D0,copyblock
- move.l 16(A0),D0
- bne.b loadblocks
- move.l destination(PC),D0
- move.l filesize(PC),D1
- bsr.w stopmtr
- movem.l (SP)+,a5/a6
- rts
-
- SeekHeader: bsr.w loadsector * filename in A3
- tst.l D0 * sectorbuffer in A0
- bmi.b mainerror
- lea 432(A0),A1
- move.l A3,A2
- move.b (A1)+,D7
- cmp.b (A2)+,D7
- beq.b cmpname
- NotTheHeader: move.l 496(A0),D0
- bne.b seekheader
- rts
- CmpName: move.b (A1)+,D6
- cmp.b #"a",D6
- blo.b caseok
- cmp.b #"z",D6
- bhi.b caseok
- sub.b #32,D6
- CaseOk: cmp.b (A2)+,D6
- bne.b nottheheader
- subq.b #1,D7
- bne.b cmpname
- moveq #1,D0
- rts
-
- SeekHash: moveq #0,D1 * filename in A1
- moveq #0,D2 * sectorbuffer in A0
- move.b (A1)+,D1
- move.w D1,D7
- subq.w #1,D7
- CalcHash: mulu #13,D1
- move.b (A1)+,D2
- add.w D2,D1
- and.w #$7FF,D1
- dbf D7,calchash
- divu #72,D1
- swap D1
- add.w D1,D1
- add.w D1,D1
- move.l 24(A0,D1.w),D0
- rts
-
- MainError: move.l D0,D1
- moveq #0,D0
- bsr.w stopmtr
- movem.l (SP)+,a5/a6
- rts
-
- Root: dc.l $80600
- Buffer: dc.l $80800
- TrackBuffer: dc.l $80A00
- FileSize: dc.l $0
- Drawer: dc.l $0
- FileName: dc.l $0
- Destination: dc.l $0
- Unit: dc.w 3
- CurrentTrack: dc.w -1
- TrackValid: dc.b 0
- RootValid: dc.b 0
- ReReadCount: dc.w rereads
- ReSeekCount: dc.w reseeks
-
- LoadSector: movem.l D0/A0/A3,-(SP)
- move.w #rereads,(rereadcount-root)(a4)
- move.w #reseeks,(reseekcount-root)(a4)
- Retry: divu #11,D0
- tst.b (trackvalid-root)(a0)
- beq.b reread
- cmp.w currenttrack(pc),D0
- beq.b sametrack
- ReRead: bsr.w loadtrack
- SameTrack: swap D0
- move.l #$55555555,D2
- move.l trackbuffer(PC),A1
- lea $3200(A1),A2
- moveq #10,D5
- SeekSync: cmp.l A2,A1
- bhi.b nosync
- cmp.w #$4489,(A1)+
- bne.b seeksync
- cmp.w #$4489,(A1)+
- beq.b dualsync
- subq.l #2,A1
- DualSync: move.l 40(A1),D3
- and.l D2,D3
- add.l D3,D3
- move.l 44(A1),D4
- and.l D2,D4
- or.l D3,D4
- moveq #9,D7
- moveq #0,D6
- move.l A1,A3
- CalcHeaderSum: move.l (A3)+,D3
- eor.l D3,D6
- dbf D7,calcheadersum
- and.l D2,D6
- cmp.l D4,D6
- beq.b headersumok
- moveq #-1,D0
- bra.w testretry
- NoSync: moveq #-5,D0
- bra.w testretry
-
- HeaderSumOk: move.b 1(A1),D3
- and.b D2,D3
- add.b D3,D3
- move.b 5(A1),D4
- and.b D2,D4
- or.b D3,D4
- cmp.b (currenttrack+1)(PC),D4
- beq.b trackok
- moveq #-3,D0
- bra.b testretry
-
- TrackOk: move.b 2(A1),D3
- and.b D2,D3
- add.b D3,D3
- move.b 6(A1),D4
- and.b D2,D4
- or.b D3,D4
- cmp.b D0,D4
- beq.b foundsector
- lea 1080(A1),A1
- dbf D5,seeksync
- moveq #-4,D0
- bra.b testretry
-
- FoundSector: lea 48(A1),A1
- move.l (A1)+,D3
- and.l D2,D3
- add.l D3,D3
- move.l (A1)+,D4
- and.l D2,D4
- or.l D3,D4
- move.w #255,D7
- moveq #0,D6
- move.l A1,A3
- CalcBlockSum: move.l (A3)+,D3
- eor.l D3,D6
- dbf D7,calcblocksum
- and.l D2,D6
- cmp.l D4,D6
- beq.b blocksumok
- moveq #-2,D0
- bra.b testretry
-
- BlockSumOk: moveq #127,D7
- lea 512(A1),A3
- DecodeSector: move.l (A1)+,D3
- and.l D2,D3
- add.l D3,D3
- move.l (A3)+,D4
- and.l D2,D4
- or.l D3,D4
- move.l D4,(A0)+
- dbf D7,decodesector
- moveq #0,D0
- ExitSectorLoad: movem.l (SP)+,D7/A0/A3
- rts
-
- TestRetry: subq.w #1,(rereadcount-root)(a4)
- bmi.b testreseek
- move.l (sp),D0
- bra.w retry
- TestReSeek: subq.w #1,(reseekcount-root)(a4)
- bmi.b exitsectorload
- move.l (sp),D0
- move.w #rereads,(rereadcount-root)(a4)
- move.w #-1,(currenttrack-root)(a4)
- bra.w retry
-
- LoadTrack: move.w currenttrack(PC),D1
- bge.b trackisknown
- bset #1,(A5)
- clr.w D1
- Cyl0Search: btst #4,ciaaoffset(A5)
- beq.b gotcyl0
- bsr.w step
- bra.b cyl0search
- GotCyl0: bsr.w delay
- bsr.w delay
- TrackIsKnown: move.w D0,(currenttrack-root)(A4)
- st (trackvalid-root)(a4)
- lsr.w #1,D0
- bcc.b gotoside0
- bclr #2,(A5) * goto side 1
- bra.b sideok
- GotoSide0: bset #2,(A5) * goto side 0
- SideOk: lsr.w #1,D1
- sub.w D1,D0
- beq.b readtrack
- bgt.b inwards
- neg.w D0
- bset #1,(A5) * step out
- bra.b directionok
- Inwards: bclr #1,(A5) * step in
- DirectionOk: subq.w #1,D0
- SeekTrack: bsr.b step
- dbf D0,seektrack
- bsr.b delay
-
- ReadTrack: bsr.b delay
- move.w #$4000,(a6)
- TestReady: btst #5,ciaaoffset(A5)
- bne.b testready
- move.l trackbuffer(pc),dskpt-dsklen(a6)
- move.w #$9900,(a6) load 6400 words
- move.w #$9900,(a6)
- WaitForBlock: btst #1,(intreqr+1)-dsklen(a6)
- beq.b waitforblock
- move.w #$2,intreq-dsklen(a6)
- move.w #$4000,(a6)
- rts
-
- StartMtr: move.w unit(pc),d4
- bset d4,(A5)
- nop
- bclr #7,(A5)
- nop
- bclr d4,(A5)
- rts
-
- StopMtr: move.w unit(pc),d4
- bset #7,(a5)
- bset d4,(A5)
- nop
- bclr d4,(A5)
- nop
- bset d4,(A5)
- rts
-
- Step: bclr #0,(A5)
- nop
- bset #0,(A5)
- Delay: move.b #$01,icr(A5)
- move.b #$08,cra(A5)
- move.b #$80,talo(A5)
- move.b #$08,tahi(A5)
- WaitForDelay: btst #0,icr(A5)
- beq.b waitfordelay
- rts
-
-