Routines |
Prev: A173 | Up: Map | Next: A1C3 |
This dispatches time-based game events like parcels, meals, exercise times and roll calls.
Used by the routine at main_loop.
|
||||
Increment the clock, wrapping at 140.
|
||||
dispatch_timed_event | A1A0 | LD HL,$A13D | Point HL at the game clock | |
A1A3 | LD A,(HL) | Load the game clock | ||
A1A4 | INC A | ...and increment it | ||
A1A5 | CP $8C | If it hits 140 then reset it to zero | ||
A1A7 | JR NZ,dispatch_timed_event_0 | |||
A1A9 | XOR A | |||
dispatch_timed_event_0 | A1AA | LD (HL),A | Then save the game clock back | |
Find an event for the current clock
|
||||
A1AB | LD HL,$A173 | Point HL at the timed events table | ||
A1AE | LD B,$0F | There are fifteen timed events | ||
Start loop
|
||||
find_event | A1B0 | CP (HL) | Does the current event's time match the game clock? | |
A1B1 | INC HL | |||
A1B2 | JR Z,event_found | Jump to setup event handler if so | ||
A1B4 | INC HL | Skip the event handler address | ||
A1B5 | INC HL | |||
A1B6 | DJNZ find_event | ...loop | ||
A1B8 | RET | Return with no event matched | ||
Found an event
|
||||
event_found | A1B9 | LD A,(HL) | Read the event handler address into HL | |
A1BA | INC HL | |||
A1BB | LD H,(HL) | |||
A1BC | LD L,A | |||
Most events need to sound the bell, so prepare for that
|
||||
A1BD | LD A,$28 | Set A to bell_RING_40_TIMES | ||
A1BF | LD BC,$A130 | Point BC at bell | ||
A1C2 | JP (HL) | Jump to the event handler |
Prev: A173 | Up: Map | Next: A1C3 |