| Chase H.Q. | Routines |
| Prev: B549 | Up: Map | Next: B627 |
|
The shadow goes down first, 56 pixels wide at y=120. The body index, 0..8, comes from the turn speed, the wobble in B and the pitch; that indexes the car parts table. The back buffer address is computed from the adjusted y and the body is drawn by plot_sprite or, when flip_car is set, plot_sprite_flipped. The windscreen, the wheels and the two side panels follow, each through draw_hero_car_part.
Used by the routine at animate_hero_car.
|
||||||||||
| draw_hero_car | B58E | AND A | If not turning (turn speed zero) then flip_car = 0 | |||||||
| B58F | JR NZ,dc_draw_shadow | |||||||||
| B591 | LD ($A251),A | |||||||||
| dc_draw_shadow | B594 | LD C,A | Preserve turn speed argument | |||||||
| B595 | PUSH BC | |||||||||
| B596 | LD HL,$CF8E | Point HL at hero_car_shadow [array of 3 x 4 bytes] then add (A * 4) | ||||||||
| B599 | RLCA | |||||||||
| B59A | RLCA | |||||||||
| B59B | LD C,A | |||||||||
| B59C | LD B,$00 | |||||||||
| B59E | ADD HL,BC | |||||||||
| B59F | LD DE,$7860 | D = 120 (vertical position in rows), E = 96 (horizontal position in pixels) | ||||||||
| B5A2 | LD C,$07 | C = 7 (56 pixels wide) | ||||||||
| B5A4 | CALL draw_hero_car_part | Call draw_hero_car_part to draw the shadow | ||||||||
| B5A7 | POP BC | Restore turn speed to C | ||||||||
|
117 is the car's usual vertical position. Smaller values make it move higher.
|
||||||||||
| B5A8 | LD A,$75 | D = 117 - <self modified car jump offset @ $B5AB> | ||||||||
| B5AA | SUB $00 | |||||||||
| B5AC | LD D,A | |||||||||
|
Build an index into hero_car_parts[]. Valid indices are 0 to 8 inclusive.
|
||||||||||
| B5AD | LD A,C | A = C (0/1/2, turn speed argument) + B (car wobble argument) + <self modified value $B5B0 == up/down facing (0/3/6 => level,up,down)> | ||||||||
| B5AE | ADD A,B | |||||||||
| B5AF | ADD A,$00 | |||||||||
| B5B1 | CP $09 | If A >= 9 A -= 9 -- clamping | ||||||||
| B5B3 | JR C,dc_draw_middle | |||||||||
| B5B5 | SUB $09 | |||||||||
| dc_draw_middle | B5B7 | LD HL,$CEDA | Point HL at hero_car_parts[A] (rows/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 | Preserve car vertical position. Only D is wanted, but the Z80 has no 8-bit push, so E rides along. The restored E is overwritten with 104 at $B5FE before anything reads it | ||||||||
| B5C5 | LD A,($A22A) | A = D - car_y - hero_car_part.y [car_y is the shift value used when a perp is caught] -- D here is (117 - car jump offset) from earlier | ||||||||
| B5C8 | ADD A,(HL) | |||||||||
| B5C9 | NEG | |||||||||
| B5CB | ADD A,D | |||||||||
| B5CC | LD E,A | Preserve A | ||||||||
| B5CD | AND $0F | D = (A & $F) | $F0 -- high byte of the back buffer plot address: the row within the character cell, in page $F0 | ||||||||
| B5CF | ADD A,$F0 | |||||||||
| B5D1 | LD D,A | |||||||||
| B5D2 | LD A,E | Restore A | ||||||||
| B5D3 | AND $70 | E = (A & $70) * 2 + 13 -- low byte of the same address: the character row scaled by the 32-byte row stride, plus column 13, where the car is drawn | ||||||||
| B5D5 | ADD A,A | |||||||||
| B5D6 | ADD A,$0D | |||||||||
| B5D8 | LD E,A | |||||||||
| B5D9 | INC HL | Advance to hero_car_part.rows | ||||||||
| B5DA | LD B,(HL) | Read rows | ||||||||
| B5DB | INC HL | Advance to hero_car_part.address | ||||||||
| B5DC | LD A,(HL) | Read low byte of address | ||||||||
| B5DD | INC HL | |||||||||
| B5DE | PUSH HL | Preserve HL. The LD H,(HL) below reads through HL and destroys it, so this is the last moment it is still a table pointer. It addresses the final byte of this 4-byte entry, so the INC after the POP lands on the next entry | ||||||||
| B5DF | PUSH DE | Preserve DE [back buffer plot address] | ||||||||
| B5E0 | LD H,(HL) | Read high byte of address | ||||||||
| B5E1 | LD L,A | HL now holds address of bitmap data | ||||||||
| B5E2 | LD A,$05 | Set A and DE to 5, which is the width & stride of the bitmap data in bytes | ||||||||
| B5E4 | LD E,A | |||||||||
| B5E5 | LD D,$00 | |||||||||
| B5E7 | EXX | Bank for plot_sprite (DE' = stride, HL' = address of bitmap data) | ||||||||
| B5E8 | POP HL | Restore the DE saved earlier [back buffer plot address] | ||||||||
| B5E9 | EX AF,AF' | Preserve A for the flip test | ||||||||
| B5EA | LD A,($A251) | If flip_car jump to dc_middle_flipped | ||||||||
| B5ED | AND A | |||||||||
| B5EE | JR NZ,dc_middle_flipped | |||||||||
| B5F0 | EX AF,AF' | Restore A | ||||||||
| B5F1 | CALL plot_sprite | Call plot_sprite -- A is (width in bytes) | ||||||||
| B5F4 | JR dc_cont | Jump to dc_cont | ||||||||
| dc_middle_flipped | B5F6 | EX AF,AF' | Restore A | |||||||
| B5F7 | DEC L | Adjust back buffer plot address to be a byte earlier | ||||||||
| B5F8 | CALL plot_sprite_flipped | Call plot_sprite_flipped | ||||||||
| dc_cont | B5FB | POP HL | Restore HL [points at second byte of hero_car_part address field] | |||||||
| B5FC | POP DE | Restore DE [car vertical position] | ||||||||
| B5FD | INC HL | Advance to the next hero_car_part entry | ||||||||
|
Draw the windscreen
|
||||||||||
| B5FE | LD E,$68 | Set (horz pos in px) to 104 | ||||||||
| B600 | LD C,$05 | Set (byte width) to 5 | ||||||||
| B602 | CALL draw_hero_car_part | Call draw_hero_car_part | ||||||||
|
Draw the wheels
|
||||||||||
| B605 | LD E,$68 | Set (horz pos in px) to 104 | ||||||||
| B607 | LD C,$05 | Set (byte width) to 5 | ||||||||
| B609 | CALL draw_hero_car_part | Call draw_hero_car_part | ||||||||
|
Draw left hand side
|
||||||||||
| B60C | LD A,($A251) | Check flip_car flag | ||||||||
| B60F | AND A | |||||||||
| B610 | LD C,$01 | Set (byte width) to 1 | ||||||||
| B612 | LD E,$60 | Set (horz pos in px) to 96 if not flipped | ||||||||
| B614 | JR Z,dc_flip_checked | Jump if not flipped | ||||||||
| B616 | LD E,$90 | Set (horz pos in px) to 144 if flipped | ||||||||
| dc_flip_checked | B618 | CALL draw_hero_car_part | Draws left side of car | |||||||
|
Draw right hand side
|
||||||||||
| B61B | LD C,$01 | Set (byte width) to 1 | ||||||||
| B61D | LD A,($A251) | Load flip_car and set flags | ||||||||
| B620 | AND A | |||||||||
| B621 | LD E,$60 | Set (horz pos in px) to 96 if flipped | ||||||||
| B623 | JR NZ,draw_hero_car_part | Jump if flipped | ||||||||
| B625 | LD E,$90 | Set (horz pos in px) to 144 if not flipped [then fall through] | ||||||||
| Prev: B549 | Up: Map | Next: B627 |