Combining Horizon and Terrain, Altitude Determination

In BGL, the following code illustrates the basic command used to determine altitude.

BGL_GROUND_ALTITUDE
RELOAD_DATABASE (bglobj.asm)
GET_BGL_OBJECTS (bglobj.asm)

The MISC elements section of the database can contain ground elevation information that overrides altitude information obtained from the seed map. The ALT_DB element specifies the NSEW range of altitude rectangles. The following example shows how ALT_DB is used.

ALT_DB_HEADERmacro nhi,nlo,shi,slo,ehi,elo,whi,wlo,object_end
localopcode
opcode:
db101;;00 op
db(offset object_end)-(offset opcode);;01 byte count of all bytes in this entity
dwnlo;;02 N (2M units) Range
dbnhi
dwslo;;05 S (2M units) Range
dbshi
dwelo;;08 E (24-bit pseudo) Range
dbehi
dwwlo;;11 W (24-bit pseudo) Range
dbwhi
endm

MISC_DATA:
rel_base=MISC_DATA
LATBAND_REL8960,9216,MISC_DATA_LIST_0001
EOL

MISC_DATA_LIST_0001:
carrier_deckmacro
localobject_end
ALT_DB_HEADER24h,0,23h,0,0c2h,0,0c0h,0,object_end
SCALEobject_end,0,0,S_16,046f8f4h,0,0c1b4f93dh,0,0,0
AREA_SENSE4object_end,50,250,50,-250,-50,-250,-50,250
ALTITUDE_SET200
ALTITUDE_SET250
object_end:
endm
carrier_deck
EOL

Data from the MISC file shown in the preceding example is retrieved during the object scan portion of the seed and object scan sequence (in the file Bglobj16.asm, sequence 4). Immediately after all the objects are loaded, bgl_ground_dbase_scan (Bglobj.asm) is performed. A range of 20,000 meters (defined by ground_scan_range) is scanned for MISC elements of type 101.