Prev: A13B Up: Map Next: A17D
A14D: Draw Inventory Item
Used by the routine at DrawInventory.
Draws and colours the item in one slot of the inventory. The item is built up as an entity in the record at EntityToDraw, so that it can be drawn with DrawEntity and coloured with SetEntityAttributes. An empty slot is drawn as the blank sprite (31), which clears the position.
Input
D The Y position
E The X position
HL The inventory slot
DrawInventoryItem A14D PUSH BC Stash the slot counter on the stack.
A14E PUSH DE Stash the position on the stack.
A14F PUSH IX Stash IX on the stack.
A151 LD IX,$A17D Point IX at the entity to draw at EntityToDraw.
A155 LD A,(HL) Fetch the low byte of the address of the item.
A156 INC HL Move to the high byte.
A157 OR (HL) Combine it with the high byte, which gives zero if the slot is empty.
A158 INC HL Move to the sprite ID.
A159 LD A,(HL) Fetch the sprite ID.
A15A JR NZ,DrawInventoryItem_Set Jump to DrawInventoryItem_Set if the slot is not empty.
A15C LD A,$31 A=31 (the blank sprite).
DrawInventoryItem_Set A15E INC HL Move to the attribute.
A15F LD (IX+$00),A Write the sprite ID to *IX+00.
A162 LD (IX+$03),E Write the X position to *IX+03.
A165 LD (IX+$04),D Write the Y position to *IX+04.
A168 LD A,(HL) Fetch the attribute.
A169 INC HL Move to the next slot.
A16A LD (IX+$05),A Write the attribute to *IX+05.
A16D PUSH HL Stash the pointer to the next slot on the stack.
A16E CALL ClearSprite Clear the area with ClearSprite.
A171 CALL DrawEntity Draw the sprite with DrawEntity.
A174 CALL SetEntityAttributes Set the attributes with SetEntityAttributes.
A177 POP HL Restore the pointer to the next slot from the stack.
A178 POP IX Restore IX from the stack.
A17A POP DE Restore the position from the stack.
A17B POP BC Restore the slot counter from the stack.
A17C RET Return.
Prev: A13B Up: Map Next: A17D