| Chase H.Q. | Routines |
| Prev: AA38 | Up: Map | Next: AB33 |
|
Advances the helicopter's position and animation, or returns at once when helicopter_control is zero. The height descends 2 pixels a frame towards 97. The animation frame cycles 0 to 3 and the horizontal swing direction is negated each time it wraps, the direction accumulating into an offset which, added to the height, is the vertical base the drawing routine uses.
The horizontal position moves by however far road_pos has moved since last frame, then steps 8 pixels a frame towards the centre target - normally 112, the middle of the screen, though drive_helicopter sets it to -56 to fly the helicopter off the side of the screen - clamping rather than overshooting.
Used by the routine at main_loop.
|
||||
| move_helicopter | AAC6 | LD A,($A224) | Return if helicopter_control is zero | |
| AAC9 | AND A | |||
| AACA | RET Z | |||
|
Helicopter descends while moving to height 97 (smaller = lower).
|
||||
| AACB | LD A,$00 | A = <self modified> -- Self modified by AAD3 below; current vertical position, descending 2px per call toward the target height of 97 | ||
| AACD | CP $61 | Jump to mh_descended if A == 97 | ||
| AACF | JR Z,mh_descended | |||
| AAD1 | SUB $02 | Descend by 2 pixels | ||
| AAD3 | LD ($AACC),A | Self modify AACB above | ||
| mh_descended | AAD6 | LD C,A | C = A | |
| AAD7 | LD A,$00 | A = <self modified> -- Self modified below [counts 0..3] | ||
| AAD9 | INC A | A = (A + 1) & 3 | ||
| AADA | AND $03 | |||
| AADC | LD ($AAD8),A | Self modify AAD7 above | ||
| AADF | LD A,$01 | A = <self modified> -- Self modified by AAE5 below [direction 1 or $FF] | ||
| AAE1 | JR NZ,move_helicopter_0 | what are we testing here? | ||
| AAE3 | NEG | A = -A | ||
| AAE5 | LD ($AAE0),A | Self modify AADF above | ||
| move_helicopter_0 | AAE8 | ADD A,$00 | A += <self modified> -- Increment by old amount -- Self modified below | |
| AAEA | LD ($AAE9),A | Self modify above with new value of A | ||
| AAED | ADD A,C | A += C | ||
| AAEE | LD ($AA5B),A | Self modify 'LD A' @ AA5A | ||
| AAF1 | LD HL,($A26C) | HL = road_pos | ||
| AAF4 | LD D,H | DE = HL | ||
| AAF5 | LD E,L | |||
| AAF6 | LD BC,$0000 | BC = <self modified> -- Self modified by AAFC below, AB60 -- prev road pos? | ||
| AAF9 | AND A | Set flags | ||
| AAFA | SBC HL,BC | HL -= BC | ||
| AAFC | LD ($AAF7),DE | Self modify 'LD BC' above to load DE | ||
| AB00 | LD DE,($AA95) | Load DE from 'LD BC' @ draw_helicoper_part | ||
| AB04 | ADD HL,DE | HL += DE | ||
| AB05 | PUSH HL | Preserve HL | ||
| AB06 | LD DE,$0070 | Set DE to <self modified> | ||
| AB09 | LD B,$00 | Clear top of BC | ||
| AB0B | AND A | Clear carry | ||
| AB0C | SBC HL,DE | HL -= DE | ||
| AB0E | POP HL | Restore HL | ||
| AB0F | JR Z,move_helicopter_4 | |||
| AB11 | LD A,$08 | A = 8 | ||
| AB13 | PUSH AF | Preserve AF | ||
| AB14 | JP M,move_helicopter_1 | |||
| AB17 | DEC B | B-- | ||
| AB18 | NEG | A = -A | ||
| move_helicopter_1 | AB1A | LD C,A | C = A | |
| AB1B | ADD HL,BC | HL += BC | ||
| AB1C | PUSH HL | Preserve HL | ||
| AB1D | AND A | Clear carry | ||
| AB1E | SBC HL,DE | HL -= DE | ||
| AB20 | POP HL | Restore HL | ||
| AB21 | JP M,move_helicopter_2 | |||
| AB24 | POP AF | Restore AF | ||
| AB25 | JP P,move_helicopter_4 | |||
| AB28 | JR move_helicopter_3 | |||
| move_helicopter_2 | AB2A | POP AF | Restore AF | |
| AB2B | JP M,move_helicopter_4 | |||
| move_helicopter_3 | AB2E | EX DE,HL | Put DE centre value into HL | |
| move_helicopter_4 | AB2F | LD ($AA95),HL | Self modify 'LD BC' @ draw_helicoper_part | |
| AB32 | RET | Return | ||
| Prev: AA38 | Up: Map | Next: AB33 |