Prev: 9B4D Up: Map Next: 9CC5
9BA7: Handle Rex Dead - Last live explossion
Used by the routine at 9683.
9BA7 LD A,($A1FC) Jump back if not the last live
9BAA OR A
9BAB JP NZ,$968F
9BAE LD IY,$9CFD Set IY to the address for explosion data position and index graphic data
9BB2 LD B,$10 Set B the number of explosions
9BB4 PUSH BC Save BC
9BB5 LD A,(IY+$00) Set A the index of explosion graphic data
9BB8 OR A if index = 0 jump forward to configure explosion position
9BB9 JP Z,$9C44
9BBC LD B,A Multiply index number by 72 (length of graphic data explosion)
9BBD LD DE,$0048
9BC0 CALL $C95B
9BC3 LD DE,$8490 Set A1CD to the address point for the current graphic data explosion
9BC6 ADD HL,DE
9BC7 LD ($A1CD),HL
9BCA LD A,(IY+$01) Set A248 the x-position for the explosion
9BCD LD ($A248),A
9BD0 LD A,(IY+$02) Set A the y-position for the explosion
9BD3 CP $A8 Jump forward to configure (x-y) position if y-position is greater than 168 or less than 24
9BD5 JP NC,$9C44
9BD8 CP $18
9BDA JP C,$9C44
9BDD LD ($A249),A Set A249 the y-position of explosion
9BE0 LD A,$03 Set A24A the width in bytes for the sprite
9BE2 LD ($A24A),A
9BE5 LD A,$18 Set A24B the height in pixels of the sprite
9BE7 LD ($A24B),A
9BEA LD A,$FF Set A1CC the entity type for explosion
9BEC LD ($A1CC),A
9BEF XOR A Set A the facing direction to right
9BF0 CALL $B296 Draw the explosion
9BF3 LD A,(IY+$01) Set A248 the x-position for the explosion
9BF6 LD ($A248),A
9BF9 LD A,(IY+$02) Set A249 the y-position of explosion
9BFC LD ($A249),A
9BFF CALL $BC17 Compute address into attribute file based on (x,y) position
9C02 LD A,(IY+$00) Increment index of explosion
9C05 INC A
9C06 LD (IY+$00),A
9C09 CP $09 Jump forward and process next explosion if index is less than 9
9C0B JP NZ,$9C1C
9C0E LD (IY+$00),$00 Set index to 0
9C12 LD HL,($A22C) Set HL to the address into the attribute file for the explosion
9C15 LD DE,($A22E) Set DE to the address into the attribute buffer for the explosion
9C19 CALL $BBEA Reset attribute color when explosion ended
handle next explosion
9C1C LD DE,$0003 Point IY to the next explosion data
9C1F ADD IY,DE
9C21 POP BC Restore BC
9C22 DJNZ $9BB4 Jump back and process next explosion
9C24 LD A,($A1EF) Decrement explosion counter
9C27 DEC A
9C28 LD ($A1EF),A
9C2B CP $2F If explosion counter is 47 or 34 jump to change offset pair
9C2D CALL Z,$9CAA
9C30 CP $22
9C32 CALL Z,$9CAA
9C35 CP $19 If explosion counter is 25 or 23 jump to change offset pair
9C37 CALL Z,$9CB3
9C3A CP $17
9C3C CALL Z,$9CB3
9C3F OR A If counter is zero jump to handle finish game
9C40 JP Z,$9D68
9C43 RET
configure explosion position
9C44 LD A,($A1EF) If counter equals 16 jump to process next explosion
9C47 CP $10
9C49 JP C,$9C1C
9C4C CALL $A51D Set A a pseudo random number
9C4F CP $96 If number is less than $96 then jump to process next explosion
9C51 JP C,$9C1C
computes x-position of explosion
9C54 LD HL,($A1F0) Substract offset to x-position of Rex
9C57 LD A,($A24F)
9C5A SUB (HL)
9C5B LD E,A Set E the x-position for explosion
9C5C CALL $A530 Set A a pseudo random number
9C5F LD HL,($A1F0) Increment address into explosion data offsets
9C62 INC HL
9C63 AND (HL) And pattern for random number
9C64 SLA A Multiply by 8 this number and add to the previous partial computed position x-position of explosion = x-position of Rex - offset #1 + (random & offset #2)*8
9C66 SLA A
9C68 SLA A
9C6A ADD A,E
9C6B AND $F8 Set new position grid fixed
9C6D CP $F0 If x-position of explosion is greater than 230 jump forward and handle next explosion
9C6F JP NC,$9C1C
9C72 LD (IY+$01),A Set the new x-position into explosion data buffer
computes y-position of explosion
9C75 LD A,($A250) Substract offset to y-position of Rex
9C78 LD HL,($A1F0)
9C7B SUB (HL)
9C7C LD E,A Set E the x-position for explosion
9C7D CALL $A530 Set A a pseudo random number
9C80 LD HL,($A1F0) Increment address into explosion data offsets
9C83 INC HL
9C84 AND (HL) And pattern for random number
9C85 SLA A Multiply by 8 this number and add to the previous partial computed position y-position of explosion = y-position of Rex - offset #1 + (random & offset #2)*8
9C87 SLA A
9C89 SLA A
9C8B ADD A,E
9C8C AND $F8 Set new position grid fixed
9C8E LD (IY+$02),A Set the new y-position into explosion data buffer
9C91 LD (IY+$00),$01 Increment graphic data index of explosion
configure sound explosion
9C95 CALL $A51D Generate a random number between 1 and 3 for channel sound
9C98 AND $03
9C9A OR A
9C9B JP Z,$9C95
9C9E LD ($D528),A Set the random channel used for explosion
9CA1 LD DE,$D528 Set DE to address for explosion sound
9CA4 CALL $D37F Configure sound channel and mixer register
9CA7 JP $9C1C Jump back and process next explosion
Increment address into data pairs for Rex explosion
9CAA LD HL,($A1F0) Point A1F0 to the next pair of data to compute position
9CAD INC HL
9CAE INC HL
9CAF LD ($A1F0),HL
9CB2 RET
Decrement address into data pairs for Rex explosion
9CB3 LD HL,($A1F0) Point A1F0 to the previous pair of data to compute position
9CB6 DEC HL
9CB7 DEC HL
9CB8 LD ($A1F0),HL
9CBB RET
Decrement address into data pairs for FINAL BOSS explosion Used by the routine at 99E3.
9CBC LD HL,($A26A) Point A26A to the previous pair of data to compute position
9CBF DEC HL
9CC0 DEC HL
9CC1 LD ($A26A),HL
9CC4 RET
Prev: 9B4D Up: Map Next: 9CC5