home *** CD-ROM | disk | FTP | other *** search
/ Aminet 18 / aminetcdnumber181997.iso / Aminet / dev / misc / gms_dev.lha / GMS / Source / Asm / Blitter / ECSPixelTrail.s < prev    next >
Encoding:
Text File  |  1997-02-16  |  3.6 KB  |  164 lines

  1. ;-------T-------T------------------------T----------------------------------;
  2. ;Draw Pixel List (OCS/ECS)
  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.     lea    Screen(pc),a0
  71.     lea    Mouse(pc),a2
  72.  
  73. .loop    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    move.w    (a2),d0
  85.     bgt.s    .ChkRX
  86.     clr.w    (a2)
  87. .ChkRX    cmp.w    GS_ScrWidth(a0),d0
  88.     blt.s    .ChkTY
  89.     move.w    GS_ScrWidth(a0),(a2)
  90.     subq.w    #1,(a2)
  91.  
  92. .ChkTY    move.w    2(a2),d0
  93.     bge.s    .ChkBY
  94.     clr.w    2(a2)
  95. .ChkBY    cmp.w    GS_ScrHeight(a0),d0
  96.     blt.s    .Draw
  97.     move.w    GS_ScrHeight(a0),2(a2)
  98.     subq.w    #1,2(a2)
  99.  
  100. .Draw    lea    MList(pc),a3    ;Shift the list up a place.
  101.     moveq    #16-1,d7
  102. .tloop    move.l    PXL_SIZEOF(a3),PXL_XCoord(a3)
  103.     addq.w    #PXL_SIZEOF,a3
  104.     dbra    d7,.tloop
  105.  
  106.     lea    PixelList(pc),a1    ;a1 = Pixel list.
  107.     moveq    #BUFFER2,d0    ;d0 = Destination buffer.
  108.     CALL    DrawUCPixelList
  109.  
  110.     CALL    WaitSVBL
  111.     CALL    SwapBuffers
  112.     bra.s    .loop
  113. .done    rts
  114.  
  115. ;===========================================================================;
  116. ;                                  DATA
  117. ;===========================================================================;
  118.  
  119. GMS_Name:
  120.     dc.b    "games.library",0
  121.     even
  122. GMS_Base:
  123.     dc.l    0
  124.  
  125. Screen:    dc.l    GSV1,0    ;Structure version.
  126.     dc.l    0,0,0    ;Screen memory pointers 1/2/3.
  127.     dc.l    0    ;Screen link.
  128.     dc.l    .Palette    ;Address of screen palette.
  129.     dc.l    0    ;Address of rasterlist.
  130.     dc.l    16    ;Amt of colours in palette.
  131.     dc.w    320,256    ;Screen Width and Height.
  132.     dc.w    320,320/8,256    ;Picture Width/8 and Height.
  133.     dc.w    4    ;Amount of planes.
  134.     dc.w    0,0    ;X/Y screen offset.
  135.     dc.w    0,0    ;X/Y picture offset.
  136.     dc.l    DBLBUFFER    ;Special attributes.
  137.     dc.w    LORES|COL12BIT    ;Screen mode.
  138.     dc.w    ILBM    ;Screen type
  139.  
  140. .Palette
  141.     dc.w    $000,$111,$222,$333,$444,$555,$666,$777
  142.     dc.w    $888,$999,$AAA,$BBB,$CCC,$DDD,$EEE,$FFF
  143.  
  144. PixelList:
  145.     dc.w    17,PXL_SIZEOF    ;Amount of entries.
  146. MList:    PIXEL    160,128,00    ;First pixel to draw (at back)
  147.     PIXEL    160,128,00    ;X/Y/Colour
  148.     PIXEL    160,128,01    ;..
  149.     PIXEL    160,128,02    ;..
  150.     PIXEL    160,128,03    ;..
  151.     PIXEL    160,128,04    ;..
  152.     PIXEL    160,128,05    ;..
  153.     PIXEL    160,128,06    ;..
  154.     PIXEL    160,128,07    ;..
  155.     PIXEL    160,128,08    ;..
  156.     PIXEL    160,128,09    ;..
  157.     PIXEL    160,128,10    ;..
  158.     PIXEL    160,128,11    ;..
  159.     PIXEL    160,128,12    ;..
  160.     PIXEL    160,128,13    ;..
  161.     PIXEL    160,128,14    ;..
  162. Mouse:    PIXEL    160,128,15    ;Last pixel to draw (in front)
  163.  
  164.