Outils pour utilisateurs

Outils du site


agi-game:specifications-resources

Différences

Ci-dessous, les différences entre deux révisions de la page.

Lien vers cette vue comparative

Les deux révisions précédentesRévision précédente
Prochaine révision
Révision précédente
Dernière révisionLes deux révisions suivantes
agi-game:specifications-resources [2021/05/24 15:17] – [How the interpreter handles the code] frateragi-game:specifications-resources [2021/05/24 15:30] – [AGI Specifications Resources : Logic resources] frater
Ligne 1: Ligne 1:
-====== Logic resources ======+====== AGI Specifications Resources : Logic resources ======
  
-===== Introduction =====+==== Introduction ====
  
 At the heart of Sierra's Adventure Game Interpreter is the logic file. At the heart of Sierra's Adventure Game Interpreter is the logic file.
Ligne 331: Ligne 331:
 </code> </code>
  
-==== The //else// command and more on brackets ====+==== The **else** command and more on brackets ====
  
-The //else// statement will always continue after an //if// bracket block. This next feature is important and has caused a number of hassles in the past. When an //else// statement follows an //if//, then the bracket distance given after the //if// statement //will be three bytes longer// (this is a consequence of the way the interpreter handles //if// and //else// codes which is discussed later).+The **else** statement will always continue after an **if** bracket block. This next feature is important and has caused a number of hassles in the past. When an **else** statement follows an **if**, then the bracket distance given after the **if** statement //will be three bytes longer// (this is a consequence of the way the interpreter handles **if** and **else** codes which is discussed later).
  
 Here's an example: Here's an example:
Ligne 352: Ligne 352:
 </code> </code>
  
-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 //if// statement and an //if..else// structure. The situation is the same for nested //if..else// structures. 
  
-The //else// statements themselves are a lot like //if// statements except that they're test condition is given after the 0xFE code but is instead the inverse of the condition given by the above //if// statement. Only the bracket distance is given after the 0xFE code and then the AGI command clock that the //else// statement encompasses.+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 **if** statement and an **if..else** structure. The situation is the same for nested **if..else** structures. 
 + 
 +The **else** statements themselves are a lot like **if** statements except that they're test condition is given after the 0xFE code but is instead the inverse of the condition given by the above **if** statement. Only the bracket distance is given after the 0xFE code and then the AGI command clock that the **else** statement encompasses.
  
 ==== Test conditions ==== ==== Test conditions ====
Ligne 621: Ligne 622:
 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. 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 <tt>said</tt> test command===+==== The **said** test command ===
 The above assembly language code does raise a very important point. The above assembly language code does raise a very important point.
-The //said// command can have a variable number of arguments. Its +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 type="C++">+<code C>
 if (said(marble))                          FF 0E 01 1E 01 FF if (said(marble))                          FF 0E 01 1E 01 FF
 if (said( open, door))                     FF 0E 02 37 02 73 00 FF if (said( open, door))                     FF 0E 02 37 02 73 00 FF
 </code> </code>
  
-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 "while", "do..while", and "for" statements wouldn't be needed because you could just use a variable to increment with each pass and an **if** statement to test the value of the variable and take action if it was withing the desired range.
-code because it seemed to me that execution of the logic script +
-continually looped. Loop code like "while", "do..while", and "for" +
-statements wouldn't be needed because you could just use a variable to +
-increment with each pass and an //if// statement to test the +
-value of the variable and take action if it was withing the desired range.+
  
 Example: Example:
  
-<code type="C++">+<code C>
 if (greatern(30, 45) && lessn(30, 55)) { if (greatern(30, 45) && lessn(30, 55)) {
     print("You're in the hot zone!");     print("You're in the hot zone!");
Ligne 654: Ligne 648:
 </code> </code>
  
-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 "do..while" can infact be coded into logic scripts.
-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 +
-//else// statement, it is easy to see that some of the +
-structures such as "do..while" can infact be coded into logic scripts.+
  
 Example: Example:
  
-<code type="C++">+<code C>
 FF FD 0D FF 03 00 FE F7 FF FF FD 0D FF 03 00 FE F7 FF
  
Ligne 672: Ligne 661:
 </code> </code>
  
-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 "do..while" structure. I don't know whether the original AGI coders used these 
-branching value to take the execution back to the start of the //if// +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 "do..while" +
-structure. I don't know whether the original AGI coders used these +
-statements or used //goto// statements to achieve the same result.+
  
agi-game/specifications-resources.txt · Dernière modification : 2023/04/13 09:50 de frater