Prev: 32061 Up: Map Next: 32363
32151: Messaging: Girl
Input
A Message block ID
19 is the highest message block ID.
Messaging_Girl 32151 LD (36079),A Write the given message block ID to *CurrentMessageBlock.
32154 CP 19 Return if the message block ID is equal to or higher than 19.
32156 RET NC
32157 INC A Increment A by one.
32158 LD HL,36014 HL=36014 (i.e. Table_InGameMessaging-3).
Find the relevant message block.
FindMessagingBlock 32161 INC HL Increment HL by three.
32162 INC HL
32163 INC HL
32164 DEC A Decrease A by one and keep jumping back to FindMessagingBlock until it is zero.
32165 JR NZ,FindMessagingBlock
Reference the message block data.
32167 LD E,(HL) Load the referenced message block into DE.
32168 INC HL
32169 LD D,(HL)
32170 INC HL Write the number of messages in this message block to *CurrentNumberOfMessagesInBlock.
32171 LD A,(HL)
32172 LD (36074),A
32175 LD (36075),DE Write DE to both *PointerToStartOfCurrentMessageBlock and *PointerCurrentMessageString.
32179 LD (36077),DE
Loop through each message in this message block until the random number generator returns a number less than 10. This is likely a completely arbitrary number.
PickRandomMessage 32183 LD B,A B=the number of messages in this message block.
PickRandomMessage_Loop 32184 CALL GetRandomNumber Call GetRandomNumber.
32187 CP 10 Jump to Prepare_GirlMessaging if the picked random number is lower than 10.
32189 JR C,Prepare_GirlMessaging
Each message is 0054 bytes long, so here we're moving to the address of the next message.
32191 LD DE,54 HL=*PointerCurrentMessageString+0054.
32194 LD HL,(36077)
32197 ADD HL,DE
32198 LD (36077),HL Write HL to *PointerCurrentMessageString.
32201 DJNZ PickRandomMessage_Loop Decrease counter by one and loop back to PickRandomMessage_Loop until counter is zero.
Nothing was picked, so refresh the message count and repoint *PointerCurrentMessageString to the first message again.
32203 LD HL,(36075) Write *PointerToStartOfCurrentMessageBlock to *PointerCurrentMessageString.
32206 LD (36077),HL
32209 LD A,(36074) A=*CurrentNumberOfMessagesInBlock.
32212 JR PickRandomMessage Jump to PickRandomMessage.
A message has been picked, so prepare the display for printing it.
Prepare_GirlMessaging 32214 XOR A Set the current line as 0.
Print_GirlMessaging_Loop 32215 PUSH AF Stash the current line on the stack.
Set the speech bubble attributes.
32216 LD A,16 Set INK: BLACK.
32218 RST 16
32219 XOR A
32220 RST 16
32221 LD A,17 Set PAPER: WHITE.
32223 RST 16
32224 LD A,7
32226 RST 16
32227 LD A,22 PRINT AT: 0, 13.
32229 RST 16
32230 POP AF
32231 PUSH AF
32232 RST 16
32233 LD A,13
32235 RST 16
32236 LD A,19 BRIGHT: ON.
32238 RST 16
32239 LD A,1
32241 RST 16
32242 LD DE,(36077) DE=*PointerCurrentMessageString.
32246 LD BC,14 Set the line length 0014 in BC.
32249 POP AF Restore the current line from the stack.
The last line is two characters less than the previous lines. This gives us a slight "speech bubble" effect. Kind of... Sorta...
32250 CP 3 Are we on line 3?
32252 PUSH AF Stash the current line on the stack.
32253 JR NZ,Print_GirlMessaging Jump to Print_GirlMessaging if we're not yet on line 3.
32255 DEC BC Decrease the message length by two.
32256 DEC BC
Print the current line.
Print_GirlMessaging 32257 CALL Print40ColumnText Call Print40ColumnText.
On return, DE points to the start of the next line - so update the pointer.
32260 LD (36077),DE Write DE to *PointerCurrentMessageString.
32264 POP AF Restore the current line from the stack.
32265 CP 3 Jump to Printed_GirlMessaging if we're on line 3.
32267 JR Z,Printed_GirlMessaging
32269 INC A Increment A by one.
32270 JR Print_GirlMessaging_Loop Jump to Print_GirlMessaging_Loop.
The messaging has been printed.
Printed_GirlMessaging 32272 LD A,(36079) Jump to Messaging_Girl_0 if *CurrentMessageBlock is equal to either 17 or 15.
32275 CP 17
32277 JR Z,Messaging_Girl_0
32279 CP 15
32281 JR Z,Messaging_Girl_0
32283 JR GirlMessaging_GetInput Jump to GirlMessaging_GetInput.
Messaging_Girl_0 32285 LD A,0 Write 0 to *37573.
32287 LD (37573),A
GirlMessaging_GetInput 32290 CALL Controls Call Controls.
32293 CP 5 Jump to GirlMessaging_GetInput if A is higher than 5.
32295 JR NC,GirlMessaging_GetInput
32297 LD A,(36079) Jump to RemoveSpeechBubble if *CurrentMessageBlock is not equal to 18.
32300 CP 18
32302 JR NZ,RemoveSpeechBubble
32304 LD HL,22528 HL=22528 (screen buffer location).
32307 LD DE,22591 DE=22591 (attribute buffer location).
32310 LD C,32 C=32.
Messaging_Girl_1 32312 PUSH HL Stash HL and DE on the stack.
32313 PUSH DE
32314 LD B,6 B=6.
Messaging_Girl_2 32316 XOR A A=0.
32317 LD (HL),0 Write 0 to *HL.
32319 LD (DE),A Write A to *DE.
32320 PUSH DE Stash DE on the stack.
32321 LD DE,64 HL+=0064.
32324 ADD HL,DE
32325 PUSH HL IX=HL (using the stack).
32326 POP IX
32328 POP HL Restore HL from the stack.
32329 ADD HL,DE HL+=DE.
32330 EX DE,HL Exchange the DE and HL registers.
32331 PUSH IX HL=IX (using the stack).
32333 POP HL
32334 DJNZ Messaging_Girl_2 Decrease counter by one and loop back to Messaging_Girl_2 until counter is zero.
32336 LD A,14 A=14.
Messaging_Girl_3 32338 DJNZ Messaging_Girl_3 Decrease counter by one and loop back to Messaging_Girl_3 until counter is zero.
32340 DEC A Decrease A by one.
32341 JR NZ,Messaging_Girl_3 Jump to Messaging_Girl_3 until A is zero.
32343 POP DE Restore DE and HL from the stack.
32344 POP HL
32345 INC HL Increment HL by one.
32346 DEC DE Decrease DE by one.
32347 DEC C Decrease C by one.
32348 JR NZ,Messaging_Girl_1 Jump to Messaging_Girl_1 until C is zero.
Count to 327680 to give the player a chance to read the messaging.
32350 LD B,5 Set a counter for 5 loops.
Messaging_Girl_PauseLoop 32352 LD HL,0 HL=0000.
Messaging_Girl_InnerPauseLoop 32355 DEC HL Decrease HL by one.
32356 LD A,H Loop back to Messaging_Girl_InnerPauseLoop until HL is zero.
32357 OR L
32358 JR NZ,Messaging_Girl_InnerPauseLoop
32360 DJNZ Messaging_Girl_PauseLoop Decrease the counter by one and loop back to Messaging_Girl_PauseLoop until the counter is zero.
32362 RET Return.
Prev: 32061 Up: Map Next: 32363