home *** CD-ROM | disk | FTP | other *** search
/ Amiga ISO Collection / AmigaUtilCD2.iso / Programming / Assembler / dse-src1.dms / in.adf / Devpac / 300bobs.asm next >
Encoding:
Assembly Source File  |  1991-12-12  |  6.7 KB  |  264 lines

  1. *        
  2. *  1.    move.w    #149,antal        ;# of bobs-1/2
  3. *  2.   move.l    #32,choice          ;even 0-36 (curve)
  4. *  
  5. *  1.   149 betyder 300 eftersom (149+1)*2=300
  6. *       helften av bobarna er en mirror kopia.
  7. *
  8. *  2.   32 betyder bana 32, helt enkelt hur
  9. *       proggy ska 'hoppa' i sinus & coslistan
  10. *  PS.  det er fullt med fula tricks i denna kod
  11. *  men vitsen med den er att ni ska fo principen
  12. *  klar over hur det funkar.... DS.
  13. *
  14.  
  15.     opt     c-
  16.         section mycode,code_c
  17.          incdir asmdisk1:binary/    
  18.  
  19.     move.l    #main,$80    ;Exeption!
  20.     trap    #0        ;first trix!
  21.     moveq    #0,d0
  22.     rts
  23.     
  24. main    bsr    preset
  25.     bsr    dubbuf
  26.     bsr    blitset
  27.         bsr     initcop                        
  28.     bsr    curve
  29.  
  30. mouse    btst    #6,$bfe001
  31.         bne     mouse
  32.         
  33.         bsr     stopcop
  34.         rte
  35.  
  36. preset    move.w    #149,antal        ;# of bobs-1/2
  37.     move.l    #32,choice          ;even 0-36 (curve)
  38.     move.w    #$0fca,d3        ;Minterm (Cookie-cut)
  39.     move.l  #mask,d4        ;Source A Pointer (mask)
  40.     move.l  #shape,d5        ;Source B Pointer (Shape)
  41.     move.w    #$0782,d6        ;BlitSize (16*30)
  42.     move.l  #$ffffffff,$dff044  ;BlitWord-Mask F & L (Source)
  43.     move.w    #28,$dff060        ;Source C Modulo
  44.     move.w    #1,$dff062        ;Source B Modulo
  45.     move.w    #1,$dff064        ;Source A Modulo
  46.     move.w    #28,$dff066        ;Destination D Modulo
  47.     move.l  #$dff000,a6        ;Offset to Hardware.
  48.     rts
  49.  
  50. blitset move.l  prebuf,$dff048      ;Source C Pointer (Backgrnd)
  51.     move.l  #shape,$dff04c      ;Source B Pointer (Bob)
  52.     move.l  #mask,$dff050       ;Source A pointer (Mask)
  53.     rts
  54.  
  55. initcop 
  56.         move.w  $dff002,olddma     
  57.         bset    #15,olddma          ;Nasty!
  58.         move.l  #mycopper,$dff080
  59.         clr.w   $dff088
  60.         move.w  #%0111111111111111,$dff09a ;off all IRQ
  61.         move.w  #%1100000000010000,$dff09a ;Use Master & Copper IRQ
  62.         move.w  #%0000000000010000,$dff09c ;off Copper IRQ
  63.         move.w  #%0111111111111111,$dff096 ;off all DMA
  64.         move.w  #%1000001111000000,$dff096 ;on blten,copen,bplen,dmaen
  65.         move.w  #%1000010000000000,$dff096 ;Blitter Nasty on!
  66.         move.l  $6c,oldirq
  67.         move.l  #newirq,$6c
  68.         move.l  #0,$dff144             ;Kill all Sprites
  69.         rts 
  70.  
  71. stopcop move.l  oldirq,$6c
  72.         move.w  #%1110000001111111,$dff09a
  73.         move.l  4,a6
  74.         move.l  156(a6),a5             ;156 -> graphics.lib.
  75.         move.l  38(a5),$dff080             ;Reactivate WB-Copper
  76.         clr.w   $dff088
  77.         move.w  #%0111111111111111,$dff096 ;off all DMA
  78.         move.w  olddma,$dff096           ;on normal DMA
  79.         rts
  80.  
  81. newirq  bsr    dubbuf               ;Shift bitmap
  82.     bsr    clsbuf               ;Clear previous
  83.     bsr    barrel               ;Fix bliter shifts
  84.     bsr    putbobs               ;put bob on bitmap
  85.     move.w  #16,$dff09c           ;off copper IRQ
  86.         rte                   ;Exit
  87.  
  88. dubbuf    lea    bufptrs(pc),a0
  89.     adda.w    offset,a0
  90.     move.l  (a0),prebuf
  91.     move.l  (a0),d0
  92.     move.w  d0,pln1l
  93.     swap    d0
  94.     move.w    d0,pln1h
  95.     swap    d0
  96.     addi.w    #32,d0
  97.     move.w    d0,pln3l
  98.     swap    d0
  99.     move.w  d0,pln3h
  100.     swap    d0
  101.     addi.w  #$2fa0,d0
  102.     move.w  d0,pln2l
  103.     swap    d0
  104.     move.w  d0,pln2h
  105.     swap    d0
  106.     addi.w  #32,d0
  107.     move.w  d0,pln4l
  108.     swap    d0
  109.     move.w  d0,pln4h
  110.     eori.w    #4,offset    ;Shifts between bitmaps
  111.     rts
  112.  
  113. clsbuf  btst    #14,$dff002
  114.     bne    clsbuf
  115.     clr.l   $dff064                 ;No shift A & D
  116.     move.l  #$01000000,$dff040         ;D on!
  117.     move.l  prebuf,$dff054             ;Dest. D ptr.
  118.     move.w  #$3020,$dff058             ;BlitSize
  119.     rts
  120.  
  121. barrel    lea    cdptrs(pc),a0        ;Close your eyes now if
  122.     lea    shifts(pc),a2            ;you do NOT like TRIX!!
  123.     lea    cosinus(pc),a4   ;x
  124.     lea    sinus(pc),a5     ;y
  125.  
  126. lsbptr1    addi.w    #2,tabendl     ;This is very nasty!!!
  127. msbptr1    addi.w    #0,tabendh     ; but i don't care...
  128.     cmpi.w    #720,tabendl     
  129.     bmi.s   hiptr    
  130.     clr.w    tabendl
  131. hiptr    cmpi.w    #720,tabendh    
  132.     bmi.s    loptr
  133.     clr.w    tabendh
  134. loptr    adda.w    tabendl,a4
  135.     adda.w  tabendh,a5
  136.  
  137.     move.w    antal,d7
  138.     ext.l   d7
  139. getnxt    move.w    (a5),d0
  140. lsbptr2    adda.w    #2,a5
  141.     lsl.w    #6,d0
  142.     move.w    (a4),d2
  143. msbptr2    adda.w  #0,a4
  144.     move.w  d2,d1
  145.     andi.w  #$000f,d1
  146.     ror.w    #4,d1
  147.     lsr.w    #3,d2
  148.     add.w    d0,d2
  149.     add.w    prebuf+2,d2
  150.     move.w    d2,(a0)+
  151.     move.w    d1,(a2)+
  152.     dbf    d7,getnxt
  153.         rts
  154.  
  155. putbobs lea    shifts(pc),a2
  156.     lea    cdptrs(pc),a0
  157. wblit    btst    #14,$dff002
  158.     bne    wblit
  159.     move.w    #1,$dff064               ;Source A Modulo
  160.     move.w    #28,$dff066           ;Dest.  D Modulo
  161.     move.w    antal,d7
  162.     ext.l    d7                   ;Make Long
  163. nxtbob    move.w    (a2)+,d1
  164.     move.w    d1,$42(a6)           ;BLTCON1
  165.     or.w    d3,d1                   ;Minterm
  166.     move.w    d1,$40(a6)               ;BLTCON0
  167.     move.w    (a0),$4a(a6)           ;Source C (LOW)
  168.     move.w    (a0)+,$56(a6)               ;Dest.  D (LOW)
  169.     move.w    d4,$52(a6)               ;Source A (LOW)
  170.     move.w    d5,$4e(a6)           ;Source B (LOW)
  171.     move.w    d6,$58(a6)               ;BLTSIZE (16*30)
  172.     dbf    d7,nxtbob
  173.     rts
  174.  
  175. curve    movem.l    a0-a4/d0-d4,-(a7)
  176.     move.w    #0,tabendl
  177.     move.w    #180,tabendh
  178.     lea    order1(pc),a0
  179.     lea    order2(pc),a1
  180.     lea    order3(pc),a2
  181.     lea    order4(pc),a3
  182.     clr.l    d0
  183.     move.l    choice,d0
  184.     move.w    0(a0,d0.l),msbptr2+2       ;Ops! illegal again!
  185.     move.w    0(a1,d0.l),lsbptr2+2
  186.     move.w    0(a2,d0.l),lsbptr1+2
  187.     move.w    0(a3,d0.l),msbptr1+2
  188.     movem.l (a7)+,a0-a4/d0-d4
  189.     rts
  190.  
  191.  
  192. prebuf  dc.l    $70000               ;Bitmap at ABS. addr.
  193. bufptrs dc.l    $70000,$75000              ;makes the code shorter.
  194. offset  dc.w    4
  195. choice    dc.l    0
  196.  
  197. order1    dc.w 2,8,18,8,30,8, 2,4,12,6, 4,12,4,2,10,92,22,118,10
  198. order2    dc.w 2,8,22,8,14,4,34,2,46,8,12,12,2,4, 4, 2,12,  2, 8
  199. order3  dc.w 2,4, 2,0, 2,4, 2,6, 2,2, 2, 2,2,8, 2, 2, 2,  2, 2
  200. order4  dc.w 0,2, 2,4, 2,6, 2,0, 0,2, 8, 0,8,2, 2, 4, 2,  2, 2
  201.  
  202.     dc.w    0,0,0,0,0,0,0,0
  203.  
  204.  
  205. mycopper
  206.     dc.w    $0182,$0093    ;also the colors are set up
  207.     dc.w    $0184,$0093    ;in a specific order.
  208.     dc.w    $0186,$0093    ;So when two bobs 'cross' each
  209.     dc.w    $0188,$0063    ;other they wont't produce
  210.     dc.w    $018a,$0043    ;another color...
  211.     dc.w    $018c,$0063
  212.     dc.w    $018e,$0043
  213.     dc.w    $0190,$0063
  214.     dc.w    $0192,$0093
  215.     dc.w    $0194,$0043
  216.     dc.w    $0196,$0093    
  217.     dc.w    $0198,$0063
  218.     dc.w    $019a,$0043
  219.     dc.w    $019c,$0063
  220.     dc.w    $019e,$0043
  221.         dc.w    $0100,$4200
  222.     dc.w    $0102,$0000
  223.         dc.w    $008e,$4ca1
  224.         dc.w    $0090,$12a1
  225.         dc.w    $0092,$0048
  226.         dc.w    $0094,$00c0
  227.         dc.w    $0108,32      ;32 bytes off screen   (This is the trick...)   
  228.         dc.w    $010a,-96     ;32*3=96               (to get so many bobs!)
  229.         dc.w    $0180
  230.         dc.w    0,$00e0       ;4 bitplanes but we do NOT
  231. pln1h    dc.w    0,$00e2          ;get 16 colors on bobs....
  232. pln1l    dc.w    0,$00e4
  233. pln2h    dc.w    0,$00e6
  234. pln2l    dc.w    0,$00e8
  235. pln3h    dc.w    0,$00ea
  236. pln3l   dc.w    0,$00ec
  237. pln4h    dc.w    0,$00ee
  238. pln4l    dc.w    0
  239.         dc.w    $009c,$8010
  240.     dc.w    $ffdf,$fffe,$1001,$fffe         ;a good one!
  241.     dc.w    $0100,$0200            ;Garbage off! he he..
  242.         dc.w    $ffff,$fffe
  243.  
  244. olddma  dc.l    0
  245. oldirq  dc.l    0
  246. tabendl dc.w    0
  247. tabendh dc.w    0
  248. antal    dc.w    0
  249.     even
  250. cdptrs  dcb.w    510,0
  251. shifts  dcb.w   510,0
  252.     even
  253.     dcb.w   100,0
  254. cosinus incbin  'cosinus'    
  255.     dcb.w    50,0
  256. sinus    incbin  'sinus'
  257.     dcb.w      50,0
  258. shape    incbin    'shape'        ;more tricks here!
  259. mask    incbin  'shadow'
  260.  
  261.   
  262.  
  263.