Prev: 9C76 Up: Map Next: 9D07
9C88: Print Message
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 9C88 LD A,($9657) Fetch the number of lines that are still to be scrolled.
9C8B AND A Jump to scroll the message area up by one pixel row if the number is not zero.
9C8C JR NZ,ScrollMessageArea
9C8E LD A,($966B) Fetch the number of characters that have been printed of the current message.
9C91 AND A Test whether it is zero.
9C92 LD A,($966C) Fetch the number of the first message in the queue.
9C95 JR NZ,PrintMessage_Character Jump if a message is being printed.
9C97 AND A Return if the queue is empty.
9C98 RET Z
9C99 LD A,($964F) Fetch the flag that is set when the previous message has been completed.
9C9C AND A Jump if the area has been scrolled for this message already.
9C9D JR Z,PrintMessage_Start
9C9F XOR A Clear the flag.
9CA0 LD ($964F),A
9CA3 LD A,$08 Scroll the message area by eight lines before the message is printed...
9CA5 LD ($9657),A ...by setting the counter.
9CA8 LD HL,$966C Point HL at MessageQueue.
9CAB LD A,(HL) Fetch its number.
9CAC DEC A Return if it is not message number one, which is "SECTOR n".
9CAD RET NZ
9CAE INC HL Move on to the argument, which is the sector number.
9CAF LD A,(HL) Fetch it.
9CB0 ADD A,$B1 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 31, and bit 7 is set as it is the last character).
9CB2 LD ($9D4D),A Write it into the message.
9CB5 RET Return.
PrintMessage_Start 9CB6 LD A,($966C) Fetch the number of the message.
PrintMessage_Character 9CB9 ADD A,A Double it to make an index into the table of messages.
9CBA LD HL,$9D34 Point HL at MessageTable.
9CBD ADD A,L Add the index to the address.
9CBE LD L,A Keep the low byte of the message address.
9CBF JR NC,PrintMessage_NoCarry Jump if there was no carry into the high byte.
9CC1 INC H Otherwise carry into the high byte.
PrintMessage_NoCarry 9CC2 LD E,(HL) Fetch the address of the message...
9CC3 INC HL ...from the table...
9CC4 LD D,(HL) ...into DE.
9CC5 LD H,$00 Clear the high byte of the index.
9CC7 LD A,($966B) Fetch the number of characters that have been printed.
9CCA LD L,A Use it as the low byte of the index.
9CCB INC A Add one...
9CCC LD ($966B),A ...and store it as the new number of characters printed.
9CCF EX DE,HL Swap the index and the address of the message.
9CD0 ADD HL,DE Find the address of the next character.
9CD1 LD A,(HL) Fetch it...
9CD2 LD C,A ...and keep it in C.
9CD3 LD HL,($5C36) Fetch the character set that the game uses...
9CD6 LD ($9618),HL ...and use it to print text.
9CD9 LD HL,$B028 Point HL at the position of the first character, with an X position of 28 and a Y position of B0.
9CDC CALL ScreenAddress Convert it to a screen address using ScreenAddress.
9CDF ADD HL,DE Add the index of the character, so that each character is one column further to the right.
9CE0 LD A,C Fetch the character...
9CE1 AND $7F ...without the flag for the last character.
9CE3 CALL PrintScreen Print it using PrintScreen.
9CE6 LD A,C Fetch the character again.
9CE7 AND $80 Jump to MakeExplosionSound if this is not the last character.
9CE9 JP Z,MakeExplosionSound
9CEC CALL MakeExplosionSound Make the click for the character.
9CEF LD DE,$966C Point DE at MessageQueue.
9CF2 LD HL,$966E Point HL at MessageQueue_Second.
9CF5 LD BC,$0010 Remove the entry that has been shown by moving the others down...
9CF8 LDIR ...by one.
9CFA XOR A Clear the last entry.
9CFB LD (DE),A
9CFC INC DE Move on to the second byte of the last entry.
9CFD LD (DE),A Clear that too.
9CFE LD ($966B),A Start the next message at its first character.
9D01 LD A,$01 Set the flag that says that the area has to be scrolled before the next message is shown...
9D03 LD ($964F),A ...and store it.
9D06 RET Return.
Prev: 9C76 Up: Map Next: 9D07