![]() |
Routines |
| Prev: C8EF | Up: Map | Next: CA07 |
|
Used by the routines at PLAYER_LEGS and TURNING_LEGS.
Reads the keyboard or a joystick, by the method in bits 1-2 of CONTROL, into one byte for this turn: the legs' update routines (PLAYER_LEGS, TURNING_LEGS) use it in C, and it is kept in INPUT for the pick-up (CHK_PICKUP_DROP).
The keyboard: Z, C, M and B turn left and X, V, SYMBOL SHIFT and N right; the whole of the A-G and H-ENTER rows walk; the whole of the Q-T and Y-P rows jump; any number key picks up or puts down. CAPS SHIFT and SPACE do nothing here (SPACE pauses, HANDLE_PAUSE). The joysticks: left and right turn, up walks, fire jumps and down picks up or puts down. The Kempston is read from port 31; the cursor keys are 5 left, 8 right, 7 up, 6 down and 0 fire; Interface II is the keys 6-0 for one stick and 1-5 for the other, read together.
Bit 5 is set, whatever the method, by any letter key, ENTER or SYMBOL SHIFT -- everything but CAPS SHIFT, SPACE and the number keys. With directional control on a joystick, where down is a direction, it is the pick-up in place of bit 4 (CHK_PICKUP_DROP), as in Knight Lore. While the game is won or the scene after a game runs (WON, GAME_OVER) only bit 5 is read: the robot takes no orders.
Pentagram's is the same but for its fire button, and it has no bit 5.
|
||||||||||
| READ_CONTROLS | C8FF | LD A,(WON) | Won, or the scene after a game: nothing but bit 5 | |||||||
| C902 | LD C,A | |||||||||
| C903 | LD A,(GAME_OVER) | |||||||||
| C906 | OR C | |||||||||
| C907 | LD C,$00 | |||||||||
| C909 | JP NZ,READ_LETTER_KEYS | |||||||||
| C90C | LD A,(CONTROL) | Bits 1-2 of CONTROL: 0 keyboard, 1 Kempston, 2 cursor keys... | ||||||||
| C90F | RRCA | |||||||||
| C910 | AND $03 | |||||||||
| C912 | JP Z,READ_KEYBOARD | |||||||||
| C915 | DEC A | |||||||||
| C916 | JR Z,READ_KEMPSTON | |||||||||
| C918 | DEC A | |||||||||
| C919 | JR Z,READ_CURSOR | |||||||||
| C91B | LD A,$F7 | ...3 Interface II: keys 1-5, their order reversed into C, so that 5 is bit 0 and 1 is bit 4, as 0 and 6 are on the other half-row | ||||||||
| C91D | CALL READ_KEYS | |||||||||
| C920 | PUSH BC | |||||||||
| C921 | LD B,$05 | |||||||||
| READ_CONTROLS_0 | C923 | RRA | ||||||||
| C924 | RL C | |||||||||
| C926 | DJNZ READ_CONTROLS_0 | |||||||||
| C928 | LD A,C | |||||||||
| C929 | POP BC | |||||||||
| C92A | LD C,A | |||||||||
| C92B | LD A,$EF | OR in keys 6-0: bit 0 fire (0 or 5), 1 up (9 or 4), 2 down (8 or 3), 3 right (7 or 2), 4 left (6 or 1) | ||||||||
| C92D | CALL READ_KEYS | |||||||||
| C930 | OR C | |||||||||
| C931 | LD C,$00 | Fire: jump | ||||||||
| C933 | BIT 0,A | |||||||||
| C935 | JR Z,READ_CONTROLS_1 | |||||||||
| C937 | SET 3,C | |||||||||
| READ_CONTROLS_1 | C939 | BIT 1,A | Up: walk | |||||||
| C93B | JR Z,READ_CONTROLS_2 | |||||||||
| C93D | SET 2,C | |||||||||
| READ_CONTROLS_2 | C93F | BIT 2,A | Down: pick up or put down | |||||||
| C941 | JR Z,READ_CONTROLS_3 | |||||||||
| C943 | SET 4,C | |||||||||
| READ_CONTROLS_3 | C945 | BIT 3,A | Right: turn right | |||||||
| C947 | JR Z,READ_CONTROLS_4 | |||||||||
| C949 | SET 1,C | |||||||||
| READ_CONTROLS_4 | C94B | BIT 4,A | Left: turn left; then bit 5 | |||||||
| C94D | JR Z,READ_CONTROLS_5 | |||||||||
| C94F | SET 0,C | |||||||||
| READ_CONTROLS_5 | C951 | JP READ_LETTER_KEYS | ||||||||
| READ_KEMPSTON | C954 | IN A,($1F) | The Kempston joystick: bit 0, right, turns right | |||||||
| C956 | LD C,$00 | |||||||||
| C958 | BIT 0,A | |||||||||
| C95A | JR Z,READ_CONTROLS_6 | |||||||||
| C95C | SET 1,C | |||||||||
| READ_CONTROLS_6 | C95E | BIT 1,A | Bit 1, left: turn left | |||||||
| C960 | JR Z,READ_CONTROLS_7 | |||||||||
| C962 | SET 0,C | |||||||||
| READ_CONTROLS_7 | C964 | BIT 2,A | Bit 2, down: pick up or put down | |||||||
| C966 | JR Z,READ_CONTROLS_8 | |||||||||
| C968 | SET 4,C | |||||||||
| READ_CONTROLS_8 | C96A | BIT 3,A | Bit 3, up: walk | |||||||
| C96C | JR Z,READ_CONTROLS_9 | |||||||||
| C96E | SET 2,C | |||||||||
| READ_CONTROLS_9 | C970 | BIT 4,A | Bit 4, fire: jump; then bit 5 | |||||||
| C972 | JR Z,READ_CONTROLS_10 | |||||||||
| C974 | SET 3,C | |||||||||
| READ_CONTROLS_10 | C976 | JP READ_LETTER_KEYS | ||||||||
| READ_CURSOR | C979 | LD C,$00 | The cursor keys: 5 turns left | |||||||
| C97B | LD A,$F7 | |||||||||
| C97D | CALL READ_KEYS | |||||||||
| C980 | BIT 4,A | |||||||||
| C982 | JR Z,READ_CONTROLS_11 | |||||||||
| C984 | SET 0,C | |||||||||
| READ_CONTROLS_11 | C986 | LD A,$EF | 0: jump | |||||||
| C988 | CALL READ_KEYS | |||||||||
| C98B | BIT 0,A | |||||||||
| C98D | JR Z,READ_CONTROLS_12 | |||||||||
| C98F | SET 3,C | |||||||||
| READ_CONTROLS_12 | C991 | BIT 3,A | 7: walk | |||||||
| C993 | JR Z,READ_CONTROLS_13 | |||||||||
| C995 | SET 2,C | |||||||||
| READ_CONTROLS_13 | C997 | BIT 2,A | 8: turn right | |||||||
| C999 | JR Z,READ_CONTROLS_14 | |||||||||
| C99B | SET 1,C | |||||||||
| READ_CONTROLS_14 | C99D | BIT 4,A | 6: pick up or put down; then bit 5 | |||||||
| C99F | JR Z,READ_LETTER_KEYS | |||||||||
| C9A1 | SET 4,C | |||||||||
| C9A3 | JR READ_LETTER_KEYS | |||||||||
| READ_KEYBOARD | C9A5 | LD A,$FE | The keyboard. CAPS SHIFT to V: Z and C brought down to bit 0, turn left, and X and V to bit 1, turn right; CAPS SHIFT dropped | |||||||
| C9A7 | CALL READ_KEYS | |||||||||
| C9AA | RRCA | |||||||||
| C9AB | LD C,A | |||||||||
| C9AC | AND $03 | |||||||||
| C9AE | SRL C | |||||||||
| C9B0 | SRL C | |||||||||
| C9B2 | OR C | |||||||||
| C9B3 | AND $03 | |||||||||
| C9B5 | LD C,A | |||||||||
| C9B6 | LD A,$7F | SYMBOL SHIFT turns right... | ||||||||
| C9B8 | CALL READ_KEYS | |||||||||
| C9BB | BIT 1,A | |||||||||
| C9BD | JR Z,READ_CONTROLS_15 | |||||||||
| C9BF | SET 1,C | |||||||||
| READ_CONTROLS_15 | C9C1 | BIT 2,A | ...M left... | |||||||
| C9C3 | JR Z,READ_CONTROLS_16 | |||||||||
| C9C5 | SET 0,C | |||||||||
| READ_CONTROLS_16 | C9C7 | BIT 3,A | ...N right... | |||||||
| C9C9 | JR Z,READ_CONTROLS_17 | |||||||||
| C9CB | SET 1,C | |||||||||
| READ_CONTROLS_17 | C9CD | BIT 4,A | ...B left | |||||||
| C9CF | JR Z,READ_CONTROLS_18 | |||||||||
| C9D1 | SET 0,C | |||||||||
| READ_CONTROLS_18 | C9D3 | LD A,$BD | Any key on the A-G or H-ENTER rows (both half-rows at once): walk | |||||||
| C9D5 | CALL READ_KEYS | |||||||||
| C9D8 | JR Z,READ_CONTROLS_19 | |||||||||
| C9DA | SET 2,C | |||||||||
| READ_CONTROLS_19 | C9DC | LD A,$DB | Any on the Q-T or Y-P rows: jump | |||||||
| C9DE | CALL READ_KEYS | |||||||||
| C9E1 | JR Z,READ_CONTROLS_20 | |||||||||
| C9E3 | SET 3,C | |||||||||
| READ_CONTROLS_20 | C9E5 | LD A,$E7 | Any number key: pick up or put down | |||||||
| C9E7 | CALL READ_KEYS | |||||||||
| C9EA | JR Z,READ_LETTER_KEYS | |||||||||
| C9EC | SET 4,C | |||||||||
| READ_LETTER_KEYS | C9EE | LD A,$7E | Any of Z, X, C, V, SYMBOL SHIFT, M, N and B, or of the four other letter half-rows: bit 5 | |||||||
| C9F0 | CALL READ_KEYS | |||||||||
| C9F3 | AND $1E | |||||||||
| C9F5 | PUSH BC | |||||||||
| C9F6 | LD B,A | |||||||||
| C9F7 | LD A,$99 | |||||||||
| C9F9 | CALL READ_KEYS | |||||||||
| C9FC | OR B | |||||||||
| C9FD | POP BC | |||||||||
| C9FE | JR Z,READ_CONTROLS_21 | |||||||||
| CA00 | SET 5,C | |||||||||
| READ_CONTROLS_21 | CA02 | LD A,C | This turn's controls into INPUT, and in A and C | |||||||
| CA03 | LD (INPUT),A | |||||||||
| CA06 | RET | |||||||||
| Prev: C8EF | Up: Map | Next: CA07 |