| Ant Attack | Routines |
| Prev: 8570 | Up: Map | Next: 85C2 |
|
Used by the routine at DRAW_VIEW.
A bubble sort into ascending order, repeated until a pass swaps nothing.
|
||||
| SORT_SPRITES | 8580 | LD C,$00 | C = 0: nothing swapped. | |
| SORT_SPRITES_0 | 8582 | LD B,$07 | Seven comparisons a pass. | |
| 8584 | LD IX,SPRITE_LIST | |||
| SORT_SPRITES_1 | 8588 | LD L,(IX+$00) | This entry's place against the next's. | |
| 858B | LD H,(IX+$01) | |||
| 858E | LD E,(IX+$03) | |||
| 8591 | LD D,(IX+$04) | |||
| 8594 | LD A,D | |||
| 8595 | CP H | |||
| 8596 | JR NZ,SORT_SPRITES_2 | |||
| 8598 | LD A,E | |||
| 8599 | CP L | |||
| SORT_SPRITES_2 | 859A | JR NC,SORT_SPRITES_3 | ||
| 859C | LD (IX+$00),E | Out of order: swap places and frames, and note it. | ||
| 859F | LD (IX+$01),D | |||
| 85A2 | LD (IX+$03),L | |||
| 85A5 | LD (IX+$04),H | |||
| 85A8 | LD C,(IX+$02) | |||
| 85AB | LD A,(IX+$05) | |||
| 85AE | LD (IX+$02),A | |||
| 85B1 | LD (IX+$05),C | |||
| 85B4 | LD C,$01 | |||
| SORT_SPRITES_3 | 85B6 | INC IX | ||
| 85B8 | INC IX | |||
| 85BA | INC IX | |||
| 85BC | DJNZ SORT_SPRITES_1 | |||
| 85BE | DEC C | Swapped something: another pass. | ||
| 85BF | JR Z,SORT_SPRITES_0 | |||
| 85C1 | RET | |||
| Prev: 8570 | Up: Map | Next: 85C2 |