Prev: F3A0 Up: Map Next: F45D
F3A7: Routine at F3A7
Used by the routines at Update_Room00 and Invaders_Loop.
Input
Output
Inv_Update F3A7 LD HL,(Inv_DataPtr) Start of data.
Inv_Update_0 F3AA LD A,(HL) Get x pos.
F3AB CP $FE See if valid.
F3AD JR NZ,Inv_Update_1
F3AF INC HL If not valid, move onto next invader.
F3B0 INC HL
F3B1 JR Inv_Update_0
Inv_Update_1 F3B3 CP $FF Check for end of data.
F3B5 JR NZ,Inv_Update_3 If not the go on to handle invader.
F3B7 LD HL,Invaders_Data Reset start of first invader.
F3BA LD (Inv_DataPtr),HL
F3BD LD HL,(Inv_StartFrame)
F3C0 LD A,(Inv_NextFrame) Update frame to the next one.
F3C3 LD (Inv_CurrentFrame),A
F3C6 INC A Update to next frame.
F3C7 CP H See if frame has reached end frame.
F3C8 JR NZ,Inv_Update_2
F3CA LD A,L Reset to start if so.
Inv_Update_2 F3CB LD (Inv_NextFrame),A Store updated frame.
F3CE LD A,(Invaders_ChangeDirFlag)
F3D1 ADD A,A
F3D2 LD (Inv___Flag),A
F3D5 OR A
F3D6 RET Z
F3D7 XOR A Reset flag.
F3D8 LD (Invaders_ChangeDirFlag),A
F3DB LD A,(Invaders_CurrentDir) Change direction.
F3DE NEG
F3E0 LD (Invaders_CurrentDir),A
F3E3 RET
Inv_Update_3 F3E4 LD C,A X position.
F3E5 INC HL
F3E6 LD B,(HL) Y position.
F3E7 INC HL
F3E8 LD (Inv_DataPtr),HL Set pointer to next invader.
F3EB DEC HL Push address back to current invader.
F3EC DEC HL
F3ED LD (BitmapX),BC Set draw to position.
F3F1 LD A,(Invaders_CurrentDir) Get direction and update X position in direction.
F3F4 ADD A,C
F3F5 LD C,A
F3F6 LD (HL),A
F3F7 CP $E8 Check for right hand end of screen reached.
F3F9 JR NZ,Inv_Update_5
Inv_Update_4 F3FB LD A,$01 If reached, change direction for all invaders.
F3FD LD (Invaders_ChangeDirFlag),A
F400 JR Inv_Update_6
Inv_Update_5 F402 CP $08 Check for left hand end of screen reached.
F404 JR Z,Inv_Update_4 Change direction if so.
Inv_Update_6 F406 LD A,(Inv___Flag)
F409 ADD A,B
F40A LD B,A
F40B CP $A0
F40D JR C,Inv_Update_7
F40F LD A,$01
F411 LD (DeathFlag),A
Draw invader
Inv_Update_7 F414 INC HL Store any change in the Y position.
F415 LD (HL),B
F416 LD A,(Inv_CurrentFrame) Erase invader with previous frame.
F419 CALL Bitmap16Draw
F41C LD (BitmapX),BC Draw invader at new position and new frame.
F420 LD A,(Inv_NextFrame)
F423 CALL Bitmap16Draw
F426 LD HL,(BitmapX) Get draw position again and check for hitting Wally.
F429 LD B,$02
F42B CALL Wally_HitTest
F42E LD HL,(BitmapX) Get position again.
F431 LD A,R Create a random number.
F433 CP $08 If great or equal to 8 then end.
F435 RET NC
Drop a bomb.
F436 EX DE,HL
F437 LD B,$03 number of bombs.
F439 LD HL,Arcade_BombData Start of bomb data.
Bombs, look for an empty slot.
Inv_Update_8 F43C LD A,(HL) Get x position.
F43D CP $FF See if bomb is active.
F43F JR Z,Inv_Update_9 If not, create one.
F441 INC HL If so, move onto next bomb.
F442 INC HL
F443 INC HL
F444 DJNZ Inv_Update_8
F446 RET
Bomb, empty slot found.
Inv_Update_9 F447 LD (HL),E Store position.
F448 INC HL
F449 LD (HL),D
F44A INC HL
F44B EX DE,HL
F44C LD HL,$F45D Get the next bitmap within the range of ($c0 ~ $c6)
F44F INC (HL)
F450 LD A,(HL)
F451 CP $C7
F453 JR NZ,Inv_Update_10
F455 LD A,$C0
F457 LD (HL),A
Inv_Update_10 F458 LD (DE),A Store the frame for this bomb.
F459 CALL Bitmap16Draw Draw bomb.
F45C RET
Prev: F3A0 Up: Map Next: F45D