The Horizon Generator

Horizon generator code is included in the file Enviro.asm. The horizon generator is run from the file Indwind.asm as soon as the Flight Simulator window is opened. The horizon generator module contains multiple BGL databases that are executed conditionally, depending on cloud levels, display options that are set (for example, textured or gradient earth and sky), whisping, and map view. The following example shows horizon generator code.

Variables:generate_horizondw0;0=generate, 1=scenery will do it (global.asm)
seed8_scaledw0,0;scale factor computed based on level 8 seed we're over
seed8_lat/londw0,0,0;lat/lon of SW corner of level 8 seed we're over
seed8_altdw0,0,0;altitude of level 8 seed we're over
sky_typedw0;0=simple or gouraud, 1=texture
texture_availdw0;0=last texture command didn't work  1= it worked

The following table describes how clouds are generated in BGL.

View BGL database Pre-BGL action BGL action
Map view gouraud_ground texture_ground_scale =seed8_scale setcolor 69b0h; SURFACE 9,10,8,7
gradient_sky draw_gradient_sky: GSURF 1,2,3,4
setcolor 69a0h
SURFACE 3,4,6,5
3-D window if generate_horizon .nz.
gouraud_ground
texture_ground_scale = seed8_scale setcolor 69b0h
SURFACE 9,10,8,7
if no clouds or above both cloud layers, or above layer 1 with no layer 2 present, then gradient_sky draw_gradient_sky:
GSURF 1,2,3,4
setcolor 69a0h
SURFACE 3,4,6,5
if under layer 1, with no layer 2,
under_cloud_1
VSCALE cloud_lat_1
if sky_type=0 (polygons)
draw_gradient_sky:
GSURF 1,2,3,4
setcolor 69a0h
SURFACE 3,4,6,5
ASMCALL poly_layer_1
if sky_type= 1 (texture)
TEXTURE 2,0,0,0
cloud1.r8
ASMCALL cloud_drift_1
if texture_avail=0
draw_gradient_sky
else
draw haze sky
HAZE 1
ANTI ALIAS 1
SURFACE 1,2,6,5
ASMCALL
do_in_cloud_1
if between layers, under_cloud_2 VSCALE cloud_lat_2
if sky_type=0 (polygons)
draw_gradient_sky:
GSURF 1,2,3,4
setcolor 69a0h
SURFACE 3,4,6,5
ASMCALL poly_layer_1
if sky_type= 1 (texture)
TEXTURE 2,128,0,128
cloud2.r8
ASMCALL cloud_drift_2
if texture_avail=0
draw_gradient_sky
else
draw haze sky
HAZE 1
ASMCALL haze_inf2
SURFACE 1,2,6,5
ASMCALL do_in_cloud_2
if under active layers 1 and 2,

under_cloud_2

special_cloud_1