| Ant Attack | Routines |
| Prev: 85FE | Up: Map | Next: 8681 |
|
Used by the routine at DRAW_VIEW.
For each object, last to first, its position relative to VIEW_ORIGIN is turned for the view and projected: the half-row is v - u - 2h and the column (u + v) / 2, where u and v are the turned coordinates and h the height. The place is height x 512 + half-row x 16 + column -- the height counting a whole pass of DRAW_SCENE -- and it goes into SPRITE_LIST with the sprite frame: the object's first frame, plus four times its animation frame, plus its facing relative to the view.
|
||||
| PROJECT_SPRITES | 8600 | LD IX,ANT5 | From the fifth ant back to the player; eight objects. | |
| 8604 | LD DE,(VIEW_ORIGIN) | |||
| 8608 | LD A,$08 | |||
| 860A | LD HL,SPRITE_LIST | |||
| PROJECT_SPRITES_0 | 860D | EX AF,AF' | ||
| 860E | PUSH HL | |||
| 860F | LD B,(IX+$02) | Its height. | ||
| 8612 | LD A,(IX+$00) | Its position relative to the view's origin. | ||
| 8615 | SUB E | |||
| 8616 | LD L,A | |||
| 8617 | LD A,(IX+$01) | |||
| 861A | SUB D | |||
| 861B | LD H,A | |||
| 861C | LD A,(VIEW) | Turn it for the view: swap x and y for views 1 and 3, and negate as the view needs. | ||
| 861F | RRA | |||
| 8620 | JR NC,PROJECT_SPRITES_1 | |||
| 8622 | LD C,H | |||
| 8623 | LD H,L | |||
| 8624 | LD L,C | |||
| 8625 | RRA | |||
| 8626 | JR NC,PROJECT_SPRITES_2 | |||
| 8628 | XOR A | |||
| 8629 | SUB L | |||
| 862A | LD L,A | |||
| 862B | JR PROJECT_SPRITES_4 | |||
| PROJECT_SPRITES_1 | 862D | RRA | ||
| 862E | JR NC,PROJECT_SPRITES_3 | |||
| 8630 | XOR A | |||
| 8631 | SUB L | |||
| 8632 | LD L,A | |||
| PROJECT_SPRITES_2 | 8633 | XOR A | ||
| 8634 | SUB H | |||
| 8635 | LD H,A | |||
| PROJECT_SPRITES_3 | 8636 | LD A,L | Raise it by its height. | |
| PROJECT_SPRITES_4 | 8637 | ADD A,B | ||
| 8638 | LD L,A | |||
| 8639 | LD A,H | |||
| 863A | SUB B | |||
| 863B | LD H,A | |||
| 863C | SUB L | The half-row, 0-31, or out of view. | ||
| 863D | JP PE,OFF_VIEW | |||
| 8640 | CP $20 | |||
| 8642 | JR NC,OFF_VIEW | |||
| 8644 | RLCA | Times 16, with the height above it. | ||
| 8645 | RLCA | |||
| 8646 | RLCA | |||
| 8647 | SLA A | |||
| 8649 | RL B | |||
| 864B | LD C,A | |||
| 864C | LD A,L | The column, 0-31 before halving, or out of view. | ||
| 864D | ADD A,H | |||
| 864E | JP PE,OFF_VIEW | |||
| 8651 | CP $20 | |||
| 8653 | JR NC,OFF_VIEW | |||
| 8655 | AND A | Into the place, plus one. | ||
| 8656 | RRA | |||
| 8657 | OR C | |||
| 8658 | LD C,A | |||
| 8659 | INC BC | |||
|
This entry point is used by the routine at OFF_VIEW.
|
||||
| PROJECT_SPRITES_5 | 865A | POP HL | Store the place. | |
| 865B | LD (HL),C | |||
| 865C | INC HL | |||
| 865D | LD (HL),B | |||
| 865E | INC HL | |||
| 865F | LD A,(VIEW) | The facing relative to the view. | ||
| 8662 | ADD A,(IX+$04) | |||
| 8665 | AND $03 | |||
| 8667 | LD C,A | |||
| 8668 | LD A,(IX+$08) | Bit 7 set: the frame outright... | ||
| 866B | AND A | |||
| 866C | JP M,PROJECT_SPRITES_6 | |||
| 866F | RLCA | ...otherwise the first frame, plus four times the animation frame, plus the facing. | ||
| 8670 | RLCA | |||
| 8671 | ADD A,(IX+$03) | |||
| 8674 | ADD A,C | |||
| PROJECT_SPRITES_6 | 8675 | LD (HL),A | ||
| 8676 | INC HL | |||
| 8677 | LD BC,$FFF0 | The object before: BC is -16, not an address. | ||
| 867A | ADD IX,BC | |||
| 867C | EX AF,AF' | |||
| 867D | DEC A | |||
| 867E | JR NZ,PROJECT_SPRITES_0 | |||
| 8680 | RET | |||
| Prev: 85FE | Up: Map | Next: 8681 |