home *** CD-ROM | disk | FTP | other *** search
- ;-------T-------T------------------------T----------------------------------;
- ;Circle Example
- ;--------------
- ;This an example of 2 circles blitted onto a planar screen at different
- ;levels. Move the green circle over the red circle to get an idea of the
- ;effect you can achieve with a planar screen.
- ;
- ;The screen is double buffered and in hi-res, just to be a bit different
- ;from the other demos. The circles are removed from the screen using the
- ;CLEAR mode and a RestoreList.
-
- INCDIR "INCLUDES:"
- INCLUDE "exec/exec_lib.i"
- INCLUDE "games/games_lib.i"
- INCLUDE "games/games.i"
-
- CALL MACRO
- jsr _LVO\1(a6)
- ENDM
-
- SECTION "Circles",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
- sub.l a0,a0
- CALL SetUserPrefs
-
- CALL AllocBlitter
- bne.s .Error_Blitter
-
- lea Screen(pc),a0
- CALL AddScreen
- tst.w d0
- bne.s .Error_Screen
-
- lea BOB_List(pc),a1
- CALL InitBOB ;Initialise the BOB.
- tst.w d0
- bne.s .Error_BOB
-
- moveq #2,d0 ;d0 = 2 buffers.
- moveq #3,d1 ;d1 = 3 BOB Entries.
- CALL InitRestore
- move.l d0,RestoreList
- beq.s .Error_RestoreList
-
- CALL ShowScreen
-
- CALL InitJoyPorts
-
- bsr.s Main
-
- .ReturnToDOS
- move.l GMS_Base(pc),a6
- move.l RestoreList(pc),d0
- CALL FreeRestore
- .Error_RestoreList
- lea BOB_List(pc),a1
- CALL FreeBOB
- .Error_BOB
- 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: moveq #$00,d7
- .loop lea BOB_Circle1(pc),a1
- moveq #JPORT1,d0
- moveq #JT_ZBXY,d1
- CALL ReadJoyPort ;Go get port status.
- move.w d0,d1
- ext.w d0
- add.w d0,BOB_YPos(a1)
- asr.w #8,d1
- add.w d1,BOB_XPos(a1)
- btst #MB_LMB,d0
- bne.s .done
-
- lea Screen(pc),a0
- lea BOB_Circle2(pc),a1
- movem.w Circle2XV(pc),d0/d1
- bsr.s MoveBOB
- movem.w d0/d1,Circle2XV
-
- lea BOB_Circle3(pc),a1
- movem.w Circle3XV(pc),d0/d1
- bsr.s MoveBOB
- movem.w d0/d1,Circle3XV
-
- .draw lea Screen(pc),a0
- move.l RestoreList(pc),a1
- CALL Restore ;Clear all buffered BOB's.
-
- lea BOB_List(pc),a1
- move.l RestoreList(pc),a2
- move.w #BUFFER2,d0
- CALL DrawBOBList ;Go and draw all circles.
- CALL WaitSVBL
- CALL SwapBuffers
- bra.s .loop
- .done rts
-
- ;===========================================================================;
- ; MOVE A BOB
- ;===========================================================================;
- ;Function: Moves a BOB, bouncing it across the screen.
- ;Requires: a0 = GameScreen
- ; a1 = BOB to move.
- ; d0 = X Velocity
- ; d1 = Y Velocity
- ;Returns: d0 = New X Velocity.
- ; d1 = New Y Velocity.
-
- MoveBOB:
- add.w d0,BOB_XCoord(a1)
- add.w d1,BOB_YCoord(a1)
-
- .ChkLX tst.w BOB_XCoord(a1)
- bgt.s .ChkTY
- neg.w BOB_XCoord(a1)
- neg.w d0
-
- .ChkTY tst.w BOB_YCoord(a1)
- bgt.s .ChkRX
- neg.w BOB_YCoord(a1)
- neg.w d1
-
- .ChkRX move.w GS_PicWidth(a0),d2
- sub.w BOB_Width(a1),d2
- cmp.w BOB_XCoord(a1),d2
- bgt.s .ChkBY
- move.w d2,BOB_XCoord(a1)
- neg.w d0
-
- .ChkBY move.w GS_PicHeight(a0),d2
- sub.w BOB_Height(a1),d2
- cmp.w BOB_YCoord(a1),d2
- bgt.s .done
- move.w d2,BOB_YCoord(a1)
- neg.w d1
- .done rts
-
- ;===========================================================================;
- ; DATA
- ;===========================================================================;
-
- Circle2XV: dc.w 3
- Circle2YV: dc.w 2
- Circle3XV: dc.w -2
- Circle3YV: dc.w -4
-
- RestoreList:
- dc.l 0
-
- GMS_Name:
- dc.b "games.library",0
- even
- GMS_Base:
- dc.l 0
-
- AMT_PLANES = 4
-
- 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 8 ;Amount of colours in palette.
- dc.w 640,256 ;Screen Width and Height.
- dc.w 640,640/8,256 ;Picture Width 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 HIRES|COL12BIT|LACED ;Screen Mode.
- dc.w PLANAR ;Screen Type
- even
-
- Palette dc.w $000,$f00,$0f0,$ff0,$00f,$f0f,$0ff,$fff
-
- ;---------------------------------------------------------------------------;
-
- BOB_List:
- dc.l "LIST"
- dc.l BOB_Circle1
- dc.l BOB_Circle2
- dc.l BOB_Circle3
- dc.l LISTEND
-
- BOB_Circle1:
- dc.l BBV1,0 ;Structure version.
- dc.l CircleGfx,CircleGfx ;Graphics and Mask data.
- dc.w 0 ;Current frame.
- dc.l .Frame ;Pointer to frame list.
- dc.w 96/8 ;Modulo (skip in source) in bytes.
- dc.w 96,96/8,83 ;Width, Width in bytes, Height.
- dc.w 100,40 ;X/Y destination.
- dc.w 0,0 ;Border restriction LeftX,TopY.
- dc.w 0,0 ;Border restrictions RightX,EndY.
- dc.w 1,1 ;1st Plane, Amount of planes.
- dc.l 0 ;Plane Size.
- dc.l CLIP|MASK|CLEAR|CLRNOMASK ;Attributes.
- dc.l 0 ;Picture Struct (Bob Origin)
- .Frame dc.w 0,0,0,0
- dc.l -1
-
- BOB_Circle2:
- dc.l BBV1,0 ;Structure version.
- dc.l CircleGfx,CircleGfx ;Graphics and Mask data.
- dc.w 0 ;Current frame.
- dc.l .Frame ;Pointer to frame list.
- dc.w 96/8 ;Modulo (skip in source) in bytes.
- dc.w 96,96/8,83 ;Width, Width in bytes, Height.
- dc.w 278,86 ;X/Y destination.
- dc.w 0,0 ;Border restriction LeftX,TopY.
- dc.w 0,0 ;Border restrictions RightX,EndY.
- dc.w 0,1 ;1st Plane, Amount of planes.
- dc.l 0 ;Plane Size, not required.
- dc.l CLEAR|CLRNOMASK ;Attributes.
- dc.l 0 ;Picture Struct (Bob Origin)
- .Frame dc.w 0,0,0,0
- dc.l -1
-
- BOB_Circle3:
- dc.l BBV1,0 ;Structure version.
- dc.l CircleGfx,CircleGfx ;Graphics and Mask data.
- dc.w 0 ;Current frame.
- dc.l .Frame ;Pointer to frame list.
- dc.w 96/8 ;Modulo (skip in source) in bytes.
- dc.w 96,96/8,83 ;Width, Width in bytes, Height.
- dc.w 450,150 ;X/Y destination.
- dc.w 0,0 ;Border restriction LeftX,TopY.
- dc.w 0,0 ;Border restrictions RightX,EndY.
- dc.w 2,1 ;1st Plane, Amount of planes.
- dc.l 0 ;Plane Size, not required.
- dc.l CLEAR|CLRNOMASK ;Attributes.
- dc.l 0 ;Picture Struct (Bob Origin)
- .Frame dc.w 0,0,0,0
- dc.l -1
-
- ;===========================================================================;
- ; ALL CHIP RAM DATA HERE
- ;===========================================================================;
-
- SECTION "Graphics",DATA_C
-
- CircleGfx:
- INCBIN "GAMESLIB:Data/BOB_Circle.raw"
-
-