Difference between revisions of "AGI/Specifications/Logic"

Jump to navigation Jump to search
m
Text replacement - "</source>" to "</syntaxhighlight>"
(Wikify and fill in differences from SGML. Work in Progress)
m (Text replacement - "</source>" to "</syntaxhighlight>")
 
(7 intermediate revisions by 3 users not shown)
Line 18: Line 18:
think they are using a flag).
think they are using a flag).


<syntax type="C++">
<syntaxhighlight lang="cpp">
     assign.v(v50,0);
     assign.v(v50,0);
     program.control();
     program.control();
</syntax>
</syntaxhighlight>


Multiple commands may be placed on the one line:
Multiple commands may be placed on the one line:


<syntax type="C++">
<syntaxhighlight lang="cpp">
   reset(f6); reset(f7);
   reset(f6); reset(f7);
</syntax>
</syntaxhighlight>


Substitutions for the following action commands are available:
Substitutions for the following action commands are available:


<syntax type="C++">
<syntaxhighlight lang="cpp">
     increment(v30);      v30++;
     increment(v30);      v30++;
     decrement(v30);      v30--;
     decrement(v30);      v30--;
Line 47: Line 47:
     lindirectv(v30,v32);  *v30 = v32;
     lindirectv(v30,v32);  *v30 = v32;
     rindirect(v30,v32);  v30 = *v32;
     rindirect(v30,v32);  v30 = *v32;
</syntax>
</syntaxhighlight>


===Conditionals and tests===
===Conditionals and tests===
Line 53: Line 53:
An '''if''' structure looks like this:
An '''if''' structure looks like this:


<syntax type="C++">
<syntaxhighlight lang="cpp">
     if (<test commands>) {
     if (<test commands>) {
         <action commands>
         <action commands>
     }
     }
</syntax>
</syntaxhighlight>


or like this :
or like this :


<syntax type="C++">
<syntaxhighlight lang="cpp">
     if (<test commands>) {
     if (<test commands>) {
         <action commands>
         <action commands>
Line 68: Line 68:
       <more action commands>
       <more action commands>
     }
     }
</syntax>
</syntaxhighlight>


Multiple commands can be placed in a single line:
Multiple commands can be placed in a single line:


<syntax type="C++">
<syntaxhighlight lang="cpp">
     if (<test commands>) { <action Commands> } else { <more action commands> }
     if (<test commands>) { <action Commands> } else { <more action commands> }
</syntax>
</syntaxhighlight>


Test commands are coded like action commands except there is no semicolon. They are separated by && or || for AND or OR.
Test commands are coded like action commands except there is no semicolon. They are separated by && or || for AND or OR.


<syntax type="C++">
<syntaxhighlight lang="cpp">
     if (isset(f5) &&
     if (isset(f5) &&
         greatern(v5,6)) { ......
         greatern(v5,6)) { ......
</syntax>
</syntaxhighlight>


  Multiple tests can be placed in a single line within the if statement:
  Multiple tests can be placed in a single line within the if statement:


<syntax type="C++">
<syntaxhighlight lang="cpp">
     if (lessn(v5,6) && (greatern(v5,2)) { .......
     if (lessn(v5,6) && (greatern(v5,2)) { .......


     if (isset(f90) && equalv(v32,v34)
     if (isset(f90) && equalv(v32,v34)
         && greatern(v34,20)) { .......
         && greatern(v34,20)) { .......
</syntax>
</syntaxhighlight>


A '''!''' placed in front of a command negates its result:
A '''!''' placed in front of a command negates its result:


<syntax type="C++">
<syntaxhighlight lang="cpp">
     if (!isset(f7)) {
     if (!isset(f7)) {
       ......
       ......
</syntax>
</syntaxhighlight>


Boolean expressions are not necessarily simplified so they must follow the rules set down by the file format. If test commands are to be ORred together, they must be placed in brackets.
Boolean expressions are not necessarily simplified so they must follow the rules set down by the file format. If test commands are to be ORred together, they must be placed in brackets.


<syntax type="C++">
<syntaxhighlight lang="cpp">
     if ((isset(f1) || isset(f2)) {
     if ((isset(f1) || isset(f2)) {
       ......
       ......
Line 109: Line 109:


     if (isset(1) || (isset(2) && isset(3))) {    // is NOT legal
     if (isset(1) || (isset(2) && isset(3))) {    // is NOT legal
</syntax>
</syntaxhighlight>


Depending on the compiler, simplification of boolean expressions may be supported, so the above may not apply in all cases (although if these are rules are followed then the logic will work with all compilers).
Depending on the compiler, simplification of boolean expressions may be supported, so the above may not apply in all cases (although if these are rules are followed then the logic will work with all compilers).
Line 115: Line 115:
The following test commands and operations are equivalent:
The following test commands and operations are equivalent:


<syntax type="C++">
<syntaxhighlight lang="cpp">
     equaln(v30,4)        v30 == 4
     equaln(v30,4)        v30 == 4
     equalv(v30,v32)      v30 == v32
     equalv(v30,v32)      v30 == v32
Line 128: Line 128:
     !lessn(v30,4)        v30 >= 4
     !lessn(v30,4)        v30 >= 4
     !lessv(v30,v32)      v30 >= v32
     !lessv(v30,v32)      v30 >= v32
</syntax>
</syntaxhighlight>


Also, flags can be tested for by just using the name of the flag:
Also, flags can be tested for by just using the name of the flag:


<syntax type="C++">
<syntaxhighlight lang="cpp">
     if (f6) { .....
     if (f6) { .....


     if (v7 > 0 && !f6) { .....
     if (v7 > 0 && !f6) { .....
</syntax>
</syntaxhighlight>


===Argument types===
===Argument types===
Line 160: Line 160:
Compilers can enforce type checking, so that the programmer must use the correct prefix for an argument so that they know they are using the right type. Decoders should display arguments with the right type.
Compilers can enforce type checking, so that the programmer must use the correct prefix for an argument so that they know they are using the right type. Decoders should display arguments with the right type.


<syntax type="C++">
<syntaxhighlight lang="cpp">
     move.obj(so4,80,120,2,f66);
     move.obj(so4,80,120,2,f66);
     if (obj.in.box(so2,30,60,120,40)) { .....
     if (obj.in.box(so2,30,60,120,40)) { .....
</syntax>
</syntaxhighlight>


A complete list of the commands and their argument types is available in [[AGI/Specifications/Resources#Command_list_and_argument_typesas | Command list and argument types table]].
A complete list of the commands and their argument types is available in [[AGI/Specifications/Resources#Command_list_and_argument_typesas | Command list and argument types table]].
Line 169: Line 169:
Messages and inventory items may be given in either numerical text format:
Messages and inventory items may be given in either numerical text format:


<syntax type="C++">
<syntaxhighlight lang="cpp">
     print("He's not here.");
     print("He's not here.");
     print(m12);
     print(m12);
     if (has("Jetpack")) { .....
     if (has("Jetpack")) { .....
     if (has(io9)) { .....
     if (has(io9)) { .....
</syntax>
</syntaxhighlight>


Messages can also be split over multiple lines:
Messages can also be split over multiple lines:


<syntax type="C++">
<syntaxhighlight lang="cpp">
     print("This message is split "
     print("This message is split "
           "over multiple lines.");
           "over multiple lines.");
</syntax>
</syntaxhighlight>


Quote marks must be used around messages and object names. This is important because some messages or object names may contain brackets or commas, which could confuse the compiler. This is also the case for the '''said''' command which will be described shortly.
Quote marks must be used around messages and object names. This is important because some messages or object names may contain brackets or commas, which could confuse the compiler. This is also the case for the '''said''' command which will be described shortly.


<syntax type="C++">
<syntaxhighlight lang="cpp">
     if (has("Buckazoid(s)")) { .....        // no ambiguity here about where
     if (has("Buckazoid(s)")) { .....        // no ambiguity here about where
                                             // the argument ends
                                             // the argument ends
</syntax>
</syntaxhighlight>


The '''said''' test command uses different parameters to all the other commands. Where as the others use 8 bit arguments (0--255), '''said''' takes 16 bit arguments (0--65535). Also, the number of arguments in a '''said''' command can vary. The numbers given in the arguments are the word group numbers from the '''words.tok''' file.
The '''said''' test command uses different parameters to all the other commands. Where as the others use 8 bit arguments (0--255), '''said''' takes 16 bit arguments (0--65535). Also, the number of arguments in a '''said''' command can vary. The numbers given in the arguments are the word group numbers from the '''words.tok''' file.


<syntax type="C++">
<syntaxhighlight lang="cpp">
     if (said(4,80)) { .....
     if (said(4,80)) { .....
</syntax>
</syntaxhighlight>


Words can also be given in place of the numbers:
Words can also be given in place of the numbers:


<syntax type="C++">
<syntaxhighlight lang="cpp">
     if (said("look")) { .....
     if (said("look")) { .....
     if (said("open","door")) { .....
     if (said("open","door")) { .....
</syntax>
</syntaxhighlight>


Quote marks must also be used around the words.
Quote marks must also be used around the words.
Line 209: Line 209:
Labels are given like this:
Labels are given like this:


<syntax type="C++">
<syntaxhighlight lang="cpp">
     Label1:
     Label1:
</syntax>
</syntaxhighlight>


The label name can contain letters, numbers, and the characters "_" and ".". No spaces are allowed. The '''goto''' command takes one parameter, the name of a label.
The label name can contain letters, numbers, and the characters "_" and ".". No spaces are allowed. The '''goto''' command takes one parameter, the name of a label.


<syntax type="C++">
<syntaxhighlight lang="cpp">
     goto(Label1);
     goto(Label1);
</syntax>
</syntaxhighlight>


===Comments===
===Comments===
Line 223: Line 223:
There are three ways that comments can be used.
There are three ways that comments can be used.


<syntax type="C++">
<syntaxhighlight lang="cpp">
     // Rest of line is ignored
     // Rest of line is ignored
     [  Rest of line is ignored
     [  Rest of line is ignored
     /* Text between these are ignored */
     /* Text between these are ignored */
</syntax>
</syntaxhighlight>


The /*...*/ can be nested:
The /*...*/ can be nested:


<syntax type="C++">
<syntaxhighlight lang="cpp">
     /* comment start
     /* comment start
       print("Hello");    // won't be run
       print("Hello");    // won't be run
Line 239: Line 239:
       print("Hey!");    // won't be run, still inside comments
       print("Hey!");    // won't be run, still inside comments
     */                  // uncomments
     */                  // uncomments
</syntax>
</syntaxhighlight>


===Defines===
===Defines===
Line 245: Line 245:
To give vars, flags etc. proper names the #define command is used. The name of the define is given followed by the define value:
To give vars, flags etc. proper names the #define command is used. The name of the define is given followed by the define value:


<syntax type="C++">
<syntaxhighlight lang="cpp">
     #define ego o0
     #define ego o0
     #define room_descr "This is a large hall with tall pillars down each side."
     #define room_descr "This is a large hall with tall pillars down each side."
</syntax>
</syntaxhighlight>


Then the define name can be used in place of the define value:
Then the define name can be used in place of the define value:


<syntax type="C++">
<syntaxhighlight lang="cpp">
     draw(ego);
     draw(ego);
     print(room_descr);
     print(room_descr);
</syntax>
</syntaxhighlight>


Define names can only be used in arguments of commands (including gotos and the v0 == 3 type syntax), although some compilers may allow you to use them anywhere.
Define names can only be used in arguments of commands (including gotos and the v0 == 3 type syntax), although some compilers may allow you to use them anywhere.
Line 267: Line 267:
You can include another file in your logic source code by using the #include command:
You can include another file in your logic source code by using the #include command:


<syntax type="C++">
<syntaxhighlight lang="cpp">
     #include "file.txt"
     #include "file.txt"
</syntax>
</syntaxhighlight>


When the compiler encounters the above line, it will replace it with the contents of file.txt.
When the compiler encounters the above line, it will replace it with the contents of file.txt.
Line 278: Line 278:
In some cases you may want to assign a specific number to a message so you can refer to it in other places. This is done by using the #message command, followed by the number of the message then the message itself:
In some cases you may want to assign a specific number to a message so you can refer to it in other places. This is done by using the #message command, followed by the number of the message then the message itself:


<syntax type="C++">
<syntaxhighlight lang="cpp">
     #message 4 "You can't do that now."
     #message 4 "You can't do that now."
</syntax>
</syntaxhighlight>


Then you can give the message number as the parameter in commands:
Then you can give the message number as the parameter in commands:


<syntax type="C++">
<syntaxhighlight lang="cpp">
     print(m4);
     print(m4);
</syntax>
</syntaxhighlight>


Or embed the message in commands as normal and the number you assigned to it before will be used:
Or embed the message in commands as normal and the number you assigned to it before will be used:


<syntax type="C++">
<syntaxhighlight lang="cpp">
     print("You can't do that now.");
     print("You can't do that now.");
</syntax>
</syntaxhighlight>


#message can be used anywhere in the file, so you do not have to set the message before you use it.
#message can be used anywhere in the file, so you do not have to set the message before you use it.
Line 305: Line 305:
From the AGDS documentation translated by Vassili Bykov, with additions/modifications by Claudio Matsuoka and XoXus (Last update 22 May 1999).
From the AGDS documentation translated by Vassili Bykov, with additions/modifications by Claudio Matsuoka and XoXus (Last update 22 May 1999).


<!-- XXXX -->
===Arithmetic commands===
===Arithmetic commands===


Line 330: Line 329:
:The value of variable vn is incremented by m (vm), i.e. vn = vn + m (vm).
:The value of variable vn is incremented by m (vm), i.e. vn = vn + m (vm).


:If the value is greater than 255 the result wraps over 0 (so 250 + 10 == 4). (Information by XoXus)
:If the value is greater than 255 the result wraps over 0 (so 250 + 10 == 4). ''(Information by XoXus)''


subn(n,m), subv(n,m)
subn(n,m), subv(n,m)
Line 336: Line 335:
:The value of vn is decremented by m (vm), i.e. vn = vn - m (vm).
:The value of vn is decremented by m (vm), i.e. vn = vn - m (vm).


:If the value is lesser than 0 the result wraps (so 1 - 2 == 255). (Information by XoXus)
:If the value is lesser than 0 the result wraps (so 1 - 2 == 255). ''(Information by XoXus)''


lindirectn(n,m)
lindirectn(n,m)


:Variable vi where i is the value of vn is assigned a value m, i.e. Var(vn) = m.
:Variable vi where ''i'' is the value of vn is assigned a value m, i.e. Var(vn) = m.


lindirectv(n,m)
lindirectv(n,m)


:Variable vi where i is the value of vn is assigned the value of vm, i.e. Var(vn) = vm.
:Variable vi where ''i'' is the value of vn is assigned the value of vm, i.e. Var(vn) = vm.


rindirect(n,m)
rindirect(n,m)


:Variable vn is assigned the value of vi where i is the value of vm, i.e. vn = Var(vm).
:Variable vn is assigned the value of vi where ''i'' is the value of vm, i.e. vn = Var(vm).


muln(n,m)
muln(n,m)
Line 373: Line 372:


:Variable vk is assigned a random value in the range between n and m. Now let us consider the commands changing flag values. Remember that a flag can only have a value 0 or 1.
:Variable vk is assigned a random value in the range between n and m. Now let us consider the commands changing flag values. Remember that a flag can only have a value 0 or 1.
===Flag commands===


set(n)
set(n)
Line 404: Line 405:
When the internal memory is full, the program has to be broken into parts which are loaded and unloaded as the story unfolds in the given room, or PICTURE, VIEW, and SOUND resources have to be manipulated using the commands below.
When the internal memory is full, the program has to be broken into parts which are loaded and unloaded as the story unfolds in the given room, or PICTURE, VIEW, and SOUND resources have to be manipulated using the commands below.


Remember that when a resource is unloaded, all resources loaded after it are also automatically unloaded!
Remember that when a resource is unloaded, all resources loaded after it are also automatically unloaded (in the Sierra interpreter).


load.logic(n)
load.logic(n)
Line 458: Line 459:
new.room command is one of the most powerful commands of the interpreter.
new.room command is one of the most powerful commands of the interpreter.


It is used to change algorithms of the object behaviour, props, etc. Automatic change of Ego coordinates imitates moving into a room adjacent to the edge of the initial one. (Sounds awkward but that's what it says. --VB)
It is used to change algorithms of the object behavior, props, etc. Automatic change of Ego coordinates imitates moving into a room adjacent to the edge of the initial one. ''(Sounds awkward but that's what it says. --VB)''


The format of the command:
The format of the command:
Line 489: Line 490:
return
return


:This command returns control to the interpreter if it is executed in Logic(0), or to the command following the call command which called the current logic.
:This command returns control to the interpreter if it is executed in Logic(0), or to the command following the '''call''' command which called the current logic.
jump <label>


:This command unconditionally transfers control to a command starting after label label within the same logic.
jump &lt;label&gt;
 
:This command unconditionally transfers control to a command starting after label '''label''' within the same logic.


set.scan.start(), reset.scan.start()
set.scan.start(), reset.scan.start()


:Normally, when a logic is called using call command, execution begins at the first instruction. set.scan.start command sets the entry point at the command following it, while reset.scan.start returns the entry point to the beginning.
:Normally, when a logic is called using call command, execution begins at the first instruction. '''set.scan.start''' command sets the entry point at the command following it, while '''reset.scan.start''' returns the entry point to the beginning.


===Object control commands===
===Object control commands===
Line 503: Line 505:


* If an object priority is 0 it cannot cross an unconditional barrier (pixels with priority 0).
* If an object priority is 0 it cannot cross an unconditional barrier (pixels with priority 0).
* If an object priority is 15 and a command ignore.block has not been given to it, it cannot cross a conditional barrier (pixels with priority 1) and leave the block set using the block command.
* If an object priority is 15 and a command '''ignore.block''' has not been given to it, it cannot cross a conditional barrier (pixels with priority 1) and leave the block set using the block command.
* If an object has not been given ignore.horizon command, it cannot move above the horizon set using the set.horizon command.
* If an object has not been given '''ignore.horizon''' command, it cannot move above the horizon set using the '''set.horizon''' command.
* An object should follow the conditions set using object.on.water and object.on.land commands (see below).
* An object should follow the conditions set using '''object.on.water''' and '''object.on.land''' commands (see below).


Object number 0 is called Ego. It is different from others in that the player may move it around using the keyboard.
Object number 0 is called Ego. It is different from others in that the player may move it around using the keyboard.
Object description commands


animate.obj(n)
animate.obj(n)
Line 556: Line 557:
                 Loop    x  3  0  0  0  2  1  1  1
                 Loop    x  3  0  0  0  2  1  1  1


:x means that the current loop number is retained.</pre>
:x means that the current loop number is retained.


set.cel(n,m), set.cel.v(n,m)
set.cel(n,m), set.cel.v(n,m)
Line 584: Line 585:
release.priority(n)
release.priority(n)


:Turns on the automatic priority choice for the object n. The priority is set depending on the vertical coordinate of the object. This way, as an object moves down it approaches the viewer. See section Priority bands and control lines for a table of y coordinates and the associated priorities.
:Turns on the automatic priority choice for the object n. The priority is set depending on the vertical coordinate of the object. This way, as an object moves down it approaches the viewer. See [[AGI/Specifications/Overview#Priority section | Priority bands and control lines]] for a table of y coordinates and the associated priorities.


get.priority(n,m)
get.priority(n,m)
Line 596: Line 597:
draw(n)
draw(n)


:Object n is shown on the screen. The image uses the values of the loop and the cel in the VIEW resource associated with the object n (see set.view), as well as the priority and coordinates of the object. If a command start.cycling is also issued, a looped animation for object n is shown until stopped (for example, with stop.cycling).
:Object n is shown on the screen. The image uses the values of the loop and the cel in the VIEW resource associated with the object n (see '''set.view'''), as well as the priority and coordinates of the object. If a command '''start.cycling''' is also issued, a looped animation for object n is shown until stopped (for example, with '''stop.cycling''').


erase(n)
erase(n)
Line 638: Line 639:
===Object motion control commands===
===Object motion control commands===


The following commands can be given to the object included in the interpreter control list with animate.obj:
The following commands can be given to the object included in the interpreter control list with '''animate.obj''':


set.horizon(n)
set.horizon(n)


:Set the horizon to y = n.
:Set the horizon y coordinate to n.


ignore.horizon(n)
ignore.horizon(n)
Line 694: Line 695:
stop.motion(n)
stop.motion(n)


:Motion of object n is stopped. If n == 0, program.control is automatically executed.
:Motion of object n is stopped. If n == 0, '''program.control''' is automatically executed.


start.motion(n)
start.motion(n)
Line 710: Line 711:
move.obj(n,x,y,s,m), move.obj.v(n,x,y,s,m)
move.obj(n,x,y,s,m), move.obj.v(n,x,y,s,m)


:Object n is told to move to the point (x,y) (or vx, vy) by s pixels every step. When the destination is reached, fm is set to 1. If n == 0 (Ego), program.control is executed automatically.
:Object n is told to move to the point (x,y) (or vx, vy) by s pixels every step. When the destination is reached, fm is set to 1. If n == 0 (Ego), '''program.control''' is executed automatically.


follow.ego(n,s,m)
follow.ego(n,s,m)
Line 752: Line 753:
object.on.anything(n)
object.on.anything(n)


:Motion restrictions previously set on the object n with commands object.on.water or object.on.land are cancelled.
:Motion restrictions previously set on the object n with commands '''object.on.water''' or '''object.on.land''' are cancelled.


reposition(n,dx,dy)
reposition(n,dx,dy)
Line 780: Line 781:
distance(n,m,d)
distance(n,m,d)


:If both objects n and m are on the screen, then
:If both objects n and m are on the screen, then  


<syntax type="C++">
<syntaxhighlight lang="cpp">vd = abs(x(n) - x(m)) + abs(y(n) - y(m))</syntaxhighlight>
    vd = abs(x(n) - x(m)) + abs(y(n) - y(m)),
</syntax>


:otherwise vd = 255.
, otherwise vd = 255.


===Inventory item management commands===
===Inventory item management commands===


OBJECT resources, stored in a separate file object, are most often used to represent inventory items. An item is a structure which consists of a one-byte field called room and a string of text, the item name.
OBJECT resources, stored in a separate file object, are most often used to represent inventory items. An item is a structure which consists of a one-byte field called room and a string of text (the member name).


If the room field of an item is 255, the item belongs to the player. Otherwise the item is considered to be in the room with the corresponding ID number.
If the room field of an item is 255, the item belongs to the player. Otherwise the item is considered to be in the room with the corresponding ID number.
Line 818: Line 817:
===Picture resource management commands===
===Picture resource management commands===


The following commands operate on PICTURE resources, loaded in the interpreter memory using load.pic:
The following commands operate on PICTURE resources, prepared using PM editor and loaded in the interpreter memory using '''load.pic''':


draw.pic(n)
draw.pic(n)


:A PICTURE resource number i, where i is the value of vn is executed. As the result, the background picture is created in the internal buffer of the interpreter. Before execution, the buffer is cleared, i.e. all pixels are set to colour 15 and priority 4.
:A PICTURE resource number i, where i is the value of vn is executed. As the result, the background picture is created in the internal buffer of the interpreter. Before execution, the buffer is cleared, i.e. all pixels are set to color 15 and priority 4.


overlay.pic(n)
overlay.pic(n)
Line 850: Line 849:
:ATTENTION! Please use the following sequence of commands when loading PICTURE resources in the interpreter memory:
:ATTENTION! Please use the following sequence of commands when loading PICTURE resources in the interpreter memory:


<syntax type="C++">
<syntaxhighlight lang="cpp">
     load.pic(n);
     load.pic(n);
     draw.pic(n);
     draw.pic(n);
Line 856: Line 855:
     ...
     ...
     show.pic();
     show.pic();
</syntax>
</syntaxhighlight>


:Any other order may crash the interpreter without any diagnostic messages.
:Any other order may crash the interpreter without any diagnostic messages.
Line 882: Line 881:
print(n), print.v(n)
print(n), print.v(n)


:Opens a text window in the centre of the screen, where a message number n (or vn) from the messages field of the current LOGIC resource is displayed. Output mode is determined by f15 (see flag description). The message is a NULL-terminated string of text. In addition to letters, digits, and other symbols, the string may contain:
:Opens a text window in the centre of the screen, where a message number n (or vn) from the messages field of the current LOGIC resource is displayed. Output mode is determined by f15 (see [[AGI/Specifications/Internals#Flag | Flag description]]). The message is a NULL-terminated string of text. In addition to letters, digits, and other symbols, the string may contain:


:* Newline character (0x0A);
:* Newline character (0x0A);
Line 925: Line 924:
set.text.attribute(fg,bg)
set.text.attribute(fg,bg)


:Sets foreground and background colours for display, get.num and get.string commands.
:Sets foreground and background colors for display, '''get.num''' and '''get.string''' commands.


clear.lines(n,m,c)
clear.lines(n,m,c)


:Clears text lines from n to m using colour c.
:Clears text lines from n to m using color c.


clear.text.rect(x1,y1,x2,y2,c)
clear.text.rect(x1,y1,x2,y2,c)


:Clears a rectangular area with top left corner coordinates (x1,y1) and bottom right coordinates (x2,y2) using colour c.
:Clears a rectangular area with top left corner coordinates (x1,y1) and bottom right coordinates (x2,y2) using color c.


status.line.on()
status.line.on()
Line 975: Line 974:
set.game.id(n)
set.game.id(n)


:Message n is scanned by the interpreter and compared with its internal identifier. On mismatch, the program exits. For the AGDS interpreter the identifier is "TQ". See also section Game IDs.
:Message n is scanned by the interpreter and compared with its internal identifier. On mismatch, the program exits. For the AGDS interpreter the identifier is "TQ". See also [[AGI/Specifications/Internals#Game_IDs_and_loaders | section Game IDs and loaders]].


script.size(n)
script.size(n)
Line 1,039: Line 1,038:
:If f14 is set, a menu system is shown on the screen, allowing the user to choose an item. Whether an item with the code c has been chosen can be tested using a command controller(c), where c is the code assigned to the menu item.
:If f14 is set, a menu system is shown on the screen, allowing the user to choose an item. Whether an item with the code c has been chosen can be tested using a command controller(c), where c is the code assigned to the menu item.


===Logical commands===
===Logical test commands===
====Test commands====


The result of test command can be either TRUE or FALSE.
The result of test command can be either TRUE or FALSE.
Line 1,141: Line 1,139:
:Prints a message for the object vn in the format
:Prints a message for the object vn in the format


         Obj <n> x: <pos> y: <pos> pri: <priority> stepsize: <step size>.
         Obj &lt;n&gt; x: &lt;pos&gt; y: <pos> pri: <priority> stepsize: &lt;step size&gt;.


show.mem()
show.mem()
Line 1,202: Line 1,200:


:Switch RGB monitor into the graphics mode.
:Switch RGB monitor into the graphics mode.
upper.left()
upper.left()


Line 1,220: Line 1,219:
:Example:
:Example:


<syntax type="C++>
<syntaxhighlight lang="cpp">
     set.string(s1,"test");
     set.string(s1,"test");
     unknown170(1);
     unknown170(1);
</syntax>
</syntaxhighlight>


:will automatically load the savegame named "test".
:will automatically load the savegame named "test".
Line 1,239: Line 1,238:
unknown181(n)
unknown181(n)


:This command restablishes the default control of Ego. It is normally used after a call to unknown173().
:This command reestablishes the default control of Ego. It is normally used after a call to unknown173().


:Note: Be aware that commands 175, 176, 178, 179 and 180 of the last version of AGI (ver 3.002.149) do absolutely nothing.
:Note: Be aware that commands 175, 176, 178, 179 and 180 of the last version of AGI (ver 3.002.149) do absolutely nothing.
Line 1,249: Line 1,248:
(Last updated: 31 August 1997).
(Last updated: 31 August 1997).


Some of you may know that ''The Official Book of King's Quest'' included three small fragments of AGI code for room 7 in the AGI version of KQ4. These fragments are given below along with the same fragments taken from the game itself. There are a few differences which is to be expected but generally the code is very similar. These examples show how the coder wrote the code and what it now looks like in the final product. I've included a few comments where some interesting observations can be seen.
Some of you may know that "The Official Book of King's Quest" included three small fragments of AGI code for room 7 in the AGI version of KQ4. These fragments are given below along with the same fragments taken from the game itself. There are a few differences which is to be expected but generally the code is very similar. These examples show how the coder wrote the code and what it now looks like in the final product. I've included a few comments where some interesting observations can be seen.
Animating the smoke
Animating the smoke


From the book:
From the book:


<syntax type="C++">
<syntaxhighlight lang="cpp">
animate.obj(smoke);
animate.obj(smoke);
ignore.horizon(smoke);
ignore.horizon(smoke);
Line 1,265: Line 1,264:
cycle.time(smoke, work);
cycle.time(smoke, work);
draw(smoke);
draw(smoke);
</syntax>
</syntaxhighlight>


From the game:
From the game:


<syntax type="C++">
<syntaxhighlight lang="cpp">
animate.obj(7);
animate.obj(7);
ignore.horizon(7);
ignore.horizon(7);
Line 1,282: Line 1,281:
cycle.time(7, 152);
cycle.time(7, 152);
draw(7);
draw(7);
</syntax>
</syntaxhighlight>


Opening the door
Opening the door
Line 1,288: Line 1,287:
From the book:
From the book:


<syntax type="C++">
<syntaxhighlight lang="cpp">
if (said( open, door)) {    // must be close enough
if (said( open, door)) {    // must be close enough
   if (posn( ego, 86, 120, 106, 133)) {
   if (posn( ego, 86, 120, 106, 133)) {
Line 1,310: Line 1,309:
   }
   }
}
}
</syntax>
</syntaxhighlight>


From the game:
From the game:


<syntax type="C++">
<syntaxhighlight lang="cpp">
if (said(OPEN, DOOR||DOORS||DOORWAY||DOORWAYS)) {
if (said(OPEN, DOOR||DOORS||DOORWAY||DOORWAYS)) {
   if (posn(0, 86, 120, 106, 133)) {
   if (posn(0, 86, 120, 106, 133)) {
Line 1,340: Line 1,339:
   }
   }
}
}
</syntax>
</syntaxhighlight>


===Unlocking the door===
===Unlocking the door===
Line 1,346: Line 1,345:
From the book:
From the book:


<syntax type="C++">
<syntaxhighlight lang="cpp">
if (said( unlock, door)) {    // must be close enough
if (said( unlock, door)) {    // must be close enough
   if (posn( ego, 86, 120, 106, 133)) {
   if (posn( ego, 86, 120, 106, 133)) {
Line 1,360: Line 1,359:
   }
   }
}
}
</syntax>
</syntaxhighlight>


From the game:
From the game:


<syntax type="C++">
<syntaxhighlight lang="cpp">
if (said(UNLATCH||UNLOCK, DOOR||DOORS||DOORWAY||DOORWAYS)) {
if (said(UNLATCH||UNLOCK, DOOR||DOORS||DOORWAY||DOORWAYS)) {
   if (posn(0, 86, 120, 106, 133)) {
   if (posn(0, 86, 120, 106, 133)) {
Line 1,379: Line 1,378:
   }
   }
}
}
</syntax>
</syntaxhighlight>


===Knocking on the door===
===Knocking on the door===
Line 1,385: Line 1,384:
From the book:
From the book:


<syntax type="C++">
<syntaxhighlight lang="cpp">
if ((said( knock, at, door) || said( knock) ||
if ((said( knock, at, door) || said( knock) ||
     said( knock, on, door) || said( knock, door)) {
     said( knock, on, door) || said( knock, door)) {
Line 1,402: Line 1,401:
   }
   }
}
}
</syntax>
</syntaxhighlight>


From the game:
From the game:


<syntax type="C++">
<syntaxhighlight lang="cpp">
if (said(BANG||KNOCK||RAP||TAP) ||
if (said(BANG||KNOCK||RAP||TAP) ||
     said(BANG||KNOCK||RAP||TAP, DOOR||DOORS||DOORWAY||DOORWAYS)) {
     said(BANG||KNOCK||RAP||TAP, DOOR||DOORS||DOORWAY||DOORWAYS)) {
Line 1,424: Line 1,423:
   }
   }
}
}
</syntax>
</syntaxhighlight>


===Fall rocks===
===Fall rocks===
Line 1,434: Line 1,433:
From the book:
From the book:


<syntax type="C++">
<syntaxhighlight lang="cpp">
if (hit.special) {
if (hit.special) {
   if ((rf2 || rf3 || rf4)) {
   if ((rf2 || rf3 || rf4)) {
Line 1,481: Line 1,480:
   }
   }
}
}
</syntax>
</syntaxhighlight>


From the game:
From the game:


<syntax type="C++">
<syntaxhighlight lang="cpp">
if (isset(3)) {    [ hit.special
if (isset(3)) {    [ hit.special
   if (isset(222) || isset(223) || isset(224)) {    // rf2, rf3, rf4
   if (isset(222) || isset(223) || isset(224)) {    // rf2, rf3, rf4
Line 1,535: Line 1,534:
   }
   }
}
}
</syntax>
</syntaxhighlight>
TrustedUser
2,147

edits

Navigation menu