home *** CD-ROM | disk | FTP | other *** search
/ Amiga Developer CD v1.2 / amidev_cd_12.iso / reference_library / hardware / hard_examples / sprite_display.asm < prev    next >
Assembly Source File  |  1992-08-20  |  5KB  |  113 lines

  1. ;
  2. ; sprite_display.asm
  3. ;
  4. ; This example displays the spaceship sprite at location V = 65,
  5. ; H = 128. Remember to include the file hw_examples.i.
  6. ;
  7. ; First, we set up a single bitplane.
  8. ;
  9.         LEA     CUSTOM,a0               ;Point a0 at custom chips
  10.         MOVE.W  #$1200,BPLCON0(a0)      ;1 bitplane color is on
  11.         MOVE.W  #$0000,BPL1MOD(a0)      ;Modulo = 0
  12.         MOVE.W  #$0000,BPLCON1(a0)      ;Horizontal scroll value = 0
  13.         MOVE.W  #$0024,BPLCON2(a0)      ;Sprites have priority over playfields
  14.         MOVE.W  #$0038,DDFSTRT(a0)      ;Set data-fetch start
  15.         MOVE.W  #$00D0,DDFSTOP(a0)      ;Set data-fetch stop
  16.  
  17. ; Display window definitions.
  18.  
  19.         MOVE.W  #$2C81,DIWSTRT(a0)      ;Set display window start
  20.                                         ;Vertical start in high byte.
  21.                                         ;Horizontal start * 2 in low byte.
  22.         MOVE.W  #$F4C1,DIWSTOP(a0)      ;Set display window stop
  23.                                         ;Vertical stop in high byte.
  24.                                         ;Horizontal stop * 2 in low byte.
  25. ;
  26. ; Set up color registers.
  27. ;
  28.         MOVE.W  #$0008,COLOR00(a0)      ;Background color = dark blue
  29.         MOVE.W  #$0000,COLOR01(a0)      ;Foreground color = black
  30.         MOVE.W  #$0FF0,COLOR17(a0)      ;Color 17 = yellow
  31.         MOVE.W  #$00FF,COLOR18(a0)      ;Color 18 = cyan
  32.         MOVE.W  #$0F0F,COLOR19(a0)      ;Color 19 = magenta
  33. ;
  34. ; Move Copper list to $20000.
  35. ;
  36.         MOVE.L  #$20000,a1              ;Point A1 at Copper list destination
  37.         LEA     COPPERL(pc),a2          ;Point A2 at Copper list source
  38. CLOOP:
  39.         MOVE.L  (a2),(a1)+              ;Move a long word
  40.         CMP.L   #$FFFFFFFE,(a2)+        ;Check for end of list
  41.         BNE     CLOOP                   ;Loop until entire list is moved
  42. ;
  43. ; Move sprite to $25000.
  44. ;
  45.         MOVE.L  #$25000,a1              ;Point A1 at sprite destination
  46.         LEA     SPRITE(pc),a2           ;Point A2 at sprite source
  47. SPRLOOP:
  48.         MOVE.L  (a2),(a1)+              ;Move a long word
  49.         CMP.L   #$00000000,(a2)+        ;Check for end of sprite
  50.         BNE     SPRLOOP                 ;Loop until entire sprite is moved
  51. ;
  52. ; Now we write a dummy sprite to $30000, since all eight sprites are activated
  53. ; at the same time and we're only going to use one.  The remaining sprites
  54. ; will point to this dummy sprite data.
  55. ;
  56.         MOVE.L  #$00000000,$30000       ;Write it
  57. ;
  58. ; Point Copper at Copper list.
  59. ;
  60.         MOVE.L  #$20000,COP1LC(a0)
  61. ;
  62. ; Fill bitplane with $FFFFFFFF.
  63. ;
  64.         MOVE.L  #$21000,a1              ;Point A1 at bitplane
  65.         MOVE.W  #1999,d0                ;2000-1(for dbf) long words = 8000 bytes
  66. FLOOP
  67.         MOVE.L  #$FFFFFFFF,(a1)+        ;Move a long word of $FFFFFFFF
  68.         DBF     d0,FLOOP                ;Decrement, repeat until false.
  69. ;
  70. ; Start DMA.
  71. ;
  72.          MOVE.W  d0,COPJMP1(a0)         ;Force load into Copper
  73.                                         ;  program counter
  74.         MOVE.W  #$83A0,DMACON(a0)       ;Bitplane, Copper, and sprite DMA
  75.         RTS                             ;..return to rest of program..
  76.  
  77. ;
  78. ; This is a Copper list for one bitplane, and 8 sprites.
  79. ; The bitplane lives at $21000.
  80. ; Sprite 0 lives at $25000; all others live at $30000 (the dummy sprite).
  81. ;
  82. COPPERL:
  83.         DC.W    BPL1PTH,$0002           ;Bitplane 1 pointer = $21000
  84.         DC.W    BPL1PTL,$1000
  85.         DC.W    SPR0PTH,$0002           ;Sprite 0 pointer = $25000
  86.         DC.W    SPR0PTL,$5000
  87.         DC.W    SPR1PTH,$0003           ;Sprite 1 pointer = $30000
  88.         DC.W    SPR1PTL,$0000
  89.         DC.W    SPR2PTH,$0003           ;Sprite 2 pointer = $30000
  90.         DC.W    SPR2PTL,$0000
  91.         DC.W    SPR3PTH,$0003           ;Sprite 3 pointer = $30000
  92.         DC.W    SPR3PTL,$0000
  93.         DC.W    SPR4PTH,$0003           ;Sprite 4 pointer = $30000
  94.         DC.W    SPR4PTL,$0000
  95.         DC.W    SPR5PTH,$0003           ;Sprite 5 pointer = $30000
  96.         DC.W    SPR5PTL,$0000
  97.         DC.W    SPR6PTH,$0003           ;Sprite 6 pointer = $30000
  98.         DC.W    SPR6PTL,$0000
  99.         DC.W    SPR7PTH,$0003           ;Sprite 7 pointer = $30000
  100.         DC.W    SPR7PTL,$0000
  101.         DC.W    $FFFF,$FFFE             ;End of Copper list
  102. ;
  103. ; Sprite data for spaceship sprite.  It appears on the screen at V=65 and H=128.
  104. ;
  105. SPRITE:
  106.         DC.W    $6D60,$7200             ;VSTART, HSTART, VSTOP
  107.         DC.W    $0990,$07E0             ;First pair of descriptor words
  108.         DC.W    $13C8,$0FF0
  109.         DC.W    $23C4,$1FF8
  110.         DC.W    $13C8,$0FF0
  111.         DC.W    $0990,$07E0
  112.         DC.W    $0000,$0000             ;End of sprite data
  113.