Prev: 8B90 Up: Map Next: 8D0F
8C3D: Check what attributes are around Monty
Used by the routine at 8B90.
8C3D LD IY,$8D54 Point IY at the movement table at 8D54.
8C41 LD B,$02
8C43 LD A,($5C7C) Get the Y co-ordinate (5C7C).
8C46 LD C,A Remember this in C.
8C47 LD A,$BF Invert the bottom 6 bits.
8C49 SUB C
8C4A PUSH AF Remember this.
8C4B AND $07 Get the lowest 3 bits.
8C4D JR Z,$8C51 Jump forward if none are set.
8C4F LD B,$03 Otherwise default to 3.
8C51 LD A,B Set the Y offset (8D5B).
8C52 LD ($8D5B),A
8C55 LD C,$02 Default to 2.
8C57 LD A,($5C7B) Get the X co-ordinate (5C7C);
8C5A AND $07 Get the lowest 3 bits.
8C5C JR Z,$8C60 Jump foward if none are set.
8C5E LD C,$03 Otherwise default to 3.
8C60 LD A,C Set the X offset (8D5C).
8C61 LD ($8D5C),A
8C64 POP AF Restore Y co-ordinate.
8C65 AND $F8 Shift the top 5 bits down and store in the Y co-ordinate (8D5E)
8C67 RRCA
8C68 RRCA
8C69 RRCA
8C6A LD ($8D5E),A
8C6D LD A,($5C7B) Get the X co-ordinate.
8C70 AND $F8 Shift the top 5 bits down and store in the X co-ordinate (8D5D)
8C72 RRCA
8C73 RRCA
8C74 RRCA
8C75 LD ($8D5D),A
8C78 LD A,($8D5E) Get the Y co-ordinate.
8C7B LD L,A Scale it up to a screen address.
8C7C LD H,$00
8C7E ADD HL,HL
8C7F ADD HL,HL
8C80 ADD HL,HL
8C81 ADD HL,HL
8C82 ADD HL,HL
8C83 LD A,($8D5D) Get the X co-ordinate.
8C86 LD D,$00 Add this to get the desired offset.
8C88 LD E,A
8C89 ADD HL,DE
8C8A LD DE,$5800 Add the base address to get an attribute on screen.
8C8D ADD HL,DE
8C8E LD ($8D59),HL Store this attribute.
8C91 LD A,($8D5C) Get the X co-ordinate for the offset.
8C94 LD B,A Store this in B.
8C95 LD (IY+$00),$00 Default to no movement in this direction.
8C99 PUSH IY Remember IY.
8C9B CALL $8D0F Check the movement tables across.
8C9E LD HL,($8D59) Move back a row.
8CA1 LD DE,$0020
8CA4 LD A,($8D5B)
8CA7 DEC A
8CA8 LD B,A
8CA9 ADD HL,DE
8CAA DJNZ $8CA9
8CAC LD A,($8D5C) Get the X co-ordinate for the offset.
8CAF LD B,A Store this in B.
8CB0 INC IY Move to the next direction.
8CB2 LD (IY+$00),$00 Default to no movement.
8CB6 CALL $8D0F Check movement tables across.
8CB9 LD HL,($8D59)
8CBC LD A,($8D5B)
8CBF LD B,A
8CC0 INC IY Move to the next direction.
8CC2 LD (IY+$00),$00 Default to no movement.
8CC6 CALL $8D2E Check movement tables down.
8CC9 LD HL,($8D59)
8CCC LD A,($8D5C)
8CCF DEC A
8CD0 LD B,A
8CD1 INC HL
8CD2 DJNZ $8CD1
8CD4 LD A,($8D5B)
8CD7 LD B,A
8CD8 INC IY Move to the next direction.
8CDA LD (IY+$00),$00 Default to no movement.
8CDE CALL $8D2E Check movement tables down.
8CE1 POP IY Restore IY to the base position.
8CE3 LD A,(IY+$00) If any direction flag was set to 3, set it to 0 instead.
8CE6 CP $03
8CE8 JR NZ,$8CEE
8CEA LD (IY+$00),$00
8CEE LD A,(IY+$01)
8CF1 CP $03
8CF3 JR NZ,$8CF9
8CF5 LD (IY+$01),$00
8CF9 LD A,(IY+$02)
8CFC CP $03
8CFE JR NZ,$8D04
8D00 LD (IY+$02),$00
8D04 LD A,(IY+$03)
8D07 CP $03
8D09 RET NZ
8D0A LD (IY+$03),$00
8D0E RET
Prev: 8B90 Up: Map Next: 8D0F