![]() |
Routines |
| Prev: 43749 | Up: Map | Next: 43919 |
|
Used by the routine at RunFrame.
Reads the controls and makes the player entity turn, jump and move forward. The controls are a byte with one bit for each direction, as read by ReadControls: bit 0 and bit 1 turn the player, bit 2 makes the player jump if it is on the ground, and bit 3 makes the player move forward. While the player is held (fields 36 and 37 are not both zero) bits 2-4 are ignored. The rate of turning builds up while a turn control is held, and is kept in TurningRate.
|
||||||||
| ControlPlayer | 43791 | CALL ReadControls | Read the controls. | |||||
| 43794 | LD A,(IX+36) | Read field 36 of the entity. | ||||||
| 43797 | OR (IX+37) | Combine it with field 37. | ||||||
| 43800 | JR Z,ControlPlayer_Store | Jump to ControlPlayer_Store if both are zero. | ||||||
| 43802 | RES 2,C | Ignore bit 2 of the controls. | ||||||
| 43804 | RES 3,C | Ignore bit 3 of the controls. | ||||||
| 43806 | RES 4,C | Ignore bit 4 of the controls. | ||||||
| ControlPlayer_Store | 43808 | LD A,C | Fetch the controls. | |||||
| 43809 | LD (23774),A | Store them in GameVariable. | ||||||
| 43812 | LD HL,(23798) | Fetch the rate of turning from TurningRate. | ||||||
| 43815 | LD DE,128 | Set the amount by which the rate builds up. | ||||||
| 43818 | RR C | Move bit 0 into the carry flag. | ||||||
| 43820 | JR NC,ControlPlayer_TestLeft | Jump to ControlPlayer_TestLeft if it is reset. | ||||||
| 43822 | RR C | Move bit 1 into the carry flag. | ||||||
| 43824 | JR C,ControlPlayer_NoTurn | Jump to ControlPlayer_NoTurn if both are set. | ||||||
| 43826 | LD B,255 | Set the direction of the turn to 255. | ||||||
| 43828 | JR ControlPlayer_Turn | Jump to ControlPlayer_Turn. | ||||||
| ControlPlayer_TestLeft | 43830 | RR C | Move bit 1 into the carry flag. | |||||
| 43832 | JR NC,ControlPlayer_NoTurn | Jump to ControlPlayer_NoTurn if neither bit is set. | ||||||
| 43834 | LD B,0 | Set the direction of the turn to 0. | ||||||
| ControlPlayer_Turn | 43836 | ADD HL,DE | Increase the rate of turning. | |||||
| 43837 | LD A,H | Fetch the whole part of the rate. | ||||||
| 43838 | CP 3 | Jump to ControlPlayer_StoreRate if it is less. | ||||||
| 43840 | JR C,ControlPlayer_StoreRate | |||||||
| 43842 | DEC H | Limit the rate to below 3. | ||||||
| ControlPlayer_StoreRate | 43843 | LD (23798),HL | Store the rate of turning. | |||||
| 43846 | LD A,H | Fetch the whole part of the rate. | ||||||
| 43847 | BIT 7,B | Jump to ControlPlayer_Heading if the turn is in the positive direction. | ||||||
| 43849 | JR Z,ControlPlayer_Heading | |||||||
| 43851 | NEG | Make the turn negative. | ||||||
| ControlPlayer_Heading | 43853 | LD B,A | Keep the turn in B. | |||||
| 43854 | LD A,(IX+17) | Fetch the heading of the player. | ||||||
| 43857 | ADD A,B | Add the turn. | ||||||
| 43858 | AND %00111111 | Use bits 0-5. | ||||||
| 43860 | LD (IX+17),A | Store the new heading. | ||||||
| 43863 | JR ControlPlayer_Jump | Jump to ControlPlayer_Jump. | ||||||
| ControlPlayer_NoTurn | 43865 | RES 7,(IX+17) | Reset bit 7 of the heading of the player, so that it is not moving forward. | |||||
| 43869 | LD E,64 | Set the amount by which the rate of turning falls. | ||||||
| 43871 | AND A | Clear the carry flag. | ||||||
| 43872 | SBC HL,DE | Reduce the rate of turning. | ||||||
| 43874 | JR NC,ControlPlayer_StoreRate2 | Jump to ControlPlayer_StoreRate2 if it is still positive. | ||||||
| 43876 | LD HL,0 | Set the rate of turning to zero. | ||||||
| ControlPlayer_StoreRate2 | 43879 | LD (23798),HL | Store the rate of turning. | |||||
| ControlPlayer_Jump | 43882 | RR C | Move bit 2 into the carry flag. | |||||
| 43884 | JR NC,ControlPlayer_Forward | Jump to ControlPlayer_Forward if it is reset. | ||||||
| 43886 | BIT 7,(IX+30) | Jump to ControlPlayer_Forward if bit 7 of field 30 of the player is reset. | ||||||
| 43890 | JR Z,ControlPlayer_Forward | |||||||
| 43892 | LD A,(23808) | Fetch the jump flag from JumpCounter. | ||||||
| 43895 | AND A | Test it. | ||||||
| 43896 | JR NZ,ControlPlayer_Forward | Jump to ControlPlayer_Forward if the player is already jumping. | ||||||
| 43898 | LD (IX+18),4 | Set the vertical speed of the player (field 18) to 4... | ||||||
| 43902 | LD (IX+19),0 | ...and field 19 to 0. | ||||||
| 43906 | LD A,1 | Set the jump flag to 1... | ||||||
| 43908 | LD (23808),A | ...and store it. | ||||||
| ControlPlayer_Forward | 43911 | RR C | Move bit 3 into the carry flag. | |||||
| 43913 | RET NC | Return if it is reset. | ||||||
| 43914 | SET 7,(IX+17) | Set bit 7 of the heading of the player, so that it moves forward. | ||||||
| 43918 | RET | Return. | ||||||
| Prev: 43749 | Up: Map | Next: 43919 |