Prev: B58E Up: Map Next: B648
B627: Draws a car part
One part is the shadow, the windscreen, the wheels or a side panel. The y-offset and the row count come from the graphic def, the part's y is subtracted from the car's y and draw_masked_sprite_rel_car does the drawing. flip_car picks the start offset in C': zero when unflipped, byte width minus one when flipped. The returned pointer is the following graphic def, so callers chain the parts together.
Used by the routine at draw_hero_car.
Input
C Byte width
D Y/Vertical position (in rows)
E X/Horizontal position (in pixels)
HL Address of graphic def (y_offset, nrows, data address)
Output
D Preserved
E Preserved
HL Address of next graphic def
draw_hero_car_part B627 LD A,D A = Y
B628 PUSH DE Preserve X,Y
B629 SUB (HL) D = Y - y_offset
B62A LD D,A
B62B INC HL Advance to nrows field
B62C LD B,(HL) Read nrows
B62D INC HL Advance to data address field
B62E LD A,(HL) Read data address while stacking HL+1
B62F INC HL
B630 PUSH HL
B631 LD H,(HL)
B632 LD L,A
B633 PUSH BC Preserve byte width over bank
D = y_offset, B = nrows, HL -> data
B634 EXX Bank
B635 POP BC Restore byte width
B636 LD A,($A251) Load flip_car into B
B639 LD B,A
B63A LD E,C E = byte width -- becomes E' which is source data stride
B63B DEC C C = byte width - 1
B63C AND A Test flip_car flag, if clear then C = 0 else C = (byte width - 1)
B63D JR NZ,dcp_cont
B63F LD C,A
dcp_cont B640 EXX Unbank
B641 CALL draw_masked_sprite_rel_car Draws all masked parts of the car (using car_y)
B644 POP HL Restore graphic def ptr
B645 INC HL Skip final byte - already consumed
B646 POP DE Restore X,Y
B647 RET Return
Prev: B58E Up: Map Next: B648