Difference between revisions of "Stack Overflow Information"

From AGI Wiki
Jump to navigationJump to search
 
(10 intermediate revisions by the same user not shown)
Line 1: Line 1:
[[AGI Tutorials|Tutorials Table of Contents]]<br />
+
[[Tutorials and Guides|Tutorials and Guides Table of Contents]]<br />
  
 
<div align="center">Creating AGI Stack Overflow Information<span style="font-size: 22pt"></span><br />
 
<div align="center">Creating AGI Stack Overflow Information<span style="font-size: 22pt"></span><br />
Line 9: Line 9:
 
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.
 
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.
+
So while the [[SBuffPicFill|picture fill routine]] has a lot of information pushed onto the stack, Windows pushes some extra stuff on and the stack overflows. AGI actually [[VectSysTimer|checks]] if the head of the stack is overwritten and so trips this stack error in the middle of a [[EGAPutBlock|screen write]].
  
 
&nbsp;
 
&nbsp;
 
== Solutions ==
 
== Solutions ==
  
# Don't create a stack heavy picture.<br /><br />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.<br /><br />[[File:stakt_pimp_bad.png]]<br />''Bad picture. (filled after)''<br /><br />[[File:stakt_pimp_good.png]]<br />''Good picture. (filled before)''<br /><br />
+
# Don't create a stack heavy picture.<br /><br />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 [[agi:Stack/Picture_50.zip|modified picture file]].<br /><br />[[File:stakt_pimp_bad.png]]<br />''Bad picture. (filled after)''<br /><br />[[File:stakt_pimp_good.png]]<br />''Good picture. (filled before)''<br /><br />
 
# Don't use Windows<br /><br />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.
 
# Don't use Windows<br /><br />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.
 
# Patch the Interpreter
 
# Patch the Interpreter
Line 35: Line 35:
 
Anyway, if you want more information, check out this [http://ub1.homepagetools.com/agiboard/UltraBoard.pl?Action=ShowPost&Board=agipublic&Post=207&Idle=90&Sort=0&Order=Descendpage0&Session= discussion] that had all this information (except about the patch) and probably a bit more.
 
Anyway, if you want more information, check out this [http://ub1.homepagetools.com/agiboard/UltraBoard.pl?Action=ShowPost&Board=agipublic&Post=207&Idle=90&Sort=0&Order=Descendpage0&Session= discussion] that had all this information (except about the patch) and probably a bit more.
  
Files:
+
&nbsp;
 +
== Files ==
 +
 
 +
[[agi:Stack/AGI_Stack_Overflow_Patch_(STACKPATCH10).zip|stackpatch]] try this stuff man<br />
 +
[[agi:Interpreters/Sierra/Sierra_AGI_Interpreter_v2_936.zip|modified agi 2.936]] with stack set to 0xC00. Works with Pimp Quest on my computer.<br />
 +
[[agi:Stack/Picture_50.zip|modified]] picture file for the title
 +
 
 +
&nbsp;
  
[[agi:Stack/AGI_Stack_Overflow_Patch_(STACKPATCH10).zip|stackpatch]] try this stuff man
+
[[Tutorials and Guides|Tutorials and Guides Table of Contents]]
[[agi:Interpreters/Sierra/Sierra_AGI_Interpreter_v2_936.zip|modified agi 2.936]] with stack set to 0xC00. Works with Pimp Quest on my computer.
 
[[agi:Stack/Picture_50.zip|modified]] PIC file for the title
 
  
 
&nbsp;
 
&nbsp;
Line 45: Line 50:
 
[[Category:Debugging]]
 
[[Category:Debugging]]
 
[[Category:Stack]]
 
[[Category:Stack]]
 +
[[Category:Memory]]
 +
[[Category:AGI Picture Resources]]

Latest revision as of 12:36, 24 March 2019

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