Prev: B549 Up: Map Next: B648
B58E: Draws the car
Used by the routine at main_loop_24.
Input
A TBD
draw_car B58E AND A If A is zero then flip = A
B58F JR NZ,draw_car_0
B591 LD ($A251),A
draw_car_0 B594 LD C,A C = A
B595 PUSH BC
B596 LD HL,$CF8E Point HL at ? then add (A * 4)
B599 RLCA
B59A RLCA
B59B LD C,A
B59C LD B,$00
B59E ADD HL,BC
B59F LD DE,$7860 Point DE at the car tiles [needs a proper label]
B5A2 LD C,$07 C = 7
B5A4 CALL sub_b627 Call sub_b627
B5A7 POP BC
117 is the car's vertical position.
B5A8 LD A,$75 117 - <self modified value $B5AB>
B5AA SUB $00
B5AC LD D,A D = A
B5AD LD A,C A = C + B + <self modified value $B5B0>
B5AE ADD A,B
B5AF ADD A,$00
B5B1 CP $09 If A >= 9 A -= 9
B5B3 JR C,draw_car_1
B5B5 SUB $09
draw_car_1 B5B7 LD HL,$CEDA Point HL at car definitions[A] (entries are 20 bytes wide)
B5BA ADD A,A
B5BB ADD A,A
B5BC LD C,A
B5BD ADD A,A
B5BE ADD A,A
B5BF ADD A,C
B5C0 LD C,A
B5C1 LD B,$00
B5C3 ADD HL,BC
B5C4 PUSH DE
B5C5 LD A,($A22A) A = var_a22a + *HL
B5C8 ADD A,(HL)
B5C9 NEG A=0-A
B5CB ADD A,D A+=D (aka A=D-A)
B5CC LD E,A E=A
B5CD AND $0F A = A & $0F
B5CF ADD A,$F0 A += $F0
B5D1 LD D,A D=A
B5D2 LD A,E A=E
B5D3 AND $70 A &= $70
B5D5 ADD A,A A = A*2
B5D6 ADD A,$0D A += $0D
B5D8 LD E,A E=A
B5D9 INC HL HL++
B5DA LD B,(HL) B=*HL++
B5DB INC HL
B5DC LD A,(HL) A=*HL++
B5DD INC HL
B5DE PUSH HL
B5DF PUSH DE
B5E0 LD H,(HL) H=*HL
B5E1 LD L,A L=A
B5E2 LD A,$05 A=5
B5E4 LD E,A E=A
B5E5 LD D,$00 D=0
B5E7 EXX
B5E8 POP HL
B5E9 EX AF,AF'
B5EA LD A,($A251) If flip jump to draw_car_perhaps_flipped
B5ED AND A
B5EE JR NZ,draw_car_perhaps_flipped
B5F0 EX AF,AF'
B5F1 CALL plot_sprite Call plot_sprite -- A is (how many pixels to plot - 1) / 8
B5F4 JR draw_car_cont Jump to draw_car_cont
draw_car_perhaps_flipped B5F6 EX AF,AF'
B5F7 DEC L L--
B5F8 CALL plot_sprite_flipped Call plot_sprite_flipped
draw_car_cont B5FB POP HL
B5FC POP DE
B5FD INC HL HL++
B5FE LD E,$68 E=$68 C=$05 (width) CALL sub_b627 draws the top (windscreen)
B600 LD C,$05
B602 CALL sub_b627
B605 LD E,$68 E=$68 C=$05 (width) CALL sub_b627 draws the bottom (wheels)
B607 LD C,$05
B609 CALL sub_b627
B60C LD A,($A251) Check flip flag
B60F AND A
B610 LD C,$01
B612 LD E,$60 unflipped
B614 JR Z,draw_car_2
B616 LD E,$90 flipped
draw_car_2 B618 CALL sub_b627 Draws left side of car
B61B LD C,$01 C = 1
B61D LD A,($A251) A = flip
B620 AND A Set flags
B621 LD E,$60 E = $60
B623 JR NZ,sub_b627 Jump if flipped
B625 LD E,$90 E = $90
sub_b627 B627 LD A,D A=D
B628 PUSH DE
B629 SUB (HL) D=A - *HL++
B62A LD D,A
B62B INC HL
B62C LD B,(HL) B=*HL++
B62D INC HL
B62E LD A,(HL) A=*HL++
B62F INC HL
B630 PUSH HL
B631 LD H,(HL) H=*HL
B632 LD L,A L=A
B633 PUSH BC
B634 EXX
B635 POP BC
B636 LD A,($A251) A=flip
B639 LD B,A B=A
B63A LD E,C E=C
B63B DEC C C--
B63C AND A If A==0 C=A
B63D JR NZ,draw_car_3
B63F LD C,A
draw_car_3 B640 EXX
B641 CALL sub_b67c_3 Draws right side of car
B644 POP HL
B645 INC HL
B646 POP DE
B647 RET Return
Prev: B549 Up: Map Next: B648