home *** CD-ROM | disk | FTP | other *** search
- ;-------T-------T------------------------T----------------------------------;
- ;Draw Line
- ;---------
- ;This demo draws a line which you can control with the mouse.
-
- INCDIR "INCLUDES:"
- INCLUDE "exec/exec_lib.i"
- INCLUDE "games/games_lib.i"
- INCLUDE "games/games.i"
-
- CALL MACRO
- jsr _LVO\1(a6)
- ENDM
-
- ;===========================================================================;
- ; INITIALISE DEMO
- ;===========================================================================;
-
- SECTION "DrawLine",CODE
-
- Start: MOVEM.L A0-A6/D1-D7,-(SP)
- move.l ($4).w,a6
- lea GMS_Name(pc),a1
- moveq #$00,d0
- CALL OpenLibrary
- move.l d0,GMS_Base
- beq.s .Error_GMS
-
- move.l GMS_Base(pc),a6
- sub.l a0,a0
- CALL SetUserPrefs
- tst.w d0
- bne.s .Error_Prefs
-
- CALL AllocBlitter
- tst.w d0
- bne.s .Error_Blitter
-
- lea Screen(pc),a0
- CALL AddScreen
- tst.l d0
- bne.s .Error_Screen
-
- CALL ShowScreen
-
- bsr.s Loop
-
- .ReturnToDOS
- move.l GMS_Base(pc),a6
- lea Screen(pc),a0
- CALL DeleteScreen
- .Error_Screen
- CALL FreeBlitter
- .Error_Blitter
- .Error_Prefs
- move.l GMS_Base(pc),a1
- move.l ($4).w,a6
- CALL CloseLibrary
- .Error_GMS
- MOVEM.L (SP)+,A0-A6/D1-D7
- moveq #$00,d0
- rts
-
- ;===========================================================================;
- ; MAIN LOOP
- ;===========================================================================;
-
- Loop: lea Screen(pc),a0
- moveq #BUFFER2,d0
- CALL ClrScreen
-
- moveq #JPORT1,d0
- CALL ReadMouse
- btst #MB_RMB,d0
- bne.s .done
- lea MouseDXY(pc),a1
- btst #MB_LMB,d0
- beq.s .no
- lea MouseSXY(pc),a1
- .no move.w d0,d1
- ext.w d1
- add.w d1,2(a1)
- asr.w #8,d0
- add.w d0,(a1)
-
- .Draw moveq #BUFFER2,d0 ;d0 = Buffer
- movem.w MouseSXY(pc),d1/d2/d3/d4 ;d1 = XStart, YStart, XEnd, YEnd.
- moveq #2,d5 ;d5 = Colour
- CALL DrawLine
- CALL WaitSVBL
- CALL SwapBuffers
- bra.s Loop
- .done rts
-
- MouseSXY
- dc.w 160,128
- MouseDXY
- dc.w 40,40
-
- ;===========================================================================;
- ; DATA
- ;===========================================================================;
-
- GMS_Name:
- dc.b "games.library",0
- even
- GMS_Base:
- dc.l 0
-
- AMT_PLANES = 2
-
- Screen: dc.l GSV1,0 ;Structure version.
- dc.l 0,0,0 ;Screen memory 1/2/3.
- dc.l 0 ;Screen link.
- dc.l .Palette ;Address of screen palette.
- dc.l 0 ;Address of rasterlist.
- dc.l 4 ;Amount of colours in palette.
- dc.w 640,256 ;Screen Width and Height.
- dc.w 640,640/8,256 ;Picture Width/8 and Height.
- dc.w AMT_PLANES ;Amount of planes
- dc.w 0,0 ;X/Y screen offset.
- dc.w 0,0 ;X/Y picture offset.
- dc.l DBLBUFFER ;Special attributes.
- dc.w COL12BIT|HIRES ;Screen mode.
- dc.w INTERLEAVED ;Screen type
-
- .Palette
- dc.w $000,$fff,$f0f,$f00
-