![]() |
Routines |
| Prev: C117 | Up: Map | Next: C1BD |
|
Used by the routine at HandlePlayerLegs.
Turns the player to face the direction that was asked for. Where a joystick with directional control is in use the walk control is set when the player is already facing the direction that is pressed, and otherwise the player is turned. With the other methods of control the left and right controls turn the player. The routine returns early while the player is entering the room, jumping or not standing on something.
Turning starts by showing one of the sprites of objects 18 to 1B (see TurningRightSpriteTable and TurningLeftSpriteTable); HandleTurningLegs finishes the turn.
|
||||||||||||||
|
Use rotational control unless a joystick is directional.
|
||||||||||||||
| HandleTurning | C13C | LD HL,$5B04 | Point HL at ControlMethod. | |||||||||||
| C13F | LD A,(HL) | Fetch it. | ||||||||||||
| C140 | AND %00000110 | Keep only bits 1 and 2. | ||||||||||||
| C142 | JR Z,HandleTurning_Rotate | Jump to HandleTurning_Rotate if they are zero. | ||||||||||||
| C144 | BIT 3,(HL) | Jump to HandleTurning_Rotate if directional control is off. | ||||||||||||
| C146 | JR Z,HandleTurning_Rotate | |||||||||||||
|
Directional control. The player cannot turn while entering the room, or while it is not standing on something.
|
||||||||||||||
| C148 | LD A,(IX+$0C) | Fetch the collision flags. | ||||||||||||
| C14B | AND %11110000 | Keep only bits 4-7. | ||||||||||||
| C14D | RET NZ | Return if the player is entering the room. | ||||||||||||
| C14E | BIT 2,(IX+$0C) | Return if the player is in the air. | ||||||||||||
| C152 | RET Z | |||||||||||||
|
Find the direction that is pressed. Left (west) is tried before up (north). Down is bit 4 of the controls.
|
||||||||||||||
| C153 | BIT 0,C | Jump to HandleTurning_Right if left is pressed. | ||||||||||||
| C155 | JR NZ,HandleTurning_Right | |||||||||||||
| C157 | BIT 2,C | Jump to HandleTurning_North if up is pressed. | ||||||||||||
| C159 | JR NZ,HandleTurning_North | |||||||||||||
| HandleTurning_Right | C15B | BIT 1,C | Jump to HandleTurning_East if right is pressed. | |||||||||||
| C15D | JR NZ,HandleTurning_East | |||||||||||||
| C15F | BIT 4,C | Jump to HandleTurning_South if down is pressed. | ||||||||||||
| C161 | JR NZ,HandleTurning_South | |||||||||||||
| C163 | BIT 0,C | Jump to HandleTurning_West if left is pressed. | ||||||||||||
| C165 | JR NZ,HandleTurning_West | |||||||||||||
| C167 | RES 2,C | Clear the walk control, as no direction is pressed. | ||||||||||||
| C169 | RET | Return. | ||||||||||||
|
The facing of the player is 00 west, 01 east, 02 north and 03 south. If the player already faces the direction that is pressed, the walk control is set. Otherwise bit 0 of the direction (inverted for north and east) chooses which way to turn.
|
||||||||||||||
| HandleTurning_North | C16A | CALL GetFacingDirection | Test whether the player is facing north. | |||||||||||
| C16D | CP $02 | |||||||||||||
| HandleTurning_Facing | C16F | JR Z,HandleTurning_Walk | Jump to HandleTurning_Walk if it is. | |||||||||||
| C171 | CPL | Invert the direction. | ||||||||||||
| HandleTurning_Turn | C172 | AND %00000001 | Keep bit 0, which decides which way to turn. | |||||||||||
| C174 | JR HandleTurning_Start | Jump to HandleTurning_Start. | ||||||||||||
| HandleTurning_East | C176 | CALL GetFacingDirection | Test whether the player is facing east. | |||||||||||
| C179 | CP $01 | |||||||||||||
| C17B | JR HandleTurning_Facing | Jump to HandleTurning_Facing. | ||||||||||||
| HandleTurning_South | C17D | CALL GetFacingDirection | Test whether the player is facing south. | |||||||||||
| C180 | CP $03 | |||||||||||||
| HandleTurning_TestFacing | C182 | JR Z,HandleTurning_Walk | Jump to HandleTurning_Walk if it is. | |||||||||||
| C184 | JR HandleTurning_Turn | Jump to HandleTurning_Turn. | ||||||||||||
| HandleTurning_West | C186 | CALL GetFacingDirection | Test whether the player is facing west. | |||||||||||
| C189 | AND A | |||||||||||||
| C18A | JR HandleTurning_TestFacing | Jump to HandleTurning_TestFacing. | ||||||||||||
| HandleTurning_Walk | C18C | SET 2,C | Set the walk control, as the player is facing the direction that is pressed. | |||||||||||
| C18E | RET | Return. | ||||||||||||
|
Rotational control. The player cannot turn while entering the room or while jumping.
|
||||||||||||||
| HandleTurning_Rotate | C18F | LD A,C | Copy C to A. | |||||||||||
| C190 | AND %00000011 | Keep only bits 0 and 1. | ||||||||||||
| C192 | RET Z | Return if they are zero. | ||||||||||||
| C193 | LD A,(IX+$0C) | Fetch the collision flags. | ||||||||||||
| C196 | AND %11110000 | Keep only bits 4-7. | ||||||||||||
| C198 | RET NZ | Return if the player is entering the room. | ||||||||||||
| C199 | BIT 3,(IX+$0C) | Return if the player is jumping. | ||||||||||||
| C19D | RET NZ | |||||||||||||
| C19E | BIT 1,C | Test the right control. | ||||||||||||
| HandleTurning_Start | C1A0 | JR NZ,HandleTurning_TurnRight | Jump to HandleTurning_TurnRight if the player is to turn right. | |||||||||||
| C1A2 | RES 0,(IX+$0D) | Reset bit 0 of the extra flags. | ||||||||||||
| C1A6 | LD HL,$C1DA | Point HL at TurningLeftSpriteTable. | ||||||||||||
| C1A9 | JR HandleTurning_SetSprite | Jump to HandleTurning_SetSprite. | ||||||||||||
| HandleTurning_TurnRight | C1AB | SET 0,(IX+$0D) | Set bit 0 of the extra flags. | |||||||||||
| C1AF | LD HL,$C1D2 | Point HL at TurningRightSpriteTable. | ||||||||||||
| HandleTurning_SetSprite | C1B2 | LD A,(IX+$0D) | Fetch the extra flags. | |||||||||||
| C1B5 | OR %00000010 | Set bit 1. | ||||||||||||
| C1B7 | LD (IX+$0D),A | Store the extra flags. | ||||||||||||
| C1BA | CALL GetFacingDirection | Call GetFacingDirection. | ||||||||||||
|
Continue on to SetSpriteFromTable.
View the equivalent code in;
|
||||||||||||||
| Prev: C117 | Up: Map | Next: C1BD |