[an error occurred while processing this directive]
DynPatch Manual Index SCASM support

FSASM support in DynKit 

Contents
Introduction

The DYNKIT.DEF file included in DynKit allows developing dynamic libraries with FSASM. It also allows accessing new dynamic object shapes from section 15 code.

In order to use definitions from DYNKIT.DEF, put the line

.include "dynkit.def"

into your FSASM source file after the inclusion of FSAHEAD.DEF. You can copy DYNKIT.DEF either into the DEF subdirectory of the main FSASM directory, or into the current directory.

DYNKIT.DEF was developed for FSASM 6.0.0. Newer versions of FSASM will most likely include these definitions into default precompiled headers and thus not need DYNKIT.DEF.

This document assumes knowledge of dynamic library structure.

There is an example dynamic object shape and a simple dynamic scenery made with FSASM: saucer10.fsa and saucer15.fsa.

Macros for defining dynamic library structure

DynLibHeader id0,id1,id2,id3,id4,id5,id6,id7

Defines the dynamic library BGL header. Should be used instead of .BGLHeader. DynLibHeader should normally be followed by the

.section 10

directive. The following macros should be used inside section 10.

DynLibTableEntry Label:, id0,id1,id2,id3,id4,id5,id6,id7, id8,id9,id10,id11,id12,id13,id14,id15

Defines an entry in the dynamic library table. The label should point to the BeginDynShape at the beginning of the shape.

DynLibTableEnd

Must conclude the dynamic library table.

BeginDynShape

Begins a dynamic object shape definition. A DynLibTableEntry record with the shape ID should point to BeginDynShape. The SDL code for drawing the shape must be between BeginDynShape and EndDynShape.

EndDynShape

Ends a dynamic object shape definition.

Special SDL instructions

This section describes SDL instructions often used by the code that displays dynamic object shapes but not in static sceneries.

RefPtIndirect JumpLabel:,Variable,Arg1=0,Arg2=0,Arg3=0

Sets a new reference point using latitude, longitude and altitude values stored at the memory location beginning at the given variable address. The meaning of Arg1, Arg2 and Arg3 arguments is unknown, default objects use zeroes. This instruction probably does some sort of a visibility test and performs a jump to JumpLabel: when it fails. Dynamic objects should use SetScale/SetScaleX2 for visibility tests.

ShadowRefPtIndirect Variable

Sets a reference point for the shadow of the object. The memory location beginning at the given variable address should contain latitude, longitude and altitude values of a point that is projected on the ground according to the sun position and used as the reference point.

SetScale ...
SetScaleX2 ...

Set the scale factor using a reference point defined earlier. Used for dynamic objects because indirect reference point instructions do not set the scale factor themselves. These instructions are described in the FSASM manual.

RotCallIndirect JumpLabel:,Variable

Calls a drawing routine in a rotated coordinate system using pitch, bank and heading values stored at the memory location beginning at the given variable address.

ShadowRotCallIndirect JumpLabel:,Variable

Rotates the coordinate system using pitch, bank and heading values stored at the memory location beginning at the given variable address, then projects it onto the reference point level according to the sun position in order to produce a realistic shadow. Calls the routine at JumpLabel: in a special mode that produces shadows instead of full-colored primitives. Used to display object shadows.

SurfaceColorIndirect Variable

Loads the surface color from a variable. Used to access colors set in the dynamic scenery with the DynColor instruction.

LineColorIndirect Variable

Loads the line color from a variable.

ShadedColorIndirect Variable

Loads the color for shaded polygons from a variable.

SetLocalVar Variable,Value

Sets a variable local to the dynamic object. Equivalent to SetVar.

SetGlobalVar Variable,Value

Sets a global variable. Normally used to set vCrashFlag in crash detection code. Equivalent to SetVar7E.

Special dynamic scenery instructions

This section describes section 15 instructions added in DYNKIT.DEF..

PatternDefEx Label:,VisFlag, id0,id1,id2,id3,id4,id5,id6,id7, id8,id9,id10,id11,id12,id13,id14,id15

This instruction is similar to PatternDef, but references a dynamic object by a 16-byte ID string, thus allowing accesses to dynamic libraries.

DynPositionEx GearHeignt, N, E, A

This instruction is similar to DynPosition, but requires specifying the gear height explicitly. It should be used for custom dynamic objects, where FSASM has no information about the gear height.

DynColor VarNumber, value

This instruction sets one color variable. The value for VarNumber should be between 0 and 4, which would correspond to vDynColor0..vDynColor4 in section 10 code.

Variables accessible by dynamic object shapes

This section lists FSASM names for variables local to dynamic objects.

Name Address Meaning
vDynPos 0000h Position of the current dynamic object stored as 3 64-bit values for latitude, longitude and altitude. Used in instructions like RefPtInd and ShadowRefPtInd, which require absolute locations stored in a variable.
vDynPitch 0018h Pitch, bank and heading of the current dynamic object stored as 3 32-bit values. Used in instructions like RotCallInd and ShadowRotCallInd.
vDynGear 0024h The bit 2 (AND DynGearMask) contains the gear position.
vDynTimer1 0026h Running-bit timer, similar to vTimer1 (0282h) used by static scenery.
vDynTimer2 0028h Linear timer. Runs downwards, the period is 1 second.
vDynTimer3 002Ah Linear timer. Runs downwards, the period is 0.5 seconds.
vDynExtent 002Ch Maximum shape extent from the reference point, in meters, used for automatic collision avoidance. The code that displays the object shape must set vDynExtent to a reasonable value.
vDynTexture 002Eh Texture flag for dynamic objects. Nonzero values mean texture is enabled. Reflects the aircraft texture setting in FS98.
vDynColor0 0030h These variables store values set by the DynColor instruction in section 15. They can be used as customizable colors and accessed by LineColorInd, SurfaceColorInd and ShadedColorInd instructions. Or, they can be used to control other features, like flaps or propeller rotation. DynKit uses vDynColor4 (identical with vDynFeatures) for such features.
vDynColor1 0032h
vDynColor2 0034h
vDynColor3 0036h
vDynColor4
vDynFeatures
0038h


DynKit feature constants

These constants define bits of vDynFeatures that control individual features. They match bit values used by DynKit Hangar in converted FSFS aircraft. Note that unlike other features, the landing gear is controlled by the vDynGear variable instead of vDynFeatures.

See the DynKit Hangar documentation for details on features.

Name Mask Meaning if set
DynNavLights 0100h Show navigation lights
DynStrobes 0200h Show strobes. The code that draws the object shape is responsible for the blinking effect.
DynFlaps 0400h Show flaps in the extended position.
DynSpoilers 0800h Show spoilers in the extended position.
DynPropStill
DynRotorStoll
0001h Show a propeller/rotor standing still.
DynPropSlow
DynRotorSlow
0002h Show a propeller/rotor rotating slowly.
DynPropFast
DynRotorFast
0004h Show a propeller/rotor rotating fast.


Generating ID strings

DynKit Hangar generates ID strings based on the system time and the user registration information. This reduces the risk of ID string conflicts to nearly zero. You can use DynKit Hangar to generate ID strings used in your FSASM code:

Repeat these steps for additional ID strings you need.


DynPatch Manual Index SCASM support

Copyright © 1998 by Konstantin Kukushkin