PDA

View Full Version : Re: Passing variables to library object BGL



cloudandy
08-27-2001, 11:07 AM
Hi Andreas,
I have read (and printed) Your SCASM macros tutorial on combatflight.de and You


mentioed there is some peculiar way to send variables to BGL library objects.
Can You give me a tip how to do it? I wan to make a BGL with houses, and I
would like to send parameters 6 and 7 (texture names) to BGL.
Many thanks
Goran

Hello Goran

If you download my car library macro package (kcarlib.zip), you can read
the calling api macro calling the library. There you can read how this is
done. I am using this here to define color textures to be used, without
having to repeat the total object code several times in the library.
It is using a local varbase. This is the calling macro:

;-----------------------------------------------------------

Area( 5 %1 %2 %3 )
IfVarRange( : 346 %12 5 )
PerspectiveCall32( :Persp )
Jump32( : )

:Persp


RefPoint( 3 :EndC %1 %2 E= %11 v1= %10 v2= 6 )
;RefPoint 2 or 7 are also possible

SetScaleX( :EndC 0 0 9 )
;setting binary scale factor, improving visibility

RotatedCall( :objcall 0 0 %5 )
;rotates object to user preset

:EndC
Return

:objcall

;-------------------------------------

;now a local varbase is generated

Jump32( :past )
;do not forget this passing instruction!!!

:TEMPVAR

;writes offsets 0,2,4 to varbase defined below

Dwx( 0 0 0 )


:past
;passing by label


VarBase( :TEMPVAR )
;initializes the local varbase with indices generated in TempVar label


;the following lines set the color code depending on the
;user's presets in %6
;the local var 0 is read by the library object
;it determines which texture will be loaded
Mif( [%6==0] );red
SetVar( 0 0 )
Mifend
Mif( [%6==1] );cherry
SetVar( 0 1 )
Mifend
Mif( [%6==2] );blue
SetVar( 0 2 )
Mifend
Mif( [%6==3] );green
SetVar( 0 3 )
Mifend
Mif( [%6==4] );black
SetVar( 0 4 )
Mifend
Mif( [%6==5] );cyan
SetVar( 0 5 )
Mifend
Mif( [%6==6] );silver
SetVar( 0 6 )
Mifend
Mif( [%6==7] );white
SetVar( 0 7 )
Mifend
Mif( [%6==8] );copper
SetVar( 0 8 )
Mifend
Mif( [%6==9] );yellow
SetVar( 0 9 )
Mifend



Low64k2var( 2 33B )
;imports content of global var 33B (shortest distance aircraft to RefPoint)
;to the local var 1 for usage in the library object

Mif( [%7==1] );performing light switch from user parameter %7
SetVar( 4 1 )
Mifend


CallLibObj( 0 7756FD53 6B630469 22F15AC3 D336CC28 )
;calls library object with hex code 7756FD53 6B630469 22F15AC3 D336CC28
;from carlib.bgl
;this bgl must have been installed!
;do not use this id for your own library! Every id code must be unique




Varbase( :[-1] )
;terminates the local varbase

Return
:EndP
;end of lib object call
EndA
;------------------------------------------------------------

The library then can read the local variables and apply e.g. colors.

Example:
IfVarAnd( :red 0 F )
IfVarAnd( :green 0 D )

;... and so on

:red
LoadBitmap( ... carred.bmp)
Return

:green
LoadBitmap( ...cargreen.bmp )
Return

;and so on


Note that the bitmasking in IfVarAnd works upside down, you must ask for
"F" (hex) if you want to test for "0" (zero). Read the section in my tutorial.


Good luck

Andreas

gorchi
08-27-2001, 03:37 PM
Andreas,
Many thanx!
Goran



Hi Andreas,
I have read (and printed) Your SCASM macros tutorial on combatflight.de and You




mentioed there is some peculiar way to send variables to BGL library objects.
Can You give me a tip how to do it? I wan to make a BGL with houses, and I
would like to send parameters 6 and 7 (texture names) to BGL.
Many thanks
Goran

Hello Goran

If you download my car library macro package (kcarlib.zip), you can read
the calling api macro calling the library. There you can read how this is
done. I am using this here to define color textures to be used, without
having to repeat the total object code several times in the library.
It is using a local varbase. This is the calling macro:

;-----------------------------------------------------------

Area( 5 %1 %2 %3 )
IfVarRange( : 346 %12 5 )
PerspectiveCall32( :Persp )
Jump32( : )

:Persp


RefPoint( 3 :EndC %1 %2 E= %11 v1= %10 v2= 6 )
;RefPoint 2 or 7 are also possible

SetScaleX( :EndC 0 0 9 )
;setting binary scale factor, improving visibility

RotatedCall( :objcall 0 0 %5 )
;rotates object to user preset

:EndC
Return

:objcall

;-------------------------------------

;now a local varbase is generated

Jump32( :past )
;do not forget this passing instruction!!!

:TEMPVAR

;writes offsets 0,2,4 to varbase defined below

Dwx( 0 0 0 )


:past
;passing by label


VarBase( :TEMPVAR )
;initializes the local varbase with indices generated in TempVar label


;the following lines set the color code depending on the
;user's presets in %6
;the local var 0 is read by the library object
;it determines which texture will be loaded
Mif( [%6==0] );red
SetVar( 0 0 )
Mifend
Mif( [%6==1] );cherry
SetVar( 0 1 )
Mifend
Mif( [%6==2] );blue
SetVar( 0 2 )
Mifend
Mif( [%6==3] );green
SetVar( 0 3 )
Mifend
Mif( [%6==4] );black
SetVar( 0 4 )
Mifend
Mif( [%6==5] );cyan
SetVar( 0 5 )
Mifend
Mif( [%6==6] );silver
SetVar( 0 6 )
Mifend
Mif( [%6==7] );white
SetVar( 0 7 )
Mifend
Mif( [%6==8] );copper
SetVar( 0 8 )
Mifend
Mif( [%6==9] );yellow
SetVar( 0 9 )
Mifend



Low64k2var( 2 33B )
;imports content of global var 33B (shortest distance aircraft to RefPoint)
;to the local var 1 for usage in the library object

Mif( [%7==1] );performing light switch from user parameter %7
SetVar( 4 1 )
Mifend


CallLibObj( 0 7756FD53 6B630469 22F15AC3 D336CC28 )
;calls library object with hex code 7756FD53 6B630469 22F15AC3 D336CC28
;from carlib.bgl
;this bgl must have been installed!
;do not use this id for your own library! Every id code must be unique




Varbase( :[-1] )
;terminates the local varbase

Return
:EndP
;end of lib object call
EndA
;------------------------------------------------------------

The library then can read the local variables and apply e.g. colors.

Example:
IfVarAnd( :red 0 F )
IfVarAnd( :green 0 D )

;... and so on

:red
LoadBitmap( ... carred.bmp)
Return

:green
LoadBitmap( ...cargreen.bmp )
Return

;and so on


Note that the bitmasking in IfVarAnd works upside down, you must ask for
"F" (hex) if you want to test for "0" (zero). Read the section in my tutorial.


Good luck

Andreas