• 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.

FS2004 Wrong atmospheric model for pressure.... and possible correction

Messages
22
Country
italy
Dear all,

As I was discussing here: https://www.fsdeveloper.com/forum/threads/inverse-atmospheric-pressure.256662/ there is a serious bug in FS9 on the atmospheric pressure computation. Apparently when the QNH is not set to standard ISA (seal level pressure != 1013.2 hPa, 29.92 inHg) FS9 applies a correction to the ISA formula that does not make any sense. I couldn't exactly figure out what it is, but there is a subtraction of a quantity, which is numerically very close to the Delta_ISA at sea level. So if at sea level there is a -10 hPa, this difference is maintained almost constant everywhere....
Obviously this brings to a HUGE error at high altitude. In some cases it is even possible to get negative pressure. In this case, the simulator seems to have some code to restore the pressure to 1013.2 hPa: imagine to be in a Concorde at FL600, enter a deep depression and suddenly the pressure moves from 60 or so hPa to 1013.2! Fantastic.
I found a rusted old copy of FSX and from a preliminary test, the problem is corrected there. Meaning that, instead of correcting the pressure a posteriori, they seem to simply start not from the geometrical altitude, but from the pressure altitude, and then use the normal ISA formula.... that's the way of doing it.
How to correct this bug? Well, patching the related DLL. After a not so long search, i found that the incriminated code is in weather.dll. And I could locate a portion of the code where there is a fork: my assembly knowledge is very basic, and the code from C++ compilation is very cryptic to read, but it looks like there is a check if the QNH is standard. If so one code is executed, if not, another code, which contains the previous one but interleaved by more instructions, including some FSUB and FADD (floating point subtractions and addition). If I revert the fork, i.e. execute in standard ISA the "longer" code and in non standard ISA the standard ISA calculation, it seems like the pressure is always computed as we are always in ISA. I guess that's due to the fact that the longer code gives the same results of the shorter one if the QNH is at 1013.2.
This "patch" only requires a single byte alternation of the weather.dll, and gives some decent approximation to the atmospheric model. Ok, the effect is that you might be off some hundreds of ft in pressure values, but not of several thousands as with the original code.
But I am not fully satisfied. Maybe there is a better correction possible. Like to pass the pressure altitude to the code, i.o. the geometric one, and hence avoide the problem at the root. But to get to this I would need some help of some people more experienced than me in assembly. Is there here anybody capable/interested in helping?

PS: if you are interested, the correction i found for now is: in weather.dll -> Byte address 0x24272 change value from 75 to 74
 
PS: if you are interested, the correction i found for now is: in weather.dll -> Byte address 0x24272 change value from 75 to 74

If anyone knows how to find this in the dll, let me know. THe hex editor makes NASA rocket equations look like fun kids games to this.

🤯
 
I'm using HxD (https://mh-nexus.de/en/hxd/).

- Make a backup of weather.dll
- If you load weather.dll into HxD, on the left side is a column headed 'Offset(h)'
- Scroll down until the row '24270' comes into view
- In the editor view, the columns are headed '00' to '0F'
- at the intersection of row '24270' with column '02' should be a byte with a value of 75. Change that to 74 - it will display in red until you save the file
- Save

I can't screenshot it because I'm on Prepar3D and the offset is slightly different.
 
Back
Top