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

  1. ;-------T-------T------------------------T----------------------------------;
  2. ;Draw Line
  3. ;---------
  4. ;This demo draws a line which you can control with the mouse.
  5.  
  6.     INCDIR    "INCLUDES:"
  7.     INCLUDE    "exec/exec_lib.i"
  8.     INCLUDE    "games/games_lib.i"
  9.     INCLUDE    "games/games.i"
  10.  
  11. CALL    MACRO
  12.     jsr    _LVO\1(a6)
  13.     ENDM
  14.  
  15. ;===========================================================================;
  16. ;                             INITIALISE DEMO
  17. ;===========================================================================;
  18.  
  19.     SECTION    "DrawLine",CODE
  20.  
  21. Start:    MOVEM.L    A0-A6/D1-D7,-(SP)
  22.     move.l    ($4).w,a6
  23.     lea    GMS_Name(pc),a1
  24.     moveq    #$00,d0
  25.     CALL    OpenLibrary
  26.     move.l    d0,GMS_Base
  27.     beq.s    .Error_GMS
  28.  
  29.     move.l    GMS_Base(pc),a6
  30.     sub.l    a0,a0
  31.     CALL    SetUserPrefs
  32.     tst.w    d0
  33.     bne.s    .Error_Prefs
  34.  
  35.     CALL    AllocBlitter
  36.     tst.w    d0
  37.     bne.s    .Error_Blitter
  38.  
  39.     lea    Screen(pc),a0
  40.     CALL    AddScreen
  41.     tst.l    d0
  42.     bne.s    .Error_Screen
  43.  
  44.     CALL    ShowScreen
  45.  
  46.     bsr.s    Loop
  47.  
  48. .ReturnToDOS
  49.     move.l    GMS_Base(pc),a6
  50.     lea    Screen(pc),a0
  51.     CALL    DeleteScreen
  52. .Error_Screen
  53.     CALL    FreeBlitter
  54. .Error_Blitter
  55. .Error_Prefs
  56.     move.l    GMS_Base(pc),a1
  57.     move.l    ($4).w,a6
  58.     CALL    CloseLibrary
  59. .Error_GMS
  60.     MOVEM.L    (SP)+,A0-A6/D1-D7
  61.     moveq    #$00,d0
  62.     rts
  63.  
  64. ;===========================================================================;
  65. ;                                MAIN LOOP
  66. ;===========================================================================;
  67.  
  68. Loop:    lea    Screen(pc),a0
  69.     moveq    #BUFFER2,d0
  70.     CALL    ClrScreen
  71.  
  72.     moveq    #JPORT1,d0
  73.     CALL    ReadMouse
  74.     btst    #MB_RMB,d0
  75.     bne.s    .done
  76.     lea    MouseDXY(pc),a1
  77.     btst    #MB_LMB,d0
  78.     beq.s    .no
  79.     lea    MouseSXY(pc),a1
  80. .no    move.w    d0,d1
  81.     ext.w    d1
  82.     add.w    d1,2(a1)
  83.     asr.w    #8,d0
  84.     add.w    d0,(a1)
  85.  
  86. .Draw    moveq    #BUFFER2,d0    ;d0 = Buffer
  87.     movem.w    MouseSXY(pc),d1/d2/d3/d4    ;d1 = XStart, YStart, XEnd, YEnd.
  88.     moveq    #2,d5    ;d5 = Colour
  89.     CALL    DrawLine
  90.     CALL    WaitSVBL
  91.     CALL    SwapBuffers
  92.     bra.s    Loop
  93. .done    rts
  94.  
  95. MouseSXY
  96.     dc.w    160,128
  97. MouseDXY
  98.     dc.w    40,40
  99.  
  100. ;===========================================================================;
  101. ;                                  DATA
  102. ;===========================================================================;
  103.  
  104. GMS_Name:
  105.     dc.b    "games.library",0
  106.     even
  107. GMS_Base:
  108.     dc.l    0
  109.  
  110. AMT_PLANES =    2
  111.  
  112. Screen:    dc.l    GSV1,0    ;Structure version.
  113.     dc.l    0,0,0    ;Screen memory 1/2/3.
  114.     dc.l    0    ;Screen link.
  115.     dc.l    .Palette    ;Address of screen palette.
  116.     dc.l    0    ;Address of rasterlist.
  117.     dc.l    4    ;Amount of colours in palette.
  118.     dc.w    640,256    ;Screen Width and Height.
  119.     dc.w    640,640/8,256    ;Picture Width/8 and Height.
  120.     dc.w    AMT_PLANES    ;Amount of planes
  121.     dc.w    0,0    ;X/Y screen offset.
  122.     dc.w    0,0    ;X/Y picture offset.
  123.     dc.l    DBLBUFFER    ;Special attributes.
  124.     dc.w    COL12BIT|HIRES    ;Screen mode.
  125.     dc.w    INTERLEAVED    ;Screen type
  126.  
  127. .Palette
  128.     dc.w    $000,$fff,$f0f,$f00
  129.