![]() |
Routines |
| Prev: 36763 | Up: Map | Next: 36852 |
|
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 | 36767 | LD C,255 | Start with every control bit released. | |||||||||||||||||
| 36769 | LD A,231 | Read from the keyboard;
|
||||||||||||||||||
| 36771 | OUT (253),A | |||||||||||||||||||
| 36773 | IN A,(254) | |||||||||||||||||||
| 36775 | CPL | Flip the bits. | ||||||||||||||||||
| 36776 | AND %00011111 | Keep only bits 0-4. | ||||||||||||||||||
| 36778 | JR Z,ReadKeyboard_Letters | Jump to ReadKeyboard_Letters if no number key is pressed. | ||||||||||||||||||
| 36780 | RES 2,C | Reset the DOWN bit. | ||||||||||||||||||
|
Read the top letter row; any key pressed in it counts as UP.
|
||||||||||||||||||||
| ReadKeyboard_Letters | 36782 | LD A,219 | Read from the keyboard;
|
|||||||||||||||||
| 36784 | OUT (253),A | |||||||||||||||||||
| 36786 | IN A,(254) | |||||||||||||||||||
| 36788 | CPL | Flip the bits. | ||||||||||||||||||
| 36789 | AND %00011111 | Keep only bits 0-4. | ||||||||||||||||||
| 36791 | JR Z,ReadKeyboard_HomeRow | Jump to ReadKeyboard_HomeRow if no letter in this row is pressed. | ||||||||||||||||||
| 36793 | RES 3,C | Reset the UP bit. | ||||||||||||||||||
|
Read the home row; any key pressed in it counts as FIRE.
|
||||||||||||||||||||
| ReadKeyboard_HomeRow | 36795 | LD A,189 | Read from the keyboard;
|
|||||||||||||||||
| 36797 | OUT (253),A | |||||||||||||||||||
| 36799 | IN A,(254) | |||||||||||||||||||
| 36801 | CPL | Flip the bits. | ||||||||||||||||||
| 36802 | AND %00011111 | Keep only bits 0-4. | ||||||||||||||||||
| 36804 | JR Z,ReadKeyboard_ZXCV | Jump to ReadKeyboard_ZXCV if no letter in this row is pressed. | ||||||||||||||||||
| 36806 | 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 | 36808 | LD A,254 | Read from the keyboard;
|
|||||||||||||||||
| 36810 | OUT (253),A | |||||||||||||||||||
| 36812 | IN A,(254) | |||||||||||||||||||
| 36814 | CPL | Flip the bits. | ||||||||||||||||||
| 36815 | LD B,A | Stash the row in B. | ||||||||||||||||||
| 36816 | AND %00010100 | Keep only bits 2 and 4. | ||||||||||||||||||
| 36818 | JR Z,ReadKeyboard_TestC | Jump to ReadKeyboard_TestC if neither key is pressed. | ||||||||||||||||||
| 36820 | RES 1,C | Reset the LEFT bit. | ||||||||||||||||||
|
Reset the RIGHT bit if C is pressed.
|
||||||||||||||||||||
| ReadKeyboard_TestC | 36822 | LD A,B | Fetch the stored row. | |||||||||||||||||
| 36823 | AND %00001000 | Keep only bit 3. | ||||||||||||||||||
| 36825 | JR Z,ReadKeyboard_BNM | Jump to ReadKeyboard_BNM if "C" is not pressed. | ||||||||||||||||||
| 36827 | 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 | 36829 | LD A,127 | Read from the keyboard;
|
|||||||||||||||||
| 36831 | OUT (253),A | |||||||||||||||||||
| 36833 | IN A,(254) | |||||||||||||||||||
| 36835 | CPL | Flip the bits. | ||||||||||||||||||
| 36836 | LD B,A | Stash the row in B. | ||||||||||||||||||
| 36837 | AND %00001000 | Keep only bit 3. | ||||||||||||||||||
| 36839 | JR Z,ReadKeyboard_TestFullStop | Jump to ReadKeyboard_TestFullStop if "N" is not pressed. | ||||||||||||||||||
| 36841 | RES 1,C | Reset the LEFT bit. | ||||||||||||||||||
|
Reset the RIGHT bit if M or B is pressed.
|
||||||||||||||||||||
| ReadKeyboard_TestFullStop | 36843 | LD A,B | Fetch the stored row. | |||||||||||||||||
| 36844 | AND %00010100 | Keep only bits 2 and 4. | ||||||||||||||||||
| 36846 | JR Z,ReadKeyboard_ReturnControls | Jump to ReadKeyboard_ReturnControls if neither key is pressed. | ||||||||||||||||||
| 36848 | RES 0,C | Reset the RIGHT bit. | ||||||||||||||||||
| ReadKeyboard_ReturnControls | 36850 | LD A,C | A=the collected controls. | |||||||||||||||||
| 36851 | RET | Return. | ||||||||||||||||||
|
View the equivalent code in;
|
||||||||||||||||||||
| Prev: 36763 | Up: Map | Next: 36852 |