Ci-dessous, les différences entre deux révisions de la page.
Les deux révisions précédentesRévision précédenteProchaine révision | Révision précédente | ||
agi-game:specifications-resources [2021/05/24 15:11] – [How the interpreter handles the code] frater | agi-game:specifications-resources [2023/04/13 09:50] (Version actuelle) – frater | ||
---|---|---|---|
Ligne 1: | Ligne 1: | ||
- | ====== Logic resources ====== | + | ====== |
- | ===== Introduction | + | ==== Introduction ==== |
- | At the heart of Sierra's Adventure Game Interpreter | + | Au cœur de l'AGI (Adventure Game Interpreter) de Sierra se trouve le fichier " |
- | These files contain the code that makes up the game. Each room has a logic script that goes with it. This logic script governs what can take place in that room. Here is an example of what the programmer writes when a game is being created. | + | |
- | Example: KQ4. Room 7. | + | Ces fichiers contiennent le code qui compose le jeu. Chaque pièce est accompagnée d'un script logique. Ce script logique régit ce qui peut se passer dans cette salle. |
+ | |||
+ | Voici un exemple de ce que le programmeur écrit lors de la création d'un jeu. | ||
+ | |||
+ | Exemple: KQ4. Room 7. | ||
<code C> | <code C> | ||
Ligne 41: | Ligne 44: | ||
===== Command list and argument types ===== | ===== Command list and argument types ===== | ||
- | Following tables show a list of all AGI commands and their argument | + | Les tableaux suivants présentent une liste de toutes les commandes |
+ | |||
+ | Les noms des commandes sont tirés des messages | ||
^ Opcode | ^ Opcode | ||
Ligne 253: | Ligne 258: | ||
- | ==== The header ==== | + | ==== le header ==== |
- | The header of each logic script | + | L' |
- | discussed at a later stage. | + | |
+ | Après cette date, une compression | ||
+ | |||
+ | Cette compression sera discutée ultérieurement. | ||
^ Offset | ^ Offset | ||
| 0-1 | Signature (0x12--0x34) | | 0-1 | Signature (0x12--0x34) | ||
- | | 2 | Vol number that the resource is contained in | + | | 2 | Numéro du volume dans lequel la ressource est contenue |
- | | 3-4 | Length of the resource without the header | + | | 3-4 | Longueur de la ressource sans l' |
- | | 5-6 | Offset of logic code message | + | | 5-6 | Décalage de la section |
- | All text that can be printed to the screen from within a logic script | + | Tout le texte qui peut être imprimé à l' |
- | Example: KQ1. Room 2. | + | Exemple: KQ1. Room 2. |
< | < | ||
Ligne 276: | Ligne 284: | ||
==== Opcodes === | ==== Opcodes === | ||
- | The logic code section starts immediately after the header and continues until the start of the message section has been reached. There are three sets of codes used in a logic script. Most codes will have between one and seven arguments inclusive. This is discussed later on. | ||
- | The first set of codes is the AGI commands themselves listed in the previous tables, and they have the range 0x00--0xB6. | ||
- | The second set of codes is as follows: | + | La section du code logique commence immédiatement après l' |
+ | |||
+ | Trois séries de codes sont utilisées dans un script logique. | ||
+ | |||
+ | La plupart des codes ont entre un et sept arguments inclus. Nous y reviendrons plus loin. | ||
+ | |||
+ | La première série de codes correspond aux commandes AGI elles-mêmes énumérées dans les tableaux précédents et se situe dans la plage 0x00--0xB6. | ||
+ | |||
+ | La deuxième série de codes est la suivante | ||
^ Code ^ Command | ^ Code ^ Command | ||
Ligne 287: | Ligne 301: | ||
| FC | **or** | | FC | **or** | ||
- | At present these are the only high value codes encountered. The '' | + | À l' |
- | Example: KQ1, Room 2. | + | Exemple: KQ1, Room 2. |
<code C> | <code C> | ||
Ligne 298: | Ligne 312: | ||
</ | </ | ||
- | The above translates to: | + | que l'on peut traduire comme ci-dessous: |
<code C> | <code C> | ||
Ligne 304: | Ligne 318: | ||
</ | </ | ||
- | which tests whether | + | ce code test si le "flag" numero |
+ | Le '' | ||
< | < | ||
0x00 - 0x12 Condition codes. | 0x00 - 0x12 Condition codes. | ||
</ | </ | ||
+ | Lorsque l' | ||
- | When the interpreter encounters a 0xFF it will then interpret the following code values as being in the condition code range until it encounters the next 0xFF which switches it back into normal AGI command | + | Les deux octets qui suivent immédiatement le deuxième |
- | mode. The two bytes immediately following the second 0xFF determine how many bytes this '' | + | |
- | us or the machine, does three things: | + | |
- | - Reads in the following two bytes. | + | Lorsque le deuxième '' |
- | - Opens a bracket. | + | |
- | - Switches to AGI command mode. | + | |
- | Example: KQ1, Room 2. | + | - Il lit les deux octets suivants. |
+ | - Il ouvre une parenthèse. | ||
+ | - Il passe en mode de commande AGI. | ||
+ | |||
+ | Exemple: KQ1, Room 2. | ||
<code C> | <code C> | ||
Ligne 331: | Ligne 347: | ||
</ | </ | ||
- | ==== The '' | + | ==== la commande **else** et plus sur les parenthèses |
- | The ''else'' | + | L'instruction **else** continue |
- | Here's an example: | + | Cette caractéristique est importante et a causé un certain nombre de problèmes dans le passé. |
+ | |||
+ | Lorsqu'une instruction **else** suit une instruction **if**, la distance entre les crochets après l' | ||
+ | |||
+ | voici un exemple: | ||
<code C> | <code C> | ||
Ligne 352: | Ligne 372: | ||
</ | </ | ||
- | Usually you would expect the bracket distance to be 0x0002 but in the above case it is clearly 0x0005 which illustrates the difference between a straight '' | ||
- | The '' | + | En général, on s'attend à ce que la distance entre les crochets soit de 0x0002, mais dans le cas ci-dessus, elle est clairement de 0x0005, ce qui illustre la différence entre une instruction **if** directe et une structure **if..else**. |
- | ==== Test conditions ==== | + | La situation est la même pour les structures **if..else** imbriquées. |
- | Conditions can be one of the following | + | Les instructions **else** elles-mêmes ressemblent beaucoup aux instructions **if**, sauf que leur condition de test est donnée après le code '' |
+ | |||
+ | Seule la distance entre les crochets est donnée après le code '' | ||
+ | |||
+ | ==== Test de conditions ==== | ||
+ | |||
+ | Les conditions peuvent être de l'un des types suivants: | ||
< | < | ||
- | FF 07 05 FF One condition | + | FF 07 05 FF Une condition |
- | FF FD 07 05 FF | + | FF FD 07 05 FF |
- | FF 07 05 07 06 FF Multiple | + | FF 07 05 07 06 FF Plusieurs |
- | FF FC 07 05 07 06 FC FF Multiple | + | FF FC 07 05 07 06 FC FF Plusieurs |
FF FC 07 06 07 06 FC FD 07 08 FF Combination. | FF FC 07 06 07 06 FC FD 07 08 FF Combination. | ||
</ | </ | ||
- | These conditions | + | Ces conditions |
<code C> | <code C> | ||
Ligne 378: | Ligne 403: | ||
</ | </ | ||
- | If multiple boolean | + | Si plusieurs |
- | their values are ORed together. | + | |
+ | Si plusieurs | ||
+ | |||
+ | Le code '' | ||
- | The 0xFD code only applies to the following condition code whose boolean value it inverts. | ||
==== Arguments ==== | ==== Arguments ==== | ||
- | You may well be asking how the interpreter knows how many arguments | + | Vous vous demandez peut-être comment l' |
- | Inside this file there is a table which contains four bytes for each AGI command and condition | + | |
+ | Cette information | ||
+ | |||
+ | Dans ce fichier, il y a un tableau qui contient quatre octets pour chaque commande | ||
+ | |||
+ | Ces quatre octets sont interprétés comme suit : | ||
^ Offset | ^ Offset | ||
- | | 0-1 | Pointer to implementation | + | | 0-1 | Pointeur vers le code de mise en œuvre |
- | | 2 | Number of arguments | + | | 2 | Numbre d'arguments |
- | | 3 | Type of arguments | + | | 3 | Type d'arguments |
- | The type of arguments | + | Le type de valeur des arguments |
< | < | ||
Ligne 399: | Ligne 431: | ||
</ | </ | ||
- | If the bit is set, argument | + | Si le bit est activé, l'argument |
+ | |||
+ | La fonction du bit 0 n'est pas connue, car aucune commande | ||
Examples: | Examples: | ||
- | * 0x80 Says that the commands first argument | + | * 0x80 Indique que le premier |
- | * 0x60 Says that the second and third arguments | + | * 0x60 Indique que les deuxième et troisième |
+ | |||
+ | ==== la section messages ==== | ||
- | ==== The messages | + | La section |
- | The messages section of a logic script contains all the strings that can be displayed by that logic script. These strings are encrypted by xor' | + | Ces chaînes sont cryptées par **XOR** tous les onze octets avec la chaîne |
- | Example: KQ1, Room 2. | + | Exemple: KQ1, Room 2. |
<code C> | <code C> | ||
Ligne 419: | Ligne 455: | ||
</ | </ | ||
- | In the above example, the print statement is represented as: | + | Dans l' |
< | < | ||
Ligne 425: | Ligne 461: | ||
</ | </ | ||
- | The 0x08 is the number given to the string and corresponds to its position | + | Le '' |
- | The format | + | |
+ | Le format | ||
^ Offset | ^ Offset | ||
Ligne 436: | Ligne 473: | ||
==== Implementation ==== | ==== Implementation ==== | ||
- | The implementation for each AGI statement is found in the '' | + | The implementation for each AGI statement is found in the //agi/// file. This is the AGI interpreter itself. The data in the '' |
Example: MH2, equaln. | Example: MH2, equaln. | ||
Ligne 589: | Ligne 626: | ||
//Situation 2.// | //Situation 2.// | ||
- | If the code is an 0xFF code, then if jumps to the '' | + | If the code is an 0xFF code, then if jumps to the **if** statement handler. In this routine is basically assesses whether the whole test condition evaluates to true or to false. It does this by treating each test separately and calling the relevant test command routines using the jump table in the '' |
//Situation 3.// | //Situation 3.// | ||
- | If in the normal execution of AGI commands, the code 0xFE is encountered, | + | If in the normal execution of AGI commands, the code 0xFE is encountered, |
If you're confused by this, the following example will probably explain things. | If you're confused by this, the following example will probably explain things. | ||
Ligne 619: | Ligne 656: | ||
</ | </ | ||
- | This is exactly how all '' | + | This is exactly how all **if**s and **else**s are implemented in the logic code. The **if** statement is a conditional branch where the branch is taken if the condition is not met, while the **else** statement is a nonconditional jump. If a 0xFE code appears in the middle of some AGI code and wasn't actually originally coded as an **else**, then it was most likely a **goto** statement. |
+ | |||
+ | ==== The **said** test command ==== | ||
- | ===The < | ||
The above assembly language code does raise a very important point. | The above assembly language code does raise a very important point. | ||
- | The ''' | + | The **said** command can have a variable number of arguments. Its code is 0x0E, and the byte following this byte gives the number of two byte words that follow as parameters. |
- | code is 0x0E, and the byte following this byte gives the number of | + | |
- | two byte words that follow as parameters. | + | |
Examples: | Examples: | ||
- | < | + | <code C> |
if (said(marble)) | if (said(marble)) | ||
if (said( open, door)) | if (said( open, door)) | ||
</ | </ | ||
- | In the above examples, the values 0x011E, 0x0237, and 0x0073 are just | + | In the above examples, the values 0x011E, 0x0237, and 0x0073 are just random word numbers that could stand for the words given. |
- | random word numbers that could stand for the words given. | + | |
- | ===Inner loops=== | + | ==== Inner loops ==== |
- | At first I almost totally discarded the existence of loops in the AGI | + | At first I almost totally discarded the existence of loops in the AGI code because it seemed to me that execution of the logic script continually looped. Loop code like " |
- | code because it seemed to me that execution of the logic script | + | |
- | continually looped. Loop code like " | + | |
- | statements wouldn' | + | |
- | increment with each pass and an ''' | + | |
- | value of the variable and take action if it was withing the desired range. | + | |
Example: | Example: | ||
- | < | + | <code C> |
if (greatern(30, | if (greatern(30, | ||
print(" | print(" | ||
Ligne 654: | Ligne 684: | ||
</ | </ | ||
- | I have found evidence of this sort of thing taking place which means | + | I have found evidence of this sort of thing taking place which means that they must loop over continuously. I don't know whether this is something that the interpreter does itself or whether it is part of |
- | that they must loop over continuously. I don't know whether this is | + | the AGI code, e.g. at the end of one logic script it calls another which then calls the first one again. With the existence of the conditional branching and unconditional branching nature of the **if** and |
- | something that the interpreter does itself or whether it is part of | + | **else** statement, it is easy to see that some of the structures such as " |
- | the AGI code, e.g. at the end of one logic script it calls another which | + | |
- | then calls the first one again. With the existence of the conditional | + | |
- | branching and unconditional branching nature of the ''' | + | |
- | ''' | + | |
- | structures such as " | + | |
Example: | Example: | ||
- | < | + | <code C> |
FF FD 0D FF 03 00 FE F7 FF | FF FD 0D FF 03 00 FE F7 FF | ||
Ligne 672: | Ligne 697: | ||
</ | </ | ||
- | The above translation is a simple one which is taken from SQ2. The | + | The above translation is a simple one which is taken from SQ2. The value 0xFFF7 is the twos complement notation for -9 which is the exact branching value to take the execution back to the start of the **if** |
- | value 0xFFF7 is the twos complement notation for -9 which is the exact | + | statement. If the above example had AGI code between the 0x00 and the 0xFE, then there would be code within the brackets of the " |
- | branching value to take the execution back to the start of the ''' | + | statements or used **goto** statements to achieve the same result. |
- | statement. If the above example had AGI code between the 0x00 and the | + | |
- | 0xFE, then there would be code within the brackets of the " | + | |
- | structure. I don't know whether the original AGI coders used these | + | |
- | statements or used ''' | + | |