Prev: A316 Up: Map Next: A3C3
A36A: A dead goblin comes back
Chained after the normal ATTACK handler in each goblin's object record (action 15 runs 90DB, then this). If the attack killed the goblin, it comes straight back: the dead flag is cleared, its number is written back into its slot in the character table (so it acts again), it is moved to another room and given a new adjective, all from its 6-byte entry in the table at A3C3. The game prints 'the goblin falls down a hole and vanishes.'
It then means to announce '- another goblin' if the goblin's new room is Bilbo's, but compares Bilbo's room with register B, which this routine never sets; B holds whatever the attack routine left there (the attack value), so the announcement depends on chance.
A36A LD IX,($B5F8) IX = the goblin's record
A36E BIT 3,(IX+$07) Did the attack kill it?
A372 RET Z No: nothing to do
A373 RES 3,(IX+$07) Bring it back to life
A377 LD DE,$0006 Find its entry in the table at A3C3 (6 bytes each)
A37A LD IY,$A3C3
A37E LD A,($B5D9)
A381 CP (IY+$00)
A384 JR Z,$A38A
A386 ADD IY,DE
A388 JR $A381
A38A PUSH IY HL = the entry
A38C POP HL
A38D INC HL DE = its slot in the character table
A38E LD E,(HL)
A38F INC HL
A390 LD D,(HL)
A391 LD (DE),A Put the goblin back in the slot: it will act again
A392 INC HL Move it to its new room
A393 LD A,(HL)
A394 LD (IX+$10),A
A397 INC HL Give it a new adjective
A398 LD A,(HL)
A399 LD (IX+$0A),A
A39C INC HL
A39D LD A,(HL)
A39E LD (IX+$0B),A
A3A1 LD HL,$AF5A "the goblin falls down a hole and vanishes."
A3A4 CALL $72D4
A3A7 LD A,($C01B) Is Bilbo in the room it went to? (B is never set here: see above)
A3AA CP B
A3AB RET NZ No
A3AC LD A,$2D Print "-"...
A3AE CALL $7580
A3B1 LD DE,$005E ...ANOTHER...
A3B4 CALL $74B8
A3B7 LD DE,$02E6 ...GOBLIN...
A3BA CALL $74B8
A3BD LD HL,$AF0B ...and the rest of the sentence
A3C0 JP $72D4
Prev: A316 Up: Map Next: A3C3