Routines
| Prev: 9EC0 | Up: Map | Next: 9ECA |
9EC1: After-turn routines for Strachan, the cook and the gardener: bedtime
|
9EC1 (Strachan, with B = room 74, Daphne's room), 9ECB (the cook) and 9ED1 (the gardener, both with B = 0, off stage) share 9ED7, with a one-byte state each (9EC0, 9ECA, 9ED0). At 9pm the character's room is saved in the state byte, the character moves to room B, is described as SLEEPING (word $07F0 written to its +9/+10 by F1C1), stops counting as a person (+5 bit 6 cleared, so it cannot be talked to) and has its next turn put back 504 to 533 minutes - until about 5:30am. On that next turn it goes back to the saved room and is a person again. At 9:00pm the cook (room 65) and the gardener were still about; at 9:05pm both were in room 0 and Strachan in room 74, each with +5 gone from $E0 to $A0 (bit 6 cleared) and +9/+10 = $07F0, SLEEPING.
The 504 to 533 minutes are only right when the random part is below 8; otherwise 256 minutes are lost and the character is back at about 1:30am - see the Bugs page.
How it works:
1. Each of the three characters has a state byte (the room he left), which is 0 while he is about.
2. If the state byte is non-zero he is away: put him back in that room with no container, clear the state byte, give him no state word and set bit 6 of +5 so he is a person to talk to again.
3. Otherwise, if it is am, do nothing. If it is not 9 o'clock in the evening, do nothing.
4. At 9pm: store the room he is in, move him to B (0 for the cook and gardener, room 74 for Strachan), and set his next turn 504 plus a random 0 to 30 minutes on. Only the low byte takes the random part, so from 8 up the carry is lost.
5. Give him the state word SLEEPING ($07F0) and clear bit 6 of +5.
|
||||||||||||
| 9EC1 | LD HL,$9EC0 | HL = the character's countdown byte (9EC0) | ||||||||||
| 9EC4 | LD C,$80 | Load C with $80 - C = $80, B = $4A | ||||||||||
| 9EC6 | LD B,$4A | Load B with $4A | ||||||||||
| 9EC8 | JR $9ED7 | Join the common code at 9ED7 | ||||||||||
| Prev: 9EC0 | Up: Map | Next: 9ECA |