Prev: 51299 Up: Map Next: 51400
51305: Handle Bag
Type 4: a bag falling in the bag stage. A hit adds 256 to Bounty and removes the bag. Otherwise the speeds in bytes 10 and 11 are added to the position, and the bag is removed if it leaves the screen.
Input
IX The address of the bag
Jump to HandleBag_Hit if the shot has hit the bag.
HandleBag 51305 CALL CheckShotHit Call CheckShotHit.
51308 JR C,HandleBag_Hit Jump to HandleBag_Hit if the shot is touching.
Move the bag sideways.
51310 LD L,(IX+1) Fetch the horizontal position.
51313 LD H,(IX+2)
51316 LD E,(IX+10) Fetch the horizontal speed.
51319 CALL AddSpeedToPosition Call AddSpeedToPosition.
51322 LD A,H Jump to RemoveBag if it is less than 16.
51323 CP 16
51325 JR C,RemoveBag
51327 CP 216 Jump to RemoveBag if it is 216 or more.
51329 JR NC,RemoveBag
51331 LD (IX+1),L Set the horizontal position.
51334 LD (IX+2),H
51337 LD L,H Make the pixel the screen position.
51338 LD H,0
51340 LD (41550),HL Set ScreenHorizontalPosition.
Move the bag down.
51343 LD L,(IX+3) Fetch the vertical position.
51346 LD H,(IX+4)
51349 LD E,(IX+11) Fetch the vertical speed.
51352 CALL AddSpeedToPosition Call AddSpeedToPosition.
51355 LD A,H Jump to RemoveBag if it is less than 48.
51356 CP 48
51358 JR C,RemoveBag
51360 LD (IX+3),L Set the vertical position.
51363 LD (IX+4),H
51366 LD L,H Make the pixel the screen position.
51367 LD H,0
51369 LD (41552),HL Set ScreenVerticalPosition.
51372 JP DrawScrollingObject_CountDrawn Jump to DrawScrollingObject_CountDrawn.
Add 256 to the bounty.
HandleBag_Hit 51375 LD BC,256 Set BC to 256.
51378 CALL AddToBounty Call AddToBounty.
51381 CALL DrawBountyDigits Call DrawBountyDigits.
Play the sound and remove the bag.
HandleBag_PlaySound 51384 LD A,4 Set SoundNotesLeft to 4.
51386 LD (41532),A
51389 LD HL,44751 Set SoundNoteAddress to SoundEffectNotes_BeforeBag.
51392 LD (41533),HL
RemoveBag 51395 LD (IX+0),0 Make the type 0 and return.
51399 RET
Prev: 51299 Up: Map Next: 51400