STEP 4 - COMPILE the SOURCE CODE
STEP 4
COMPILE the SOURCE CODE
Compile the edited myairplane.sca file to generate a scenery object file, e.g. myairplane.bgl.

This is where you convert your edited object source code (.sca) to a scenery object file (.bgl). It's a straightforward process and the SCASM Compiler does all the work.

From the Start Menu\Programs, run "MS-DOS Prompt" to open the DOS window. You'll should see the following text:

Microsoft (R) Windows 98
   (C) Copyright Microsoft Corp 1991-1999

   C:\WINDOWS>_

SCASM 2.xx is actually a Win32 console application. While it looks like a DOS program to you, it has all the advantages of a 32-bit program, including the ability to handle long filenames.

At the prompt, use the chdir command to change the active directory to the folder containing your SCASM Compiler. In my case, it's ...

   C:\WINDOWS>chdir C:\SCASM2.88

Which results in the command line ...

   C:\SCASM2.88>_

You're now ready to compile your source code. The SCASM command line to do this has the format ...

scasm  input_file.sca  output_file.bgl    [<optional switches>]

If you're interested in the available optional switches, please read the SCASM documentation for "command line interface."

To compile your source code file myairplane.sca, enter the following command line at the DOS-prompt:

   scasm  myairplane.sca  myairplane.bgl

NOTE
Any file extension is accepted for the input file, but the file must be a pure ASCII text file. If you include an output filename, you must enter the .bgl extension for that file. If you omit an output filename, the compiler will use your input filename and change the extension to .bgl.

When you hit enter, the file is compiled and you'll see output in the DOS window similar to the following:

   C:\SCASM2.88> scasm  myairplane.sca  myairplane.bgl
     SCENERY Assembler vers. 2.88 (32)
     Copyright (C) 1995-2002 by Manfred Moldenhauer, ...
     Any unauthorized distribution prohibited

   found sections 0x00000200
   VIS SCN -> entrys:   1   mem:   94258
   Linebuffer   193006/2097152
   Maxlabels   357/1500   Maxpatches   358/2000
   Scasm compilation status:  ok

   C:\SCASM2.88>_

What you want to see is that last line of the output that says,

   Scasm compilation status:  ok

That means your edited object source code has successfully produced a scenery object file.

If you get errors during the compilation process, SCASM will list them for you. They are most often caused by unresolved labels (referring to a labelname that doesn't exist ), subroutines without a Return command, failure to include a TransformEnd command where required, and, believe it or not, misspelled words.

DESIGN

TIP
FSDS will generate the full object source code for your model, but it does leave a few items you will have to clean up.

IfInf( ) label error. If your model uses the IfInF( ) command (a new IfVarRange instruction using floating point numbers and 32 bit labels), FSDS creates a bad jump label within the command that the SCASM compiler will report as an unresolved label. In the example below, the bad label is highlighted in red.

:Part000121
IfInF( :Ret138 98 0 0 )
Jump( :GO138 )
 
:RET138
Return
 
SCASM labels are case-sensitive, so that label should be ":RET138"

Missing label in animation tables. FSDS does a good job of producing the animation tables, but it leaves out a key label that the SCASM compiler reports as an unresolved label. Here's the animation table for the left folding wing FSDS generated for Flerk's Corsair. The label problem is highlighted in red.

; Part: l_wingfold
:Part000007
Jump( :Draw007 )
; Animation Motion Table
:MotionTbl007
Dwx( 0001 )
Dr4( -1.000000 )
Dr4( 0.000000 0.000000 0.000000 0.000000 )
Dr4( 0.000000 0.000000 0.000000 0.000000 )
Dr4( 0.000000 0.000000 0.000000 0.000000 )
Dr4( 0.000000 0.000000 0.000000 0.000000 )
Dwx( 2 )
Dr4( 0.000000 0.000000 0.000000 0.000000 )
Dr4( 100.000000 0.000000 0.000000 0.000000 )
; Animation Rotation Table
:RotationTbl007
Dwx( 0003 )
Dr4( -1.000000 )
Dr4( 0.000000 0.000000 0.000000 0.000000 )
Dr4( 0.000000 0.000000 0.000000 0.000000 )
Dr4( 0.000000 0.000000 0.000000 0.000000 )
Dr4( 0.000000 0.000000 0.000000 0.000000 )
Dwx( 2 )
Dr4( 0.000000 0.000000 0.000000 0.000000 1.000000 )
Dr4( 100.000000 0.000000 0.000000 0.833886 0.551937 )
VarBase( :MotionTbl007 )
Animate( :[0] 314 1 0 0.000000 0.000000 0.000000 )
VarBase( :[0] )
VarBase( :RotationTbl007 )
Animate( :[0] 314 1 0 0.000000 0.000000 0.000000 )
VarBase( :[0] )
SetMaterial( 0 -1 )
DrawTriList( 1330
.......
 
The correction is simple. Copy the ":Draw..." label and insert it just before the line beginning "VarBase( :MotionTbl ..." The result looks like this ...

; Part: l_wingfold
:Part000007
Jump( :Draw007 )
; Animation Motion Table
:MotionTbl007
Dwx( 0001 )
Dr4( -1.000000 )
Dr4( 0.000000 0.000000 0.000000 0.000000 )
Dr4( 0.000000 0.000000 0.000000 0.000000 )
Dr4( 0.000000 0.000000 0.000000 0.000000 )
Dr4( 0.000000 0.000000 0.000000 0.000000 )
Dwx( 2 )
Dr4( 0.000000 0.000000 0.000000 0.000000 )
Dr4( 100.000000 0.000000 0.000000 0.000000 )
; Animation Rotation Table
:RotationTbl007
Dwx( 0003 )
Dr4( -1.000000 )
Dr4( 0.000000 0.000000 0.000000 0.000000 )
Dr4( 0.000000 0.000000 0.000000 0.000000 )
Dr4( 0.000000 0.000000 0.000000 0.000000 )
Dr4( 0.000000 0.000000 0.000000 0.000000 )
Dwx( 2 )
Dr4( 0.000000 0.000000 0.000000 0.000000 1.000000 )
Dr4( 100.000000 0.000000 0.000000 0.833886 0.551937 )
:Draw007
VarBase( :MotionTbl007 )
Animate( :[0] 314 1 0 0.000000 0.000000 0.000000 )
VarBase( :[0] )
VarBase( :RotationTbl007 )
Animate( :[0] 314 1 0 0.000000 0.000000 0.000000 )
VarBase( :[0] )
SetMaterial( 0 -1 )
DrawTriList( 1330
.......
 
You'll need to do this for every animation table in your model.

It's sometimes a bit tricky to clear up errors, but the SCASM documentation helps a lot.

You're halfway there. You have a good scenery file (myairplane.bgl) which contains the edited SCASM code needed to rebuild your model with animations and new effects.

Now it's on to STEP 5, where you use a hex editor to move the .bgl code from its location in the scenery file back into the model file (.mdl).

STEP 3 The Process STEP 5