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

ASM position format HEX

Messages
5
Country
ukraine
hello community, I have always found answers here (Many thanks to everyone for this) and finally decided to sign up.
I have a question: I want to insert coordinates in the asm file, I have the coordinates in decimal degrees - how can I bring them to the format of hex to asm file?

for example: I have a makeMDL latitude and longitude of 10 (N10*E10*)
asm code is created
Code:
 ;compile with BGLC /BGL 10.asm
header label word
    dw      0001            ; 00 World set number   
    dd      00010FA44H          ; 02 North bound        
    dd      00010EFCEH          ; 06 South bound        
    dd      0071C71C8H          ; 10 East bound         
    dd      0071C71C6H          ; 14 West bound         
    dw      20 dup(0)                               
    dd      (offset OBJECT_DATA) - (offset header)
    dw      33 dup(0)                               

OBJECT_DATA label word                                  
    db  21              ;;LATBAND_REL                   
    dw  00877h          ;;lat min (inclusive) 512M units
    dw  0087Eh          ;;lat max (exclusive)           
    dd  (offset OBJECT_0) - (offset OBJECT_DATA)        
    db  0               ;;EOL                           
OBJECT_0 label    BGLCODE
    db  12                      ; NEAR_FAR_HUGE_OBJECT_HEADER
    [COLOR="Red"]dd  00010F509h,0071C71C7h           ; latitude,longitude[/COLOR]          
    db  100                     ; image power                 
    dd  (offset OBJECT_0_END) - (offset OBJECT_0)             
OBJECT_0_START label word
    IFIN1       OBJECT_0_FAIL, image_complex, 2, 32767
    ADDOBJ      OBJECT_0_SCALE
    SHADOW_CALL OBJECT_0_SCALE
OBJECT_0_FAIL label    BGLCODE
    BGL_JUMP_32 OBJECT_0_END  
OBJECT_0_SCALE label    BGLCODE
    SCALE_AGL   OBJECT_0_RETURN, 10000, 1339, 131072, [COLOR="red"]00010F509h[/COLOR], 08E39h, [COLOR="red"]0071C71C7h[/COLOR], 01C72h, 0, 0
    BGL_CALL        OBJECT_0_BEGIN
OBJECT_0_RETURN label word
    BGL_RETURN
OBJECT_0_BEGIN label word
model_outside    label    BGLCODE
model_shadow label BGLCODE

LOD_0    label    BGLCODE
    BGL_JUMP_32    LOD_0L

model_inside  label    BGLCODE
    BGL_RETURN
LOD_0L    label    BGLCODE
    include    10_0.asm



OBJECT_0_END label word
EOF


As far as I can understand 00010F509h,0071C71C7h is latitude and longitude

I tried this:
hexdec("00010F509h") * 90
result is 100017450
quite strange :)

point out my mistake please
 
Hi,

I will come back to this soon. I need to figure out some of the details to be able to give the exact answer. But I need that for my ModelConverterX tool anyway.
 
I just want to create a tool for placing ground polygons.
For example, I get geometry from 0.asm, and I only have to change the coordinates and name of the texture to cover a large area and I would like to use a separate BGL for each texture.
maybe you do something like that in the next build ModelConverterX?
 
Last edited:
I think this is right:

Header bounds are SINT32 for Latitude and ANGL32 for Longitude.

World polar circumference = 40007 km
1/2 world circumference = 20003500 meters
1 degree equals 20003500 / 180 = 111130.55555555555555555555555556

Latitude = (decimal_degrees * 111130.55555555555555555555555556)
(10.0000 * 111130.55555555555555555555555556)
1111305.555555555555555555555555
1111305d
10F509h


Longitude = ((decimal_degrees / 360 ) * 4294967296 )
((10.0000 / 360 ) * 4294967296 )
119304647.11111111111111111111111
119304647d
071c71c7h


****************************************

Latbands are 512M units

Latitude = ((decimal_degrees / 180 ) * 65536 )
((10.0000 / 180 ) * 65536 )
3640.8888888888888888888888888889
3640d
0e38h

****************************************

The actual object placement has

;latitude =iiii M units ... meaning it uses integers only
;longitude =32-bit pseudo

so...

longitude would be as above:

Longitude = ((decimal_degrees / 360 ) * 4294967296 )
((10.0000 / 360 ) * 4294967296 )
119304647.11111111111111111111111
119304647d
071c71c7h


latitude would be:

World polar circumference = 40007 km
1/2 world circumference = 20003500 meters
1 degree equals 20003500 / 180 = 111130.55555555555555555555555556

Latitude = ((decimal_degrees * 111130.55555555555555555555555556)/512)
((10.0000 * 111130.55555555555555555555555556)/512)
2170.5186631944444444444444444434
2170d
087ah

***********************************

You would need to alter the header bounds, which should be a bit greater NSEW than the actual location. Then you need to alter the latbands to be also inclusive ( a bit greater range lat south...lat north ). Then you need to alter the actual N10* E10*.

You could get by setting the header and latbands exactly, but MS suggests making it a bit more inclusive, by a degree perhaps.

As I wrote, I think this is right. Also you can use decimal integers by using a format like 238609294d... d specifies decimal integers to BGLC.

Try this and see if it is right.

This is from gmax output for N10.0000* x E10.0000*:
Code:
;compile with BGLC /BGL C:\Documents and Settings\Dick.LUDOWR\Desktop\BigBox.asm
header label word
    dw      0001            ; 00 World set number   
    dd      00010F518H          ; 02 North bound        
    dd      00010F4FAH          ; 06 South bound        
    dd      0071C71C8H          ; 10 East bound         
    dd      0071C71C6H          ; 14 West bound         
    dw      20 dup(0)                               
    dd      (offset OBJECT_DATA) - (offset header)
    dw      33 dup(0)                               

OBJECT_DATA label word                                  
    db  21              ;;LATBAND_REL                   
    dw  0087Ah          ;;lat min (inclusive) 512M units
    dw  0087Bh          ;;lat max (exclusive)           
    dd  (offset OBJECT_0) - (offset OBJECT_DATA)        
    db  0               ;;EOL                           
OBJECT_0 label    BGLCODE
    db  12                      ; NEAR_FAR_HUGE_OBJECT_HEADER
    dd  00010F509h,0071C71C7h           ; latitude,longitude          
    db  100                     ; image power                 
    dd  (offset OBJECT_0_END) - (offset OBJECT_0)             
OBJECT_0_START label word
    ADDOBJ      OBJECT_0_SCALE
    SHADOW_CALL OBJECT_0_SCALE
OBJECT_0_FAIL label    BGLCODE
    BGL_JUMP_32 OBJECT_0_END  
OBJECT_0_SCALE label    BGLCODE
    SCALE_AGL   OBJECT_0_RETURN, 10000, 25, 131072, 00010F509h, 08E39h, 0071C71C7h, 01C72h, 0, 0
    BGL_CALL        OBJECT_0_BEGIN
OBJECT_0_RETURN label word
    BGL_RETURN
OBJECT_0_BEGIN label word
model_outside    label    BGLCODE
model_shadow label BGLCODE

LOD_0    label    BGLCODE
    BGL_JUMP_32    LOD_0L

model_inside  label    BGLCODE
    BGL_RETURN
LOD_0L    label    BGLCODE
    include    C:\Documents and Settings\Dick.LUDOWR\Desktop\BigBox_0.asm


Dick
 
Last edited:
I just checked out after you've edited your post, and lo! I think everything is correct.
I have not checked bounds, but I think the problems should not be

what I fed MakeMDL: N48.4201442971957*E39.3709659576416*

what I got in asm: 000521B5Dh 01BFF4400h

and got:
Code:
pow(2,32); //4294967296
dechex(48.4201442971957 * (20003500 / 180)); 
dechex((39.3709659576416 / 360 ) * 4294967296 );
result: 521b5d 1bff4400

cool!

what you mean when you say that I can use a decimal for BGLC? I'm getting from it errors in this case...

and yes! many thanks rhumbaflappy

you among the relatives was Einstein?...
 
I not only messed up the latbands, but the fractional degrees as well.

This is a solution that works...

First, the original BigBox.asm from gmax:

Code:
;compile with BGLC /BGL C:\Documents and Settings\Dick.LUDOWR\Desktop\BigBox.asm
header label word
    dw      0001            ; 00 World set number   
[COLOR="Red"]    dd      00010F518H          ; 02 North bound        
    dd      00010F4FAH          ; 06 South bound        
    dd      0071C71C8H          ; 10 East bound         
    dd      0071C71C6H          ; 14 West bound[/COLOR]         
    dw      20 dup(0)                               
    dd      (offset OBJECT_DATA) - (offset header)
    dw      33 dup(0)                               

OBJECT_DATA label word                                  
    db  21              ;;LATBAND_REL                   
[COLOR="Red"]    dw  0087Ah          ;;lat min (inclusive) 512M units
    dw  0087Bh          ;;lat max (exclusive)  [/COLOR]         
    dd  (offset OBJECT_0) - (offset OBJECT_DATA)        
    db  0               ;;EOL                           
OBJECT_0 label    BGLCODE
    db  12                      ; NEAR_FAR_HUGE_OBJECT_HEADER
[COLOR="Red"]    dd  00010F509h,0071C71C7h           ; latitude,longitude [/COLOR]         
    db  100                     ; image power                 
    dd  (offset OBJECT_0_END) - (offset OBJECT_0)             
OBJECT_0_START label word
    ADDOBJ      OBJECT_0_SCALE
    SHADOW_CALL OBJECT_0_SCALE
OBJECT_0_FAIL label    BGLCODE
    BGL_JUMP_32 OBJECT_0_END  
OBJECT_0_SCALE label    BGLCODE
    SCALE_AGL   OBJECT_0_RETURN, 10000, 25, 131072, [COLOR="Red"]00010F509h, 08E39h, 0071C71C7h, 01C72h[/COLOR], 0, 0
    BGL_CALL        OBJECT_0_BEGIN
OBJECT_0_RETURN label word
    BGL_RETURN
OBJECT_0_BEGIN label word
model_outside    label    BGLCODE
model_shadow label BGLCODE

LOD_0    label    BGLCODE
    BGL_JUMP_32    LOD_0L

model_inside  label    BGLCODE
    BGL_RETURN
LOD_0L    label    BGLCODE
    include    BigBox_0.asm



OBJECT_0_END label word
EOF

Now to move the BigBox to airfield C59... C59_BigBox.asm:

Code:
;c59 @ 42.6295787481559 latitude, 88.6016458232594 longitude

;Latitude:
;The Earth's latitude is expressed as meters;
;Polar circumference=40007.0 km 
;Pole to pole = 20003500 meters
;each degree latitude = ( 20003500 / 180 ) = 111130.55555555555555555555555556
;latitude = ( latitude_decimal_degrees * 111130.55555555555555555555555556 )

;Longitude:
;The earth's longitude is expresses as a fraction of 2^32.
;2^32 = 4294967296
;longitude = (( longitude_decimal_degrees / 360 ) * 4294967296 )

[COLOR="Blue"]
;+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
;lat = 42.6295787481559 = ( 42.6295787481559 * 111130.55555555555555555555555556 )  = 4737448.7693818696980555555555532
;4737449d
;fraction = ( 0.7693818696980555555555532 * 65536 ) = 50422.2102125317688888887345152
;50422d


;long = -88.6016458232594 = (( -88.6016458232594 / 360 ) * 4294967296 ) = -1057058808.8407614420127288888889
;-1057058808d
;fraction = ( 0.8407614420127288888889 * 65536 ) = 55100.1418637462004622229504
;55100d


;latband = 42.6295787481559 = ( 42.6295787481559 * 217.05186631944444444444444444444 ) = 9252.8296276989642540147569444425
;9252d

;++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++[/COLOR]
;compile with BGLC /BGL C:\Documents and Settings\Dick.LUDOWR\Desktop\BigBox.asm
header label word
    dw      0001            ; 00 World set number   
[COLOR="Red"]    dd      4737450d         ; 02 North bound        
    dd      4737448d         ; 06 South bound        
    dd      -1057058807d         ; 10 East bound         
    dd      -1057058809d          ; 14 West bound     [/COLOR]    
    dw      20 dup(0)                               
    dd      (offset OBJECT_DATA) - (offset header)
    dw      33 dup(0)                               

OBJECT_DATA label word                                  
    db  21              ;;LATBAND_REL                   
[COLOR="Red"]    dw  9251d          ;;lat min (inclusive) 512M units
    dw  9253d          ;;lat max (exclusive)      [/COLOR]     
    dd  (offset OBJECT_0) - (offset OBJECT_DATA)        
    db  0               ;;EOL                           
OBJECT_0 label    BGLCODE
    db  12                      ; NEAR_FAR_HUGE_OBJECT_HEADER
[COLOR="Red"]    dd  4737449d,-1057058808d           ; latitude,longitude  ****** general integer lat-long[/COLOR]        
    db  100                     ; image power                 
    dd  (offset OBJECT_0_END) - (offset OBJECT_0)             
OBJECT_0_START label word
    ADDOBJ      OBJECT_0_SCALE
    SHADOW_CALL OBJECT_0_SCALE
OBJECT_0_FAIL label    BGLCODE
    BGL_JUMP_32 OBJECT_0_END  
OBJECT_0_SCALE label    BGLCODE
    SCALE_AGL   OBJECT_0_RETURN, 10000, 25, 131072, [COLOR="Red"]4737449d, 50422d, -1057058808d, 55100d[/COLOR], 0, 0 ; [COLOR="Red"]****** note specific lat-long[/COLOR]
    BGL_CALL        OBJECT_0_BEGIN
OBJECT_0_RETURN label word
    BGL_RETURN
OBJECT_0_BEGIN label word
model_outside    label    BGLCODE
model_shadow label BGLCODE

LOD_0    label    BGLCODE
    BGL_JUMP_32    LOD_0L

model_inside  label    BGLCODE
    BGL_RETURN
LOD_0L    label    BGLCODE
    include    BigBox_0.asm



OBJECT_0_END label word
EOF

Note that I used decimal integers, which BGLC accepts just fine ( including negative values ), by specifying "d" as the numerical suffix, instead of "h".

On the header bounds and the latbands, I increased or decreased the integer lat-long by a single digit as needed to make the range inclusive of the object.

In SCALE_AGL, the integer latitude is followed by the fractional part... and the same for longitude.

Dick
 
Last edited:
Back
Top