Difference between revisions of "AGIWiki/Interpreter"
(Created page with "{{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 b...") |
(No difference)
|
Revision as of 20:58, 17 February 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: <syntax type = "C++"> v202 = 35; set(f98); </syntax> 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.