• Work continues

General Info
Main Page
Latest News
Schedule
What is it?
About Matt
About This Site

Duke Enhancements
Latest Features
Older Features
Cheat Codes

Duke Insider
Language Basics
Compile Time
Room over Room
Player Structures
UserDef Explanations

More Information
Features Database
E Duke Forum

WW2GI Enhancements
Variables
Weapon Changes
Weapon Settings
System Variables
Events
All


Language Basics

This is a short description of how the CON language is parsed and processed.

Parsing

Parsing is performed using a directected interpreter (in other words, it's all hard-coded).

The commands are translated at startup 'compile time' into a series of DWORDs.  Each DWORD is an opcode with a variable number of parameters.   All parameters are (currently) DWORDs (long).

Parsing is performed by lookup into a table of keywords.   The offset into the table is the 'opcode'.  All of the Duke opcodes are hardcoded like this:

	case 7:
	   if( parsing_actor || parsing_state )
		transnum();
   	   else
	   {
	...
  

In this case, 7 is the offset of the keyword 'action' in the keyword table.  You (I) just have to know that when reading the code.

All the commands that I have added have #defines for them, so they read a little more naturaly.  In addition, I have added comments for the code I write :)

        case CON_ADDLOGVAR:
            // syntax: addlogvar <var>

            // prints the line number in the log file.
            *scriptptr=line_number;
            scriptptr++;
	...
  

After the commands have been translated into the script, Duke Startup continues. (assuming that there are no errors).  The size of the 'compiled' script has been increased from Duke, so larger CONs can be created.

 

Name Definitions

When something is defined, the name is stored in a temporary table for lookup.  This table is removed after compilation is complete.

When a quote is defined, it is stored in a special 'quote' string table.

Running the Scripts

When a script needs to be run, the interpreter gets an offset into the compiled script.  This is provided by the object that is running the script.  For example, an actor stores the script offset as part of its structure.   The code is the start of the actor's code in the CON.  The script is run until the 'end' is found.  Then the Duke code goes on processing the next object.

Run Time

At run-time, the script DWORDS are retrived and processed through a big switch() statement.

The case statement for the command retrieves the needed paramaters from the script and perfoms the action meant by the command.

For instance, the runtime for command 7 ('action') is:

	case 7:
	    gc = *scriptptr; break;  

 

Saving and Loading

When a game is saved and loaded, the script and associated tables (quotes, etc) are in the saved file.  The CON code is not re-processed.

 

Copyright © 2000, Matt Saettler. All Rights Reserved