|  | Routines | 
| Prev: F5AD | Up: Map | Next: F6A6 | 
| 
Used by the routine at F7C7.
 | ||||
| 
First, work out how much coal has been collected.
 | ||||
| F64D | XOR A | Start the count of coal items at 0. | ||
| F64E | LD HL,$964C | Look at the buffer at 964D. | ||
| F651 | LD B,$40 | 40 items to look at. | ||
| F653 | INC HL | Has the next bit of coal been collected? | ||
| F654 | BIT 7,(HL) | |||
| F656 | JR NZ,$F659 | No, so move on. | ||
| F658 | INC A | Otherwise, increment the count of collected coal. | ||
| F659 | DJNZ $F653 | Loop back round to look at the next coal data. | ||
| F65B | LD ($F7D5),A | Set this as the number of collected coal pieces. | ||
| 
Now, get the wall flags.
 | ||||
| F65E | LD IX,$F7D1 | Set IX to the wall flags at F7D1. | ||
| F662 | CP $10 | Have 16 pieces of coal being collected? | ||
| F664 | JR Z,$F682 | Jump if so. | ||
| F666 | CP $20 | Have 32? | ||
| F668 | JR Z,$F68E | Jump if so. | ||
| F66A | CP $30 | Have 48? | ||
| F66C | JR Z,$F69A | Jump if so. | ||
| F66E | CP $40 | Have 64? | ||
| F670 | RET NZ | Return if not. | ||
| 
Handle collecting 64 pieces of coal.
 | ||||
| F671 | LD A,($9649) | |||
| F674 | CP $14 | |||
| F676 | JR NZ,$F67D | |||
| 
There are no walls in this room.
 | ||||
| F678 | SET 0,(IX+$00) | Reset the flag and exit. | ||
| F67C | RET | |||
| 
Handle collecting 64 pieces of coal (2).
 | ||||
| F67D | SET 2,(IX+$00) | |||
| F681 | RET | |||
| 
Handle collecting 16 pieces of coal.
 | ||||
| F682 | LD A,($9649) | Is Monty in room 6? | ||
| F685 | CP $06 | |||
| F687 | JR Z,$F678 | Exit if not. | ||
| F689 | SET 5,(IX+$00) | Set bit 5 (room 6) | ||
| F68D | RET | |||
| 
Handle collecting 32 pieces of coal.
 | ||||
| F68E | LD A,($9649) | |||
| F691 | CP $0B | |||
| F693 | JR Z,$F678 | |||
| F695 | SET 4,(IX+$00) | |||
| F699 | RET | |||
| 
Handle collectiong 48 pieces of coal.
 | ||||
| F69A | LD A,($9649) | |||
| F69D | CP $0F | |||
| F69F | JR Z,$F678 | |||
| F6A1 | SET 3,(IX+$00) | |||
| F6A5 | RET | |||
| Prev: F5AD | Up: Map | Next: F6A6 |