Routines |
Prev: 6EC3 | Up: Map | Next: 6FC3 |
|
||||||||
6EC5 | LD E,A | E=number of the message to be queued | ||||||
6EC6 | LD HL,$7FB7 | 7FB7 holds the index of the current message in the message queue at 7FB8 | ||||||
6EC9 | LD A,(HL) | Pick up the index of the current message | ||||||
6ECA | DEC A | A=index of the last message in the queue | ||||||
6ECB | AND $07 | |||||||
6ECD | ADD A,$B8 | Point HL at the corresponding slot in the message queue at 7FB8 | ||||||
6ECF | LD L,A | |||||||
6ED0 | LD A,(HL) | Pick up the message number from this slot | ||||||
6ED1 | AND A | Is the slot empty? | ||||||
6ED2 | JR Z,$6EE2 | 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.
|
||||||||
6ED4 | LD B,$07 | There are six messages to move up a slot, and one to remove completely | ||||||
6ED6 | LD C,$00 | The final slot will be made empty | ||||||
6ED8 | LD A,(HL) | Pick up the message number from this slot | ||||||
6ED9 | LD (HL),C | Replace it with 0 or the message number from the previous slot | ||||||
6EDA | LD C,A | Save the old contents of this slot | ||||||
6EDB | LD A,L | Point HL at the previous slot in the message queue | ||||||
6EDC | DEC A | |||||||
6EDD | OR $08 | |||||||
6EDF | LD L,A | |||||||
6EE0 | DJNZ $6ED8 | 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.
|
||||||||
6EE2 | LD L,$B7 | HL=7FB7 (which holds the index of the current message in the message queue at 7FB8) | ||||||
6EE4 | LD L,(HL) | Copy the index to L | ||||||
6EE5 | LD A,L | A=index of the next message in the queue | ||||||
6EE6 | INC A | |||||||
6EE7 | AND $07 | |||||||
6EE9 | ADD A,$B8 | Point HL at the corresponding slot in the queue | ||||||
6EEB | LD L,A | |||||||
6EEC | LD A,(HL) | Pick up the message number from this slot | ||||||
6EED | AND A | Is the slot empty? | ||||||
6EEE | JR NZ,$6EE5 | Jump back if not to check the next slot | ||||||
6EF0 | LD (HL),E | Store the message number in this slot | ||||||
6EF1 | NOP | |||||||
6EF2 | NOP | |||||||
6EF3 | NOP | |||||||
6EF4 | LD HL,$7FB7 | 7FB7 holds the index of the current message in the message queue at 7FB8 | ||||||
6EF7 | LD A,(HL) | Pick up the index of the current message (0-7) | ||||||
6EF8 | AND $07 | Point HL at the corresponding slot in the message queue | ||||||
6EFA | ADD A,$B8 | |||||||
6EFC | LD L,A | |||||||
6EFD | LD A,(HL) | Pick up the number of the current message | ||||||
6EFE | AND A | Is there a message being displayed at the moment? | ||||||
6EFF | JR NZ,$6F0A | Jump if so | ||||||
6F01 | CALL $FA79 | Check whether there are any messages remaining in the message queue | ||||||
6F04 | LD HL,($5C78) | Collect the two least significant bytes of the system variable FRAMES in HL | ||||||
6F07 | JR NZ,$6F26 | Jump if there is another message waiting in the queue | ||||||
6F09 | RET Z | This return always happens | ||||||
There is a message being displayed at the moment.
|
||||||||
6F0A | CALL $75D0 | A=minimum number of subintervals of 0.64s that the current message (or message portion) should be displayed for before being replaced | ||||||
6F0D | LD HL,$0000 | DE=32*A | ||||||
6F10 | LD DE,$0020 | |||||||
6F13 | ADD HL,DE | |||||||
6F14 | DEC A | |||||||
6F15 | JR NZ,$6F13 | |||||||
6F17 | EX DE,HL | |||||||
6F18 | LD HL,($5C78) | Collect the two least significant bytes of the system variable FRAMES in HL | ||||||
6F1B | LD BC,($7FA0) | BC=two least significant bytes of the system variable FRAMES as they were when the last message was displayed | ||||||
6F1F | SBC HL,BC | Is it time to display the next message (or next portion of the current message) yet? | ||||||
6F21 | SBC HL,DE | |||||||
6F23 | RET C | Return if not | ||||||
6F24 | ADD HL,DE | Restore the current value of the two least significant bytes of the system variable FRAMES to HL | ||||||
6F25 | ADD HL,BC | |||||||
6F26 | LD ($7FA0),HL | Update the message display timer at 7FA0 | ||||||
This entry point is used by the routine at 7414.
|
||||||||
6F29 | EXX | |||||||
6F2A | LD HL,$7F7F | Fill the message buffer at 7F60 with spaces | ||||||
6F2D | LD BC,$2020 | |||||||
6F30 | LD (HL),C | |||||||
6F31 | DEC L | |||||||
6F32 | DJNZ $6F30 | |||||||
6F34 | EXX | |||||||
6F35 | LD HL,$7F81 | 7F81 holds the submessage indicator (0, 2, 4, 6 or 8) | ||||||
6F38 | LD A,(HL) | Pick it up in A | ||||||
6F39 | AND A | Are we in the middle of a message at the moment? | ||||||
6F3A | JR NZ,$6F60 | 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.
|
||||||||
6F3C | LD L,$B7 | HL=7FB7 (which holds the index of the current message in the message queue at 7FB8) | ||||||
6F3E | LD A,(HL) | Pick up this index | ||||||
6F3F | INC (HL) | Increment the index | ||||||
6F40 | AND $07 | Point HL at the current message in the queue | ||||||
6F42 | ADD A,$B8 | |||||||
6F44 | LD L,A | |||||||
6F45 | LD (HL),$00 | Set the current message number to 0 (no message) | ||||||
6F47 | SUB $07 | Point HL at the next message in the queue | ||||||
6F49 | OR $08 | |||||||
6F4B | LD L,A | |||||||
6F4C | LD A,(HL) | Pick up the message number | ||||||
6F4D | AND A | Is there another message waiting in the queue? | ||||||
6F4E | JR Z,$6F76 | 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.
|
||||||||
6F50 | LD C,A | Point BC at the LSB of the message address | ||||||
6F51 | LD B,$6C | |||||||
6F53 | LD L,$81 | Increase the submessage indicator at 7F81 by 2 (to 2, 4, 6 or 8) | ||||||
6F55 | INC (HL) | |||||||
6F56 | INC (HL) | |||||||
6F57 | LD L,(HL) | Point HL at where the LSB of the message address will be stored | ||||||
6F58 | SET 7,L | |||||||
6F5A | LD A,(BC) | Copy the LSB of the message address here | ||||||
6F5B | LD (HL),A | |||||||
6F5C | INC B | Point BC at the MSB of the message address | ||||||
6F5D | INC L | Point HL at where the MSB of the message address will be stored | ||||||
6F5E | LD A,(BC) | Copy the MSB of the message address here | ||||||
6F5F | LD (HL),A | |||||||
6F60 | LD L,$81 | HL=7F81 (submessage indicator) | ||||||
6F62 | LD L,(HL) | Point HL at the LSB of the address of the next character in the message | ||||||
6F63 | SET 7,L | |||||||
6F65 | LD E,(HL) | Pick up the LSB in E | ||||||
6F66 | INC (HL) | Increment the LSB | ||||||
6F67 | INC HL | Point HL at the MSB of the address of the next character in the message | ||||||
6F68 | LD D,(HL) | Pick up the MSB in D | ||||||
6F69 | JR NZ,$6F6C | Jump unless the LSB rolled over to 0 | ||||||
6F6B | INC (HL) | Increment the MSB | ||||||
6F6C | LD A,(DE) | A=ASCII code of the next character in the message | ||||||
6F6D | AND A | Is it the end marker? | ||||||
6F6E | JR NZ,$6F7F | Jump if not | ||||||
We've reached the end of the top-level message or a submessage.
|
||||||||
6F70 | LD L,$81 | HL=7F81 (submessage indicator) | ||||||
6F72 | DEC (HL) | Reduce the submessage indicator by 2 | ||||||
6F73 | DEC (HL) | |||||||
6F74 | JR NZ,$6F3A | Jump unless we've reached the end of the top-level message | ||||||
It's time to print the contents of the message buffer.
|
||||||||
6F76 | LD HL,$7F60 | Point HL at the first byte of the message buffer at 7F60 | ||||||
6F79 | LD DE,$5080 | DE=display file address | ||||||
6F7C | JP $6E00 | Print the contents of the message buffer | ||||||
At this point A holds the ASCII code of the next character in the message.
|
||||||||
6F7F | CP $20 | Is the ASCII code of the character < 0x20? | ||||||
6F81 | JR C,$6F50 | Jump if so to deal with a submessage | ||||||
6F83 | JR NZ,$6F90 | Jump if the ASCII code of the character is > 0x20 | ||||||
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.
|
||||||||
6F85 | LD HL,$7F81 | Copy the submessage indicator and submessage addresses from 7F81 to 7F00-7F0F | ||||||
6F88 | LD BC,$0010 | |||||||
6F8B | LD DE,$7F00 | |||||||
6F8E | LDIR | |||||||
6F90 | CP $60 | Is the ASCII code of the character < 0x60? | ||||||
6F92 | JR C,$6F9C | Jump if so | ||||||
6F94 | JR Z,$6F76 | Jump if the ASCII code of the character is 0x60 (newline) | ||||||
6F96 | CP $64 | Is the ASCII code of the character >= 0x64? | ||||||
6F98 | JR NC,$6F50 | Jump if so to deal with a submessage | ||||||
6F9A | JR $6FBC | Jump forward to deal with ASCII code 0x61 or 0x62 (0x63 is not used) | ||||||
6F9C | EXX | |||||||
6F9D | INC L | Point HL' at the next free byte in the message buffer at 7F60 | ||||||
6F9E | LD (HL),A | Store the ASCII code of the message character there | ||||||
6F9F | BIT 7,L | Reset the zero flag if we've reached the end of the message buffer (HL'=7F80) | ||||||
6FA1 | EXX | |||||||
6FA2 | JR Z,$6F60 | Jump if there's still space left in the message buffer | ||||||
The message buffer at 7F60 is full.
|
||||||||
6FA4 | LD HL,$7F00 | Restore the submessage indicator and message addresses to 7F81 | ||||||
6FA7 | LD DE,$7F81 | |||||||
6FAA | LD BC,$0010 | |||||||
6FAD | LDIR | |||||||
6FAF | LD L,$80 | HL=7F80 (message buffer overflow byte) | ||||||
6FB1 | LD A,(HL) | Remove all characters from the end of the message buffer back to the last space | ||||||
6FB2 | LD (HL),C | |||||||
6FB3 | DEC L | |||||||
6FB4 | LD C,$20 | |||||||
6FB6 | CP $20 | |||||||
6FB8 | JR NZ,$6FB1 | |||||||
6FBA | JR $6F76 | Print the contents of the message buffer | ||||||
The ASCII code of the next character in the message is 0x61 (person or group of people) or 0x62 (verb).
|
||||||||
6FBC | ADD A,$64 | A=0xC5 or 0xC6 | ||||||
6FBE | CALL $6FC8 | Randomly select a message number for either a verb or a person or group of people | ||||||
6FC1 | JR $6F50 |
Prev: 6EC3 | Up: Map | Next: 6FC3 |