Prev: 50305 Up: Map Next: 50396
50313: 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 48 and above, the kind of object (bits 2 and 3 of the type) plus five.
Input
IX Object
PickUpItem 50313 LD HL,48131 Point at the first place in the inventory and set a counter for the eleven places.
50316 LD B,11
PickUpItem_Find 50318 LD A,(HL) Jump to PickUpItem_Free if this place is empty.
50319 AND A
50320 JR Z,PickUpItem_Free
50322 INC HL Move on to the next place, and loop back until all eleven have been checked.
50323 DJNZ PickUpItem_Find
50325 RET Return, because the inventory is full.
PickUpItem_Free 50326 LD A,(IX+0) Fetch the type of the object, and jump to PickUpItem_Special if it is 48 or more.
50329 CP 48
50331 JR NC,PickUpItem_Special
50333 SUB 3 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 50335 LD (HL),A Put the item in the empty place in the inventory.
50336 LD (IX+0),0 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 50340 EX DE,HL Point at the place in the inventory.
50341 LD HL,30065 Point at the character set of the status panel icons.
50344 LD (48044),HL Set it as the font.
50347 LD A,B Work out the screen Y position of the place up the tube.
50348 NEG
50350 ADD A,11
50352 RLCA
50353 RLCA
50354 RLCA
50355 RLCA
50356 AND 240
50358 ADD A,23
50360 LD H,A
50361 LD L,16 Set the screen X position of the item.
50363 CALL CalculateScreenAddress Work out the screen address of the item.
50366 LD A,(DE) Fetch the number of the item.
50367 ADD A,A Multiply it by four, to get the first of the four characters that make up the icon.
50368 ADD A,A
50369 PUSH AF Keep the character code.
50370 CALL PrintGlyph Print the top left character.
50373 POP AF Get the character code back.
50374 INC A Move on to the next character.
50375 INC L Move one position to the right.
50376 PUSH AF Keep the character code.
50377 CALL PrintGlyph Print the top right character.
50380 DEC L Move one position back to the left.
50381 CALL MoveDownRow Move down one row.
50384 POP AF Get the character code back.
50385 INC A Move on to the next character.
50386 PUSH AF Keep the character code.
50387 CALL PrintGlyph Print the bottom left character.
50390 POP AF Get the character code back.
50391 INC A Move on to the next character.
50392 INC L Move one position to the right.
50393 JP PrintGlyph Jump to PrintGlyph to print the bottom right character.
Prev: 50305 Up: Map Next: 50396