Routines |
Prev: $392D | Up: Map | Next: $39C7 |
$3940 | LDA $EB | Pick up the keyboard delay counter from $EB. | ||
$3942 | BEQ $3951 | Branch if it's zero (time to read the keyboard). | ||
$3944 | CMP #$10 | Is the keyboard delay counter less than $10? | ||
$3946 | BCC $394C | Branch if so. | ||
$3948 | LDA #$10 | Reset the keyboard delay counter at $EB to $10. | ||
$394A | STA $EB | |||
$394C | DEC $EB | Decrement the keyboard delay counter at $EB. | ||
$394E | JMP $39C6 | Return. | ||
$3951 | LDA #$00 | Initialise the modifier key flag at $CA. | ||
$3953 | STA $CA | |||
$3955 | LDY #$40 | Initialise the keyboard indicator at $CB to no key. | ||
$3957 | STY $CB | |||
$3959 | TAY | Initialise the key index in Y to 0. | ||
$395A | STA $DC00 | Prepare to read the entire keyboard. | ||
$395D | LDX $DC01 | Pick up a keyboard reading. | ||
$3960 | CPX #$FF | Was any key pressed? | ||
$3962 | BEQ $39C6 | Return if not. | ||
$3964 | LDA #$00 | Prepare to address the standard keyboard table at $5F00. | ||
$3966 | STA $CE | |||
$3968 | LDA #$5F | |||
$396A | STA $CF | |||
$396C | LDA #$FE | Prepare to read keyboard matrix column 0. | ||
$396E | STA $DC00 | |||
$3971 | LDX #$08 | X will count the keyboard rows. | ||
$3973 | PHA | Save the keyboard column bit mask temporarily. | ||
$3974 | LDA $DC01 | Pick up a keyboard/joystick reading. | ||
$3977 | CMP $DC01 | Compare it with itself. | ||
$397A | BNE $3974 | Branch back to get another reading while it's changing. | ||
$397C | LSR A | Shift a bit of the keyboard reading into the carry flag. | ||
$397D | BCS $3993 | Branch if there was no keypress in this row. | ||
$397F | PHA | Save the remainder of the keyboard reading temporarily. | ||
$3980 | LDA ($CE),Y | Pick up a character code from the keyboard table at $5F00. | ||
$3982 | CMP #$05 | Is a control key being pressed? | ||
$3984 | BCS $3990 | Branch if not. | ||
$3986 | CMP #$03 | Is the STOP key being pressed? | ||
$3988 | BEQ $3990 | Branch if so. | ||
$398A | ORA $CA | Update the modifier key flag at $CA: SHIFT, CTRL or the CBM key is being pressed. | ||
$398C | STA $CA | |||
$398E | BPL $3992 | Skip over the next instruction. | ||
$3990 | STY $CB | Store the key index at $CB. | ||
$3992 | PLA | Restore the remainder of the keyboard reading to A. | ||
$3993 | INY | Increment the key index. | ||
$3994 | CPY #$41 | Have we read every key yet? | ||
$3996 | BCS $39A3 | Branch if so. | ||
$3998 | DEX | Decrement the keyboard row counter. | ||
$3999 | BNE $397C | Branch back to check the next row. | ||
$399B | SEC | Set the carry flag to ensure that a set bit is rotated into bit 0 of the mask in A. | ||
$399C | PLA | Restore the keyboard column bit mask to A. | ||
$399D | ROL A | Prepare to read the next keyboard matrix column. | ||
$399E | STA $DC00 | |||
$39A1 | BNE $3971 | Branch back to get a reading. | ||
$39A3 | PLA | Drop the keyboard column bit mask from the stack. | ||
$39A4 | LDA $CA | Pick up the modifier key flag from $CA. | ||
$39A6 | CMP #$03 | Were the SHIFT and CBM keys being pressed? | ||
$39A8 | BEQ $39BC | Branch if so to use the standard keyboard table. | ||
$39AA | ASL A | Shift the modifier key flag left. | ||
$39AB | CMP #$08 | Was CTRL being pressed? | ||
$39AD | BCC $39B1 | Branch if not. | ||
$39AF | LDA #$06 | Select the CTRL keyboard table. | ||
$39B1 | TAX | Collect the appropriate keyboard table address from $4438 and store it at $CE. | ||
$39B2 | LDA $4438,X | |||
$39B5 | STA $CE | |||
$39B7 | LDA $4439,X | |||
$39BA | STA $CF | |||
$39BC | LDY $CB | Pick up an entry from one of the four keyboard tables at $5F00. | ||
$39BE | LDA ($CE),Y | |||
$39C0 | STA $4C | Set the keyboard reading at $4C. | ||
$39C2 | LDA #$0F | Reset the keyboard delay counter at $EB to $0F. | ||
$39C4 | STA $EB | |||
$39C6 | RTS |
Prev: $392D | Up: Map | Next: $39C7 |