Routines
 Prev: 29912 Up: Map Next: 30017
29952: Process the event table
Used by the routine at 61568. Scans the event table at 24544 and processes every active entry.
29952 LD HL,30051 Set the operand of the JP instruction at 29963 (below) to 30051 (RET)
29955 LD (29964),HL
29958 LD HL,24544 Point HL at the event table at 24544
29961 LD A,(HL) Collect the first byte of an entry
29962 INC A Set the zero flag if it's 255
The operand of the JP instruction that follows is changed (by this routine) using entries in the event table at 24544 during the game as follows:
Operand Entry Occasion
31236 24626 Sam finds the dead body in the hotel
24914 24586 Sam enters no. 15 using the key (in game mode 1)
24914 24695 Sam climbs the stairs up to the roof of the apartment building next to no. 74 (in game mode 2, after he has entered the hotel's right-hand green room while disguised as a woman)
29963 JP Z,30051 Jump if we've reached the end of the event table
29966 AND 2 Is this event active?
29968 JR NZ,29989 Jump if not
29970 PUSH HL Save the event table entry pointer
29971 INC HL Point HL at the third byte of the entry
29972 INC HL
29973 LD B,(HL) B=number of conditions to check
29974 INC HL DE=address to check
29975 LD E,(HL)
29976 INC HL
29977 LD D,(HL)
29978 INC HL A=opcode of the 'JR' instruction to place at 29986 (below)
29979 LD A,(HL)
29980 INC HL Point HL at the value to compare with (DE)
29981 LD (29986),A Set the instruction at 29986 (below) to 'JR Z', 'JR NZ', 'JR C' or 'JR NC' as appropriate
29984 LD A,(DE) Check the condition
29985 CP (HL)
29986 JR 29996 This instruction is set to 'JR Z', 'JR NZ', 'JR C' or 'JR NC' above
29988 POP HL Restore the event table entry pointer to HL
29989 INC HL Point HL at the second byte of the entry
29990 LD E,(HL) Move HL along to the first byte of the next entry
29991 LD D,0
29994 JR 29961 Jump back to examine the next entry
29996 DJNZ 29974 Jump back to check the next condition in the entry
If we get here, then every condition in the entry was satisfied.
29998 INC HL B=number of POKEs in the entry
29999 LD B,(HL)
30000 INC HL DE=address to POKE
30001 LD E,(HL)
30002 INC HL
30003 LD D,(HL)
30004 INC HL A=byte to POKE
30005 LD A,(HL)
30006 LD (DE),A Do the POKE
30007 DJNZ 30000 Jump back until every POKE has been done
The entry has been processed.
30009 POP HL Restore the event table entry pointer to HL
30010 BIT 6,(HL) Should this entry be deactivated now?
30012 JR NZ,29989 Move along to the next entry if not
30014 INC (HL) Otherwise deactivate the entry by setting bit 0 of the first byte
30015 JR 29989 Move along to the next entry
 Prev: 29912 Up: Map Next: 30017