Prev: C481 Up: Map Next: C4DC
C489: Pick Up Item
Used by the routines at UpdateMonsterItem and UpdateVillageItem.
Puts the object at IX into the first free place in the inventory (the eleven bytes from Inventory), removes the object from the village and draws the item in the inventory tube. Nothing happens if the inventory is full.
The number of the item is the type of the object minus three, or, for objects of type 30 and above, the kind of object (bits 2 and 3 of the type) plus five.
Input
IX Object
PickUpItem C489 LD HL,$BC03 Point at the first place in the inventory and set a counter for the eleven places.
C48C LD B,$0B
PickUpItem_Find C48E LD A,(HL) Jump to PickUpItem_Free if this place is empty.
C48F AND A
C490 JR Z,PickUpItem_Free
C492 INC HL Move on to the next place, and loop back until all eleven have been checked.
C493 DJNZ PickUpItem_Find
C495 RET Return, because the inventory is full.
PickUpItem_Free C496 LD A,(IX+$00) Fetch the type of the object, and jump to PickUpItem_Special if it is 30 or more.
C499 CP $30
C49B JR NC,PickUpItem_Special
C49D SUB $03 Subtract three from the type to make the number of the item.
This entry point is used by the routine at PickUpItem_Special.
PickUpItem_Store C49F LD (HL),A Put the item in the empty place in the inventory.
C4A0 LD (IX+$00),$00 Remove the object from the village.
This entry point is used by the routine at ThrowItem.
Draws the icon of an item in the inventory tube.
DrawInventoryItem C4A4 EX DE,HL Point at the place in the inventory.
C4A5 LD HL,$7571 Point at the character set of the status panel icons.
C4A8 LD ($BBAC),HL Set it as the font.
C4AB LD A,B Work out the screen Y position of the place up the tube.
C4AC NEG
C4AE ADD A,$0B
C4B0 RLCA
C4B1 RLCA
C4B2 RLCA
C4B3 RLCA
C4B4 AND $F0
C4B6 ADD A,$17
C4B8 LD H,A
C4B9 LD L,$10 Set the screen X position of the item.
C4BB CALL CalculateScreenAddress Work out the screen address of the item.
C4BE LD A,(DE) Fetch the number of the item.
C4BF ADD A,A Multiply it by four, to get the first of the four characters that make up the icon.
C4C0 ADD A,A
C4C1 PUSH AF Keep the character code.
C4C2 CALL PrintGlyph Print the top left character.
C4C5 POP AF Get the character code back.
C4C6 INC A Move on to the next character.
C4C7 INC L Move one position to the right.
C4C8 PUSH AF Keep the character code.
C4C9 CALL PrintGlyph Print the top right character.
C4CC DEC L Move one position back to the left.
C4CD CALL MoveDownRow Move down one row.
C4D0 POP AF Get the character code back.
C4D1 INC A Move on to the next character.
C4D2 PUSH AF Keep the character code.
C4D3 CALL PrintGlyph Print the bottom left character.
C4D6 POP AF Get the character code back.
C4D7 INC A Move on to the next character.
C4D8 INC L Move one position to the right.
C4D9 JP PrintGlyph Jump to PrintGlyph to print the bottom right character.
Prev: C481 Up: Map Next: C4DC