Prev: 47203 Up: Map Next: 47257
47233: Count Rooms Visited
Used by the routine at GameOver.
Counts the bits which are set in RoomsVisitedBitmap.
Output
A The number of rooms visited, less one
Count every set bit.
CountRoomsVisited 47233 LD E,0 Set the count to 0.
47235 LD BC,2080 Set a counter of 8 bits and 32 bytes.
47238 LD HL,23384 Point HL at RoomsVisitedBitmap.
CountRoomsVisited_NextByte 47241 PUSH BC Stash the counters on the stack.
47242 LD A,(HL) Fetch a byte of the table.
47243 INC HL Move on.
CountRoomsVisited_NextBit 47244 RRCA Move a bit into the carry flag.
47245 JR NC,CountRoomsVisited_CountBits Jump to CountRoomsVisited_CountBits if the bit is not set.
47247 INC E Count the room.
CountRoomsVisited_CountBits 47248 DJNZ CountRoomsVisited_NextBit Jump to CountRoomsVisited_NextBit until all of the bits have been done.
47250 POP BC Restore the counters from the stack.
47251 DEC C Count down the bytes.
47252 JR NZ,CountRoomsVisited_NextByte Jump to CountRoomsVisited_NextByte until all of the bytes have been done.
47254 LD A,E Copy the count to A.
47255 DEC A Subtract one from it.
47256 RET Return.
Prev: 47203 Up: Map Next: 47257