Prev: BA34 Up: Map Next: BAC2
BA3D: Display Objects Carried
Used by the routine at RunGame.
Displays the objects which the player is carrying in the panel. Each of the three places takes three cells across and is 18 pixels apart from the next. The place is cleared, the sprite of the object is printed in the screen buffer and copied to the screen, and the cells are coloured according to the shape of the object (see InventoryColours).
Draw the three places in the panel.
DisplayObjectsCarried BA3D PUSH IX Stash IX on the stack.
BA3F LD IX,$BACA Use the temporary object, TemporaryObject.
BA43 LD B,$03 Set a counter of 03 places.
BA45 LD HL,$A726 Start with the first carried object, ObjectsCarried_Newest.
Work out the pixel x of this place (18 times the place, plus 10).
DisplayObjectsCarried_Next BA48 PUSH BC Stash the counter on the stack.
BA49 PUSH HL Stash the address of the object on the stack.
BA4A LD A,B Copy the counter to A.
BA4B NEG Make it negative.
BA4D ADD A,$03 ...and add three, to get the number of the icon.
BA4F SLA A Multiply it by eight.
BA51 SLA A
BA53 SLA A
BA55 LD C,A Keep it in C.
BA56 SLA A Multiply by two again, which makes 10 times the number.
BA58 ADD A,C Add the eight times.
BA59 ADD A,$10 Add 10.
BA5B LD (IX+$1A),A Write it as the screen x co-ordinate of the temporary object.
BA5E LD (IX+$1B),$00 Write 00 as the screen y co-ordinate.
Clear the place and print the sprite.
BA62 LD C,(IX+$1A) Fetch the pixel x position into C.
BA65 LD B,(IX+$1B) Fetch the pixel y position into B.
BA68 PUSH HL Stash the address of the object on the stack.
BA69 CALL CalculateBufferAddress Call CalculateBufferAddress to get the address in the buffer.
BA6C LD L,C Copy it to HL.
BA6D LD H,B
BA6E LD BC,$0318 Set BC to 0318.
BA71 XOR A Set A to 00.
BA72 CALL FillWindow Call FillWindow.
BA75 POP HL Restore the address of the object from the stack.
Draw the icon, if there is an object in this entry.
BA76 LD A,(HL) Fetch the type of the object.
BA77 AND A Jump to DisplayObjectsCarried_Copy if the carried entry is empty.
BA78 JR Z,DisplayObjectsCarried_Copy
BA7A LD (IX+$00),A Set the type of the temporary object.
BA7D CALL DrawObject_Sprite Call DrawObject_Sprite to draw its sprite.
Copy the place to the screen.
DisplayObjectsCarried_Copy BA80 LD C,(IX+$1A) Fetch the pixel x position into C.
BA83 LD B,(IX+$1B) Fetch the pixel y position into B.
BA86 CALL CalculateScreenAddress Call CalculateScreenAddress to get the address in the display file.
BA89 CALL CalculateBufferAddress Call CalculateBufferAddress to get the address in the buffer.
BA8C LD L,C Copy it to HL.
BA8D LD H,B
BA8E LD BC,$1803 Set BC to 1803.
BA91 CALL CopyBlockToScreen Call CopyBlockToScreen to copy the icon to the screen.
Colour the cells from the shape.
BA94 POP HL Restore the address of the object from the stack.
BA95 POP BC Keep the counter on the stack.
BA96 PUSH BC
BA97 PUSH HL Stash the address of the object on the stack.
BA98 LD A,(HL) Fetch the type of the object.
BA99 AND %00000111 Keep only bits 0 to 2.
BA9B LD E,A Copy the shape into DE.
BA9C LD D,$00
BA9E LD HL,$BAC2 Point HL at the entry of InventoryColours for the shape.
BAA1 ADD HL,DE
BAA2 LD C,(HL) Fetch the colour into C.
BAA3 LD L,(IX+$1A) Fetch the pixel x position of the place into L.
Add 17 to the y co-ordinate to get to the top of the icon.
BAA6 LD A,(IX+$1B) Fetch the pixel y position of the place.
BAA9 ADD A,$17 Add 17.
BAAB LD H,A Keep it in H.
BAAC CALL CalculateAttributeAddress Call CalculateAttributeAddress to get the address in the attribute file.
BAAF EX DE,HL Swap it into HL.
BAB0 LD A,C Fetch the colour.
BAB1 LD BC,$0303 Set BC to 0303.
BAB4 CALL FillWindow Call FillWindow to set the attributes.
BAB7 POP HL Restore the address of the object and the counter from the stack.
BAB8 POP BC
BAB9 INC HL Move on to the next entry, which is four bytes on.
BABA INC HL
BABB INC HL
BABC INC HL
BABD DJNZ DisplayObjectsCarried_Next Decrease the counter and loop until all three icons have been drawn.
BABF POP IX Restore IX from the stack.
BAC1 RET Return.
View the equivalent code in;
Prev: BA34 Up: Map Next: BAC2