Difference between revisions of "AGIWiki/Interpreter"

From ScummVM :: Wiki
Jump to navigation Jump to search
(removing link to Sarien, since it's part of ScummVM and all relevant information about the history of Sarien is now in AGIWiki's ScummVM article)
m (Text replacement - "<source lang=" to "<syntaxhighlight lang=")
 
(2 intermediate revisions by the same user not shown)
Line 4: Line 4:
  
 
For example, the logic commands:
 
For example, the logic commands:
<syntax type = "C++">
+
<syntaxhighlight lang="cpp">
 
v202 = 35;
 
v202 = 35;
 
set(f98);
 
set(f98);
</syntax>
+
</syntaxhighlight>
 
translate into the sequence of numbers 3 202 35 12 98, or (for those who like hexadecimal notation) 03 CA 23 0C 62. The [[AGIWiki/Assignn|assignn]] command has a bytecode of 3, the command is working with [[AGIWiki/Variable|variable]] number 202, and the variable is being assigned the number 35. The [[AGIWiki/Set|set]] command, with bytecode 12, is going to set [[AGIWiki/Flag|flag]] number 98. When the interpreter reads these codes, it performs the actions that it knows correspond to those codes – this is the part that is called "interpreting."
 
translate into the sequence of numbers 3 202 35 12 98, or (for those who like hexadecimal notation) 03 CA 23 0C 62. The [[AGIWiki/Assignn|assignn]] command has a bytecode of 3, the command is working with [[AGIWiki/Variable|variable]] number 202, and the variable is being assigned the number 35. The [[AGIWiki/Set|set]] command, with bytecode 12, is going to set [[AGIWiki/Flag|flag]] number 98. When the interpreter reads these codes, it performs the actions that it knows correspond to those codes – this is the part that is called "interpreting."
  

Latest revision as of 15:17, 25 October 2018

AGIWiki


The interpreter reads the logic resources that are a part of an AGI game and uses them to run the game. Logic resources are compiled into a bytecode which has meaning to the interpreter.

For example, the logic commands:

v202 = 35;
set(f98);

translate into the sequence of numbers 3 202 35 12 98, or (for those who like hexadecimal notation) 03 CA 23 0C 62. The assignn command has a bytecode of 3, the command is working with variable number 202, and the variable is being assigned the number 35. The set command, with bytecode 12, is going to set flag number 98. When the interpreter reads these codes, it performs the actions that it knows correspond to those codes – this is the part that is called "interpreting."

As this example shows, the AGI bytecode is not especially complicated, and is for the most part a simple translation of commands to numbers. Having the bytecode allows the interpreter to avoid translating the textual logic code every interpreter cycle. It also allows AGI compilers to use their own syntax, which means that the C-style syntax is not the only possible syntax. There is nothing preventing the command set(f98) from being written as f98.set() other than the need for a compiler to be written that translates f98.set() into the bytecode 12 98.

The interpreter runs in cycles, which means that a game is essentially one giant loop that keeps running until the player quits, the game is completed, or an error occurs. See interpreter cycle for more details on what occurs during a cycle.

Interpreters

While Sierra's interpreters as original and real things run AGI-games as they should be within boundaries of the 256 byte memory, newer fanmade interpreters tend ignore such trivial issues among other things. The downside with Sierra's interpreters is that the technology those were built once is becoming ancient history and running them on modern hardware is either impossible or requires meddling with special software in the middle, e.g. DOSBox, in order to interpreter thus the game function properly. The newer interpreters support more features, platforms and operating systems, however running AGI games does not always go as it should.

Related links