![]() |
Routines |
| Prev: 37784 | Up: Map | Next: 37859 |
|
Reads the controls that were chosen in GameOptions. A bit is reset when the control is used: bit 0 is right, bit 1 is left, bit 2 is down, bit 3 is up and bit 4 is fire. The keyboard uses W, Q, E, R and T, the cursor keys are read by ReadCursorKeys and otherwise the Kempston joystick is read.
|
||||||||||||||||||||
| ReadControls | 37822 | LD A,(24064) | Fetch the controls that were chosen from GameOptions. | |||||||||||||||||
| 37825 | AND %00000110 | Keep only bits 1-2. | ||||||||||||||||||
| 37827 | JR Z,ReadControls_Keyboard | Jump to ReadControls_Keyboard if the keyboard is used. | ||||||||||||||||||
| 37829 | CP 4 | Jump to ReadCursorKeys if the cursor keys are used. | ||||||||||||||||||
| 37831 | JR Z,ReadCursorKeys | |||||||||||||||||||
| 37833 | IN A,(31) | Read the Kempston joystick. | ||||||||||||||||||
| 37835 | CPL | Flip the bits, so that a reset bit is a control which is used. | ||||||||||||||||||
| 37836 | RET | Return. | ||||||||||||||||||
| ReadControls_Keyboard | 37837 | LD A,251 | Read from the keyboard;
|
|||||||||||||||||
| 37839 | OUT (253),A | |||||||||||||||||||
| 37841 | IN A,(254) | |||||||||||||||||||
| 37843 | LD C,A | Keep the keys in C. | ||||||||||||||||||
| 37844 | RRA | Rotate A right, to move W (right) to bit 0. | ||||||||||||||||||
| 37845 | AND %00000001 | Keep only bit 0. | ||||||||||||||||||
| 37847 | LD E,A | Keep right in E. | ||||||||||||||||||
| 37848 | LD A,C | Fetch the keys. | ||||||||||||||||||
| 37849 | RLA | Rotate A left, to move Q (left) to bit 1. | ||||||||||||||||||
| 37850 | AND %00000010 | Keep only bit 1. | ||||||||||||||||||
| 37852 | OR E | Combine left with right. | ||||||||||||||||||
| 37853 | LD E,A | Keep right and left in E. | ||||||||||||||||||
| 37854 | LD A,C | Fetch the keys. | ||||||||||||||||||
| 37855 | AND %00011100 | Keep only bits 2-4 (E is down, R is up and T is fire). | ||||||||||||||||||
| 37857 | OR E | Combine down, up and fire with right and left. | ||||||||||||||||||
| 37858 | RET | Return. | ||||||||||||||||||
|
View the equivalent code in;
|
||||||||||||||||||||
| Prev: 37784 | Up: Map | Next: 37859 |