Prev: 9BD6 Up: Map Next: 9D0E
9BDA: Draw the flickering beams, and test them against the ship
Used by the routine at scroll_landscape.
Called by scroll_landscape, not while map_rebuild is set. A beam crosses a screen whose landscape piece is $A6, at a fixed height in it, unless the thing that makes it has been shot: a bit in the player's record, found by map_square_bit and tested by a BIT instruction this routine writes into itself (the third after the CALL to map_square_bit). Each pass the old beams are rubbed out (erase_flicker_beam) and drawn again in the four screens around the view (the four pieces in map_window_pointer, in the order 0, 2, 1, 3; bit 0 the page row below, bit 1 the column to the right). A beam is a one-line row of bytes ORed onto the screen in the current pattern, rotated to follow the fine scroll, its characters coloured (fill_attributes) and its extent kept in flicker_beam_records for rubbing out (draw_flicker_beam draws it, place_flicker_beam places it).
The pattern changes when its timer runs out: half the time one of the eight at flicker_beam_patterns in a random bright colour, for 1-32 passes; otherwise none, for 1-16. A beam that touches the ship's box (40 by 16) damages it (beam_hits_ship), then not again for 16 passes.
All of it, the pattern changes included, ran in the build's sessions.
draw_beams 9BDA LD A,(map_rebuild) Not while map_rebuild is set
9BDD AND A
9BDE RET NZ
9BDF LD A,(beam_grace) Counting down after a hit: no box
9BE2 AND A
9BE3 JR Z,draw_beams_0
9BE5 DEC A
9BE6 LD (beam_grace),A
9BE9 JR draw_beams_1
draw_beams_0 9BEB LD A,(ship_line) The ship's box at collision_box
9BEE ADD A,$08
9BF0 LD H,A
9BF1 LD L,$64
9BF3 LD D,$10
9BF5 LD E,$28
9BF7 LD (collision_box),HL
9BFA LD (collision_box_size),DE
draw_beams_1 9BFE LD B,$04 No beam piece in view and none drawn: done
9C00 LD IY,flicker_beam_records
9C04 LD HL,map_window_tile_bytes
draw_beams_2 9C07 LD A,(HL)
9C08 CP $A6
9C0A JR Z,draw_beams_3
9C0C INC HL
9C0D LD A,(IY+$00)
9C10 AND A
9C11 JR NZ,draw_beams_3
9C13 INC IY
9C15 INC IY
9C17 INC IY
9C19 INC IY
9C1B DJNZ draw_beams_2
9C1D RET
draw_beams_3 9C1E LD IX,beam_state The timer
9C22 DEC (IX+$02)
9C25 JR NZ,draw_beams_7
9C27 LD (IX+$00),$00 Half the time, no beam
9C2B LD A,(random_a)
9C2E BIT 0,A
9C30 JR Z,draw_beams_5
9C32 LD A,(random_b) A random bright colour
9C35 AND $07
9C37 JR NZ,draw_beams_4
9C39 LD A,$05
draw_beams_4 9C3B LD B,A
9C3C ADD A,$40
9C3E LD (IX+$01),A
9C41 LD A,(random_a) A random pattern, for up to 32 passes
9C44 AND $07
9C46 XOR B
9C47 LD HL,flicker_beam_patterns
9C4A CALL add_a_to_hl
9C4D LD A,(HL)
9C4E LD (IX+$00),A
9C51 LD B,$1F
9C53 JR draw_beams_6
draw_beams_5 9C55 LD B,$0F Or none, for up to 16
draw_beams_6 9C57 LD A,(random_b) The timer
9C5A CPL
9C5B AND B
9C5C INC A
9C5D LD (IX+$02),A
draw_beams_7 9C60 XOR A None drawn yet; the four screens
9C61 LD ($9BD9),A
9C64 LD IY,flicker_beam_records
draw_beams_8 9C68 LD (row_count),A Rub out the beam drawn there last pass
9C6B LD A,(IY+$00)
9C6E AND A
9C6F JR Z,draw_beams_9
9C71 LD L,(IY+$00)
9C74 LD H,(IY+$01)
9C77 LD B,(IY+$02)
9C7A LD C,(IY+$03)
9C7D CALL erase_flicker_beam
draw_beams_9 9C80 LD (IY+$00),$00 None now
9C84 LD A,(row_count) This screen's row and column
9C87 LD HL,(view_column)
9C8A BIT 0,A
9C8C JR Z,draw_beams_10
9C8E INC H
draw_beams_10 9C8F BIT 1,A
9C91 JR Z,draw_beams_11
9C93 INC L
draw_beams_11 9C94 EX DE,HL
9C95 CALL map_square_bit Its beam-maker shot? (the BIT is written here)
9C98 LD A,B
9C99 ADD A,$46
9C9B LD ($9C9F),A
9C9E BIT 0,(HL)
9CA0 JR NZ,draw_beams_12
9CA2 LD HL,map_window_tile_bytes A beam piece, and a pattern
9CA5 LD A,(row_count)
9CA8 CALL add_a_to_hl
9CAB LD A,(HL)
9CAC CP $A6
9CAE JR NZ,draw_beams_12
9CB0 LD A,(IX+$00)
9CB3 AND A
9CB4 JR Z,draw_beams_12
9CB6 LD HL,(view_x) Where it is on the screen; none in view
9CB9 LD DE,(origin_x)
9CBD CALL place_flicker_beam
9CC0 LD A,B
9CC1 AND A
9CC2 JR Z,draw_beams_12
9CC4 CALL draw_flicker_beam Draw it
9CC7 LD HL,(sprite_screen_pos) Its width, for the colour and the test
9CCA LD A,(IY+$02)
9CCD LD (shot_colour_patch),A
9CD0 ADD A,A
9CD1 ADD A,A
9CD2 ADD A,A
9CD3 LD D,A
9CD4 LD A,(beam_grace) Not counting down: test it against the ship
9CD7 AND A
9CD8 PUSH HL
9CD9 CALL Z,beam_hits_ship
9CDC POP HL
9CDD LD A,(IX+$01) Colour it; a beam drawn
9CE0 LD ($B627),A
9CE3 LD DE,shot_colour_patch
9CE6 CALL fill_attributes
9CE9 OR $01
9CEB LD ($9BD9),A
draw_beams_12 9CEE INC IY Next screen
9CF0 INC IY
9CF2 INC IY
9CF4 INC IY
9CF6 LD A,(row_count)
9CF9 CP $03
9CFB JR Z,draw_beams_13
9CFD XOR $02
9CFF JP NZ,draw_beams_8
9D02 INC A
9D03 JP draw_beams_8
draw_beams_13 9D06 LD A,($9BD9) The sound when any was drawn (sound_beams)
9D09 AND A
9D0A RET Z
9D0B JP sound_beams
Prev: 9BD6 Up: Map Next: 9D0E