Prev: 8820 Up: Map Next: 896E
882B: Fire a shot from an object
Used by the routine at attacker_fires.
Fallen into from ground_object_fires (ground objects) and jumped to from attacker_fires (attackers), with the kind of shot in scratch_count. See ground_object_fires for what each kind does.
Input
IX The shooter's record
fire_from 882B PUSH IX A free record among 4-6, as IY
882D LD A,$03
882F LD IX,drop_records
8833 CALL find_free_record
8836 PUSH IX
8838 POP IY
883A POP IX
883C RET NZ
883D LD A,(IX+$11) The shooter between x $18 and $BF
8840 CP $C0
8842 RET NC
8843 CP $18
8845 RET C
8846 LD A,(scratch_count) The kind's flags (shot_kind_flags) to ground_cell
8849 LD HL,$89A6
884C CALL add_a_to_hl
884F LD A,(HL)
8850 LD (ground_cell),A
8853 LD A,(IX+$12) Bit 7: only from above line $58
8856 BIT 7,(HL)
8858 JR Z,fire_from_0
885A CP $58
885C RET NC
fire_from_0 885D BIT 6,(HL) Bit 6: only from line $50 down
885F JR Z,fire_from_1
8861 CP $50
8863 RET C
fire_from_1 8864 CALL swap_to_shot The new record at the shooter's place, cleared
8867 CALL free_object
886A LD (IX+$00),$1C Type $1C; +$10 = $20 (shot, top speed 1); the template's four bytes to +7, +9, +$13, +$14
886E LD (IX+$10),$20
8872 LD HL,$89AB
8875 LD A,(scratch_count)
8878 ADD A,A
8879 ADD A,A
887A CALL add_a_to_hl
887D LD A,(HL)
887E LD (IX+$07),A
8881 INC HL
8882 LD A,(HL)
8883 LD (IX+$09),A
8886 INC HL
8887 LD A,(HL)
8888 LD (IX+$13),A
888B INC HL
888C LD A,(HL)
888D LD (IX+$14),A
8890 LD A,(ground_cell) Its colour: the flags' low nibble in both halves of +$0D
8893 AND $0F
8895 LD B,A
8896 ADD A,A
8897 ADD A,A
8898 ADD A,A
8899 ADD A,A
889A OR B
889B LD (IX+$0D),A
889E LD (IX+$15),$38 +$15 = $38; move it by the template's numbers (move_object), which places it
88A2 CALL move_object
88A5 PUSH IY IX the shooter again, IY the shot
88A7 PUSH IX
88A9 POP IY
88AB POP IX
88AD LD A,(IY+$13) By the shot's frame
88B0 AND $0F
88B2 JP Z,fire_from_6
88B5 CP $05
88B7 JP Z,fire_from_4
88BA CP $06
88BC JP Z,fire_from_4
88BF CP $07
88C1 JP Z,fire_spray_down
88C4 CP $0A
88C6 JP Z,fire_from_3
88C9 LD H,(IX+$07) Others: X velocity half the shooter's...
88CC LD L,(IX+$08)
88CF SRA H
88D1 RR L
88D3 LD (IY+$07),H
88D6 LD (IY+$08),L
88D9 LD A,(ground_cell) ...and Y velocity 5 up, or down for flags bit 7
88DC LD (IY+$09),$05
88E0 BIT 7,A
88E2 JR NZ,fire_from_2
88E4 LD (IY+$09),$FB
This entry point is used by the routine at fire_spray_down.
fire_from_2 88E8 LD A,(IY+$00) Sound it, unless it was freed
88EB INC A
88EC CALL NZ,sound_fire
88EF RET
fire_from_3 88F0 LD (IY+$07),$06 Frame 10: 6 pixels a pass across, right for kind 7, left otherwise
88F4 LD (IY+$08),$00
88F8 LD (IY+$09),$00
88FC LD (IY+$0A),$00
8900 LD A,(scratch_count)
8903 CP $07
8905 JR Z,fire_from_2
8907 LD (IY+$07),$FA
890B JR fire_from_2
This entry point is used by the routine at fire_spray_down.
fire_from_4 890D LD A,(random_b) Frames 5 and 6, and the others' start: Y velocity 0, -2, -4 or -6 at random...
8910 LD B,A
8911 AND $06
8913 NEG
8915 LD C,A
8916 LD (IY+$09),A
8919 LD A,B ...X velocity -6 to +6 from the random byte's top three bits; 7 there, or no velocity at all, frees it
891A RLCA
891B RLCA
891C RLCA
891D AND $07
891F CP $07
8921 JP Z,fire_from_5
8924 SUB $03
8926 ADD A,A
8927 LD B,A
8928 LD (IY+$07),A
892B OR C
892C JR NZ,fire_from_2
fire_from_5 892E LD (IY+$00),$FF Free it
8932 JR fire_from_2
fire_from_6 8934 CALL fire_from_4 Frame 0: the spray; none frees it
8937 LD A,(IY+$09)
893A AND A
893B JR Z,fire_from_5
893D LD A,R One in eight: frame 9, the shield ball
893F AND $07
8941 JR NZ,fire_from_7
8943 LD (IY+$13),$09
fire_from_7 8947 LD (IY+$10),$25 Top speed 6, still a shot
894B LD A,(IY+$00)
894E INC A
894F JP Z,fire_from_2
8952 LD A,(extra_life_countdown) Every (lives x 4)th: frame 8, the extra life
8955 DEC A
8956 LD (extra_life_countdown),A
8959 JR NZ,fire_from_8
895B LD A,(lives)
895E ADD A,A
895F ADD A,A
8960 LD (extra_life_countdown),A
8963 LD (IY+$13),$08
fire_from_8 8967 LD (IY+$0F),$20 Gravity: Y acceleration $0020
896B JP fire_from_2
Prev: 8820 Up: Map Next: 896E