out of memory problems working in basic (Development MSX Fora)MSX Resource Center PassionMSX MSX2 contest           
            
English Nederlands Español Português Russian         
 Nieuws
   Voorpagina
  Nieuws archief
  Nieuws onderwerpen

 Informatie
   MSX Fora
  Artikelen
  Recensies
  Beursverslagen
  Fotoreportages
  Beurzen en meetings
  Enquêtes
  Links
  Zoek

 Software
   Downloads
  Webshop

 MRC
   Wie we zijn
  Kom bij ons team
  Doneren
  Policies
  Contact met het MRC
  Link naar Ons
  Statistieken

 Zoek
 
  

  

 Login
 

Gebruikersnaam

Wachtwoord




Ben je nog niet lid? Klik hier en word MSX vriend!


 Statistieken
 

Er zijn 60 gasten en 3 MSX vrienden online

Je bent een anonieme bezoeker.
 

MSX Fora


MSX Fora

Development - out of memory problems working in basic

Ga naar pagina ( 1 | 2 Volgende pagina )
Schrijver

out of memory problems working in basic

norakomi
msx professional
Berichten: 861
Geplaatst: 08 Februari 2005, 10:43   
I have been working on my latest project.
A game completely in basic (msx2) using software sprites (copy paste).
No sprites.
I use a lot of variables and a lot of if, then, else statements.
What i also use is nbasic.
I used to use xbasic, but after I got too many errors (randomly??)
I shitched to nbasic.

Now after a couple of hundred programlines I get a
out of memory error.

Can somebody help me with this?
Is this because of nbasic, because of the amount of variables I use,
And, more important:

Is there a way to utilize more memory somehow,
or clear a lot of un-used memory?

W/programmin´luv,
Thanx
msd
msx professional
Berichten: 612
Geplaatst: 08 Februari 2005, 10:54   
Can you split parts of the code to different files? For example make a different file with init code and such.
norakomi
msx professional
Berichten: 861
Geplaatst: 08 Februari 2005, 11:04   
could you give a little example?
because I dont know how to do this....
and i must say, my programm is not at all big,
maybe 300 lines.....
msd
msx professional
Berichten: 612
Geplaatst: 08 Februari 2005, 11:06   
you can use load"file.bas" in your code to load a new bas file. So code is replaced by new loaded file. Thus needing less memory
Imanok
msx addict
Berichten: 283
Geplaatst: 08 Februari 2005, 12:01   
Don't measure the length of your program depending on the number of lines, but on the kb's. You'd better not make turbo-blocks bigger than 8Kb.
norakomi
msx professional
Berichten: 861
Geplaatst: 08 Februari 2005, 12:21   
splitting my game into more than one file is gonna be crazy.

example.
I started making a gradius kinda like game.

I dont have music or background yet.
I have 2 diferent types of enemies.
so far the ship can shoot, kill enemies and get hit and die.

After the first enemy has passed
the second one comes.

Then there is an out of memory.
So it would be insane to load a new file every 20 seconds in the game !
msd
msx professional
Berichten: 612
Geplaatst: 08 Februari 2005, 12:31   
Not everything in separate files.. just stuff that is not needed at the same time
wolf_
online

msx legend
Berichten: 4712
Geplaatst: 08 Februari 2005, 12:32   
Quote:

I dont have music or background yet.
I have 2 diferent types of enemies.
so far the ship can shoot, kill enemies and get hit and die.



and you need ~300 lines for that ?? How long are those lines? One command orso, or multiple stuff (like in the listings of the old msx magazines) ?
[D-Tail]

msx guru
Berichten: 3017
Geplaatst: 08 Februari 2005, 13:39   
norakomi: how about using NestorBASIC instead of XBASIC?

XBASIC uses about 12kB of normal BASIC memory, NBASIC only 700 bytes , it will surely solve your problem, at least my (big) programs work that way
DarQ
msx professional
Berichten: 836
Geplaatst: 08 Februari 2005, 14:14   
with nestorBasic i had the experience that the code must not be larger than 6kb.. very unfortunate. but the compiler needs to store the stuff somewhere.
there are a few things to gain just a littel bit more ram but that wont help too much.
DarQ
msx professional
Berichten: 836
Geplaatst: 08 Februari 2005, 14:18   
btw: a way to minimise the ammount of ram used ( use fre(0) to determine how much i used (must not be below eeehm IIRC 12000))

- NO REMARKS
- as many commands on 1 line
- NO SPACES
- TINY varnames
- maxfiles = 0

its all about keeping the sources as small as possible is my experience with nbasic.

becasue of the things about, the main source of the last game i coded is 90 lines of garbage too the eye. even i have difficulties to read it now. but hey, you want to use nbasic dont you
flyguille
msx master
Berichten: 1202
Geplaatst: 08 Februari 2005, 15:32   
i thinks this is other kind of problem

from my experience...

1... NOT USE A LOT OF "DATA ..." statements, instead that, use BINS loaded with BLOAD.

2... make sure that all subroutines called with "GOSUB..." exits in all its exit points with RETURN..... <---- about that i remember a frustrant "out of memory" programming an arkanoid type game.

3.... make sure that all your FOR .. TO.. sentences, exits with NEXT sentences, because if not, you makes bigger the FOR/NEXT STACK.

and this question for the MSXBASIC geeks......

when i programmed in BASIC, i have the need to exit the bucle FOR/NEXT conditionaly BY example:

FOR I=10 to 1 step -1
if STRIG(pl) then 2000
NEXT I

now the question, this will increase the FOR/NEXT stack?

exists a safe way to exit from a bucle like that without increasing the FOR/NEXT stack?

NYYRIKKI
msx master
Berichten: 1509
Geplaatst: 08 Februari 2005, 16:00   
I'll continue a bit, but it is hard to give good ideas, without seeing the source.

- Avoid using string variables
- DEFINT A-Z if possible (save memory & get more speed)
- Check, that your table variables are correct size
- ERASE tables you don't use anymore.
- Check your CLEAR command if it is used.
- Split your turbo blocks, if possible.
- Using DOS2 will give you about 3KB more space.
- Check, if N-BASIC functions 55-57 are usefull for you.
- Try Nestorpreter

The BASIC memory is about 23KB, in that space you have your tokenized BASIC program, variables, compiled turbo block and possible custom allocated space.

AFAIK unlike D-Tail said, N-BASIC uses more BASIC memory than X-BASIC.

manuel
msx guru
Berichten: 3447
Geplaatst: 08 Februari 2005, 17:04   
For tips regarding NestorBasic: see http://www.mccw.aktu.nl issue 93
[D-Tail]

msx guru
Berichten: 3017
Geplaatst: 08 Februari 2005, 23:55   
NYYRIKKI: NBASIC does indeed use more memory, but that memory was inaccessible anyway using XBASIC. NBASIC uses less BASIC program memory. That's what you want, so your program can be somewhat bigger.

Flyguille: wrap the FOR/NEXT in a GOSUB and BE SURE to return from that subroutine. Any bytes allocated at the stack for the FOR/NEXT will be released as well.

Best thing while programming is to use array vars (like V(0) to V(31) or so) and array strings (F$(0);F$(1) are special to NBASIC, but F$(2) to F$(~) can be used freely). Next advice: get NPR, at www.konamiman.com
 
Ga naar pagina ( 1 | 2 Volgende pagina )
 







(c) 1994 - 2008 Stichting MSX Resource Center. MSX is een trademark van MSX Licensing Corporation.