Prev: 8B1F Up: Map Next: 8C3D
8B90: Determine where Monty can move to
Used by the routine at 8B34.
8B90 CALL $8C3D Check for collision.
8B93 LD IX,$8D52 Point IX at the room flags (8D52).
8B97 LD IY,$8D54 Point IY at the direction flags (8D54).
8B9B LD A,(IX+$00) Clear all bits except 2 and 4 on the room flags.
8B9E AND $0A
8BA0 LD (IX+$00),A
Check the movement flags.
8BA3 LD A,(IY+$00) Can Monty move up?
8BA6 OR A
8BA7 JR NZ,$8BAD Jump forward if so.
8BA9 SET 7,(IX+$00) Set bit 7 of the room flags - Monty can't move up.
8BAD LD A,(IY+$01) Can Monty move down?
8BB0 OR A
8BB1 JR NZ,$8BB7 Jump forward if so.
8BB3 SET 6,(IX+$00) Set bit 6 of the room flags - Monty can't move down.
8BB7 LD A,(IY+$02) Can Monty move left?
8BBA OR A
8BBB JR NZ,$8BC1 Jump forward if so.
8BBD SET 5,(IX+$00) Set bit 5 of the room flags - Monty can't move left.
8BC1 LD A,(IY+$03) Can Monty move right?
8BC4 OR A
8BC5 JR NZ,$8BCB Jump forward if so.
8BC7 SET 4,(IX+$00) Set bit 4 of the room flags - Monty can't move right.
Check to see if there is a nasty in the proximity.
8BCB CP $01 Is a nasty to the right of Monty?
8BCD JP Z,$946E If so, Monty dies.
8BD0 LD A,(IY+$02) Is a nasty to the left of Monty?
8BD3 CP $01 If so, Monty dies.
8BD5 JR Z,$8BCD
8BD7 LD A,(IY+$01) Is a nasty below Monty?
8BDA CP $01 If so, Monty dies.
8BDC JR Z,$8BCD
8BDE LD A,(IY+$00) Is a nasty above Monty?
8BE1 CP $01 If so, Monty dies.
8BE3 JR Z,$8BCD
See if Monty can climb here.
8BE5 PUSH IY Remember IY.
8BE7 CALL $FEA2 Can Monty climb here?
8BEA JR NZ,$8BF0 Jump forward if not.
8BEC SET 2,(IX+$00) Set bit 2 of the room flags - Monty can climb.
8BF0 POP IY Restore IY.
See if Monty has collided with non-empty space.
8BF2 LD B,$02
8BF4 LD A,($5C7B) Get the bottom 3 bits of the X co-ordinate.
8BF7 AND $07
8BF9 JR Z,$8BFD Move forward if they are zero.
8BFB LD B,$03 Scan 3 rows.
8BFD CALL $8D5F Get the current screen address in HL.
8C00 LD C,$00 Set C as no bits found.
8C02 LD A,(HL) Get the next data from screen.
8C03 OR C OR it against C to retain any bits found.
8C04 LD C,A Store this result back in C.
8C05 INC HL Move to the next column.
8C06 DJNZ $8C02 Loop back if there are more columns to look at.
8C08 LD A,C Was anything found at this screen address?
8C09 OR A
8C0A JP Z,$8B0C If not, set various flags.
8C0D BIT 7,(IX+$01) Is Monty in mid-air?
8C11 RET Z Return if so. Monty has reached the ground after falling.
8C12 RES 7,(IX+$01) Reset the mid-air flag.
8C16 RES 0,(IX+$00) Enable background objects to move.
8C1A RES 1,(IX+$00) Set that Monty is not jumping.
8C1E LD A,($8D58) Get the height fallen.
8C21 CP $20 Is it above 20?
8C23 JP NC,$946E Yes, Monty has fallen too far, so he's dead.
8C26 XOR A Set A to 0 to reset some flags.
8C27 LD ($8D58),A Reset the height fallen.
8C2A LD ($848F),A Reset the position jumped off ground.
8C2D LD ($8498),A Reset the time being jumped.
8C30 LD HL,$869C Reset the pointer to the movement table back to 869C.
8C33 LD ($8492),HL
8C36 LD HL,($8496) Reset the pitch to sound when jumping back to the default.
8C39 LD ($8494),HL
8C3C RET Return.
Prev: 8B1F Up: Map Next: 8C3D