out of memory problems working in basic (Development Foros MSX)MSX Resource Center            
                       
English Nederlands Espa�ol Portugu�s Russian                  
 Noticias
   Página principal
  Almacén de noticias
  Temas de noticias

 Recursos
   Foros MSX
  Artículos
  Analisis
  Informe de ferias/RUs
  Álbum de fotos
  Ferias y encuentros
  Encuestas
  Enlaces
  Buscar

 Software
   Descargas
  Tienda Online

 MRC
   Quiénes somos
  Únete a nuestro equipo
  Donar
  Políticas
  Contacta con nosotros
  Enlázanos
  Estadísticas

 Buscar
 
  

  

 Login
 

Login

Contraseña




¿Aún no tienes una cuenta? ¡Conviértete en miembro del MSX Resource Center! ¡Únete a nosotros!.


 Estadísticas
 

Hay 52 invitados y 1 miembro en línea

Eres un usuario anónimo.
 

Foros MSX


Foros MSX

Development - out of memory problems working in basic

Ir a la página ( 1 | 2 Siguiente página )
Autor

out of memory problems working in basic

norakomi
msx professional
Mensajes: 861
Publicado: Febrero 08 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
Mensajes: 618
Publicado: Febrero 08 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
Mensajes: 861
Publicado: Febrero 08 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
Mensajes: 618
Publicado: Febrero 08 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
Mensajes: 284
Publicado: Febrero 08 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
Mensajes: 861
Publicado: Febrero 08 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
Mensajes: 618
Publicado: Febrero 08 2005, 12:31   
Not everything in separate files.. just stuff that is not needed at the same time
wolf_

msx legend
Mensajes: 4780
Publicado: Febrero 08 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
Mensajes: 3020
Publicado: Febrero 08 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
Mensajes: 839
Publicado: Febrero 08 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
Mensajes: 839
Publicado: Febrero 08 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
Mensajes: 1225
Publicado: Febrero 08 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
Mensajes: 1528
Publicado: Febrero 08 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
Mensajes: 3545
Publicado: Febrero 08 2005, 17:04   
For tips regarding NestorBasic: see http://www.mccw.aktu.nl issue 93
[D-Tail]

msx guru
Mensajes: 3020
Publicado: Febrero 08 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
 
Ir a la página ( 1 | 2 Siguiente página )
 







(c) 1994 - 2008 Fundación MSX Resource Center. MSX es una marca registrada de MSX Licensing Corporation