Prev: 8303 Up: Map Next: 838B
8347: Adjust a landscape run's start and width for its end pieces
Used by the routine at fill_behind_moving_piece.
Called by fill_behind_moving_piece (when the byte at piece_rise is 0) just before it draws a run of the landscape. piece_extra_a and piece_extra_b hold the codes of the run's first and last pieces (piece_ends sets them from the map); pieces $90-$93 are ends that need the run moved or widened, depending on the scroll step across (the second byte of scroll_down) and on E, which is 0 or $AA (fill_behind_moving_piece sets DE to 0 or $55AA, the dither's phase). B is added to the run's x and C to its width.
The width's base is the operand of the LD A,n near the end of this routine, which fill_behind_moving_piece writes as its own width less one. The result goes to piece_step_y and HL is left at the run's screen position from saved_speed with x moved.
How the pieces look and why each case needs its adjustment is not yet worked out; a first piece of $93 never came up in the build's sessions.
Input
IX The landscape strip's record (nothing is done when +1 is 0)
E 0 or $AA
Output
HL The run's screen position, x moved by B
A Its width, also in piece_step_y
landscape_end_pieces 8347 LD A,(IX+$01) Nothing for a strip whose +1 is 0
834A AND A
834B RET Z
834C LD HL,(piece_extra_a) The first and last pieces' codes; B and C from them (first_piece_shift, last_piece_width)
834F LD BC,$0000
8352 CALL first_piece_shift
8355 CALL last_piece_width
8358 LD A,L First piece $91 with the last below $80 and E=0: one wider
8359 CP $91
835B JR NZ,landscape_end_pieces_0
835D BIT 7,H
835F JR NZ,landscape_end_pieces_0
8361 LD A,E
8362 AND A
8363 JR NZ,landscape_end_pieces_0
8365 INC C
landscape_end_pieces_0 8366 LD A,L First piece $93: one wider when E=0, if the landscape scrolls this pass or saved_speed is not on a byte boundary
8367 CP $93
8369 JR NZ,landscape_end_pieces_2
836B LD A,(scroll_across)
836E AND A
836F JR NZ,landscape_end_pieces_1
8371 LD A,(saved_speed)
8374 AND $07
8376 JR Z,landscape_end_pieces_2
landscape_end_pieces_1 8378 LD A,E
8379 AND A
837A JR NZ,landscape_end_pieces_2
837C INC C
landscape_end_pieces_2 837D LD HL,(saved_speed) The run's position, x moved by B
8380 LD A,L
8381 ADD A,B
8382 LD L,A
8383 LD A,$00 Width = the base fill_behind_moving_piece wrote into the operand + C
8385 ADD A,C
8386 LD C,A
8387 LD (piece_step_y),A
838A RET
Prev: 8303 Up: Map Next: 838B