![]() |
Routines |
| Prev: 9BCE | Up: Map | Next: 9C0E |
|
Used by the routine at CountSectorPrograms.
Counts the installed programs in a sector of 10 by 10 cells and adds each one to the energy of the sector.
|
||||||||||
| CountSectorPrograms_Sector | 9BF3 | LD DE,$0040 | Each row of the map is 40 bytes long. | |||||||
| 9BF6 | LD C,$10 | There are 10 rows in the sector. | ||||||||
| CountSectorPrograms_Row | 9BF8 | LD B,$10 | There are 10 cells in each row. | |||||||
| 9BFA | PUSH HL | Save the address of the start of the row. | ||||||||
| CountSectorPrograms_Cell | 9BFB | LD A,(HL) | Fetch the cell. | |||||||
| 9BFC | CP $22 | Jump if it is an installed program, which is a cell with a current and an initial type of 02. | ||||||||
| 9BFE | JR Z,CountSectorPrograms_Installed | |||||||||
| CountSectorPrograms_Next | 9C00 | INC HL | Move on to the next cell. | |||||||
| 9C01 | DJNZ CountSectorPrograms_Cell | Loop back until the whole row has been checked. | ||||||||
| 9C03 | POP HL | Restore the address of the start of the row. | ||||||||
| 9C04 | ADD HL,DE | Move down to the next row of the map. | ||||||||
| 9C05 | DEC C | Count down the rows. | ||||||||
| 9C06 | JR NZ,CountSectorPrograms_Row | Loop back until the whole sector has been checked. | ||||||||
| 9C08 | RET | Return. | ||||||||
| CountSectorPrograms_Installed | 9C09 | EXX | Switch to the shadow registers. | |||||||
| 9C0A | INC (HL) | Add one to the energy of the sector. | ||||||||
| 9C0B | EXX | Switch back to the main registers. | ||||||||
| 9C0C | JR CountSectorPrograms_Next | Jump back to carry on with the row. | ||||||||
| Prev: 9BCE | Up: Map | Next: 9C0E |