Prev: 46380 Up: Map Next: 46463
46408: Create list of characters in room A and load A with number of characters
The list is created at 23422.
Used by the routine at 45963.
Input
A Room index
Output
A Number of characters in room
F Zero flag set if no characters in room, reset otherwise
46408 LD (46437),A Modify instruction at 46436 with room index
46411 PUSH HL Store HL
46412 PUSH BC Store BC
46413 PUSH DE Store DE
46414 PUSH IX Store IX
46416 LD A,255 Set A to 255 (end marker)
46418 LD HL,23429 Point HL at end of table of characters in room of interest
46421 LD B,8 Load B with 8 (as we are clearing 8 entries in the list)
46423 LD (HL),A Set value at address in HL to 255
46424 DEC HL Move HL back one byte
46425 DJNZ 46423 Loop back to 46423
46427 LD IX,24898 Point IX at start of table of characters' current positions at 24898
46431 LD D,0 Set D (index of current character) to zero
46433 LD B,8 Load B with 8 (as there are 8 characters in the game)
46435 LD C,D Set C (count of characters in room of interest) to zero
The operand of the instruction at 46436 represents a room index. This is modified by the instruction at 46408.
46436 LD A,0 Load A with room index
46438 CP (IX+0) If current character's current room is not the room of interest...
46441 JR NZ,46446 ...then skip ahead to 46446
46443 INC C Increase C (count of number of characters in room of interest)
46444 INC HL Advance HL by one byte
46445 LD (HL),D Load index of current character into address in HL
46446 INC IX Advance IX to next character's position data...
46448 INC IX ...
46450 INC IX ...
46452 INC D Increase index of current character (i.e. advance to next character)
46453 DJNZ 46436 Loop back to 46436
46455 LD A,C Load number of characters in room of interest into A
46456 OR A Set zero flag is there are no characters in room, otherwise reset
46457 POP IX Restore IX
46459 POP DE Restore DE
46460 POP BC Restore BC
46461 POP HL Restore HL
46462 RET Return
Prev: 46380 Up: Map Next: 46463