GBAGI
The Sierra Adventure Game Interpreter for the Nintendo Game Boy Advance

By Brian Provinciano

AGI Logic Files

The AGI Logic files contain the game's code. Each game can have up to 256 logic files. Logics have two basic parts--the code and the messages. The messages are strings of text, while the code are simple pcode instructions.

The game revolves around the usage of four types of variables:

The logic code is an array of instructions, up to 183 logic commands, if expressions, else/goto expressions, and 19 test commands. Each command can have parameters with any variable or data type--immediate integers, vars, flags, strings, messages or controllers, depending on what it's purpose is.

The Commands

0
return();

1 byte

Returns from the currently executed logic back to either the previous logic which called it, or in the case of logic.000, back to the interpreter.


1
increment(var vA);
vA++;

2 bytes

Increments the given variable vA. If vA is 255, it will not be incremented and remain 255, preventing it from rolling over back to zero.


2
decrement(var vA);
vA--;

2 bytes

Decrements the given variable vA. If vA is 0, it will not be decremented and remain 0, preventing it from rolling over back to 255.


3
assign(var vA, int B);
vA = B;

3 bytes

Variable vA is assigned the value of B, where B is an immediate integer value between 0 and 255.


4
assignv(var vA, var vB);
vA = vB;

3 bytes

Variable vA is assigned the value of variable vB.


5
addn(var vA, int B);
vA = vA + B;
vA += B;

3 bytes

The value of B, where B is an immediate integer value, is added to variable vA. No checking takes place, so if the result is greater than 255, it will wrap around to zero and above.


6
addv(var vA, var vB);
vA = vA + vB;
vA += vB;

3 bytes

The value of vB, where vB is variable, is added to variable vA. No checking takes place, so if the result is greater than 255, it will wrap around to zero and above.


7
subn(var vA, int B);
vA = vA - B;
vA -= B;

3 bytes

The value of B, where B is an immediate integer value, is subtracted from variable vA. No checking takes place, so if the result is less than 0, it will wrap around to 255 and below.


8
subv(var vA, var vB);
vA = vA - vB;
vA -= vB;

3 bytes

The value of vB, where vB is a variable, is subtracted from variable vA. No checking takes place, so if the result is less than 0, it will wrap around to 255 and below.


9
lindirectv(var vA, var vB);
v[vA] = vB;

3 bytes

The value of vB, where vB is a variable, is assigned to the variable which number is specified in vA.


10
rindirect(var vA, var vB);
vA = v[vB];

3 bytes

Variable vA is assigned the value which is contained in the variable which is specified in vB.


11
lindirectn(var vA, int B);
v[vA] = B;

3 bytes

The value of B, where B is an immediate integer value, is assigned to the variable which number is specified in vA.


12
set(flag fA);
fA = TRUE;

2 bytes

Flag fA is set to a boolean TRUE.


13
reset(flag fA);
fA = FALSE;

2 bytes

Flag fA is set to a boolean FALSE.


14
toggle(flag fA);
fA = !fA;

2 bytes

Flag fA is toggled. If it was TRUE, it will now be FALSE. If it was FALSE, it will now be TRUE.


15
setv(var vA);
f[vA] = TRUE;

2 bytes

Flag fX, where X is the value of vA, is set to a boolean TRUE.


16
resetv(var vA);
f[vA] = FALSE;

2 bytes

Flag fX, where X is the value of vA,is set to a boolean FALSE.


17
togglev(var vA);
f[vA] = !f[vA];

2 bytes

Flag fX, where X is the value of vA, is toggled. If it was TRUE, it will now be FALSE. If it was FALSE, it will now be TRUE.


18
new.room(int roomNum);

2 bytes

The interpreter takes the game to another "room", where roomNum is the logic number of the new room to execute. Each interpreter cycle, Logic.000 is executed, which then calls the current room's logic.

Switching to another room causes the interpreter to perform the following tasks:

  • All of the view objs are unanimated and erased
  • Any sound currently playing is stopped.
  • The controllers are cleared.
  • The pic views and overlays are cleared from the script stack.
  • The ego's control state is set to TRUE.
  • View obj blocking is disabled.
  • The horizon is set back to the default 36.
  • v01 (vOldRoom) is set to v00 (vCurrentRoom)
  • v00 (vCurrentRoom) is set to roomNum.
  • v04 (vViewObj) and v05 (vViewObjBorder) are set to zero.
  • v08 (vFreeMem) is set to 10 (not important).
  • v16 (vEgoView) is set to the current view number view obj #0 is set to.
  • If the ego is exiting a room from a border (v02, vEgoBorder), place the ego view obj (#0) at the opposite end.
  • The fNewRoom flag (f05) is set to TRUE.
  • The status line is redrawn.
  • The currently active logics all return and execution resumes from the beginning of logic.000

19
new.room.v(var vRoomNum);

2 bytes

Performs the exact same task as new.room(int), but the number of the new room is specified in the variable vRoomNum instead of an immediate integer.


20
load.logics(int num);

2 bytes

In GBAGI, all resources are in ROM, thus do not need to be loaded into RAM as they were on the original PC interpreters. However, in the PC interpreters, this command loaded the specified logic resource (logic.num) from the vol file into RAM so it could be executed.


21
load.logics.v(var vNum);

2 bytes

In GBAGI, all resources are in ROM, thus do not need to be loaded into RAM as they were on the original PC interpreters. However, in the PC interpreters, this command loaded the specified logic resource (logic.vNum) from the vol file into RAM so it could be executed.


22
call(int num);

2 bytes

The logic specified by num is executed following the call command. When the logic returns, execution of the previous logic which called it resumes. The logics are already loaded in ROM and need not be loaded into RAM in GBAGI, however, in the PC version, there was no need to preload the logic before using this command either, as it would automatically load/unload the logic for you.


23
call.v(var vNum);

2 bytes

The logic specified by variable vNum is executed following the call command. When the logic returns, execution of the previous logic which called it resumes.


24
load.pic(var vPicNum);

2 bytes

In GBAGI, all resources are in ROM, thus do not need to be loaded into RAM as they were on the original PC interpreters. However, in the PC interpreters, this command loaded the specified picture resource (picture.vPicNum) from the vol file into RAM so it could be used.


25
draw.pic(var vPicNum);

2 bytes

The off screen picture buffer in cleared and the picture specified by variable vPicNum is drawn. It does not actually update the picture on the screen, show.pic() does that.


26
show.pic();

1 byte

The current off screen picture buffer in drawn on the screen filling the whole graphical play area with a background.


27
discard.pic(var vPicNum);

2 bytes

In GBAGI, all resources are in ROM, thus do not need to be loaded/unloaded to/from RAM as they were on the original PC interpreters. However, in the PC interpreters, this command unloaded the specified picture resource (picture.vPicNum) from memory.


28
overlay.pic(var vPicNum);

2 bytes

Performs the same function as draw.pic(var), but does not clear the picture buffer prior to drawing. It simply draws the specified picture in vPicNum over the current picture. Because only white areas are filled, any fills the overlaid picture makes on non-white areas will be ignored.


29
show.pri.screen();

1 byte

Displays the current picture buffer's priority picture on the screen to view until a key is pressed. It then redraws the screen as normal and resumes the game.


30
load.view(int viewNum);

2 bytes

In GBAGI, all resources are in ROM, thus do not need to be loaded into RAM as they were on the original PC interpreters. However, in the PC interpreters, this command loaded the specified view resource (view.viewNum) from the vol file into RAM so it could be used.


31
load.view.v(var vViewNum);

2 bytes

In GBAGI, all resources are in ROM, thus do not need to be loaded into RAM as they were on the original PC interpreters. However, in the PC interpreters, this command loaded the specified view resource (view.vViewNum) from the vol file into RAM so it could be used.


32
discard.view(int viewNum);

2 bytes

In GBAGI, all resources are in ROM, thus do not need to be loaded/unloaded to/from RAM as they were on the original PC interpreters. However, in the PC interpreters, this command unloaded the specified view resource (view.viewNum) from memory.


33
animate.obj(vobj voNum)

2 bytes

If the view object specified by voNum is not currently animated, it sets the view object for updating/cycling/animating, sets it's motion to mtNORMAL, cycle to cyNORMAL, and direction to drNONE.


34
unanimate.all

1 byte

Deactivates and erases all the objects currently visible on the screen.


35
draw(vobj voNum)

2 bytes

Draws the view object specified by voNum onto the screen. It solidifies it's positioning on screen, erases all the animated objects from the screen, then redraws them all with the new object.


36
erase(vobj voNum)

2 bytes

Erases the view object specified by voNum from the screen. It erases all the animated objects from the screen, and if the view object is flagged for updating, the unanimated objects as well, then redraws them without the erased object.


37
position(vobj voNum, int X, int Y)

4 bytes

Simply sets the view object specified by voNum to the coordinates specified by the X and Y parameters passed to the command.


38
position.v(vobj voNum, var vX, var vY)

4 bytes

Simply sets the view object specified by voNum to the coordinates specified by the variables vX and vY passed to the command.


39
get.posn(vobj voNum, var vX, var vY)

4 bytes

The variables vX and vY are assigned the values of the the view object specified by voNum's X and Y coordinates.


40
reposition(vobj voNum, signed var vDX, signed var vDY)

4 bytes

Repositions the view object specified by voNum to new coordinates. The current coordinates are offset by the values of the specified variables vDX and vDY. The vDX and vDY variables are signed values from -128 to +127 and are added to the view object's x and y coordinates. The view object's new position is then solidified.


41
set.view(vobj voNum, int viewNum)

3 bytes

The view object specified by voNum's view is set to the view resource specified in viewNum. The view object can then be drawn with the cels from the new view resource. If the current loop number it out of the new view's loop range, the current loop is then set to zero, as with the cels.


42
set.view.v(vobj voNum, var vViewNum)

3 bytes

The view object specified by voNum's view is set to the view resource specified in the variable vViewNum. The view object can then be drawn with the cels from the new view resource.


43
set.loop(vobj voNum, int loopNum)

3 bytes

The view object specified by voNum's current loop is set to the loop specified by loopNum. If the current cel number it out of the new loop's range, the current cel number is then set to zero.


44
set.loop.v(vobj voNum, var vLoopNum)

3 bytes

The view object specified by voNum's current loop is set to the loop specified by the variable vLoopNum. If the current cel number it out of the new loop's range, the current cel number is then set to zero.


45
fix.loop(vobj voNum)

2 bytes

The interpreter can automatically set a view object's loop based on it's current direction. This is frequently desired and very useful, however, in the case that you do not want this, a call of this command will prevent the interpreter from doing this. The loop will stay what you set it to no matter what direction the view object is set to.


46
release.loop(vobj voNum)

2 bytes

The interpreter can automatically set a view object's loop based on it's current direction. This is frequently desired and very useful for view objects such as people or other moving objects. By calling this command, the view object's current loop will be automatically set by the interpreter.


47
set.cel(vobj voNum, int celNum)

3 bytes

The view object specified by voNum's current cel is set to the number specified by celNum.


48
set.cel.v(vobj voNum, var vCelNum)

3 bytes

The view object specified by voNum's current cel is set to the number specified by the variable vCelNum.


49
last.cel(vobj voNum, var vCelNum)

3 bytes

The variable vCelNum is set to the number of the last cel in the view object specified by voNum's current loop. This is equal to the total number of cels - 1 as the first cel is 0.


50
current.cel(vobj voNum, var vCelNum)

3 bytes

The variable vCelNum is set to the number of the current cel in the view object specified by voNum.


51
current.loop(vobj voNum, var vLoopNum)

3 bytes

The variable vLoopNum is set to the number of the current loop in the view object specified by voNum.


52
current.view(vobj voNum, var vViewNum)

3 bytes

The variable vViewNum is set to the number of the current view in the view object specified by voNum.


53
number.of.loops(vobj voNum, var vTotalLoops)

3 bytes

The variable vTotalLoops is set to the total number of loops in the view object specified by voNum's current view. The last loop is equal to the total number of loops - 1 as the first loop number is 0.


54
set.priority(vobj voNum, int priNum)

3 bytes

The view object specified by voNum's priority value is set to priNum. Normally a priority is set automatically based on the Y coordinate of the view object. However, with this command, you can set it to be fixed on any priority value regardless of coordinate.

The priority value can be anywhere from 0 to 15 (though controls are 0-3 and priorities are 4-15). If it is 15, the object will be drawn above everything and ignore all boundaries specified by control lines.


55
set.priority.v(vobj voNum, var vPriNum)

3 bytes

The view object specified by voNum's priority value is set to the value in variable vPriNum. Normally a priority is set automatically based on the Y coordinate of the view object. However, with this command, you can set it to be fixed on any priority value regardless of coordinate.

The priority value can be anywhere from 0 to 15 (though controls are 0-3 and priorities are 4-15). If it is 15, the object will be drawn above everything and ignore all boundaries specified by control lines.


56
release.priority(vobj voNum)

2 bytes

The view object specified by voNum's priority value reset to automatically be set based on the current Y coordinate of the view object.


57
get.priority(vobj voNum, var vPriNum)

3 bytes

The variable vPriNum is set to the current priority number of the view object specified by voNum.


58
stop.update(vobj voNum)

2 bytes

If the view object specified by voNum is flagged for updating, all view objects on screen are erased, view object specified is unflagged to not be updated, then the view objects are redrawn.


59
start.update(vobj voNum)

2 bytes

If the view object specified by voNum is not flagged for updating, all view objects on screen are erased, view object specified is flagged to be updated, then the view objects are redrawn.


60
force.update(vobj voNum)

2 bytes

Immediately erases all the current view objects on screen, redraws them, then updates them. The parameter is unused in the majority of interpreters. It was only used in the very early versions when they only updated the specified view object.


61
ignore.horizon(vobj voNum)

2 bytes

The view object specified by voNum is set to ignore the horizon, that is, it will be allowed to move past the top horizon line normally a boundary for moving objects.


62
observe.horizon(vobj voNum)

2 bytes

The view object specified by voNum is set to react to the horizon, that is, it will be not be allowed to move past the top horizon line.


63
set.horizon(int Y)

2 bytes

The horizon boundary line is set to the coordinate Y. Objects observing the horizon will not be allowed to move past this line. The default coordinate is 36 and it is reset to the default on each call to new.room(int) or new.room.v(var).


64
object.on.water(vobj voNum)

2 bytes

The view object specified by voNum is set to be constrained to only move around in areas of the screen which have the water control bit set (any pixels on the priority screen with a value of 3).


65
object.on.land(vobj voNum)

2 bytes

The view object specified by voNum is set to be constrained to only move around in areas of the screen which do not completely have the water control bit set, which are any pixels on the priority screen not with a value of 3 (other than other control boundaries).


66
object.on.anything(vobj voNum)

2 bytes

The view object specified by voNum will be allowed to move around on any type of priority region including water as long as it does not bump into a control boundary.


67
ignore.objs(vobj voNum)

2 bytes

The view object specified by voNum will be set to ignore other objects. That is, when a collision check is made, no check between this and another view object will return true. Both view objects need to have their observe objs flag set or they will be unable to collide.


68
observe.objs(vobj voNum)

2 bytes

The view object specified by voNum will be set to observe other objects. That is, when a collision check is made, it will be check between this and another view object. If either view object is not set to observe other view objects, they will be unable to collide.


69
distance(vobj voNumA, vobj voNumB, var vDistance)

4 bytes

The variable vDistance will be set to the absolute distance between the view object specified by voNumA and the view object specified by voNumA. If either of the view objects is not visible, the vDistance is set to 255. Otherwise, it is set to the absolute distance, which will be a maximum of 254.


70
stop.cycling(vobj voNum)

2 bytes

The view object specified by voNum will no longer cycle, that is, the cels will no longer be animating.


71
start.cycling(vobj voNum)

2 bytes

The view object specified by voNum will be set to cycle, that is, the cels will animate according to their cycle type (cyNORMAL, cyENDOFLOOP, cyREVERSELOOP, cyREVERSECYCLE).


72
normal.cycle(vobj voNum)

2 bytes

The view object specified by voNum's cycle mode it set to cyNORMAL. With this cycle, the view object will animate looping the cels from first to last.


73
end.of.loop(vobj voNum, flag fNotify)

3 bytes

The flag fNotify is set to FALSE, then the view object specified by voNum's cycle mode it set to cyENDOFLOOP. It will cycle normally from beginning to end. When the last cel of the loop is reached, the flag fNotify will be set.


74
reverse.cycle(vobj voNum)

2 bytes

The view object specified by voNum's cycle mode it set to cyREVERSECYCLE. With this cycle, the view object will animate looping the cels from last to first.


75
reverse.loop(vobj voNum, flag fNotify)

3 bytes

The flag fNotify is set to FALSE, then the view object specified by voNum's cycle mode it set to cyREVERSELOOP. With this cycle, the view object will animate looping the cels from last to first. When the first cel of the loop is reached, the flag fNotify will be set.


76
cycle.time(vobj voNum, var vTime)

3 bytes

The view object specified by voNum's cycle time will be set to the value of variable vTime. The cycle time specifies how frequently to update the view object's animation cycle, that is how often to move to the next frame. This time is measured in interpreter cycles. If the cycle time is set to zero, the view object will not cycle at all.


77
stop.motion(vobj voNum)

2 bytes

The view object specified by voNum's will stop movement. It's direction will be set to dirNONE, and motion back to mtNONE. If the view object specified is the ego, the variable vEgoDirection (v6) is updated and the player control is disabled.


78
start.motion(vobj voNum)

2 bytes

The view object specified by voNum's motion will be set to mtNONE and if the view object specified is the ego, the variable vEgoDirection (v6) is updated and the player control is enabled.


79
step.size(vobj voNum, var vStepSize)

3 bytes

The view object specified by voNum's step size will be set to the value of variable vStepSize. The step size specifies how many pixels to move the view object per movement step.


80
step.time(vobj voNum, var vStepTime)

3 bytes

The view object specified by voNum's step time will be set to the value of variable vStepTime. The step time specifies how many interpreter cycles to wait before updating the view object's movement.


81
move.obj(vobj voNum, int X, int Y, int StepSize, flag fDone)

6 bytes

Resets the flag fDone, then the view object specified by voNum will be set up to move from it's current coordinate to the new coordinate specified by the X and Y parameters. If the StepSize parameter is nonzero, the view object's step size will be set to it's value. Upon the view object reaching the destination, the flag fDone will be set to TRUE.


82
move.obj.v(vobj voNum, var vX, int var vY, var vStepSize, flag fDone)

6 bytes

Resets the flag fDone, then the view object specified by voNum will be set up to move from it's current coordinate to the new coordinate specified by the variables vX and vY parameters. If the vStepSize parameter's value is nonzero, the view object's step size will be set to it's value. Upon the view object reaching the destination, the flag fDone will be set to TRUE.


83
follow.ego(vobj voNum, int StepSize, flag fDone)

4 bytes

Resets the flag fDone, then the view object specified by voNum will be set up to move from it's current coordinate to the new coordinate to the ego's (view object #0) position. If the StepSize parameter's value is nonzero, the view object's follow step size will be set to it's value, otherwise it will be set to the view object's step size. Upon the view object reaching the destination, the flag fDone will be set to TRUE.


84
wander(vobj voNum)

2 bytes

Sets the view object specified by voNum's motion to mtWANDER and causes the view object to wander aimlessly and randomly around the screen. If the view object specified is the ego (view object #0), the player control is disabled.


85
normal.motion(vobj voNum)

2 bytes

Sets the view object specified by voNum's motion to mtNONE, in that, it will stop any special movement. If the view object was following, wandering or whatnot, it will now resume normal movement.


86
set.dir(vobj voNum, var vDirection)

2 bytes

Sets the view object specified by voNum's direction to the value of variable vDirection, which is a value between 0 and 8.


87
get.dir(vobj voNum, var vDirection)

2 bytes

Sets the value of variable vDirection to the view object specified by voNum's current direction.


88
ignore.blocks(vobj voNum)

2 bytes

If the view object blocking parameter has been set up, it will allows the view object specified by voNum to ignore this constraint region and move freely. It also allows the view object to walk past control screen boundaries.


89
observe.blocks(vobj voNum)

2 bytes

If the view object blocking parameter has been set up, it will force the view object specified by voNum to be constrained to the block region. It also forces the view object to be unable to walk past control screen boundaries.


90
block(int X1, int Y1, int X2, int Y2)

5 bytes

Turns on view object blocking and sets the block to the region specified by the X1, Y1, X2 and Y2 coordinates. Objects that observe blocks will be constrained to this area.


91
unblock()

1 byte

Turns off view object blocking. Objects will no longer be constrained to the block region, regardless of whether they observe blocks or not.


92
get(invi iNum)

2 bytes

The inventory item specified by iNum will be placed in the player's inventory. This is done by simply setting the item's current room to 255.


93
get.v(var vInvNum)

2 bytes

The inventory item specified by the value of variable vInvNum will be placed in the player's inventory. This is done by simply setting the item's current room to 255.


94
drop(invi iNum)

2 bytes

The inventory item specified by iNum will be removed from the player's inventory. This is done by simply setting the item's current room to 0.


95
put(invi iNum, int RoomNum)

3 bytes

The inventory item specified by iNum's current room will be set to the value of RoomNum. If it was in the player's inventory before, it no longer will be.


96
put.v(invi iNum, var vRoomNum)

3 bytes

The inventory item specified by iNum's current room will be set to the value of variable vRoomNum. If it was in the player's inventory before, it no longer will be.


97
get.room.v(invi iNum, var vRoomNum)

3 bytes

The variable vRoomNum will be set to the room number of the inventory item specified by iNum.


98
load.sound(int num);

2 bytes

In GBAGI, all resources are in ROM, thus do not need to be loaded into RAM as they were on the original PC interpreters. However, in the PC interpreters, this command loaded the specified sound resource (sound.num) from the vol file into RAM so it could be executed.


99
sound(int num, flag fDone);

2 bytes

Sets the flag fDone to FALSE then starts playing the sound specified by num. Upon completion, the flag fDone is set to TRUE.


100
stop.sound();

1 byte

If a sound is currently playing, it stops, and the sound flag is set to TRUE to indicate the sound is done.


101
print(msg Message);

2 bytes

Displays a message box on the screen with the string of Message as it's message.

Flag fPrintMode (f15) controls whether or not to automatically close the message box. If set, the box will remain until the close.window() command is called, and the game execution will continue with the message box on the screen.

If fPrintMode is not set, variable vPrintTime (v21) is used to control the timing of the message box. If nonzero, the message box will remain on the screen for vPrintTime*0.5 seconds, or until the player presses a button. Otherwise, it will simply stay on until the player presses a button.


102
print.v(var vMessage);

2 bytes

Displays a message box on the screen with the string of message number vMessage as it's message.

Flag fPrintMode (f15) controls whether or not to automatically close the message box. If set, the box will remain until the close.window() command is called, and the game execution will continue with the message box on the screen.

If fPrintMode is not set, variable vPrintTime (v21) is used to control the timing of the message box. If nonzero, the message box will remain on the screen for vPrintTime*0.5 seconds, or until the player presses a button. Otherwise, it will simply stay on until the player presses a button.


103
display(int Row, int Col, msg Message);

4 bytes

Displays a string of text (message number Message) on the screen using the current text color attributes and positions it at Row and Col.


104
display.v(var vRow, var vCol, var vMessage);

4 bytes

Displays a string of text (message number vMessage) on the screen using the current text color attributes and positions it at vRow and vCol.