basic item collision detection

This commit is contained in:
alpine9000
2016-05-03 20:24:54 +10:00
parent bb8af65d67
commit 3b77fd8eaf
10 changed files with 121 additions and 19 deletions
+6 -3
View File
@@ -63,7 +63,7 @@ IMAGES=foreground.png \
IMAGEDATA=$(addprefix out/, $(IMAGES:.png=.bin))
VASM_EXTRA_ARGS=-DTIMING_TEST=0
VASM_EXTRA_ARGS=-DTIMING_TEST=0 -DSFX=1
#SYMBOL_INFO=-M
LINKER_OPTIONS=-T link.script.x
@@ -170,10 +170,13 @@ out/falling.raw: assets/falling.wav
out/jump.raw: assets/jump.wav
sox -v 0.98 assets/jump.wav -c 1 -r 13000 -b 8 out/jump.raw
out/main.o: $(IMAGEDATA) out/background-map.s out/foreground-map.s Makefile link.script.x out/playarea_fade.s out/flags_fade.s out/panelFade.s out/tileFade.s out/jump.raw out/falling.raw
out/chaching.raw: assets/chaching.wav
sox -v 0.98 assets/chaching.wav -c 1 -r 13000 -b 8 out/chaching.raw
out/main.o: $(IMAGEDATA) out/background-map.s out/foreground-map.s Makefile link.script.x out/playarea_fade.s out/flags_fade.s out/panelFade.s out/tileFade.s out/jump.raw out/falling.raw out/chaching.raw
setuptiming:
$(eval VASM_EXTRA_ARGS="-DTIMING_TEST=1")
$(eval VASM_EXTRA_ARGS=-DTIMING_TEST=1 -DSFX=1)
echo $(VASM_EXTRA_ARGS)
timing: setuptiming all
+4
View File
@@ -41,8 +41,12 @@ p61exec =0 ;0 if execbase is destroyed, such as in a trackmo.
p61fade =0 ;enable channel volume fading from your demo
if SFX=1
channels=3 ;<4 for game sound effects in the higher channels. Incompatible
; with splitchans/split4.
else
channels=4
endif
playflag=0 ;1=enable music on/off capability (at run-time). .If 0, you can
;still do this by just, you know, not calling P61_Music...
Binary file not shown.
+3
View File
@@ -29,11 +29,14 @@ BACKGROUND_SCROLL_TILE_INDEX_CONVERT equ 3
BACKGROUND_SCROLL_PIXELS equ 16
ITEM_SPRITE_HEIGHT equ 15
ITEM_SPRITE_SPACING equ 16
ITEM_SPRITE_NUM_VERTICAL_SPRITES equ 6
ITEM_SPRITE_VERTICAL_BYTES equ ((ITEM_SPRITE_HEIGHT*4)+4)
ITEM_SPRITE_BYTES equ (ITEM_SPRITE_NUM_VERTICAL_SPRITES*ITEM_SPRITE_VERTICAL_BYTES)+4
ITEM_SPRITE_VSTART equ 149
ITEM_NUM_SLOTS equ 8
ITEM_SPRITE_HORIZONTAL_START_PIXELS equ 32
ITEM_SPRITE_Y_COLLISION_OFFSET equ 1
;item control struct offsets
ITEM_X equ 0
+2 -2
View File
@@ -16,9 +16,9 @@
eJxjYBgFIwUYMzIw6DKi0qOAMnAeiD9S2UxuRoTZoHj6TmXzhxNAD39WRkj4nWSgXjpnZcROjwIEgIWzJBA/hvJhABYn6ACkjpy8AzMLnR4FxAFQeOFKw+TEyWj+oAzcBWJ5PGEGy0+w8owQgKmHmYmeH0fBKBgsAADYaBI9
</data>
</layer>
<layer name="items" width="100" height="8" visible="0">
<layer name="items" width="100" height="8">
<data encoding="base64" compression="zlib">
eJxjYBgFgw04MuLnE1JPCDgRqZ5YdcMdgMKX2DBGV+dKhD6QHucREtbUSFOwMMYVJy6MqGph6lxItJtU9SMduDISjhv0vERK3oLZQW0wlMs5kNuRMQiQU3/A1LiRERbk6KEmICX+Bktck1pnu1NRPal2j4JRQCsAAIdJC5A=
eJxjYBgFgw04MuLnE1JPCDgRqZ5YdcMdgMKX2DBGV+dKhD6QHucREtbUSFOwMMYVJy6MqGpJzR/YzBkFhIErI+G4QY8PUuOHmPxEKhjK5RzI7cgYBMipP2Bq3MgIC3L0UBOQEn+DJa5JLZPcqaie3PJwFIwCagMAfEgLSw==
</data>
</layer>
</map>
+13 -4
View File
@@ -1,7 +1,9 @@
include "includes.i"
xdef BigBang
xdef IncrementCounter
xdef RenderCounter
xdef pathwayRenderPending
xdef pathwayXIndex
xdef pathwayFadeCount
@@ -77,6 +79,7 @@ Entry:
move.w #(DMAF_SPRITE|DMAF_BLITTER|DMAF_SETCLR|DMAF_COPPER|DMAF_RASTER|DMAF_MASTER),DMACON(a6)
jsr InitialiseItems
Reset:
lea livesCounterText,a0
@@ -166,6 +169,8 @@ FadeInLoop:
bra FadeInLoop
GameLoop:
if 0
lea frameCounterText,a0
bsr IncrementCounter
lea frameCounterText,a1
@@ -173,7 +178,8 @@ GameLoop:
jsr RenderCounter
lea verticalBlankCounterText,a1
move.w #101,d0
jsr RenderCounter
jsr RenderCounter
endif
add.l #1,frameCount
move.l frameCount,d6
@@ -181,8 +187,10 @@ GameLoop:
jsr WaitVerticalBlank
if SFX=1
move.w #2,AUD3LEN(a6) ; set the empty sound for the next sample to be played
move.l #emptySound,AUD3LCH(a6)
endif
if TIMING_TEST=1
move.l #4000,d0
@@ -217,7 +225,7 @@ GameLoop:
bsr Update
jsr CheckPlayerMiss
jsr CheckPlayerMiss
bsr RenderNextForegroundFrame
jsr RenderNextBackgroundFrame
@@ -298,6 +306,7 @@ GameOver:
move.l #foregroundMap,startForegroundMapPtr
move.l #pathwayMap,startPathwayMapPtr
move.l #'0004',livesCounterText
jsr InitialiseItems
bra Reset
ShowMessagePanel:
@@ -642,7 +651,7 @@ PostMissedTile:
BigBang:
jsr PlayFallingSound
PlaySound Falling
jsr WaitVerticalBlank
move.w #2,AUD3LEN(a6) ; set the empty sound for the next sample to be played
+61 -2
View File
@@ -5,6 +5,16 @@
xdef RenderItemSprite
xdef ResetItems
xdef EnableItemSprites
xdef DetectItemCollisions
xdef InitialiseItems
DeleteItemSprite:
move.w #0,ITEM_SPRITE(a1)
move.w #0,ITEM_X(a1)
move.w #0,ITEM_LAGX(a1)
move.w ITEM_Y(a1),d2
bsr ClearItemSpriteData
rts
ScrollItemSprites:
move.w #ITEM_NUM_SLOTS-1,d1
@@ -26,6 +36,48 @@ ScrollItemSprites:
dbra d1,.loop
rts
DetectItemCollisions:
move.w #ITEM_NUM_SLOTS-1,d1
lea item1,a1
.loop:
cmp.w #0,ITEM_SPRITE(a1)
beq .skip
move.w spriteX,d2
move.w ITEM_X(a1),d3
move.w ITEM_Y(a1),d4
mulu.w #ITEM_SPRITE_SPACING,d4
add.w #ITEM_SPRITE_VSTART,d4
lsr.w #FOREGROUND_SCROLL_SHIFT_CONVERT,d3 ; convert to pixels
add.w #ITEM_SPRITE_HORIZONTAL_START_PIXELS,d3
cmp.w d2,d3
bne .skip
move.w spriteY,d2
add.w #ITEM_SPRITE_Y_COLLISION_OFFSET,d2
cmp.w d2,d4
bne .skip
bsr DeleteItemSprite
lea coinCounterText,a0
jsr IncrementCounter
bsr RenderCoinScore
PlaySound Chaching
.skip:
add.l #ITEM_STRUCT_SIZE,a1
dbra d1,.loop
rts
RenderCoinScore:
lea coinCounterText,a1
move.w #31,d0
jsr RenderCounter
rts
InitialiseItems:
move.l #"0000",coinCounterText
bsr RenderCoinScore
ResetItems:
lea item1,a1
move.w #ITEM_NUM_SLOTS-1,d1
@@ -34,6 +86,7 @@ ResetItems:
move.w #0,ITEM_X(a1)
move.w #0,ITEM_LAGX(a1)
move.w ITEM_Y(a1),d2
;; bsr ClearItemSpriteData
add.l #ITEM_STRUCT_SIZE,a1 ; multiply by 16 (item control structure size)
dbra d1,.loop1
move.l #0,itemSpritesEnabled
@@ -99,7 +152,7 @@ SetupItemSpriteData:
cmp.l #0,itemSpritesEnabled
beq .dontEnable
add.w #32,d0
add.w #ITEM_SPRITE_HORIZONTAL_START_PIXELS,d0
move.w d0,d1
andi #1,d1
move.b d1,3(a0) ;spriteControl
@@ -184,4 +237,10 @@ currentItemSprite:
nextSpriteSlot:
dc.w 0
dc.w 0
coinCounterText:
dc.b "0000"
dc.b 0
align 4
+6
View File
@@ -1,3 +1,9 @@
PlaySound: macro
if SFX=1
jsr Play\1Sound
endif
endm
WaitBlitter: macro
tst DMACONR(a6) ;for compatibility
.\@:
+7 -5
View File
@@ -157,22 +157,22 @@ ProcessJoystick:
cmp.b #3,joystickpos
bne .notRight
move.w #PLAYER_JUMP_PIXELS+PLAYER_PAUSE_PIXELS,spriteR
jsr PlayJumpSound
PlaySound Jump
.notRight:
cmp.b #1,joystickpos
bne .notUp
move.w #PLAYER_JUMP_PIXELS+PLAYER_PAUSE_PIXELS,spriteU
jsr PlayJumpSound
PlaySound Jump
.notUp:
cmp.b #5,joystickpos
bne .notDown
move.w #PLAYER_JUMP_PIXELS+PLAYER_PAUSE_PIXELS,spriteD
jsr PlayJumpSound
PlaySound Jump
.notDown:
cmp.b #7,joystickpos
bne .notLeft
move.w #PLAYER_JUMP_PIXELS+PLAYER_PAUSE_PIXELS,spriteL
jsr PlayJumpSound
PlaySound Jump
.notLeft:
.skip:
rts
@@ -341,7 +341,9 @@ CheckPlayerMiss:
move.l a3,startForegroundMapPtr
move.l a2,startPathwayMapPtr
.dontClearPathway:
.dontClearPathway:
jsr DetectItemCollisions
rts
+19 -3
View File
@@ -1,7 +1,9 @@
include "includes.i"
if SFX=1
xdef PlayJumpSound
xdef PlayFallingSound
xdef PlayChachingSound
PlayJumpSound:
lea jump(pc),a1
move.l a1,AUD3LCH(a6)
@@ -19,7 +21,16 @@ PlayFallingSound:
move.w #25,AUD3VOL(a6)
move.w #(endFalling-falling)/4,AUD3LEN(a6) ;Set length in words
move.w #(DMAF_AUD3|DMAF_SETCLR),DMACON(a6)
rts
rts
PlayChachingSound:
lea chaching,a1
move.l a1,AUD3LCH(a6)
move.w #256,AUD3PER(a6)
move.w #64,AUD3VOL(a6)
move.w #(endChaching-chaching)/2,AUD3LEN(a6) ;Set length in words
move.w #(DMAF_AUD3|DMAF_SETCLR),DMACON(a6)
rts
align 4
jump:
@@ -28,4 +39,9 @@ endJump:
align 4
falling:
incbin "out/falling.raw"
endFalling:
endFalling:
align 4
chaching:
incbin "out/chaching.raw"
endChaching:
endif