Prev: F518 Up: Map Next: F5A8
F51A: Invaders : Bullet Update.
Used by the routines at Update_Room00 and Invaders_Loop.
Input
Output
Inv_BulletUpdate F51A LD HL,(Inv_BulletX) See if a bullet exists, if not then do nothing.
F51D LD A,L
F51E CP $FF
F520 RET Z
F521 EX DE,HL
F522 LD HL,Invaders_Data Run through the data of each invader.
F525 LD B,$18
Inv_BulletUpdate_0 F527 LD A,(HL) Only do anything if invader is active. If it is check for collision.
F528 CP $FE
F52A JR NZ,Inv_BulletUpdate_4
Inv_BulletUpdate_1 F52C INC HL Move onto next invaders.
Inv_BulletUpdate_2 F52D INC HL
F52E DJNZ Inv_BulletUpdate_0
Update bullet.
F530 LD HL,(Inv_BulletX)
F533 LD (BitmapX),HL
F536 LD A,$BF Erase Knife and Fork
F538 CALL Bitmap16Draw
F53B LD A,H Decrease Y pos by three pixels.
F53C DEC A
F53D DEC A
F53E DEC A
F53F CP $30 See if at top of screen.
F541 JR C,Inv_BulletUpdate_3
F543 LD (Inv_BulletY),A Store new position.
F546 LD (BitmapY),A
F549 LD A,$BF Draw Knife and Fork
F54B CALL Bitmap16Draw
F54E RET
Disable bullet.
Inv_BulletUpdate_3 F54F LD A,$FF
F551 LD (Inv_BulletX),A
F554 RET
Check collision.
HL - Invader position.
DE - Bullet position.
Inv_BulletUpdate_4 F555 LD A,E See if bullet Y is within range of invader.
F556 SUB (HL)
F557 SUB $10
F559 CP $E0
F55B JR C,Inv_BulletUpdate_1 Next invader if not.
F55D INC HL Check against X position of bullet.
F55E LD A,D
F55F SUB (HL)
F560 SUB $10
F562 CP $E0
F564 JR C,Inv_BulletUpdate_2 Next invader if not.
Hit.
F566 DEC HL
F567 LD (BitmapX),DE Update position of bullet.
F56B LD A,$FF Set as disabled.
F56D LD (Inv_BulletX),A
F570 LD A,$BF Erase image.
F572 CALL Bitmap16Draw
F575 LD E,(HL) GEt X position of invader.
F576 LD (HL),$FE Set as disabled as well.
F578 INC HL Get y position.
F579 LD D,(HL)
F57A LD (BitmapX),DE Set position for draw.
F57E DEC HL See if draw needs to current frame or the next frame by checking where pointer is within the invaders data.
F57F LD DE,(Inv_DataPtr)
F583 DEC DE
F584 AND A
F585 SBC HL,DE If its before the current position use the next frame, if same or after use current frame.
F587 JR NC,Inv_BulletUpdate_5
F589 LD A,(Inv_NextFrame)
F58C JR Inv_BulletUpdate_6
Inv_BulletUpdate_5 F58E LD A,(Inv_CurrentFrame)
Inv_BulletUpdate_6 F591 CALL Bitmap16Draw Erase invader.
F594 LD HL,(BitmapX)
F597 CALL Arcade_CreateExplosions Special effects.
F59A LD HL,Invaders_PauseValue Speed up invaders slightly.
F59D DEC (HL)
F59E RET NZ
F59F CALL Invaders_NextStage Carry on if invaders left.
F5A2 LD SP,$0000
F5A5 JP Invaders_Loop
Prev: F518 Up: Map Next: F5A8