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



