Prev: 99D1 Up: Map Next: 9AE1
99E3: Handle FINAL BOSS destruction
Used by the routine at 9470.
99E3 LD IY,$9CFD Set IY to the address for explosion data position and index graphic data
99E7 LD B,$10 Set B the number of explosions
99E9 PUSH BC Save BC
99EA LD A,(IY+$00) Set A the index of explosion graphic data
99ED OR A if index = 0 jump forward to configure explosion position
99EE JP Z,$9A6B
99F1 LD B,A Multiply index number by 72 (length of graphic data explosion)
99F2 LD DE,$0048
99F5 CALL $C95B
99F8 LD DE,$8490 Set A1CD to the address point for the current graphic data explosion
99FB ADD HL,DE
99FC LD ($A1CD),HL
99FF LD A,(IY+$01) Set A248 the x-position for the explosion
9A02 LD ($A248),A
9A05 LD A,(IY+$02) Set A the y-position for the explosion
9A08 CP $A8 Jump forward to configure (x-y) position if y-position is greater than 168 or less than 24
9A0A JP NC,$9A6B
9A0D CP $18
9A0F JP C,$9A6B
9A12 LD ($A249),A Set A249 the y-position of explosion
9A15 LD A,$03 Set A24A the width in bytes for the sprite
9A17 LD ($A24A),A
9A1A LD A,$18 Set A24B the height in pixels of the sprite
9A1C LD ($A24B),A
9A1F LD A,$FF Set A1CC the entity type for explosion
9A21 LD ($A1CC),A
9A24 XOR A Set A the facing direction to right
9A25 CALL $9AE5 Draw the explosion
9A28 LD A,(IY+$01) Set A248 the x-position for the explosion
9A2B LD ($A248),A
9A2E LD A,(IY+$02) Set A249 the y-position of explosion
9A31 LD ($A249),A
9A34 CALL $9B4D Compute address into attribute file based on (x,y) position
9A37 LD A,(IY+$00) Increment index of explosion
9A3A INC A
9A3B LD (IY+$00),A
9A3E CP $09 Jump forward and process next explosion if index is less than 9
9A40 JP NZ,$9A51
9A43 LD (IY+$00),$00 Set index to 0
9A47 LD HL,($A22C) Set HL to the address into the attribute file for the explosion
9A4A LD DE,($A22E) Set DE to the address into the attribute buffer for the explosion
9A4E CALL $BBEA Reset attribute color when explosion ended
handle next explosion
9A51 LD DE,$0003 Point IY to the next explosion data
9A54 ADD IY,DE
9A56 POP BC Restore BC
9A57 DJNZ $99E9 Jump back and process next explosion
9A59 LD A,($A269) Decrement explosion counter
9A5C DEC A
9A5D LD ($A269),A
9A60 CP $82 If explosion counter is 130 then decrement data pairs for offset position
9A62 CALL Z,$9CBC
9A65 CP $64 If explosion counter is 100 then jump to draw final windows
9A67 JP Z,$9AD5
9A6A RET
configure explosion position
9A6B LD A,($A269) If explosion counter is less than 120 then jump to process next explosion
9A6E CP $78
9A70 JP C,$9A51
9A73 CALL $A51D If generated random number is less than 150 then jump to process next explosion
9A76 CP $96
9A78 JP C,$9A51
computes x-position of explosion
9A7B LD HL,($A26A) Set HL to the address into table offset for compute explosion location
9A7E LD A,$68 Substract x-offset to x-position of FINAL BOSS (104)
9A80 SUB (HL)
9A81 LD E,A Set E the x-position for explosion
9A82 CALL $A530 Set A a pseudo random number
9A85 LD HL,($A26A) Increment address into explosion data offsets
9A88 INC HL
9A89 AND (HL) And pattern for random number
9A8A SLA A Multiply by 8 this number and add to the previous partial computed position x-position of explosion = x-position of FINAL BOSS - offset #1 + (random & offset #2)*8
9A8C SLA A
9A8E SLA A
9A90 ADD A,E
9A91 AND $F8 Set new position grid fixed
9A93 CP $F0 If x-position of explosion is greater than 230 jump forward and handle next explosion
9A95 JP NC,$9A51
9A98 LD (IY+$01),A Set the new x-position into explosion data buffer
9A9B LD ($A248),A Set A248 the x-position of the explosion
computes y-position of explosion
9A9E LD A,$68 Substract y-offset to y-position of FINAL BOSS (104)
9AA0 LD HL,($A26A)
9AA3 SUB (HL)
9AA4 LD E,A Set E the x-position for explosion
9AA5 CALL $A530 Set A a pseudo random number
9AA8 LD HL,($A26A) Increment address into explosion data offsets
9AAB INC HL
9AAC AND (HL) And pattern for random number
9AAD 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
9AAF SLA A
9AB1 SLA A
9AB3 ADD A,E
9AB4 AND $F8 Set new position grid fixed
9AB6 LD (IY+$02),A Set the new y-position into explosion data buffer
9AB9 LD ($A249),A Set A249 the y-position of the explosion
9ABC LD (IY+$00),$01 Increment graphic data index of explosion
configure sound explosion
9AC0 CALL $A51D Generate a random number between 1 and 3 for channel sound
9AC3 AND $03
9AC5 OR A
9AC6 JP Z,$9AC0
9AC9 LD ($D528),A Set the random channel used for explosion
9ACC LD DE,$D528 Set DE to address for explosion sound
9ACF CALL $D37F Configure sound channel and mixer register
9AD2 JP $9A51 Jump back and process next explosion
Draw final windows
9AD5 LD IX,$AB6E Set IX tht text definition for end game text
9AD9 LD B,$05 Set B the number of lines to drae
9ADB CALL $A2E6 Draws end game windows
9ADE JP $9ADE Infinite loop
Prev: 99D1 Up: Map Next: 9AE1