| Chase H.Q. | Routines |
| Prev: F2A2 | Up: Map | Next: F2F1 |
|
This takes the current speed, halves it, then complements it, then quarters it (or eighths it if in high gear). It's then added to a base value to produce a divisor suitable for poking into the AY chip. If we're in a tunnel then an even lower base value is used. AY Channel C is used.
Lives at $80AA when relocated. Used by the routine at play_engine_or_turbo_sfx_128k.
|
||||
| engine_sfx_from_speed_128k | F2B6 | LD HL,($A24A) | Load speed into HL | |
| F2B9 | RR H | Move bottom bit of H to carry | ||
|
H is now zero since speed can never exceed 511.
|
||||
| F2BB | LD A,L | Get speed low byte | ||
| F2BC | RRA | Halve speed, shifting carry in as MSB | ||
|
This is now part of the pitch divisor that we'll set later.
|
||||
| F2BD | CPL | Invert the divisor (and the pitch) | ||
| F2BE | LD L,A | Widen to HL | ||
| F2BF | LD A,($A253) | Jump if in low gear | ||
| F2C2 | AND A | |||
| F2C3 | JR Z,esfs_low_gear | |||
|
We're in high gear.
|
||||
| F2C5 | SLA L | Double divisor in HL to lower the pitch | ||
| F2C7 | RL H | |||
| esfs_low_gear | F2C9 | SLA L | Quadruple divisor in HL to lower the pitch more | |
| F2CB | RL H | |||
| F2CD | SLA L | |||
| F2CF | RL H | |||
| F2D1 | LD A,($A23B) | Read tunnel_sfx | ||
| F2D4 | AND A | Set flags | ||
| F2D5 | LD DE,$0190 | Not-in-tunnel base divisor (~277Hz) | ||
| F2D8 | LD A,$0F | Not-in-tunnel volume | ||
| F2DA | JR Z,esfs_tone_chosen | Jump if tunnel_sfx was zero (not in tunnel) | ||
|
We're in the tunnel.
|
||||
| F2DC | LD DE,$0258 | In-tunnel base divisor (~185Hz) | ||
| F2DF | LD A,$0C | In-tunnel volume | ||
| esfs_tone_chosen | F2E1 | ADD HL,DE | Add speed divisor to base divisor | |
| F2E2 | LD ($A217),HL | Set Channel C pitch divisor (12-bit combined, fine and coarse registers) | ||
| F2E5 | LD ($A21D),A | Set Channel C volume | ||
| F2E8 | LD A,($A21A) | Set mixer to enable Tone C | ||
| F2EB | AND $3B | |||
| F2ED | LD ($A21A),A | |||
| F2F0 | RET | Return | ||
| Prev: F2A2 | Up: Map | Next: F2F1 |