Prev: B730 Up: Map Next: B832
B731: Fire, if the fire key is pressed
Used by the routine at draw_trail.
Called every pass from draw_ship. First the special beam's key (special_beam_key); then, if the fire key is held and the gun has cooled (6 passes, gun_cooling), a shot in the first free record of four. Its record is cleared (free_object), takes the ship's facing and world position, 8 pixels ahead of it (24 facing right), at the ship's shot line (place_shot), and is moved there. Then one of three kinds:
A laser (update_shot takes it on), with a zap (sound_crackle_b).
A missile, every other shot with add-on 8 (shot_alternator bit 0): type 0, the small 8 by 3 sprite of missile_frames, steady bright cyan, flying 8 pixels a pass from 32 ahead of the ship (8 facing left) and 3 lines higher, updated as an ordinary object by update_missile (+16 $80).
The special beam (shot_alternator bit 2, from special_beam_key): +15 $80, bright magenta, at x $90 going right or $60 going left, stepping 8 a pass; it holds the ship still (special_beam_on).
Both ran in the build's every-add-on session, though a missile was never fired facing left.
fire B731 CALL special_beam_key the special beam's key
B734 LD A,(gun_cooling) the gun cooling
B737 AND A
B738 JR Z,fire_0
B73A DEC A
B73B LD (gun_cooling),A
B73E RET
fire_0 B73F LD A,(controls_now) fire not pressed
B742 BIT 4,A
B744 RET Z
B745 LD A,$06 6 passes to the next; flip the alternator
B747 LD (gun_cooling),A
B74A LD A,(shot_alternator)
B74D XOR $01
B74F LD (shot_alternator),A
This entry point is used by the routine at special_beam_key.
fire_1 B752 LD IX,shot_records (entry from special_beam_key) four records; a missile's is free when its +0 is $FF
B756 LD A,$04
fire_2 B758 EX AF,AF'
B759 BIT 7,(IX+$16)
B75D JR NZ,fire_3
B75F LD A,(IX+$0B) a beam's when +B is 0
B762 AND A
B763 JR Z,fire_4
fire_3 B765 LD A,(IX+$00)
B768 INC A
B769 JR NZ,fire_6
fire_4 B76B CALL free_object clear it; the ship's facing; in use; the ship's position (place_shot)
B76E LD A,(ship_facing)
B771 LD (IX+$00),A
B774 LD (IX+$0B),$99
B778 CALL place_shot
B77B LD A,(shot_alternator) the special beam, or (every other shot) a missile
B77E BIT 2,A
B780 JP NZ,fire_10
B783 DEC A
B784 JP Z,fire_7
fire_5 B787 CALL move_object a laser: move it ahead of the ship; a zap
B78A LD (IX+$09),$00
B78E BIT 7,(IX+$15)
B792 RET NZ
B793 JP sound_crackle_b
fire_6 B796 LD BC,$0018 the next record; none free, no shot
B799 ADD IX,BC
B79B EX AF,AF'
B79C DEC A
B79D JR NZ,fire_2
B79F RET
fire_7 B7A0 LD A,(addon_eight) no add-on 8: a laser after all
B7A3 AND A
B7A4 JP Z,fire_5
B7A7 LD A,(IX+$07) 32 ahead facing right, 3 lines up; put it there
B7AA CP $08
B7AC JR Z,fire_8
B7AE LD (IX+$07),$20
fire_8 B7B2 LD A,(IX+$09)
B7B5 SUB $03
B7B7 LD (IX+$09),A
B7BA LD (IX+$08),$00
B7BE LD (IX+$0A),$00
B7C2 CALL move_object
B7C5 LD (IX+$09),$00
B7C9 LD (IX+$10),$27 8 a pass, the right way; type 0, bright cyan, a missile
B7CD LD A,(IX+$07)
B7D0 LD (IX+$07),$08
B7D4 CP $20
B7D6 JR Z,fire_9
B7D8 LD (IX+$07),$F8
fire_9 B7DC LD (IX+$00),$00
B7E0 LD (IX+$0D),$DD
B7E4 LD (IX+$15),$7F
B7E8 LD (IX+$16),$80
B7EC CALL clear_screen_fields nothing on the screen yet; a zap
B7EF LD (IX+$17),$F0
B7F3 JP sound_crackle_b
fire_10 B7F6 LD A,$80 the special beam: hold the ship; bright magenta
B7F8 LD (IX+$15),A
B7FB LD (special_beam_on),A
B7FE LD (IX+$0D),$43
B802 LD A,(ship_line) the shot line, and 9 down in the world
B805 ADD A,$09
B807 LD (IX+$0C),A
B80A LD A,(IX+$09)
B80D ADD A,$09
B80F LD (IX+$09),A
B812 LD A,(IX+$07) facing left: x $60, -8 a pass; facing right: x $90, +8 a pass
B815 ADD A,$08
B817 AND $20
B819 LD (IX+$07),A
B81C LD (IX+$12),$F8
B820 LD (IX+$0B),$60
B824 JP Z,fire_5
B827 LD (IX+$12),$08
B82B LD (IX+$0B),$90
B82F JP fire_5
Prev: B730 Up: Map Next: B832