Prev: 41275 Up: Map Next: 41341
41293: 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 (49), which clears the position.
Input
D The Y position
E The X position
HL The inventory slot
DrawInventoryItem 41293 PUSH BC Stash the slot counter on the stack.
41294 PUSH DE Stash the position on the stack.
41295 PUSH IX Stash IX on the stack.
41297 LD IX,41341 Point IX at the entity to draw at EntityToDraw.
41301 LD A,(HL) Fetch the low byte of the address of the item.
41302 INC HL Move to the high byte.
41303 OR (HL) Combine it with the high byte, which gives zero if the slot is empty.
41304 INC HL Move to the sprite ID.
41305 LD A,(HL) Fetch the sprite ID.
41306 JR NZ,DrawInventoryItem_Set Jump to DrawInventoryItem_Set if the slot is not empty.
41308 LD A,49 A=49 (the blank sprite).
DrawInventoryItem_Set 41310 INC HL Move to the attribute.
41311 LD (IX+0),A Write the sprite ID to *IX+0.
41314 LD (IX+3),E Write the X position to *IX+3.
41317 LD (IX+4),D Write the Y position to *IX+4.
41320 LD A,(HL) Fetch the attribute.
41321 INC HL Move to the next slot.
41322 LD (IX+5),A Write the attribute to *IX+5.
41325 PUSH HL Stash the pointer to the next slot on the stack.
41326 CALL ClearSprite Clear the area with ClearSprite.
41329 CALL DrawEntity Draw the sprite with DrawEntity.
41332 CALL SetEntityAttributes Set the attributes with SetEntityAttributes.
41335 POP HL Restore the pointer to the next slot from the stack.
41336 POP IX Restore IX from the stack.
41338 POP DE Restore the position from the stack.
41339 POP BC Restore the slot counter from the stack.
41340 RET Return.
Prev: 41275 Up: Map Next: 41341