home *** CD-ROM | disk | FTP | other *** search
/ Compendium Deluxe 1 / LSD Compendium Deluxe 1.iso / a / programming / assembly / copperfun.lha / roll.s < prev    next >
Encoding:
Text File  |  1992-12-31  |  4.8 KB  |  168 lines

  1. ***********************************************************
  2. * This little program shows how to use the BPLxMOD registers
  3. * to produce a neat "scroll".
  4. * 1992 Epsilon
  5. ***********************************************************
  6.  
  7. WaitVblank    MACRO
  8. .\@        move.l    4(a5),d0
  9.         andi.l    #$3ff00,d0
  10.         cmpi.l    #$0f400,d0
  11.         bne.b    .\@
  12.         ENDM
  13.  
  14. ***********************************************************
  15.  
  16.         bsr.w    TakeSystem
  17. MouseWait:    WaitVblank
  18.  
  19.         bsr.s    Roll
  20.  
  21.         btst    #6,$bfe001
  22.         bne.s    MouseWait
  23.  
  24.         bsr.w    RestoreSystem
  25.         rts                ; Done!
  26.  
  27. ***********************************************************    
  28.  
  29. Roll:        move.w    skip,d0        ; can't compare memory locations
  30.         cmp.w    WAIT,d0        ; update every WAIT
  31.         bne.s    no_roll        ;   VBlanks
  32.         clr.w    skip
  33.  
  34.         lea    wavestart+6,a1    ; first line to wave in copper
  35.         cmpi.w    #8,Roll_Count    ; is text all the way up?
  36.         bne.s    roll_it
  37.         clr.w    Roll_Count    ; reset counter
  38.         neg.w    Roll_Dir    ; reverse scroll direction
  39.  
  40. roll_it:    move.w    Roll_Dir,d0    ; can't add memory loactions
  41.         add.w    d0,(a1)        ; skip another line show up.
  42.         addq.w    #1,Roll_Count    ; increment counter
  43.  
  44.         tst.w    (a1)        ; is text in center position?
  45.         bne.s    normal_wait
  46.         move.w    #60,WAIT    ; wait longer so they can read it
  47.         bra.s    no_roll
  48. normal_wait:    move.w    #10,WAIT    ; move it faster
  49.  
  50. no_roll:    addq.w    #1,skip
  51.         rts
  52.  
  53. ***********************************************************    
  54.  
  55. TakeSystem:    move.l    #$dff000,a5        ; Custom chip base
  56.  
  57.         bsr.w    InstallBmap
  58.         bsr.w    InstallSprites
  59.         move.l    #Copper,$80(a5)        ; install copper
  60.         rts                ; Done
  61.  
  62. ***********************************************************
  63.  
  64. RestoreSystem:    move.l    #$dff000,a5        ; Custom chip base
  65.  
  66.         movea.l    4.w,a6            ; ExecBase
  67.         lea    GraphicsName,a1        ; "graphics.library"
  68.         jsr    -$198(a6)        ; OpenLibrary()
  69.         move.l    d0,a1            ; Copy ptr to GfxBase
  70.         move.l    $26(a1),$80(a5)        ; Install old system copperlist
  71.         jsr    -$19e(a6)        ; CloseLibrary()
  72.         rts                ; Done
  73.  
  74. ***********************************************************    
  75.  
  76. InstallBmap:    lea    bmapptrs,a0
  77.         move.l    #Bmap,d0    ; say our bmap address is $12345678
  78.         move.w    d0,6(a0)    ;   write $5678 to $e2 reg in copper
  79.         swap    d0        ;   list, and
  80.         move.w    d0,2(a0)    ;   write $1234 to $e0
  81.         rts
  82.  
  83. ***********************************************************    
  84.  
  85. InstallSprites:    lea    sprptrs,a0        ; this causeses all sprites 
  86.         move.l    #NullSprite,d0        ;   to be just blank data.
  87.         move.w    d0,6(a0)        ;   The same effect could have
  88.         move.w    d0,14(a0)        ;   been achieved by just shutting
  89.         move.w    d0,22(a0)        ;   off sprite DMA.
  90.         move.w    d0,30(a0)
  91.         move.w    d0,38(a0)
  92.         move.w    d0,46(a0)
  93.         move.w    d0,54(a0)
  94.         move.w    d0,62(a0)
  95.         swap    d0    
  96.         move.w    d0,2(a0)    
  97.         move.w    d0,10(a0)
  98.         move.w    d0,18(a0)
  99.         move.w    d0,26(a0)
  100.         move.w    d0,34(a0)
  101.         move.w    d0,42(a0)
  102.         move.w    d0,50(a0)
  103.         move.w    d0,58(a0)
  104.         rts
  105.  
  106. ***********************************************************
  107.  
  108.         section amazin_fruit,data
  109.  
  110. WAIT:        dc.w    40
  111. Roll_Dir:    dc.w    40
  112.  
  113. Roll_Count:    dc.w    0
  114. skip:        dc.w    0
  115.  
  116. GraphicsName:    dc.b    'graphics.library',0
  117.         EVEN
  118.  
  119. ***********************************************************
  120.  
  121.         section    squid,data_c
  122.  
  123. Copper:    dc.w    $0100,$1200        ; bit plane control reg.0
  124.     dc.w    $0102,$0000        ; scroll value
  125.     dc.w    $0104,$0000        ; blp/sprite priority reg.
  126.     dc.w    $0108,$0000        ; odd bitplane modulo value
  127.     dc.w    $010a,$0000        ; even bitplane modulo value
  128.     dc.w    $0180,$0000        ; color00 = black
  129.     dc.w    $0182,$0000        ; color01 = black
  130.     dc.w    $008e,$2c81        ; upper left corner of disp. window
  131.     dc.w    $0090,$f4c1        ; lower right corner of disp. window
  132.     dc.w    $0092,$0038        ; start of bpl. (horizontal)
  133.     dc.w    $0094,$00d0        ; end of bpl. (horizontal)
  134. bmapptrs:dc.w    $00e0,$0000        ; adr of bplane 1 (long - 2 words)
  135.     dc.w    $00e2,$0000        ; low word of bplane 1 adr
  136. sprptrs:dc.w    $0120,$0000,$0122,$0000,$0124,$0000,$0126,$0000
  137.     dc.w    $0128,$0000,$012a,$0000,$012c,$0000,$012e,$0000
  138.     dc.w    $0130,$0000,$0132,$0000,$0134,$0000,$0136,$0000
  139.     dc.w    $0138,$0000,$013a,$0000,$013c,$0000,$013e,$0000
  140. wavestart:
  141.     dc.w    $4d0f,$fffe,$0108,$0000        ; odd bitplane modulo value
  142.     dc.w    $4e0f,$fffe,$0180,$0001,$0182,$0111
  143.     dc.w    $4f0f,$fffe,$0180,$0003,$0182,$0333
  144.     dc.w    $500f,$fffe,$0180,$0005,$0182,$0555
  145.     dc.w    $510f,$fffe,$0180,$0007,$0182,$0777
  146.     dc.w    $520f,$fffe,$0180,$0009,$0182,$0999
  147.     dc.w    $530f,$fffe,$0180,$000b,$0182,$0aaa
  148.     dc.w    $540f,$fffe,$0180,$000d,$0182,$0ddd
  149.     dc.w    $550f,$fffe,$0180,$000f,$0182,$0fff
  150.     dc.w    $560f,$fffe,$0180,$000d,$0182,$0ddd
  151.     dc.w    $570f,$fffe,$0180,$000b,$0182,$0bbb
  152.     dc.w    $580f,$fffe,$0180,$0009,$0182,$0999
  153.     dc.w    $590f,$fffe,$0180,$0008,$0182,$0888
  154.     dc.w    $5a0f,$fffe,$0180,$0007,$0182,$0777
  155.     dc.w    $5b0f,$fffe,$0180,$0006,$0182,$0666
  156.     dc.w    $5c0f,$fffe,$0180,$0005,$0182,$0555
  157.     dc.w    $5d0f,$fffe,$0180,$0004,$0182,$0444
  158.     dc.w    $5e0f,$fffe,$0180,$0003,$0182,$0333
  159.     dc.w    $5f0f,$fffe,$0180,$0002,$0182,$0222
  160.     dc.w    $600f,$fffe,$0180,$0001,$0182,$0111
  161. waveend:dc.w    $610f,$fffe,$0108,$0000,$0180,$0000
  162.     dc.w    $0182,$0000
  163.     dc.l    -2,-2
  164.  
  165. Bmap:    incbin    "fun.raw"
  166.     
  167. NullSprite:    dc.l    0,0,0        ; 2 controll words,2 data words,2 blank word
  168.