' An audible tone (BEEP) will be heard if command is configured improperly and a value of 0 returned to indicate the command did not complete successfully.
'
' usage:
' value = SL_LAYER(x, SL_DEST) set layer x as destination returns -1 if command completed successfully, 0 otherwise
' value = SL_LAYER(SL_GET, SL_DEST) return the value of current destination layer returns the value of the destination layer, 0 if no destination found
' value = SL_LAYER(x, SL_SOURCE) set layer x as the source returns -1 if command completed successfully, 0 otherwise
' value = SL_LAYER(SL_GET, SL_SOURCE) return the value of the current source layer returns the value of the source layer, 0 if no source found
' value = SL_LAYER(x, SL_CLS) clear layer x returns -1 if command completed successfully, 0 otherwise
' value = SL_LAYER(SL_ALL, SL_CLS) clear all layers returns -1 if command completed successfully, 0 otherwise
' value = SL_LAYER(x, SL_VALID) return either -1 or 0 depending on layer x being valid returns -1 if layer is valid, 0 if layer is invalid
' value = SL_LAYER(x, SL_VISBILE) set layer x as visible ' returns -1 if command completed successfully, 0 otherwise
' value = SL_LAYER(SL_ALL, SL_VISIBLE) set all layers as visible returns -1 if command completed successfully, 0 otherwise
' value = SL_LAYER(x, SL_INVISIBLE) set layer x as invisible returns -1 if command completed successfully, 0 otherwise
' value = SL_LAYER(SL_ALL, SL_INVISIBLE) set all layers as invisible returns -1 if command completed successfully, 0 otherwise
' declare global variables
SHARED SL_layers
() AS SL_LAYERS
' master layer array SHARED SL_global
AS SL_GLOBAL
' common globals array
' declare local variables
DIM temp
AS LONG ' temp source/destination iamge
IF (layer
<> SL_ALL
) AND (layer
<> SL_GET
) THEN ' was a layer value supplied? CASE SL_DEST
' (0) get or set destination layer IF layer
= SL_GET
THEN ' retrieve current destination layer? SL_LAYER = SL_global.destination ' yes, report current destination layer
ELSE ' no, a layer value was supplied _DEST SL_layers
(layer
).image
' set destination as layer software image SL_layers(layer).dest = -1 ' mark this layer as the destination
SL_global.destination = layer ' save destination layer in global settings
SL_LAYER = -1 ' report that command executed correctly
CASE SL_SOURCE
' (1) get or set source layer IF layer
= SL_GET
THEN ' retrieve current source layer? SL_LAYER = SL_global.source ' yes, report current source layer
ELSE ' no, a layer value was supplied _SOURCE SL_layers
(layer
).image
' set source as layer software image SL_layers(layer).source = -1 ' mark this layer as the source
SL_global.source = layer ' save source layer in global settings
SL_LAYER = -1 ' report that command executed correctly
CASE SL_CLS
' (2) clear layer(s) temp
= _NEWIMAGE(1, 1, 32) ' great a temp image for source / destination IF layer
= SL_ALL
THEN ' clear all layers? _SOURCE temp
' yes, make temp image the current source _DEST temp
' make temp image the current destination DO ' cycle through all layers count = count + 1 ' increment layer counter
_FREEIMAGE SL_layers
(count
).image
' remove current layer from memory SL_layers
(count
).image
= _NEWIMAGE(SL_global.swidth
, SL_global.sheight
, 32) ' create new layer image IF SL_global.source
= count
THEN _SOURCE SL_layers
(count
).image
' set it back to source if necessary IF SL_global.destination
= count
THEN _DEST SL_layers
(count
).image
' set it back to destination if necessary SL_LAYER = -1 ' report that command executed correctly
ELSE ' no, just clear one layer IF SL_global.source
= layer
THEN _SOURCE temp
' make temp image the source if necessary IF SL_global.destination
= layer
THEN _DEST temp
' make temp image the destination if necessary _FREEIMAGE SL_layers
(layer
).image
' remove currentl layer from memory SL_layers
(layer
).image
= _NEWIMAGE(SL_global.swidth
, SL_global.sheight
, 32) ' create new layer image IF SL_global.source
= layer
THEN _SOURCE SL_layers
(layer
).image
' set it back to source if necessary IF SL_global.destination
= layer
THEN _DEST SL_layers
(layer
).image
' set it back to destination if necessary SL_LAYER = -1 ' report that command executed correctly
CASE SL_VALID
' (3) check for valid layer SL_LAYER = -1 ' yes, report that this is a valid layer
CASE SL_VISIBLE
, SL_INVISIBLE
' (4, 5) make layer(s) (in)visible IF action
= SL_VISIBLE
THEN visibility
= -1 ' determine visibility setting IF layer
= SL_ALL
THEN ' change visibility of all layers? DO ' cycle through all layers count = count + 1 ' increment layer counter
SL_layers(count).visible = visibility ' change visibility of layer
SL_LAYER = -1 ' report that command executed correctly
ELSE ' no, change visibility of one layer SL_layers(layer).visible = visibility ' change visibility of layer
SL_LAYER = -1 ' report that command executed correctly
BEEP: SL_LAYER
= 0 ' report that command did not execute correctly