![]() |
Routines |
| H | Character number of teacher (163-166) |
| 31282 | PUSH HL | Save the teacher's character number |
| 31283 | LD A,H | A=teacher's character number |
| 31284 | CP 163 | Is it MR WACKER? |
| 31286 | JR NZ,31378 | Jump if not |
| 31288 | LD HL,61448 | 61448=address of '12' in 'WHAT IS 12 x 34' |
| 31291 | LD B,2 | There are two numbers to generate |
| 31293 | LD C,A | Store the second (the multiplier) in C on pass 2 |
| 31294 | CALL 24993 | Collect a random number between 32 and 99 in A |
| 31297 | AND 127 | |
| 31299 | CP 100 | |
| 31301 | JR NC,31294 | |
| 31303 | CP 32 | |
| 31305 | JR C,31294 | |
| 31307 | PUSH AF | Store this number temporarily |
| 31308 | LD (HL),47 | Insert the ASCII codes for the digits of the number into the 'WHAT IS 12 x 34' message |
| 31310 | INC (HL) | |
| 31311 | SUB 10 | |
| 31313 | JR NC,31310 | |
| 31315 | ADD A,58 | |
| 31317 | INC L | |
| 31318 | LD (HL),A | |
| 31319 | POP AF | Restore the number to A |
| 31320 | LD L,13 | HL=61453: address of '34' in 'WHAT IS 12 x 34' message |
| 31322 | DJNZ 31293 | Jump back to insert the multiplier into the message |
| 31324 | LD DE,0 | HL=0 (ready for multiplication); DE=61463 (address of '1234' in EINSTEIN's response message) |
| 31327 | LD L,23 | |
| 31329 | EX DE,HL | |
| 31330 | ADD HL,BC | HL=the product of the two numbers |
| 31331 | DEC A | |
| 31332 | JR NZ,31330 | |
| 31334 | LD BC,64536 | Calculate the 1000s digit and store its ASCII code in the appropriate spot (61463) |
| 31337 | INC A | |
| 31338 | ADD HL,BC | |
| 31339 | JR C,31337 | |
| 31341 | SBC HL,BC | |
| 31343 | ADD A,47 | |
| 31345 | LD (DE),A | |
| 31346 | LD BC,65436 | Calculate the 100s digit and store its ASCII code in the appropriate spot (61464) |
| 31349 | LD A,47 | |
| 31351 | INC A | |
| 31352 | ADD HL,BC | |
| 31353 | JR C,31351 | |
| 31355 | SBC HL,BC | |
| 31357 | INC E | |
| 31358 | LD (DE),A | |
| 31359 | LD A,L | Calculate the 10s digit and store its ASCII code in the appropriate spot (61465) |
| 31360 | EX DE,HL | |
| 31361 | INC L | |
| 31362 | LD (HL),47 | |
| 31364 | INC (HL) | |
| 31365 | SUB 10 | |
| 31367 | JR NC,31364 | |
| 31369 | ADD A,58 | Store the ASCII code of the units digit in the appropriate spot (61466) |
| 31371 | INC L | |
| 31372 | LD (HL),A | |
| 31373 | LD HL,31256 | This is the base address of the data table used for MR WACKER's questions and answers |
| 31376 | JR 31424 |
| 31378 | SUB 164 | A=0 (MR ROCKITT), 1 (MR WITHIT), or 2 (MR CREAK) |
| 31380 | CALL 63779 | Make MR CREAK ask the birth year question if appropriate |
| 31383 | LD B,128 | |
| 31385 | JR Z,31398 | Jump if we're dealing with MR ROCKITT |
| 31387 | LD B,170 | |
| 31389 | LD L,34 | HL=31266 |
| 31391 | DEC A | Are we dealing with MR WITHIT? |
| 31392 | JR Z,31398 | Jump if so |
| 31394 | LD L,42 | HL=31274 |
| 31396 | LD B,212 |
| 31398 | CALL 24993 | Get a random number between 0 and 41 in A |
| 31401 | CP 42 | |
| 31403 | JR NC,31398 | |
| 31405 | ADD A,B | A=128-169 (MR ROCKITT), 170-211 (MR WITHIT), or 212-253 (MR CREAK) |
| 31406 | BIT 0,A | There are two types of question the teacher can ask; here we decide which one |
| 31408 | JR Z,31414 | |
| 31410 | INC L | Move forward four spaces in the data table to the LSBs for the second type of question |
| 31411 | INC L | |
| 31412 | INC L | |
| 31413 | INC L | |
| 31414 | LD D,240 | Insert the random identifier into the teacher's question |
| 31416 | LD E,(HL) | |
| 31417 | LD (DE),A | |
| 31418 | INC L | Insert the corresponding random identifier into EINSTEIN's answer |
| 31419 | LD E,(HL) | |
| 31420 | XOR 1 | |
| 31422 | LD (DE),A | |
| 31423 | INC L | |
| 31424 | LD E,(HL) | Store the address of the answer message in bytes 107 and 108 of EINSTEIN's buffer |
| 31425 | LD D,240 | |
| 31427 | LD (43371),DE | |
| 31431 | INC L | |
| 31432 | LD E,(HL) | DE=address of the question message |
| 31433 | POP HL | Restore the teacher's character number to H |
| 31434 | LD L,107 | Store the address of the question message in bytes 107 and 108 of the teacher's buffer |
| 31436 | LD (HL),E | |
| 31437 | INC L | |
| 31438 | LD (HL),D | |
| 31439 | LD L,106 | Place the address of the routine at 31110 (make character speak) into bytes 105 and 106 of the teacher's buffer |
| 31441 | LD (HL),121 | |
| 31443 | DEC L | |
| 31444 | LD (HL),134 | |
| 31446 | RET |