To compile the main/synoptic/multimedia submodule.

§1. Our inventory inv already contains a list inv->figure_nodes of all packages in the tree with type _instance which are of the kind K_figure_name, and similarly for sounds and files. (These do not have ID numbers here because they already have instance_id values by virtue of being instances. Resource ID numbers are a little different, and are pooled between sounds and figures: these are assigned by the inform7 compiler, not here.)

void SynopticMultimedia::compile(inter_tree *I, pipeline_step *step, tree_inventory *inv) {
    if (InterNodeList::array_len(inv->figure_nodes) > 0)
        InterNodeList::array_sort(inv->figure_nodes, MakeSynopticModuleStage::module_order);
    if (InterNodeList::array_len(inv->sound_nodes) > 0)
        InterNodeList::array_sort(inv->sound_nodes, MakeSynopticModuleStage::module_order);
    if (InterNodeList::array_len(inv->file_nodes) > 0)
        InterNodeList::array_sort(inv->file_nodes, MakeSynopticModuleStage::module_order);
    if (InterNodeList::array_len(inv->internal_file_nodes) > 0)
        InterNodeList::array_sort(inv->internal_file_nodes, MakeSynopticModuleStage::module_order);
    Define RESOURCEIDSOFFIGURES array1.1;
    Define RESOURCEIDSOFSOUNDS array1.2;
    Define NO_EXTERNAL_FILES1.3;
    Define TABLEOFEXTERNALFILES array1.4;
    Define NO_INTERNAL_FILES1.5;
    Define TABLEOFINTERNALFILES array1.6;
}

§1.1. Define RESOURCEIDSOFFIGURES array1.1 =

    inter_name *iname = HierarchyLocations::iname(I, RESOURCEIDSOFFIGURES_HL);
    Synoptic::begin_array(I, step, iname);
    Synoptic::numeric_entry(0);
    for (int i=0; i<InterNodeList::array_len(inv->figure_nodes); i++) {
        inter_package *pack =
            PackageInstruction::at_this_head(inv->figure_nodes->list[i].node);
        inter_ti id = Metadata::read_numeric(pack, I"^resource_id");
        Synoptic::numeric_entry(id);
    }
    Synoptic::numeric_entry(0);
    Synoptic::end_array(I);

§1.2. Define RESOURCEIDSOFSOUNDS array1.2 =

    inter_name *iname = HierarchyLocations::iname(I, RESOURCEIDSOFSOUNDS_HL);
    Synoptic::begin_array(I, step, iname);
    Synoptic::numeric_entry(0);
    for (int i=0; i<InterNodeList::array_len(inv->sound_nodes); i++) {
        inter_package *pack =
            PackageInstruction::at_this_head(inv->sound_nodes->list[i].node);
        inter_ti id = Metadata::read_numeric(pack, I"^resource_id");
        Synoptic::numeric_entry(id);
    }
    Synoptic::numeric_entry(0);
    Synoptic::end_array(I);

§1.3. Define NO_EXTERNAL_FILES1.3 =

    inter_name *iname = HierarchyLocations::iname(I, NO_EXTERNAL_FILES_HL);
    Produce::numeric_constant(I, iname, K_value, (inter_ti) InterNodeList::array_len(inv->file_nodes));

§1.4. Define TABLEOFEXTERNALFILES array1.4 =

    inter_name *iname =
        HierarchyLocations::iname(I, TABLEOFEXTERNALFILES_HL);
    Synoptic::begin_array(I, step, iname);
    Synoptic::numeric_entry(0);
    for (int i=0; i<InterNodeList::array_len(inv->file_nodes); i++) {
        inter_package *pack = PackageInstruction::at_this_head(inv->file_nodes->list[i].node);
        inter_symbol *vc_s = Metadata::required_symbol(pack, I"^file_value");
        Synoptic::symbol_entry(vc_s);
    }
    Synoptic::numeric_entry(0);
    Synoptic::end_array(I);

§1.5. Define NO_INTERNAL_FILES1.5 =

    inter_name *iname = HierarchyLocations::iname(I, NO_INTERNAL_FILES_HL);
    Produce::numeric_constant(I, iname, K_value, (inter_ti) InterNodeList::array_len(inv->internal_file_nodes));

§1.6. Define TABLEOFINTERNALFILES array1.6 =

    inter_name *iname =
        HierarchyLocations::iname(I, TABLEOFINTERNALFILES_HL);
    Synoptic::begin_array(I, step, iname);
    Synoptic::numeric_entry(0);
    for (int i=0; i<InterNodeList::array_len(inv->internal_file_nodes); i++) {
        inter_package *pack = PackageInstruction::at_this_head(inv->internal_file_nodes->list[i].node);
        inter_symbol *vc_s = Metadata::required_symbol(pack, I"^file_value");
        Synoptic::symbol_entry(vc_s);
    }
    Synoptic::numeric_entry(0);
    Synoptic::end_array(I);