FB II Compiler

PG PRO

Debugging

Memory

System

Mathematics

Resources

Disk I/O

Windows

Controls

Menus

Mouse

Keyboard

Text

Fonts

Drawing

Sound

Clipboard

Printing

Communication

ASM

Made with FB

DRAWING

Build a GWorld according to available memory


I had a problem whereby I wanted to create the largest possible gWorld to hold an offscreen map of something like 4000 x 4000 pixels. I eventually ended up by allocating the program something like 30Megs to run in. Once I had done this, I was able to check the free memory available within my partition at runtime, and then set the gWorld to match after I'd checked the colour depth in use.

If it's of any use to anyone this is the function I use :

' Get GWorld Co-ords
'
'
CLEAR LOCAL
  DIM Twelfth!,Sqrt!
LOCAL FN GetGWorldSize
  gAvailMem& = MEM(-1)
  gContingency! = gAvailMem& / 20
  gAvailMem& = gAvailMem& - gContingency!)
  Twelfth! = gAvailMem& / 12
  Sqrt! = SQR(Twelfth!)
  gGWorldX! = INT(Sqrt! * 4):'Sets 4 x 3 aspect ratio to match the screen
  gGWorldY! = INT(Sqrt! * 3)
  LONG IF SYSTEM(_crntDepth) > 8:'allow for 32K colours
    gGWorldX! = gGWorldX! / 2
    gGWorldY! = gGWorldY! / 2
  END IF
  IF gGWorldX! > 4000 THEN gGWorldX! = 4000
  IF gGWorldY! > 4000 THEN gGWorldY! = 4000
END FN

PMY