![]() |
Routines |
| Prev: ADF8 | Up: Map | Next: AE56 |
|
Used by the routines at Handle_Sabreman_On_Rope, Handle_Sabreman_Walking, Handle_Sabreman_Jumping, Handle_Sabreman_Falling, Update_Rope, Steer_Eagle and Handle_Carried_Sabreman.
Reads the controls that were chosen on the game selection screen (see GameOptions). A bit is reset when its 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.
Bit 5 is reset when a key from the bottom row of the keyboard (CAPS SHIFT, Z, X, C or V) is pressed, whichever control method is in use.
The cursor keys and the Interface II joystick are read by Read_Cursor_Keys and Read_Interface_II_Joystick. The Kempston joystick is read directly.
|
||||||||||||||||||||
|
Pick the routine for the control method.
|
||||||||||||||||||||
| ReadControls | AE17 | LD A,($8ED5) | Fetch the control method from GameOptions. | |||||||||||||||||
| AE1A | AND %00000011 | Keep only the control method bits (bits 0 and 1). | ||||||||||||||||||
| AE1C | JR Z,ReadControls_Keyboard | Jump to ReadControls_Keyboard if the keyboard is being used. | ||||||||||||||||||
| AE1E | CP $02 | Jump to Read_Cursor_Keys if the cursor keys are being used. | ||||||||||||||||||
| AE20 | JP Z,Read_Cursor_Keys | |||||||||||||||||||
| AE23 | CP $03 | Jump to Read_Interface_II_Joystick if the Interface II joystick is being used. | ||||||||||||||||||
| AE25 | JP Z,Read_Interface_II_Joystick | |||||||||||||||||||
|
Read the Kempston joystick.
|
||||||||||||||||||||
| AE28 | IN A,($1F) | Read the Kempston joystick. | ||||||||||||||||||
| AE2A | CPL | Flip the bits, so that a reset bit is a direction or fire which is used. | ||||||||||||||||||
| AE2B | LD B,A | Store the state of the controls in B. | ||||||||||||||||||
|
This entry point is used by the routines at Read_Cursor_Keys and Read_Interface_II_Joystick.
Read the bottom row of the keyboard, which sets bit 5 whichever control method is being used.
|
||||||||||||||||||||
| ReadControls_Bottom_Row | AE2C | LD A,$FE | Read from the keyboard;
|
|||||||||||||||||
| AE2E | OUT ($FD),A | |||||||||||||||||||
| AE30 | IN A,($FE) | |||||||||||||||||||
| AE32 | CPL | Flip the bits so that a pressed key gives a set bit. | ||||||||||||||||||
| AE33 | AND %00011111 | Keep only the five keys. | ||||||||||||||||||
| AE35 | SET 5,B | Set bit 5 of the controls. | ||||||||||||||||||
| AE37 | JR Z,ReadControls_Fetch_State | Jump to ReadControls_Fetch_State if none of those keys is pressed. | ||||||||||||||||||
| AE39 | RES 5,B | Reset bit 5 of the controls. | ||||||||||||||||||
| ReadControls_Fetch_State | AE3B | LD A,B | Fetch the state of the controls. | |||||||||||||||||
| AE3C | RET | Return. | ||||||||||||||||||
|
Read the keyboard controls.
|
||||||||||||||||||||
| ReadControls_Keyboard | AE3D | LD A,$FB | Read from the keyboard;
|
|||||||||||||||||
| AE3F | OUT ($FD),A | |||||||||||||||||||
| AE41 | IN A,($FE) | |||||||||||||||||||
| AE43 | LD C,A | Stash the state of the keys in C. | ||||||||||||||||||
| AE44 | RRA | Move bit 1 (W) into bit 0. | ||||||||||||||||||
| AE45 | AND %00000001 | Keep only that bit (right). | ||||||||||||||||||
| AE47 | LD B,A | Store it in B. | ||||||||||||||||||
| AE48 | LD A,C | Fetch the state of the keys. | ||||||||||||||||||
| AE49 | RLA | Move bit 0 (Q) into bit 1. | ||||||||||||||||||
| AE4A | AND %00000010 | Keep only that bit (left). | ||||||||||||||||||
| AE4C | OR B | Combine it with right. | ||||||||||||||||||
| AE4D | LD B,A | Store the result in B. | ||||||||||||||||||
| AE4E | LD A,C | Fetch the state of the keys. | ||||||||||||||||||
| AE4F | AND %00011100 | Keep only bits 2 to 4 (E, R and T: down, up and fire). | ||||||||||||||||||
| AE51 | OR B | Combine them with right and left. | ||||||||||||||||||
| AE52 | LD B,A | Store the result in B. | ||||||||||||||||||
| AE53 | JP ReadControls_Bottom_Row | Jump to ReadControls_Bottom_Row to read the bottom row of the keyboard. | ||||||||||||||||||
| Prev: ADF8 | Up: Map | Next: AE56 |