home *** CD-ROM | disk | FTP | other *** search
/ Aminet 18 / aminetcdnumber181997.iso / Aminet / dev / misc / gms_dev.lha / GMS / Source / Asm / Blitter / AGAPixelTrail2.s < prev    next >
Encoding:
Text File  |  1997-01-10  |  4.1 KB  |  182 lines

  1. ;-------T-------T------------------------T----------------------------------;
  2. ;Draw Pixel List (AGA)
  3. ;---------------------
  4. ;This demo demonstrates the usefulness of LISTs, by drawing a trail of
  5. ;pixels attached to the mouse.  In the case of pixels there are special
  6. ;routines for drawing with lists, so the drawing is very fast.
  7. ;
  8. ;Press LMB to exit.
  9.  
  10.     INCDIR    "INCLUDES:"
  11.     INCLUDE    "exec/exec_lib.i"
  12.     INCLUDE    "games/games_lib.i"
  13.     INCLUDE    "games/games.i"
  14.  
  15. CALL    MACRO
  16.     jsr    _LVO\1(a6)
  17.     ENDM
  18.  
  19. ;===========================================================================;
  20. ;                             INITIALISE DEMO
  21. ;===========================================================================;
  22.  
  23.     SECTION    "DrawPixel",CODE
  24.  
  25. Start:    MOVEM.L    A0-A6/D1-D7,-(SP)
  26.     move.l    ($4).w,a6
  27.     lea    GMS_Name(pc),a1
  28.     moveq    #$00,d0
  29.     CALL    OpenLibrary
  30.     move.l    d0,GMS_Base
  31.     beq.s    .Error_GMS
  32.  
  33.     move.l    GMS_Base(pc),a6
  34.     sub.l    a0,a0
  35.     CALL    SetUserPrefs
  36.  
  37.     CALL    AllocBlitter
  38.     tst.w    d0
  39.     bne.s    .Error_Blitter
  40.  
  41.     lea    Screen(pc),a0
  42.     CALL    AddScreen
  43.     tst.l    d0
  44.     bne.s    .Error_Screen
  45.  
  46.     CALL    ShowScreen
  47.  
  48.     bsr.s    Main
  49.  
  50. .ReturnToDOS
  51.     move.l    GMS_Base(pc),a6
  52.     lea    Screen(pc),a0
  53.     CALL    DeleteScreen
  54. .Error_Screen
  55.     CALL    FreeBlitter
  56. .Error_Blitter
  57.     move.l    GMS_Base(pc),a1
  58.     move.l    ($4).w,a6
  59.     CALL    CloseLibrary
  60. .Error_GMS
  61.     MOVEM.L    (SP)+,A0-A6/D1-D7
  62.     moveq    #$00,d0
  63.     rts
  64.  
  65. ;===========================================================================;
  66. ;                                MAIN LOOP
  67. ;===========================================================================;
  68.  
  69. Main:    CALL    InitJoyPorts
  70.  
  71. .loop    lea    Screen(pc),a0
  72.     lea    Mouse(pc),a2
  73.     moveq    #JPORT1,d0
  74.     CALL    ReadMouse
  75.     btst    #MB_LMB,d0
  76.     bne.s    .done
  77.  
  78.     move.w    d0,d1
  79.     ext.w    d1
  80.     add.w    d1,2(a2)
  81.     asr.w    #8,d0
  82.     add.w    d0,(a2)
  83.  
  84. .ChkLX    tst.w    (a2)
  85.     bge.s    .ChkRX
  86.     clr.w    (a2)
  87. .ChkRX    cmp.w    #319,(a2)
  88.     ble.s    .ChkTY
  89.     move.w    #319,(a2)
  90. .ChkTY    tst.w    2(a2)
  91.     bge.s    .ChkBY
  92.     clr.w    2(a2)
  93. .ChkBY    cmp.w    #255,2(a2)
  94.     ble.s    .Draw
  95.     move.w    #255,2(a2)
  96.  
  97. .Draw    lea    MList(pc),a3    ;Shift the list up a place.
  98.     moveq    #32-1,d7
  99. .tloop    move.l    PXL_SIZEOF(a3),PXL_XCoord(a3)
  100.     addq.w    #PXL_SIZEOF,a3
  101.     dbra    d7,.tloop
  102.  
  103.     lea    PixelList(pc),a1    ;a1 = Pixel list.
  104.     moveq    #BUFFER2,d0    ;d0 = Destination buffer.
  105.     CALL    DrawUCPixelList
  106.  
  107.     CALL    WaitSVBL
  108.     CALL    SwapBuffers
  109.     bra.s    .loop
  110. .done    rts
  111.  
  112. ;===========================================================================;
  113. ;                                  DATA
  114. ;===========================================================================;
  115.  
  116. GMS_Name:
  117.     dc.b    "games.library",0
  118.     even
  119. GMS_Base:
  120.     dc.l    0
  121.  
  122. Screen:    dc.l    GSV1,0    ;Structure version.
  123.     dc.l    0,0,0    ;Screen memory pointers 1/2/3.
  124.     dc.l    0    ;Screen link.
  125.     dc.l    .Palette    ;Address of screen palette.
  126.     dc.l    0    ;Address of rasterlist.
  127.     dc.l    32    ;Amt of colours in palette.
  128.     dc.w    320,256    ;Screen Width and Height.
  129.     dc.w    320,320/8,256    ;Picture Width/8 and Height.
  130.     dc.w    5    ;Amount of planes.
  131.     dc.w    0,0    ;X/Y screen offset.
  132.     dc.w    0,0    ;X/Y picture offset.
  133.     dc.l    DBLBUFFER    ;Special attributes.
  134.     dc.w    LORES|COL24BIT    ;Screen mode.
  135.     dc.w    INTERLEAVED    ;Screen type
  136.     even
  137.  
  138. .Palette
  139.  dc.l    $000000,$101010,$202020,$303030,$404040,$505050,$606060,$707070
  140.  dc.l    $808080,$909090,$a0a0a0,$b0b0b0,$c0c0c0,$d0d0d0,$e0e0e0,$f0f0f0
  141.  dc.l    $000000,$101010,$202020,$303030,$404040,$505050,$606060,$707070
  142.  dc.l    $808080,$909090,$a0a0a0,$b0b0b0,$c0c0c0,$d0d0d0,$e0e0e0,$ffffff
  143.  
  144. ;---------------------------------------------------------------------------;
  145.  
  146. PixelList:
  147.     dc.w    33,PXL_SIZEOF    ;Amount of entries.
  148. MList:    PIXEL    160,128,00    ;First pixel to draw (at back)
  149.     PIXEL    160,128,00    ;X/Y/Colour
  150.     PIXEL    160,128,01    ;..
  151.     PIXEL    160,128,02    ;..
  152.     PIXEL    160,128,03    ;..
  153.     PIXEL    160,128,04    ;..
  154.     PIXEL    160,128,05    ;..
  155.     PIXEL    160,128,06    ;..
  156.     PIXEL    160,128,07    ;..
  157.     PIXEL    160,128,08    ;..
  158.     PIXEL    160,128,09    ;..
  159.     PIXEL    160,128,10    ;..
  160.     PIXEL    160,128,11    ;..
  161.     PIXEL    160,128,12    ;..
  162.     PIXEL    160,128,13    ;..
  163.     PIXEL    160,128,14    ;..
  164.     PIXEL    160,128,15    ;..
  165.     PIXEL    160,128,16    ;..
  166.     PIXEL    160,128,17    ;..
  167.     PIXEL    160,128,18    ;..
  168.     PIXEL    160,128,19    ;..
  169.     PIXEL    160,128,20    ;..
  170.     PIXEL    160,128,21    ;..
  171.     PIXEL    160,128,22    ;..
  172.     PIXEL    160,128,23    ;..
  173.     PIXEL    160,128,24    ;..
  174.     PIXEL    160,128,25    ;..
  175.     PIXEL    160,128,26    ;..
  176.     PIXEL    160,128,27    ;..
  177.     PIXEL    160,128,28    ;..
  178.     PIXEL    160,128,29    ;..
  179.     PIXEL    160,128,30    ;..
  180. Mouse:    PIXEL    160,128,31    ;Last pixel to draw (in front)
  181.  
  182.