Prev: C00E Up: Map Next: C0A7
C017: Drop Object
Used by the routine at HandlePickupAndDrop.
Drops the oldest carried object into the free object record in IY, at the position of the player. If there is no object in the oldest place in the inventory, the carried objects are only moved along. The player rises by 0C, to be out of the way of the object that is dropped.
Input
IX Record of the object of the legs of the player
IY Free object record
DropObject C017 LD HL,$A72E Take the oldest of the carried objects, ObjectsCarried_Oldest.
C01A LD A,(HL) Fetch the type of it.
C01B INC HL
C01C AND A Jump to DropObject_MoveAlong to move the objects along if there is none.
C01D JR Z,DropObject_MoveAlong
C01F LD A,($A741) Fetch the flag from NoRoomToDropFlag.
C022 AND A Jump to HandlePickupAndDrop_Done if there is no room above the player.
C023 JR NZ,HandlePickupAndDrop_Done
C025 DEC HL Fetch the type of the object again.
C026 LD A,(HL)
C027 INC HL
C028 LD (IY+$00),A Make it the type of the new object.
C02B PUSH HL Stash the address of the flags of the carried object on the stack.
Copy the player to the new object, which gives it the position, the speeds and the room of the player.
C02C LD BC,$001F Set the number of bytes to copy in BC.
C02F PUSH IX Take the player, using the stack.
C031 POP HL
C032 PUSH IY Take the new object, using the stack.
C034 POP DE
C035 INC DE Move on to the second byte of each of them.
C036 INC HL
C037 LDIR Copy the record of the player to the new object.
Raise both of the object records of the player, to be above the dropped object.
C039 LD A,(IX+$03) Add 0C to the height of the legs.
C03C ADD A,$0C
C03E LD (IX+$03),A
C041 LD A,(IX+$23) Add 0C to the height of the body.
C044 ADD A,$0C
C046 LD (IX+$23),A
Make the new object ready to be drawn.
C049 PUSH IX Stash the records of the player and the object on the stack.
C04B PUSH IY
C04D PUSH IY Take the new object as the one being updated, using the stack.
C04F POP IX
C051 CALL SetSpriteOffset_Minus16_Minus8 Call SetSpriteOffset_Minus16_Minus8 to set where the sprite is drawn.
C054 CALL CalculatePixelCoordinates Call CalculatePixelCoordinates to work out where the sprite goes on the screen.
C057 CALL ApplyGravityAndMove Call ApplyGravityAndMove to find where the object can be.
C05A CALL SetWipeAndDrawFlags Call SetWipeAndDrawFlags to mark the object to be drawn.
C05D POP IY Restore the records of the object and the player from the stack.
C05F POP IX
This entry point is used by the routine at PickUpObject.
Set up the dropped object, which is also done when an object is swapped for one that is picked up.
DropObject_SetUp C061 LD (IY+$04),$05 Set the half size along x to 05.
C065 LD (IY+$05),$05 Set the half size along y to 05.
C069 LD (IY+$06),$0C Set the size along z to 0C.
C06D POP HL Restore the address of the flags of the carried object from the stack.
C06E LD A,(HL) Fetch the flags of the carried object.
C06F INC HL
C070 LD (IY+$07),A Set them as the flags of the new object.
C073 LD A,(IX+$08) Copy the room of the player to the new object.
C076 LD (IY+$08),A
C079 LD A,(HL) Fetch the low byte of the address of the object in the store.
C07A INC HL
C07B LD (IY+$10),A Keep the low byte of the store address in the new object.
C07E LD A,(HL) Fetch the high byte of the address of the object in the store.
C07F LD (IY+$11),A
C082 LD H,A Set HL to the address of the object in the store.
C083 LD L,(IY+$10)
C086 LD A,(IY+$00) Write the type of the object to its entry in the store, so that it stays in the room.
C089 LD (HL),A
C08A SET 0,(IY+$0D) Set bit 0 of the hit flags of the new object.
C08E CALL SetWipeAndDrawFlagsForObject Call SetWipeAndDrawFlagsForObject to mark the new object to be drawn.
This entry point is used by the routine at PickUpObject.
Move the carried objects along one place, which gets rid of the oldest and leaves the first place empty.
DropObject_MoveAlong C091 LD HL,$A72D Start at the last byte of the third entry of ObjectsCarried.
C094 LD DE,$A731 Take the last byte of the fourth entry.
C097 LD BC,$000C Set the number of bytes in BC to 0C, three objects.
C09A LDDR Move them along, copying down from the end.
C09C LD DE,$A722 Take the first place of the inventory, ObjectsCarried.
C09F LD B,$04 Set a counter in B of four bytes.
C0A1 CALL ClearBytes Call ClearBytes to clear the first place of the inventory.
C0A4 JP HandlePickupAndDrop_Done Jump to HandlePickupAndDrop_Done.
Prev: C00E Up: Map Next: C0A7