Prev: BF37 Up: Map Next: BFD3
BF45: Display Objects Carried
Used by the routine at DrawChangedObjects.
Draws the objects that the player is carrying on the panel, but only if they have changed since they were last drawn. The panel has room for three objects, which are drawn from the left: the object that was picked up last comes first. Each object is drawn in a space of 18 by 18 pixels, with a colour that goes with it.
DisplayObjectsCarried BF45 LD A,($5BB4) Fetch the flag that says the objects carried have changed from ObjectsCarriedChangedFlag.
BF48 AND A Test it.
BF49 RET Z Return if they have not changed.
BF4A XOR A Clear A.
BF4B LD ($5BB4),A Clear the flag at ObjectsCarriedChangedFlag.
This entry point is used by the routine at RunGame.
The objects are drawn using an object that is kept just for drawing the panel.
DisplayObjects BF4E PUSH IX Stash IX on the stack.
BF50 LD IX,$BFDB Point IX at PanelObject.
BF54 LD B,$03 Set the number of objects to 03.
BF56 LD HL,$5BDC Point HL at ObjectsCarried_Newest.
DisplayObjects_Next BF59 PUSH BC Stash the number of objects left on the stack.
BF5A PUSH HL Stash the address of the object carried on the stack.
BF5B LD A,B Copy the number of objects left into A.
BF5C NEG Negate it.
BF5E ADD A,$03 Add 03, to get the number of objects done.
BF60 SLA A Multiply it by eight.
BF62 SLA A
BF64 SLA A
BF66 LD C,A Stash it in C.
BF67 SLA A Multiply it by two.
BF69 ADD A,C Add the number multiplied by eight, to get it multiplied by 18.
BF6A ADD A,$10 Add 10 to get the pixel X coordinate.
BF6C LD (IX+$1A),A Set the pixel X coordinate.
BF6F LD (IX+$1B),$00 Set the pixel Y coordinate to 00.
BF73 LD C,(IX+$1A) Fetch the pixel X coordinate into C.
BF76 LD B,(IX+$1B) Fetch the pixel Y coordinate into B.
BF79 PUSH HL Stash the address of the object carried on the stack.
BF7A CALL CalculateBufferAddress Find the address in the screen buffer.
BF7D LD L,C Copy it to HL.
BF7E LD H,B
BF7F LD BC,$0318 Set the width to 03 bytes and the height to 18 lines.
BF82 XOR A Set the fill byte to 00.
BF83 CALL FillWindow Clear the area.
BF86 POP HL Restore the address of the object carried from the stack.
BF87 LD A,(HL) Fetch the graphic number of the object.
BF88 AND A Test it.
BF89 JR Z,DisplayObjectsCarried_CopyPlace Jump to DisplayObjectsCarried_CopyPlace if there is no object.
BF8B LD (IX+$00),A Set the graphic number of the panel object.
BF8E CALL PrintSprite Draw the object.
Copy the area from the screen buffer to the display.
DisplayObjectsCarried_CopyPlace BF91 LD C,(IX+$1A) Fetch the pixel X coordinate into C.
BF94 LD B,(IX+$1B) Fetch the pixel Y coordinate into B.
BF97 CALL CalculateScreenAddress Find the address in the display.
BF9A CALL CalculateBufferAddress Find the address in the screen buffer.
BF9D LD L,C Copy it to HL.
BF9E LD H,B
BF9F LD BC,$1803 Set the number of lines to 18 and the number of bytes to 03.
BFA2 CALL CopyBlockToScreen Copy the area to the display.
Colour the area.
BFA5 POP HL Restore the address of the object carried from the stack.
BFA6 POP BC Restore the number of objects left from the stack.
BFA7 PUSH BC Stash the number of objects left on the stack.
BFA8 PUSH HL Stash the address of the object carried on the stack.
BFA9 LD A,(HL) Fetch the graphic number of the object.
BFAA AND %00001111 Keep the number of the object.
BFAC LD E,A Copy it into E.
BFAD LD D,$00 Clear D.
BFAF LD HL,$BFD3 Point HL at ObjectAttributes.
BFB2 ADD HL,DE Find the attribute of the object.
BFB3 LD C,(HL) Fetch it into C.
BFB4 LD L,(IX+$1A) Set L to the pixel X coordinate.
BFB7 LD A,(IX+$1B) Fetch the pixel Y coordinate.
BFBA ADD A,$17 Add 17, to get the top of the area.
BFBC LD H,A Use it as the Y coordinate of the position.
BFBD CALL CalculateAttributeAddress Find the address in the attribute file.
BFC0 EX DE,HL Copy it to HL.
BFC1 LD A,C Fetch the attribute.
BFC2 LD BC,$0303 Set the width to 03 and the height to 03.
BFC5 CALL FillWindow Colour the area.
BFC8 POP HL Restore the address of the object carried from the stack.
BFC9 POP BC Restore the number of objects left from the stack.
BFCA INC HL Move on to the next object carried.
BFCB INC HL
BFCC INC HL
BFCD INC HL
BFCE DJNZ DisplayObjects_Next Jump to DisplayObjects_Next until all of the objects have been drawn.
BFD0 POP IX Restore IX from the stack.
BFD2 RET Return.
View the equivalent code in;
Prev: BF37 Up: Map Next: BFD3