Prev: 28592 Up: Map Next: 28631
28596: Read Controls
Used by the routine at GamePlay_Start.
Reads the controls which have been chosen in GameOptions; the keyboard, the Kempston joystick or the cursor joystick. The bits of the result are reset for the directions (and fire) which are being pressed.
Bit Control Keyboard
0 Right W
1 Left Q
2 Down E
3 Up R
4 Fire T
Output
A The controls
ReadControls 28596 LD A,(24332) Fetch the game options.
28599 AND %00000110 Keep only bits 1-2 (the choice of controls).
28601 CP 2 Jump to ReadKempstonJoystick if the Kempston joystick is being used.
28603 JR Z,ReadKempstonJoystick
28605 CP 4 Jump to ReadCursorJoystick if the cursor joystick is being used.
28607 JR Z,ReadCursorJoystick
28609 LD A,251 Read from the keyboard;
Port Number Bit
0 1 2 3 4
251 Q W E R T
28611 OUT (253),A
28613 IN A,(254)
28615 LD C,A Keep the key states in C.
28616 RRA Move the "W" key into bit 0.
28617 AND %00000001 Keep only bit 0.
28619 LD E,A Keep the result in E.
28620 LD A,C Fetch the key states.
28621 RLA Move the "Q" key into bit 1.
28622 AND %00000010 Keep only bit 1.
28624 OR E Combine with E.
28625 LD E,A Keep the result in E.
28626 LD A,C Fetch the key states.
28627 AND %00011100 Keep only bits 2-4 ("E", "R" and "T").
28629 OR E Combine with E.
28630 RET Return.
View the equivalent code in;
Prev: 28592 Up: Map Next: 28631