Prev: 9D43 Up: Map Next: 9DA9
9D53: Work out where a beam lies on the screen
Used by the routine at draw_beams.
Called by draw_beams. From the view's pixel position in its page (HL, from view_x), the origins (DE, from origin_x) and the page being drawn (draw_beams's quarter, in row_count: bit 0 the page below, bit 1 the page to the right), it works out the beam's x and line, kept in moved_x, and its length in bytes in B (0: not in view). The beam's pattern (from beam_state) is rotated right by the fine scroll (origin_x AND 7) into C, and HL becomes the beam's screen address (pixel_to_screen). A beam lies at page y $21, 9 lines below the top of its tile-$A6 cell.
place_flicker_beam 9D53 LD B,$00 Its line and x; its length; the pattern rotated with the scroll; its screen address
9D55 LD A,(row_count)
9D58 BIT 0,A
9D5A LD A,H
9D5B JR NZ,place_flicker_beam_0
9D5D CP $21
9D5F RET NC
9D60 LD A,$81
9D62 JR place_flicker_beam_1
place_flicker_beam_0 9D64 CP $21
9D66 RET C
9D67 LD A,$21
place_flicker_beam_1 9D69 ADD A,D
9D6A LD D,A
9D6B LD A,(row_count)
9D6E BIT 1,A
9D70 JR NZ,place_flicker_beam_2
9D72 LD A,$E8
9D74 SUB L
9D75 LD E,$08
9D77 JR place_flicker_beam_3
place_flicker_beam_2 9D79 LD A,$E8
9D7B ADD A,E
9D7C LD E,A
9D7D LD A,L
9D7E SUB $08
place_flicker_beam_3 9D80 LD (sprite_screen_pos),DE
9D84 LD B,A
9D85 AND $07
9D87 JR Z,place_flicker_beam_4
9D89 LD A,B
9D8A ADD A,$08
9D8C LD B,A
place_flicker_beam_4 9D8D SRL B
9D8F SRL B
9D91 SRL B
9D93 RET Z
9D94 LD C,(IX+$00)
9D97 LD A,(origin_x)
9D9A AND $07
9D9C JR Z,place_flicker_beam_6
place_flicker_beam_5 9D9E RRC C
9DA0 DEC A
9DA1 JR NZ,place_flicker_beam_5
place_flicker_beam_6 9DA3 LD HL,(sprite_screen_pos)
9DA6 JP pixel_to_screen
Prev: 9D43 Up: Map Next: 9DA9