.TT102 CMP #f8 \ If red key f8 was pressed, jump to STATUS to show the BNE P%+5 \ Status Mode screen, returning from the subroutine JMP STATUS \ using a tail call CMP #f4 \ If red key f4 was pressed, jump to TT22 to show the BNE P%+5 \ Long-range Chart, returning from the subroutine using JMP TT22 \ a tail call CMP #f5 \ If red key f5 was pressed, jump to TT23 to show the BNE P%+5 \ Short-range Chart, returning from the subroutine using JMP TT23 \ a tail call CMP #f6 \ If red key f6 was pressed, call TT111 to select the BNE TT92 \ system nearest to galactic coordinates (QQ9, QQ10) JSR TT111 \ (the location of the chart crosshairs) and set ZZ to JMP TT25 \ the system number, and then jump to TT25 to show the \ Data on System screen (along with an extended system \ description for the system in ZZ if we're docked), \ returning from the subroutine using a tail call .TT92 CMP #f9 \ If red key f9 was pressed, jump to TT213 to show the BNE P%+5 \ Inventory screen, returning from the subroutine JMP TT213 \ using a tail call CMP #f7 \ If red key f7 was pressed, jump to TT167 to show the BNE P%+5 \ Market Price screen, returning from the subroutine JMP TT167 \ using a tail call CMP #f0 \ If red key f0 was pressed, jump to TT110 to launch our BNE fvw \ ship (if docked), returning from the subroutine using JMP TT110 \ a tail call .fvw CMP #f1 \ If the key pressed is < red key f1 or > red key f3, BCC LABEL_3 \ jump to LABEL_3 (so only do the following if the key CMP #f3+1 \ pressed is f1, f2 or f3) BCS LABEL_3 AND #3 \ If we get here then we are either in space, or we are TAX \ docked and none of f1-f3 were pressed, so we can now JMP LOOK1 \ process f1-f3 with their in-flight functions, i.e. \ switching space views \ \ A will contain &71, &72 or &73 (for f1, f2 or f3), so \ set X to the last digit (1, 2 or 3) and jump to LOOK1 \ to switch to view X (rear, left or right), returning \ from the subroutine using a tail call .LABEL_3 CMP #&54 \ If "H" was pressed, jump to hyp to do a hyperspace BNE P%+5 \ jump (if we are in space), returning from the JMP hyp \ subroutine using a tail call CMP #&32 \ If "D" was pressed, jump to T95 to print the distance BEQ T95 \ to a system (if we are in one of the chart screens) STA T1 \ Store A (the key that's been pressed) in T1 LDA QQ11 \ If the current view is a chart (QQ11 = 64 or 128), AND #%11000000 \ keep going, otherwise jump down to TT107 to skip the BEQ TT107 \ following LDA QQ22+1 \ If the on-screen hyperspace counter is non-zero, BNE TT107 \ then we are already counting down, so jump to TT107 \ to skip the following LDA T1 \ Restore the original value of A (the key that's been \ pressed) from T1 CMP #&36 \ If "O" was pressed, do the following three jumps, BNE ee2 \ otherwise skip to ee2 to continue JSR TT103 \ Draw small crosshairs at coordinates (QQ9, QQ10), \ which will erase the crosshairs currently there JSR ping \ Set the target system to the current system (which \ will move the location in (QQ9, QQ10) to the current \ home system JSR TT103 \ Draw small crosshairs at coordinates (QQ9, QQ10), \ which will draw the crosshairs at our current home \ system .ee2 JSR TT16 \ Call TT16 to move the crosshairs by the amount in X \ and Y, which were passed to this subroutine as \ arguments .TT107 LDA QQ22+1 \ If the on-screen hyperspace counter is zero, return BEQ t95 \ from the subroutine (as t95 contains an RTS), as we \ are not currently counting down to a hyperspace jump DEC QQ22 \ Decrement the internal hyperspace counter BNE t95 \ If the internal hyperspace counter is still non-zero, \ then we are still counting down, so return from the \ subroutine (as t95 contains an RTS) \ If we get here then the internal hyperspace counter \ has just reached zero and it wasn't zero before, so \ we need to reduce the on-screen counter and update \ the screen. We do this by first printing the next \ number in the countdown sequence, and then printing \ the old number, which will erase the old number \ and display the new one because printing uses EOR \ logic LDX QQ22+1 \ Set X = the on-screen hyperspace counter - 1 DEX \ (i.e. the next number in the sequence) JSR ee3 \ Print the 8-bit number in X at text location (0, 1) LDA #5 \ Reset the internal hyperspace counter to 5 STA QQ22 LDX QQ22+1 \ Set X = the on-screen hyperspace counter (i.e. the \ current number in the sequence, which is already \ shown on-screen) JSR ee3 \ Print the 8-bit number in X at text location (0, 1), \ i.e. print the hyperspace countdown in the top-left \ corner DEC QQ22+1 \ Decrement the on-screen hyperspace countdown BNE t95 \ If the countdown is not yet at zero, return from the \ subroutine (as t95 contains an RTS) JMP TT18 \ Otherwise the countdown has finished, so jump to TT18 \ to do a hyperspace jump, returning from the subroutine \ using a tail call .t95 RTS \ Return from the subroutine .T95 \ If we get here, "D" was pressed, so we need to show \ the distance to the selected system (if we are in a \ chart view) LDA QQ11 \ If the current view is a chart (QQ11 = 64 or 128), AND #%11000000 \ keep going, otherwise return from the subroutine (as BEQ t95 \ t95 contains an RTS) JSR hm \ Call hm to move the crosshairs to the target system \ in (QQ9, QQ10), returning with A = 0 STA QQ17 \ Set QQ17 = 0 to switch to ALL CAPS JSR cpl \ Print control code 3 (the selected system name) LDA #%10000000 \ Set bit 7 of QQ17 to switch to Sentence Case, with the STA QQ17 \ next letter in capitals LDA #1 \ Move the text cursor to column 1 and down one line STA XC \ (in other words, to the start of the next line) INC YC JMP TT146 \ Print the distance to the selected system and return \ from the subroutine using a tail callName: TT102 [Show more] Type: Subroutine Category: Keyboard Summary: Process function key, save key, hyperspace and chart key presses and update the hyperspace counterContext: See this subroutine in context in the source code Variations: See code variations for this subroutine in the different versions References: This subroutine is called as follows: * Main game loop (Part 6 of 6) calls TT102
Process function key presses, plus "@" (save commander), "H" (hyperspace), "D" (show distance to system) and "O" (move chart cursor back to current system). We can also pass cursor position deltas in X and Y to indicate that the cursor keys or joystick have been used (i.e. the values that are returned by routine TT17).
Arguments: A The internal key number of the key pressed (see p.142 of the Advanced User Guide for a list of internal key numbers) X The amount to move the crosshairs in the x-axis Y The amount to move the crosshairs in the y-axis
Other entry points: T95 Print the distance to the selected system
[X]
Label LABEL_3 is local to this routine
[X]
Subroutine LOOK1 (category: Flight)
Initialise the space view
[X]
Subroutine STATUS (category: Status)
Show the Status Mode screen (red key f8)
[X]
Subroutine TT103 (category: Charts)
Draw a small set of crosshairs on a chart
[X]
Label TT107 is local to this routine
[X]
Subroutine TT110 (category: Flight)
Launch from a station or show the front space view
[X]
Subroutine TT111 (category: Universe)
Set the current system to the nearest system to a point
[X]
Subroutine TT146 (category: Universe)
Print the distance to the selected system in light years
[X]
Subroutine TT16 (category: Charts)
Move the crosshairs on a chart
[X]
Subroutine TT167 (category: Market)
Show the Market Price screen (red key f7)
[X]
Subroutine TT18 (category: Flight)
Try to initiate a jump into hyperspace
[X]
Subroutine TT213 (category: Market)
Show the Inventory screen (red key f9)
[X]
Subroutine TT22 (category: Charts)
Show the Long-range Chart (red key f4)
[X]
Subroutine TT23 (category: Charts)
Show the Short-range Chart (red key f5)
[X]
Subroutine TT25 (category: Universe)
Show the Data on System screen (red key f6)
[X]
Label TT92 is local to this routine
[X]
Subroutine cpl (category: Universe)
Print the selected system name
[X]
Label ee2 is local to this routine
[X]
Subroutine ee3 (category: Flight)
Print the hyperspace countdown in the top-left of the screen
[X]
Configuration variable f0 = &20
Internal key number for red key f0 (Launch, Front)
[X]
Configuration variable f1 = &71
Internal key number for red key f1 (Buy Cargo, Rear)
[X]
Configuration variable f3 = &73
Internal key number for red key f3 (Equip Ship, Right)
[X]
Configuration variable f4 = &14
Internal key number for red key f4 (Long-range Chart)
[X]
Configuration variable f5 = &74
Internal key number for red key f5 (Short-range Chart)
[X]
Configuration variable f6 = &75
Internal key number for red key f6 (Data on System)
[X]
Configuration variable f7 = &16
Internal key number for red key f7 (Market Price)
[X]
Configuration variable f8 = &76
Internal key number for red key f8 (Status Mode)
[X]
Configuration variable f9 = &77
Internal key number for red key f9 (Inventory)
[X]
Label fvw is local to this routine
[X]
Subroutine hm (category: Charts)
Select the closest system and redraw the chart crosshairs
[X]
Subroutine hyp (category: Flight)
Start the hyperspace process
[X]
Subroutine ping (category: Universe)
Set the selected system to the current system
[X]
Label t95 is local to this routine