| Chase H.Q. | Routines |
| Prev: B4F0 | Up: Map | Next: B58E |
|
Three pieces of debris fly off when the perp is rammed. The frame counter counts down from 9 and the routine returns without drawing anything once it reaches zero.
Each of the three sub-tables holds a piece counter cycling 0..3 followed by a nine entry table of y/x positions. The counter picks the bitmap frame, 12 bytes per frame, and the current frame offset picks the y/x pair. Each piece is drawn 6 bytes by 1 row, masked, through draw_masked_sprite.
Used by the routine at animate_hero_car.
|
||||
| draw_debris | B549 | LD A,$00 | Load <self modified> frame counter -- this is set to 9 to start the animation | |
| B54B | AND A | Return if the counter is zero (not animating) | ||
| B54C | RET Z | |||
| B54D | DEC A | Decrement counter | ||
| B54E | LD ($B54A),A | Self modify 'LD A' above with new counter value | ||
| B551 | RLCA | Double the frame counter, turning it into an offset in DE | ||
| B552 | LD E,A | |||
| B553 | LD D,$00 | |||
| B555 | LD ($B571),DE | Self modify 'LD HL' below with the result | ||
| B559 | LD B,$03 | 3 iterations | ||
| B55B | LD HL,$0000 | Load value <self modified by B503> -- an entry in debris_table | ||
| dd_loop | B55E | PUSH BC | Preserve BC (iterations) | |
| B55F | LD E,(HL) | Load address of debris sub-table into DE (e.g. debris_subtable_1) | ||
| B560 | INC HL | |||
| B561 | LD D,(HL) | |||
| B562 | INC HL | |||
| B563 | PUSH HL | Preserve HL (table addr) | ||
|
The first sub-table byte is this piece's own 0..3 frame counter; the 9 y/x pairs that follow are its positions, indexed by the debris frame offset.
|
||||
| B564 | LD A,(DE) | Cycle this byte 0-1-2-3 | ||
| B565 | INC A | |||
| B566 | AND $03 | |||
| B568 | LD (DE),A | |||
| B569 | RLCA | Multiply it by 12 (stride of bitmap_debris_1/2/3/4) | ||
| B56A | RLCA | |||
| B56B | LD C,A | |||
| B56C | RLCA | |||
| B56D | ADD A,C | |||
| B56E | LD C,A | |||
| B56F | INC DE | Advance to next byte in table | ||
| B570 | LD HL,$0000 | Load frame counter turned into offset <self modified> above | ||
| B573 | LD B,H | BC = C since C is set and H is always zero here | ||
| B574 | ADD HL,DE | Add table address to offset | ||
| B575 | LD D,(HL) | Load vertical position | ||
| B576 | INC HL | Load horizontal position | ||
| B577 | LD E,(HL) | |||
| B578 | LD HL,$CEAA | Load address of bitmap_debris_1, 2, 3 or 4 (bitmap data) | ||
| B57B | ADD HL,BC | |||
| B57C | LD BC,$0601 | 6 height (rows), 1 byte wide (masked) | ||
| B57F | EXX | Bank | ||
| B580 | LD BC,$0000 | B = 0 | ||
| B583 | LD E,$01 | E = 1 | ||
| B585 | EXX | Unbank | ||
| B586 | CALL draw_masked_sprite | Draw | ||
| B589 | POP HL | Restore HL (addr) | ||
| B58A | POP BC | Restore BC (iterations) | ||
| B58B | DJNZ dd_loop | Loop to dd_loop | ||
| B58D | RET | Return | ||
| Prev: B4F0 | Up: Map | Next: B58E |