SCDIS: MSFS Scenery Disassembler for SCASM

version 1.9
copyright (C) 1996-2000 by Takuya Murakami

This document is written in English. Japanese document is here.

Introduction

Scdis is the software to decompile BGL file, which is scenery file of Microsoft Flight Simulator ver.5 later, and convert it into the source file of SCASM.

You can compile the generated source file by SCASM and re-compile BGL file.

Use for learning of technique, scenery correction and so on.

Problem of Decompilation

"De-compilers have been released for SCASM, Scenery Maker, BGLCOMP and BGLGEN, but not for FSASM. There has been opposition to decompilers in some quarters because of the potential for abuse. Reports have circulated of a few unscrupulous scenery creators grabbing certain contents of someone else's scenery, and then using it in their own scenery without giving credit -- or even selling the scenery."
- from World Wide Guide to Flight-sim scenery design
http://www.vianet.net.au/~kraybill/fltsim5/index.htm
To prevent such problem, you MUST be aware of copyright laws. If you can't agree, you MUST NOT use this software.

Restriction on use

When you decompile the scenery files of another scenery designer, you MUST confirm that you are AWARE OF COPYRIGHT LAWS. Without the agreement of the author of the scenery, you MUST NOT redistribute a part or all of the analyzed scenery source file, or use them in another scenery and redistribute.

SCDIS is free software, so you can use this freely. But it is NOT public domain. SCDIS is copyrighted software by Takuya Murakami.

You can use this software for both non-commercial and commercial purpose.

SCDIS follows BSD style copyright:

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
   notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
   notice, this list of conditions and the following disclaimer in the
   documentation and/or other materials provided with the distribution.

THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE.

File list

System requirements

scdis.exe can work in Windows 95/98/NT command prompt. (DOS commandline enviroment is not supported from ver 1.5.)

And, UNIX environment is also supported. See 'UNIX environment' section.

How to use

Type at the Windows9x/NT command prompt
    
    scdis [option] <Scenery File Name> <Output directory name>
<Scenery File Name> should be the filename of BGL file. The output directory specify the directory location where scasm source files are put. If you omit the output directory name, output files will be put in the current directory

You can use following option:

	-s      :  Allocate label name as sequenced number.
The output files are as follows:
	scdhead.txt	BGL header information
	scd*.scm	Source files of each section
	compall.bat	Batch file to compile at once by SCASM
	sclink.ctl	Control file for SCLINK
Scdhead.txt has a BGL header informationiThis file can't be compiled by scasm)

BGL file consistes 22 sections. The sections can be analyzed are as follows:

	Section 0     : VOR, ILS
	Section 1-6   : Synthetic Scenery
	Section 9     : Procedural Scenery
	Section 10    : Library
	Section 11    : Airport
	Section 13    : ATIS
	Section 14    : NDB
	Section 15    : Dynamic Scenery
	Section 16    : IMO Marker, Landme, Area16
	Section 19    : Exception
The analysis results of each sections are stored in the file according to the section. For section 0, filename is scd0.scm.

For some sections, one file will be generated for each LatRange. For exsample, section9, filenames will be scd9-1.scm, scd9-2.scm,... and so on. This is because of the restriction of SCASM which can't handle only one LatRange in a file.

Note: For section19, the output bgl file name will be 'exclude.bgl'.

Re-compile

Almost all scm files can be re-compiled by scasm, but Section 10 can't be compiled, because scasm do not support it.

Some codes produced by SCDIS can't be compiled by old SCASM, so you should use most recent version of scasm. It is not distributed solely now, so you need to buy Airport & Scenery Designer from Abacus, or use one included in other free tools. The SCASM included in Airport Facility Directory (http://www.fly.to/scenery) is fairly new (version 2.30). You can use comall.bat file to compile all scm files.

To link all bgl files, use sclink. Type 'sclink sclink.ctl'.

About FS2000

Some BGL files included in FS2000 are compressed, so SCDIS can't analyze them directly. You can get BGL file compressor/decompressor from Micrososft website. Get it, decompress the bgl file, then use SCDIS.

About source files

The source files can be compiled with any generic ANSI-C compiler, but mkdir() runtime library function (not ANSI standard) is used in util.c, so it may be necessary to rewrite it.

Sorry, some comments are written in Japanese.

UNIX environment

SCDIS can run over UNIX environment. In fact, SCDIS ver 1.9 later was developed on FreeBSD. To compile SCDIS, go to source directory, and do 'make'.

If you compile SCDIS for a computer which has big endian byte order, you must define BIG_ENDIAN in the head of types.h.

Credits

Special Thanks to:
	Kouichi Shimosato
	MOJ
	Gene Kraybill
	Winfried Orthmann
	Alessandro Antonini
	Jim Reuter

Version history

Ver0.1		First version. Not open to the public

Ver0.2		Bug fix. Not open to the public

Ver0.3		'97/1/20
		Not open to the public
		Becomes to be able to decompile almost sections.


Ver1.0		'97/2/1
		First released version to public.

Ver1.1		'97/2/16
		Fix analyzation of ILS glide slope angle.
 		Fix analyzation of rotate angle of TransformCall
		Fix analyzation of runway ID of RunwayData
		Fix analyzation of runway ID of ATIS
		Analyze following records of Section9
			0x1d 	- VPPolygon
			0x42	- Runway
			0x7F	- City
		Dump following records of Section9
			0x17	- unknown, length = 4
			0x40	- RefPointInd
			0x41	- CondCall41
			0x62	- PointList
			0x6d	- CondJump6D
		Fix record length of Section9
			0x82	- SimpleRefPoint (20bytes)

Ver1.2		'97/2/23
		Fix miscalculation of latitude/longtitude in 
			western/southern himesphere.
		Fix analyzation of Section9
			0x1c	- IfVarRange2
			0x1d	- VecPoly
			0x21	- IfVarRange3
			0x28	- BigDot
			0x34	- CondJump34
			0x72	- RunwayLights
		Dump following records of Section9
			0x1b	- GoIfOutRotatedCube(SceneryMaker)
		Modify maximum length of ATIS message to 255 characters.

Ver1.3		'97/3/15
		Fix some bugs
		Analyze following records of Section9
			0x15	- TexRelief
			0x1b	- MonitorTr
			0x34	- SetScaleX
			0x58	- MoveTexture
			0x5d	- RepeatBitmap
			0x62	- MonitorPt
			0x6d	- IfHRes
			0x75	- PerspectiveSurface
			0x83	- SetScale

Ver1.4		'97/3/16
		Fix bugs around VectorJump

Ver1.5		'97/10/15
		Fix some bugs.
		Fix documents.
		Stop support of DOS enviroment.
		Analyze following records of Section9
			0x8c	- CallDll

Ver1.6		'97/10/26
		Improve decompile performance.
		Change exe file name.

Ver1.7		'98/2/14
		Fix VOR name display.
		Skip record 0x14 Section 0 
		Analyze following records of Section 9.
			0x54 	- CallAsm
		Analyze all records of Section16.

Ver1.8		'99/10/16
		Now scdis can analyze section 19.
		Fix restriction of use.
		Fix documents.

Ver1.9		2000/1/15
		Now SCDIS can analyze Section10 (Library).
		Limitation of number of label was removed.
		Add -s option.
		Analyze following records.
			ShadowPos/ShadowPosInd/ShadowCallVI
			IfVRes
			SetVar7E
			Transparency
			Call32
			TimeZone
			StartTimer
			PtichCall
			Transparency
			PolyM
			MoveToPos1/MoveToPos5
			TaxiTo
			MonitorRwy
			SetWeather
			Weather
		Bug fix around outputs of following records.
			IfVarRange
			LandMe
			Block
			RunwayData/RunwayLights

Contact information

If you have any request, bug information, please let me know by E-Mail.
E-Mail: tmurakam@mtd.biglobe.ne.jp

SCDIS website : http://www.freesc.org/
Author's homepage: http://flightinfo.ens.ne.jp/tmurakam/


Takuya Murakami - tmurakam@mtd.biglobe.ne.jp