![]() |
Routines |
| Prev: 45333 | Up: Map | Next: 45620 |
|
Used by the routine at ReadControls.
Reads the device that was chosen on the title screen: the keyboard (0), a Kempston joystick (1), a Cursor joystick (2) or a Sinclair Interface 2 joystick (3). The result is in the same layout for all of them. The keyboard has no joystick, so the keys of the middle two rows are all for up, the top row is for fire, the number keys are for the extra key, and the keys of the bottom row alternate between right and left.
|
||||||||
| ReadInputDevice | 45423 | LD A,(62979) | The control device. | |||||
| 45426 | AND A | Jump to ReadInputDevice_Keyboard if A is zero. | ||||||
| 45427 | JP Z,ReadInputDevice_Keyboard | |||||||
| 45430 | CP 1 | Jump to ReadInputDevice_Kempston if A is 1. | ||||||
| 45432 | JR Z,ReadInputDevice_Kempston | |||||||
| 45434 | CP 2 | Jump to ReadInputDevice_Cursor if A is 2. | ||||||
| 45436 | JR Z,ReadInputDevice_Cursor | |||||||
| 45438 | JR ReadInputDevice_Interface2 | Jump to ReadInputDevice_Interface2. | ||||||
| ReadInputDevice_Kempston | 45440 | IN A,(31) | Read port 31. | |||||
| 45442 | AND %00011111 | Keep the bits of A that are set in 31. | ||||||
| 45444 | LD C,A | C=A. | ||||||
| 45445 | JP ReadInputDevice_Joystick | Jump to ReadInputDevice_Joystick. | ||||||
| ReadInputDevice_Interface2 | 45448 | LD A,239 | A=239. | |||||
| 45450 | OUT (253),A | Send A to port 253. | ||||||
| 45452 | IN A,(254) | Read port 254. | ||||||
| 45454 | LD B,255 | B=255. | ||||||
| 45456 | RRA | Rotate A right. | ||||||
| 45457 | RL B | Rotate B left through the carry. | ||||||
| 45459 | RRA | Rotate A right. | ||||||
| 45460 | RL B | Rotate B left through the carry. | ||||||
| 45462 | RRA | Rotate A right. | ||||||
| 45463 | RL B | Rotate B left through the carry. | ||||||
| 45465 | RRA | Rotate A right. | ||||||
| 45466 | RRA | Rotate A right. | ||||||
| 45467 | RL B | Rotate B left through the carry. | ||||||
| 45469 | RLA | Rotate A left. | ||||||
| 45470 | RL B | Rotate B left through the carry. | ||||||
| 45472 | LD A,B | A=B. | ||||||
| 45473 | CPL | Invert A. | ||||||
| 45474 | LD C,A | C=A. | ||||||
| 45475 | JP ReadInputDevice_Joystick | Jump to ReadInputDevice_Joystick. | ||||||
| ReadInputDevice_Cursor | 45478 | LD A,239 | A=239. | |||||
| 45480 | OUT (253),A | Send A to port 253. | ||||||
| 45482 | IN A,(254) | Read port 254. | ||||||
| 45484 | OR %11100000 | Set the bits of A that are set in 224. | ||||||
| 45486 | LD B,A | B=A. | ||||||
| 45487 | AND %00001000 | Keep the bits of A that are set in 8. | ||||||
| 45489 | LD C,A | C=A. | ||||||
| 45490 | LD A,B | A=B. | ||||||
| 45491 | RRCA | Rotate A right. | ||||||
| 45492 | RRCA | Rotate A right. | ||||||
| 45493 | LD B,A | B=A. | ||||||
| 45494 | AND %00000101 | Keep the bits of A that are set in 5. | ||||||
| 45496 | OR C | Set the bits of A that are set in C. | ||||||
| 45497 | LD C,A | C=A. | ||||||
| 45498 | LD A,B | A=B. | ||||||
| 45499 | RRA | Rotate A right. | ||||||
| 45500 | RRA | Rotate A right. | ||||||
| 45501 | AND %00010000 | Keep the bits of A that are set in 16. | ||||||
| 45503 | OR C | Set the bits of A that are set in C. | ||||||
| 45504 | LD C,A | C=A. | ||||||
| 45505 | LD A,247 | A=247. | ||||||
| 45507 | OUT (253),A | Send A to port 253. | ||||||
| 45509 | IN A,(254) | Read port 254. | ||||||
| 45511 | RRA | Rotate A right. | ||||||
| 45512 | RRA | Rotate A right. | ||||||
| 45513 | RRA | Rotate A right. | ||||||
| 45514 | AND %00000010 | Keep the bits of A that are set in 2. | ||||||
| 45516 | OR C | Set the bits of A that are set in C. | ||||||
| 45517 | CPL | Invert A. | ||||||
| 45518 | LD C,A | C=A. | ||||||
| 45519 | JP ReadInputDevice_Joystick | Jump to ReadInputDevice_Joystick. | ||||||
| ReadInputDevice_Keyboard | 45522 | XOR A | Clear A. | |||||
| 45523 | LD C,A | C=A. | ||||||
| 45524 | LD A,254 | A=254. | ||||||
| 45526 | OUT (253),A | Send A to port 253. | ||||||
| 45528 | IN A,(254) | Read port 254. | ||||||
| 45530 | AND %00010100 | Keep the bits of A that are set in 20. | ||||||
| 45532 | LD B,A | B=A. | ||||||
| 45533 | LD A,127 | A=127. | ||||||
| 45535 | OUT (253),A | Send A to port 253. | ||||||
| 45537 | IN A,(254) | Read port 254. | ||||||
| 45539 | AND %00001010 | Keep the bits of A that are set in 10. | ||||||
| 45541 | OR B | Set the bits of A that are set in B. | ||||||
| 45542 | XOR %00011110 | Flip the bits of A that are set in 30. | ||||||
| 45544 | JR Z,ReadInputDevice_Left | Jump to ReadInputDevice_Left if the zero flag is set. | ||||||
| 45546 | LD A,C | A=C. | ||||||
| 45547 | OR %00000001 | Set the bits of A that are set in 1. | ||||||
| 45549 | LD C,A | C=A. | ||||||
| 45550 | JR ReadInputDevice_Up | Jump to ReadInputDevice_Up. | ||||||
| ReadInputDevice_Left | 45552 | LD A,254 | A=254. | |||||
| 45554 | OUT (253),A | Send A to port 253. | ||||||
| 45556 | IN A,(254) | Read port 254. | ||||||
| 45558 | AND %00001010 | Keep the bits of A that are set in 10. | ||||||
| 45560 | LD B,A | B=A. | ||||||
| 45561 | LD A,127 | A=127. | ||||||
| 45563 | OUT (253),A | Send A to port 253. | ||||||
| 45565 | IN A,(254) | Read port 254. | ||||||
| 45567 | AND %00010100 | Keep the bits of A that are set in 20. | ||||||
| 45569 | OR B | Set the bits of A that are set in B. | ||||||
| 45570 | XOR %00011110 | Flip the bits of A that are set in 30. | ||||||
| 45572 | JR Z,ReadInputDevice_Up | Jump to ReadInputDevice_Up if the zero flag is set. | ||||||
| 45574 | SET 1,C | Set bit 1 of C. | ||||||
| ReadInputDevice_Up | 45576 | LD A,189 | A=189. | |||||
| 45578 | CALL ReadKeyboardPort | Call ReadKeyboardPort. | ||||||
| 45581 | JR Z,ReadInputDevice_Fire | Jump to ReadInputDevice_Fire if the zero flag is set. | ||||||
| 45583 | SET 3,C | Set bit 3 of C. | ||||||
| ReadInputDevice_Fire | 45585 | LD A,219 | A=219. | |||||
| 45587 | CALL ReadKeyboardPort | Call ReadKeyboardPort. | ||||||
| 45590 | JR Z,ReadInputDevice_Extra | Jump to ReadInputDevice_Extra if the zero flag is set. | ||||||
| 45592 | SET 4,C | Set bit 4 of C. | ||||||
| ReadInputDevice_Extra | 45594 | LD A,231 | A=231. | |||||
| 45596 | LD B,0 | Clear B. | ||||||
| ReadInputDevice_Test | 45598 | CALL ReadKeyboardPort | Call ReadKeyboardPort. | |||||
| 45601 | OR B | Set the bits of A that are set in B. | ||||||
| 45602 | RET Z | Return if the zero flag is set. | ||||||
| 45603 | SET 5,C | Set bit 5 of C. | ||||||
| 45605 | RET | Return. | ||||||
| ReadInputDevice_Joystick | 45606 | RES 5,C | Reset bit 5 of C. | |||||
| 45608 | LD A,126 | A=126. | ||||||
| 45610 | CALL ReadKeyboardPort | Call ReadKeyboardPort. | ||||||
| 45613 | AND %00011110 | Keep the bits of A that are set in 30. | ||||||
| 45615 | LD B,A | B=A. | ||||||
| 45616 | LD A,153 | A=153. | ||||||
| 45618 | JR ReadInputDevice_Test | Jump to ReadInputDevice_Test. | ||||||
| Prev: 45333 | Up: Map | Next: 45620 |