![]() |
Routines |
| Prev: AB0F | Up: Map | Next: AC40 |
|
Used by the routine at ControlPlayer.
Reads the controls of the current player, using the control method which is selected in Player1ControlMethod (00 for the keyboard, 01 for a Kempston joystick, 02 for a Cursor joystick, otherwise an Interface II joystick). The result has one bit for each control: bit 0 is right, bit 1 is left, bit 2 is down, bit 3 is up and bit 4 is fire.
|
||||||||||||||||||||
| ReadControls | AB8F | LD A,($60FB) | Fetch the control method of the current player. | |||||||||||||||||
| AB92 | AND A | Test it. | ||||||||||||||||||
| AB93 | JP Z,ReadControls_Keyboard | Jump to ReadControls_Keyboard if it is the keyboard. | ||||||||||||||||||
| AB96 | DEC A | Decrease it by one. | ||||||||||||||||||
| AB97 | JR Z,ReadControls_Kempston | Jump to ReadControls_Kempston if it is a Kempston joystick. | ||||||||||||||||||
| AB99 | DEC A | Decrease it by one. | ||||||||||||||||||
| AB9A | JR Z,ReadControls_Cursor | Jump to ReadControls_Cursor if it is a Cursor joystick. | ||||||||||||||||||
| AB9C | LD A,$EF | Read from the keyboard;
|
||||||||||||||||||
| AB9E | IN A,($FE) | |||||||||||||||||||
| ABA0 | LD B,$FF | Start with all of the bits set. | ||||||||||||||||||
| ABA2 | RRA | Move the bit for "0" into the carry flag. | ||||||||||||||||||
| ABA3 | RL B | Move it into B. | ||||||||||||||||||
| ABA5 | RRA | Move the bit for "9" into the carry flag. | ||||||||||||||||||
| ABA6 | RL B | Move it into B. | ||||||||||||||||||
| ABA8 | RRA | Move the bit for "8" into the carry flag. | ||||||||||||||||||
| ABA9 | RL B | Move it into B. | ||||||||||||||||||
| ABAB | RRA | Move the bit for "7" into the carry flag... | ||||||||||||||||||
| ABAC | RRA | ...and then the bit for "6". | ||||||||||||||||||
| ABAD | RL B | Move it into B. | ||||||||||||||||||
| ABAF | RLA | Rotate the bit for "7" back into the carry flag... | ||||||||||||||||||
| ABB0 | RL B | ...and move it into B. | ||||||||||||||||||
| ABB2 | LD A,B | Fetch the result. | ||||||||||||||||||
| ABB3 | CPL | Invert the bits, so that a set bit is a control being used. | ||||||||||||||||||
| ABB4 | LD C,A | Store it in C. | ||||||||||||||||||
| ABB5 | RET | Return. | ||||||||||||||||||
| ReadControls_Kempston | ABB6 | IN A,($1F) | Read the Kempston joystick. | |||||||||||||||||
| ABB8 | AND %00011111 | Keep the five bits. | ||||||||||||||||||
| ABBA | LD C,A | Store them in C. | ||||||||||||||||||
| ABBB | RET | Return. | ||||||||||||||||||
| ReadControls_Cursor | ABBC | LD A,$EF | Read from the keyboard;
|
|||||||||||||||||
| ABBE | IN A,($FE) | |||||||||||||||||||
| ABC0 | OR %11100000 | Set the unused bits. | ||||||||||||||||||
| ABC2 | LD B,A | Keep the bits in B. | ||||||||||||||||||
| ABC3 | AND %00001000 | Keep the bit for "7", up. | ||||||||||||||||||
| ABC5 | LD C,A | Store it in C. | ||||||||||||||||||
| ABC6 | LD A,B | Fetch the bits. | ||||||||||||||||||
| ABC7 | RRCA | Rotate bit 2, for "8" (right), into bit 0... | ||||||||||||||||||
| ABC8 | RRCA | ...and bit 4, for "6" (down), into bit 2. | ||||||||||||||||||
| ABC9 | LD B,A | Keep the bits in B. | ||||||||||||||||||
| ABCA | AND %00000101 | Keep the bits for right and down. | ||||||||||||||||||
| ABCC | OR C | Add the bit for up. | ||||||||||||||||||
| ABCD | LD C,A | Store them in C. | ||||||||||||||||||
| ABCE | LD A,B | Fetch the bits. | ||||||||||||||||||
| ABCF | RRA | Rotate the bit for "0" (fire)... | ||||||||||||||||||
| ABD0 | RRA | ...into bit 4. | ||||||||||||||||||
| ABD1 | AND %00010000 | Keep the bit for fire. | ||||||||||||||||||
| ABD3 | OR C | Add the other bits. | ||||||||||||||||||
| ABD4 | LD C,A | Store them in C. | ||||||||||||||||||
| ABD5 | LD A,$F7 | Read from the keyboard;
|
||||||||||||||||||
| ABD7 | IN A,($FE) | |||||||||||||||||||
| ABD9 | RRA | Rotate the bit for "5" (left)... | ||||||||||||||||||
| ABDA | RRA | ...into... | ||||||||||||||||||
| ABDB | RRA | ...bit 1. | ||||||||||||||||||
| ABDC | AND %00000010 | Keep the bit for left. | ||||||||||||||||||
| ABDE | OR C | Add the other bits. | ||||||||||||||||||
| ABDF | CPL | Invert the bits, so that a set bit is a control being used. | ||||||||||||||||||
| ABE0 | LD C,A | Store them in C. | ||||||||||||||||||
| ABE1 | RET | Return. | ||||||||||||||||||
| ReadControls_Keyboard | ABE2 | LD C,$00 | Clear the controls. | |||||||||||||||||
| ABE4 | LD A,$FE | Read from the keyboard;
|
||||||||||||||||||
| ABE6 | CALL ReadKeyboard | |||||||||||||||||||
| ABE9 | AND %00010100 | Keep the bits for "X" and "V". | ||||||||||||||||||
| ABEB | JR NZ,ReadControls_Right | Jump to ReadControls_Right if either of them is being pressed. | ||||||||||||||||||
| ABED | LD A,$7F | Read from the keyboard;
|
||||||||||||||||||
| ABEF | CALL ReadKeyboard | |||||||||||||||||||
| ABF2 | AND %00001010 | Keep the bits for "SYMBOL SHIFT" and "N". | ||||||||||||||||||
| ABF4 | JR Z,ReadControls_TestLeft | Jump to ReadControls_TestLeft if neither of them is being pressed. | ||||||||||||||||||
| ReadControls_Right | ABF6 | SET 0,C | Set bit 0, right. | |||||||||||||||||
| ReadControls_TestLeft | ABF8 | LD A,$FE | Read from the keyboard;
|
|||||||||||||||||
| ABFA | CALL ReadKeyboard | |||||||||||||||||||
| ABFD | AND %00001010 | Keep the bits for "Z" and "C". | ||||||||||||||||||
| ABFF | JR NZ,ReadControls_Left | Jump to ReadControls_Left if either of them is being pressed. | ||||||||||||||||||
| AC01 | LD A,$7F | Read from the keyboard;
|
||||||||||||||||||
| AC03 | CALL ReadKeyboard | |||||||||||||||||||
| AC06 | AND %00010100 | Keep the bits for "M" and "B". | ||||||||||||||||||
| AC08 | JR Z,ReadControls_TestUp | Jump to ReadControls_TestUp if neither of them is being pressed. | ||||||||||||||||||
| ReadControls_Left | AC0A | SET 1,C | Set bit 1, left. | |||||||||||||||||
| ReadControls_TestUp | AC0C | LD A,$FD | Read from the keyboard;
|
|||||||||||||||||
| AC0E | CALL ReadKeyboard | |||||||||||||||||||
| AC11 | JR NZ,ReadControls_Up | Jump to ReadControls_Up if any of the keys is being pressed. | ||||||||||||||||||
| AC13 | LD A,$BF | Read from the keyboard;
|
||||||||||||||||||
| AC15 | CALL ReadKeyboard | |||||||||||||||||||
| AC18 | JR Z,ReadControls_TestDown | Jump to ReadControls_TestDown if none of the keys is being pressed. | ||||||||||||||||||
| ReadControls_Up | AC1A | SET 3,C | Set bit 3, up. | |||||||||||||||||
| ReadControls_TestDown | AC1C | LD A,$FB | Read from the keyboard;
|
|||||||||||||||||
| AC1E | CALL ReadKeyboard | |||||||||||||||||||
| AC21 | LD E,A | Keep the bits in E. | ||||||||||||||||||
| AC22 | LD A,$DF | Read from the keyboard;
|
||||||||||||||||||
| AC24 | CALL ReadKeyboard | |||||||||||||||||||
| AC27 | LD D,A | Keep the bits in D. | ||||||||||||||||||
| AC28 | LD A,E | Fetch the bits for "Q", "W", "E", "R" and "T". | ||||||||||||||||||
| AC29 | AND %00010101 | Keep the bits for "Q", "E" and "T". | ||||||||||||||||||
| AC2B | LD L,A | Store them in L. | ||||||||||||||||||
| AC2C | LD A,D | Fetch the bits for "P", "O", "I", "U" and "Y". | ||||||||||||||||||
| AC2D | AND %00001010 | Keep the bits for "O" and "U". | ||||||||||||||||||
| AC2F | OR L | Combine them with the bits for "Q", "E" and "T". | ||||||||||||||||||
| AC30 | JR Z,ReadControls_TestFire | Jump to ReadControls_TestFire if none of them is being pressed. | ||||||||||||||||||
| AC32 | SET 2,C | Set bit 2, down. | ||||||||||||||||||
| ReadControls_TestFire | AC34 | LD A,E | Fetch the bits for "Q", "W", "E", "R" and "T". | |||||||||||||||||
| AC35 | AND %00001010 | Keep the bits for "W" and "R". | ||||||||||||||||||
| AC37 | LD L,A | Store them in L. | ||||||||||||||||||
| AC38 | LD A,D | Fetch the bits for "P", "O", "I", "U" and "Y". | ||||||||||||||||||
| AC39 | AND %00010101 | Keep the bits for "P", "I" and "Y". | ||||||||||||||||||
| AC3B | OR L | Combine them with the bits for "W" and "R". | ||||||||||||||||||
| AC3C | RET Z | Return if none of them is being pressed. | ||||||||||||||||||
| AC3D | SET 4,C | Set bit 4, fire. | ||||||||||||||||||
| AC3F | RET | Return. | ||||||||||||||||||
| Prev: AB0F | Up: Map | Next: AC40 |