Routines |
Prev: 55628 | Up: Map | Next: 55885 |
Used by the routine at 55628.
|
||||
Maroc has left a room - all door, creature and object data from the room he's left has been dealt with in the previous routine.
|
||||
55818 | LD A,(60087) | Get room number | ||
55821 | CP 224 | Check if it's a tunnel room (room numbers 224-255) | ||
55823 | JR NC,55837 | If so, there are no creatures to deal with, so skip the next few instructions | ||
55825 | DEC A | Offset starts at 0, not 1, so decrement room number | ||
55826 | LD C,A | Use room number as an offset in BC register pair | ||
55827 | LD B,0 | |||
55829 | LD HL,(56048) | Address pointer for the room creature data set at 27532 | ||
55832 | ADD HL,BC | Add offset (with C = room number) | ||
55833 | LD A,(60343) | Byte indicating which creatures are in the room (that Maroc is leaving) | ||
55836 | LD (HL),A | Copy into the room creature data at 26512 | ||
Get new room number:
|
||||
55837 | LD A,(60080) | Get (new) room number data byte | ||
55840 | CP 255 | If byte set to 255 it indicates that the room number needs to be calculated, so will need calculating using the connecting door table at 26512 | ||
55842 | JR NZ,55857 | If already calculated, skip the next few instructions | ||
55844 | LD HL,(60085) | Address pointer to connecting door data at 26512 | ||
55847 | LD A,(60087) | Get current room number | ||
55850 | CP (HL) | The connecting room will either be byte 2 or 3 (1 door, two rooms) Is the current room equal to byte 2 in the door table? |
||
55851 | JR NZ,55854 | If not, the new room is byte 2 | ||
55853 | INC HL | If so, we need byte 3 | ||
55854 | LD A,(HL) | Get the room byte from the connecting door table | ||
55855 | JR 55874 | |||
If the new room number is already set/calculated, it means it's been changed by some event during the game cycle.
For example, if Maroc:
If so, set Maroc's position in the new room at the point of the room's left wall-floor connector. See Bugs - Teleport spells
|
||||
55857 | LD C,A | Calculated room number - temp store in C | ||
55858 | LD A,48 | Set Maroc's vertical pixel position in the room to 48 pixels | ||
55860 | LD (60276),A | |||
55863 | LD A,16 | Set Maroc's horizontal room position (4-pixel/half-character steps) to 16 | ||
55865 | LD (60277),A | |||
55868 | LD A,0 | |||
55870 | LD (60278),A | Set Maroc's room vertical position to 0 | ||
55873 | LD A,C | Retrieve byte (60080) from C register | ||
Maroc's room has now changed, so he's either gone through a door, run out of energy, or has teleported somewhere.
|
||||
55874 | LD (60087),A | Store new room number (e.g. = room #1 when Maroc is out of energy, room #61 for SUMMON) | ||
55877 | LD A,(60128) | Check Maroc's energy level | ||
55880 | CP 0 | Is it zero? | ||
55882 | JP NZ,49415 | If not 0, Maroc hasn't run out of energy, so if he hasn't just gone through a door he's probably cast some sort of teleport spell. If this is the case, jump out here and initialize the data for his new room. Otherwise, Maroc is out of energy - continue to the next routine. |
Prev: 55628 | Up: Map | Next: 55885 |