Cfs Operations

Setscale - Model File Scaling Utility
Version 1.0.9

This utility sets the scaling value for an aircraft Model file. It is designed as one solution to the small sized nature of add-on aircraft in Cfs.

It searches for a specific sequence of BGL instructions in the Model file and, having found that sequence, updates a 16 bit value which controls scaling. This latest version accounts for BGL changes made by the animator program.

There are two versions of Setscale: the original, console-mode program and a Windows graphical program. Both are included in the download package.

The Windows version of Setscale, Setscalew, allows you to open an Aircraft “container”, in example, one of the aircraft you’ve already installed in CFS, by using the “Aircraft…” button. Or, you can open a Model file anywhere on your system by using the “Mdl…” button. You can specify the name of a Model file as an argument to Setscalew and you can even use “Drag and Drop” to load a file.

The Setscalew main window and the “Open Aircraft” dialog are resizable and can be moved anywhere on your desktop.

Quick Start - Console Version

To use Setscale, simply change to the Model directory of the aircraft you want to modify and run the program, specifying the name of the .MDL file. For example:

C:\>cd [CFS Directory]\Aircraft\Foo\Model
C:\>Setscale FOO.MDL

Quick Start - Windows Version

To use Setscalew, simply run the program. You may open an aircraft container, in example an aircraft which has been installed into Cfs, by clicking the "Aircraft..." button. As an alternative, you may open a Model file anywhere on your system by using the "Mdl..." button.

Setscalew is Drag and Drop enabled and also accepts the name of a Model file as an argument to the program at start time.

Once you've opened a Model file, you may enter a new Scale value and click the "Update" button to effect the change.

To quit Setscalew, click the "Quit" button, or press the ESC key.

Details

Setscale works with two types of Model files: standard FS98 type files which all appear to be 71680 bytes large, along with Model files which have been constructed to support "moving parts". I have only two of this latter type on my system and, although they are both 101376 bytes large, this size could be variable.

For that reason, Setscale does not concern itself with the size of the Model file. Instead, it works with two other observations: FS98 type Model files have the BGL code loaded into a binary resource, while the "moving parts" Model files, (and the CFS Model files), have their BGL code loaded into the module's .data section.

With this in mind, Setscale first locates and scans a Model file's Resource section and, if that scan fails to locate the appropriate BGL code, it then scans the Model file's .data section.

Once the BGL code is located, it is validated against a sequence of instructions that has been observed to be consistant across all of the Model files tested. That sequence of instructions is:

BGL                           ;; 76 instruction. 
VPOSITION FF84, 0, 12, 0, 4   ;; 3A instruction. 
VFILE_MARKER 64               ;; 8E instruction. 
IFMSK 2A, 68, 8002            ;; 39 instruction. 
BGL_CALL 003A                 ;; 23 instruction. 
VPOSITION FF68, 0, 12, 0, 4   ;; 3A instruction. 
SUPER_SCALE FF5C, 0, 0, 7     ;; 34 instruction. 
VINSTANCE_CALL 004C, 001C     ;; 3B instruction. 
BGL_RETURN                    ;; 22 instruction. 

Only the opcodes are validated.

If the sequence is validated, Setscale begins the update process. The update involves a second validation of the opcodes, but only up to and including the SUPER_SCALE instruction. Once this instruction is found and validated, it's fourth parameter is updated to the specified value, or the Setscale default of Nine.

Before operating on a Model file, Setscale creates a backup copy of the file using the following naming convention:

Mdlbasename.Zyyyymmddhhmmss.MDL

where "yyyymmddhhmmss" is the date and time when the utility began to process the specified file. For example, given a Model file called:

FOO.MDL

a backup file would be created that looks something like this:

FOO.Z19990520082359.MDL

The "Z" in the timestamp is designed to keep the backup file lower in the collating sequence than the original file. This should ensure that the original file always appears first in a standard directory listing. The .MDL file extension is retained to allow Model files to be quickly and easily changed by simply editing the MODEL.CFG file.

Setscale is designed to remove this backup file if processing fails for any reason.

When Setscale operates on a Model file, it does not operate on the original file. Instead, a temporary file is created and the contents of the Model file is copied onto it. Setscale then operates only on this temporary file and, if the update is successful, copies the contents of the temporary file onto the original. The temporary file is designed to be removed under all circumstances.

Setscale has been tested on Windows NT Version 4 with SP5, Windows NT Version 5 Beta 3, Windows 95 OSR2 and Windows 98.

Finally, although every effort has been made to make Setscale as robust and error free, such perfection in software is inpractical. As a result, you should ALWAYS BACKUP the aircraft container before using Setscale against the Model file.

Usage/Help

Usage: Setscale [-nologo] [-hvx?] [-s Scale] Mdlfile [Mdlfile ...]

Options:

  • h - Help, (this)
  • s - Specify the scale value to set. Default is 9.
  • v - View Only. View the current scale without updating it.
  • x - Debug. Emit [numerous] debug messages.
  • ? - Usage.
  • nologo - Don't display copyright information.
  • Scale - The scale value to set for the SUPER_SCALE instruction.
  • Mdlfile - The name of the Model file to modify.

With no parameters, other than the name of a Model file, Setscale adjusts the scale in the specified Model file to the [default] value "9".

The "-s" option can be used to specify a different scale, which must be in the range [0..16].

A backup copy of the original Model fileis created using a name built in the following format:

Mdlbasename.Zyyyymmddhhmmss.MDL

where "yyyymmddhhmmss" is the date and time when the utility began to process the specified file.

Installation

Copy the files included in the download package into a directory listed in the %Path% Environment variable, the Windows directory, the Windows\Command directory or the Windows\System directory.

Download!
 
Home
News
Missions
Campaigns
Gauges
Scenery
Modules
Reference
Links

 

Copyright © 1999-2003 Bill Potvin, II. All rights reserved.
All specifications subject to change without notice.
All items available for download from this site are copyrights of their respective authors.
Items may not be redistributed without the permission of the author.
Products and companies referred to herein are trademarks or registered trademarks of their respective companies or mark holders.