English Amiga Board


Go Back   English Amiga Board > Coders > Coders. Language > Coders. Blitz Basic

 
 
Thread Tools
Old 17 February 2021, 00:07   #1
Havie
Registered User
Havie's Avatar
 
Join Date: Mar 2012
Location: UK
Posts: 1,217
Out of Stack Space Error

Hi - so have discovered I have a game killing error - out of stack space.

At first I thought it might be because I am jumping out of for next loops and I read the manual that said I needed to pop for if this is the case. I have found them all I think.

Does anyone know what else might cause this error so I can root it out! Have checked a much earlier version of my Space Invaders and I still get the error so it's been there for a while but only shows itself if you play the game through a few times.

Thanks in advance for any help you can offer.
Havie is offline  
Old 17 February 2021, 10:12   #2
Daedalus
Registered User

Daedalus's Avatar
 
Join Date: Jun 2009
Location: Dublin, then Glasgow
Posts: 5,313
I've never run into it myself - are you doing any sort of recursion? Jumping with Gosub without returns? Jumping out of a Select block without returning? It sounds like something's not happening in the right order, and you're just building a massive stack without clearing it.
Daedalus is offline  
Old 17 February 2021, 14:24   #3
Havie
Registered User
Havie's Avatar
 
Join Date: Mar 2012
Location: UK
Posts: 1,217
Thanks - that's what I am think. Error doesn't even appear int he Blitz manual that I have! No selects but some gosubs (sorry bit old school as learnt to program from the ZX Spectrum manual).

I'll have to work my way slowly through the code - it's something that has always been there so I may be able to go back to earlier (less spaghetti) code to hunt it out!
Havie is offline  
Old 17 February 2021, 15:29   #4
DamienD
Banned
DamienD's Avatar
 
Join Date: Aug 2005
Location: London / Sydney
Age: 44
Posts: 20,378
I'm sure I had this when looking at Brick Nash's Streets of Rage.

...nope, just checked, it was:

Quote:
Originally Posted by DamienD View Post
  • Kept getting errors about "variable buffer to small" when testing, had to increase to "300000".
Ooops, and that was AMOS; not Blitz Basic
DamienD is offline  
Old 17 February 2021, 15:46   #5
Daedalus
Registered User

Daedalus's Avatar
 
Join Date: Jun 2009
Location: Dublin, then Glasgow
Posts: 5,313
There's nothing wrong with a Gosub (or even a Goto, for that matter) if it's used responsibly and with good reason They're a bit old skool and can lead to difficult to debug situations, weird bugs and tricky to follow code, but they're also faster than using functions, and in game terms on stock hardware, that speed difference can be important.

Make sure every Gosub is terminated with a Return, and that if you leave the Gosub for anything, you Return back into it before Returning to the previous point. If you really need to, you can Pop out of a Gosub stack, but I think such a situation could easily be handled some other way.
Daedalus is offline  
Old 17 February 2021, 15:52   #6
Havie
Registered User
Havie's Avatar
 
Join Date: Mar 2012
Location: UK
Posts: 1,217
Quote:
Originally Posted by DamienD View Post
I'm sure I had this when looking at Brick Nash's Streets of Rage.

...nope, just checked, it was:


Ooops, and that was AMOS; not Blitz Basic
Good try!
Havie is offline  
Old 17 February 2021, 15:52   #7
Havie
Registered User
Havie's Avatar
 
Join Date: Mar 2012
Location: UK
Posts: 1,217
Quote:
Originally Posted by Daedalus View Post
There's nothing wrong with a Gosub (or even a Goto, for that matter) if it's used responsibly and with good reason They're a bit old skool and can lead to difficult to debug situations, weird bugs and tricky to follow code, but they're also faster than using functions, and in game terms on stock hardware, that speed difference can be important.

Make sure every Gosub is terminated with a Return, and that if you leave the Gosub for anything, you Return back into it before Returning to the previous point. If you really need to, you can Pop out of a Gosub stack, but I think such a situation could easily be handled some other way.
Thanks - will track them all through...
Havie is offline  
 


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Similar Threads
Thread Thread Starter Forum Replies Last Post
how can I save some stack space? litwr Coders. General 2 18 September 2020 19:47
[Found: Space Baller] Bouncing ball in space? Kada Looking for a game name ? 23 06 April 2018 03:10
Space Quest : Read Write error coze project.Killergorilla's WHD packs 1 20 July 2015 12:39
How much stack space do we need? AGS Coders. System 3 18 March 2015 17:00
ERROR: Plan 9 from Outer Space (Illegal Instruction) Dwyloc project.Killergorilla's WHD packs 1 26 July 2009 12:51

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 20:42.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2021, vBulletin Solutions Inc.
Page generated in 0.13019 seconds with 15 queries