Can a basic function call (FN) cause out of memory?
Moderator: Moderators
Can a basic function call (FN) cause out of memory?
I get an out of memory error on a line with a function call, but I still have 701 bytes left.
(t+3*i+1) is 673+3*5+1=689 at the time of the error.
It's some data I stored in USRVCTRS, a trick I read about in a previous thread.
Are there other reasons to get 'out of memory' besides actually being out of memory?
(And here a more interesting picture of the goings-on; still deeply uncertain if this is going to work out especially in the light of this error.)
(t+3*i+1) is 673+3*5+1=689 at the time of the error.
It's some data I stored in USRVCTRS, a trick I read about in a previous thread.
Are there other reasons to get 'out of memory' besides actually being out of memory?
(And here a more interesting picture of the goings-on; still deeply uncertain if this is going to work out especially in the light of this error.)
Re: Can a basic function call (FN) cause out of memory?
Yes, if you have a stack overflow. Try this for example:Witzo wrote:I get an out of memory error on a line with a function call, but I still have 701 bytes left.
(t+3*i+1) is 673+3*5+1=689 at the time of the error.
It's some data I stored in USRVCTRS, a trick I read about in a previous thread.
Are there other reasons to get 'out of memory' besides actually being out of memory?
Code: Select all
0 GOSUB 0
- Mike
- Herr VC
- Posts: 4832
- Joined: Wed Dec 01, 2004 1:57 pm
- Location: Munich, Germany
- Occupation: electrical engineer
Re: Can a basic function call (FN) cause out of memory?
Yes, there are.Witzo wrote:Are there other reasons to get 'out of memory' besides actually being out of memory?
FOR loops and GOSUBs are stored on the stack; when there are too many open FOR loops and/or nested sub-routines, even a simple expression evaluation might not have enough spare memory on the stack to complete properly.
It's quite 'difficult' to nest a lot of FOR loops, most probably you have some sub-routine in your program, which at one point doesn't return to the main program via RETURN but with GOTO. Such programming errors fill up the stack within short time.
I suspect that it's a hex-based wargame, but I am biased and tend to see all hex-based games as wargames.orion70 wrote:Hope these suggestions will help you complete the game . Are you planning to redefine characters? Any info about what the game will be about ?
"A slave is one who waits for someone to come and free him." -- Ezra Pound
You guessed right, it's a war game / turn based strategy game
I was inspired after reading this book from 1980:
http://www.librarything.com/work/1613529
It's not going to have redefined characters, since I'm not experienced in making them and I'm trying to squeeze it into the unexpanded VIC. Because I still haven't ordered a Megacart to get more memory
I haven't thought of a theme yet. So far it has three unit types with different movement points and to-hit.
I didn't want to reveal it yet as I'm not sure I'll manage to finish it, but I can't do without this forum to ask about problems I run into. And I still have a fair number of puzzles that I'm not sure I'll be able to solve... (how to make the computer player move in a sensible way, in the 650 or so bytes I have left).
But I appreciate your interest!
I was inspired after reading this book from 1980:
http://www.librarything.com/work/1613529
It's not going to have redefined characters, since I'm not experienced in making them and I'm trying to squeeze it into the unexpanded VIC. Because I still haven't ordered a Megacart to get more memory
I haven't thought of a theme yet. So far it has three unit types with different movement points and to-hit.
I didn't want to reveal it yet as I'm not sure I'll manage to finish it, but I can't do without this forum to ask about problems I run into. And I still have a fair number of puzzles that I'm not sure I'll be able to solve... (how to make the computer player move in a sensible way, in the 650 or so bytes I have left).
But I appreciate your interest!
- Mike
- Herr VC
- Posts: 4832
- Joined: Wed Dec 01, 2004 1:57 pm
- Location: Munich, Germany
- Occupation: electrical engineer
Actually, that's no reason not to use them. It's only slightly more complicated when a +8K or bigger RAM expansion is used. You need to set the BASIC start to an higher address, so the RAM 'below' your BASIC program can hold the screen memory and the character data and you still have all the room available up to the top address of the used RAM expansion. As you see, that's a method different from unexpanded or +3K, where the 'roof' is lowered, but it can be done.Witzo wrote:It's not going to have redefined characters, since I'm not experienced in making them [...]
Sigh. Do you see any realistic chance to implement the remaining game logic into the ~600 remaining bytes? Not really? It's still possible to programm for a bigger RAM expansion, taking the shifted screen and colour memory address into account. You can design the redefined graphics 'off-line' if you wish, and combine these into your game at a later stage. And why would you need a Mega-Cart to be able to write a program for expanded memory? You can always try out your program in an emulator, that should go without saying.[...] and I'm trying to squeeze it into the unexpanded VIC. Because I still haven't ordered a Megacart to get more memory
Good luck with your project, and please don't let false suppositions and unjustified fears limit your creativity.
No worries. I was already happy that I managed to make hexes and move stuff hex-wise around with a few keys to point where to go. I'm making stuff up as I go along. If I run out of memory when I'm nearly there, I already made up my mind to use the expansion in an emulator, since someday I'll order the Megacart eventually anyway. But if I can run it on the real metal as I have it available now, that would be a big bonus.
I've put this project on ice for a while.
I think I'm stuck in overflowing the stack with whatever gosubs and for-nexts I'm using.
But I've got a basic layout of what I want in this program, and hope to return to it later, possibly in assembly.
First I want to do an Android project where I'm not stuck, which, this being a hobby, is for now more rewarding
I think I'm stuck in overflowing the stack with whatever gosubs and for-nexts I'm using.
But I've got a basic layout of what I want in this program, and hope to return to it later, possibly in assembly.
First I want to do an Android project where I'm not stuck, which, this being a hobby, is for now more rewarding
What's your android project, if I can ask? I have some experience of that.
Pallas - OPByte
http://www.opbyte.it/vic20/
http://www.opbyte.it/vic20/
My newest is a calendar conversion routine, it translates today from AD to the Rastafari Tabot calendar:pallas wrote:What's your android project, if I can ask? I have some experience of that.
https://play.google.com/store/apps/deta ... ware.tabot
The interesting thing here was not the Android specifics, because it's just text, but figuring out how to get the right date in the Tabot calendar, that has differing lengths of months and a different phase for leap years.
- freshlamb
- Vic 20 Dabbler
- Posts: 76
- Joined: Sun Apr 04, 2004 5:38 pm
- Website: http://www.rufnoiz.com
- Location: Prince Albert SK Can
A bit of time away from a project sometimes will help. I know when I was working on Martain Raid (forever ago) I got stuck and had no one to ask for help, so I left it for a year or so. When I got back to it, I immediately found I was jumping out (GOTO) of a FOR-NEXT loop. I'm sure I finished quickly after that.
Fresh eyes definitely help, if you can't or don't want to get someone else involved. Hopefully you don't have to leave it for 2 years though ...
Fresh eyes definitely help, if you can't or don't want to get someone else involved. Hopefully you don't have to leave it for 2 years though ...