Prev: 31537 Up: Map Next: 32055
31688: Process command to move starship
Used by the routine at 55726.
31688 LD A,255 Store 255 at 23694 and 23696...
31690 LD (23696),A ...to preserve attributes already on screen...
31693 LD (23694),A ...
31696 CALL 54333 Print or update command summary window at top of screen
31699 LD DE,41888 Point DE at "MOVE THE STARSHIP TO"...
31702 CALL 54283 ...and print in command summary window at top of screen
31705 LD A,(23700) Load D with USS Pisces' current location...
31708 LD D,A ...
31709 LD HL,53329 Point HL at starship location connectivity data
31712 LD BC,16384 Load B with 64 and C with zero
31715 LD A,(HL) Load current location index in starship location connectivity data into A...
31716 CP D ...and if this is the same as the USS Pisces' Current Location...
31717 JR Z,31723 ...then skip ahead to 31723
31719 INC HL Advance HL to next location index
31720 INC C Increase C
31721 DJNZ 31715 Loop back to 31715
31723 LD A,C Load C (index of index of USS Pisces' Current Location!) into instruction at 31766 as operand...
31724 LD (31767),A ...
31727 LD BC,9 Load BC with 9
31730 OR A Reset carry flag
31731 SBC HL,BC Move HL back nine bytes to cell to current location's north-west
31733 LD DE,23436 Point DE at the list of currently available destinations
31736 LD B,3 Load B with 3
31738 PUSH BC Store BC (B = current repeat counter)
31739 LD A,(HL) Copy entry from starship location connectivity data to list of currently available destinations...
31740 LD (DE),A ...
31741 INC DE Advance list of currently available destinations pointer
31742 INC HL Advance starship location connectivity data pointer east one unit
31743 LD A,B If repeat counter is 2...
31744 CP 2 ...
31746 JR Z,31751 ...then skip ahead to 31751 (skip over current location as we are already here!)
31748 LD A,(HL) Copy entry from starship location connectivity data to list of currently available destinations...
31749 LD (DE),A ...
31750 INC DE Advance list of currently available destinations pointer
31751 INC HL Advance starship location connectivity data pointer east one unit
31752 LD A,(HL) Copy entry from starship location connectivity data to list of currently available destinations...
31753 LD (DE),A ...
31754 INC DE Advance list of currently available destinations pointer
31755 LD BC,6 Advance starship location connectivity data pointer by 6 bytes (i.e. south one and west two units)...
31758 ADD HL,BC ...
31759 POP BC Restore BC (B = current repeat counter)
31760 DJNZ 31738 Loop back to 31738 for next iteration
31762 LD IX,23436 Point IX at start of list of currently available destinations
31766 LD A,0 Load A with index of index of USS Pisces' Current Location as stored by instruction at 31723
31768 CP 8 If index is less than 8 (i.e. already on northern-most row of grid)...
31770 JP C,32200 ...then remove starship destination entries for locations to the north-west, north and north-east
31773 CP 24 If index is 24 or more (i.e. already on southern-most row of grid)...
31775 JP NC,32213 ...then remove starship destination entries for locations to the south-west, south and south-east
This entry point is used by the routines at 32200 and 32213.
31778 LD A,(31767) Load A with index of index of USS Pisces' Current Location as stored by instruction at 31723
31781 AND 7 If lowest three bits are reset...
31783 OR A ...(i.e. already on western-most column of grid)...
31784 JP Z,32226 ...then remove starship destination entries for locations to the north-west, west and south-west
31787 CP 7 If lowest three bits are set (i.e. already on eastern-most column of grid)...
31789 JP Z,32239 ...then remove starship destination entries for locations to the north-east, east and south-east
This entry point is used by the routines at 32226 and 32239.
Code here compacts the list of currently available destinations at 23436 by removing mid-list zeroes.
31792 LD HL,23436 Point HL at start of list of currently available destinations
31795 LD DE,23436 Point DE at start of list of currently available destinations
31798 LD BC,2048 Set B = 8 (as list of currently available destinations can have at most eight entries) and C = 0
31801 LD A,(HL) If current available destination list entry is zero...
31802 OR A ...
31803 JR Z,31808 ...then skip ahead to 31808 (advance HL to next list position)
31805 LD (DE),A Set byte at DE to value read from HL
31806 INC C Increase C (current number of entries in tidied list)
31807 INC DE Advance DE to next list position
31808 INC HL Advance HL to next list position
31809 DJNZ 31801 Decrease B (remaining list entries to process) and loop back to 31801
31811 LD A,9 Load A with 9...
31813 ADD A,C ...plus number of entries in list of currently available destinations
31814 PUSH BC Store BC (C = number of available destinations)
31815 LD (37292),A Set y-coordinate of bottom of "WHERE TO ?" window (25) to value stored in A
31818 LD A,1 Set initial (and minimum allowed) y-coordinate of hand cursor to 1 for window 25...
31820 LD (37295),A ...
31823 LD A,25 Draw "WHERE TO?" menu window...
31825 CALL 34982 ...
31828 LD HL,41899 Point HL at "WHERE TO ?" text...
31831 CALL 34762 ...and print to screen
31834 POP BC Restore BC (C = number of available destinations)
Print list of available destinations as options in "WHERE TO ?" window
31835 LD HL,23436 Point HL at start of list of currently available destinations
31838 LD B,C Load B with number of available destinations
31839 LD A,(HL) Load location index from current position in list of currently available destinations
31840 PUSH HL Store HL (current position in list of currently available destinations)
31841 PUSH BC Store BC (B = remaining number of available destinations)
31842 PUSH AF Store AF (A = index of a location read from destinations list)
31843 LD HL,38351 Move cursor to start of next character row within window, then right by two characters...
31846 CALL 34762 ...
31849 POP AF Restore AF (A = index of a location read from destinations list)
31850 LD B,A Load B with location index...
31851 CALL 54261 ...and point HL at that location's name
31854 CALL 34762 Print the location's name in the menu window
31857 POP BC Restore BC (B = remaining number of available destinations)
31858 POP HL Restore HL (current position in list of currently available destinations)
31859 INC HL Advance HL to next location in list
31860 DJNZ 31839 Loop back to 31839 to print next name in list
31862 CALL 35296 Process keyboard / joystick input on a menu and load A with selected item index
31865 LD C,A Load BC with index of selected destination...
31866 LD B,0 ...
31868 LD HL,23436 Point HL at start of list of currently available destinations...
31871 ADD HL,BC ...and advance to entry for selected destination
31872 LD A,(HL) Store this location index as operand of instruction at 32034...
31873 LD (32035),A ...
31876 LD B,A Load B with location's index
31877 CALL 54261 Point HL at the location's name
31880 EX DE,HL Switch HL and DE (DE now points to location's name)...
31881 CALL 54283 ...and print in command summary window at top of screen
31884 LD DE,38233 Point DE at "AT"...
31887 CALL 54283 ...and print in command summary window at top of screen
31890 LD DE,37291 Point DE at y-coordinate of top edge of window 25...
31893 LD A,14 ...and set this window's height to 14...
31895 CALL 33782 ...
31898 LD A,2 Set initial (and minimum allowed) y-coordinate of hand cursor to 2 for window 25...
31900 LD (37295),A ...
31903 LD A,25 Draw menu window 25...
31905 CALL 34982 ...
31908 LD HL,41928 Point HL at "MOVE STARSHIP" speed selection menu heading text...
31911 CALL 34762 ...and print to screen
31914 LD HL,41943 Point HL at "MOVE STARSHIP" speed selection menu options text...
31917 CALL 34762 ...and print to screen
31920 CALL 35296 Process keyboard / joystick input on a menu and load A with selected item index
31923 LD (23484),A Store selected speed index at 23484
31926 LD HL,41984 Point HL at start of list of speed strings
31929 LD B,A Load B with index of selected speed
31930 CALL 54269 Advance HL to B-th entry in list of speed strings
31933 EX DE,HL Switch HE and DE (DE now points to speed string for selected speed)...
31934 CALL 54283 ...and print in command summary window at top of screen
31937 CALL 55115 Display execute / reject command window and return here if execute chosen, else exit to main game loop
31940 CALL 33788 If Gordon and Sarab are both asleep then reset zero flag, otherwise increase their happiness by five if not
31943 JP NZ,55291 If zero flag is reset then display "GORDON AND SARAB ARE BOTH ASLEEP" window (12) and return to game
31946 LD A,27 If Magic Knight is wearing the Gas Mask (27)...
31948 CALL 33640 ...
31951 JP Z,55327 ...then display "GORDON AND SARAB CANNOT UNDERSTAND YOU" window (12) and return to game
31954 CALL 36415 Reset all stars to point of origin and generate new velocities and movement data
31957 LD A,189 Set Current Starship Location in " LOCATION : [name of Current Starship Location]" text at 38298...
31959 LD (38307),A ...to "IN TRANSIT" (189)
31962 CALL 27765 Draw Magic Knight's current room, draw objects and characters and initialise room-specific data
31965 CALL 32065 Scroll viewscreen content down 24 pixel rows then display acceleration / deceleration effect (i.e. leave orbit)
31968 LD A,(23484) Load A with selected speed index...
31971 NEG ...multiply by minus one...
31973 ADD A,10 ...and add 10 to give a delay constant between 1 (fastest) to 10 (slowest)
31975 LD (36350),A Update operand to instruction at 36349 to hold delay constant value
31978 LD A,(23484) Load A with selected speed index plus one...
31981 INC A ...
31982 ADD A,A Load E with this value multiplied by eight...
31983 ADD A,A ...
31984 ADD A,A ...
31985 LD E,A ...
31986 LD BC,1 Load B with zero and C (remaining number of blocks of 256 timesteps to process) with 1
31989 PUSH BC Store BC (B = remaining number of timesteps to process)
31990 PUSH DE Store DE (E = eight times [speed index + 1])
31991 CALL 36321 Advance positions of stars on viewscreen by one timestep
31994 POP DE Restore DE (E = eight times [speed index + 1])
31995 LD A,(23435) Load A with fraction remaining of current unit of star drive fuel
31998 SUB E Subtract E (eight times [speed index + 1])...
31999 LD (23435),A ...and store
32002 JR NC,32017 If unit of star drive fuel was not completely depleted then skip ahead to 32017
32004 LD A,(25013) Decrease USS Pisces' star drive fuel by one...
32007 DEC A ...
32008 LD (25013),A ...
32011 LD HL,44953 Point HL at "YOU RAN OUT OF STAR DRIVE FUEL..." text
32014 JP Z,55685 If no star drive fuel remains then jump to "game over" window routine and return to control selection menu
32017 POP BC Restore BC (B = remaining number of timesteps to process)
32018 DJNZ 31989 Decrease remaining number of timesteps to process and loop back to 31989 if not zero
32020 DEC C Decrease C (remaining number of blocks of 256 timesteps to process)
32021 JR NZ,31989 If C is not zero (i.e. there are more blocks of timesteps to process) then loop back to 31989
32023 CALL 35782 Play "USS Pisces has arrived" sound
32026 CALL 32124 Display acceleration / deceleration effect then scroll viewscreen content up 24 pixel rows (i.e. enter orbit)
32029 LD A,28 Set Current Starship Location in " LOCATION : [name of Current Starship Location]" text at 38298...
32031 LD (38307),A ...to the name of the Current Starship Location (28)
The operand of the instruction at 32034 represents the selected destination from the "MOVE STARSHIP" command. This is modified by the instruction at 31873.
32034 LD A,0 Load A with selected destination location index...
32036 LD (23700),A ...and set this as the USS Pisces' current location
32039 CP 5 If A is 5 (i.e. location is Starbase 1)...
32041 CALL Z,32055 ...then set unknown flag and set A to zero
32044 CP 27 If A is 27 (location index of Starbase 2 in 128k version)... (see trivia)
32046 CALL Z,32055 ...then set unknown flag and set A to zero
32049 CALL 27703 Draw top in-game window
32052 JP 55277 Display "THE STARSHIP HAS ARRIVED AT [Starship Location]" window (12) and return to game
Prev: 31537 Up: Map Next: 32055