| Chase H.Q. | Routines |
| Prev: 9BCF | Up: Map | Next: 9CD6 |
|
The low byte of speed is rotated using the carry out of the high byte, halved twice, then BCD corrected with any remaining carry folded in. What comes out is the low pair of BCD digits of the increment; the higher pairs are zero.
Used by the routine at main_loop.
|
||||
| speed_score | 9CC2 | LD HL,($A24A) | Load speed into HL | |
|
The increment is ((speed low byte << 1 | bit 0 of the high byte) & $FF) / 4, rounded. Bit 7 of the low byte is lost, so the increment is about (speed mod 128) / 2 rather than speed / 8.
|
||||
| 9CC5 | LD A,L | Speed low byte | ||
| 9CC6 | RR H | Bottom bit of H moves to carry (H now unused) | ||
| 9CC8 | RLA | Rotate the carry in at bit 0; bit 7 of the speed low byte falls out | ||
| 9CC9 | SRL A | Divide by four | ||
| 9CCB | SRL A | |||
| 9CCD | LD E,A | [Needless move] | ||
| 9CCE | ADD A,$00 | Add carry in -- the bit shifted out by the second SRL, which rounds the divide by four to nearest | ||
| 9CD0 | DAA | BCD correction | ||
| 9CD1 | LD DE,$0000 | Zero high part of score increment | ||
| 9CD4 | JR increment_score | Exit via increment_score | ||
| Prev: 9BCF | Up: Map | Next: 9CD6 |