Prev: 838B Up: Map Next: 83CE
83A1: Move a landscape run's start for its first piece
Used by the routine at landscape_end_pieces.
Part of landscape_end_pieces, for the first piece (piece_extra_a). $90: B=7 when E=0; otherwise B is minus the scroll step across (the second byte of scroll_down) when that is positive, with the run one wider, and 0 when it is not. $91: B=7 unless E=0, when it is minus the scroll step. Other pieces leave B at 0.
L holds piece_extra_a itself here, so the AND 7 near the end always gives 0 for piece $90 and the run is always one wider on that path.
Input
E 0 or $AA
Output
B The shift in x
first_piece_shift 83A1 LD A,(piece_extra_a) Only pieces $90 and $91
83A4 CP $90
83A6 JR Z,first_piece_shift_0
83A8 CP $91
83AA RET NZ
83AB LD A,E $91
83AC AND A
83AD JR Z,first_piece_shift_1
83AF LD B,$07
83B1 RET
first_piece_shift_0 83B2 LD B,$07 $90 with E=0: 7
83B4 LD A,E
83B5 AND A
83B6 RET Z
83B7 LD B,$00 Otherwise 0 unless the scroll step is positive...
83B9 LD A,(scroll_across)
83BC BIT 7,A
83BE RET NZ
83BF AND A
83C0 RET Z
83C1 LD A,L ...then one wider
83C2 AND $07
83C4 JR NZ,first_piece_shift_1
83C6 INC C
first_piece_shift_1 83C7 LD A,(scroll_across) And B is minus the scroll step
83CA NEG
83CC LD B,A
83CD RET
Prev: 838B Up: Map Next: 83CE