Prev: BC05 Up: Map Next: BC18
BC10: Count the rooms visited and print the percentage of the quest
Used by the routine at game_over_summary.
Counts the set bits in the 32-byte visited-room map at $5BE8 -- one bit per room number, set by flag_room_visited whenever a room is entered -- and keeps that count less one in $5BC6 for the rating.
The percentage is (rooms + 2 x charms) x 100 / 156, and 156 is 128 rooms plus 14 charms counted twice, so visiting every room and filling the cauldron is exactly 100. There is no divide: HL is a 16-bit fraction and A a BCD whole part, and adding 100/156 as a 16-bit fraction once per point carries into A, with DAA keeping A decimal. The final $28 is exactly what a perfect score falls short of 100 x 65536, so the maximum comes out as 100 rather than 99; it is also the only step that can carry into the hundreds.
Input
E on exit, rooms + 2 x charms
calc_and_display_percent BC10 LD E,$00 E = the count; B = 8 bits, C = 32 bytes, from $5BE8
BC12 LD BC,$0820
BC15 LD HL,$5BE8
Prev: BC05 Up: Map Next: BC18