DQBinit
FUNCTION

Prototype

DECLARE FUNCTION DQBinit (BYVAL NumLayers, BYVAL NumSounds, BYVAL MemSize)

Parameters

NumLayers - Number of layers to allocate memory for

NumSounds - Number of sounds to allocate memory for

MemSize - Kbytes of EMS memory to preserve for custom purposes

Returns

An INTEGER value holding the initialization result. It can be: > 0 Initialization successful > 1 386 or better CPU not detected > 2 Unable to find an expanded memory manager > 3 Not enough free EMS memory to allocate specified number of layers > 4 Library has already been initialized

Description

The DQBinit function must be called before any of the other library functions. It allocates a specified number of layers, sounds and free memory into EMS, and does other initializations; remember that you can allocate as much layers as you want, and up to 256 sounds, as long as enough free memory is available, otherwise you'll get an error 3 when calling this function; the same goes for the amount of EMS for personal purposes: the limit is the amount of free EMS available on your system. The only thing you need to know is that each layer or sound takes 64KB of EMS. Also, please keep in mind that if you refer to a layer or a sound number that has not been allocated with this procedure, your system will probably crash: I mean that if you allocate 3 layers with DQBinit, you must not refer to layer 4. If you get an error 2, please refer to section 1.3 of this manual, that explains how to install EMS on your system.

Notes:

As DQBinit must be called at the beginning of your program, remember to call DQBclose at its end. Initialized layers are automatically cleared (they're filled with pixel color 0), and the sounds are reset to silence and 0 length.

Example

*****************************************************************************

' All integers for speed
DEFINT A-Z

'$INCLUDE:'DIRECTQB.BI'

' Let's initialize the library with four extra layers and no sounds nor EMS
Result = DQBinit(4, 0, 0)

' Closes DirectQB
DQBclose

' A smarter way to handle errors would be to use DQBerror$, but for clarity
' here we do it this way:
SELECT CASE Result
CASE 0
    PRINT "Initialization successful"
CASE 1
    PRINT "Error: 386 or better CPU not detected!"
CASE 2
    PRINT "Error: unable to find an expanded memory manager!"
CASE 3
    PRINT "Error: not enough free EMS memory!"
END SELECT

' Ends program
END

*****************************************************************************