Prev: 99FB Up: Map Next: 9A5D
9A28: Report that a character has arrived
Prints the message at DE (for example 'thorin enters.' or 'X appears.') with the object's name, if object A has just arrived in the room where Bilbo is ($B5E6), was not there before ((HL)), and Bilbo is not in the dark.
9A28 CP $FF Is there actually no object at all?
9A2A RET Z If so, there is nothing to report
9A2B AND A Is it object 0 (Bilbo himself)?
9A2C RET Z If so, do not announce his own arrival
9A2D LD B,A B = the object
9A2E LD A,($976A) Is Bilbo in the dark?
9A31 CP $02
9A33 RET Z Yes: he would not see this anyway
9A34 LD A,B A = the object again
9A35 CALL $9ECB A = its own room
9A38 LD C,A
9A39 CP (HL) Was it already in that room before this turn?
9A3A RET Z Yes: nothing has changed, no need to announce it
9A3B LD A,($B5E6) Is that room the one Bilbo is actually in right now?
9A3E CP C
9A3F RET NZ No: he would not see it arrive
9A40 LD A,($9B37) Was Bilbo himself just moved along with it (e.g. carried in a barrel)?
9A43 AND A
9A44 RET Z No: report it as usual, below
9A45 LD A,$01 Yes: switch output on, since this is happening right in front of him
9A47 LD ($B5F3),A
9A4A PUSH DE HL = whichever "enters"/"appears" message the caller is using
9A4B POP HL
9A4C LD A,B IX = the object's own record
9A4D CALL $9B25
9A50 PUSH DE Save DE
9A51 LD DE,$0008 IX = the object's own words
9A54 ADD IX,DE
9A56 POP DE Restore DE
9A57 PUSH IX Push the object's name as the message parameter
9A59 CALL $72D4 Print the message
9A5C RET
Prev: 99FB Up: Map Next: 9A5D