home *** CD-ROM | disk | FTP | other *** search
- ;-------T-------T------------------------T----------------------------------;
- ;Draw Pixel List (OCS/ECS)
- ;-------------------------
- ;This demo demonstrates the usefulness of LISTs, by drawing a trail of
- ;pixels attached to the mouse. In the case of pixels there are special
- ;routines for drawing with lists, so the drawing is very fast.
- ;
- ;Press LMB to exit.
-
- 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 "DrawPixel",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
-
- 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 Main
-
- .ReturnToDOS
- move.l GMS_Base(pc),a6
- lea Screen(pc),a0
- CALL DeleteScreen
- .Error_Screen
- CALL FreeBlitter
- .Error_Blitter
- 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
- ;===========================================================================;
-
- Main: CALL InitJoyPorts
- lea Screen(pc),a0
- lea Mouse(pc),a2
-
- .loop moveq #JPORT1,d0
- CALL ReadMouse
- btst #MB_LMB,d0
- bne.s .done
-
- move.w d0,d1
- ext.w d1
- add.w d1,2(a2)
- asr.w #8,d0
- add.w d0,(a2)
-
- .ChkLX move.w (a2),d0
- bgt.s .ChkRX
- clr.w (a2)
- .ChkRX cmp.w GS_ScrWidth(a0),d0
- blt.s .ChkTY
- move.w GS_ScrWidth(a0),(a2)
- subq.w #1,(a2)
-
- .ChkTY move.w 2(a2),d0
- bge.s .ChkBY
- clr.w 2(a2)
- .ChkBY cmp.w GS_ScrHeight(a0),d0
- blt.s .Draw
- move.w GS_ScrHeight(a0),2(a2)
- subq.w #1,2(a2)
-
- .Draw lea MList(pc),a3 ;Shift the list up a place.
- moveq #16-1,d7
- .tloop move.l PXL_SIZEOF(a3),PXL_XCoord(a3)
- addq.w #PXL_SIZEOF,a3
- dbra d7,.tloop
-
- lea PixelList(pc),a1 ;a1 = Pixel list.
- moveq #BUFFER2,d0 ;d0 = Destination buffer.
- CALL DrawUCPixelList
-
- CALL WaitSVBL
- CALL SwapBuffers
- bra.s .loop
- .done rts
-
- ;===========================================================================;
- ; DATA
- ;===========================================================================;
-
- GMS_Name:
- dc.b "games.library",0
- even
- GMS_Base:
- dc.l 0
-
- Screen: dc.l GSV1,0 ;Structure version.
- dc.l 0,0,0 ;Screen memory pointers 1/2/3.
- dc.l 0 ;Screen link.
- dc.l .Palette ;Address of screen palette.
- dc.l 0 ;Address of rasterlist.
- dc.l 16 ;Amt of colours in palette.
- dc.w 320,256 ;Screen Width and Height.
- dc.w 320,320/8,256 ;Picture Width/8 and Height.
- dc.w 4 ;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 LORES|COL12BIT ;Screen mode.
- dc.w ILBM ;Screen type
-
- .Palette
- dc.w $000,$111,$222,$333,$444,$555,$666,$777
- dc.w $888,$999,$AAA,$BBB,$CCC,$DDD,$EEE,$FFF
-
- PixelList:
- dc.w 17,PXL_SIZEOF ;Amount of entries.
- MList: PIXEL 160,128,00 ;First pixel to draw (at back)
- PIXEL 160,128,00 ;X/Y/Colour
- PIXEL 160,128,01 ;..
- PIXEL 160,128,02 ;..
- PIXEL 160,128,03 ;..
- PIXEL 160,128,04 ;..
- PIXEL 160,128,05 ;..
- PIXEL 160,128,06 ;..
- PIXEL 160,128,07 ;..
- PIXEL 160,128,08 ;..
- PIXEL 160,128,09 ;..
- PIXEL 160,128,10 ;..
- PIXEL 160,128,11 ;..
- PIXEL 160,128,12 ;..
- PIXEL 160,128,13 ;..
- PIXEL 160,128,14 ;..
- Mouse: PIXEL 160,128,15 ;Last pixel to draw (in front)
-
-