Prev: AE78 Up: Map Next: AF5E
AEB8: Searchlight: plot
This draws the searchlight.
Note: The game window attributes are located at (7,2)-(29,17) inclusive.
Used by the routine at nighttime.
Input
DE Pointer to screen attributes.
searchlight_plot AEB8 EXX Bank the screen attribute pointer supplied in DE
AEB9 LD DE,$AF3E Point DE at the searchlight bitmap searchlight_shape[0]
AEBC LD C,$10 16 iterations - one per row of searchlight bitmap
Start loop (outer)
searchlight_plot_0 AEBE EXX Switch register banks for this iteration
Note: I'm presently unable to discern the intent of the 'clip' flag.
AEBF LD A,($AE75) Fetch the clip flag
Stop if we're beyond the maximum Y
AEC2 LD HL,$5A40 Point HL at the screen attribute (0,18). This is max_y_attrs: the bottom of the game window
AEC5 AND A Is the clip flag zero?
AEC6 JP Z,searchlight_plot_1 Jump forward if so
AEC9 LD A,E Extract the X position from the screen attribute pointer
AECA AND $1F
AECC CP $16 Is it < 22?
AECE JR C,searchlight_plot_1 Jump forward if so
AED0 LD L,$20 Otherwise point HL at screen attribute (0,17)
searchlight_plot_1 AED2 SBC HL,DE Is the screen attribute pointer >= max_y_attrs?
AED4 RET C Return if so
AED5 PUSH DE Preserve the screen attribute pointer
Skip rows until we're in bounds
AED6 LD HL,$5840 Point HL at screen attribute (0,2). This is min_y_attrs: the first row that has the game window on it
AED9 AND A Is the clip flag zero?
AEDA JP Z,searchlight_plot_2 Jump forward if so
AEDD LD A,E Extract the X position from the screen attribute pointer
AEDE AND $1F
AEE0 CP $07 Is it < 7?
AEE2 JR C,searchlight_plot_2 Jump forward if so
AEE4 LD L,$20 Otherwise point HL at screen attribute (0,1)
searchlight_plot_2 AEE6 SBC HL,DE Is the screen attribute pointer >= min_y_attrs?
AEE8 JR C,searchlight_plot_3 Jump forward if so
AEEA EXX Otherwise we need to skip this row. Increment the (banked) shape pointer by a row
AEEB INC DE
AEEC INC DE
AEED EXX
AEEE JR next_row Then jump to the next row, skipping all of the plotting
searchlight_plot_3 AEF0 EX DE,HL Move shape pointer into DE
AEF1 EXX
AEF2 LD B,$02 Two iterations (two bytes per row)
Start loop (inner)
searchlight_plot_4 AEF4 LD A,(DE) Fetch eight pixels from the shape data
AEF5 EXX
AEF6 LD DE,$071E Preload D with 7 (left hand clip) and E with 30 (right hand clip)
AEF9 LD C,A Save the shape pixels to C
AEFA LD B,$08 Eight iterations (bits per byte)
Start loop (inner inner)
Clip right hand edge
searchlight_plot_5 AEFC LD A,($AE75) Fetch the clip flag
AEFF AND A Is the clip flag zero?
AF00 LD A,L Fetch the screen attribute pointer low byte (interleaved)
AF01 JP Z,searchlight_plot_6 Jump forward if so
AF04 AND $1F Get X
AF06 CP $16 Is it >= 22?
AF08 JR NC,dont_plot Jump to don't plot if so
AF0A JR searchlight_plot_8 Otherwise jump to plot test
searchlight_plot_6 AF0C AND $1F Get X
AF0E CP E Is it < 30? (E is 30 here, as set by AEF6)
AF0F JR C,searchlight_plot_8 Jump to plot test if so
AF11 EXX
Tight loop to increment DE by B
searchlight_plot_7 AF12 INC DE Skip the remainder of the shape's row
AF13 DJNZ searchlight_plot_7
AF15 EXX
AF16 JR next_row Jump to next_row
Clip left hand edge
searchlight_plot_8 AF18 CP D Is A >= 8? (AEF6 previously stored 7 in D)
AF19 JR NC,do_plot Jump to plot if so
dont_plot AF1B RL C Extract the next bit from shape's pixels
AF1D JR searchlight_plot_10 Jump to the next pixel
do_plot AF1F RL C Extract the next bit from shape's pixels
AF21 JP NC,searchlight_plot_9 Jump if the pixel is not set
AF24 LD (HL),$06 Set screen attribute to attribute_YELLOW_OVER_BLACK
AF26 JR searchlight_plot_10 (else)
searchlight_plot_9 AF28 LD (HL),$41 Set screen attribute to attribute_BRIGHT_BLUE_OVER_BLACK
searchlight_plot_10 AF2A INC HL Advance to the next pixel and attribute
AF2B DJNZ searchlight_plot_5 ...loop (inner inner)
AF2D EXX
AF2E INC DE Advance shape pointer
AF2F DJNZ searchlight_plot_4 ...loop (inner)
AF31 EXX
next_row AF32 POP HL
AF33 LD DE,$0020 Move the attribute pointer to the next scanline
AF36 ADD HL,DE
AF37 EX DE,HL
AF38 EXX
AF39 DEC C Decrement row counter
AF3A JP NZ,searchlight_plot_0 ...loop while row > 0 (outer)
AF3D RET Return
Searchlight circle shape.
searchlight_shape AF3E DEFB $00,$00
AF40 DEFB $00,$00
AF42 DEFB $00,$00
AF44 DEFB $01,$80
AF46 DEFB $07,$E0
AF48 DEFB $0F,$F0
AF4A DEFB $0F,$F0
AF4C DEFB $1F,$F8
AF4E DEFB $1F,$F8
AF50 DEFB $0F,$F0
AF52 DEFB $0F,$F0
AF54 DEFB $07,$E0
AF56 DEFB $01,$80
AF58 DEFB $00,$00
AF5A DEFB $00,$00
AF5C DEFB $00,$00
Prev: AE78 Up: Map Next: AF5E