3D CONSTRUCTION KIT15. THE FREESCAPE COMMAND LANGUAGEThe Freescape system contains a simple language definition allowing functions to be performed when certain conditions occur within the Freescape environment. The commands can be used in any of three places;
In the following list P1, P2 and P3 or V1, V2 or V3 refer to parameters 1, 2 and 3 respectively. These can either be a literal number (referred to as P1, P2 or P3) or a variable number. In this case the contents of the variable will be used as the parameter value. Parameters which must be Variables are referred to as V1, V2, V3 e.g. SETV (P1,V2) shows that the second parameter must be a variable and the first is an absolute value Optional parameters or commands are surrounded by square brackets []. A list of the available commands follows with a description of the required parameters and their functions. CONDITIONSADCVFull Name: Add to Variable with CarryClass: Variable Manipulation Format: ADCV P1 V2 Function: This adds the absolute value P1 to variable V2. If the carry flag was set before the execution of this instruct, one (the carry) is also added to the result. If the result is greater than 255 then the value wraps around (becoming the would-be result minus 256) and the carry flag is set. See also: ADDV, SUBV, SBCV ADDVFull Name: Add to VariableClass: Variable Manipulation Format: ADDV P1 V2 Function: This adds the absolute value P1 to V2. If the result is greater than 255, then the value wraps around (becoming the would-be result minus 256) and the carry flag is set. See also: ADCV, SUBV, SBCV ANDFull Name: AndClass: Conditional Instruction Format: IF -xx- AND IF -xx- THEN <commands> [ELSE <commands> ENDIFFunction: This command combines the result of two or more condition checking commands and returns true only if all the specified checks are true otherwise a false result is returned. See also: IFEQ, IFLT, IFGT, THEN, ELSE, ENDIF, OR ANDVFull Name: AND VariableClass: Variable Manipulation Format: ANDV P1 V2 Function: This command performs the logical AND on the absolute value P1 and Variable number V2 and the result is stored in Variable number V2. This instruction requires some understanding of Binary and Logical functions. See also: ORV, XORV CMPVFull Name: Compare Variable with Absolute ValueClass: Variable Manipulation Format: CMPV P1 V2 Function: This command compares the value of P1 with V2. The value held in the variable specified as V2 is subtracted from the constant P1. The zero and carry flags are set accordingly. The contents of V2 remain unchanged. CMPV usually precedes an IFEQ, IFLT or IFGT instruction, as these act on the result of the comparison. Example: Variable 23 holds a count of objects collected in a game. No more than 5 objects are allowed to be carried at any one time. To see if an object may be picked up would require a check to see if less than five objects are carried. This could be performed with the following: CMPV 5 23 (compare contents of V23 with 5) IFLT (if V3 is less than 5) THEN (then) <Pick up object> ELSE <Object cannot be carried> ENDIFSee also: IFEQ, IFLT, IFGT, THEN, ELSE, ENDIF, OR CALLFull Name: Call ProcedureClass: Miscellaneous Instruction Format: CALL P1 Function: This calls the Procedure number P1. Processing will continue from the next instruction in the current condition list when the procedure exits. Note: Do not call a procedure from within itself or the computer will lock up! CROSSFull Name: CrossClass: Miscellaneous Instruction Format: CROSS P1 (either 0 or 1) Function: Turns the centre cross ON or OFF (0 is off and 1 is on). It defaults to 0 (on). COLOURFull Name: ColourClass: Miscellaneous Instruction Format: COLOUR P1 P2 Function: To change the colour of the 3D View window. Amstrad CPC & Commodore 64
Spectrum
DELAYFull Name: DelayClass: Miscellaneous Instruction Format: DELAY P1 Function: This command halts all Freescape functions for the specified time. The specified time P1 is in 50ths of a second. Example: DELAY 50 (would halt execution for 1 second.) DESTROYFull Name: Destroy ObjectClass: Object Manipulation Format: DESTROY P1 [P2] (object [area] ) Function: This command marks the given object as destroyed. If no area is specified then it is assumed the object is in the current area. Example: IFSHOT 4 2 THEN DESTROY 4 2 ENDIFThis simply asks if object 4 in area 2 has been shot and if so destroy object 4 in area 2. ELSEFull Name: ElseClass: Conditional Instruction Format: IF -xx- THEN <commands> [ELSE <commands...]> ENDIFFunction: This command exists only as part of an IF -xx-/THEN/ELSE/ENDIF combination. It marks the start of commands to execute only if the result of a previous condition was false. The effectiveness of the command relies on the correct usage of the IF and THEN commands. For any condition checking to work it is essential that the Condition be preceded by an IF -xx- command and followed by a THEN and (if required) an ELSE statement. See also: THEN, ENDIF ENDFull Name: End Command ProcessingClass: Miscellaneous Instruction Format: IF -xx- THEN /lt;commands...> END [ELSE <commands...]> ENDIF <commands...>Function: This command exits command processing before the end of the command list is reached. It allows the user to cut short the command execution on a particular condition being true or false. Used in the above format, if the result of the condition is true only the commands following the THEN statement will be executed and upon reaching the END command the processor would stop processing the commands from this list. Were there no END command the processor would continue executing from the command following the ENDIF statement. Note: If used in a procedure then processing returns to the command after the CALL instruction (in the condition list which called it). ENDGAMEFull Name: End GameClass: Miscellaneous Instruction Format: ENDGAME Function: This command serves to reset the environment. This can be executed on a particular condition being true or false, i.e. if a counter being used to store game time reaches zero then the game finishes and a RESET of the environment is performed. Example: In this example variable 10 has been assigned to store game time. CMPV 0 10 IFEQ THEN ENDGAME ENDIF ENDIFFull Name: End If ConditionClass: Conditional Instruction Format: IF -xx- THEN <commands...> [ELSE <commands...]> ENDIFFunction: This command terminates a conditional section. Upon reaching an ENDIF command, execution continues as normal before the IF -xx-/THEN/ELSE combination. If the result of a Condition is true the commands after the THEN statements are executed and those between the ELSE statement and the ENDIF are ignored. If the result is false the commands between the THEN and the ELSE statements are ignored and those between the ELSE and the ENDIF are executed. In either case unless an END command has been issued, command processing will continue after the ENDIF statement. See also: IF -xx-, Interrogators, THEN, ELSE GOTOFull Name: Go To Entrance/AreaClass: Vehicle Instruction Format: GOTO P1 [P2] (entrance [area] ) Function: This command is used to allow player movement between the various defined areas and/or entrances. Upon reaching this command the player will be moved to the ENTRANCE P1 in the AREA P2. If no area is specified, the entrance is presumed to be in the current area. If a new area is specified, command processing will cease at this point otherwise normal command processing will continue. Example: IFSHOT 9 THEN GOTO 1 2 ENDIFThe above example would be quite useful if it was desired that the player, upon shooting a doorway (object 9) would then be transported to Entrance 1 in Area 2. IFACTIVEFull Name: If Object ActiveClass: Conditional Instruction (Interrogator) Format: IFACTIVE P1 [P2] (P1 is an object number and P2 is an optional area number) THEN <commands...> ENDIFFunction: This command checks whether the selected object has been activated. Example: IFACTIVE 4 THEN INVIS 4 ENDIFThis condition simply informs the system that if object 4 is activated then make object 4 invisible. Note: IF's cannot be nested! IFCRUSHFull Name: If Crush OccurringClass: Conditional Instruction (Interrogator) Format: IFCRUSH THEN <commands...> ENDIFFunction: This Interrogator checks to see if the player occupies the same space as an object in the same area. If so, a true is returned allowing the result of the check to be dealt with by a THEN/[ELSE]/ENDIF construct. A positive result from the interrogator is usually obtained when an object is VISiblised and that object's bounding cube encloses the player's view point. It can also occur when the view point is moved (via a GOTO) to a space currently occupied by another object. IFEQFull Name: If EqualClass: Conditional Instruction Format: IFEQ THEN <commands...> [ELSE <commands...]> ENDIFFunction: This command returns a true result if the preceding command had a zero result. This instruction will normally follow a CMPV, ADDV, ADCV, SUBV or SBCV instruction and act on the result of it. A THEN/[ELSE]/ENDIF construct should follow this instruction. Note: IF's cannot be nested! IFFALLFull Name: If FallenClass: Conditional Instruction (Interrogator) Format: IFFALL THEN <commands...> [ELSE <commands...]> ENDIFFunction: This Interrogator returns true if the player has fallen past the safe fall height, specified as FALL ABILITY in the SETUP menu. The result of the check can then be dealt with by a THEN/[ELSE]/ENDIF construct. IFGTFull Name: If Greater ThanClass: Conditional Instruction Format: IFGT THEN <commands...> [ELSE<commands...]> ENDIFFunction: This command returns a true result if the preceding command had: (i) set the carry flag and (ii) unset the zero flag. This instruction will normally follow a CMPV, ADDV, ADCV, SUBV or SBCV instruction and act on the result of it. A THEN/[ELSE]/ENDIF construct should follow this instruction. Note: IF's cannot be nested! IFHITFull Name: If Object HitClass: Conditional Instruction (Interrogator) Format: IFHIT P1 THEN <commands...> [ELSE <commands...]> ENDIFFunction: This command checks if an object P1 has been collided with (or walked on). A true or false is returned. Example: IFHIT 4 THEN INVIS 4 VIS 5 ENDIFIn this condition the system checks if object 4 has been collided with. If it has then object 4 becomes invisible and object 5 becomes visible. This could be used to remove a door (object 4) and replace it with an open doorway (object 5). Note: IF's cannot be nested! See also: IFACTIVE, IFSHOT IFLTFull Name: If Less ThanClass: Conditional Instruction Format: IFLT THEN <commands...> [ELSE < commands...]> ENDIFFunction: This command returns a true result if the preceding command had: (i) unset the carry flag and (ii) unset the zero flag. This instruction will normally follow a CMPV, ADDV, ADCV, SUBV or SBCV instruction and act on the result of it. A THEN/[ELSE]/ENDIF construct should follow this instruction. Note: IF's cannot be nested! IFSENSEDFull Name: If SensedClass: Conditional Instruction (Interrogator) Format: IFSENSED THEN <commands...> [ELSE <commands...]> ENDIFFunction: This Interrogator returns true if the player is occupying space that is detectable by a sensor. The result of the interrogator is then acted upon bu a THEN/[ELSE]/ENDIF construct placed after it. The effectiveness of a sensor can be set by altering it's ATTRIBUTES. IFSHOTFull Name: If ShotClass: Conditional Instruction (Interrogator) Format: IFSHOT P1 (P1 is an object) THEN <commands...> [ELSE <commands...] ENDIFFunction: Checks if you have just shot object P1, returning a true or false. IFTIMERFull Name: If TimerClass: Conditional Instruction (Interrogator) Format: IFTIMER THEN <commands...> [ELSE <commands...]> ENDIFFunction: This command checks the TIMER flag, the command returns a true result if a time lapse of the amount specified in the SETUP section has passed, otherwise a false result is returned. Use the TIMER command to set TIMER frequency. IFVISFull Name: If Object VisibleClass: Conditional Instruction (Interrogator) Format: IFVIS P1 [P2] (P1 is an object number and P2 is an optional area number.) THEN <commands...> [ELSE <commands...]> ENDIFFunction: This command checks the INVISIBLE flag in the status byte of object P1 in area P2. If no area is specified then the object is presumed to be in the current area. The command returns a true result if the specified object is visible, otherwise a false result is returned. Example 1: IFHIT 12 THEN ELSE (if object 12, a door say, is not hit then end) END ENDIF (if it is then process the following) IFVIS 4 (if object 4, a switch perhaps, is visible) THEN (then) GOTO 1 5 (go to entrance 1 in area 5) ENDIFExample 2: To check if an object is invisible, check to see if it is visible but act on a false outcome. IFVIS 4 THEN ELSE Insert your commands here... ENDIF INVISFull Name: Invisiblise ObjectClass: Object Manipulation Format: INVIS P1 [P2] Function: Makes the object P1 in area P2 (optional) invisible. If the area is not specified, then object P1 in the current area is made invisible. Example: IFSHOT 8 THEN INVIS 9 ENDIFA simple condition which states that if object 8 is shot then object 9 will become invisible. See also: VIS MODEFull Name: Movement ModeClass: Vehicle Instruction Format: MODE P1 (P1 = movement mode code) Function: This command alters the current movement mode of the player in the game. The player is restricted to CRAWL, WALK, RUN, FLY1 and FLY2. The value of the new mode P1 must be in the range of 0-4. Any value above this will be interpreted as 4 and any value less than 0 will be interpreted as 0. The parameter and what it represents are listed below: 0 = Crawl 1 = Walk 2 = Run 3 = Fly1 4 = Fly2 ORFull Name: OrClass: Conditional Instruction Format: IF -xx- OR IF -xx- THEN <commands...> [ELSE <commands...]> ENDIFFunction: This command combines the result of two or more condition checking commands and returns true if any of the specified checks are true otherwise a false result is returned. See also: IFEQ, IFLT, IFGT, THEN, ELSE, ENDIF, AND ORVFull Name: OR VariableClass: Variable Manipulation Format: ORV P1 V2 Function: This command performs the logical OR on the two values specified. The value P1 is ORed with the variable V2 and the result is stored in variable V2. Flags are set accordingly. This instruction requires some understanding of Binary and Logical functions. Example 1: IFSHOT 8 (object) THEN ORV 2 21 ENDIFThis uses bit 2 of variable V21 as a flag to say that object 8 has been shot. Using this method it is possible to use a variable to store a number of on/off flags. The flags can be checked using the ANDV command, e.g. Example 2: ANDV 2 21 IFEQ THEN <commands...> [ELSE <commands...]> ENDIF Class: Miscellaneous Instruction Format: PRINT P1 xx yy Function: This command will print the specified message number P1 from the message list at the X (xx) and Y (yy) co-ordinates specified. These co-ordinates are in characters. Note: You must use a TEXTCOL command to set the colour. REDRAWFull Name: Redraw View WindowClass: Miscellaneous Instruction Format: REDRAW Function: This command will force an immediate redraw of the Freescape view window. Any objects whose status have changed since the last frame will be displayed in their new state. SETVFull Name: Set Variable ValueClass: Variable Manipulation Format: SETV P1 V2 Function: Sets the variable V2 to the value P1. SOUNDFull Name: SoundClass: Miscellaneous Instruction Format: SOUND P1 Function: This command will immediately perform the sound number P1. The parameter P1 must be in the range 0-12, the sounds corresponding to the value of the parameter are listed in the Appendix. SBCVFull Name: Subtract with CarryClass: Variable Manipulation Format: SBCV P1 V2 Function: This subtracts the absolute value P1 from the variable V2. If the carry flag was set before the execution of this instruction, then the result is decremented further by 1. See also: ADDV, ADCV, SUBV SUBVFull Name: SubtractClass: Variable Manipulation Format: SUBV P1 V2 Function: This subtracts the absolute value P1 from the variable V2. See also: ADDV, ADCV, SBCV SYNCSNDFull Name: Synchronise SoundClass: Miscellaneous Instruction Format: SYNCSND P1 Function: This command will execute the specified sound P1 in sync with the next complete frame update. The parameter P1 must be in the range 0-12, the sounds corresponding to the value of the parameter are listed in the Appendix. See also: SOUND TEXTCOLFull Name: Text ColourClass: Miscellaneous Instruction Format: TEXTCOL P1 Function: This command is used to set the text and background colour for printing messages. P1 is calculated thus:
THENFull Name: ThenClass: Conditional Statement Format: IF -xx- THEN <commands...> [ELSE <commands...]> ENDIFFunction: This command checks the status of the zero flag in the CCR. If the contents are true then the commands following the THEN statement are executed until either an ELSE or ENDIF statement is found. If an ELSE is found the commands following it are ignored up until an ENDIF or the end of the command list. If an ENDIF is found then normal command execution will continue with the following command. The THEN command is the only command which examines the result of a condition, so an IF -xx-, ELSE, ENDIF combination without a THEN command will produce incorrect results. TIMERFull Name: Timer Set FrequencyClass: Miscellaneous Instruction Format: TIMER P1 Function: The TIMER instruction sets the frequency at which the timer flag is set, for detection by an IFTIMER instruction. P1 is the interval time, and is in 50ths of a second. TOGVISFull Name: Toggle VisibilityClass: Object Manipulation Format: TOGVIS P1 [P2] (object [area] ) Function: This command will make an invisible object visible or a visible object invisible. If no area is specified the object is presumed to be in the current area. VISFull Name: VisibliseClass: Object Manipulation Format: VIS P1 [P2] (object [area] ) Function: This command makes an object visible. See also: INVIS, IFVIS, TOGVIS XORVFull Name: XOR VariableClass: Variable Manipulation Format: XORV P1 V2 Function: This command performs the logical EXCLUSIVE OR (EOR/XOR) on the two values specified. The value P1 is XORed with the variable V2 and the result is stored in variable V2. Flags are set accordingly. This instruction requires some understanding of Binary and Logical functions. Example 1: IFACTIVE 12 (object) THEN XORV 8 21 ENDIFThis uses bit 3 (the fourth bit) of variable V2 as a flag to say that object 12 has been activated or deactivated. This allows us to toggle a flag using only one bit. Possible uses include keeping track of switches which toggle between on and off. Using this method it is possible to use a variable to store up to eight on/off flags. The flags can be checked using the ANDV command, e.g. Example 2: ANDV 8 21 IFEQ THEN <commands...> [ELSE <commands...]> ENDIF |