home *** CD-ROM | disk | FTP | other *** search
- ;-------T-------T------------------------T----------------------------------;
- ;BOB example
- ;-----------
- ;This example blits a Worm from an IFF file onto a double buffered screen.
- ;The RESTORE mode is used to put the background back.
-
- INCDIR "INCLUDES:"
- INCLUDE "exec/exec_lib.i"
- INCLUDE "games/games_lib.i"
- INCLUDE "games/games.i"
-
- CALL MACRO
- jsr _LVO\1(a6)
- ENDM
-
- SECTION "BOB",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 .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 .Error_Blitter
-
- CALL AllocAudio ;Allocate the audio channels.
- tst.w d0
- bne .Error_Audio
-
- lea Screen(pc),a0 ;Initialise the screen.
- CALL AddScreen
- tst.w d0
- bne .Error_Screen
-
- ;---------------------------------------------------------------------------;
- ;Load a picture into the background of the screen.
-
- lea PIC_Background(pc),a1 ;Load the picture.
- move.l GS_MemPtr2(a0),PIC_Data(a1)
- CALL LoadPic
- tst.w d0
- bne .Error_Picture
-
- move.l PIC_Palette(a1),GS_Palette(a0)
- CALL UpdatePalette
-
- lea Screen(pc),a0
- CALL SwapBuffers
- moveq #BUFFER1,d0
- moveq #BUFFER2,d1
- CALL CopyBuffer
-
- ;---------------------------------------------------------------------------;
- ;Initialise the restorelist.
-
- moveq #2,d0 ;2 buffers.
- moveq #1,d1 ;1 BOB Entry.
- CALL InitRestore
- move.l d0,RestoreList
- beq.s .Error_RestoreList
-
- ;---------------------------------------------------------------------------;
- ;Load the BOB file in. This contains the graphics data that we are
- ;going to draw to the screen.
-
- lea PIC_Bobs(pc),a1 ;Load the picture that contains
- CALL LoadPic ;our BOB.
- tst.w d0
- bne.s .Error_BOBPic
-
- lea Screen(pc),a0 ;Initialise the BOB so that it is
- lea BOB_Rambo(pc),a1 ;ready for drawing.
- CALL InitBOB
- tst.w d0
- bne.s .Error_BOB
-
- lea SND_Rambo(pc),a0
- CALL InitSound
- tst.w d0
- bne.s .Error_Sound
-
- lea Screen(pc),a0
- CALL ShowScreen
-
- bsr.s Main
-
- .ReturnToDOS
- move.l GMS_Base(pc),a6
- lea SND_Rambo(pc),a0
- CALL FreeSound
- .Error_Sound
- lea BOB_Rambo(pc),a1
- CALL FreeBOB
- .Error_BOB
- lea PIC_Bobs(pc),a1
- CALL FreePic
- .Error_BOBPic
- move.l RestoreList(pc),d0
- CALL FreeRestore
- .Error_RestoreList
- lea PIC_Background(pc),a1
- CALL FreePic
- .Error_Picture
- lea Screen(pc),a0
- CALL DeleteScreen
- .Error_Screen
- CALL FreeAudio
- .Error_Audio
- 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
- ;===========================================================================;
-
- SPEED = 5
- FIRESPEED = 1
-
- Main: move.l GMS_Base(pc),a6
- CALL InitJoyPorts
- moveq #$00,d7
-
- .Loop lea Screen(pc),a0
- move.l RestoreList(pc),a1
- CALL Restore
-
- lea BOB_Rambo(pc),a1
- move.l RestoreList(pc),a2
- move.w #BUFFER2,d0
- CALL DrawBOB ;Blit the bob.
- CALL WaitSVBL ;Wait for VBL.
- CALL SwapBuffers
- addq.w #1,d7
-
- tst.b FireState
- bne.s .FireOn
-
- cmp.w #SPEED,d7
- ble.s .Move
- moveq #$00,d7
- addq.w #1,BOB_Frame(a1)
- cmp.w #9,BOB_Frame(a1)
- blt.s .Move
- clr.w BOB_Frame(a1)
- bra.s .Move
-
- .FireOn cmp.w #FIRESPEED,d7
- ble.s .Move
- moveq #$00,d7
- cmp.w #10,BOB_Frame(a1)
- bge.s .On
- move.w #9,BOB_Frame(a1)
-
- .On addq.w #1,BOB_Frame(a1)
- cmp.w #13,BOB_Frame(a1)
- blt.s .Move
-
- lea SND_Rambo(pc),a0
- CALL PlaySound
-
- btst #MB_LMB,d0
- beq.s .Off
- move.w #11,BOB_Frame(a1)
- bra.s .Move
-
- .Off clr.w BOB_Frame(a1)
- clr.b FireState
-
- .Move 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
- add.w d0,BOB_YPos(a1)
- asr.w #8,d1
- add.w d1,BOB_XPos(a1)
-
- btst #MB_LMB,d0
- beq.s .chkRMB
- st FireState ;Set fire to on.
- .chkRMB btst #MB_RMB,d0
- beq .Loop
- rts
-
- FireState:
- dc.b 0
- even
-
- ;===========================================================================;
- ; DATA
- ;===========================================================================;
-
- GMS_Name: dc.b "games.library",0
- even
- GMS_Base: dc.l 0
- RestoreList: dc.l 0
-
- AMT_PLANES = 5
-
- Screen: dc.l GSV1,0 ;Version header.
- dc.l 0,0,0 ;Screen memory 1/2/3.
- dc.l 0 ;Screen link.
- dc.l 0 ;Address of screen palette.
- dc.l 0 ;Address of rasterlist.
- dc.l 0 ;Amount of colours in palette.
- dc.w 320,256 ;Screen Width and Height.
- dc.w 320,320/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 LORES|COL12BIT ;Screen Mode.
- dc.w PLANAR ;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 PLANAR ;Destination
- dc.l GETPALETTE ;Parameters.
- dc.l .File
- .File dc.b "GAMESLIB:data/IFF.Pic320",0
- even
-
- ;---------------------------------------------------------------------------;
-
- PIC_Bobs:
- dc.l PCV1,0 ;Version header.
- dc.l 0 ;Source data.
- dc.w 0,0,0 ;Width, Height.
- dc.w AMT_PLANES ;Amount of Planes.
- dc.l 0 ;Amount of colours.
- dc.l 0 ;Source palette.
- dc.w LORES|COL12BIT ;Screen mode.
- dc.w PLANAR ;Destination
- dc.l BLITMEM ;Parameters.
- dc.l .File
- .File dc.b "GAMESLIB:data/IFF.Rambo",0
- even
-
- BOB_Rambo:
- dc.l BBV1,0 ;Structure version.
- dc.l 0,0 ;Graphics data.
- dc.w 0 ;Current frame.
- dc.l .Frames ;Pointer to frame list.
- dc.w 0 ;Modulo (skip in source) in bytes.
- dc.w 32,0,24 ;Width, Width in bytes, Height.
- dc.w 150,150 ;X/Y destination.
- dc.w 32,32 ;Border restriction LeftX,TopY.
- dc.w 320-32,256-32 ;Border restrictions RightX,EndY.
- dc.w 0,0 ;Amount of planes.
- dc.l 0 ;Size of plane, not required.
- dc.l GENMASKS|CLIP|RESTORE ;Attributes.
- dc.l PIC_Bobs ;Picture struct (Bob origin).
- .Frames dc.w 000,000,0,0 ;0 X/Y Graphic, X/Y Mask
- dc.w 032,000,0,0 ;1 ...
- dc.w 064,000,0,0 ;2
- dc.w 096,000,0,0 ;3
- dc.w 128,000,0,0 ;4
- dc.w 160,000,0,0 ;5
- dc.w 192,000,0,0 ;6
- dc.w 224,000,0,0 ;7
- dc.w 256,000,0,0 ;8
- dc.w 288,000,0,0 ;9
- dc.w 000,048,0,0 ;10
- dc.w 032,048,0,0 ;11
- dc.w 064,048,0,0 ;12
- dc.l -1
-
- SND_Rambo:
- dc.l SMV1,0 ;Structure version.
- dc.w CHANNEL1 ;Channel to play through.
- dc.w 0 ;Priority.
- dc.l 0 ;Sample header
- dc.l 0 ;Sample address.
- dc.l 0 ;Sample length.
- dc.w OCT_C2S ;Sample period.
- dc.w 100 ;Sample volume.
- dc.l 0 ;Sound attributes.
- dc.l .File ;Sound file.
- .File dc.b "GAMESLIB:data/SND.Rambo",0
- even
-
- ;---------------------------------------------------------------------------;
-
-