Prev: F09A Up: Map Next: F177
F0BF: Room Event : Invaders
Used by the routine at Update_Room00.
Input
Output
Handler_Invaders F0BF LD A,(Flag_LaserGun) See if the gun is charged.
F0C2 OR A
F0C3 JR Z,Handler_Invaders_1
F0C5 LD A,(Pocket1) See if gun is being carried.
F0C8 CP $0D
F0CA JR Z,Handler_Invaders_0
F0CC LD A,(Pocket2)
F0CF CP $0D
F0D1 JR NZ,Handler_Invaders_1
Handler_Invaders_0 F0D3 LD C,$30 Set position up high away from Wally.
F0D5 JR Handler_Invaders_3
Handler_Invaders_1 F0D7 LD A,(ObjSlot19) If the laser is in the room and is charged
F0DA CP $0D
F0DC JR NZ,Handler_Invaders_2
F0DE LD A,(Flag_LaserGun)
F0E1 OR A
F0E2 JR NZ,Handler_Invaders_0 Then set the invaders up high.
Handler_Invaders_2 F0E4 LD C,$70 Set position low down to block Wally.
Handler_Invaders_3 F0E6 LD A,(Flag_BaddyInit) See if invaders are intialised.
F0E9 OR A
F0EA JR NZ,Handler_Invaders_5
Initialised.
F0EC LD A,$01 Set as initialised.
F0EE LD (Flag_BaddyInit),A
F0F1 PUSH BC Store the Y position.
F0F2 LD HL,Invader_Init Copy start positions into current data slots.
F0F5 LD DE,Invader1
F0F8 LD BC,$0012
F0FB LDIR
F0FD POP BC
F0FE LD B,$06 Number of invaders to draw.
F100 LD IX,Invader1 Index to start of invader data.
Handler_Invaders_4 F104 LD L,(IX+$00) X position of current invader.
F107 LD A,(IX+$02) Y offset position of invader.
F10A ADD A,C Add Offset to Y position.
F10B LD H,A
F10C INC IX Next invader data pointer.
F10E INC IX
F110 INC IX
F112 LD A,(Invaders_bitmap) Get bitmap and draw invader.
F115 LD (BitmapX),HL
F118 CALL Bitmap16Draw
F11B DJNZ Handler_Invaders_4 Next invader.
F11D RET
Update
Handler_Invaders_5 F11E LD A,(Invaders_bitmap) Get bitmap and increase to next frame.
F121 INC A
F122 CP $9B Check for animation loop.
F124 JR NZ,Handler_Invaders_6
F126 LD A,$99 Reset animation if required.
Handler_Invaders_6 F128 LD E,A Store animation frame.
F129 LD B,$06
F12B LD IX,Invader1 Index to invader data.
Handler_Invaders_7 F12F LD L,(IX+$00) Get X, Y offset and DirX of invader.
F132 LD A,(IX+$02)
F135 LD D,(IX+$01)
F138 INC IX Update index to next invader.
F13A INC IX
F13C INC IX
F13E ADD A,C Add Y offset to Y position.
F13F LD H,A
F140 LD A,L check X position for left hand bounding edge.
F141 CP $32
F143 JR NZ,Handler_Invaders_9
Handler_Invaders_8 F145 LD A,D Reverse direction if edge of bounds if reached by X position.
F146 NEG
F148 LD D,A
F149 LD (IX-$02),D
F14C JR Handler_Invaders_10
Handler_Invaders_9 F14E CP $E8 check X position for right hand bounding edge.
F150 JR Z,Handler_Invaders_8
Handler_Invaders_10 F152 LD (BitmapX),HL Erase invader.
F155 LD A,(Invaders_bitmap)
F158 CALL Bitmap16Draw
F15B LD A,L Update X position in DirX direction.
F15C ADD A,D
F15D LD (IX-$03),A
F160 LD (BitmapX),A
F163 LD A,E Draw invader.
F164 CALL Bitmap16Draw
F167 PUSH BC Check for hitting Wally with 3 Hit points.
F168 PUSH DE
F169 LD B,$03
F16B CALL Wally_HitTest
F16E POP DE
F16F POP BC
F170 DJNZ Handler_Invaders_7 Next invader.
F172 LD A,E Store updated bitmap index.
F173 LD (Invaders_bitmap),A
F176 RET
Prev: F09A Up: Map Next: F177