Difference between revisions of "Interpreter"
(4 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
− | The '''interpreter''' reads the [[ | + | The '''interpreter''' reads the [[Logic Resource|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: | For example, the logic commands: | ||
<div class="CodeBlockHeader">Code:</div> | <div class="CodeBlockHeader">Code:</div> | ||
− | + | <syntaxhighlight lang="agi"> | |
− | <syntaxhighlight lang="agi" | ||
v202 = 35; | v202 = 35; | ||
set(f98); | set(f98); | ||
− | </syntaxhighlight> | + | </syntaxhighlight> |
− | |||
− | 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. | + | translate into the sequence of numbers <code>3 202 35 12 98</code>, or (for those who like hexadecimal notation) <code>03 CA 23 0C 62</code>. The [[Assignn|assignn]] command has a bytecode of 3, the command is working with [[Variable|variable]] number <code>202</code>, and the variable is being assigned the number <code>35</code>. The [[Set|set]] command, with bytecode <code>12</code>, is going to set [[Flag|flag]] number <code>98</code>. 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<code>(f98)</code> from being written as <code>f98.set()</code> other than the need for a compiler to be written that translates <code>f98.set()</code> into the bytecode <code>12 98</code>. | ||
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|interpreter cycle]] for more details on what occurs during a cycle. | 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|interpreter cycle]] for more details on what occurs during a cycle. | ||
Line 16: | Line 16: | ||
== Interpreters == | == Interpreters == | ||
− | While Sierra's interpreters as original and real things run AGI | + | While Sierra's interpreters as original and real things run AGI games as they should be within boundaries of the 256 byte memory, newer fan made 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. |
* [[AGIL|AGIL]] | * [[AGIL|AGIL]] | ||
Line 32: | Line 32: | ||
* [[AGI|AGI]] | * [[AGI|AGI]] | ||
* [[Running AGI Games|Running AGI Games]] | * [[Running AGI Games|Running AGI Games]] | ||
− | * [[Hacked Interpreters|Hacked | + | * [[Hacked Interpreters|Hacked Interpreters]] |
Latest revision as of 16:04, 28 December 2013
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:
<syntaxhighlight lang="agi"> v202 = 35; set(f98); </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 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 fan made 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.