![]() |
Routines |
| Prev: 44955 | Up: Map | Next: 45025 |
|
Used by the routines at StartPictureModeScreenIdle and CopyDisplayIfNeeded.
Searches through a command handler lookup table for a matching value pair and jumps to the associated handler routine if found.
|
||||||||||
| SearchCommandHandlerTable | 44979 | LD HL,44907 | Set the table pointer to Table_CommandHandlerLookup_Standard. | |||||||
| 44982 | LD A,(40996) | Check which lookup table to use based on the current mode. | ||||||||
| 44985 | CP 2 | |||||||||
| 44987 | JR NZ,SearchCommandHandlerTable_StartSearch | Jump ahead to SearchCommandHandlerTable_StartSearch if the mode is not 2. | ||||||||
| 44989 | LD HL,44955 | Point HL at the alternate table at Table_CommandHandlerLookup_Alternate. | ||||||||
| SearchCommandHandlerTable_StartSearch | 44992 | PUSH DE | Count 12 entries, or 6 when the mode is 2 keeping the source. | |||||||
| 44993 | LD E,12 | |||||||||
| 44995 | JR NZ,SearchCommandHandlerTable_Loop | |||||||||
| 44997 | LD E,6 | |||||||||
| SearchCommandHandlerTable_Loop | 44999 | LD A,(HL) | Check if the first value in the current table entry matches the search value. | |||||||
| 45000 | INC HL | |||||||||
| 45001 | CP C | |||||||||
| 45002 | JR NZ,SearchCommandHandlerTable_NextEntry | Skip to the next entry if it doesn't match. | ||||||||
| 45004 | LD A,(HL) | Check if the second value in the current table entry matches the search value. | ||||||||
| 45005 | CP B | |||||||||
| 45006 | JR Z,SearchCommandHandlerTable_Found | Jump to the handler if both values match. | ||||||||
| SearchCommandHandlerTable_NextEntry | 45008 | INC HL | Move to the next table entry. | |||||||
| 45009 | INC HL | |||||||||
| 45010 | INC HL | |||||||||
| 45011 | DEC E | Decrease the entry counter and continue searching if there are more entries. | ||||||||
| 45012 | JR NZ,SearchCommandHandlerTable_Loop | |||||||||
| SearchCommandHandlerTable_NotFound | 45014 | POP DE | Jump back to CopyBytes_ReportSuccess to return non-zero. | |||||||
| 45015 | JP CopyBytes_ReportSuccess | |||||||||
|
Reads the handler address that follows and jumps to it.
A handler was found, use it!
|
||||||||||
| SearchCommandHandlerTable_Found | 45018 | INC HL | Load the handler pointer from the table entry. | |||||||
| 45019 | LD E,(HL) | |||||||||
| 45020 | INC HL | |||||||||
| 45021 | LD D,(HL) | |||||||||
| 45022 | EX DE,HL | |||||||||
| 45023 | POP DE | |||||||||
| 45024 | JP (HL) | Jump to the handler. | ||||||||
|
View the equivalent code in;
|
||||||||||
| Prev: 44955 | Up: Map | Next: 45025 |