Difference between revisions of "AGI/Specifications/Resources"

From ScummVM :: Wiki
Jump to navigation Jump to search
(Initial semi-wikified content. Tables are yet to be converted)
 
(→‎How the interpreter handles the code: -- fix syntax highlighting)
 
(7 intermediate revisions by the same user not shown)
Line 45: Line 45:
<span id="CmdList"></span>
<span id="CmdList"></span>
==Command list and argument types==
==Command list and argument types==
<xref linkend="tab-test-commands"> and <xref linkend="tab-action-commands">
[[AGI/Specifications/Resources#test-commands | Table 6-1]] and [[AGI/Specifications/Resources#action-commands|  Table 6-2]]
show a list of all AGI commands and their argument types. The
show a list of all AGI commands and their argument types. The
command names have been taken from debug messages contained in
command names have been taken from debug messages contained in
some AGI games.
some AGI games.


<pre>
<table id="tab-test-commands">
  <title>Test commands</title>
  <tgroup cols="8">
    <thead>
      <row>
        <entry/Opcode/ <entry/Command/ <entry/Args/ &p1; &p2; &p3; &p4; &p5;
      </row>
    </thead>
    <tbody>
      <row/<entry/01/ <entry/'''equaln'''/    &p2; &v; &n;/
      <row/<entry/02/ <entry/'''equalv'''/    &p2; &v; &v;/
      <row/<entry/03/ <entry/'''lessn'''/      &p2; &v; &n;/
      <row/<entry/04/ <entry/'''lessv'''/      &p2; &v; &v;/
      <row/<entry/05/ <entry/'''greatern'''/  &p2; &v; &n;/
      <row/<entry/06/ <entry/'''greaterv'''/  &p2; &v; &v;/
      <row/<entry/07/ <entry/'''isset'''/      &p1; &f;/
      <row/<entry/08/ <entry/'''issetv'''/    &p1; &v;/
      <row/<entry/09/ <entry/'''has'''/        &p1; &i;/
      <row/<entry/0A/ <entry/'''obj.in.room'''/&p2; &i; &v;/
      <row/<entry/0B/ <entry/'''posn'''/      &p5; &o; &n; &n; &n; &n;/
      <row/<entry/0C/ <entry/'''controller'''/ &p1; &c;/
      <row/<entry/0D/ <entry/'''have.key'''/  &p0;/
      <row/<entry/0E/ <entry/'''said'''/      <entry/-/ <entry/.../
      <row/<entry/0F/ <entry/'''compare.strings'''/&p2; &s; &s;/
      <row/<entry/10/ <entry/'''obj.in.box'''/ &p5; &o; &n; &n; &n; &n;/
      <row/<entry/11/ <entry/'''center.posn'''/&p5; &o; &n; &n; &n; &n;/
      <row/<entry/12/ <entry/'''right.posn'''/ &p5; &o; &n; &n; &n; &n;/
    </tbody>
  </tgroup>
</table>


<table id="tab-action-commands">
<span id="test-commands"></span>
  <title>Action commands</title>
{| border="1"  cellspacing="0" cellpadding="5"
  <tgroup cols="10">
|+ '''Table 6-1: Test commands'''
    <thead>
|-
      <row/ <entry/Opcode/ <entry/Command/ <entry/Args/
! Opcode
      &p1; &p2; &p4; &p4; &p5; &p6; &p7; /
! Command
    </thead>
! Args
    <tbody>
! 1
      <row/<entry/00/ <entry/'''return'''/        &p0;/
! 2
      <row/<entry/01/ <entry/'''increment'''/      &p1; &v;/
! 3
      <row/<entry/02/ <entry/'''decrement'''/      &p1; &v;/
! 4
      <row/<entry/03/ <entry/'''assignn'''/        &p2; &v; &n;/
! 5
      <row/<entry/04/ <entry/'''assignv'''/        &p2; &v; &v;/
|-
      <row/<entry/05/ <entry/'''addn'''/          &p2; &v; &n;/
| 01
      <row/<entry/06/ <entry/'''addv'''/          &p2; &v; &v;/
| '''equaln'''
      <row/<entry/07/ <entry/'''subn'''/          &p2; &v; &n;/
| 2
      <row/<entry/08/ <entry/'''subv'''/          &p2; &v; &v;/
| var
      <row/<entry/09/ <entry/'''lindirectv'''/    &p2; &v; &v;/
| num
      <row/<entry/0A/ <entry/'''rindirect'''/      &p2; &v; &v;/
| &nbsp;
      <row/<entry/0B/ <entry/'''lindirectn'''/    &p2; &v; &n;/
| &nbsp;
      <row/<entry/0C/ <entry/'''set'''/            &p1; &f;/
| &nbsp;
      <row/<entry/0D/ <entry/'''reset'''/          &p1; &f;/
|-
      <row/<entry/0E/ <entry/'''toggle'''/        &p1; &f;/
| 02
      <row/<entry/0F/ <entry/'''set.v'''/          &p1; &v;/
| '''equalv'''
| 2
| var
| var
| &nbsp;
| &nbsp;
| &nbsp;
|-
| 03
| '''lessn'''
| 2
| var
| num
| &nbsp;
| &nbsp;
| &nbsp;
|-
| 04
| '''lessv'''
| 2
| var
| var
| &nbsp;
| &nbsp;
| &nbsp;
|-
| 05
| '''greatern'''
| 2
| var
| num
| &nbsp;
| &nbsp;
| &nbsp;
|-
| 06
| '''greaterv'''
| 2
| var
| var
| &nbsp;
| &nbsp;
| &nbsp;
|-
| 07
| '''isset'''
| 1
| flag
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
|-
| 08
| '''issetv'''
| 1
| var
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
|-
| 09
| '''has'''
| 1
| item
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
|-
| 0A
| '''obj.in.room'''
| 2
| item
| var
| &nbsp;
| &nbsp;
| &nbsp;
|-
| 0B
| '''posn'''
| 5
| obj
| num
| num
| num
| num
|-
| 0C
| '''controller'''
| 1
| ctr
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
|-
| 0D
| '''have.key'''
| 0
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
|-
| 0E
| '''said'''
| -
| ...
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
|-
| 0F
| '''compare.strings'''
| 2
| str
| str
| &nbsp;
| &nbsp;
| &nbsp;
|-
| 10
| '''obj.in.box'''
| 5
| obj
| num
| num
| num
| num
|-
| 11
| '''center.posn'''
| 5
| obj
| num
| num
| num
| num
|-
| 12
| '''right.posn'''
| 5
| obj
| num
| num
| num
| num
|}


      <row/<entry/10/ <entry/'''reset.v'''        &p1; &v;/
<span id="action-commands"></span>
      <row/<entry/11/ <entry/'''toggle.v'''/      &p1; &v;/
      <row/<entry/12/ <entry/'''new.room'''/      &p1; &n;/
      <row/<entry/13/ <entry/'''new.room.v'''/    &p1; &v;/
      <row/<entry/14/ <entry/'''load.logics'''/    &p1; &n;/
      <row/<entry/15/ <entry/'''load.logics.v'''/  &p1; &v;/
      <row/<entry/16/ <entry/'''call'''/          &p1; &n;/
      <row/<entry/17/ <entry/'''call.v'''/        &p1; &v;/
      <row/<entry/18/ <entry/'''load.pic'''/      &p1; &v;/
      <row/<entry/19/ <entry/'''draw.pic'''/      &p1; &v;/
      <row/<entry/1A/ <entry/'''show.pic'''/      &p0;/
      <row/<entry/1B/ <entry/'''discard.pic'''/    &p1; &v;/
      <row/<entry/1C/ <entry/'''overlay.pic'''/    &p1; &v;/
      <row/<entry/1D/ <entry/'''show.pri.screen'''/&p0;/
      <row/<entry/1E/ <entry/'''load.view'''/      &p1; &n;/
      <row/<entry/1F/ <entry/'''load.view.v'''/    &p1; &v;/


      <row/<entry/20/ <entry/'''discard.view'''&p1; &n;/
{|  border="1"  cellspacing="0" cellpadding="5"
      <row/<entry/21/ <entry/'''animate.obj'''/    &p1; &o;/
|+ '''Table 6-2: Action Commands'''
      <row/<entry/22/ <entry/'''unanimate.all'''&p0;/
|-
      <row/<entry/23/ <entry/'''draw'''/          &p1; &o;/
! Opcode
      <row/<entry/24/ <entry/'''erase'''/          &p1; &o;/
! Command
      <row/<entry/25/ <entry/'''position'''/      &p3; &o; &n; &n;/
! Args
      <row/<entry/26/ <entry/'''position.v'''/    &p3; &o; &v; &v;/
! 1
      <row/<entry/27/ <entry/'''get.posn'''/      &p3; &o; &v; &v;/
! 2
      <row/<entry/28/ <entry/'''reposition'''/    &p3; &o; &v; &v;/
! 4
      <row/<entry/29/ <entry/'''set.view'''/      &p2; &o; &n;/
! 4
      <row/<entry/2A/ <entry/'''set.view.v'''/    &p2; &o; &v;/
! 5
      <row/<entry/2B/ <entry/'''set.loop'''/      &p2; &o; &n;/
! 6
      <row/<entry/2C/ <entry/'''set.loop.v'''/    &p2; &o; &v;/
! 7
      <row/<entry/2D/ <entry/'''fix.loop'''/      &p1; &o;/
|-
      <row/<entry/2E/ <entry/'''release.loop'''&p1; &o;/
| 00
      <row/<entry/2F/ <entry/'''set.cel'''/        &p2; &o; &n;/
| '''return'''
| 0
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
|-
| 01
| '''increment'''
| 1
| var
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
|-
| 02
| '''decrement'''
| 1
| var
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
|-
| 03
| '''assignn'''
| 2
| var
| num
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
|-
| 04
| '''assignv'''
| 2
| var
| var
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
|-
| 05
| '''addn'''
| 2
| var
| num
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
|-
| 06
| '''addv'''
| 2
| var
| var
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
|-
| 07
| '''subn'''
| 2
| var
| num
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
|-
| 08
| '''subv'''
| 2
| var
| var
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
|-
| 09
| '''lindirectv'''
| 2
| var
| var
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
|-
| 0A
| '''rindirect'''
| 2
| var
| var
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
|-
| 0B
| '''lindirectn'''
| 2
| var
| num
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
|-
| 0C
| '''set'''
| 1
| flag
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
|-
| 0D
| '''reset'''
| 1
| flag
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
|-
| 0E
| '''toggle'''
| 1
| flag
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
|-
| 0F
| '''set.v'''
| 1
| var
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
|-
| 10
| '''reset.v'''
| 1
| var
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
|-
| 11
| '''toggle.v'''
| 1
| var
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
|-
| 12
| '''new.room'''
| 1
| num
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
|-
| 13
| '''new.room.v'''
| 1
| var
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
|-
| 14
| '''load.logics'''
| 1
| num
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
|-
| 15
| '''load.logics.v'''
| 1
| var
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
|-
| 16
| '''call'''
| 1
| num
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
|-
| 17
| '''call.v'''
| 1
| var
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
|-
| 18
| '''load.pic'''
| 1
| var
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
|-
| 19
| '''draw.pic'''
| 1
| var
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
|-
| 1A
| '''show.pic'''
| 0
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
|-
| 1B
| '''discard.pic'''
| 1
| var
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
|-
| 1C
| '''overlay.pic'''
| 1
| var
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
|-
| 1D
| '''show.pri.screen'''
| 0
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
|-
| 1E
| '''load.view'''
| 1
| num
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
|-
| 1F
| '''load.view.v'''
| 1
| var
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
|-
| 20
| '''discard.view'''
| 1
| num
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
|-
| 21
| '''animate.obj'''
| 1
| obj
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
|-
| 22
| '''unanimate.all'''
| 0
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
|-
| 23
| '''draw'''
| 1
| obj
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
|-
| 24
| '''erase'''
| 1
| obj
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
|-
| 25
| '''position'''
| 3
| obj
| num
| num
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
|-
| 26
| '''position.v'''
| 3
| obj
| var
| var
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
|-
| 27
| '''get.posn'''
| 3
| obj
| var
| var
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
|-
| 28
| '''reposition'''
| 3
| obj
| var
| var
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
|-
| 29
| '''set.view'''
| 2
| obj
| num
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
|-
| 2A
| '''set.view.v'''
| 2
| obj
| var
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
|-
| 2B
| '''set.loop'''
| 2
| obj
| num
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
|-
| 2C
| '''set.loop.v'''
| 2
| obj
| var
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
|-
| 2D
| '''fix.loop'''
| 1
| obj
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
|-
| 2E
| '''release.loop'''
| 1
| obj
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
|-
| 2F
| '''set.cel'''
| 2
| obj
| num
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
|-
| 30
| '''set.cel.v'''
| 2
| obj
| var
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
|-
| 31
| '''last.cel'''
| 2
| obj
| var
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
|-
| 32
| '''current.cel'''
| 2
| obj
| var
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
|-
| 33
| '''current.loop'''
| 2
| obj
| var
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
|-
| 34
| '''current.view'''
| 2
| obj
| var
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
|-
| 35
| '''number.of.loops'''
| 2
| obj
| var
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
|-
| 36
| '''set.priority'''
| 2
| obj
| num
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
|-
| 37
| '''set.priority.v'''
| 2
| obj
| var
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
|-
| 38
| '''release.priority'''
| 1
| obj
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
|-
| 39
| '''get.priority'''
| 2
| obj
| var
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
|-
| 3A
| '''stop.update'''
| 1
| obj
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
|-
| 3B
| '''start.update'''
| 1
| obj
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
|-
| 3C
| '''force.update'''
| 1
| obj
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
|-
| 3D
| '''ignore.horizon'''
| 1
| obj
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
|-
| 3E
| '''observe.horizon'''
| 1
| obj
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
|-
| 3F
| '''set.horizon'''
| 1
| num
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
|-
| 40
| '''object.on.water'''
| 1
| obj
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
|-
| 41
| '''object.on.land'''
| 1
| obj
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
|-
| 42
| '''object.on.anything'''
| 1
| obj
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
|-
| 43
| '''ignore.objs'''
| 1
| obj
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
|-
| 44
| '''observe.objs'''
| 1
| obj
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
|-
| 45
| '''distance'''
| 3
| obj
| obj
| var
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
|-
| 46
| '''stop.cycling'''
| 1
| obj
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
|-
| 47
| '''start.cycling'''
| 1
| obj
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
|-
| 48
| '''normal.cycle'''
| 1
| obj
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
|-
| 49
| '''end.of.loop'''
| 2
| obj
| flag
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
|-
| 4A
| '''reverse.cycle'''
| 1
| obj
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
|-
| 4B
| '''reverse.loop'''
| 2
| obj
| flag
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
|-
| 4C
| '''cycle.time'''
| 2
| obj
| var
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
|-
| 4D
| '''stop.motion'''
| 1
| obj
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
|-
| 4E
| '''start.motion'''
| 1
| obj
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
|-
| 4F
| '''step.size'''
| 2
| obj
| var
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
|-
| 50
| '''step.time'''
| 2
| obj
| var
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
|-
| 51
| '''move.obj'''
| 5
| obj
| num
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
|-
| 52
| '''move.obj.v'''
| 5
| obj
| var
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
|-
| 53
| '''follow.ego'''
| 3
| obj
| num
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
|-
| 54
| '''wander'''
| 1
| obj
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
|-
| 55
| '''normal.motion'''
| 1
| obj
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
|-
| 56
| '''set.dir'''
| 2
| obj
| var
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
|-
| 57
| '''get.dir'''
| 2
| obj
| var
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
|-
| 58
| '''ignore.blocks'''
| 1
| obj
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
|-
| 59
| '''observe.blocks'''
| 1
| obj
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
|-
| 5A
| '''block'''
| 4
| num
| num
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
|-
| 5B
| '''unblock'''
| 0
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
|-
| 5C
| '''get'''
| 1
| item
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
|-
| 5D
| '''get.v'''
| 1
| var
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
|-
| 5E
| '''drop'''
| 1
| item
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
|-
| 5F
| '''put'''
| 2
| item
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
|-
| 60
| '''put.v'''
| 2
| var
| var
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
|-
| 61
| '''get.room.v'''
| 2
| var
| var
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
|-
| 62
| '''load.sound'''
| 1
| num
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
|-
| 63
| '''sound'''
| 2
| num
| flag
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
|-
| 64
| '''stop.sound'''
| 0
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
|-
| 65
| '''print'''
| 1
| msg
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
|-
| 66
| '''print.v'''
| 1
| var
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
|-
| 67
| '''display'''
| 3
| num
| num
| msg
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
|-
| 68
| '''display.v'''
| 3
| var
| var
| var
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
|-
| 69
| '''clear.lines'''
| 3
| num
| num
| msg
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
|-
| 6A
| '''text.screen'''
| 0
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
|-
| 6B
| '''graphics'''
| 0
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
|-
| 6C
| '''set.cursor.char'''
| 1
| msg
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
|-
| 6D
| '''set.text.attribute'''
| 2
| num
| num
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
|-
| 6E
| '''shake.screen'''
| 1
| num
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
|-
| 6F
| '''configure.screen'''
| 3
| num
| num
| num
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
|-
| 70
| '''status.line.on'''
| 0
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
|-
| 71
| '''status.line.off'''
| 0
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
|-
| 72
| '''set.string'''
| 2
| str
| msg
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
|-
| 73
| '''get.string'''
| 2
| str
| msg
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
|-
| 74
| '''word.to.string'''
| 2
| word
| str
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
|-
| 75
| '''parse'''
| 1
| str
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
|-
| 76
| '''get.num'''
| 2
| str
| var
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
|-
| 77
| '''prevent.input'''
| 0
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
|-
| 78
| '''accept.input'''
| 0
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
|-
| 79
| '''set.key'''
| 3
| num
| num
| num
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
|-
| 7A
| '''add.to.pic'''
| 7
| num
| num
| num
| num
| num
| num
| num
|-
| 7B
| '''add.to.pic.v'''
| 7
| var
| var
| var
| var
| var
| var
| var
|-
| 7C
| '''status'''
| 0
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
|-
| 7D
| '''save.game'''
| 0
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
|-
| 7E
| '''restore.game'''
| 0
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
|-
| 7F
| '''init.disk'''
| 0
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
|-
| 80
| '''restart.game'''
| 0
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
|-
| 81
| '''show.obj'''
| 1
| num
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
|-
| 82
| '''random'''
| 3
| num
| num
| var
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
|-
| 83
| '''program.control'''
| 0
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
|-
| 84
| '''player.control'''
| 0
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
|-
| 85
| '''obj.status.v'''
| 1
| var
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
|-
| 86
| '''quit'''
| 1
| num
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
|-
| 87
| '''show.mem'''
| 0
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
|-
| 88
| '''pause'''
| 0
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
|-
| 89
| '''echo.line'''
| 0
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
|-
| 8A
| '''cancel.line'''
| 0
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
|-
| 8B
| '''init.joy'''
| 0
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
|-
| 8C
| '''toggle.monitor'''
| 0
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
|-
| 8D
| '''version'''
| 0
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
|-
| 8E
| '''script.size'''
| 1
| num
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
|-
| 8F
| '''set.game.id'''
| 1
| msg
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
|-
| 90
| '''log'''
| 1
| msg
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
|-
| 91
| '''set.scan.start'''
| 0
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
|-
| 92
| '''reset.scan.start'''
| 0
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
|-
| 93
| '''reposition.to'''
| 3
| obj
| num
| num
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
|-
| 94
| '''reposition.to.v'''
| 3
| obj
| var
| var
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
|-
| 95
| '''trace.on'''
| 0
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
|-
| 96
| '''trace.info'''
| 3
| num
| num
| num
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
|-
| 97
| '''print.at'''
| 4
| msg
| num
| num
| num
| &nbsp;
| &nbsp;
| &nbsp;
|-
| 98
| '''print.at.v'''
| 4
| var
| num
| num
| num
| &nbsp;
| &nbsp;
| &nbsp;
|-
| 99
| '''discard.view.v'''
| 1
| var
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
|-
| 9A
| '''clear.text.rect'''
| 5
| num
| num
| num
| num
| num
| &nbsp;
| &nbsp;
|-
| 9B
| '''set.upper.left'''
| 2
| num
| num
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
|-
| 9C
| '''set.menu'''
| 1
| msg
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
|-
| 9D
| '''set.menu.member'''
| 2
| msg
| ctr
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
|-
| 9E
| '''submit.menu'''
| 0
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
|-
| 9F
| '''enable.member'''
| 1
| ctr
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
|-
| A0
| '''disable.member'''
| 1
| ctr
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
|-
| A1
| '''menu.input'''
| 0
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
|-
| A2
| '''show.obj.v'''
| 1
| var
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
|-
| A3
| '''open.dialogue'''
| 0
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
|-
| A4
| '''close.dialogue'''
| 0
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
|-
| A5
| '''mul.n'''
| 2
| var
| num
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
|-
| A6
| '''mul.v'''
| 2
| var
| var
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
|-
| A7
| '''div.n'''
| 2
| var
| num
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
|-
| A8
| '''div.v'''
| 2
| var
| var
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
|-
| A9
| '''close.window'''
| 0
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
|-
| AA
| '''set.simple'''
| 1
| ???
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
|-
| AB
| '''push.script'''
| 0
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
|-
| AC
| '''pop.script'''
| 0
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
|-
| AD
| '''hold.key'''
| 0
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
|-
| AE
| '''set.pri.base'''
| 1
| num
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
|-
| AF
| '''discard.sound'''
| 1
| num
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
|-
| B0
| '''hide.mouse'''
| 0&#124;1
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
|-
| B1
| '''allow.menu'''
| 1
| ???
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
|-
| B2
| '''show.mouse'''
| 0
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
|-
| B3
| '''fence.mouse'''
| 4
| num
| num
| num
| num
| &nbsp;
| &nbsp;
| &nbsp;
|-
| B4
| '''mouse.posn'''
| 2
| var
| var
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
|-
| B5
| '''release.key'''
| 0
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
|-
| B6
| '''adj.ego.move.to.xy'''
| 0
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
| &nbsp;
|}


      <row/<entry/30/ <entry/'''set.cel.v'''/      &p2; &o; &v;/
<span id="LogicFormat"></span>
      <row/<entry/31/ <entry/'''last.cel'''/      &p2; &o; &v;/
      <row/<entry/32/ <entry/'''current.cel'''/    &p2; &o; &v;/
      <row/<entry/33/ <entry/'''current.loop'''/  &p2; &o; &v;/
      <row/<entry/34/ <entry/'''current.view'''/  &p2; &o; &v;/
      <row/<entry/35/ <entry/'''number.of.loops'''/&p2; &o; &v;/
      <row/<entry/36/ <entry/'''set.priority'''/  &p2; &o; &n;/
      <row/<entry/37/ <entry/'''set.priority.v'''/ &p2; &o; &v;/
      <row/<entry/38/ <entry/'''release.priority'''/&p1; &o;/
      <row/<entry/39/ <entry/'''get.priority'''/  &p2; &o; &v;/
      <row/<entry/3A/ <entry/'''stop.update'''/    &p1; &o;/
      <row/<entry/3B/ <entry/'''start.update'''/  &p1; &o;/
      <row/<entry/3C/ <entry/'''force.update'''/  &p1; &o;/
      <row/<entry/3D/ <entry/'''ignore.horizon'''/ &p1; &o;/
      <row/<entry/3E/ <entry/'''observe.horizon'''/&p1; &o;/
      <row/<entry/3F/ <entry/'''set.horizon'''/    &p1; &n;/
 
      <row/<entry/40/ <entry/'''object.on.water'''/&p1; &o;/
      <row/<entry/41/ <entry/'''object.on.land'''/ &p1; &o;/
      <row/<entry/42/ <entry/'''object.on.anything'''/ &p1; &o;/
      <row/<entry/43/ <entry/'''ignore.objs'''/    &p1; &o;/
      <row/<entry/44/ <entry/'''observe.objs'''/  &p1; &o;/
      <row/<entry/45/ <entry/'''distance'''/      &p3; &o; &o; &v;/
      <row/<entry/46/ <entry/'''stop.cycling'''/  &p1; &o;/
      <row/<entry/47/ <entry/'''start.cycling'''/  &p1; &o;/
      <row/<entry/48/ <entry/'''normal.cycle'''/  &p1; &o;/
      <row/<entry/49/ <entry/'''end.of.loop'''/    &p2; &o; &f;/
      <row/<entry/4A/ <entry/'''reverse.cycle'''/  &p1; &o;/
      <row/<entry/4B/ <entry/'''reverse.loop'''/  &p2; &o; &f;/
      <row/<entry/4C/ <entry/'''cycle.time'''/    &p2; &o; &v;/
      <row/<entry/4D/ <entry/'''stop.motion'''/    &p1; &o;/
      <row/<entry/4E/ <entry/'''start.motion'''/  &p1; &o;/
      <row/<entry/4F/ <entry/'''step.size'''/      &p2; &o; &v;/
 
      <row/<entry/50/ <entry/'''step.time'''/      &p2; &o; &v;/
      <row/<entry/51/ <entry/'''move.obj'''/      &p5; &o; &n;/
      <row/<entry/52/ <entry/'''move.obj.v'''/    &p5; &o; &v;/
      <row/<entry/53/ <entry/'''follow.ego'''/    &p3; &o; &n;/
      <row/<entry/54/ <entry/'''wander'''/        &p1; &o;/
      <row/<entry/55/ <entry/'''normal.motion'''/  &p1; &o;/
      <row/<entry/56/ <entry/'''set.dir'''/        &p2; &o; &v;/
      <row/<entry/57/ <entry/'''get.dir'''/        &p2; &o; &v;/
      <row/<entry/58/ <entry/'''ignore.blocks'''/  &p1; &o;/
      <row/<entry/59/ <entry/'''observe.blocks'''/ &p1; &o;/
      <row/<entry/5A/ <entry/'''block'''/          &p4; &n; &n;/
      <row/<entry/5B/ <entry/'''unblock'''/        &p0;/
      <row/<entry/5C/ <entry/'''get'''/            &p1; &i;/
      <row/<entry/5D/ <entry/'''get.v'''/          &p1; &v;/
      <row/<entry/5E/ <entry/'''drop'''/          &p1; &i;/
      <row/<entry/5F/ <entry/'''put'''/            &p2; &i;/
 
      <row/<entry/60/ <entry/'''put.v'''/          &p2; &v; &v;/
      <row/<entry/61/ <entry/'''get.room.v'''/    &p2; &v; &v;/
      <row/<entry/62/ <entry/'''load.sound'''/    &p1; &n;/
      <row/<entry/63/ <entry/'''sound'''/          &p2; &n; &f;/
      <row/<entry/64/ <entry/'''stop.sound'''/    &p0;/
      <row/<entry/65/ <entry/'''print'''/          &p1; &m;/
      <row/<entry/66/ <entry/'''print.v'''/        &p1; &v;/
      <row/<entry/67/ <entry/'''display'''/        &p3; &n; &n; &m;/
      <row/<entry/68/ <entry/'''display.v'''/      &p3; &v; &v; &v;/
      <row/<entry/69/ <entry/'''clear.lines'''/    &p3; &n; &n; &m;/
      <row/<entry/6A/ <entry/'''text.screen'''/    &p0;/
      <row/<entry/6B/ <entry/'''graphics'''/      &p0;/
      <row/<entry/6C/ <entry/'''set.cursor.char'''/&p1; &m;/
      <row/<entry/6D/ <entry/'''set.text.attribute'''/ &p2; &n; &n;/
      <row/<entry/6E/ <entry/'''shake.screen'''/  &p1; &n;/
      <row/<entry/6F/ <entry/'''configure.screen'''/ &p3; &n; &n; &n;/
 
      <row/<entry/70/ <entry/'''status.line.on'''/ &p0;/
      <row/<entry/71/ <entry/'''status.line.off'''/&p0;/
      <row/<entry/72/ <entry/'''set.string'''/    &p2; &s; &m;/
      <row/<entry/73/ <entry/'''get.string'''/    &p2; &s; &m;/
      <row/<entry/74/ <entry/'''word.to.string'''/ &p2; &w; &s;/
      <row/<entry/75/ <entry/'''parse'''/          &p1; &s;/
      <row/<entry/76/ <entry/'''get.num'''/        &p2; &s; &v;/
      <row/<entry/77/ <entry/'''prevent.input'''/  &p0;/
      <row/<entry/78/ <entry/'''accept.input'''/  &p0;/
      <row/<entry/79/ <entry/'''set.key'''/        &p3; &n; &n; &n;/
      <row/<entry/7A/ <entry/'''add.to.pic'''/  &p7; &n;&n;&n;&n;&n;&n;&n;/
      <row/<entry/7B/ <entry/'''add.to.pic.v'''/&p7; &v;&v;&v;&v;&v;&v;&v;/
      <row/<entry/7C/ <entry/'''status'''/        &p0;/
      <row/<entry/7D/ <entry/'''save.game'''/      &p0;/
      <row/<entry/7E/ <entry/'''restore.game'''/  &p0;/
      <row/<entry/7F/ <entry/'''init.disk'''/      &p0;/
 
      <row/<entry/80/ <entry/'''restart.game'''/  &p0;/
      <row/<entry/81/ <entry/'''show.obj'''/      &p1; &n;/
      <row/<entry/82/ <entry/'''random'''/        &p3; &n; &n; &v/
      <row/<entry/83/ <entry/'''program.control'''/&p0;/
      <row/<entry/84/ <entry/'''player.control'''/ &p0;/
      <row/<entry/85/ <entry/'''obj.status.v'''/  &p1; &v;/
      <row/<entry/86/ <entry/'''quit'''/          &p1; &n;/
      <row/<entry/87/ <entry/'''show.mem'''/      &p0;/
      <row/<entry/88/ <entry/'''pause'''/          &p0;/
      <row/<entry/89/ <entry/'''echo.line'''/      &p0;/
      <row/<entry/8A/ <entry/'''cancel.line'''/    &p0;/
      <row/<entry/8B/ <entry/'''init.joy'''/      &p0;/
      <row/<entry/8C/ <entry/'''toggle.monitor'''/ &p0;/
      <row/<entry/8D/ <entry/'''version'''/        &p0;/
      <row/<entry/8E/ <entry/'''script.size'''/    &p1; &n;/
      <row/<entry/8F/ <entry/'''set.game.id'''/    &p1; &m;/
 
      <row/<entry/90/ <entry/'''log'''/            &p1; &m;/
      <row/<entry/91/ <entry/'''set.scan.start'''/ &p0;/
      <row/<entry/92/ <entry/'''reset.scan.start'''/ &p0;/
      <row/<entry/93/ <entry/'''reposition.to'''/  &p3; &o; &n; &n;/
      <row/<entry/94/ <entry/'''reposition.to.v'''/&p3; &o; &v; &v;/
      <row/<entry/95/ <entry/'''trace.on'''/      &p0;/
      <row/<entry/96/ <entry/'''trace.info'''/    &p3; &n; &n; &n;/
      <row/<entry/97/ <entry/'''print.at'''/      &p4; &m; &n; &n; &n/
      <row/<entry/98/ <entry/'''print.at.v'''/    &p4; &v; &n; &n; &n/
      <row/<entry/99/ <entry/'''discard.view.v'''/ &p1; &v;/
      <row/<entry/9A/ <entry/'''clear.text.rect'''/&p5; &n; &n; &n; &n;&n;/
      <row/<entry/9B/ <entry/'''set.upper.left'''/ &p2; &n; &n;/
      <row/<entry/9C/ <entry/'''set.menu'''/      &p1; &m;/
      <row/<entry/9D/ <entry/'''set.menu.member'''/&p2; &m; &c;/
      <row/<entry/9E/ <entry/'''submit.menu'''/    &p0;/
      <row/<entry/9F/ <entry/'''enable.member'''/  &p1; &c;/
 
      <row/<entry/A0/ <entry/'''disable.member'''/ &p1; &c;/
      <row/<entry/A1/ <entry/'''menu.input'''/    &p0;/
      <row/<entry/A2/ <entry/'''show.obj.v'''/    &p1; &v;/
      <row/<entry/A3/ <entry/'''open.dialogue'''/  &p0;/
      <row/<entry/A4/ <entry/'''close.dialogue'''/ &p0;/
      <row/<entry/A5/ <entry/'''mul.n'''/          &p2; &v; &n;/
      <row/<entry/A6/ <entry/'''mul.v'''/          &p2; &v; &v;/
      <row/<entry/A7/ <entry/'''div.n'''/          &p2; &v; &n;/
      <row/<entry/A8/ <entry/'''div.v'''/          &p2; &v; &v;/
      <row/<entry/A9/ <entry/'''close.window'''/  &p0;/
      <row/<entry/AA/ <entry/'''set.simple'''/    &p1; <entry/???//
      <row/<entry/AB/ <entry/'''push.script'''/    &p0;/
      <row/<entry/AC/ <entry/'''pop.script'''/    &p0;/
      <row/<entry/AD/ <entry/'''hold.key'''/      &p0;/
      <row/<entry/AE/ <entry/'''set.pri.base'''/  &p1; &n;/
      <row/<entry/AF/ <entry/'''discard.sound'''/  &p1; &n;/
 
      <row/<entry/B0/ <entry/'''hide.mouse'''/    <entry>0|1</entry>/
      <row/<entry/B1/ <entry/'''allow.menu'''/    &p1; <entry/???//
      <row/<entry/B2/ <entry/'''show.mouse'''/    &p0;/
      <row/<entry/B3/ <entry/'''fence.mouse'''/    &p4; &n; &n; &n; &n;/
      <row/<entry/B4/ <entry/'''mouse.posn'''/    &p2; &v; &v;/
      <row/<entry/B5/ <entry/'''release.key'''/    &p0;/
      <row/<entry/B6/ <entry/'''adj.ego.move.to.xy'''/ &p0;/
    </tbody>
  </tgroup>
</table>  
</pre>


<span id="LogicFormat"></span>
==Logic resource format==
==Logic resource format==


Line 298: Line 2,267:
discussed at a later stage.
discussed at a later stage.


  <informaltable>
{| border="1"  cellspacing="0" cellpadding="5"
    <tgroup cols="2">
|-
      <thead>
! Offset
        <row/ <entry/Offset/ <entry/Command/ /
! Command
      </thead>
|-
      <tbody>
| 0-1
        <row/ <entry/0-1/ <entry/Signature (0x12--0x34)//
| Signature (0x12--0x34)
        <row/ <entry/ 2 / <entry/Vol number that the resource is contained in//
|-
        <row/ <entry/3-4/ <entry/Length of the resource without the header//
2  
        <row/ <entry/5-6/ <entry/Offset of logic code message section//
| Vol number that the resource is contained in
      </tbody>
|-
    </tgroup>
| 3-4
  </informaltable>
| Length of the resource without the header
|-
| 5-6
| Offset of logic code message section
|}


All text that can be printed to the screen from within a logic script
All text that can be printed to the screen from within a logic script
Line 328: Line 2,301:
between one and seven arguments inclusive. This is discussed later on.
between one and seven arguments inclusive. This is discussed later on.
The first set of codes is the AGI commands themselves listed in
The first set of codes is the AGI commands themselves listed in
<xref linkend="tab-action-commands">, and they have the range 0x00--0xB6.
[[AGI/Specifications/Resources#action-commands|  Table 6-2]], and they have the range 0x00--0xB6.
 
The second set of codes is as follows:
The second set of codes is as follows:
  <informaltable>
 
    <tgroup cols="2">
{| border="1"  cellspacing="0" cellpadding="5"
      <thead>
! Code
        <row/ <entry/Code/ <entry/Command/ /
! Command
      </thead>
|-
      <tbody>
| FF
        <row/ <entry/FF/ <entry/'''if'''/ /
| '''if'''
        <row/ <entry/FE/ <entry/'''else''' or '''goto'''/ /
|-
        <row/ <entry/FD/ <entry/'''not'''/ /
| FE
        <row/ <entry/FC/ <entry/'''or'''/ /
| '''else''' or '''goto'''
      </tbody>
|-
    </tgroup>
| FD
  </informaltable>
| '''not'''
|-
| FC
| '''or'''
|}


At present these are the only high value codes encountered. The
At present these are the only high value codes encountered. The
Line 364: Line 2,342:
which tests whether flag number 5 is set. The 0xFF effectively switches
which tests whether flag number 5 is set. The 0xFF effectively switches
the interpreter into a condition checking mode which leads us to the
the interpreter into a condition checking mode which leads us to the
set of codes listed in <xref linkend="tab-test-commands">
set of codes listed in [[AGI/Specifications/Resources#test-commands|  Table 6-1]]


  0x00 - 0x12    Condition codes.
  0x00 - 0x12    Condition codes.
Line 467: Line 2,445:
follows:
follows:


  <informaltable>
{| border="1"  cellspacing="0" cellpadding="5"
    <tgroup cols="2">
|-
      <thead>
! Offset
        <row/ <entry/Offset/ <entry/Description/ /
! Description
      </thead>
|-
      <tbody>
| 0-1
        <row/ <entry/0-1/ <entry/Pointer to implementation code/ /
| Pointer to implementation code
        <row/ <entry/ 2 / <entry/Number of arguments/ /
|-
        <row/ <entry/ 3 / <entry/Type of arguments/ /
2  
      </tbody>
| Number of arguments
    </tgroup>
|-
  </informaltable>
3  
| Type of arguments
|}


The type of arguments value is interpreted as follows:
The type of arguments value is interpreted as follows:
Line 516: Line 2,496:
The format of the message section is as follows:
The format of the message section is as follows:


  <informaltable>
{| border="1"  cellspacing="0" cellpadding="5"
    <tgroup cols="2">
|-
      <thead>
! Offset
        <row/ <entry/Offset/ <entry/Description/ /
! Description
      </thead>
|-
      <tbody>
|  0
        <row/ <entry/ 0 / <entry/Number of messages//
| Number of messages
        <row/ <entry/1-2/ <entry/Pointer to the end of the messages//
|-
        <row/ <entry/3-4/ <entry/Array of message pointers//
| 1-2
        <row/ <entry/.../ <entry/Array of message pointers//
| Pointer to the end of the messages
        <row/ <entry/ ? / <entry/Start of the text data. From this point
|-
              the messages are encrypted with Avis Durgan (in their
| 3-4
              unencrypted form, each message is separated by a 0x00 value)//
| Array of message pointers
      </tbody>
|-
    </tgroup>
| ...
  </informaltable>
| Array of message pointers
|-
?  
| Start of the text data. From this point the messages are encrypted with Avis Durgan (in their unencrypted form, each message is separated by a 0x00 value)
|}


===Implementation===
===Implementation===
Line 541: Line 2,525:
Example: MH2, equaln.
Example: MH2, equaln.


<syntax type="ASM (x86)">
<syntax type="ASM">
;equaln  (eg.  if (work = 3)  )
;equaln  (eg.  if (work = 3)  )
0D71 AC            LODSB                      ;get variable number
0D71 AC            LODSB                      ;get variable number
Line 556: Line 2,540:
Example: MH2, equalv.
Example: MH2, equalv.


<syntax type="ASM (x86)">
<syntax type="ASM">
;equalv  (eg.  if (work = maxwork)  )
;equalv  (eg.  if (work = maxwork)  )
0D82 AC            LODSB                      ;get first var number
0D82 AC            LODSB                      ;get first var number
Line 584: Line 2,568:
on, I'll explain the interpretation in steps after the code block.
on, I'll explain the interpretation in steps after the code block.


<syntax type="ASM (x86)">
<syntax type="ASM">
;Decoding a LOGIC file.
;Decoding a LOGIC file.
1E6C:2EF2 56            PUSH  SI
1E6C:2EF2 56            PUSH  SI
Line 709: Line 2,693:
treating each test separately and calling the relevant test command
treating each test separately and calling the relevant test command
routines using the jump table in the <tt>agidata.ovl</tt> file.
routines using the jump table in the <tt>agidata.ovl</tt> file.
Each test command routine will return a value in <literal/AL/ which
Each test command routine will return a value in <tt>AL</tt> which
says whether it is true or not. Depending on the NOTs and ORs, the
says whether it is true or not. Depending on the NOTs and ORs, the
whole expression is evaluated. If at any stage during the evaluation
whole expression is evaluated. If at any stage during the evaluation
Line 794: Line 2,778:
<syntax type="C++">
<syntax type="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!");
     increment(30);
     increment(30);
}
}

Latest revision as of 21:58, 30 November 2011

Logic resources

Introduction

At the heart of Sierra's Adventure Game Interpreter is the logic file. 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.

<syntax type="C++"> if (said( open, door)) // must be close enough {

  if (posn( ego, 86, 120, 106, 133))
  {
     if (!night)
     {
        if ( door.open)
        {
           print("The door is already open");
        }
        else
        {
           set( game.control);
           set.priority( ego, 11);
           start.update( door);
           end.of.loop( door, door.done);
        }
     }
     else
     {
        print("You can't -- it's locked");
     }
  }
  else
  {
     set( notCloseEnough);
  }

} </syntax>

Command list and argument types

Table 6-1 and Table 6-2 show a list of all AGI commands and their argument types. The command names have been taken from debug messages contained in some AGI games.


Table 6-1: Test commands
Opcode Command Args 1 2 3 4 5
01 equaln 2 var num      
02 equalv 2 var var      
03 lessn 2 var num      
04 lessv 2 var var      
05 greatern 2 var num      
06 greaterv 2 var var      
07 isset 1 flag        
08 issetv 1 var        
09 has 1 item        
0A obj.in.room 2 item var      
0B posn 5 obj num num num num
0C controller 1 ctr        
0D have.key 0          
0E said - ...        
0F compare.strings 2 str str      
10 obj.in.box 5 obj num num num num
11 center.posn 5 obj num num num num
12 right.posn 5 obj num num num num

Table 6-2: Action Commands
Opcode Command Args 1 2 4 4 5 6 7
00 return 0              
01 increment 1 var            
02 decrement 1 var            
03 assignn 2 var num          
04 assignv 2 var var          
05 addn 2 var num          
06 addv 2 var var          
07 subn 2 var num          
08 subv 2 var var          
09 lindirectv 2 var var          
0A rindirect 2 var var          
0B lindirectn 2 var num          
0C set 1 flag            
0D reset 1 flag            
0E toggle 1 flag            
0F set.v 1 var            
10 reset.v 1 var            
11 toggle.v 1 var            
12 new.room 1 num            
13 new.room.v 1 var            
14 load.logics 1 num            
15 load.logics.v 1 var            
16 call 1 num            
17 call.v 1 var            
18 load.pic 1 var            
19 draw.pic 1 var            
1A show.pic 0              
1B discard.pic 1 var            
1C overlay.pic 1 var            
1D show.pri.screen 0              
1E load.view 1 num            
1F load.view.v 1 var            
20 discard.view 1 num            
21 animate.obj 1 obj            
22 unanimate.all 0              
23 draw 1 obj            
24 erase 1 obj            
25 position 3 obj num num        
26 position.v 3 obj var var        
27 get.posn 3 obj var var        
28 reposition 3 obj var var        
29 set.view 2 obj num          
2A set.view.v 2 obj var          
2B set.loop 2 obj num          
2C set.loop.v 2 obj var          
2D fix.loop 1 obj            
2E release.loop 1 obj            
2F set.cel 2 obj num          
30 set.cel.v 2 obj var          
31 last.cel 2 obj var          
32 current.cel 2 obj var          
33 current.loop 2 obj var          
34 current.view 2 obj var          
35 number.of.loops 2 obj var          
36 set.priority 2 obj num          
37 set.priority.v 2 obj var          
38 release.priority 1 obj            
39 get.priority 2 obj var          
3A stop.update 1 obj            
3B start.update 1 obj            
3C force.update 1 obj            
3D ignore.horizon 1 obj            
3E observe.horizon 1 obj            
3F set.horizon 1 num            
40 object.on.water 1 obj            
41 object.on.land 1 obj            
42 object.on.anything 1 obj            
43 ignore.objs 1 obj            
44 observe.objs 1 obj            
45 distance 3 obj obj var        
46 stop.cycling 1 obj            
47 start.cycling 1 obj            
48 normal.cycle 1 obj            
49 end.of.loop 2 obj flag          
4A reverse.cycle 1 obj            
4B reverse.loop 2 obj flag          
4C cycle.time 2 obj var          
4D stop.motion 1 obj            
4E start.motion 1 obj            
4F step.size 2 obj var          
50 step.time 2 obj var          
51 move.obj 5 obj num          
52 move.obj.v 5 obj var          
53 follow.ego 3 obj num          
54 wander 1 obj            
55 normal.motion 1 obj            
56 set.dir 2 obj var          
57 get.dir 2 obj var          
58 ignore.blocks 1 obj            
59 observe.blocks 1 obj            
5A block 4 num num          
5B unblock 0              
5C get 1 item            
5D get.v 1 var            
5E drop 1 item            
5F put 2 item            
60 put.v 2 var var          
61 get.room.v 2 var var          
62 load.sound 1 num            
63 sound 2 num flag          
64 stop.sound 0              
65 print 1 msg            
66 print.v 1 var            
67 display 3 num num msg        
68 display.v 3 var var var        
69 clear.lines 3 num num msg        
6A text.screen 0              
6B graphics 0              
6C set.cursor.char 1 msg            
6D set.text.attribute 2 num num          
6E shake.screen 1 num            
6F configure.screen 3 num num num        
70 status.line.on 0              
71 status.line.off 0              
72 set.string 2 str msg          
73 get.string 2 str msg          
74 word.to.string 2 word str          
75 parse 1 str            
76 get.num 2 str var          
77 prevent.input 0              
78 accept.input 0              
79 set.key 3 num num num        
7A add.to.pic 7 num num num num num num num
7B add.to.pic.v 7 var var var var var var var
7C status 0              
7D save.game 0              
7E restore.game 0              
7F init.disk 0              
80 restart.game 0              
81 show.obj 1 num            
82 random 3 num num var        
83 program.control 0              
84 player.control 0              
85 obj.status.v 1 var            
86 quit 1 num            
87 show.mem 0              
88 pause 0              
89 echo.line 0              
8A cancel.line 0              
8B init.joy 0              
8C toggle.monitor 0              
8D version 0              
8E script.size 1 num            
8F set.game.id 1 msg            
90 log 1 msg            
91 set.scan.start 0              
92 reset.scan.start 0              
93 reposition.to 3 obj num num        
94 reposition.to.v 3 obj var var        
95 trace.on 0              
96 trace.info 3 num num num        
97 print.at 4 msg num num num      
98 print.at.v 4 var num num num      
99 discard.view.v 1 var            
9A clear.text.rect 5 num num num num num    
9B set.upper.left 2 num num          
9C set.menu 1 msg            
9D set.menu.member 2 msg ctr          
9E submit.menu 0              
9F enable.member 1 ctr            
A0 disable.member 1 ctr            
A1 menu.input 0              
A2 show.obj.v 1 var            
A3 open.dialogue 0              
A4 close.dialogue 0              
A5 mul.n 2 var num          
A6 mul.v 2 var var          
A7 div.n 2 var num          
A8 div.v 2 var var          
A9 close.window 0              
AA set.simple 1 ???            
AB push.script 0              
AC pop.script 0              
AD hold.key 0              
AE set.pri.base 1 num            
AF discard.sound 1 num            
B0 hide.mouse 0|1              
B1 allow.menu 1 ???            
B2 show.mouse 0              
B3 fence.mouse 4 num num num num      
B4 mouse.posn 2 var var          
B5 release.key 0              
B6 adj.ego.move.to.xy 0              

Logic resource format

The header

The header of each logic script is seven bytes in length for games before 1988. After this date compression seems to have been introduced and the header was subsequently altered. This compression will be discussed at a later stage.

Offset Command
0-1 Signature (0x12--0x34)
2 Vol number that the resource is contained in
3-4 Length of the resource without the header
5-6 Offset of logic code message section

All text that can be printed to the screen from within a logic script is stored in an encrypted form at the end of the logic script.

Example: KQ1. Room 2.

12 34    Signature
01       vol.1
5F 06    Length = 0x065F
BA 02    Text start = 0x02BA

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 Table 6-2, and they have the range 0x00--0xB6.

The second set of codes is as follows:

Code Command
FF if
FE else or goto
FD not
FC or

At present these are the only high value codes encountered. The if and or codes are like brackets, i.e. the code will be at the start and the end of the section of codes that it refers to. The following example will illustrate this:

Example: KQ1, Room 2.

  FF      'if' conditions start.
  07      07 = isset
  05      05 = flag 5
  FF      'if' conditions close.

The above translates to:

<syntax type="C++"> if (isset(5)) </syntax>

which tests whether flag number 5 is set. The 0xFF effectively switches the interpreter into a condition checking mode which leads us to the set of codes listed in Table 6-1

0x00 - 0x12    Condition codes.

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 mode. The two bytes immediately following the second 0xFF determine how many bytes this if statement lasts for before the if is ended. When the second 0xFF is encountered the interpreter, be it us or the machine, does three things:

  1. Reads in the following two bytes.
  2. Opens a bracket.
  3. Switches to AGI command mode.

Example: KQ1, Room 2.

<syntax type="C++">

FF 07 05 FF if (isset(5)) 84 00 { // For 0x0084 bytes. 18 00 load.pic(0); 19 00 draw.pic(0); 1B 00 discard.pic(0); ... ...

              }			// Closed. 0x0084 bytes counted.

</syntax>

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).

Here's an example:

<syntax type="C++"> if (isset(231)) { FF 07 E7 FF 05 00

   printf("The door is already open.");   65 0F

} else { FE 11 00

   set(36);                               0C 24
   prevent.input();                       77
   start.update(5);                       3B 05
   assignn(152, 3);                       03 98 03
   cycle.time(5, 152);                    4C 05 98
   end.of.loop(5, 232);                   49 05 E8
   sound(70, 154);                        63 46 9A

} </syntax>

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

Conditions can be one of the following types:

FF 07 05 FF                         One condition tested, ie. isset(5)
FF FD 07 05 FF                      One condition NOTed, ie. !isset(5)
FF 07 05 07 06 FF                   Multiple conditions, ANDed.
FF FC 07 05 07 06 FC FF             Multiple conditions ORed.
FF FC 07 06 07 06 FC FD 07 08 FF    Combination.

These conditions translate to:

<syntax type="C++"> if (isset(5)) if (!isset(5)) if (isset(5) && isset(6)) if (isset(5) || isset(6)) if ((isset(5) || isset(6)) && !isset(7)) </syntax>

If multiple boolean expressions are grouped together, then there respective values are ANDed together. If multiple boolean expressions are grouped together and then surrounded by a pair of 0xFC codes, then their values are ORed together.

The 0xFD code only applies to the following condition code whose boolean value it inverts.

Arguments

You may well be asking how the interpreter knows how many arguments each code has and what type of argument each argument is. This information is stored in agidata.ovl in the MS-DOS version. Inside this file there is a table which contains four bytes for each AGI command and condition code. These four bytes are interpreted as follows:

Offset Description
0-1 Pointer to implementation code
2 Number of arguments
3 Type of arguments

The type of arguments value is interpreted as follows:

Bit        7     6     5     4     3     2     1       0
command( arg1, arg2, arg3, arg4, arg5, arg6, arg7); (unknown)

If the bit is set, argument is interpreted as a variable; otherwise the argument is interpreted as a number. It is unknown what bit 0 does since no AGI command or AGI condition code has more than seven arguments.

Examples:

  • 0x80 Says that the commands first argument is a variable.
  • 0x60 Says that the second and third arguments are variable numbers.

The messages 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'ing every eleven bytes with the string "Avis Durgan".

Example: KQ1, Room 2.

<syntax type="C++"> if (said(look, alligators)) {

   print("The alligators are swimming in the moat.");

} </syntax>

In the above example, the print statement is represented as:

65 08

The 0x08 is the number given to the string and corresponds to its position in the list of strings at the end of the logic script. The format of the message section is as follows:

Offset Description
0 Number of messages
1-2 Pointer to the end of the messages
3-4 Array of message pointers
... Array of message pointers
? Start of the text data. From this point the messages are encrypted with Avis Durgan (in their unencrypted form, each message is separated by a 0x00 value)

Implementation

The implementation for each AGI statement is found in the agi/ file. This is the AGI interpreter itself. The data in the agidata.ovl file is used to find the start of the implementation for an AGI statement. Below are a couple of examples:

Example: MH2, equaln.

<syntax type="ASM">

equaln (eg. if (work = 3) )

0D71 AC LODSB ;get variable number 0D72 32FF XOR BH,BH 0D74 8AD8 MOV BL,AL 0D76 AC LODSB ;get test number 0D77 3A870900 CMP AL,[BX+0009] ;test if var = number 0D7B B000 MOV AL,00 ;return 0 if not equal 0D7D 7502 JNZ 0D81 0D7F FEC0 INC AL ;return 1 if equal 0D81 C3 RET </syntax>

Example: MH2, equalv.

<syntax type="ASM">

equalv (eg. if (work = maxwork) )

0D82 AC LODSB ;get first var number 0D83 32FF XOR BH,BH ;clear bh 0D85 8AD8 MOV BL,AL ;BX = variable number 0D87 8AA70900 MOV AH,[BX+0009] ;get first var value 0D8B AC LODSB ;get second var number 0D8C 8AD8 MOV BL,AL 0D8E 32C0 XOR AL,AL ;return 0 if not equal 0D90 3AA70900 CMP AH,[BX+0009] ;compare variables 0D94 7502 JNZ 0D98 0D96 FEC0 INC AL ;return 1 if equal 0D98 C3 RET </syntax>

These two examples show the difference between how numbers and variables are dealt with. In the case of a variable, the variables number is used as an index into the table of variable values to get the value which is being tested. It appears that the variable table is at offset 0x0009 in the data segment.

How the interpreter handles the code

The following 8086 assembly language code is the actual code from the MS-DOS version of Manhunter: San Francisco. There are some calls to routines which aren't displayed. Take my word for it that they do what the comment says. For those of you who can't follow whats going on, I'll explain the interpretation in steps after the code block.

<syntax type="ASM">

Decoding a LOGIC file.

1E6C:2EF2 56 PUSH SI 1E6C:2EF3 57 PUSH DI 1E6C:2EF4 55 PUSH BP 1E6C:2EF5 8BEC MOV BP,SP 1E6C:2EF7 83EC02 SUB SP,+02 1E6C:2EFA 8B7608 MOV SI,[BP+08] ;SI -> start of LOGIC script. 1E6C:2EFD 8B7406 MOV SI,[SI+06] ;Skip first 6 bytes (header). 1E6C:2F00 AC LODSB ;Get next byte in LOGIC file. 1E6C:2F01 84C0 TEST AL,AL ;Is code a zero? 1E6C:2F03 7414 JZ 2F19 ;If so, jump to exit. 1E6C:2F05 3CFF CMP AL,FF ;If an opening 'if' code is found 1E6C:2F07 7419 JZ 2F22 ;jump to 'if' handler. 1E6C:2F09 3CFE CMP AL,FE ;If an 'else' has not been found 1E6C:2F0B 7505 JNZ 2F12 ;jump over else/branch. 1E6C:2F0D AD LODSW ;Get word (bracket distance) 1E6C:2F0E 03F0 ADD SI,AX ;Add to SI. Skip else code. 1E6C:2F10 EBEE JMP 2F00 ;Go back to get next byte. 1E6C:2F12 E8A8D6 CALL 05BD ;Execute AGI command. 1E6C:2F15 85F6 TEST SI,SI  ; 1E6C:2F17 75E8 JNZ 2F01 ;Jump back to top. 1E6C:2F19 8BC6 MOV AX,SI 1E6C:2F1B 83C402 ADD SP,+02 1E6C:2F1E 5D POP BP 1E6C:2F1F 5F POP DI 1E6C:2F20 5E POP SI 1E6C:2F21 C3 RET

Handler for 'if' statement.
BH determines if its in an OR bracket (BH=1 means OR).
BL determines the nature of the evalutation (BL=1 means NOT)

1E6C:2F22 33DB XOR BX,BX 1E6C:2F24 AC LODSB ;Get next byte 1E6C:2F25 3CFC CMP AL,FC ;If less than 0xFC, then 1E6C:2F27 721C JB 2F45 ;jump to normal processing. 1E6C:2F29 7508 JNZ 2F33 ;If greater, jump to 'if' close. 1E6C:2F2B 84FF TEST BH,BH  ;(Could BH be the evaluation reg? 1E6C:2F2D 7551 JNZ 2F80 ;or whether its the second FC? 1E6C:2F2F FEC7 INC BH  ; 1E6C:2F31 EBF1 JMP 2F24 ;Go back to get next byte.

1E6C:2F33 3CFF CMP AL,FF ;Is the code for an 'if' close? 1E6C:2F35 7505 JNZ 2F3C ;If not, jump to 'not' test. 1E6C:2F37 83C602 ADD SI,+02  ; 1E6C:2F3A EBC4 JMP 2F00  ; 1E6C:2F3C 3CFD CMP AL,FD ;Is the code for a 'not'? 1E6C:2F3E 7505 JNZ 2F45 ;If not, jump to test command. 1E6C:2F40 80F301 XOR BL,01  ; 1E6C:2F43 EBDF JMP 2F24 ;Go back to get next byte. 1E6C:2F45 53 PUSH BX ;BX = test conditions?? 1E6C:2F46 E8E8DD CALL 0D31 ;Evaluate separate test command. 1E6C:2F49 5B POP BX  ; 1E6C:2F4A 32C3 XOR AL,BL ;Toggle the result for NOT. 1E6C:2F4C B300 MOV BL,00  ; 1E6C:2F4E 7506 JNZ 2F56 ;If true jump to 2F56. 1E6C:2F50 84FF TEST BH,BH ;If BH=0 then not in OR and 1E6C:2F52 742C JZ 2F80 ;test is truely false. 1E6C:2F54 EBCE JMP 2F24 ;Otherwise evaluate next OR. 1E6C:2F56 84FF TEST BH,BH ;Are we in OR mode? 1E6C:2F58 7424 JZ 2F7E ;If not, continue with testing. 1E6C:2F5A 32FF XOR BH,BH ;If so, then we will skip the 1E6C:2F5C 32E4 XOR AH,AH ;rest of the tests in the OR 1E6C:2F5E AC LODSB ;bracket since the first is true. 1E6C:2F5F 3CFC CMP AL,FC ;OR: Waiting for closing OR. 1E6C:2F61 741B JZ 2F7E ;If OR found, then continue testing. 1E6C:2F63 77F9 JA 2F5E  ; 1E6C:2F65 3C0E CMP AL,0E ;If 'said' then goto said handler 1E6C:2F67 7507 JNZ 2F70 ;else goto normal handler 1E6C:2F69 AC LODSB ;Work out number of words in said 1E6C:2F6A D1E0 SHL AX,1 ;and jump over them. 1E6C:2F6C 03F0 ADD SI,AX  ; 1E6C:2F6E EBEE JMP 2F5E  ; 1E6C:2F70 8BF8 MOV DI,AX ;Jumps over arguments. 1E6C:2F72 D1E7 SHL DI,1  ; 1E6C:2F74 D1E7 SHL DI,1  ; 1E6C:2F76 8A856407 MOV AL,[DI+0764] ;Load up the number of arguments 1E6C:2F7A 03F0 ADD SI,AX ;Add to the execution pointer 1E6C:2F7C EBE0 JMP 2F5E  ; 1E6C:2F7E EBA4 JMP 2F24

Test is false.
This routine basically skips over the rest of the codes until it finds the
closing 0xFF at which point it will load the following two bytes and add
them to the execution pointer SI.

1E6C:2F80 32FF XOR BH,BH 1E6C:2F82 32E4 XOR AH,AH 1E6C:2F84 AC LODSB  ; 1E6C:2F85 3CFF CMP AL,FF ;If the closing 0XFF is found, 1E6C:2F87 741D JZ 2FA6 ;jump 2FA6. 1E6C:2F89 3CFC CMP AL,FC ;If greater than FC, 1E6C:2F8B 73F7 JNB 2F84 ;get next byte. 1E6C:2F8D 3C0E CMP AL,0E ;If 'said' then goto said handler 1E6C:2F8F 7507 JNZ 2F98 ;else goto normal handler. 1E6C:2F91 AC LODSB ;Work out number of words in said 1E6C:2F92 D1E0 SHL AX,1 ;and jump over them. 1E6C:2F94 03F0 ADD SI,AX 1E6C:2F96 EBEC JMP 2F84 1E6C:2F98 8AD8 MOV BL,AL ;Jump over arguments. 1E6C:2F9A D1E3 SHL BX,1 1E6C:2F9C D1E3 SHL BX,1 1E6C:2F9E 8A876407 MOV AL,[BX+0764] ;Load up the number of arguments. 1E6C:2FA2 03F0 ADD SI,AX ;Add to the execution pointer. 1E6C:2FA4 EBDE JMP 2F84 1E6C:2FA6 AD LODSW 1E6C:2FA7 03F0 ADD SI,AX ;Skip over if (includes 3 else byte s) 1E6C:2FA9 E954FF JMP 2F00 </syntax>

Situation 1. Every logic script starts in normal AGI command execution mode. In this routine, if the code is below 0xFC, then it is presumed to be an AGI command. It will then call the main command execution routine which will jump to the relevant routine for the specific command using the jump table stored in agidata.ovl. The command is performed and it returns to the main execution routine where it loops back to the top and deals with the next code in the logic file.

Situation 2. 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 agidata.ovl file. Each test command routine will return a value in AL which says whether it is true or not. Depending on the NOTs and ORs, the whole expression is evaluated. If at any stage during the evaluation the routine decides that the expression will be false, it exits to another routine which skips the rest of the if statement and then adds the two byte word following the closing 0xFF code to the execution pointer. This usually has the affect of jumping over the if block of code. If the if handler gets to the ending 0xFF then it knows the expression is true simply because it hasn't exited out of the routine yet. At this stage it jumps over the two bytes following the closing 0xFF and then goes back to executing straight AGI commands.

/Situation 3. If in the normal execution of AGI commands, the code 0xFE is encountered, a very simple action takes place. The two bytes which follow form a 16-bit twos complement value which is added to execution pointer. This is all it does. Previously we said that the 0xFE code stood for the else statement which is in actual fact correct for over 90% of the time, but the small number of other occurrences are best described as goto statements. If you're confused by this, the following example will probably explain things.

Example:

<syntax type="C++"> if (said( open, door)) {

   // first block of AGI statements

} else {

   // second block of AGI statements

} </syntax>

The above example is how the original coder would have written the AGI code. If we now look at the following example, it is not hard to see that it would achieve the same thing.

<syntax type="C++"> if (!said( open, door)) goto label1;

   // first block of AGI statements
   goto label2:

label1:

   // second block of AGI statements

label2: </syntax>

This is exactly how all ifs and elses 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 above assembly language code does raise a very important point. 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.

Examples:

<syntax type="C++"> if (said(marble)) FF 0E 01 1E 01 FF if (said( open, door)) FF 0E 02 37 02 73 00 FF </syntax>

In the above examples, the values 0x011E, 0x0237, and 0x0073 are just random word numbers that could stand for the words given.

Inner loops

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.

Example:

<syntax type="C++"> if (greatern(30, 45) && lessn(30, 55)) {

   print("You're in the hot zone!");
   increment(30);

} </syntax>

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 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:

<syntax type="C++"> FF FD 0D FF 03 00 FE F7 FF

do { } while (!havekey); </syntax>

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 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.