• Which the release of FS2020 we see an explosition of activity on the forun and of course we are very happy to see this. But having all questions about FS2020 in one forum becomes a bit messy. So therefore we would like to ask you all to use the following guidelines when posting your questions:

    • Tag FS2020 specific questions with the MSFS2020 tag.
    • Questions about making 3D assets can be posted in the 3D asset design forum. Either post them in the subforum of the modelling tool you use or in the general forum if they are general.
    • Questions about aircraft design can be posted in the Aircraft design forum
    • Questions about airport design can be posted in the FS2020 airport design forum. Once airport development tools have been updated for FS2020 you can post tool speciifc questions in the subforums of those tools as well of course.
    • Questions about terrain design can be posted in the FS2020 terrain design forum.
    • Questions about SimConnect can be posted in the SimConnect forum.

    Any other question that is not specific to an aspect of development or tool can be posted in the General chat forum.

    By following these guidelines we make sure that the forums remain easy to read for everybody and also that the right people can find your post to answer it.

Editing API

Messages
334
Country
france
Hello
I wish to change some textures in API files ; I don't have the source files.
With Notepad, I succeeded in editing an API file created with EOD, simply in replacing the bmp file with a new one.
I tried the same with an API file created with FSDS (oltimedomehangar), to replace the wooden walls (2wood.bmp) by rusty metal (FineCorrVrust.bmp). The modified parts are no more visible!

in the original text:
Code:
...
:Part3
Points( 0 
    -305     0     1       ; 0
    -305   229     1       ; 1
    -296   229     1       ; 2
    -296     0     1       ; 3
    -305     0   458       ; 4
    -305   229   458       ; 5
    -296   229   458       ; 6
    -296     0   458       ; 7
    -305     0  -454       ; 8
    -305   229  -454       ; 9
    -296   229  -454       ; 10
    -296     0  -454       ; 11
    -305     0     2       ; 12
    -305   229     2       ; 13
    -296   229     2       ; 14
    -296     0     2       ; 15
    )
;RGBSColor( ef 56 56 56 )
Dwx( 2d ) ; color command
Dbd( 56 ) ; red
Dbx( ef ) ; flag/transparency
Dbd( 56 ) ; green
Dbd( 56 ) ; blue
Poly( 0 0 -32767 -0.76   0   1   2   3   )
Poly( 0 0 32767 457.96   7   6   5   4   )[/COLOR]
[B]; BGL_TEXTURE: tclass=1h color=38EF3838 name=[COLOR="Red"]2wood.bmp[/COLOR]
Dwx( 0043 0016 0000 0001 ef38 3838 )
Dba([COLOR="red"]2wood.bmp[/COLOR])[/B]
[COLOR="blue"]Dbx( 00 )
TexPoly( -32767 0 0 305.64  5 2 254 1 253 254 0 253 3 4 2 3 )
TexPoly( 32767 0 0 -297.10  2 1 255 6 254 255 7 254 2 3 1 2 )
Poly( 0 32767 0 228.60   5   6   2   1   )
Poly( 0 -32767 0 0.00   0   3   7   4   )
Poly( 0 0 -32767 455.29   8   9   10   11   )
Poly( 0 0 32767 1.91   15   14   13   12   )
TexPoly( -32767 0 0 305.71  13 2 254 9 253 254 8 253 3 12 2 3 )
TexPoly( 32767 0 0 -297.04  10 1 255 14 254 255 15 254 2 11 1 2 )
Poly( 0 32767 0 228.60   13   14   10   9   )
Poly( 0 -32767 0 0.00   8   11   15   12   )
Return
...

By changing all occurences of 2wood.bmp into FineCorrVrust.bmp, the walls are no more visible (the texture file is present in the right directory!)

Thanks for help!!!
Pierrot - FMEP
 
Last edited by a moderator:
Hi Pierrot,

Unfortunately FSDS uses this weird code to write the bitmaps (this is to let old version of SCASM also compile the API code). Only changing the bitmap name is not enough, you also need to change the parameter that defines the length of the LoadBitmap command (as your new texture name is longer). This code should work:

Code:
Dwx( 0043 001E 0000 0001 ef38 3838 )
Dba(FineCorrVrust.bmp)
 
Hello! Tanks for quick answer! It works!!!
In fact, I have a second other new metal texture FineCorrVrustbrace.bmp for doors:
...
Dwx( 0043 0018 0000 0001 ef64 4054 )
Dba(FineCorrVrustbrace.bmp)
...

Could you explain me -if possible- how to change the code number in Dwx
What is the meaning of parameters? is there a formula?
Original texture file name was 2woodV.bmp:
Dwx( 0043 0018 0000 0001 ef64 4054 )
Dba(2woodV.bmp)

Does exist a tuto about API programming? not to write aPI! but to understand how to do minor changes in existing API, such as colors or textures?

Thanks for answer! Pierrot -FMEP
 
Hi Pierrot,

Actually this code is not really API code, it is writing information directly in the binary BGL format. So to fully understand you need to go even a step deeper into the code. I have not seen many tutorials about that, I am mainly using the INC files of BGLC when I look for information.

The second parameters, the one I changed, is the total number of bytes used by the texture command. All parameters have a fixed length of 12 bytes and the remaining number is the length of your texture name. These two summed together form the value given there (rounded to an even value and in hex format).
 
Hi Pierrot,

I just thought of an easier solution. You could also just delete those two Dwx/Dba lines and replace it with the SCASM LoadBitmap command (that is the same command as written there in binary form). In that case you can just change the texture name without trouble:

Code:
LoadBitmap( 0 6 EF 38 38 38 2woodV.bmp )
 
Thanks for help.
I'll make try as soon as possible and tell you if it works.
In the meantime, I used an other solution.
As the 2 texture files "2wood.bmp" and "2woodV.bmp" seem not to be used so far in other bgl, I renamed my 2 new texture files with them. Not very good, but working!

Pierrot - FMEP
 
Back
Top