Routines
 Prev: 8EF1 Up: Map Next: 8FC5
8F63: Draw the items in the current cavern and collect any that Willy is touching
Used by the routine at 870E.
Input
Output
8F63 XOR A Initialise the attribute of the last item drawn at 8074 to 0x00 (in case there are no items left to draw)
8F64 LD (\$8074),A
8F67 LD IY,\$8075 Point IY at the first byte of the first item definition at 8075
The item-drawing loop begins here.
8F6B LD A,(IY+\$00) Pick up the first byte of the item definition
8F6E CP \$FF Have we dealt with all the items yet?
8F70 JR Z,\$8FBA Jump if so
8F72 OR A Has this item already been collected?
8F73 JR Z,\$8FAE If so, skip it and consider the next one
8F75 LD E,(IY+\$01) Point DE at the address of the item's location in the attribute buffer at 5C00
8F78 LD D,(IY+\$02)
8F7B LD A,(DE) Pick up the current attribute byte at the item's location
8F7C AND \$07 Is the INK white (which happens if Willy is touching the item)?
8F7E CP \$07
8F80 JR NZ,\$8F8E Jump if not
Willy is touching this item, so add it to his collection.
8F82 LD HL,\$842C Add 100 to the score
8F85 CALL \$90FE
8F88 LD (IY+\$00),\$00 Set the item's attribute byte to 0x00 so that it will be skipped the next time
8F8C JR \$8FAE Jump forward to consider the next item
This item has not been collected yet.
8F8E LD A,(IY+\$00) Pick up the item's current attribute byte
8F91 AND \$F8 Keep the BRIGHT and PAPER bits, and set the INK to 3 (magenta)
8F93 OR \$03
8F95 LD B,A Store this value in B
8F96 LD A,(IY+\$00) Pick up the item's current attribute byte again
8F99 AND \$03 Keep only bits 0 and 1 and add the value in B; this maintains the BRIGHT and PAPER bits, and cycles the INK colour through 3, 4, 5 and 6
8F9C LD (IY+\$00),A Store the new attribute byte
8F9F LD (DE),A Update the attribute byte at the item's location in the buffer at 5C00
8FA0 LD (\$8074),A Store the new attribute byte at 8074 as well
8FA3 LD D,(IY+\$03) Point DE at the address of the item's location in the screen buffer at 6000
8FA6 LD HL,\$80B4 Point HL at the item graphic for the current cavern (at 80B4)
8FA9 LD B,\$08 There are eight pixel rows to copy
8FAB CALL \$92D5 Draw the item to the screen buffer at 6000
The current item definition has been dealt with. Time for the next one.
8FAE INC IY Point IY at the first byte of the next item definition
8FB0 INC IY
8FB2 INC IY
8FB4 INC IY
8FB6 INC IY
8FB8 JR \$8F6B Jump back to deal with the next item
All the items have been dealt with. Check whether there were any left.
8FBA LD A,(\$8074) Pick up the attribute of the last item drawn at 8074
8FBD OR A Were any items drawn?
8FBE RET NZ Return if so (some remain to be collected)
8FBF LD HL,\$808F Ensure that the portal is flashing by setting bit 7 of its attribute byte at 808F
8FC2 SET 7,(HL)
8FC4 RET
 Prev: 8EF1 Up: Map Next: 8FC5