![]() |
Routines |
| Prev: 25928 | Up: Map | Next: 25994 |
|
Used by the routine at GameLoop.
Count down the active turn-based events and run each one that expires.
|
||||
| HandlerTurnBasedEvents | 25943 | LD A,(25113) | Fetch the turn-based event flags. | |
| 25946 | OR A | No turn-based event is running. | ||
| 25947 | JR Z,HandlerTurnBasedEvents_Step3 | |||
| 25949 | LD C,A | Keep the event flags and test all eight bits. | ||
| 25950 | LD B,8 | |||
|
Each set bit is a countdown that is still running.
|
||||
| HandlerTurnBasedEvents_Loop1 | 25952 | SRL C | Take the next turn-based event bit. | |
| 25954 | JR NC,HandlerTurnBasedEvents_Step2 | This event is not running. | ||
| 25956 | LD DE,0 | Count down the turn-based event whose bit was just set. | ||
| 25959 | LD HL,25114 | |||
| 25962 | LD A,8 | |||
| 25964 | SUB B | |||
| 25965 | LD E,A | |||
| 25966 | ADD HL,DE | |||
| 25967 | DEC (HL) | |||
| 25968 | JR NZ,HandlerTurnBasedEvents_Step2 | Leave this event when its countdown has not expired. | ||
| 25970 | LD IX,25250 | Find the handler for this turn-based event. | ||
| 25974 | SLA E | Index the handler for this event. | ||
| 25976 | ADD IX,DE | |||
| 25978 | LD L,(IX+0) | Read that handler's address. | ||
| 25981 | LD H,(IX+1) | |||
| 25984 | PUSH BC | Remember which events are still to be checked. | ||
| HandlerTurnBasedEvents_Step1 | 25985 | LD DE,25990 | Run the handler, then return here for the remaining events. | |
| 25988 | PUSH DE | |||
| 25989 | JP (HL) | |||
| 25990 | POP BC | Restore the event flags still to be checked. | ||
| HandlerTurnBasedEvents_Step2 | 25991 | DJNZ HandlerTurnBasedEvents_Loop1 | Repeat for the remaining event bits. | |
| HandlerTurnBasedEvents_Step3 | 25993 | NOP | Leave this event for the next turn. | |
| Prev: 25928 | Up: Map | Next: 25994 |