![]() |
Routines |
Prev: 28355 | Up: Map | Next: 28611 |
Used by the routines at 30154, 30211, 30989, 31126, 31594 and 64338. Adds a message to the message queue, and updates the message line (by clearing it or displaying the next message or message portion) if necessary.
|
||||
28357 | LD E,A | E=number of the message to be queued | ||
28358 | LD HL,32695 | 32695 holds the index of the current message in the message queue at 32696 | ||
28361 | LD A,(HL) | Pick up the index of the current message | ||
28362 | DEC A | A=index of the last message in the queue | ||
28363 | AND 7 | |||
28365 | ADD A,184 | Point HL at the corresponding slot in the message queue at 32696 | ||
28367 | LD L,A | |||
28368 | LD A,(HL) | Pick up the message number from this slot | ||
28369 | AND A | Is the slot empty? | ||
28370 | JR Z,28386 | Jump if so | ||
The message queue is full. To make space for the new message, we remove the second message from the queue, and move the following messages up a slot, thus leaving the final slot free.
|
||||
28372 | LD B,7 | There are six messages to move up a slot, and one to remove completely | ||
28374 | LD C,0 | The final slot will be made empty | ||
28376 | LD A,(HL) | Pick up the message number from this slot | ||
28377 | LD (HL),C | Replace it with 0 or the message number from the previous slot | ||
28378 | LD C,A | Save the old contents of this slot | ||
28379 | LD A,L | Point HL at the previous slot in the message queue | ||
28380 | DEC A | |||
28381 | OR 8 | |||
28383 | LD L,A | |||
28384 | DJNZ 28376 | Jump back to deal with the remaining slots | ||
The following loop looks for the first empty slot in the message queue, and stores the message number there.
|
||||
28386 | LD L,183 | HL=32695 (which holds the index of the current message in the message queue at 32696) | ||
28388 | LD L,(HL) | Copy the index to L | ||
28389 | LD A,L | A=index of the next message in the queue | ||
28390 | INC A | |||
28391 | AND 7 | |||
28393 | ADD A,184 | Point HL at the corresponding slot in the queue | ||
28395 | LD L,A | |||
28396 | LD A,(HL) | Pick up the message number from this slot | ||
28397 | AND A | Is the slot empty? | ||
28398 | JR NZ,28389 | Jump back if not to check the next slot | ||
28400 | LD (HL),E | Store the message number in this slot | ||
28401 | NOP | |||
28402 | NOP | |||
28403 | NOP | |||
28404 | LD HL,32695 | 32695 holds the index of the current message in the message queue at 32696 | ||
28407 | LD A,(HL) | Pick up the index of the current message (0-7) | ||
28408 | AND 7 | Point HL at the corresponding slot in the message queue | ||
28410 | ADD A,184 | |||
28412 | LD L,A | |||
28413 | LD A,(HL) | Pick up the number of the current message | ||
28414 | AND A | Is there a message being displayed at the moment? | ||
28415 | JR NZ,28426 | Jump if so | ||
28417 | CALL 64121 | Check whether there are any messages remaining in the message queue | ||
28420 | LD HL,(23672) | Collect the two least significant bytes of the system variable FRAMES in HL | ||
28423 | JR NZ,28454 | Jump if there is another message waiting in the queue | ||
28425 | RET Z | This return always happens | ||
There is a message being displayed at the moment.
|
||||
28426 | CALL 30160 | A=minimum number of subintervals of 0.64s that the current message (or message portion) should be displayed for before being replaced | ||
28429 | LD HL,0 | DE=32*A | ||
28432 | LD DE,32 | |||
28435 | ADD HL,DE | |||
28436 | DEC A | |||
28437 | JR NZ,28435 | |||
28439 | EX DE,HL | |||
28440 | LD HL,(23672) | Collect the two least significant bytes of the system variable FRAMES in HL | ||
28443 | LD BC,(32672) | BC=two least significant bytes of the system variable FRAMES as they were when the last message was displayed | ||
28447 | SBC HL,BC | Is it time to display the next message (or next portion of the current message) yet? | ||
28449 | SBC HL,DE | |||
28451 | RET C | Return if not | ||
28452 | ADD HL,DE | Restore the current value of the two least significant bytes of the system variable FRAMES to HL | ||
28453 | ADD HL,BC | |||
28454 | LD (32672),HL | Update the message display timer at 32672 | ||
This entry point is used by the routine at 29716.
|
||||
28457 | EXX | |||
28458 | LD HL,32639 | Fill the message buffer at 32608 with spaces | ||
28461 | LD BC,8224 | |||
28464 | LD (HL),C | |||
28465 | DEC L | |||
28466 | DJNZ 28464 | |||
28468 | EXX | |||
28469 | LD HL,32641 | 32641 holds the submessage indicator (0, 2, 4, 6 or 8) | ||
28472 | LD A,(HL) | Pick it up in A | ||
28473 | AND A | Are we in the middle of a message at the moment? | ||
28474 | JR NZ,28512 | Jump if so | ||
We've reached the end of the current message. Time to display the next message, or clear the message line if there are no messages waiting in the queue.
|
||||
28476 | LD L,183 | HL=32695 (which holds the index of the current message in the message queue at 32696) | ||
28478 | LD A,(HL) | Pick up this index | ||
28479 | INC (HL) | Increment the index | ||
28480 | AND 7 | Point HL at the current message in the queue | ||
28482 | ADD A,184 | |||
28484 | LD L,A | |||
28485 | LD (HL),0 | Set the current message number to 0 (no message) | ||
28487 | SUB 7 | Point HL at the next message in the queue | ||
28489 | OR 8 | |||
28491 | LD L,A | |||
28492 | LD A,(HL) | Pick up the message number | ||
28493 | AND A | Is there another message waiting in the queue? | ||
28494 | JR Z,28534 | Jump if not to clear the message line | ||
Here we transition from no message to top-level message, or from one message level to a submessage. A holds the (sub)message number.
|
||||
28496 | LD C,A | Point BC at the LSB of the message address | ||
28497 | LD B,108 | |||
28499 | LD L,129 | Increase the submessage indicator at 32641 by 2 (to 2, 4, 6 or 8) | ||
28501 | INC (HL) | |||
28502 | INC (HL) | |||
28503 | LD L,(HL) | Point HL at where the LSB of the message address will be stored | ||
28504 | SET 7,L | |||
28506 | LD A,(BC) | Copy the LSB of the message address here | ||
28507 | LD (HL),A | |||
28508 | INC B | Point BC at the MSB of the message address | ||
28509 | INC L | Point HL at where the MSB of the message address will be stored | ||
28510 | LD A,(BC) | Copy the MSB of the message address here | ||
28511 | LD (HL),A | |||
28512 | LD L,129 | HL=32641 (submessage indicator) | ||
28514 | LD L,(HL) | Point HL at the LSB of the address of the next character in the message | ||
28515 | SET 7,L | |||
28517 | LD E,(HL) | Pick up the LSB in E | ||
28518 | INC (HL) | Increment the LSB | ||
28519 | INC HL | Point HL at the MSB of the address of the next character in the message | ||
28520 | LD D,(HL) | Pick up the MSB in D | ||
28521 | JR NZ,28524 | Jump unless the LSB rolled over to 0 | ||
28523 | INC (HL) | Increment the MSB | ||
28524 | LD A,(DE) | A=ASCII code of the next character in the message | ||
28525 | AND A | Is it the end marker? | ||
28526 | JR NZ,28543 | Jump if not | ||
We've reached the end of the top-level message or a submessage.
|
||||
28528 | LD L,129 | HL=32641 (submessage indicator) | ||
28530 | DEC (HL) | Reduce the submessage indicator by 2 | ||
28531 | DEC (HL) | |||
28532 | JR NZ,28474 | Jump unless we've reached the end of the top-level message | ||
It's time to print the contents of the message buffer.
|
||||
28534 | LD HL,32608 | Point HL at the first byte of the message buffer at 32608 | ||
28537 | LD DE,20608 | DE=display file address | ||
28540 | JP 28160 | Print the contents of the message buffer | ||
At this point A holds the ASCII code of the next character in the message.
|
||||
28543 | CP 32 | Is the ASCII code of the character < 32? | ||
28545 | JR C,28496 | Jump if so to deal with a submessage | ||
28547 | JR NZ,28560 | Jump if the ASCII code of the character is > 32 | ||
The next character in the message is a space. In case there's not enough room left in the message buffer for the word that follows, we now save the submessage indicator and submessage addresses.
|
||||
28549 | LD HL,32641 | Copy the submessage indicator and submessage addresses from 32641 to 32512-32527 | ||
28552 | LD BC,16 | |||
28555 | LD DE,32512 | |||
28558 | LDIR | |||
28560 | CP 96 | Is the ASCII code of the character < 96? | ||
28562 | JR C,28572 | Jump if so | ||
28564 | JR Z,28534 | Jump if the ASCII code of the character is 96 (newline) | ||
28566 | CP 100 | Is the ASCII code of the character >= 100? | ||
28568 | JR NC,28496 | Jump if so to deal with a submessage | ||
28570 | JR 28604 | Jump forward to deal with ASCII code 97 or 98 (99 is not used) | ||
28572 | EXX | |||
28573 | INC L | Point HL' at the next free byte in the message buffer at 32608 | ||
28574 | LD (HL),A | Store the ASCII code of the message character there | ||
28575 | BIT 7,L | Reset the zero flag if we've reached the end of the message buffer (HL'=32640) | ||
28577 | EXX | |||
28578 | JR Z,28512 | Jump if there's still space left in the message buffer | ||
The message buffer at 32608 is full.
|
||||
28580 | LD HL,32512 | Restore the submessage indicator and message addresses to 32641 | ||
28583 | LD DE,32641 | |||
28586 | LD BC,16 | |||
28589 | LDIR | |||
28591 | LD L,128 | HL=32640 (message buffer overflow byte) | ||
28593 | LD A,(HL) | Remove all characters from the end of the message buffer back to the last space | ||
28594 | LD (HL),C | |||
28595 | DEC L | |||
28596 | LD C,32 | |||
28598 | CP 32 | |||
28600 | JR NZ,28593 | |||
28602 | JR 28534 | Print the contents of the message buffer | ||
The ASCII code of the next character in the message is 97 (person or group of people) or 98 (verb).
|
||||
28604 | ADD A,100 | A=197 or 198 | ||
28606 | CALL 28616 | Randomly select a message number for either a verb or a person or group of people | ||
28609 | JR 28496 |
Prev: 28355 | Up: Map | Next: 28611 |