![]() |
Routines |
| Prev: 8F9B | Up: Map | Next: 8FF4 |
|
Read the movement and fire rows into the same bit order as the Kempston joystick.
|
||||||||||||||||||||
|
Start with every control bit released, then read 0-9.
|
||||||||||||||||||||
| ReadKeyboard | 8F9F | LD C,$FF | Start with every control bit released. | |||||||||||||||||
| 8FA1 | LD A,$E7 | Read from the keyboard;
|
||||||||||||||||||
| 8FA3 | OUT ($FD),A | |||||||||||||||||||
| 8FA5 | IN A,($FE) | |||||||||||||||||||
| 8FA7 | CPL | Flip the bits. | ||||||||||||||||||
| 8FA8 | AND %00011111 | Keep only bits 0-4. | ||||||||||||||||||
| 8FAA | JR Z,ReadKeyboard_Letters | Jump to ReadKeyboard_Letters if no number key is pressed. | ||||||||||||||||||
| 8FAC | RES 2,C | Reset the DOWN bit. | ||||||||||||||||||
|
Read the top letter row; any key pressed in it counts as UP.
|
||||||||||||||||||||
| ReadKeyboard_Letters | 8FAE | LD A,$DB | Read from the keyboard;
|
|||||||||||||||||
| 8FB0 | OUT ($FD),A | |||||||||||||||||||
| 8FB2 | IN A,($FE) | |||||||||||||||||||
| 8FB4 | CPL | Flip the bits. | ||||||||||||||||||
| 8FB5 | AND %00011111 | Keep only bits 0-4. | ||||||||||||||||||
| 8FB7 | JR Z,ReadKeyboard_HomeRow | Jump to ReadKeyboard_HomeRow if no letter in this row is pressed. | ||||||||||||||||||
| 8FB9 | RES 3,C | Reset the UP bit. | ||||||||||||||||||
|
Read the home row; any key pressed in it counts as FIRE.
|
||||||||||||||||||||
| ReadKeyboard_HomeRow | 8FBB | LD A,$BD | Read from the keyboard;
|
|||||||||||||||||
| 8FBD | OUT ($FD),A | |||||||||||||||||||
| 8FBF | IN A,($FE) | |||||||||||||||||||
| 8FC1 | CPL | Flip the bits. | ||||||||||||||||||
| 8FC2 | AND %00011111 | Keep only bits 0-4. | ||||||||||||||||||
| 8FC4 | JR Z,ReadKeyboard_ZXCV | Jump to ReadKeyboard_ZXCV if no letter in this row is pressed. | ||||||||||||||||||
| 8FC6 | RES 4,C | Reset the FIRE bit. | ||||||||||||||||||
|
Read the bottom-left row; X and V count as LEFT and C counts as RIGHT.
|
||||||||||||||||||||
| ReadKeyboard_ZXCV | 8FC8 | LD A,$FE | Read from the keyboard;
|
|||||||||||||||||
| 8FCA | OUT ($FD),A | |||||||||||||||||||
| 8FCC | IN A,($FE) | |||||||||||||||||||
| 8FCE | CPL | Flip the bits. | ||||||||||||||||||
| 8FCF | LD B,A | Stash the row in B. | ||||||||||||||||||
| 8FD0 | AND %00010100 | Keep only bits 2 and 4. | ||||||||||||||||||
| 8FD2 | JR Z,ReadKeyboard_TestC | Jump to ReadKeyboard_TestC if neither key is pressed. | ||||||||||||||||||
| 8FD4 | RES 1,C | Reset the LEFT bit. | ||||||||||||||||||
|
Reset the RIGHT bit if C is pressed.
|
||||||||||||||||||||
| ReadKeyboard_TestC | 8FD6 | LD A,B | Fetch the stored row. | |||||||||||||||||
| 8FD7 | AND %00001000 | Keep only bit 3. | ||||||||||||||||||
| 8FD9 | JR Z,ReadKeyboard_BNM | Jump to ReadKeyboard_BNM if "C" is not pressed. | ||||||||||||||||||
| 8FDB | RES 0,C | Reset the RIGHT bit. | ||||||||||||||||||
|
Read the bottom-right row; N counts as LEFT and M or B counts as RIGHT.
|
||||||||||||||||||||
| ReadKeyboard_BNM | 8FDD | LD A,$7F | Read from the keyboard;
|
|||||||||||||||||
| 8FDF | OUT ($FD),A | |||||||||||||||||||
| 8FE1 | IN A,($FE) | |||||||||||||||||||
| 8FE3 | CPL | Flip the bits. | ||||||||||||||||||
| 8FE4 | LD B,A | Stash the row in B. | ||||||||||||||||||
| 8FE5 | AND %00001000 | Keep only bit 3. | ||||||||||||||||||
| 8FE7 | JR Z,ReadKeyboard_TestFullStop | Jump to ReadKeyboard_TestFullStop if "N" is not pressed. | ||||||||||||||||||
| 8FE9 | RES 1,C | Reset the LEFT bit. | ||||||||||||||||||
|
Reset the RIGHT bit if M or B is pressed.
|
||||||||||||||||||||
| ReadKeyboard_TestFullStop | 8FEB | LD A,B | Fetch the stored row. | |||||||||||||||||
| 8FEC | AND %00010100 | Keep only bits 2 and 4. | ||||||||||||||||||
| 8FEE | JR Z,ReadKeyboard_ReturnControls | Jump to ReadKeyboard_ReturnControls if neither key is pressed. | ||||||||||||||||||
| 8FF0 | RES 0,C | Reset the RIGHT bit. | ||||||||||||||||||
| ReadKeyboard_ReturnControls | 8FF2 | LD A,C | A=the collected controls. | |||||||||||||||||
| 8FF3 | RET | Return. | ||||||||||||||||||
|
View the equivalent code in;
|
||||||||||||||||||||
| Prev: 8F9B | Up: Map | Next: 8FF4 |