Prev: 55349 Up: Map Next: 55461
55404: Load A with new room index for a character to move into
This routine causes a character to leave his / her current room and move to an adjacent room if that character has a current room index not equal to 99. In this case, the value of A upon entering this routine is the index of that character's current room.
If the character's current room index IS equal to 99 (set by commanding the character to go away), then A instead holds the value ((4 × character index) + 5), which means each character has his or her own room to which they go away (although they don't immediately appear in that room as their room index is set to 99). He or she will reappear next time it is his or her turn to move, appearing in one of the two rooms connected to this one (if possible). The table below shows which room is the "go away base room" for each character:
Character Index A input (room)
Gimbal 0 5 (Roof 5)
Thor 1 9 (4th Floor 1)
Florin 2 13 (4th Floor 5)
Orik 3 17 (3rd Floor 1)
Samsun 4 21 (3rd Floor 5)
Elrand 5 25 (2nd Floor 1)
Rosmar 6 29 (2nd Floor 5)
Banshee 7 33 (1st Floor 1)
Used by the routine at 55233.
Input
A Character's current room index, or ((4 × character index) + 5)
Output
A New room index for character to move into
55404 PUSH HL Store HL
55405 PUSH DE Store DE
55406 ADD A,A Load double A (now either "character to move" index × 8 + 10, or double a room index) into E...
55407 LD E,A ...
55408 LD A,(55218) Load "character to move" index into A
55411 AND 1 Discard all but bit 0 (odd / even)
55413 LD D,A Load 0 for even-numbered character (EC), or 1 for odd-numbered character (OC) into D
55414 LD A,(23404) Load A with number of hours left
55417 AND 1 Set A to 0 for even number of hours left (EH), or 1 for odd number of hours left (OH)
55419 XOR D Set A to 0 for EH / EC or OH/OH, and 1 for EH / OC or OH / EC
55420 ADD A,E Add A (0 or 1, i.e. left or right) to double room index in DE...
55421 LD E,A ...
55422 LD D,0 ...
55424 LD HL,41711 Point HL at table of room connectivity data
55427 ADD HL,DE Add DE as offset
55428 LD A,(HL) Load room index off current room's exit of interest
55429 CP 255 If 255 (i.e. no exit from room)...
55431 JR Z,55456 ...return with A = 255
55433 CP 34 If 34 (i.e. "The Gas Room")...
55435 JR Z,55456 ...return with A = 255
55437 CP 18 If 18 (i.e. "The Little Bottle")...
55439 JR Z,55456 ...return with A = 255
55441 CP 46 If 46 (i.e. "The Pit")...
55443 JR Z,55456 ...return with A = 255
55445 CP 9 If 9 (i.e. "The Tower")...
55447 JR Z,55456 ...return with A = 255
55449 CP 29 If 29 (i.e. "The Wall")...
55451 JR Z,55456 ...return with A = 255
55453 POP DE Restore DE
55454 POP HL Restore HL
55455 RET Return
55456 LD A,255 Set A to 255 (to denote that chosen room exit is impassable)
55458 POP DE Restore DE
55459 POP HL Restore HL
55460 RET Return
Prev: 55349 Up: Map Next: 55461