![]() |
Routines |
Prev: 31110 | Up: Map | Next: 31204 |
Called from the main loop at 61483.
|
||
31126 | LD A,(32750) | A=current game mode (0-4) |
31129 | AND A | Is it demo mode? |
31130 | JP NZ,60082 | Jump if not |
It's demo mode.
|
||
31133 | CALL 60121 | Collect the ASCII code of the last key pressed in A |
31136 | JP NZ,61674 | Start a new game if a game key was pressed |
31139 | LD A,38 | Message 38: 'PRESS A KEY TO PLAY' |
31141 | LD (32722),A | Store this message number at 32722 so that it can be monitored |
31144 | CALL 30975 | Is this message in the message queue? |
31147 | CALL NZ,28357 | If not, add it to the message queue (again) |
31150 | LD A,248 | Set bits 3-7 at 32746, effectively giving Sam the keys to all the houses |
31152 | LD (32746),A | |
31155 | LD A,(58891) | Pick up byte 11 of Sam's buffer (which holds his destination y-coordinate) |
31158 | AND A | Has a destination been set for Sam yet? |
31159 | JR NZ,31188 | Jump if so |
We need to set a new destination for Sam.
|
||
31161 | CALL 61823 | Get an even random number between 134 and 148 in A |
31164 | AND 14 | |
31166 | ADD A,134 | |
31168 | LD L,A | Point HL at an entry in the table of locations at 31110 |
31169 | LD H,121 | |
31171 | LD E,(HL) | Collect the location coordinates in DE |
31172 | INC L | |
31173 | LD D,(HL) | |
31174 | LD HL,58890 | Copy the location coordinates into bytes 10 and 11 of Sam's buffer |
31177 | LD (HL),E | |
31178 | INC L | |
31179 | LD (HL),D | |
31180 | LD C,1 | Assume a z-coordinate of 1 (indoors) |
31182 | CALL 60743 | Obtain an identifier for the location |
31185 | LD L,12 | Copy the destination location identifier into byte 12 of Sam's buffer |
31187 | LD (HL),A | |
31188 | LD H,230 | 230=Sam |
31190 | CALL 60812 | Determine the next move Sam should make to reach his destination |
31193 | AND A | Is Sam already at his destination? |
31194 | JR Z,31161 | Jump back to set a new destination if so |
Sam's destination has been set. Now to simulate a keypress that will make him take the next step towards it.
|
||
31196 | ADD A,127 | Point HL at the offset of the appropriate keypress to simulate in the table at 31104 |
31198 | LD L,A | |
31199 | LD H,121 | |
31201 | LD A,(HL) | Pick up the keypress offset |
31202 | AND A | Make sure the zero flag is reset to indicate that a simulated keypress was made (this instruction is redundant) |
31203 | RET |
Prev: 31110 | Up: Map | Next: 31204 |