CREATING WASM SYSTEMS

WASM (C/C++) systems can be developed for Microsoft Flight Simulator 2024 with the Microsoft Flight Simulator Platform Toolset. Those systems will be updated every frame without drawing anything and have access to all variables, events... of an aircraft.

 

 

Creating A New System For Your Project

As explained in the Creating & configure WASM Project, you first need to create a MSFS 2024 WASM Module. By doing that, you will get a new project with only the module_init and module_deinit functions.

 

To create a new system, right click on your project in the solution explorer and add a new file. In the selection page, choose MSFS and pick System.

 

After selecting the MSFS WASM Module template, you will be presented with the following basic project, which you'll be editing:

MSFS_CALLBACK bool [MODULE_NAME]_system_init(FsContext ctx, sSystemInstallData* pInstallData)
{
    // This is called during initialization of the system
    // do initialization
    // ...
    // return false if there is any error
    return true;
}
  • The [MODULE_NAME]_system_init is the initialisation function - the first function to be called in the gauge cycle - that allows you to initialise everything related to the gauge.
  • The pInstallData parameter points to a sSystemInstallData structure.
  • The parameterString member of the sSystemInstallData struct is filled from the data given in the [WASM_SYSTEM.N] section of the systems.cfg.

 

MSFS_CALLBACK bool [MODULE_NAME]_system_update(FsContext ctx, float dTime)
{
    // This is called each frame
    // dTime is the time between the previous frame and this one
    // return false if there is any error
    return true;
}
  • The [MODULE_NAME]_system_update is the update function dedicated to this gauge. It will be called once per frame. This function must not be used for draw functions because it will be called at a moment in which the draw system in not ready.
  • The dTime parameter represents the time between the previous update and this one.

 

MSFS_CALLBACK bool System_system_kill(FsContext ctx)
{
    // This is called before the system is destroyed
    // return false if there is any error
    return true;
}
  • The [MODULE_NAME]_system_kill is the de-initialisation function - the last function to be called in the gauge cycle - that allows you to de-initialise everything related to the gauge.

 

 

Editing The WASM Module Project

Now you've initialised the new WASM project and setup Visual Studio, you'll need to edit the source code to include the minimum header files - supplied by the SDK - to create the module. You can find all the available files that can be included from the following SDK location:

<root>\MSFS SDK\WASM\include\MSFS

Location Of The MSFS.h File

 

These different API's are as follows:

 

 

Adding The System To Your Aircraft

Once you have created the gauge, you need to be able to add it to your aircraft and to test it. This means that you should already have created an aircraft package (as explained here: Creating The Project), and after building the WASM module from Visual Studio, you will want to save in the wasm file in the PackageSources directory.

 

Once you have built the module and saved it to the appropriate location, you need to tell the aircraft to reference it. This is done in the systems.cfg, under the [WASM_SYSTEM.N] header, something like this:

[WASM_SYSTEM.0]
ModulePath=<VFS_PATH_WASM_FOLDER>/<MODULENAME>
SystemName=<SYSTEMNAME>
ParameterString="blah"

 

The important thing to note here is that a system.cfg file can only reference a WASM module that is in the same package. If a WASM system is meant to be shared between multiple packages, then it should be configured as a Sim Attachment. It should also be noted that the WASM file - located in WASM folder - can also contain WASM Gauges, if required.

 

When you have the saved the file in the correct location, you can go ahead and build the package (as explained here: Building A Package). Once built, you will need to restart the flight to see the module in the simulation. Note that this is the case for every edition you make to the WASM code - afterwards it will need to be re-exported, built, and the flight restarted.