Prev: 48154 Up: Map Next: 48212
48158: Script routine: (18) Have Berk put down an entity behind him, if appropriate
Used by the routine at 48096.
Input
D (Entry at 48160 only) Depth offset for entity being put down
IX Address of complex state data (current level) for Berk
48158 LD D,255 Load D with depth offset of -1 (as Berk is putting down an entity behind him)
This entry point is used by the routine at 48154.
48160 BIT 4,(IX+9) If Berk's carrying-something flag is reset...
48164 RET Z ...then return
Berk is carrying something
48165 RES 4,(IX+9) Reset Berk's carrying-something flag
48169 XOR A Set class of entity held by Berk to zero (i.e. nothing)...
48170 LD (34221),A ...
48173 LD IY,(34260) Load IY with address of complex state data for entity last held by Berk...
48177 RES 5,(IY+10) ...and reset its is-being-carried flag
48181 LD A,(IY+6) Load E with height of entity minus one...
48184 SUB (IY+4) ...
48187 LD E,A ...
48188 LD A,(34222) Load A with y-coordinate minus one of top edge of coloured creature slot Berk is interacting with...
48191 OR A ...and if this is not zero...
48192 JR NZ,48198 ...then skip ahead to 48198
Value at 34222 is zero (i.e. Berk not interacting with a coloured creature slot on level 3)
48194 LD A,(IX+6) Load A with y-coordinate of Berk's bottom edge...
48197 ADD A,D ...plus depth offset...
At this point, A holds either the y-coordinate of Berk's bottom edge plus depth offset, or the y-coordinate minus one of the top edge of (actually the y-coordinate of the bottom of the space within) a coloured creature slot on level 3. This value in A is the y-coordinate that the carried entity's bottom edge will take on when that entity is put down.
48198 LD (IY+6),A Set the y-coordinate of the bottom edge of the put-down entity to value in A
48201 SUB E Set the y-coordinate of the top edge of the put-down entity...
48202 LD (IY+4),A ...to that of the bottom edge, minus the height as appropriate
48205 XOR A Set value at 34222 to zero...
48206 LD (34222),A ...as Berk is not (any longer) interacting with a coloured creature slot on level 3
48209 JP 48096 Advance HL to next script instruction and execute
Prev: 48154 Up: Map Next: 48212