Prev: CE74 Up: Map Next: CF59
CEE5: Handle Rex falling
Used by the routine at 9470.
CEE5 LD A,($A256) Return if Rex is jumping
CEE8 OR A
CEE9 RET NZ
CEEA LD A,($A250) Add falling speed to y-position of Rex
CEED LD HL,$A255
CEF0 ADD A,(HL)
CEF1 CP $BA if y-position is greater then 186 jump to check bottom room
CEF3 JP NC,$CF3B
CEF6 LD ($A250),A Set the new y-position
CEF9 AND $07 Return if y-position is not grid fixed
CEFB OR A
CEFC RET NZ
CEFD LD A,($A24F) Set A248 the x-position of Rex
CF00 LD ($A248),A
CF03 LD A,($A250) Set A249 the y-position of Rex
CF06 LD ($A249),A
CF09 LD A,($A254) Set A the face direction
CF0C CALL $A6AB Computes address position in tile type buffer based on (x,y) position on screen
CF0F LD DE,$0061 Set HL to point into tile type buffer under Rex feet
CF12 ADD HL,DE
CF13 LD A,(HL) Set A the tile type
CF14 CALL $CE17 Check if tile type is 'background'
CF17 JP NZ,$CF36 Jump to stop falling if not background
CF1A INC HL Increment address
CF1B LD A,(HL) Set A the tile type
CF1C CALL $CE17 Check if tile type is 'background'
CF1F JP NZ,$CF36 Jump to stop falling if not background
CF22 LD A,($A25D) If Rex collides with tile type $03 (tile of death) then jump to kill Rex
CF25 CP $03
CF27 CALL Z,$9CC5
CF2A LD A,($A255) Increase falling speed by 2
CF2D ADD A,$02
CF2F CP $06 Return if falling speed greater than 4
CF31 RET Z
CF32 LD ($A255),A Set the new falling speed
CF35 RET
Rex has finished falling
CF36 XOR A Set falling speed to 0
CF37 LD ($A255),A
CF3A RET
Rex has fallen through bottom room
CF3B LD A,($A228) If no bottom room connection then jump to kill Rex
CF3E OR A
CF3F JP Z,$CF4E
CF42 LD ($A251),A Set the new room
CF45 LD A,$08 Set the new y-position of Rex as 8
CF47 LD ($A250),A
CF4A POP BC Restore BC
CF4B JP $C9CD Check for end game room
No room connection, kill Rex
CF4E XOR A Set Rex to not jumping nor falling
CF4F LD ($A255),A
CF52 LD ($A256),A
CF55 CALL $9CC5 Handle Rex dead
CF58 RET
Prev: CE74 Up: Map Next: CF59