Absolute and Relative Addressing in BGL Files

The pointers in the BGL header are double words (32-bits) and are absolute pointers to the offset in the file in which the data is located. For example, the pointer to synth_seeds_13 in the BGL header shown in this topic points to the section in the BGL file in which the data is located. Notice that the offset is specified by synth_seeds_13-the_data in the header. The -the_data is included to make sure that the generated absolute pointer value is correctly computed from the beginning of the BGL file, which begins at the first word in the BGL header. Notice also that in the assembly listing in the example (just prior to the beginning of the header), the_data is equated to the beginning of the BGL file and is used throughout the file as the base for all absolute addresses.

the_dataequ$.list
;DATABASE HEADER ********************************************************
dw0001;00 world set number (not saved to file list)
;0=off 1=fs5 default world
dd000465f4eh;02 N bound 43 degrees meter units
dd00043d426h;06 S bound
dd0c1c71c71h;10 E bound 85 degrees 32-bit pseudo
dd0c127d27dh;14 W bound
ddVOR_DATA-the_data;18 VOR_DATA
dw50;22 lowest vor freq (channel 0–199)
dw50;24 highest vor freq (108.00–117.95)
ddsynth_seeds_08-the_data;26 seeds level 8
ddsynth_seeds_09-the_data;30 seeds level 9
ddSYNTH_SEEDS_10-the_data;34 seeds level 10
ddSYNTH_SEEDS_11-the_data;38 seeds level 11
ddsynth_seeds_12 - the_data ;42 seeds level 12
ddsynth_seeds_13 - the_data ;46 seeds level 13
synth_seeds_13labelword
rel_base=synth_seeds_13
COORD_LATBAND_REL00990,levl_13_lat_00990
EOL

levl_13_lat_00990labelword
SEED_BAND6184,6184
BAND_ELEMENTseed_water,flat_seed,0,230,0; 230 meters is ground level at Willard
......

In the preceding example, once the synth_seeds_13 section is reached by the absolute pointer in the header, a new base address at the beginning of this section of scenery data is established. The new base address is called rel_base. In the preceding example, rel_base is equated to the synth_seeds_13 label address. Throughout this section of the data, rel_base is used as a reference point wherever an absolute address is needed. Local base addresses, typically called rel_base in the assembly files, are used for all data sections. This makes these database sections more stand-alone and, in some cases, accommodates limited 16-bit absolute addressing.

Database concatenation and building tools often juggle pieces of data sections. For example, a seed concatenation can combine the level 13 seed sections from two BGL files into a single seed section. Because each database section has its own rel_base, the seed concatenation program can ignore the data structure within other sections of the BGL file. To concatenate new level 13 seed data, the seed concatenation can simply move other data sections to higher addresses in the file and adjust the pointers in the header to keep them pointing at the data sections. Because data sections all have their own section-relative address base, no internal absolute address adjustments are needed.

Some database sections are designed to contain limited data (as opposed to seed sections, for example, which can have an unlimited number in a section). Because these sections are not very large, 16-bit addressing is used for offset. Because a BGL file can be much larger than the 16-bit addressing limit of 64K, the local base address allows 16-bit addressing to be used in these data sections even if the actual data is at an address many megabytes into a file.