![]() |
Routines |
| Prev: 60916 | Up: Map | Next: 60969 |
|
Used by the routine at ReadControls.
Reads the cursor keys and puts the state of the controls in B, to be completed by ReadControls_Bottom_Row (see ReadControls). The keys are 5 (left), 6 (down), 7 (up), 8 (right) and 0 (fire), and a bit is reset when its key is pressed.
|
||||||||||||||||||||
| Read_Cursor_Keys | 60928 | LD A,239 | Read from the keyboard;
|
|||||||||||||||||
| 60930 | OUT (253),A | |||||||||||||||||||
| 60932 | IN A,(254) | |||||||||||||||||||
| 60934 | LD C,A | Stash the state of the keys in C. | ||||||||||||||||||
| 60935 | AND %00001000 | Keep only bit 3, which is the key 7 (up). | ||||||||||||||||||
| 60937 | LD E,A | Store it in E. | ||||||||||||||||||
| 60938 | LD A,C | Fetch the state of the keys. | ||||||||||||||||||
| 60939 | RRCA | Rotate the keys right twice, which moves the key 0 into bit 6, the key 6 into bit 2 and the key 8 into bit 0. | ||||||||||||||||||
| 60940 | RRCA | |||||||||||||||||||
| 60941 | AND %01000101 | Keep only those three bits. | ||||||||||||||||||
| 60943 | OR E | Combine them with up. | ||||||||||||||||||
| 60944 | LD E,A | Store the result in E. | ||||||||||||||||||
| 60945 | RRCA | Rotate the result right twice, which moves fire from bit 6 into bit 4. | ||||||||||||||||||
| 60946 | RRCA | |||||||||||||||||||
| 60947 | AND %00010000 | Keep only bit 4. | ||||||||||||||||||
| 60949 | OR E | Combine it with the other directions. | ||||||||||||||||||
| 60950 | AND %00011111 | Keep only the five low bits, which are right, down, up and fire (the bit for left is not set yet). | ||||||||||||||||||
| 60952 | LD E,A | Store the result in E. | ||||||||||||||||||
| 60953 | LD A,247 | Read from the keyboard;
|
||||||||||||||||||
| 60955 | OUT (253),A | |||||||||||||||||||
| 60957 | IN A,(254) | |||||||||||||||||||
| 60959 | RRA | Rotate the keys right three times, which moves the key 5 into bit 1. | ||||||||||||||||||
| 60960 | RRA | |||||||||||||||||||
| 60961 | RRA | |||||||||||||||||||
| 60962 | AND %00000010 | Keep only that bit (left). | ||||||||||||||||||
| 60964 | OR E | Combine it with the other controls. | ||||||||||||||||||
| 60965 | LD B,A | Store the state of the controls in B. | ||||||||||||||||||
| 60966 | JP ReadControls_Bottom_Row | Jump to ReadControls_Bottom_Row to read the bottom row of the keyboard. | ||||||||||||||||||
| Prev: 60916 | Up: Map | Next: 60969 |