Back to Skool Routines
31861: Collect bit mask and buffer address for event identifier
Used by the routines at 31887, 31893 and 31905. The event identifier in A (0, 7-12), taken modulo 8, corresponds to a bit in one of the bytes at 32640 (A<=7) or 32641 (A>=8). On exit, HL points to the appropriate byte and A holds the bit mask (single bit set), as follows:
Entry Exit Event
0 1 End of lesson
7 128 Time to sit down for assembly
8 1 Teacher has arrived at top floor room in girls' skool
9 2 Teacher has arrived at middle floor room in girls' skool
10 4 Teacher has arrived at Blue room
11 8 Teacher has arrived at Yellow room
12 16 Teacher has arrived at Science lab
Event IDs 1-6 (corresponding to those bits in 32640) are not used in any command lists, but bits 1-6 in 32640 are used internally; event IDs 13-15 (and the corresponding bits 5-7 in 32641) are not used anywhere.
A Event ID from command list
31861 AND A Set the carry flag if the event identifier is odd
31862 RRA
31863 LD E,A Copy bits 1-3 of the event ID into bits 0-2 of E
31864 LD A,0 A=1 if the event ID is an even number, 2 if it's an odd number
31866 ADC A,A
31867 INC A
31868 RR E Now bits 2 and 3 of the event ID are in bits 0 and 1 of E
31870 JR NC,31874 Jump if the event ID is 0, 8, 9 or 12 (bit 1 reset)
31872 ADD A,A A=4 (event ID = 10) or 8 (event ID = 7 or 11)
31873 ADD A,A
31874 SCF
31875 RR E E=128 (event ID <= 7) or 129
31877 JR NC,31883 Jump if the event ID is 0, 8, 9, 10 or 11 (bit 2 reset)
31879 ADD A,A A=16 (event ID = 12) or 128 (event ID = 7)
31880 ADD A,A
31881 ADD A,A
31882 ADD A,A
31883 LD D,127 HL=32640 or 32641
31885 EX DE,HL
31886 RET