Prev: D259 Up: Map Next: D2F2
D260: Goldfish Game: Handler: Bubbles
Used by the routine at GoldfishGame.
GoldfishGame_Handler_Bubbles D260 LD IX,$DD2A Point IX at Data_Bubbles.
D264 LD B,$05 B=05 (maximum number of bubbles).
Handler_Bubbles_Loop D266 PUSH BC Stash the bubble counter on the stack.
D267 LD A,(IX+$0A) Jump to Handler_Bubbles_Generate if this bubble is inactive.
D26A CP $00
D26C JP Z,Handler_Bubbles_Generate
Erase the bubble before plotting it in its new position.
D26F LD A,$14 Set INVERSE: ON
D271 RST $10
D272 LD A,$01
D274 RST $10
Fetch the current pixel co-ordinates.
D275 LD C,(IX+$00) C=this bubble's horizontal pixel.
D278 LD B,(IX+$01) B=this bubble's vertical pixel.
Inverse PLOT erases the single-pixel bubble.
D27B CALL $22E5 Call PLOT_SUB.
Prepare to draw the moved bubble.
D27E LD A,$14 Set INVERSE: OFF
D280 RST $10
D281 LD A,$00
D283 RST $10
D284 LD C,(IX+$00) C=this bubble's horizontal pixel.
D287 LD B,(IX+$01) B=this bubble's vertical pixel.
The bubble always rises and accelerates as it drifts.
D28A INC C Move the bubble three pixels.
D28B INC C
D28C INC C
D28D LD A,(IX+$05) A=this bubble's drift velocity.
D290 INC (IX+$05) Increase the velocity so the bubble accelerates.
D293 ADD A,B Add the velocity to the other axis.
D294 LD B,A
D295 CP $70 Jump to Handler_Bubbles_Deactivate if the bubble has left the play area.
D297 JR NC,Handler_Bubbles_Deactivate
Store the new pixel co-ordinates.
D299 LD (IX+$00),C Write the new horizontal pixel back to the bubble.
D29C LD (IX+$01),B Write the new vertical pixel back to the bubble.
Draw the bubble.
Handler_Bubbles_Plot D29F CALL $22E5 Call PLOT_SUB.
Move onto the next bubble.
Handler_Bubbles_Next D2A2 POP BC Restore the bubble counter from the stack.
D2A3 LD DE,$000B Move IX on to the next eleven-byte bubble entry.
D2A6 ADD IX,DE
D2A8 DJNZ Handler_Bubbles_Loop Decrease the bubble counter by one and loop back to Handler_Bubbles_Loop until every bubble has been processed.
D2AA RET Return.
The bubble has finished its cycle, so deactivate it.
Handler_Bubbles_Deactivate D2AB LD (IX+$0A),$00 Mark this bubble inactive.
D2AF JR Handler_Bubbles_Next Jump to Handler_Bubbles_Next.
Maybe spawn a new bubble from the player.
Handler_Bubbles_Generate D2B1 CALL UpdateAnimationCounter Call UpdateAnimationCounter.
D2B4 CP $03 Jump to Handler_Bubbles_Next if the random roll is too low.
D2B6 JR C,Handler_Bubbles_Next
No bubbles once the player is out of air.
D2B8 LD A,($D33E) Jump to Handler_Bubbles_Next if *GoldfishGame_OxygenLevel shows no air left.
D2BB CP $00
D2BD JR Z,Handler_Bubbles_Next
Start the bubble from *GoldfishGame_PlayerAttributes.
D2BF LD BC,($DC0E) BC=*GoldfishGame_PlayerAttributes.
D2C3 LD A,$21 A=21.
D2C5 SUB C Invert the player column.
D2C6 SLA A Convert it to a pixel column (*08).
D2C8 SLA A
D2CA SLA A
D2CC ADD A,$06 A+=06.
D2CE LD (IX+$00),A Write the pixel column to the new bubble.
D2D1 LD A,B A=the player row.
D2D2 DEC A Move two rows up from the player.
D2D3 DEC A
D2D4 SLA A Convert that row into a pixel position.
D2D6 SLA A
D2D8 SLA A
D2DA CP $70 Jump to Handler_Bubbles_Next if that pixel is off the top.
D2DC JR NC,Handler_Bubbles_Next
Activate the bubble.
D2DE LD (IX+$01),A Write the pixel row to the new bubble.
D2E1 LD (IX+$0A),$01 Mark this bubble active.
D2E5 LD (IX+$05),$01 Start the bubble with a small rightward velocity.
Plot the newly spawned bubble.
D2E9 LD C,(IX+$00) C=the new bubble's horizontal pixel.
D2EC LD B,(IX+$01) B=the new bubble's vertical pixel.
D2EF JP Handler_Bubbles_Plot Jump to Handler_Bubbles_Plot.
Prev: D259 Up: Map Next: D2F2