Prev: 7D13 Up: Map Next: 7D2F
7D15: Queue message
This adds a new message index to the pending messages queue.
Commentary: The use of C on entry to this routine is puzzling. One routine (check_morale) explicitly sets it to zero before calling, but the other callers do not so we receive whatever was in C previously.
Input
B Message index.
C Unknown: Possibly intended as a second message index.
queue_message 7D15 LD HL,($7D11) Fetch the message queue pointer
7D18 LD A,$FF Is the currently pointed-to index message_QUEUE_END? ($FF)
7D1A CP (HL)
7D1B RET Z Return if so - the queue is full
Is this message index already pending?
7D1C DEC HL Step back two bytes to the next pending entry
7D1D DEC HL
7D1E LD A,(HL) If the new message index matches the pending entry then return
7D1F CP B
7D20 INC HL
7D21 JR NZ,queue_message_0
7D23 LD A,(HL)
7D24 CP C
7D25 RET Z
Add it to the queue.
queue_message_0 7D26 INC HL Store the new message index
7D27 LD (HL),B
7D28 INC HL
7D29 LD (HL),C
7D2A INC HL
7D2B LD ($7D11),HL Update the message queue pointer
7D2E RET Return
Prev: 7D13 Up: Map Next: 7D2F