Stack Overflow Information

From AGI Wiki
Jump to navigationJump to search
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.

Tutorials and Guides Table of Contents

Creating AGI Stack Overflow Information

By Nick Sonneveld

Last updated 23/2/2001

 

Windows users may encounter the "stack blown error". Most Sierra AGI games work just under Windows. This happens when the stack is becomes filled. The culprits are AGI itself (in the case with Pimp Quest because it is filling around a brushed object in the title screen.. so there's lots of little lines to fill up and all these lines get pushed onto stack) and Windows. I'm not quite sure, but I think Windows has some sort of timer running in DOS mode that is called and pushes a bit too much on the stack.

So while the picture fill routine has a lot of information pushed onto the stack, Windows pushes some extra stuff on and the stack overflows. AGI actually checks if the head of the stack is overwritten and so trips this stack error in the middle of a screen write.

 

Solutions

  1. Don't create a stack heavy picture.

    Don't fill around brushed objects. In the Pimp Quest case, you should fill the screen first before drawing in the title with the brush. Here's the actual modified picture file.

    Stakt pimp bad.png
    Bad picture. (filled after)

    Stakt pimp good.png
    Good picture. (filled before)

  2. Don't use Windows

    You could go straight into pure DOS if you *really* wanted to. This isn't very helpful if you're using AGI Studio as your main editor.
  3. Patch the Interpreter


This is what I kinda wrote myself. I wrote a small patch program (that will only work in Windows.. I used MinGW as my compiler) that lets you change the stack size in the interpreter. It's usually 0xA00 bytes (in all interpreter's I have checked).

The cool thing about this program is that it works with all the versions of Sierra's interpreter that I have checked. (including v3!) The stack code didn't vary much over the different versions.

 

Steps

  1. Get a working AGI file. Try AGI Demo Pack 3, which is version 2.917 . There is a later v2.936 interpreter that shipped with some versions of SQ2 and KQ3.
  2. Decompress AGI executable file. Sierra encrypted their interpreters most of the time and some (like the demo pack 3) aren't encrypted. Use SUP to insert a key into SIERRA.COM/AGI.COM and the ADECRYPT to decrypt the AGI file.
  3. Run STACKPATCH.EXE. The proper way to run it is:

STACKPATCH AGI.EXE 0xA00 where AGI.EXE is the interpreter and 0xA00 is the stack size to change. 0xA00 is the AGI default. If you get a stack error, try increasing it to 0xB00 or 0xC00

  1. Play with your working game.

Anyway, if you want more information, check out this discussion that had all this information (except about the patch) and probably a bit more.

 

Files

stackpatch try this stuff man
modified agi 2.936 with stack set to 0xC00. Works with Pimp Quest on my computer.
modified picture file for the title

 

Tutorials and Guides Table of Contents