Prev: C38F Up: Map Next: C3F0
C397: Leave Room To The West
Sends the player to the room to the west if it has gone past the west edge of the room. The x position is set to 00, which PlacePlayerAtDoor takes as the sign that the player has come out of the west and puts it at the east side of the new room.
Input
HL Distances to the walls along x and y
IX The address of the object
Leave if past the west edge.
LeaveRoomToWest C397 POP HL Restore HL from the stack.
C398 LD A,$80 Set A to 80.
C39A SUB L Subtract L.
C39B LD L,A Copy it to L.
C39C LD A,(IX+$01) Fetch the x position of the player.
C39F ADD A,(IX+$09) Add the speed along the x axis.
C3A2 ADD A,(IX+$04) Add the width of the player.
C3A5 CP L Return if the player is still in the room.
C3A6 RET NC
C3A7 LD (IX+$01),$00 Write 00 to the x position.
C3AB LD A,(IX+$08) Fetch the room number.
C3AE LD L,A Copy it to L.
C3AF DEC A Decrement A.
This entry point is used by the routine at LeaveRoomToEast.
Change the column. The room number has the row in the high nibble and the column in the low nibble.
ChangeRoomEastWest C3B0 AND %00001111 Keep only bits 0-3.
C3B2 LD H,A Copy it to H.
C3B3 LD A,L Copy L to A.
C3B4 AND %11110000 Keep only bits 4-7.
C3B6 OR H Merge H.
This entry point is used by the routines at LeaveRoomToNorth and LeaveRoomToSouth.
Change the room of the player. Bit 6 of the collision flags starts the entering-room counter at 04. If the object is the player then it is copied and replaced by sparkles, and the game loop is started again.
ChangeRoom C3B7 LD (IX+$08),A Store the room number.
C3BA LD A,(IX+$0C) Fetch the collision flags.
C3BD OR %01000000 Set bit 6.
C3BF LD (IX+$0C),A Store the collision flags.
C3C2 LD A,(IX+$00) Fetch the sprite number of the object.
C3C5 SUB $10 Subtract 10.
C3C7 CP $40 Return if it is not the player.
C3C9 RET NC
C3CA INC SP Drop two return addresses from the stack.
C3CB INC SP
C3CC INC SP
C3CD INC SP
C3CE PUSH IX Copy IX to HL (using the stack).
C3D0 POP HL
C3D1 LD DE,$CA1D Point DE at PlayerCopy.
C3D4 LD BC,$0040 Set BC to 0040.
C3D7 LDIR Copy the player.
Remember the sprites, then turn the copy into sparkles.
C3D9 LD A,($CA1D) Fetch the sprite of the bottom half.
C3DC LD ($CA2D),A Keep it as the sprite that the bottom half will appear as.
C3DF LD A,($CA3D) Fetch the sprite of the top half.
C3E2 LD ($CA4D),A Keep it as the sprite that the top half will appear as.
C3E5 LD A,$38 Write 38 to PlayerCopy and PlayerCopy_TopHalf.
C3E7 LD ($CA1D),A
C3EA LD ($CA3D),A
C3ED JP RunGame Jump to RunGame.
View the equivalent code in;
Prev: C38F Up: Map Next: C3F0