Prev: 9327 Up: Map Next: 940C
935C: Check to see if Monty has moved near any coal, and if so, pick it up
Used by the routine at 940C.
935C LD HL,($5C7B) Get the current position.
935F CALL $9258 Is there any coal here?
9362 JR NZ,$93C1 Jump forward if there is.
9364 LD HL,($5C7B) Get the current X position plus 7.
9367 LD A,$07
9369 ADD A,L
936A LD L,A
936B CALL $9258 Is there any coal here?
936E JR NZ,$93C1 Jump forward if there is.
9370 LD HL,($5C7B) Get the current X position plus 0F.
9373 LD A,$0F
9375 ADD A,L
9376 LD L,A
9377 CALL $9258 Is there any coal here?
937A JR NZ,$93C1 Jump forward if there is.
937C LD HL,($5C7B) Get the current Y position minus 7.
937F LD A,$F8
9381 ADD A,H
9382 LD H,A
9383 CALL $9258 Is there any coal here?
9386 JR NZ,$93C1 Jump forward if there is.
9388 LD HL,($5C7B) Get the current X position plus 0F.
938B LD A,$0F
938D ADD A,L
938E LD L,A
938F LD A,$F8 Get the current Y position minus 7.
9391 ADD A,H
9392 LD H,A
9393 CALL $9258 Is there any coal here?
9396 JR NZ,$93C1 Jump forward if there is.
9398 LD HL,($5C7B) Get the current Y position minus 15.
939B LD A,$F0
939D ADD A,H
939E LD H,A
939F LD ($9647),HL Store this temporarily.
93A2 CALL $9258 Is there any coal here?
93A5 JR NZ,$93C1 Jump forward if there is.
93A7 LD HL,($9647) Restore the previously cached position.
93AA LD A,$08 Add 8 to the X position.
93AC ADD A,L
93AD LD L,A
93AE LD ($9647),HL Cache this.
93B1 CALL $9258 Is there any coal here?
93B4 JR NZ,$93C1 Jump forward if there is.
93B6 LD HL,($9647) Restore the previously cached position.
93B9 LD A,$07 Add 7 to the X position.
93BB ADD A,L
93BC LD L,A
93BD CALL $9258 Is there any coal here?
93C0 RET Z No, so there's nothing near.
At this point, Monty has walked near enough some coal to be able to pick it up.
93C1 LD (HL),$00 Set that there's no coal here.
93C3 LD DE,$88AC
93C6 ADD HL,DE
93C7 LD A,($C54E)
93CA LD (HL),A
93CB LD ($9647),BC Put the found screen position for the coal in 9647.
93CF LD DE,$0031 Make a beep using the ROM routine, but skip the first instruction so that interrupts remain enabled.
93D2 LD HL,$0376
93D5 CALL $03B6
93D8 LD IX,$C53F C53F holds coal positions in the room.
93DC LD B,$05 5 positions to check.
93DE LD A,($9647) Get the found X position.
93E1 CP (IX+$01) Is it this one?
93E4 JR Z,$93ED Move forward if so.
93E6 LD DE,$0003 Look at the next coal position.
93E9 ADD IX,DE
93EB DJNZ $93DE
93ED LD A,($9648) Get the found Y position.
93F0 CP (IX+$02) Is it this one?
93F3 JR NZ,$93E6 Loop back if not.
Found the necessary entry for coal.
93F5 PUSH IX
93F7 LD E,(IX+$00) Put the coal index in DE.
93FA LD D,$00
93FC LD HL,$964D 964D holds scores for coal.
93FF ADD HL,DE Get the right offset.
9400 RES 7,(HL) Bit 7 is not used here.
9402 LD A,(HL) Add to the score.
9403 CALL $919D
9406 POP IX
9408 CALL $96AA Refresh the coal flags.
940B RET
Prev: 9327 Up: Map Next: 940C