Prev: 9228 Up: Map Next: 927E
9258: See if Monty is touching some coal and can collect it
Used by the routine at 935C.
Input
H Current Y position
L Current X position
HL On exit, returns the address in the coal attribute buffer that was checked.
F Resets the zero flag if there is coal here, otherwise sets it.
9258 LD A,L Divide the X co-ordinate by 8 and put it in C.
9259 AND $F8
925B RRCA
925C RRCA
925D RRCA
925E LD C,A
925F LD A,H Divide the Y co-ordinate by 8 and put it in B.
9260 AND $F8
9262 RRCA
9263 RRCA
9264 RRCA
9265 LD B,A
9266 LD A,$18 Flip the Y co-ordinate to be the right way round for a screen address.
9268 SUB B
9269 DEC A
926A LD B,A
926B LD L,B Convert this into a screen offset.
926C LD H,$00
926E ADD HL,HL
926F ADD HL,HL
9270 ADD HL,HL
9271 ADD HL,HL
9272 ADD HL,HL
9273 LD D,$00 Add the column to the screen offset.
9275 LD E,C
9276 ADD HL,DE
9277 LD DE,$CF54 Add the base position of the coal attributes (CF54).
927A ADD HL,DE
927B LD A,(HL) Reset the zero flag if there is coal at this position and return.
927C OR A
927D RET
Prev: 9228 Up: Map Next: 927E