home *** CD-ROM | disk | FTP | other *** search
- ;Sprite Example (AGA only)
- ;-------------------------
- ;This example contains four 64 pixel wide sprites, in high resolution.
- ;You can move sprite number 2 around with the mouse, notice how it
- ;appears behind number 1 and in front of 3 and 4.
- ;
- ;This demo also uses the LIST feature to initialise the four sprites.
- ;
- ;The LMB exits the demo.
-
- INCDIR "INCLUDES:"
- INCLUDE "exec/exec_lib.i"
- INCLUDE "games/games_lib.i"
- INCLUDE "games/games.i"
-
- CALL MACRO
- jsr _LVO\1(a6)
- ENDM
-
- SECTION "Sprites",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
-
- lea Screen(pc),a0 ;Initialise our screen for use.
- CALL AddScreen
- tst.l d0
- bne.s .Error_Screen
-
- CALL ShowScreen ;Show our screen.
-
- lea SpriteList(pc),a1
- CALL InitSprite
- tst.l d0
- bne.s .Error_Sprites
-
- lea Circle1(pc),a1
- CALL UpdateSprite
- lea Circle3(pc),a1
- CALL UpdateSprite
- lea Circle4(pc),a1
- CALL UpdateSprite
-
- CALL InitJoyPorts
-
- bsr.s Main
-
-
- .ReturnToDOS
- move.l GMS_Base(pc),a6
- lea SpriteList(pc),a1
- CALL FreeSprite
- .Error_Sprites
- lea Screen(pc),a0
- CALL DeleteScreen
- .Error_Screen
- 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: lea Circle2(pc),a1
- .loop moveq #JPORT1,d0 ;Read from port 1
- CALL ReadMouse ;Go get mouse position.
- move.w d0,d1
- asr.w #8,d0
- add.w d0,SPR_XPos(a1)
- ext.w d1
- add.w d1,SPR_YPos(a1)
-
- CALL WaitSVBL ;Allow screen-switching.
- CALL UpdateSprite ;Put Sparkie on the screen.
-
- btst #MB_LMB,d0
- beq.s .loop
- rts
-
- ;===========================================================================;
- ; DATA
- ;===========================================================================;
-
- GMS_Name:
- dc.b "games.library",0
- even
- GMS_Base:
- dc.l 0
-
- SpriteList:
- dc.l "LIST"
- dc.l Circle1
- dc.l Circle2
- dc.l Circle3
- dc.l Circle4
- dc.l LISTEND
-
- Circle1 dc.l SPV1,0 ;Structure version.
- dc.w 0 ;Bank Number 0.
- dc.l Gfx_Circle1 ;Ptr to graphic.
- dc.w 20,20 ;Beginning X/Y position
- dc.w 0 ;Current frame.
- dc.w 64 ;Width (16/32/64)
- dc.w 64 ;Height
- dc.w 16 ;Amt of colours.
- dc.w 16 ;Colour start in palette.
- dc.w 2 ;Amt of planes.
- dc.w LORES ;Resolution.
- dc.w 0 ;PlayField position.
- dc.w 0 ;Special attributes.
-
- Circle2 dc.l SPV1,0 ;Structure version.
- dc.w 2 ;Bank Number 2.
- dc.l Gfx_Circle2 ;Ptr to graphic.
- dc.w 70,70 ;Beginning X/Y position
- dc.w 0 ;Current frame.
- dc.w 64 ;Width (16/32/64)
- dc.w 64 ;Height
- dc.w 16 ;Amt of colours.
- dc.w 16 ;Colour start in palette.
- dc.w 2 ;Amt of planes.
- dc.w LORES ;Resolution
- dc.w 0 ;PlayField position.
- dc.w 0 ;Special attributes.
-
- Circle3 dc.l SPV1,0 ;Structure version.
- dc.w 4 ;Bank Number 4.
- dc.l Gfx_Circle3 ;Ptr to graphic.
- dc.w 120,120 ;Beginning X/Y position
- dc.w 0 ;Current frame.
- dc.w 64 ;Width (16/32/64)
- dc.w 64 ;Height
- dc.w 16 ;Amt of colours.
- dc.w 16 ;Colour start in palette.
- dc.w 2 ;Amt of planes.
- dc.w LORES ;Resolution.
- dc.w 0 ;PlayField position.
- dc.w 0 ;Special attributes.
-
- Circle4 dc.l SPV1,0 ;Structure version.
- dc.w 6 ;Bank Number 4.
- dc.l Gfx_Circle4 ;Ptr to graphic.
- dc.w 170,170 ;Beginning X/Y position
- dc.w 0 ;Current frame.
- dc.w 64 ;Width (16/32/64)
- dc.w 64 ;Height
- dc.w 16 ;Amt of colours.
- dc.w 16 ;Colour start in palette.
- dc.w 2 ;Amt of planes.
- dc.w HIRES ;Screen mode.
- dc.w 0 ;PlayField position.
- dc.w 0 ;Special attributes.
-
- AMT_PLANES = 1
-
- Screen: dc.l GSV1,0
- dc.l 0,0,0 ;Screen Memory 1/2/3.
- dc.l 0 ;Screen link.
- dc.l .Palette ;Address of the screen palette.
- dc.l 0 ;Address of a ColourList.
- dc.l 32 ;Amt of colours in the palette.
- dc.w 320,256 ;Screen Width and Height.
- dc.w 0,0,0 ;Picture Widths and Height.
- dc.w AMT_PLANES ;Amt_Planes
- dc.w 0,0 ;X/Y screen offset.
- dc.w 0,0 ;X/Y picture offset.
- dc.l SPRITES|NOSCRBDR ;Special attributes.
- dc.w LORES|COL24BIT ;Screen mode.
- dc.w INTERLEAVED ;Screen type
- even
-
- .Palette
- dc.l $000000,$0F0000,$1F0000,$2F0000,$3F0000,$4F0000
- dc.l $5F0000,$6F0000,$7F0000,$8F0000,$9F0000,$AF0000
- dc.l $BF0000,$CF0000,$DF0000,$EF0000,$FF0000,$001111
- dc.l $002222,$003333,$004444,$005555,$006666,$007777
- dc.l $008888,$009999,$00AAAA,$00BBBB,$00CCCC,$00DDDD
- dc.l $00EEEE,$00FFFF
-
- ;===========================================================================;
- ; ALL CHIP RAM DATA HERE
- ;===========================================================================;
-
- SECTION "Graphics",DATA_C
-
- CNOP 0,4 ;Sprite must be 64bit aligned.
- Gfx_Circle1:
- INCBIN "GAMESLIB:data/CircleSpr1.raw"
-
- CNOP 0,4 ;Sprite must be 64bit aligned.
- Gfx_Circle2:
- INCBIN "GAMESLIB:data/CircleSpr2.raw"
-
- CNOP 0,4 ;Sprite must be 64bit aligned.
- Gfx_Circle3:
- INCBIN "GAMESLIB:data/CircleSpr3.raw"
-
- CNOP 0,4 ;Sprite must be 64bit aligned.
- Gfx_Circle4:
- INCBIN "GAMESLIB:data/CircleSpr3.raw"
-
-
-