Prev: F746 Up: Map Next: F7DE
F773: Room logic : The School
F773 LD A,$02 Moving objects decrease endurance by 2.
F775 LD ($F26E),A
F778 LD A,(IY+$0A) Get the player's Y co-ordinate.
F77B CP $98 Is the player on the floor?
F77D JR NZ,$F78D Jump forward if they're not.
The player is on the floor.
F77F LD A,(IY+$05) Get the X co-ordinate.
F782 CP $28 Is it greater than 28?
F784 JR C,$F78D Jump forward if so.
F786 CP $E6 Is it less than E6?
F788 JR NC,$F78D Jump forward if not.
F78A CALL $E33F Otherwise, the player is standing on the spikes, so decrease endurance.
Now draw the desks.
F78D LD B,$05 5 objects to draw.
F78F LD A,($F7DE) Get the next frame ID of the desk.
F792 INC A Increment it.
F793 CP $5B If it goes higher than 5A set it back to 57.
F795 JR NZ,$F799
F797 LD A,$57
F799 LD ($F7DE),A Store the next frame ID.
F79C LD HL,$F7DF Point HL at the next x co-ordinate to use.
F79F LD D,$98 Y co-ordinate is always 98.
F7A1 LD E,(HL) Get the X co-ordinate.
F7A2 LD ($A838),DE Set the position to draw. (A838)
F7A6 INC HL Move to the next position in the buffer.
F7A7 DEC (HL) Decrement the tick counter.
F7A8 JR NZ,$F7AC Jump forward if it's not zero.
The tick counter has run to 0, does a desk need to be flipped?
F7AA LD (HL),$28 Set the tick count back to 28.
F7AC LD A,(HL) Put the tick count in A.
F7AD INC HL Move to the next position in the buffer.
F7AE CP $09 Is the counter less than 9?
F7B0 JR NC,$F7D6 Jump forward if not.
The desk needs flipping, check if dislodges the player.
F7B2 LD A,(IY+$0A) Get the player's y co-ordinate.
F7B5 CP $80 Is it 80? (ie: on a desk)
F7B7 JR NZ,$F7D1 Jump foward if it isn't.
F7B9 LD A,($A838) Is the player's x co-ordinate near this one?
F7BC SUB (IY+$05)
F7BF SUB $10
F7C1 CP $E0
F7C3 JR C,$F7D1 Jump if not.
The desk opened while the player was on it. Dislodge them.
F7C5 LD A,(IY+$0A) Add 4 to the player's y co-ordinate.
F7C8 ADD A,$04
F7CA LD (IY+$0A),A
F7CD LD (IY+$37),$01 Set the character in mid-air.
F7D1 LD A,($F7DE) Get the object ID to draw.
F7D4 JR $F7D8 Jump forward to draw it.
F7D6 LD A,$57 Set the object ID as 57 - closed desk. (8E58)
F7D8 CALL $A83D Draw the object
F7DB DJNZ $F7A1 Loop while there are more objects to draw.
F7DD RET Otherwise return.
Prev: F746 Up: Map Next: F7DE