In some cases, you need to delay execution of a BGL fragment (for instance, until the ground is drawn). You can use the radsort system to do this; however, using the radsort system takes a lot of sorting time, and there are often items that need to be delayed, but don't need to be radsorted. In this situation, you can use the categories system.
The categories system includes CAT_SEG, which is a list of 64 segment pointers. In this list, zero indicates that no segment is available for the category; a nonzero value indicates that items are available for the category. If an item is available for the category, the segment contains a structure with a maximum count word, a current count word, and a list of four-word entries that point to the BGL fragments. The following example shows the structure of CAT_SEG.
CAT_SEGdw0;category 0 empty
dw0;category 1 empty
dwseg list1;category 2 segment
dw....
dw0;category 63 empty
list1dw2;maximum of 2 items in this list
dw1;current number of items in this list
ddptr bgl_frag_1;item 1 fragment pointer
dwbgl_page;item 1 bgl_page number (for 16K paging system)
dwfile_number;item 1 file_number (for frontend file source path ident)
dd0
dw0
dw0
bgl_frag_1:BGL
.........
BGL_RETURN
You can use the ADDCAT command to add items to the category list. When the ADDCAT command is invoked, the current bgl_page and file_number are inserted into the list. The ADDCAT command must be invoked at the object16_project sequence in the code, when the bgl_page and file_number are valid.
Use CALLOV INSERT_CHAIN_FAR_ID to create and maintain the list structures. The control chain insert utility manages all segment creation and expansion. (In the preceding example, notice the control chain-like structure of list1
.)
The categories are executed after the pre-radsort and object16 projection, but before elements and radsort. Fragments are executed in a "low category first, first inserted element first within a category" sequence. After all elements in a category are executed, the current number of elements word is set to zero to indicate that these elements have been executed and that the list can be purged if necessary.
GARBAGE_COLLECT_CAT is executed at bgl_cat_kill time (when the user quits the Flight Simulator program) and once every 8 seconds on the chain_8hz_sync chain. This system goes through the cat_seg pointers and looks for nonzero segments. For each nonzero segment encountered, the current number of items in the list is checked. If there are no items in the list, the segment is deallocated and the cat_seg list entry is set to zero.