Prev: CB4C Up: Map Next: CB96
CB5B: Handle interactable objects that are falling/flying
Used by the routine at CB00.
Follows from previous routine or jump from CB20 if bit 3 (8) of item byte at EB4E is set (item is moving/falling after being dropped).
CB5B CALL $DAC8 Check that the servant isn't dragging a held object below the bottom of the room boundary, adjusting co-ordinates accordingly
CB5E CALL $E039 Other wall/room boundary checks, including horizontal wall checks
The next routine handles the item's vertical movement speed/momentum. When objects are dropped, they will fall a certain distance that depends on the item's screen height/position:
object being dropped from a height object being dropped from a lower height
CB61 LD A,($EB4D) Vertical movement speed/offset in pixels (negative = up, positive = down)
CB64 ADD A,$0C Adjust vertical movement rate slightly - 12 pixels gives a bit of momentum to the object to create a semblence of gravity when the servant is throwing or dropping an object - this increase means vertical speed will increase if the item is falling, and decrease if it is rising (after being 'thrown' upwards by the servant).
CB66 LD ($EB4D),A
CB69 CP $80 >=128 = negative value
CB6B JR NC,$CBA8 If no carry (>=128) item is moving upwards
Item is falling (moving downwards). Check it doesn't move off the bottom of the playing area, and stop it if it is.
CB6D SRA A Halve the downward momentum (adjusted earlier by adding 12, so halving here will increment the value in steps of 6)
CB6F LD C,A Temp store in C register
CB70 LD A,($EB4A) Graphic vertical pixel position from top of playing area
CB73 LD D,A
CB74 LD A,$60 Pixel line 96 is the bottom of the playing area when the room viewport is in its default position
CB76 LD HL,$EAF6 Address holding the vertical pixel position of the current room viewport
CB79 INC HL Advance to the next address as it's the high byte that contains the vertical pixel value
CB7A ADD A,(HL) Adjust the bottom-of-screen boundary based on the current room position/viewport
CB7B SUB D Subtract the item vertical position
CB7C CP $60
CB7E JR NC,$CB83 If there's no carry, the item is falling off the bottom of the screen
Item isn't falling off the bottom of the screen. Check if the item has fallen far enough to rest on the room floor.
CB80 CP C C contains the falling item's incremental vertical momentum (6, 12, 18, 24 etc.). Once this surpasses the adjusted vertical screen pixel position, the object stops.
The effect of this calculation means the object will fall further the higher up the screen it is.
This reinforces the 3D illusion, where the lower part of the room (the floor area) is presented at an angle, compared to the back wall, which is presented face on.
CB81 JR NC,$CBA8 No carry = jump out here - the object can continue to fall
Item is falling off the bottom of the screen, or has fallen far enough in the room - need to stop it moving so it's now at rest.
CB83 LD A,($EB4E)
CB86 AND $F7 Reset bit 3 (8) of the item properties byte to indicate this item is no longer falling/moving
CB88 LD ($EB4E),A
CB8B LD A,$00
CB8D LD ($EB4D),A Set the item's vertical speed to zero
CB90 LD ($EB4C),A Set the item's horizontal speed to zero
CB93 JP $CC27
Prev: CB4C Up: Map Next: CB96