.TT17 JSR DOKEY \ Scan the keyboard for flight controls and pause keys, \ (or the equivalent on joystick) and update the key \ logger, setting KL to the key pressed \ --- Mod: Code removed for Demonstration Disc: -------> \LDA JSTK \ If the joystick is not configured, jump down to TJ1, \BEQ TJ1 \ otherwise we move the cursor with the joystick \ \LDA JSTX \ Fetch the joystick roll, ranging from 1 to 255 with \ \ 128 as the centre point \ \EOR #&FF \ Flip the sign so A = -JSTX, because the joystick roll \ \ works in the opposite way to moving a cursor on-screen \ \ in terms of left and right \ \JSR TJS1 \ Call TJS1 just below to set A to a value between -2 \ \ and +2 depending on the joystick roll value (moving \ \ the stick sideways) \ \TYA \ Copy Y to A \ \TAX \ Copy A to X, so X contains the joystick roll value \ \LDA JSTY \ Fetch the joystick pitch, ranging from 1 to 255 with \ \ 128 as the centre point, and fall through into TJS1 to \ \ set Y to the joystick pitch value (moving the stick up \ \ and down) \ \.TJS1 \ \TAY \ Store A in Y \ \LDA #0 \ Set the result, A = 0 \ \CPY #16 \ If Y >= 16 set the C flag, so A = A - 1 \SBC #0 \ \\CPY #&20 \ These instructions are commented out in the original \\SBC #0 \ source, but they would make the joystick move the \ \ cursor faster by increasing the range of Y by -1 to +1 \ \CPY #64 \ If Y >= 64 set the C flag, so A = A - 1 \SBC #0 \ \CPY #192 \ If Y >= 192 set the C flag, so A = A + 1 \ADC #0 \ \CPY #224 \ If Y >= 224 set the C flag, so A = A + 1 \ADC #0 \ \\CPY #&F0 \ These instructions are commented out in the original \\ADC #0 \ source, but they would make the joystick move the \ \ cursor faster by increasing the range of Y by -1 to +1 \ \TAY \ Copy the value of A into Y \ \LDA KL \ Set A to the value of KL (the key pressed) \ \RTS \ Return from the subroutine \ --- End of removed code -----------------------------> .TJ1 \ --- Mod: Code removed for Demonstration Disc: -------> \LDA KL \ Set A to the value of KL (the key pressed) \ \LDX #0 \ Set the initial values for the results, X = Y = 0, \LDY #0 \ which we now increase or decrease appropriately \ \CMP #&19 \ If left arrow was pressed, set X = X - 1 \BNE P%+3 \DEX \ \CMP #&79 \ If right arrow was pressed, set X = X + 1 \BNE P%+3 \INX \ \CMP #&39 \ If up arrow was pressed, set Y = Y + 1 \BNE P%+3 \INY \ \CMP #&29 \ If down arrow was pressed, set Y = Y - 1 \BNE P%+3 \DEY \ --- And replaced by: --------------------------------> LDX #0 \ Set the initial values for the results, X = Y = 0, LDY #0 \ which we now increase or decrease appropriately LDA QQ11 \ If the current view is not the Short-range Chart, CMP #128 \ jump to chrt3 to skip the following, so we only set BNE chrt3 \ up the hyperspace jump when the chart is visible LDA QQ22+1 \ If the on-screen hyperspace counter is zero, then we BEQ chrt1 \ are not currently counting down to a hyperspace jump, \ so jump to chrt1 to keep setting up the hyperspace \ jump \ We are currently counting down to a hyperspace jump, \ so we have already finished moving the pointer to \ Riedquat and initialising the hyperspace jump, so now \ we want to leave the Short-range Chart and switch to \ the main space view to watch the hyperspace tunnel LDY #60 \ Wait for 60/50 of a second (1.2 seconds) JSR DELAY LDA #f0 \ Set KL so that we "press" f0 to switch to the front STA KL \ space view and leave the Short-range Chart RTS \ Return from the subroutine .chrt1 DEX \ Set X = X - 1 to move the chart crosshairs left by \ one pixel LDA QQ10 \ If the galactic y-coordinate of the crosshairs is 181 CMP #181 \ then we have already reached Riedquat, so jump to BEQ chrt2 \ chrt2 to skip moving the crosshairs down, as they are \ already at the correct vertical position DEY \ Set Y = Y - 1 to move the chart crosshairs down by \ one pixel .chrt2 LDA QQ9 \ If the galactic x-coordinate of the crosshairs is not CMP #3 \ yet 3 then jump to chrt3 to skip the following, so we BNE chrt3 \ keep the left movement above so the crosshairs move \ left towards Riedquat INX \ If we get here then we have now reached Riedquat in \ the horizontal x-axis direction, so reverse the \ decrement to put X back to zero \ \ We also know that we will have reached Riedquat in the \ vertical y-axis direction by now, as Riedquat is far \ to the left of the starting point of Lave, so we need \ to do more x-axis steps than y-axis steps, so now we \ can do the hyperspace LDA #&54 \ Set KL so that we "press" "H" to initiate a hyperspace STA KL .chrt3 LDA KL \ Set A to the value of KL (the key being pressed) \ --- End of replacement ------------------------------> RTS \ Return from the subroutineName: TT17 [Show more] Type: Subroutine Category: Keyboard Summary: Scan the keyboard for cursor key or joystick movementContext: See this subroutine in context in the source code References: This subroutine is called as follows: * Main game loop (Part 5 of 6) calls TT17
Scan the keyboard and joystick for cursor key or stick movement, and return the result as deltas (changes) in x- and y-coordinates as follows: * For joystick, X and Y are integers between -2 and +2 depending on how far the stick has moved * For keyboard, X and Y are integers between -1 and +1 depending on which keys are pressed
Returns: A The key pressed, if the arrow keys were used X Change in the x-coordinate according to the cursor keys being pressed or joystick movement, as an integer (see above) Y Change in the y-coordinate according to the cursor keys being pressed or joystick movement, as an integer (see above)
[X]
Subroutine DELAY (category: Utility routines)
Wait for a specified time, in 1/50s of a second
[X]
Subroutine DOKEY (category: Keyboard)
Scan for the seven primary flight controls
[X]
Label chrt1 is local to this routine
[X]
Label chrt2 is local to this routine
[X]
Label chrt3 is local to this routine
[X]
Configuration variable f0 = &20
Internal key number for red key f0 (Launch, Front)