![]() |
Routines |
| Prev: B863 | Up: Map | Next: B899 |
|
Used by the routine at GameOver.
Counts the bits which are set in RoomsVisitedBitmap.
|
||||||||
|
Count every set bit.
|
||||||||
| CountRoomsVisited | B881 | LD E,$00 | Set the count to 00. | |||||
| B883 | LD BC,$0820 | Set a counter of 08 bits and 20 bytes. | ||||||
| B886 | LD HL,$5B58 | Point HL at RoomsVisitedBitmap. | ||||||
| CountRoomsVisited_NextByte | B889 | PUSH BC | Stash the counters on the stack. | |||||
| B88A | LD A,(HL) | Fetch a byte of the table. | ||||||
| B88B | INC HL | Move on. | ||||||
| CountRoomsVisited_NextBit | B88C | RRCA | Move a bit into the carry flag. | |||||
| B88D | JR NC,CountRoomsVisited_CountBits | Jump to CountRoomsVisited_CountBits if the bit is not set. | ||||||
| B88F | INC E | Count the room. | ||||||
| CountRoomsVisited_CountBits | B890 | DJNZ CountRoomsVisited_NextBit | Jump to CountRoomsVisited_NextBit until all of the bits have been done. | |||||
| B892 | POP BC | Restore the counters from the stack. | ||||||
| B893 | DEC C | Count down the bytes. | ||||||
| B894 | JR NZ,CountRoomsVisited_NextByte | Jump to CountRoomsVisited_NextByte until all of the bytes have been done. | ||||||
| B896 | LD A,E | Copy the count to A. | ||||||
| B897 | DEC A | Subtract one from it. | ||||||
| B898 | RET | Return. | ||||||
| Prev: B863 | Up: Map | Next: B899 |