home *** CD-ROM | disk | FTP | other *** search
- ;-------T-------T------------------------T----------------------------------;
- ;Draw Pixel
- ;----------
- ;Draws a pixel on a screen without destroying the background.
- ;
-
- INCDIR "INCLUDES:"
- INCLUDE "exec/exec_lib.i"
- INCLUDE "games/games_lib.i"
- INCLUDE "games/games.i"
-
- CALL MACRO
- jsr _LVO\1(a6)
- ENDM
-
- SECTION "DrawPixel",CODE
-
- ;===========================================================================;
- ; INITIALISE DEMO
- ;===========================================================================;
-
- 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 ;Activate user preferences.
- sub.l a0,a0
- CALL SetUserPrefs
-
- CALL AllocBlitter ;Allocate the blitter.
- tst.w d0
- bne.s .Error_Blitter
-
- lea Screen(pc),a0 ;Initialise the screen.
- CALL AddScreen
- tst.w d0
- bne.s .Error_Screen
-
- lea PIC_Background(pc),a1 ;Load the picture.
- move.l GS_MemPtr1(a0),PIC_Data(a1)
- CALL LoadPic
- tst.w d0
- bne.s .Error_Picture
-
- move.l PIC_Palette(a1),GS_Palette(a0)
- CALL UpdatePalette
-
- lea Screen(pc),a0
- CALL ShowScreen
-
- bsr.s Main
-
- .ReturnToDOS
- move.l GMS_Base(pc),a6
- lea PIC_Background(pc),a1
- CALL FreePic
- .Error_Picture
- 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: move.l GMS_Base(pc),a6
- CALL InitJoyPorts
-
- moveq #100,d6
- moveq #100,d7
-
- .loop lea Screen(pc),a0
- moveq #BUFFER1,d0
- movem.w OldPixel(pc),d1/d2/d3
- tst.w d3
- blt.s .read
- CALL DrawPixel ;>> = Draw the old background pixel.
-
- .read moveq #BUFFER1,d0 ;d0 = Buffer to read.
- move.w d6,d1 ;d1 = X Coordinate.
- move.w d7,d2 ;d2 = Y Coordinate.
- CALL ReadPixel ;>> = Read the pixel.
- movem.w d6/d7,OldPixel ;MA = Save coords of next pixel.
- move.w d0,OldPixel+4 ;MA = Save colour of next pixel.
-
- moveq #BUFFER1,d0 ;d0 = Buffer.
- move.w #3,d3 ;d3 = Colour.
- CALL DrawPixel ;>> = Draw our pixel.
- CALL WaitSVBL ;>> = Wait for VBL.
-
- moveq #JPORT1,d0 ;Read the mouse, then update the
- moveq #JT_ZBXY,d1 ;BOB's X and Y co-ordinates.
- CALL ReadJoyPort
- move.w d0,d1
- ext.w d0
- asr.w #8,d1
- add.w d0,d7
- add.w d1,d6
- btst #MB_LMB,d0
- beq.s .loop
- rts
-
- OldPixel:
- dc.w 0,0,-1
-
- ;===========================================================================;
- ; DATA
- ;===========================================================================;
-
- GMS_Name: dc.b "games.library",0
- even
- GMS_Base: dc.l 0
-
- AMT_PLANES = 5
-
- Screen: dc.l GSV1,0 ;Structure version.
- dc.l 0,0,0 ;Screen_Mem1/2/3
- dc.l 0 ;Screen link.
- dc.l 0 ;Address of screen palette.
- dc.l 0 ;Address of rasterlist.
- dc.l 0 ;Amt of colours in palette.
- dc.w 320,256 ;Screen Width and Height.
- dc.w 0,0,0 ;Picture Widths and Height.
- dc.w AMT_PLANES ;Amt of planes.
- dc.w 0,0 ;X/Y screen offset.
- dc.w 0,0 ;X/Y picture offset.
- dc.l 0 ;Special attributes.
- dc.w LORES|COL12BIT ;Screen Mode.
- dc.w ILBM ;Screen Type
- even
-
- PIC_Background:
- dc.l PCV1,0 ;Version header.
- dc.l 0 ;Source data.
- dc.w 320,320/8,256 ;Width, Height.
- dc.w AMT_PLANES ;Amount of Planes.
- dc.l 0 ;Amount of colours.
- dc.l 0 ;Source palette (remap).
- dc.w LORES|COL12BIT ;Screen mode.
- dc.w ILBM ;Destination
- dc.l GETPALETTE ;Parameters.
- dc.l .File
- .File dc.b "GAMESLIB:data/IFF.Pic320",0
- even
-
-