![]() |
Routines |
| Prev: 40054 | Up: Map | Next: 40199 |
|
Used by the routine at MainLoop.
Called every frame. When the message area is being scrolled this does the scrolling. Otherwise it prints one more character of the first message in the queue, and when that is complete removes the message from the queue.
|
||||
| PrintMessage | 40072 | LD A,(38487) | Fetch the number of lines that are still to be scrolled. | |
| 40075 | AND A | Jump to scroll the message area up by one pixel row if the number is not zero. | ||
| 40076 | JR NZ,ScrollMessageArea | |||
| 40078 | LD A,(38507) | Fetch the number of characters that have been printed of the current message. | ||
| 40081 | AND A | Test whether it is zero. | ||
| 40082 | LD A,(38508) | Fetch the number of the first message in the queue. | ||
| 40085 | JR NZ,PrintMessage_Character | Jump if a message is being printed. | ||
| 40087 | AND A | Return if the queue is empty. | ||
| 40088 | RET Z | |||
| 40089 | LD A,(38479) | Fetch the flag that is set when the previous message has been completed. | ||
| 40092 | AND A | Jump if the area has been scrolled for this message already. | ||
| 40093 | JR Z,PrintMessage_Start | |||
| 40095 | XOR A | Clear the flag. | ||
| 40096 | LD (38479),A | |||
| 40099 | LD A,8 | Scroll the message area by eight lines before the message is printed... | ||
| 40101 | LD (38487),A | ...by setting the counter. | ||
| 40104 | LD HL,38508 | Point HL at MessageQueue. | ||
| 40107 | LD A,(HL) | Fetch its number. | ||
| 40108 | DEC A | Return if it is not message number one, which is "SECTOR n". | ||
| 40109 | RET NZ | |||
| 40110 | INC HL | Move on to the argument, which is the sector number. | ||
| 40111 | LD A,(HL) | Fetch it. | ||
| 40112 | ADD A,177 | Convert it into the digit that is the last character of the message (the number of the first sector is zero, but it is shown as 49, and bit 7 is set as it is the last character). | ||
| 40114 | LD (40269),A | Write it into the message. | ||
| 40117 | RET | Return. | ||
| PrintMessage_Start | 40118 | LD A,(38508) | Fetch the number of the message. | |
| PrintMessage_Character | 40121 | ADD A,A | Double it to make an index into the table of messages. | |
| 40122 | LD HL,40244 | Point HL at MessageTable. | ||
| 40125 | ADD A,L | Add the index to the address. | ||
| 40126 | LD L,A | Keep the low byte of the message address. | ||
| 40127 | JR NC,PrintMessage_NoCarry | Jump if there was no carry into the high byte. | ||
| 40129 | INC H | Otherwise carry into the high byte. | ||
| PrintMessage_NoCarry | 40130 | LD E,(HL) | Fetch the address of the message... | |
| 40131 | INC HL | ...from the table... | ||
| 40132 | LD D,(HL) | ...into DE. | ||
| 40133 | LD H,0 | Clear the high byte of the index. | ||
| 40135 | LD A,(38507) | Fetch the number of characters that have been printed. | ||
| 40138 | LD L,A | Use it as the low byte of the index. | ||
| 40139 | INC A | Add one... | ||
| 40140 | LD (38507),A | ...and store it as the new number of characters printed. | ||
| 40143 | EX DE,HL | Swap the index and the address of the message. | ||
| 40144 | ADD HL,DE | Find the address of the next character. | ||
| 40145 | LD A,(HL) | Fetch it... | ||
| 40146 | LD C,A | ...and keep it in C. | ||
| 40147 | LD HL,(23606) | Fetch the character set that the game uses... | ||
| 40150 | LD (38424),HL | ...and use it to print text. | ||
| 40153 | LD HL,45096 | Point HL at the position of the first character, with an X position of 40 and a Y position of 176. | ||
| 40156 | CALL ScreenAddress | Convert it to a screen address using ScreenAddress. | ||
| 40159 | ADD HL,DE | Add the index of the character, so that each character is one column further to the right. | ||
| 40160 | LD A,C | Fetch the character... | ||
| 40161 | AND 127 | ...without the flag for the last character. | ||
| 40163 | CALL PrintScreen | Print it using PrintScreen. | ||
| 40166 | LD A,C | Fetch the character again. | ||
| 40167 | AND 128 | Jump to MakeExplosionSound if this is not the last character. | ||
| 40169 | JP Z,MakeExplosionSound | |||
| 40172 | CALL MakeExplosionSound | Make the click for the character. | ||
| 40175 | LD DE,38508 | Point DE at MessageQueue. | ||
| 40178 | LD HL,38510 | Point HL at MessageQueue_Second. | ||
| 40181 | LD BC,16 | Remove the entry that has been shown by moving the others down... | ||
| 40184 | LDIR | ...by one. | ||
| 40186 | XOR A | Clear the last entry. | ||
| 40187 | LD (DE),A | |||
| 40188 | INC DE | Move on to the second byte of the last entry. | ||
| 40189 | LD (DE),A | Clear that too. | ||
| 40190 | LD (38507),A | Start the next message at its first character. | ||
| 40193 | LD A,1 | Set the flag that says that the area has to be scrolled before the next message is shown... | ||
| 40195 | LD (38479),A | ...and store it. | ||
| 40198 | RET | Return. | ||
| Prev: 40054 | Up: Map | Next: 40199 |