![]() |
Routines |
| Prev: 62102 | Up: Map | Next: 62283 |
|
|
||||
|
Clear/reset input area (clear by printing 5 spaces):
|
||||
| 62201 | LD BC,3603 | Line number (B) = 14 Column number (C) = 19 |
||
| 62204 | CALL 3545 | Call ROM 'CL-SET' routine HL register pair returned with screen display position to print at (18510) |
||
| 62207 | CALL 62056 | Print the following characters on screen. On RETurn from this CALL, continue from 62216 | ||
|
Characters to print - spaces to clear input area:
|
||||
| 62210 | DEFM " " | 5 spaces | ||
| 62215 | DEFB 255 | End-of-data byte | ||
|
Prepare for player input:
|
||||
| 62216 | LD BC,3603 | Line number (B) = 14 Column number (C) = 19 |
||
| 62219 | CALL 3545 | Call ROM 'CL-SET' routine HL register pair returned with screen display position to print at |
||
| 62222 | LD B,4 | 4 digits to enter | ||
| 62224 | LD HL,0 | HL not needed for print routine (uses RST 16 instruction and stack pointer to the following data) | ||
| 62227 | CALL 62056 | Print the (following) characters on screen | ||
|
Characters for flashing cursor:
|
||||
| 62230 | DEFM 18,1," ",18,0,8 | ASCII codes for: - FLASH 1 - " " (SPACE) - FLASH 0 - CURSOR LEFT |
||
| 62236 | DEFB 255 | End-of-data marker | ||
|
Check player input:
|
||||
| 62237 | BIT 5,(IY+1) | FLAGS (system variable) - bit 5 is set if a key is pressed | ||
| 62241 | JR Z,62237 | Keep checking until it's pressed | ||
| 62243 | RES 5,(IY+1) | Key pressed - reset bit 5 of FLAGS system variable | ||
| 62247 | LD A,(23560) | Get value of LAST-K (last pressed key) | ||
| 62250 | CP 12 | Has DELETE been pressed? | ||
| 62252 | JR Z,62201 | If so, jump back and reset the player's input (clear the input area) | ||
|
Evaluate key pressed:
|
||||
| 62254 | LD C,A | Store key value in C register | ||
| 62255 | SUB 48 | Is code for key pressed <48 (number 0 = value of 48, the first valid character that can be typed) | ||
| 62257 | JR C,62237 | If so, it's not valid - jump back until another key is pressed | ||
| 62259 | CP 10 | Is the code for the key press one of the numbers (0-9)? | ||
| 62261 | JR NC,62237 | If not, it's not valid - jump back until another key is pressed | ||
|
A valid key between 0 and 9 has been pressed
|
||||
| 62263 | LD E,A | Store value of key pressed (0-9) in E register | ||
| 62264 | LD A,C | Retrieve key code value from C register | ||
| 62265 | RST 16 | Print the value on screen | ||
|
The value to check against is a 2 byte value stored at 61944. Therefore we need to multiple each accumulated figure/digit by 16 before adding the next:
|
||||
| 62266 | ADD HL,HL | HL = HL x2 | ||
| 62267 | ADD HL,HL | x4 | ||
| 62268 | ADD HL,HL | x8 | ||
| 62269 | ADD HL,HL | x16 | ||
| 62270 | LD D,0 | |||
| 62272 | ADD HL,DE | |||
| 62273 | DJNZ 62227 | Decrement the counter in the B register. Continue to check for input until all 4 digits have been entered | ||
|
We now have the code value in the HL register pair - check it against the correct code:
|
||||
| 62275 | LD DE,(61944) | Get the correct code value | ||
| 62279 | XOR A | Clear the carry flag | ||
| 62280 | SBC HL,DE | Subtract the correct code from the user-entered code | ||
| 62282 | RET | Return to 62292 with zero flag result (Z = correct, NZ = incorrect) | ||
| Prev: 62102 | Up: Map | Next: 62283 |