Skool Daze Routines
27543: Knock occupant from chair
Used by the routine at 27517.
B Number of characters to check (11, 3, or 1)
D Number of first character to check (152, 167, or 172)
H Number of character who wants to sit down (152-169)
27543 LD L,98 Byte 98 of a character's buffer holds his x-coordinate
27545 LD E,L
27546 LD A,(DE) A=x-coordinate of character to check
27547 CP (HL) Do the x-coordinates match?
27548 JR NZ,27564 Jump to consider the next character if not
27550 DEC E E=L=97 (which byte holds the y-coordinate)
27551 DEC L
27552 LD A,(DE) A=y-coordinate of character to check
27553 CP (HL) Do the y-coordinates match?
27554 JR NZ,27564 Jump to consider the next character if not
27556 DEC E E=96
27557 LD A,(DE) A=animatory state of character to check
27558 AND 15
27560 CP 5 Is the character sitting in this chair?
27562 JR Z,27569 Jump to dethrone him if so
27564 INC D Next character to check
27565 DJNZ 27543 Jump back until all characters have been checked
27567 AND A Return with the carry flag reset to indicate no one was knocked out of the chair
27568 RET
27569 LD A,D A=number of character sitting in chair
27570 CP 172 Is ERIC sitting here?
27572 JR NZ,27601 Jump if not
27574 LD DE,32763 32763 holds ERIC's status flags
27577 EX DE,HL
27578 SET 4,(HL) Signal: ERIC has been knocked out of his chair
27580 EX DE,HL
27581 LD L,112 Remove the routine address from bytes 111 and 112 of the buffer of the character who is going to sit down
27583 LD (HL),0
27585 LD L,96 A=animatory state of character sitting in a chair
27587 LD A,(HL)
27588 AND 248
27590 ADD A,5
27592 INC L Pick up the character's coordinates in DE
27593 LD D,(HL)
27594 INC L
27595 LD E,(HL)
27596 CALL 25008 Update character's animatory state and location and update SRB
27599 SCF Return with the carry flag set to indicate that a character was pushed out of his chair
27600 RET
Someone was sitting in the chair, but it wasn't ERIC.
27601 LD E,112 Is there a routine address in bytes 111 and 112 of the seated character's buffer?
27603 LD A,(DE)
27604 AND A
27605 JR Z,27613 Jump if not
27607 LD L,96 A=animatory state of character sitting on the floor
27609 LD A,(HL)
27610 INC A
27611 JR 27592
27613 EX DE,HL
27614 LD (HL),108 Place the address of the routine at 27733 in bytes 111 and 112 of the seated character's buffer
27616 DEC L
27617 LD (HL),85
27619 JR 27580