home *** CD-ROM | disk | FTP | other *** search
/ Amiga ISO Collection / AmigaUtilCD2.iso / Misc / GXY-INF.LHA / infos / bigm-miniload.s < prev    next >
Encoding:
Text File  |  1996-03-09  |  5.1 KB  |  295 lines

  1.  
  2. * Bigmama's DMA-AmigaDos fileloader
  3. * And it's great...
  4.  
  5.  
  6.         incdir    SYS:include/
  7.         include    hardware/custom.i
  8.  
  9.  
  10. DriveStatus    = $F01
  11. ICR        = $C00
  12. CRA        = $D00
  13. TALO        = $300
  14. TAHI        = $400
  15.  
  16.  
  17. Start:        dc.l    $444F5300
  18.         dc.l    0
  19.         dc.l    $54524821
  20.  
  21.         move.l    #$3400+8000,D0
  22.         moveq    #$3,D1
  23.         jsr    -198(A6)
  24.         lea    root(PC),A4
  25.         move.l    D0,(A4)+
  26.         beq.w    mainerror
  27.         add.l    #$200,D0
  28.         move.l    D0,(A4)+
  29.         add.l    #$3200,D0
  30.         move.l    D0,(A4)
  31.         subq.l    #8,A4
  32.         lea    $DFF000,A6
  33.         move.w    #$7FFF,D0
  34.         move.w    D0,intena(A6)
  35.         move.w    D0,intreq(A6)
  36.         move.w    D0,dmacon(A6)
  37.         move.w    D0,adkcon(A6)
  38.         moveq    #13,D0
  39.         moveq    #0,D1
  40.         lea    $BFD100,A5
  41.         move.w    #$8210,dmacon(A6)
  42.         move.w    #$A58,color(A6)
  43.  
  44.         lea    spr(A6),A0
  45. KillSprites:    move.l    D1,(A0)+
  46.         dbf    D0,killsprites
  47.  
  48. StartMtr:    bset    #3,(A5)
  49.         nop
  50.         bclr    #7,(A5)
  51.         nop
  52.         bclr    #3,(A5)
  53.  
  54.         move.l    #880,D0
  55.         move.l    (A4),A0
  56.         bsr.w    loadsector
  57.         tst.l    D0
  58.         bmi.b    mainerror
  59.  
  60.         moveq    #0,D1
  61.         moveq    #0,D2
  62.         lea    filename(PC),A1
  63.         move.b    (A1)+,D1
  64.         move.w    D1,D7
  65.         subq.w    #1,D7
  66. CalcHash:    mulu    #13,D1
  67.         move.b    (A1)+,D2
  68.         add.w    D2,D1
  69.         and.w    #$7FF,D1
  70.         dbf    D7,calchash
  71.         divu    #72,D1
  72.         swap    D1
  73.         add.w    D1,D1
  74.         add.w    D1,D1
  75.         move.l    (A4),A0
  76.         move.l    24(A0,D1.w),D0
  77.         bne.b    seekfile
  78.  
  79. MainError:    or.b    #$88,(A5)
  80.         nop
  81.         bclr    #3,(A5)
  82.         nop
  83.         bset    #3,(A5)
  84. ErrorLoop:    move.w    vhposr(A6),color(A6)
  85.         bra.b    errorloop
  86.  
  87. SeekFile:    bsr.w    loadsector
  88.         tst.l    D0
  89.         bmi.b    mainerror
  90.  
  91.         lea    432(A0),A1
  92.         lea    filename(PC),A2
  93.         move.b    (A1)+,D7
  94.         cmp.b    (A2)+,D7
  95.         beq.b    cmpname
  96. NotTheFile:    move.l    496(A0),D0
  97.         bne.b    seekfile
  98.         bra.b    mainerror
  99.         
  100. CmpName:    move.b    (A1)+,D6
  101.         cmp.b    #"a",D6
  102.         blo.b    caseok
  103.         cmp.b    #"z",D6
  104.         bhi.b    caseok
  105.         sub.b    #32,D6
  106. CaseOk:        cmp.b    (A2)+,D6
  107.         bne.b    notthefile
  108.         subq.b    #1,D7
  109.         bne.b    cmpname
  110.  
  111.         move.l    destination(PC),A3
  112.         move.l    16(A0),D0
  113.         beq.b    mainerror
  114.  
  115. LoadBlocks:    bsr.w    loadsector
  116.         tst.l    D0
  117.         bmi.b    mainerror
  118.         move.w    14(A0),D0
  119.         subq.b    #1,D0
  120.         lea    24(A0),A1
  121. Copy:        move.b    (A1)+,(A3)+
  122.         dbf    D0,copy
  123.         move.l    16(A0),D0
  124.         bne.b    loadblocks
  125.         move.l    destination(PC),A0
  126.         jmp    $20(A0)
  127.  
  128.         dc.b    "  This loader was made by Bigmama of Trash in 1992 "
  129.         dc.b    "and don't you steal it, or ...  Anyway, call our BBS "
  130.         dc.b    "on : -» Metal Connextion «-   +45 74435949      "
  131.  
  132. Root:        dc.l    $0
  133. TrackBuffer:    dc.l    $0
  134. Destination:    dc.l    $0
  135. CurrentTrack:    dc.w    -1
  136.  
  137. LoadSector:    movem.l    A0/A3,-(SP)
  138.         divu    #11,D0
  139.         cmp.w    currenttrack(PC),D0
  140.         beq.b    sametrack
  141.         bsr.w    loadtrack
  142. SameTrack:    swap    D0
  143.         move.l    #$55555555,D2
  144.         move.l    trackbuffer(PC),A1
  145.         lea    $3200(A1),A2
  146.         moveq    #10,D5
  147. SeekSync:    cmp.l    A2,A1
  148.         bhi.w    errorexit
  149.         cmp.w    #$4489,(A1)+
  150.         bne.b    seeksync
  151.         cmp.w    #$4489,(A1)+
  152.         beq.b    dualsync
  153.         subq.l    #2,A1
  154. DualSync:    move.l    40(A1),D3
  155.         and.l    D2,D3
  156.         add.l    D3,D3
  157.         move.l    44(A1),D4
  158.         and.l    D2,D4
  159.         or.l    D3,D4
  160.         moveq    #9,D7
  161.         moveq    #0,D6
  162.         move.l    A1,A3
  163. CalcHeaderSum:    move.l    (A3)+,D3
  164.         eor.l    D3,D6
  165.         dbf    D7,calcheadersum
  166.         and.l    D2,D6
  167.         cmp.l    D4,D6
  168.         bne.b    errorexit
  169.  
  170. HeaderSumOk:    move.b    1(A1),D3
  171.         and.b    D2,D3
  172.         add.b    D3,D3
  173.         move.b    5(A1),D4
  174.         and.b    D2,D4
  175.         or.b    D3,D4
  176.         cmp.b    (currenttrack+1)(PC),D4
  177.         bne.b    errorexit
  178.  
  179. TrackOk:    move.b    2(A1),D3
  180.         and.b    D2,D3
  181.         add.b    D3,D3
  182.         move.b    6(A1),D4
  183.         and.b    D2,D4
  184.         or.b    D3,D4
  185.         cmp.b    D0,D4
  186.         beq.b    foundsector
  187.         lea    1080(A1),A1
  188.         dbf    D5,seeksync
  189.         bra.b    errorexit
  190.  
  191. FoundSector:    lea    48(A1),A1
  192.         move.l    (A1)+,D3
  193.         and.l    D2,D3
  194.         add.l    D3,D3
  195.         move.l    (A1)+,D4
  196.         and.l    D2,D4
  197.         or.l    D3,D4
  198.         move.w    #255,D7
  199.         moveq    #0,D6
  200.         move.l    A1,A3
  201. CalcBlockSum:    move.l    (A3)+,D3
  202.         eor.l    D3,D6
  203.         dbf    D7,calcblocksum
  204.         and.l    D2,D6
  205.         cmp.l    D4,D6
  206.         bne.b    errorexit
  207.  
  208. BlockSumOk:    moveq    #127,D7
  209.         lea    512(A1),A3
  210. DecodeSector:    move.l    (A1)+,D3
  211.         and.l    D2,D3
  212.         add.l    D3,D3
  213.         move.l    (A3)+,D4
  214.         and.l    D2,D4
  215.         or.l    D3,D4
  216.         move.l    D4,(A0)+
  217.         dbf    D7,decodesector
  218.         moveq    #0,D0
  219. ExitSectorLoad:    movem.l    (SP)+,A0/A3
  220.         rts
  221. ErrorExit:    moveq    #-1,D0
  222.         bra.b    exitsectorload
  223.  
  224. LoadTrack:    move.w    currenttrack(PC),D1
  225.         bge.b    trackisknown
  226.         or.b    #$6,(A5)
  227.         clr.w    D1
  228. Cyl0Search:    btst    #4,drivestatus(A5)
  229.         beq.b    trackisknown
  230.         bsr.w    step
  231.         bra.b    cyl0search
  232. TrackIsKnown:    move.w    D0,(currenttrack-root)(A4)
  233.         lsr.w    #1,D0
  234.         bcc.b    gotoside0
  235.         bclr    #2,(A5)        * goto side 1
  236.         bra.b    sideok
  237. GotoSide0:    bset    #2,(A5)        * goto side 0
  238. SideOk:        nop
  239.         nop
  240.         lsr.w    #1,D1
  241.         sub.w    D1,D0
  242.         beq.b    readtrack
  243.         bge.b    inwards
  244.         neg.w    D0
  245.         btst    #1,(A5)
  246.         bne.b    directionok
  247.         bset    #1,(A5)        * step out
  248.         bsr.w    directiondelay
  249.         bra.b    directionok
  250. Inwards:    btst    #1,(A5)
  251.         beq.b    directionok
  252.         bclr    #1,(A5)        * step in
  253.         bsr.b    directiondelay
  254. DirectionOk:    subq.w    #1,D0
  255. SeekTrack:    bsr.b    step
  256.         dbf    D0,seektrack
  257.  
  258. ReadTrack:    move.w    #$4000,dsklen(A6)
  259.         move.w    #$8500,adkcon(A6)
  260.         move.w    #$4489,dsksync(A6)
  261. TestReady:    btst    #5,drivestatus(A5)
  262.         bne.b    testready
  263.         move.l    trackbuffer(PC),dskpt(A6)
  264.         move.w    #$9900,dsklen(A6)    load 6400 words
  265.         move.w    #$9900,dsklen(A6)
  266. WaitForBlock:    btst    #1,(intreqr+1)(A6)
  267.         beq.b    waitforblock
  268.         move.w    #$2,intreq(A6)
  269.         move.w    #$4000,dsklen(A6)
  270.         rts
  271.  
  272. Step:        bclr    #0,(A5)
  273.         nop
  274.         nop
  275.         bset    #0,(A5)
  276.         move.b    #$7F,icr(A5)
  277.         move.b    #$08,cra(A5)
  278.         move.b    #$70,talo(A5)
  279.         move.b    #$08,tahi(A5)
  280. WaitForDelay:    btst    #0,icr(A5)
  281.         beq.b    waitfordelay
  282.         rts
  283.  
  284. DirectionDelay:    move.b    #$7F,icr(A5)
  285.         move.b    #$08,cra(A5)
  286.         move.b    #$00,talo(A5)
  287.         move.b    #$33,tahi(A5)
  288.         bra.b    waitfordelay
  289.  
  290. FileName:    dc.b    9,"DUCKS.EXE"    * MUST be uppercase!!!
  291.         even
  292.  
  293. Junk:        blk.l    (1024-(junk-start))/4,"THR!"
  294. End:
  295.