diff --git a/docs/if-module/3-tm.html b/docs/if-module/3-tm.html index 7df504208..698a1d1ed 100644 --- a/docs/if-module/3-tm.html +++ b/docs/if-module/3-tm.html @@ -119,8 +119,6 @@ quite specific problem messages. int Map::production_line(int stage, int debugging, stopwatch_timer *sequence_timer) { if (stage == INTER1_CSEQ) { BENCH(RTMap::compile_model_tables); - BENCH(RTMap::write_door_dir_routines); - BENCH(RTMap::write_door_to_routines); } return FALSE; } @@ -432,8 +430,6 @@ direction, but implies both.
     registered_directions++;
-    inter_name *dname = RTMap::new_direction_iname();
-    MAP_DATA(I)->direction_iname = dname;
     MapRelations::make_mapped_predicate(I);
 
@@ -1119,7 +1115,7 @@ trust that there is nothing surprising here.

-    parse_node *val = RTMap::found_in_for_2_sided(I, R1, R2);
+    parse_node *val = RTDoors::found_in_for_2_sided(I, R1, R2);
     Map::set_found_in(I, val);
 
@@ -1131,7 +1127,7 @@ always the way to the other room — the one we are not in.

-    parse_node *val = RTMap::door_dir_for_2_sided(I, R1, D1, D2);
+    parse_node *val = RTDoors::door_dir_for_2_sided(I, R1, D1, D2);
     ValueProperties::assert(P_door_dir, Instances::as_subject(I), val, CERTAIN_CE);
 
@@ -1143,7 +1139,7 @@ always the other room — the one we are not in.

-    parse_node *val = RTMap::door_to_for_2_sided(I, R1, R2);
+    parse_node *val = RTDoors::door_to_for_2_sided(I, R1, R2);
     ValueProperties::assert(P_door_to, Instances::as_subject(I), val, CERTAIN_CE);
 
diff --git a/docs/runtime-module/1-rm.html b/docs/runtime-module/1-rm.html index d1457626c..483e70bd0 100644 --- a/docs/runtime-module/1-rm.html +++ b/docs/runtime-module/1-rm.html @@ -90,7 +90,7 @@ which use this module: } diff --git a/docs/runtime-module/2-cu.html b/docs/runtime-module/2-cu.html index b4107904b..820e8da44 100644 --- a/docs/runtime-module/2-cu.html +++ b/docs/runtime-module/2-cu.html @@ -243,7 +243,7 @@ but that's now easy. } diff --git a/docs/runtime-module/2-dv.html b/docs/runtime-module/2-dv.html index 5d101a739..ccdceeac5 100644 --- a/docs/runtime-module/2-dv.html +++ b/docs/runtime-module/2-dv.html @@ -420,7 +420,7 @@ names are not. diff --git a/docs/runtime-module/2-ea.html b/docs/runtime-module/2-ea.html index 78f2a26b1..5d18b087f 100644 --- a/docs/runtime-module/2-ea.html +++ b/docs/runtime-module/2-ea.html @@ -92,7 +92,7 @@ enforced; it's fine to store arbitrary data with
-packaging_state EmitArrays::begin(inter_name *name, kind *K) {
+packaging_state EmitArrays::begin(inter_name *name, kind *K) {
     packaging_state save = Packaging::enter_home_of(name);
     EmitArrays::begin_inner(name, K, FALSE);
     return save;
@@ -158,11 +158,11 @@ which would be a typesafe list in I7, so they can be absolutely any data,
 

-void EmitArrays::numeric_entry(inter_ti N) {
+void EmitArrays::numeric_entry(inter_ti N) {
     EmitArrays::entry_inner(LITERAL_IVAL, N);
 }
 
-void EmitArrays::iname_entry(inter_name *iname) {
+void EmitArrays::iname_entry(inter_name *iname) {
     inter_symbol *alias;
     if (iname == NULL) alias = Emit::get_veneer_symbol(NOTHING_VSYMB);
     else alias = InterNames::to_symbol(iname);
@@ -203,7 +203,7 @@ difference to compiled code.
 

-void EmitArrays::divider(text_stream *divider_text) {
+void EmitArrays::divider(text_stream *divider_text) {
     inter_ti S = Inter::Warehouse::create_text(Emit::warehouse(), Emit::package());
     Str::copy(Inter::Warehouse::get_text(Emit::warehouse(), S), divider_text);
     EmitArrays::entry_inner(DIVIDER_IVAL, S);
@@ -213,7 +213,7 @@ difference to compiled code.
 

-void EmitArrays::end(packaging_state save) {
+void EmitArrays::end(packaging_state save) {
     EmitArrays::end_inner();
     Packaging::exit(Emit::tree(), save);
 }
@@ -349,7 +349,7 @@ is completely emitted before another one is.
 }
 
diff --git a/docs/runtime-module/2-ec.html b/docs/runtime-module/2-ec.html index 2a1255ae5..3fb3917fb 100644 --- a/docs/runtime-module/2-ec.html +++ b/docs/runtime-module/2-ec.html @@ -108,10 +108,10 @@ instruction last emitted, not after it.
  • EmitCode::up then returns us back to where we were.
  • -void EmitCode::up(void) {
    +void EmitCode::up(void) {
         Produce::up(Emit::tree());
     }
    -void EmitCode::down(void) {
    +void EmitCode::down(void) {
         Produce::down(Emit::tree());
     }
     
    @@ -127,7 +127,7 @@ have made, net:

    §5. Structural.

    -void EmitCode::code(void) {
    +void EmitCode::code(void) {
         Produce::code(Emit::tree());
     }
     
    @@ -165,7 +165,7 @@ start of a function.
         Produce::val(Emit::tree(), K_truth_state, LITERAL_IVAL, 0);
     }
     
    -void EmitCode::val_iname(kind *K, inter_name *iname) {
    +void EmitCode::val_iname(kind *K, inter_name *iname) {
         Produce::val_iname(Emit::tree(), K, iname);
     }
     
    @@ -185,7 +185,7 @@ start of a function.
         Produce::val_nothing(Emit::tree());
     }
     
    -void EmitCode::val_symbol(kind *K, inter_symbol *S) {
    +void EmitCode::val_symbol(kind *K, inter_symbol *S) {
         Produce::val_symbol(Emit::tree(), K, S);
     }
     
    @@ -253,7 +253,7 @@ in such cases, this function must exist in the kits somewhere. Produce::ref_iname(Emit::tree(), K, iname); } -void EmitCode::ref_symbol(kind *K, inter_symbol *S) { +void EmitCode::ref_symbol(kind *K, inter_symbol *S) { Produce::ref_symbol(Emit::tree(), K, S); }
    @@ -261,7 +261,7 @@ in such cases, this function must exist in the kits somewhere.

    -void EmitCode::inv(inter_ti bip) {
    +void EmitCode::inv(inter_ti bip) {
         Produce::inv_primitive(Emit::tree(), bip);
     }
     
    @@ -317,7 +317,7 @@ advance:
     }
     
    diff --git a/docs/runtime-module/2-emt.html b/docs/runtime-module/2-emt.html index 11b3cdc14..8a2de1335 100644 --- a/docs/runtime-module/2-emt.html +++ b/docs/runtime-module/2-emt.html @@ -329,7 +329,7 @@ it represents an actual number at run-time, the second if not:

    -inter_name *Emit::numeric_constant(inter_name *con_iname, inter_ti val) {
    +inter_name *Emit::numeric_constant(inter_name *con_iname, inter_ti val) {
         return Emit::numeric_constant_inner(con_iname, val, int_interk, INVALID_IANN);
     }
     
    @@ -379,7 +379,7 @@ it represents an actual number at run-time, the second if not:
     

    -inter_name *Emit::iname_constant(inter_name *con_iname, kind *K, inter_name *val_iname) {
    +inter_name *Emit::iname_constant(inter_name *con_iname, kind *K, inter_name *val_iname) {
         packaging_state save = Packaging::enter_home_of(con_iname);
         inter_symbol *con_s = Produce::define_symbol(con_iname);
         inter_symbol *kind_s = Produce::kind_to_symbol(K);
    @@ -593,7 +593,7 @@ assimilating during linking.
     }
     
    diff --git a/docs/runtime-module/2-es.html b/docs/runtime-module/2-es.html index 0a833318b..4d1829c28 100644 --- a/docs/runtime-module/2-es.html +++ b/docs/runtime-module/2-es.html @@ -128,7 +128,7 @@ data, not merely the pointer to them, which is a "deep copy". }
    diff --git a/docs/runtime-module/2-hnae.html b/docs/runtime-module/2-hnae.html index e24a20dfc..744975b93 100644 --- a/docs/runtime-module/2-hnae.html +++ b/docs/runtime-module/2-hnae.html @@ -130,7 +130,7 @@ ever change our minds about that. }
    diff --git a/docs/runtime-module/2-hrr.html b/docs/runtime-module/2-hrr.html index 2a4234679..44a1ee650 100644 --- a/docs/runtime-module/2-hrr.html +++ b/docs/runtime-module/2-hrr.html @@ -827,6 +827,7 @@ that the compiler can refer to it. enum TSD_DOOR_TO_FN_HL enum INLINE_PROPERTIES_HAP enum INLINE_PROPERTY_HL +enum DIRECTION_HL

    §8.1.24. Establish instances8.1.24 =

    @@ -862,6 +863,7 @@ that the compiler can refer to it. H_BEGIN_AP(INLINE_PROPERTIES_HAP, I"inline_property", I"_inline_property") H_C_U(INLINE_PROPERTY_HL, I"inline") H_END + H_C_G(DIRECTION_HL, I"DirectionObject") H_END H_END @@ -876,8 +878,6 @@ that the compiler can refer to it. enum NO_DIRECTIONS_HL enum MAP_STORAGE_HL enum INITIALSITUATION_HL -enum DIRECTIONS_HAP -enum DIRECTION_HL

    §8.1.26. Establish int-fiction8.1.26 =

    @@ -897,9 +897,6 @@ that the compiler can refer to it. H_C_T(NO_DIRECTIONS_HL, I"No_Directions") H_C_T(MAP_STORAGE_HL, I"Map_Storage") H_C_T(INITIALSITUATION_HL, I"InitialSituation") - H_BEGIN_AP(DIRECTIONS_HAP, I"direction", I"_direction") - H_C_G(DIRECTION_HL, I"DirectionObject") - H_END H_END @@ -1614,7 +1611,7 @@ at which this array should be placed, by calling, e.g.,
    -inter_name *Hierarchy::find(int id) {
    +inter_name *Hierarchy::find(int id) {
         return HierarchyLocations::find(Emit::tree(), id);
     }
     
    @@ -1637,7 +1634,7 @@ package holding it. (P

    -inter_name *Hierarchy::make_iname_in(int id, package_request *P) {
    +inter_name *Hierarchy::make_iname_in(int id, package_request *P) {
         return HierarchyLocations::find_in_package(Emit::tree(), id, P, EMPTY_WORDING,
             NULL, -1, NULL);
     }
    @@ -1699,7 +1696,7 @@ available", using the following, which creates a socket. Again, see
     

    -void Hierarchy::make_available(inter_name *iname) {
    +void Hierarchy::make_available(inter_name *iname) {
         text_stream *ma_as = Produce::get_translation(iname);
         if (Str::len(ma_as) == 0) ma_as = InterNames::to_text(iname);
         PackageTypes::get(Emit::tree(), I"_linkage");
    @@ -1753,7 +1750,7 @@ compilation unit is meant: that's why it's "synoptic".
     

    -package_request *Hierarchy::synoptic_package(int hap_id) {
    +package_request *Hierarchy::synoptic_package(int hap_id) {
         return HierarchyLocations::attach_new_package(Emit::tree(), NULL, NULL, hap_id);
     }
     
    @@ -1780,7 +1777,7 @@ will automatically trip, in order to enforce the layout rules.
     

    -package_request *Hierarchy::package_within(int hap_id, package_request *super) {
    +package_request *Hierarchy::package_within(int hap_id, package_request *super) {
         return HierarchyLocations::attach_new_package(Emit::tree(), NULL, super, hap_id);
     }
     
    @@ -1827,7 +1824,7 @@ point system, and for those: }
    diff --git a/docs/runtime-module/2-int.html b/docs/runtime-module/2-int.html index f9e17c478..bc7aa2ba6 100644 --- a/docs/runtime-module/2-int.html +++ b/docs/runtime-module/2-int.html @@ -300,7 +300,7 @@ to reject it again with a problem message.
    • This code is used in §4.
    diff --git a/docs/runtime-module/2-kd.html b/docs/runtime-module/2-kd.html index b03c345b3..e8751867d 100644 --- a/docs/runtime-module/2-kd.html +++ b/docs/runtime-module/2-kd.html @@ -333,7 +333,7 @@ source text.
    • This code is used in §9.
    diff --git a/docs/runtime-module/2-ni.html b/docs/runtime-module/2-ni.html index 6d5ca9c3f..df17f6614 100644 --- a/docs/runtime-module/2-ni.html +++ b/docs/runtime-module/2-ni.html @@ -145,7 +145,7 @@ mutate the name in order to achieve that uniqueness. } diff --git a/docs/runtime-module/2-sc.html b/docs/runtime-module/2-sc.html index 6a2ee46fe..7cdd38dfc 100644 --- a/docs/runtime-module/2-sc.html +++ b/docs/runtime-module/2-sc.html @@ -510,7 +510,7 @@ turn by turn.
    • This code is used in §6.2.
    diff --git a/docs/runtime-module/2-sn.html b/docs/runtime-module/2-sn.html index 6d5ef280b..3e7239aeb 100644 --- a/docs/runtime-module/2-sn.html +++ b/docs/runtime-module/2-sn.html @@ -232,7 +232,7 @@ short name, and FALSE<
    • This code is used in §4.
    diff --git a/docs/runtime-module/2-sv.html b/docs/runtime-module/2-sv.html index 58a3266f4..264b75c26 100644 --- a/docs/runtime-module/2-sv.html +++ b/docs/runtime-module/2-sv.html @@ -168,7 +168,7 @@ need to come into being.
    • This code is used in §1.
    diff --git a/docs/runtime-module/2-th.html b/docs/runtime-module/2-th.html index b4bb815a5..87cbee243 100644 --- a/docs/runtime-module/2-th.html +++ b/docs/runtime-module/2-th.html @@ -216,7 +216,7 @@ in Flex (in BasicInformK } diff --git a/docs/runtime-module/3-cm.html b/docs/runtime-module/3-cm.html index fc54a2094..04b7ba11d 100644 --- a/docs/runtime-module/3-cm.html +++ b/docs/runtime-module/3-cm.html @@ -132,7 +132,7 @@
    • This code is used in §1.
    diff --git a/docs/runtime-module/3-gm.html b/docs/runtime-module/3-gm.html index 67010baa1..c2af6c146 100644 --- a/docs/runtime-module/3-gm.html +++ b/docs/runtime-module/3-gm.html @@ -190,7 +190,7 @@ in the VM can be added to it without it becoming negative. } diff --git a/docs/runtime-module/3-uo.html b/docs/runtime-module/3-uo.html index a6caf9772..8867d06e5 100644 --- a/docs/runtime-module/3-uo.html +++ b/docs/runtime-module/3-uo.html @@ -222,7 +222,7 @@ made in that second case would be something like
    • This code is used in §1.
    diff --git a/docs/runtime-module/4-bq.html b/docs/runtime-module/4-bq.html index 097326f61..c92f5e3b4 100644 --- a/docs/runtime-module/4-bq.html +++ b/docs/runtime-module/4-bq.html @@ -169,7 +169,7 @@ tiny array inside the same enclosure as the box function. } diff --git a/docs/runtime-module/4-enc.html b/docs/runtime-module/4-enc.html index 4e5128ac7..f08239331 100644 --- a/docs/runtime-module/4-enc.html +++ b/docs/runtime-module/4-enc.html @@ -136,7 +136,7 @@ same size of small block. } diff --git a/docs/runtime-module/4-gt.html b/docs/runtime-module/4-gt.html index 4bc0a621d..12393fd60 100644 --- a/docs/runtime-module/4-gt.html +++ b/docs/runtime-module/4-gt.html @@ -197,7 +197,7 @@ following, which returns a text literal to print a listing grouped as asked. } diff --git a/docs/runtime-module/4-ll.html b/docs/runtime-module/4-ll.html index 749407dff..a79dfb0c3 100644 --- a/docs/runtime-module/4-ll.html +++ b/docs/runtime-module/4-ll.html @@ -301,7 +301,7 @@ not in creation order, as a simple
  • This code is used in §7.
  • diff --git a/docs/runtime-module/4-rl.html b/docs/runtime-module/4-rl.html index 77077dd12..839265874 100644 --- a/docs/runtime-module/4-rl.html +++ b/docs/runtime-module/4-rl.html @@ -122,7 +122,7 @@ See Relations and }
    diff --git a/docs/runtime-module/4-rsp.html b/docs/runtime-module/4-rsp.html index 092e8490e..774d503e7 100644 --- a/docs/runtime-module/4-rsp.html +++ b/docs/runtime-module/4-rsp.html @@ -485,7 +485,7 @@ it responds.
    • This code is used in §7.
    diff --git a/docs/runtime-module/4-sal.html b/docs/runtime-module/4-sal.html index 50e442ace..b1d041ed4 100644 --- a/docs/runtime-module/4-sal.html +++ b/docs/runtime-module/4-sal.html @@ -163,7 +163,7 @@ therefore always 0 for literal actions. } diff --git a/docs/runtime-module/4-tl.html b/docs/runtime-module/4-tl.html index 82f4f49ea..75cda4399 100644 --- a/docs/runtime-module/4-tl.html +++ b/docs/runtime-module/4-tl.html @@ -192,7 +192,7 @@ much later in the process. See }
    diff --git a/docs/runtime-module/4-ts.html b/docs/runtime-module/4-ts.html index 53a5dab78..27785d464 100644 --- a/docs/runtime-module/4-ts.html +++ b/docs/runtime-module/4-ts.html @@ -471,7 +471,7 @@ local names being used in substitutions, since this often confuses newcomers: } diff --git a/docs/runtime-module/5-act.html b/docs/runtime-module/5-act.html index 34b586ed6..5245942e8 100644 --- a/docs/runtime-module/5-act.html +++ b/docs/runtime-module/5-act.html @@ -169,7 +169,7 @@ write 0. } diff --git a/docs/runtime-module/5-act2.html b/docs/runtime-module/5-act2.html index bfd131317..3eaf71117 100644 --- a/docs/runtime-module/5-act2.html +++ b/docs/runtime-module/5-act2.html @@ -451,7 +451,7 @@ the function is attached to. } diff --git a/docs/runtime-module/5-adj.html b/docs/runtime-module/5-adj.html index bc8d64d09..6a1c9a457 100644 --- a/docs/runtime-module/5-adj.html +++ b/docs/runtime-module/5-adj.html @@ -665,7 +665,7 @@ as "a container is roomy if its carrying capacity is 20 or more".
    • The structure measurement_compilation_data is private to this section.
    diff --git a/docs/runtime-module/5-bi.html b/docs/runtime-module/5-bi.html index b798b8fc1..069e6f1b3 100644 --- a/docs/runtime-module/5-bi.html +++ b/docs/runtime-module/5-bi.html @@ -145,7 +145,7 @@ the current location
    • This code is used in §2.
    diff --git a/docs/runtime-module/5-chr.html b/docs/runtime-module/5-chr.html index ec31bc550..23e151b09 100644 --- a/docs/runtime-module/5-chr.html +++ b/docs/runtime-module/5-chr.html @@ -551,7 +551,7 @@ the pattern, and otherwise false. } diff --git a/docs/runtime-module/5-cnj.html b/docs/runtime-module/5-cnj.html index 77f37bf77..196b699ed 100644 --- a/docs/runtime-module/5-cnj.html +++ b/docs/runtime-module/5-cnj.html @@ -685,7 +685,7 @@ packages occur as sub-packages of the relevant } diff --git a/docs/runtime-module/5-di.html b/docs/runtime-module/5-di.html new file mode 100644 index 000000000..11b92ce44 --- /dev/null +++ b/docs/runtime-module/5-di.html @@ -0,0 +1,282 @@ + + + + Door Instances + + + + + + + + + + + + + + + + + + +
    + + +

    Property values for two-sided doors to make them interconnect with the map at runtime.

    + +
    + +

    §1. The I6 implementation of two-way doors is quite complicated; see the Inform +Designer's Manual, fourth edition (the "DM4") for explanations, but basically +it means giving instances of such doors three low-level properties — +

    + +
    • door_dir, the map direction through the door; +
    • door_to, the room on the other side; +
    • found_in, the two rooms in which the door is located. +
    +

    We continue to use that implementation because there is no pressing reason to +change it: I7 authors are never even aware of how this is all done, and do not +have to see or think about these properties. +

    + +

    §2. Door direction.

    + +
    +typedef struct door_dir_notice {
    +    struct inter_name *ddn_iname;
    +    struct instance *door;
    +    struct instance *R1;
    +    struct instance *D1;
    +    struct instance *D2;
    +    CLASS_DEFINITION
    +} door_dir_notice;
    +
    +parse_node *RTDoors::door_dir_for_2_sided(instance *I, instance *R1, instance *D1,
    +    instance *D2) {
    +    door_dir_notice *notice = CREATE(door_dir_notice);
    +    notice->ddn_iname =
    +        Hierarchy::make_iname_in(TSD_DOOR_DIR_FN_HL, RTInstances::package(I));
    +    notice->door = I;
    +    notice->R1 = R1;
    +    notice->D1 = D1;
    +    notice->D2 = D2;
    +    text_stream *desc = Str::new();
    +    WRITE_TO(desc, "door_dir for "); Instances::write(desc, I);
    +    Sequence::queue(&RTDoors::door_dir_agent, STORE_POINTER_door_dir_notice(notice), desc);
    +    return Rvalues::from_iname(notice->ddn_iname);
    +}
    +
    +
    • The structure door_dir_notice is private to this section.
    +

    §3. So, then, this is a function: see the DM4 for specification. +

    + +
    +void RTDoors::door_dir_agent(compilation_subtask *t) {
    +    door_dir_notice *notice = RETRIEVE_POINTER_door_dir_notice(t->data);
    +    packaging_state save = Functions::begin(notice->ddn_iname);
    +    local_variable *loc = LocalVariables::new_internal_commented(I"loc", I"room of actor");
    +    inter_symbol *loc_s = LocalVariables::declare(loc);
    +    EmitCode::inv(STORE_BIP);
    +    EmitCode::down();
    +        EmitCode::ref_symbol(K_value, loc_s);
    +        EmitCode::val_iname(K_value, Hierarchy::find(LOCATION_HL));
    +    EmitCode::up();
    +
    +    EmitCode::inv(IF_BIP);
    +    EmitCode::down();
    +        EmitCode::inv(EQ_BIP);
    +        EmitCode::down();
    +            EmitCode::val_symbol(K_value, loc_s);
    +            EmitCode::val_iname(K_value, Hierarchy::find(THEDARK_HL));
    +        EmitCode::up();
    +        EmitCode::code();
    +        EmitCode::down();
    +            EmitCode::inv(STORE_BIP);
    +            EmitCode::down();
    +                EmitCode::ref_symbol(K_value, loc_s);
    +                EmitCode::val_iname(K_value, Hierarchy::find(REAL_LOCATION_HL));
    +            EmitCode::up();
    +        EmitCode::up();
    +    EmitCode::up();
    +
    +    EmitCode::inv(IF_BIP);
    +    EmitCode::down();
    +        EmitCode::inv(EQ_BIP);
    +        EmitCode::down();
    +            EmitCode::val_symbol(K_value, loc_s);
    +            EmitCode::val_iname(K_value, RTInstances::value_iname(notice->R1));
    +        EmitCode::up();
    +        EmitCode::code();
    +        EmitCode::down();
    +            EmitCode::inv(RETURN_BIP);
    +            EmitCode::down();
    +                EmitCode::val_iname(K_value,
    +                    RTInstances::value_iname(Map::get_value_of_opposite_property(notice->D1)));
    +            EmitCode::up();
    +        EmitCode::up();
    +    EmitCode::up();
    +
    +    EmitCode::inv(RETURN_BIP);
    +    EmitCode::down();
    +        EmitCode::val_iname(K_value,
    +            RTInstances::value_iname(Map::get_value_of_opposite_property(notice->D2)));
    +    EmitCode::up();
    +
    +    Functions::end(save);
    +}
    +
    +

    §4. Door to.

    + +
    +typedef struct door_to_notice {
    +    struct inter_name *dtn_iname;
    +    struct instance *door;
    +    struct instance *R1;
    +    struct instance *R2;
    +    CLASS_DEFINITION
    +} door_to_notice;
    +
    +parse_node *RTDoors::door_to_for_2_sided(instance *I, instance *R1, instance *R2) {
    +    door_to_notice *notice = CREATE(door_to_notice);
    +    notice->dtn_iname =
    +        Hierarchy::make_iname_in(TSD_DOOR_TO_FN_HL, RTInstances::package(I));
    +    notice->door = I;
    +    notice->R1 = R1;
    +    notice->R2 = R2;
    +    text_stream *desc = Str::new();
    +    WRITE_TO(desc, "door_to for "); Instances::write(desc, I);
    +    Sequence::queue(&RTDoors::door_to_agent, STORE_POINTER_door_to_notice(notice), desc);
    +    return Rvalues::from_iname(notice->dtn_iname);
    +}
    +
    +
    • The structure door_to_notice is private to this section.
    +

    §5. Another function: see the DM4 for specification. +

    + +
    +void RTDoors::door_to_agent(compilation_subtask *t) {
    +    door_to_notice *notice = RETRIEVE_POINTER_door_to_notice(t->data);
    +    packaging_state save = Functions::begin(notice->dtn_iname);
    +    local_variable *loc = LocalVariables::new_internal_commented(I"loc", I"room of actor");
    +    inter_symbol *loc_s = LocalVariables::declare(loc);
    +    EmitCode::inv(STORE_BIP);
    +    EmitCode::down();
    +        EmitCode::ref_symbol(K_value, loc_s);
    +        EmitCode::val_iname(K_value, Hierarchy::find(LOCATION_HL));
    +    EmitCode::up();
    +
    +    EmitCode::inv(IF_BIP);
    +    EmitCode::down();
    +        EmitCode::inv(EQ_BIP);
    +        EmitCode::down();
    +            EmitCode::val_symbol(K_value, loc_s);
    +            EmitCode::val_iname(K_value, Hierarchy::find(THEDARK_HL));
    +        EmitCode::up();
    +        EmitCode::code();
    +        EmitCode::down();
    +            EmitCode::inv(STORE_BIP);
    +            EmitCode::down();
    +                EmitCode::ref_symbol(K_value, loc_s);
    +                EmitCode::val_iname(K_value, Hierarchy::find(REAL_LOCATION_HL));
    +            EmitCode::up();
    +        EmitCode::up();
    +    EmitCode::up();
    +
    +    EmitCode::inv(IF_BIP);
    +    EmitCode::down();
    +        EmitCode::inv(EQ_BIP);
    +        EmitCode::down();
    +            EmitCode::val_symbol(K_value, loc_s);
    +            EmitCode::val_iname(K_value, RTInstances::value_iname(notice->R1));
    +        EmitCode::up();
    +        EmitCode::code();
    +        EmitCode::down();
    +            EmitCode::inv(RETURN_BIP);
    +            EmitCode::down();
    +                EmitCode::val_iname(K_value, RTInstances::value_iname(notice->R2));
    +            EmitCode::up();
    +        EmitCode::up();
    +    EmitCode::up();
    +
    +    EmitCode::inv(RETURN_BIP);
    +    EmitCode::down();
    +        EmitCode::val_iname(K_value, RTInstances::value_iname(notice->R1));
    +    EmitCode::up();
    +
    +    Functions::end(save);
    +}
    +
    +

    §6. Found in. And this is a two-element array, simply giving the two rooms R1 and R2 +which the door is found in: +

    + +
    +parse_node *RTDoors::found_in_for_2_sided(instance *I, instance *R1, instance *R2) {
    +    package_request *PR =
    +        Hierarchy::package_within(INLINE_PROPERTIES_HAP, RTInstances::package(I));
    +    inter_name *S = Hierarchy::make_iname_in(INLINE_PROPERTY_HL, PR);
    +    packaging_state save = EmitArrays::begin(S, K_value);
    +    EmitArrays::iname_entry(RTInstances::value_iname(R1));
    +    EmitArrays::iname_entry(RTInstances::value_iname(R2));
    +    EmitArrays::end(save);
    +    Produce::annotate_i(S, INLINE_ARRAY_IANN, 1);
    +    return Rvalues::from_iname(S);
    +}
    +
    + + +
    + + + diff --git a/docs/runtime-module/5-eqt.html b/docs/runtime-module/5-eqt.html index 65447e0fa..31ab4d963 100644 --- a/docs/runtime-module/5-eqt.html +++ b/docs/runtime-module/5-eqt.html @@ -100,7 +100,7 @@ not here; see Compil
    • The structure equation_compilation_data is private to this section.
    diff --git a/docs/runtime-module/5-ins.html b/docs/runtime-module/5-ins.html index 811c1f074..5b9793454 100644 --- a/docs/runtime-module/5-ins.html +++ b/docs/runtime-module/5-ins.html @@ -91,12 +91,12 @@ function togglePopup(material_id) { NounIdentifiers::set_iname(I->as_noun, I->icd.instance_iname); } -inter_name *RTInstances::value_iname(instance *I) { +inter_name *RTInstances::value_iname(instance *I) { if (I == NULL) return NULL; return I->icd.instance_iname; } -package_request *RTInstances::package(instance *I) { +package_request *RTInstances::package(instance *I) { return I->icd.instance_package; } @@ -182,7 +182,7 @@ using Inter's INSTANCE_IST} diff --git a/docs/runtime-module/5-kc.html b/docs/runtime-module/5-kc.html index 6c2fed57d..85218e9ff 100644 --- a/docs/runtime-module/5-kc.html +++ b/docs/runtime-module/5-kc.html @@ -1021,7 +1021,7 @@ and b inclusive diff --git a/docs/runtime-module/5-ki.html b/docs/runtime-module/5-ki.html index 327e22d02..c16dcc768 100644 --- a/docs/runtime-module/5-ki.html +++ b/docs/runtime-module/5-ki.html @@ -507,7 +507,7 @@ been done at compile time. } diff --git a/docs/runtime-module/5-lp.html b/docs/runtime-module/5-lp.html index 997222e79..2e70654b6 100644 --- a/docs/runtime-module/5-lp.html +++ b/docs/runtime-module/5-lp.html @@ -1622,7 +1622,7 @@ the sorting measure. } diff --git a/docs/runtime-module/5-mlt.html b/docs/runtime-module/5-mlt.html index 77b6a45c5..ec06256fc 100644 --- a/docs/runtime-module/5-mlt.html +++ b/docs/runtime-module/5-mlt.html @@ -174,7 +174,7 @@ array.
    • This code is used in §2.
    diff --git a/docs/runtime-module/5-nap.html b/docs/runtime-module/5-nap.html index 549e4a477..8b60c40d6 100644 --- a/docs/runtime-module/5-nap.html +++ b/docs/runtime-module/5-nap.html @@ -147,7 +147,7 @@ the current action fits the named pattern or not. } diff --git a/docs/runtime-module/5-prp.html b/docs/runtime-module/5-prp.html index 5e7a8b56c..18bc9c7a7 100644 --- a/docs/runtime-module/5-prp.html +++ b/docs/runtime-module/5-prp.html @@ -538,7 +538,7 @@ answer now.
    • This code is used in §11.
    diff --git a/docs/runtime-module/5-ri.html b/docs/runtime-module/5-ri.html index 60f582a4c..640f31b6d 100644 --- a/docs/runtime-module/5-ri.html +++ b/docs/runtime-module/5-ri.html @@ -112,7 +112,7 @@ player's current location lies in the given region. } diff --git a/docs/runtime-module/5-rlb.html b/docs/runtime-module/5-rlb.html index 745c8f279..70705a986 100644 --- a/docs/runtime-module/5-rlb.html +++ b/docs/runtime-module/5-rlb.html @@ -726,7 +726,7 @@ questionable arrangement, but there it is). } diff --git a/docs/runtime-module/5-rls.html b/docs/runtime-module/5-rls.html index 1fc8b3abd..15e342d34 100644 --- a/docs/runtime-module/5-rls.html +++ b/docs/runtime-module/5-rls.html @@ -742,7 +742,7 @@ with the default outcome return (see above). diff --git a/docs/runtime-module/5-rlt.html b/docs/runtime-module/5-rlt.html index 376ab4ddd..02021c224 100644 --- a/docs/runtime-module/5-rlt.html +++ b/docs/runtime-module/5-rlt.html @@ -2103,7 +2103,7 @@ matches the specific necessary kind of object if there is one. } diff --git a/docs/runtime-module/5-tbl.html b/docs/runtime-module/5-tbl.html index 3458d42fb..62226834b 100644 --- a/docs/runtime-module/5-tbl.html +++ b/docs/runtime-module/5-tbl.html @@ -488,7 +488,7 @@ should return FALSE} diff --git a/docs/runtime-module/5-tc.html b/docs/runtime-module/5-tc.html index f6df5ee41..c36901e1c 100644 --- a/docs/runtime-module/5-tc.html +++ b/docs/runtime-module/5-tc.html @@ -124,7 +124,7 @@ to the column-ID constant, and let the linker choose a value for that. } diff --git a/docs/runtime-module/5-vrb.html b/docs/runtime-module/5-vrb.html index d10b0f561..063af3c3a 100644 --- a/docs/runtime-module/5-vrb.html +++ b/docs/runtime-module/5-vrb.html @@ -549,7 +549,7 @@ which makes its kind safe.
    • This code is used in §15.
    diff --git a/docs/runtime-module/6-bd.html b/docs/runtime-module/6-bd.html index 6ce7d57a4..856111ea1 100644 --- a/docs/runtime-module/6-bd.html +++ b/docs/runtime-module/6-bd.html @@ -213,7 +213,7 @@ around it, in byte-accessible memory. } diff --git a/docs/runtime-module/6-tm.html b/docs/runtime-module/6-tm.html new file mode 100644 index 000000000..063991388 --- /dev/null +++ b/docs/runtime-module/6-tm.html @@ -0,0 +1,145 @@ + + + + The Map + + + + + + + + + + + + + + + +
    + + +

    The runtime representation of the spatial map for works of interactive fiction: that is, how the rooms and doors connect up.

    + +

    §1. One of the few early breaks with I6 practice was that I7 stores the +map differently at run-time compared to earlier I6 games. +

    + +

    The Map_Storage array consists only of the exits arrays written out +one after another. It looks wasteful of memory, since it is almost always +going to be filled mostly with 0 entries (meaning: no exit that way). But +the memory needs to be there because map connections can be added dynamically +at run-time, so we can't know now how many we will need. +

    + +
    +int RTMap::compile_model_tables(void) {
    +    inter_name *ndi = Hierarchy::find(NO_DIRECTIONS_HL);
    +    Emit::numeric_constant(ndi, (inter_ti) Map::number_of_directions());
    +    Hierarchy::make_available(ndi);
    +
    +    instance *I;
    +    LOOP_OVER_INSTANCES(I, K_object)
    +        RTInstances::value_iname(I);
    +    inter_name *iname = Hierarchy::find(MAP_STORAGE_HL);
    +    packaging_state save = EmitArrays::begin(iname, K_object);
    +    int words_used = 0;
    +    if (Task::wraps_existing_storyfile()) {
    +        EmitArrays::divider(I"minimal, as there are no rooms");
    +        EmitArrays::iname_entry(NULL);
    +        EmitArrays::iname_entry(NULL);
    +        EmitArrays::iname_entry(NULL);
    +        EmitArrays::iname_entry(NULL);
    +        words_used = 4;
    +    } else {
    +        EmitArrays::divider(I"one row per room");
    +        instance *I;
    +        LOOP_OVER_INSTANCES(I, K_object)
    +            if (Spatial::object_is_a_room(I)) {
    +                int N = Map::number_of_directions();
    +                for (int i=0; i<N; i++) {
    +                    instance *to = MAP_EXIT(I, i);
    +                    if (to)
    +                        EmitArrays::iname_entry(RTInstances::value_iname(to));
    +                    else
    +                        EmitArrays::numeric_entry(0);
    +                }
    +                words_used++;
    +                TEMPORARY_TEXT(divider)
    +                WRITE_TO(divider, "Exits from: %~I", I);
    +                EmitArrays::divider(divider);
    +                DISCARD_TEXT(divider)
    +            }
    +    }
    +    EmitArrays::end(save);
    +    Hierarchy::make_available(iname);
    +    return FALSE;
    +}
    +
    +

    §2. This may as well be here as anywhere else: it specifies how to read or +change the map, by testing or asserting the "mapped D of" relation for a +given direction D, which appears here in the guise of its instance I: +

    + +
    +void RTMap::set_map_schemas(binary_predicate *bp, instance *I) {
    +    inter_name *ident = RTInstances::value_iname(I);
    +    bp->task_functions[TEST_ATOM_TASK] =
    +        Calculus::Schemas::new("(MapConnection(*2,%n) == *1)", ident);
    +    bp->task_functions[NOW_ATOM_TRUE_TASK] =
    +        Calculus::Schemas::new("AssertMapConnection(*2,%n,*1)", ident);
    +    bp->task_functions[NOW_ATOM_FALSE_TASK] =
    +        Calculus::Schemas::new("AssertMapUnconnection(*2,%n,*1)", ident);
    +}
    +
    + + +
    + + + diff --git a/docs/runtime-module/6-tp.html b/docs/runtime-module/6-tp.html index a066b54ec..8de54f70e 100644 --- a/docs/runtime-module/6-tp.html +++ b/docs/runtime-module/6-tp.html @@ -124,7 +124,7 @@ the function ChangePlayer} diff --git a/docs/runtime-module/7-ap.html b/docs/runtime-module/7-ap.html index a58cb24fa..2a6619c77 100644 --- a/docs/runtime-module/7-ap.html +++ b/docs/runtime-module/7-ap.html @@ -871,7 +871,7 @@ and in this case we therefore ignore } diff --git a/docs/runtime-module/7-cg.html b/docs/runtime-module/7-cg.html index 0c57703e7..16f7abcda 100644 --- a/docs/runtime-module/7-cg.html +++ b/docs/runtime-module/7-cg.html @@ -457,7 +457,7 @@ next priority, and so on up the hierarchy. } diff --git a/docs/runtime-module/7-cgl.html b/docs/runtime-module/7-cgl.html index 2e0e76ad3..92aacfa14 100644 --- a/docs/runtime-module/7-cgl.html +++ b/docs/runtime-module/7-cgl.html @@ -1635,7 +1635,7 @@ nothing else. diff --git a/docs/runtime-module/7-epv.html b/docs/runtime-module/7-epv.html index cc19bfaf4..b0ea87532 100644 --- a/docs/runtime-module/7-epv.html +++ b/docs/runtime-module/7-epv.html @@ -529,7 +529,7 @@ and it seems best to reject the extra complexity needed. } diff --git a/docs/runtime-module/7-gng.html b/docs/runtime-module/7-gng.html index 2e816ea93..d5ebb61be 100644 --- a/docs/runtime-module/7-gng.html +++ b/docs/runtime-module/7-gng.html @@ -135,7 +135,7 @@ } diff --git a/docs/runtime-module/7-gpr.html b/docs/runtime-module/7-gpr.html index 0b6775c42..607a25f95 100644 --- a/docs/runtime-module/7-gpr.html +++ b/docs/runtime-module/7-gpr.html @@ -1324,7 +1324,7 @@ alter the value of self} diff --git a/docs/runtime-module/7-ic.html b/docs/runtime-module/7-ic.html index 26345e031..cfc40157e 100644 --- a/docs/runtime-module/7-ic.html +++ b/docs/runtime-module/7-ic.html @@ -502,7 +502,7 @@ constants, and use the Link constants to progress; we stop at } diff --git a/docs/runtime-module/7-los.html b/docs/runtime-module/7-los.html index 68ddc6e62..905529b18 100644 --- a/docs/runtime-module/7-los.html +++ b/docs/runtime-module/7-los.html @@ -135,7 +135,7 @@ function togglePopup(material_id) { } diff --git a/docs/runtime-module/7-nft.html b/docs/runtime-module/7-nft.html index 3ead5d289..464f60152 100644 --- a/docs/runtime-module/7-nft.html +++ b/docs/runtime-module/7-nft.html @@ -352,7 +352,7 @@ that's why.) } diff --git a/docs/runtime-module/7-prs.html b/docs/runtime-module/7-prs.html index 8b47b31bd..b62b83668 100644 --- a/docs/runtime-module/7-prs.html +++ b/docs/runtime-module/7-prs.html @@ -185,7 +185,7 @@ for the kinds we inherit from.
    • The structure cached_understanding is private to this section.
    diff --git a/docs/runtime-module/7-scn.html b/docs/runtime-module/7-scn.html index 1f4ef9a60..db78f0fab 100644 --- a/docs/runtime-module/7-scn.html +++ b/docs/runtime-module/7-scn.html @@ -724,7 +724,7 @@ actually running: } diff --git a/docs/runtime-module/7-tm.html b/docs/runtime-module/7-tm.html deleted file mode 100644 index f977bf2ed..000000000 --- a/docs/runtime-module/7-tm.html +++ /dev/null @@ -1,350 +0,0 @@ - - - - The Map - - - - - - - - - - - - - - - -
    - - -
    - -

    §1.

    - -
    -inter_name *RTMap::new_direction_iname(void) {
    -    package_request *PR = Hierarchy::synoptic_package(DIRECTIONS_HAP);
    -    return Hierarchy::make_iname_in(DIRECTION_HL, PR);
    -}
    -
    -

    §2. One of the few early breaks with I6 practice was that I7 stores the -map differently at run-time compared to earlier I6 games. -

    - -
    -int RTMap::compile_model_tables(void) {
    -    Declare I6 constants for the directions2.1;
    -    Compile the I6 Map-Storage array2.2;
    -    return FALSE;
    -}
    -
    -

    §2.1. Declare I6 constants for the directions2.1 = -

    - -
    -    inter_name *ndi = Hierarchy::find(NO_DIRECTIONS_HL);
    -    Emit::numeric_constant(ndi, (inter_ti) Map::number_of_directions());
    -    Hierarchy::make_available(ndi);
    -
    -    instance *I;
    -    LOOP_OVER_INSTANCES(I, K_direction)
    -        Emit::iname_constant(MAP_DATA(I)->direction_iname, K_object,
    -            RTInstances::value_iname(I));
    -
    -
    • This code is used in §2.
    -

    §2.2. The Map_Storage array consists only of the exits arrays written out -one after another. It looks wasteful of memory, since it is almost always -going to be filled mostly with 0 entries (meaning: no exit that way). But -the memory needs to be there because map connections can be added dynamically -at run-time, so we can't know now how many we will need. -

    - -

    Compile the I6 Map-Storage array2.2 = -

    - -
    -    instance *I;
    -    LOOP_OVER_INSTANCES(I, K_object)
    -        RTInstances::value_iname(I);
    -    inter_name *iname = Hierarchy::find(MAP_STORAGE_HL);
    -    packaging_state save = EmitArrays::begin(iname, K_object);
    -    int words_used = 0;
    -    if (Task::wraps_existing_storyfile()) {
    -        EmitArrays::divider(I"minimal, as there are no rooms");
    -        EmitArrays::iname_entry(NULL);
    -        EmitArrays::iname_entry(NULL);
    -        EmitArrays::iname_entry(NULL);
    -        EmitArrays::iname_entry(NULL);
    -        words_used = 4;
    -    } else {
    -        EmitArrays::divider(I"one row per room");
    -        instance *I;
    -        LOOP_OVER_INSTANCES(I, K_object)
    -            if (Spatial::object_is_a_room(I)) {
    -                int N = Map::number_of_directions();
    -                for (int i=0; i<N; i++) {
    -                    instance *to = MAP_EXIT(I, i);
    -                    if (to)
    -                        EmitArrays::iname_entry(RTInstances::value_iname(to));
    -                    else
    -                        EmitArrays::numeric_entry(0);
    -                }
    -                words_used++;
    -                TEMPORARY_TEXT(divider)
    -                WRITE_TO(divider, "Exits from: %~I", I);
    -                EmitArrays::divider(divider);
    -                DISCARD_TEXT(divider)
    -            }
    -    }
    -    EmitArrays::end(save);
    -    Hierarchy::make_available(iname);
    -
    -
    • This code is used in §2.
    -

    §3. Two-sided doors. The I6 implementation of two-way doors and of what, in I7, are called backdrops, -is quite complicated; and the Inter code we generate follows that traditional -form. See the Inform Designer's Manual, fourth edition (the "DM4") for explanations. -We are essentially trying to program all of that automatically, which is why these -awkward multi-purpose I6 properties (door_to, found_in, etc.) have no direct -I7 equivalents. -

    - -

    These little structures are needed to remember routines to compile later: -

    - -
    -typedef struct door_dir_notice {
    -    struct inter_name *ddn_iname;
    -    struct instance *door;
    -    struct instance *R1;
    -    struct instance *D1;
    -    struct instance *D2;
    -    CLASS_DEFINITION
    -} door_dir_notice;
    -
    -typedef struct door_to_notice {
    -    struct inter_name *dtn_iname;
    -    struct instance *door;
    -    struct instance *R1;
    -    struct instance *R2;
    -    CLASS_DEFINITION
    -} door_to_notice;
    -
    -parse_node *RTMap::door_dir_for_2_sided(instance *I, instance *R1, instance *D1,
    -    instance *D2) {
    -    door_dir_notice *notice = CREATE(door_dir_notice);
    -    notice->ddn_iname =
    -        Hierarchy::make_iname_in(TSD_DOOR_DIR_FN_HL, RTInstances::package(I));
    -    notice->door = I;
    -    notice->R1 = R1;
    -    notice->D1 = D1;
    -    notice->D2 = D2;
    -    return Rvalues::from_iname(notice->ddn_iname);
    -}
    -
    -parse_node *RTMap::door_to_for_2_sided(instance *I, instance *R1, instance *R2) {
    -    door_to_notice *notice = CREATE(door_to_notice);
    -    notice->dtn_iname =
    -        Hierarchy::make_iname_in(TSD_DOOR_TO_FN_HL, RTInstances::package(I));
    -    notice->door = I;
    -    notice->R1 = R1;
    -    notice->R2 = R2;
    -    return Rvalues::from_iname(notice->dtn_iname);
    -}
    -
    -parse_node *RTMap::found_in_for_2_sided(instance *I, instance *R1, instance *R2) {
    -    package_request *PR =
    -        Hierarchy::package_within(INLINE_PROPERTIES_HAP, RTInstances::package(I));
    -    inter_name *S = Hierarchy::make_iname_in(INLINE_PROPERTY_HL, PR);
    -    packaging_state save = EmitArrays::begin(S, K_value);
    -    EmitArrays::iname_entry(RTInstances::value_iname(R1));
    -    EmitArrays::iname_entry(RTInstances::value_iname(R2));
    -    EmitArrays::end(save);
    -    Produce::annotate_i(S, INLINE_ARRAY_IANN, 1);
    -    return Rvalues::from_iname(S);
    -}
    -
    -
    • The structure door_dir_notice is private to this section.
    • The structure door_to_notice is private to this section.
    -

    §4. Redeeming those notices: -

    - -
    -void RTMap::write_door_dir_routines(void) {
    -    door_dir_notice *notice;
    -    LOOP_OVER(notice, door_dir_notice) {
    -        packaging_state save = Functions::begin(notice->ddn_iname);
    -        local_variable *loc = LocalVariables::new_internal_commented(I"loc", I"room of actor");
    -        inter_symbol *loc_s = LocalVariables::declare(loc);
    -        EmitCode::inv(STORE_BIP);
    -        EmitCode::down();
    -            EmitCode::ref_symbol(K_value, loc_s);
    -            EmitCode::val_iname(K_value, Hierarchy::find(LOCATION_HL));
    -        EmitCode::up();
    -
    -        EmitCode::inv(IF_BIP);
    -        EmitCode::down();
    -            EmitCode::inv(EQ_BIP);
    -            EmitCode::down();
    -                EmitCode::val_symbol(K_value, loc_s);
    -                EmitCode::val_iname(K_value, Hierarchy::find(THEDARK_HL));
    -            EmitCode::up();
    -            EmitCode::code();
    -            EmitCode::down();
    -                EmitCode::inv(STORE_BIP);
    -                EmitCode::down();
    -                    EmitCode::ref_symbol(K_value, loc_s);
    -                    EmitCode::val_iname(K_value, Hierarchy::find(REAL_LOCATION_HL));
    -                EmitCode::up();
    -            EmitCode::up();
    -        EmitCode::up();
    -
    -        EmitCode::inv(IF_BIP);
    -        EmitCode::down();
    -            EmitCode::inv(EQ_BIP);
    -            EmitCode::down();
    -                EmitCode::val_symbol(K_value, loc_s);
    -                EmitCode::val_iname(K_value, RTInstances::value_iname(notice->R1));
    -            EmitCode::up();
    -            EmitCode::code();
    -            EmitCode::down();
    -                EmitCode::inv(RETURN_BIP);
    -                EmitCode::down();
    -                    EmitCode::val_iname(K_value,
    -                        RTInstances::value_iname(Map::get_value_of_opposite_property(notice->D1)));
    -                EmitCode::up();
    -            EmitCode::up();
    -        EmitCode::up();
    -
    -        EmitCode::inv(RETURN_BIP);
    -        EmitCode::down();
    -            EmitCode::val_iname(K_value,
    -                RTInstances::value_iname(Map::get_value_of_opposite_property(notice->D2)));
    -        EmitCode::up();
    -
    -        Functions::end(save);
    -    }
    -}
    -
    -void RTMap::write_door_to_routines(void) {
    -    door_to_notice *notice;
    -    LOOP_OVER(notice, door_to_notice) {
    -        packaging_state save = Functions::begin(notice->dtn_iname);
    -        local_variable *loc = LocalVariables::new_internal_commented(I"loc", I"room of actor");
    -        inter_symbol *loc_s = LocalVariables::declare(loc);
    -        EmitCode::inv(STORE_BIP);
    -        EmitCode::down();
    -            EmitCode::ref_symbol(K_value, loc_s);
    -            EmitCode::val_iname(K_value, Hierarchy::find(LOCATION_HL));
    -        EmitCode::up();
    -
    -        EmitCode::inv(IF_BIP);
    -        EmitCode::down();
    -            EmitCode::inv(EQ_BIP);
    -            EmitCode::down();
    -                EmitCode::val_symbol(K_value, loc_s);
    -                EmitCode::val_iname(K_value, Hierarchy::find(THEDARK_HL));
    -            EmitCode::up();
    -            EmitCode::code();
    -            EmitCode::down();
    -                EmitCode::inv(STORE_BIP);
    -                EmitCode::down();
    -                    EmitCode::ref_symbol(K_value, loc_s);
    -                    EmitCode::val_iname(K_value, Hierarchy::find(REAL_LOCATION_HL));
    -                EmitCode::up();
    -            EmitCode::up();
    -        EmitCode::up();
    -
    -        EmitCode::inv(IF_BIP);
    -        EmitCode::down();
    -            EmitCode::inv(EQ_BIP);
    -            EmitCode::down();
    -                EmitCode::val_symbol(K_value, loc_s);
    -                EmitCode::val_iname(K_value, RTInstances::value_iname(notice->R1));
    -            EmitCode::up();
    -            EmitCode::code();
    -            EmitCode::down();
    -                EmitCode::inv(RETURN_BIP);
    -                EmitCode::down();
    -                    EmitCode::val_iname(K_value, RTInstances::value_iname(notice->R2));
    -                EmitCode::up();
    -            EmitCode::up();
    -        EmitCode::up();
    -
    -        EmitCode::inv(RETURN_BIP);
    -        EmitCode::down();
    -            EmitCode::val_iname(K_value, RTInstances::value_iname(notice->R1));
    -        EmitCode::up();
    -
    -        Functions::end(save);
    -    }
    -}
    -
    -

    §5. ident is an identifier name for the direction instance. It seems redundant -here because surely if we know I, we know its runtime representation; but -that's not true — we need to call this function at a time when the final -identifier names for instance have not yet been settled. -

    - -
    -void RTMap::set_map_schemas(binary_predicate *bp, instance *I) {
    -    inter_name *ident = MAP_DATA(I)->direction_iname;
    -    bp->task_functions[TEST_ATOM_TASK] =
    -        Calculus::Schemas::new("(MapConnection(*2,%n) == *1)", ident);
    -    bp->task_functions[NOW_ATOM_TRUE_TASK] =
    -        Calculus::Schemas::new("AssertMapConnection(*2,%n,*1)", ident);
    -    bp->task_functions[NOW_ATOM_FALSE_TASK] =
    -        Calculus::Schemas::new("AssertMapUnconnection(*2,%n,*1)", ident);
    -}
    -
    - - -
    - - - diff --git a/docs/runtime-module/7-tpv.html b/docs/runtime-module/7-tpv.html index 3c7bfdf7f..bda3aaa0a 100644 --- a/docs/runtime-module/7-tpv.html +++ b/docs/runtime-module/7-tpv.html @@ -441,7 +441,7 @@ function togglePopup(material_id) {
    • This code is used in §1.1 (three times).
    diff --git a/docs/runtime-module/7-ts.html b/docs/runtime-module/7-ts.html index 236a3913a..d627192dc 100644 --- a/docs/runtime-module/7-ts.html +++ b/docs/runtime-module/7-ts.html @@ -296,7 +296,7 @@ stipulations on place and possessions attached. } diff --git a/docs/runtime-module/P-wtmd.html b/docs/runtime-module/P-wtmd.html index 3e241abbe..a2c5ccc50 100644 --- a/docs/runtime-module/P-wtmd.html +++ b/docs/runtime-module/P-wtmd.html @@ -199,7 +199,7 @@ and imperative to

    diff --git a/docs/runtime-module/index.html b/docs/runtime-module/index.html index 3c7d7089f..9056124cc 100644 --- a/docs/runtime-module/index.html +++ b/docs/runtime-module/index.html @@ -276,6 +276,11 @@ Backdrop Instances
    - Some additions to an _instance package for instances of the kind "backdrop".

    +
  • +

    + Door Instances - + Property values for two-sided doors to make them interconnect with the map at runtime.

    +
  • Region Instances - @@ -362,17 +367,17 @@ The Player -

  • +
  • +

    + The Map - + The runtime representation of the spatial map for works of interactive fiction: that is, how the rooms and doors connect up.

    +
  • Chapter 7: Still Unsorted

      -
    • -

      - The Map - -

      -
    • Scenes - diff --git a/inform7/Figures/memory-diagnostics.txt b/inform7/Figures/memory-diagnostics.txt index 2f674e8fe..89f1fd398 100644 --- a/inform7/Figures/memory-diagnostics.txt +++ b/inform7/Figures/memory-diagnostics.txt @@ -1,10 +1,10 @@ -Total memory consumption was 302116K = 295 MB +Total memory consumption was 300505K = 293 MB -63.8% was used for 1491094 objects, in 318774 frames in 241 x 800K = 192800K = 188 MB: +63.6% was used for 1482058 objects, in 318721 frames in 239 x 800K = 191200K = 186 MB: - 9.5% inter_tree_node_array 41 x 8192 = 335872 objects, 29558048 bytes - 6.0% text_stream_array 3328 x 100 = 332800 objects, 18743296 bytes - 5.3% linked_list 29332 objects, 16425920 bytes + 9.3% inter_tree_node_array 40 x 8192 = 327680 objects, 28837120 bytes + 6.0% text_stream_array 3327 x 100 = 332700 objects, 18737664 bytes + 5.3% linked_list 29329 objects, 16424240 bytes 3.3% parse_node 129367 objects, 10349360 bytes 2.7% inter_symbol_array 87 x 1024 = 89088 objects, 8555232 bytes 2.4% verb_conjugation 160 objects, 7425280 bytes @@ -17,19 +17,19 @@ Total memory consumption was 302116K = 295 MB 0.4% inter_name_array 31 x 1000 = 31000 objects, 1488992 bytes 0.4% match_trie_array 10 x 1000 = 10000 objects, 1360320 bytes 0.4% i6_schema_array 21 x 100 = 2100 objects, 1260672 bytes - 0.3% inter_package 15075 objects, 1085400 bytes + 0.3% inter_package 15063 objects, 1084536 bytes 0.3% id_body 940 objects, 1075360 bytes 0.3% inter_name_generator_array 25 x 1000 = 25000 objects, 1000800 bytes 0.3% adjective_meaning 202 objects, 1000304 bytes 0.3% excerpt_meaning 3098 objects, 966576 bytes - 0.3% inter_symbols_table 15075 objects, 964800 bytes - 0.3% dictionary 19937 objects, 956976 bytes + 0.3% inter_symbols_table 15063 objects, 964032 bytes + 0.3% dictionary 19925 objects, 956400 bytes 0.2% production 3871 objects, 898072 bytes - 0.2% dict_entry_array 276 x 100 = 27600 objects, 892032 bytes 0.2% ptoken 8379 objects, 871416 bytes + 0.2% dict_entry_array 269 x 100 = 26900 objects, 869408 bytes 0.2% grammatical_usage 3610 objects, 866400 bytes 0.2% individual_form 2560 objects, 860160 bytes - 0.2% package_request 9649 objects, 849112 bytes + 0.2% package_request 9637 objects, 848056 bytes 0.2% inter_schema_node 8663 objects, 831648 bytes 0.2% unary_predicate_array 16 x 1000 = 16000 objects, 640512 bytes 0.1% local_variable_array 47 x 100 = 4700 objects, 452704 bytes @@ -39,7 +39,7 @@ Total memory consumption was 302116K = 295 MB 0.1% verb_form 386 objects, 345856 bytes ---- noun 2379 objects, 285480 bytes ---- inference_subject 665 objects, 260680 bytes - ---- compilation_subtask 2577 objects, 206160 bytes + ---- compilation_subtask 2587 objects, 206960 bytes ---- inter_annotation_array 1 x 8192 objects, 196640 bytes ---- binary_predicate 321 objects, 169488 bytes ---- linguistic_stock_item 3315 objects, 159120 bytes @@ -54,7 +54,7 @@ Total memory consumption was 302116K = 295 MB ---- anl_entry_array 2 x 1000 = 2000 objects, 96064 bytes ---- noun_usage 2401 objects, 96040 bytes ---- preposition 273 objects, 87360 bytes - ---- inter_tree 6 objects, 84384 bytes + ---- inter_tree 6 objects, 84336 bytes ---- lexical_cluster 2516 objects, 80512 bytes ---- pcalc_term_array 2 x 1000 = 2000 objects, 80064 bytes ---- kind_variable_declaration 1652 objects, 79296 bytes @@ -110,7 +110,7 @@ Total memory consumption was 302116K = 295 MB ---- booking_list 407 objects, 13024 bytes ---- adjective_iname_holder 320 objects, 12800 bytes ---- pathname 292 objects, 11680 bytes - ---- stopwatch_timer 114 objects, 9120 bytes + ---- stopwatch_timer 112 objects, 8960 bytes ---- filename 208 objects, 8320 bytes ---- uniqueness_count 324 objects, 7776 bytes ---- equation_node 68 objects, 7616 bytes @@ -119,7 +119,7 @@ Total memory consumption was 302116K = 295 MB ---- determiner 22 objects, 7216 bytes ---- verb 108 objects, 6048 bytes ---- text_literal_holder 144 objects, 5760 bytes - ---- hierarchy_attachment_point 54 objects, 5184 bytes + ---- hierarchy_attachment_point 53 objects, 5088 bytes ---- inbuild_work 78 objects, 4992 bytes ---- explicit_action_array 1 x 100 objects, 4832 bytes ---- value_property_data 84 objects, 4704 bytes @@ -238,16 +238,16 @@ Total memory consumption was 302116K = 295 MB ---- parse_name_notice 1 object, 40 bytes ---- loop_over_scope 1 object, 40 bytes -36.1% was used for memory not allocated for objects: +36.3% was used for memory not allocated for objects: - 16.9% text stream storage 52286800 bytes in 344484 claims - 3.5% dictionary storage 11131392 bytes in 19937 claims - ---- sorting 760 bytes in 3 claims + 16.9% text stream storage 52283808 bytes in 344406 claims + 3.6% dictionary storage 11125248 bytes in 19925 claims + ---- sorting 744 bytes in 3 claims 2.3% source text 7200000 bytes in 3 claims - 3.4% source text details 10800000 bytes in 2 claims + 3.5% source text details 10800000 bytes in 2 claims ---- linguistic stock array 81920 bytes in 2 claims ---- small word set array 105600 bytes in 22 claims - 0.8% inter symbols storage 2620096 bytes in 15957 claims + 0.8% inter symbols storage 2618560 bytes in 15945 claims 5.4% inter bytecode storage 16802796 bytes in 14 claims 2.8% inter links storage 8866944 bytes in 265 claims ---- inter tree location list storage 146432 bytes in 24 claims @@ -257,5 +257,5 @@ Total memory consumption was 302116K = 295 MB ---- code generation workspace for objects 9648 bytes in 9 claims ---- emitter array storage 154432 bytes in 2037 claims -20.4% was overhead - 63229128 bytes = 61747K = 60 MB +20.2% was overhead - 62344360 bytes = 60883K = 59 MB diff --git a/inform7/Figures/timings-diagnostics.txt b/inform7/Figures/timings-diagnostics.txt index 9323881bd..251582bb2 100644 --- a/inform7/Figures/timings-diagnostics.txt +++ b/inform7/Figures/timings-diagnostics.txt @@ -1,9 +1,9 @@ 100.0% in inform7 run - 56.3% in compilation to Inter - 37.6% in //Sequence::undertake_queued_tasks// + 56.1% in compilation to Inter + 37.5% in //Sequence::undertake_queued_tasks// 5.9% in //InferenceSubjects::emit_all// 3.5% in //MajorNodes::pre_pass// - 2.8% in //MajorNodes::pass_1// + 2.9% in //MajorNodes::pass_1// 1.5% in //ImperativeDefinitions::assess_all// 0.5% in //ImperativeDefinitions::compile_first_block// 0.5% in //MajorNodes::pass_2// @@ -12,13 +12,14 @@ 0.3% in //Sequence::undertake_queued_tasks// 0.1% in //RTCommandGrammars::compile_all// 0.1% in //Task::make_built_in_kind_constructors// - 2.0% not specifically accounted for + 0.1% in //World::stages_II_and_III// + 1.7% not specifically accounted for 41.4% in running Inter pipeline - 10.6% in step preparation - 10.5% in inter step 7/14: consolidate-text - 8.9% in inter step 2/14: link + 10.7% in step preparation + 10.4% in inter step 7/14: consolidate-text + 9.0% in inter step 2/14: link 6.9% in inter step 14/14: generate inform6 -> auto.inf - 0.8% in inter step 10/14: make-identifiers-unique + 0.6% in inter step 10/14: make-identifiers-unique 0.3% in inter step 11/14: reconcile-verbs 0.3% in inter step 13/14: eliminate-redundant-operations 0.3% in inter step 6/14: assimilate @@ -27,6 +28,6 @@ 0.1% in inter step 5/14: resolve-conditional-compilation 0.1% in inter step 8/14: resolve-external-symbols 0.1% in inter step 9/14: inspect-plugs - 1.6% not specifically accounted for + 1.7% not specifically accounted for 1.8% in supervisor - 0.4% not specifically accounted for + 0.6% not specifically accounted for diff --git a/inform7/if-module/Chapter 3/The Map.w b/inform7/if-module/Chapter 3/The Map.w index 0b837ee15..e41c44dd7 100644 --- a/inform7/if-module/Chapter 3/The Map.w +++ b/inform7/if-module/Chapter 3/The Map.w @@ -33,8 +33,6 @@ void Map::start(void) { int Map::production_line(int stage, int debugging, stopwatch_timer *sequence_timer) { if (stage == INTER1_CSEQ) { BENCH(RTMap::compile_model_tables); - BENCH(RTMap::write_door_dir_routines); - BENCH(RTMap::write_door_to_routines); } return FALSE; } @@ -319,8 +317,6 @@ int Map::set_kind_notify(instance *I, kind *k) { @ = registered_directions++; - inter_name *dname = RTMap::new_direction_iname(); - MAP_DATA(I)->direction_iname = dname; MapRelations::make_mapped_predicate(I); @h Map data on instances. @@ -926,21 +922,21 @@ trust that there is nothing surprising here. @ Here |found_in| is a two-entry list. @ = - parse_node *val = RTMap::found_in_for_2_sided(I, R1, R2); + parse_node *val = RTDoors::found_in_for_2_sided(I, R1, R2); Map::set_found_in(I, val); @ Here |door_dir| is a routine looking at the current location and returning always the way to the other room -- the one we are not in. @ = - parse_node *val = RTMap::door_dir_for_2_sided(I, R1, D1, D2); + parse_node *val = RTDoors::door_dir_for_2_sided(I, R1, D1, D2); ValueProperties::assert(P_door_dir, Instances::as_subject(I), val, CERTAIN_CE); @ Here |door_to| is a routine looking at the current location and returning always the other room -- the one we are not in. @ = - parse_node *val = RTMap::door_to_for_2_sided(I, R1, R2); + parse_node *val = RTDoors::door_to_for_2_sided(I, R1, R2); ValueProperties::assert(P_door_to, Instances::as_subject(I), val, CERTAIN_CE); @ The reversal of direction here looks peculiar, but is correct. Suppose diff --git a/inform7/runtime-module/Chapter 2/Hierarchy.w b/inform7/runtime-module/Chapter 2/Hierarchy.w index 3410d472a..980abbfa8 100644 --- a/inform7/runtime-module/Chapter 2/Hierarchy.w +++ b/inform7/runtime-module/Chapter 2/Hierarchy.w @@ -689,6 +689,7 @@ void Hierarchy::establish(void) { @e TSD_DOOR_TO_FN_HL @e INLINE_PROPERTIES_HAP @e INLINE_PROPERTY_HL +@e DIRECTION_HL @ = submodule_identity *instances = Packaging::register_submodule(I"instances"); @@ -721,6 +722,7 @@ void Hierarchy::establish(void) { H_BEGIN_AP(INLINE_PROPERTIES_HAP, I"inline_property", I"_inline_property") H_C_U(INLINE_PROPERTY_HL, I"inline") H_END + H_C_G(DIRECTION_HL, I"DirectionObject") H_END H_END @@ -736,9 +738,6 @@ void Hierarchy::establish(void) { @e MAP_STORAGE_HL @e INITIALSITUATION_HL -@e DIRECTIONS_HAP -@e DIRECTION_HL - @ = submodule_identity *interactive_fiction = Packaging::register_submodule(I"interactive_fiction"); @@ -754,9 +753,6 @@ void Hierarchy::establish(void) { H_C_T(NO_DIRECTIONS_HL, I"No_Directions") H_C_T(MAP_STORAGE_HL, I"Map_Storage") H_C_T(INITIALSITUATION_HL, I"InitialSituation") - H_BEGIN_AP(DIRECTIONS_HAP, I"direction", I"_direction") - H_C_G(DIRECTION_HL, I"DirectionObject") - H_END H_END @h Kinds. diff --git a/inform7/runtime-module/Chapter 5/Door Instances.w b/inform7/runtime-module/Chapter 5/Door Instances.w new file mode 100644 index 000000000..3ccd039bf --- /dev/null +++ b/inform7/runtime-module/Chapter 5/Door Instances.w @@ -0,0 +1,196 @@ +[RTDoors::] Door Instances. + +Property values for two-sided doors to make them interconnect with the map +at runtime. + +@ The I6 implementation of two-way doors is quite complicated; see the Inform +Designer's Manual, fourth edition (the "DM4") for explanations, but basically +it means giving instances of such doors three low-level properties -- + +(*) |door_dir|, the map direction through the door; +(*) |door_to|, the room on the other side; +(*) |found_in|, the two rooms in which the door is located. + +We continue to use that implementation because there is no pressing reason to +change it: I7 authors are never even aware of how this is all done, and do not +have to see or think about these properties. + +@h Door direction. + += +typedef struct door_dir_notice { + struct inter_name *ddn_iname; + struct instance *door; + struct instance *R1; + struct instance *D1; + struct instance *D2; + CLASS_DEFINITION +} door_dir_notice; + +parse_node *RTDoors::door_dir_for_2_sided(instance *I, instance *R1, instance *D1, + instance *D2) { + door_dir_notice *notice = CREATE(door_dir_notice); + notice->ddn_iname = + Hierarchy::make_iname_in(TSD_DOOR_DIR_FN_HL, RTInstances::package(I)); + notice->door = I; + notice->R1 = R1; + notice->D1 = D1; + notice->D2 = D2; + text_stream *desc = Str::new(); + WRITE_TO(desc, "door_dir for "); Instances::write(desc, I); + Sequence::queue(&RTDoors::door_dir_agent, STORE_POINTER_door_dir_notice(notice), desc); + return Rvalues::from_iname(notice->ddn_iname); +} + +@ So, then, this is a function: see the DM4 for specification. + += +void RTDoors::door_dir_agent(compilation_subtask *t) { + door_dir_notice *notice = RETRIEVE_POINTER_door_dir_notice(t->data); + packaging_state save = Functions::begin(notice->ddn_iname); + local_variable *loc = LocalVariables::new_internal_commented(I"loc", I"room of actor"); + inter_symbol *loc_s = LocalVariables::declare(loc); + EmitCode::inv(STORE_BIP); + EmitCode::down(); + EmitCode::ref_symbol(K_value, loc_s); + EmitCode::val_iname(K_value, Hierarchy::find(LOCATION_HL)); + EmitCode::up(); + + EmitCode::inv(IF_BIP); + EmitCode::down(); + EmitCode::inv(EQ_BIP); + EmitCode::down(); + EmitCode::val_symbol(K_value, loc_s); + EmitCode::val_iname(K_value, Hierarchy::find(THEDARK_HL)); + EmitCode::up(); + EmitCode::code(); + EmitCode::down(); + EmitCode::inv(STORE_BIP); + EmitCode::down(); + EmitCode::ref_symbol(K_value, loc_s); + EmitCode::val_iname(K_value, Hierarchy::find(REAL_LOCATION_HL)); + EmitCode::up(); + EmitCode::up(); + EmitCode::up(); + + EmitCode::inv(IF_BIP); + EmitCode::down(); + EmitCode::inv(EQ_BIP); + EmitCode::down(); + EmitCode::val_symbol(K_value, loc_s); + EmitCode::val_iname(K_value, RTInstances::value_iname(notice->R1)); + EmitCode::up(); + EmitCode::code(); + EmitCode::down(); + EmitCode::inv(RETURN_BIP); + EmitCode::down(); + EmitCode::val_iname(K_value, + RTInstances::value_iname(Map::get_value_of_opposite_property(notice->D1))); + EmitCode::up(); + EmitCode::up(); + EmitCode::up(); + + EmitCode::inv(RETURN_BIP); + EmitCode::down(); + EmitCode::val_iname(K_value, + RTInstances::value_iname(Map::get_value_of_opposite_property(notice->D2))); + EmitCode::up(); + + Functions::end(save); +} + +@h Door to. + += +typedef struct door_to_notice { + struct inter_name *dtn_iname; + struct instance *door; + struct instance *R1; + struct instance *R2; + CLASS_DEFINITION +} door_to_notice; + +parse_node *RTDoors::door_to_for_2_sided(instance *I, instance *R1, instance *R2) { + door_to_notice *notice = CREATE(door_to_notice); + notice->dtn_iname = + Hierarchy::make_iname_in(TSD_DOOR_TO_FN_HL, RTInstances::package(I)); + notice->door = I; + notice->R1 = R1; + notice->R2 = R2; + text_stream *desc = Str::new(); + WRITE_TO(desc, "door_to for "); Instances::write(desc, I); + Sequence::queue(&RTDoors::door_to_agent, STORE_POINTER_door_to_notice(notice), desc); + return Rvalues::from_iname(notice->dtn_iname); +} + +@ Another function: see the DM4 for specification. + += +void RTDoors::door_to_agent(compilation_subtask *t) { + door_to_notice *notice = RETRIEVE_POINTER_door_to_notice(t->data); + packaging_state save = Functions::begin(notice->dtn_iname); + local_variable *loc = LocalVariables::new_internal_commented(I"loc", I"room of actor"); + inter_symbol *loc_s = LocalVariables::declare(loc); + EmitCode::inv(STORE_BIP); + EmitCode::down(); + EmitCode::ref_symbol(K_value, loc_s); + EmitCode::val_iname(K_value, Hierarchy::find(LOCATION_HL)); + EmitCode::up(); + + EmitCode::inv(IF_BIP); + EmitCode::down(); + EmitCode::inv(EQ_BIP); + EmitCode::down(); + EmitCode::val_symbol(K_value, loc_s); + EmitCode::val_iname(K_value, Hierarchy::find(THEDARK_HL)); + EmitCode::up(); + EmitCode::code(); + EmitCode::down(); + EmitCode::inv(STORE_BIP); + EmitCode::down(); + EmitCode::ref_symbol(K_value, loc_s); + EmitCode::val_iname(K_value, Hierarchy::find(REAL_LOCATION_HL)); + EmitCode::up(); + EmitCode::up(); + EmitCode::up(); + + EmitCode::inv(IF_BIP); + EmitCode::down(); + EmitCode::inv(EQ_BIP); + EmitCode::down(); + EmitCode::val_symbol(K_value, loc_s); + EmitCode::val_iname(K_value, RTInstances::value_iname(notice->R1)); + EmitCode::up(); + EmitCode::code(); + EmitCode::down(); + EmitCode::inv(RETURN_BIP); + EmitCode::down(); + EmitCode::val_iname(K_value, RTInstances::value_iname(notice->R2)); + EmitCode::up(); + EmitCode::up(); + EmitCode::up(); + + EmitCode::inv(RETURN_BIP); + EmitCode::down(); + EmitCode::val_iname(K_value, RTInstances::value_iname(notice->R1)); + EmitCode::up(); + + Functions::end(save); +} + +@h Found in. +And this is a two-element array, simply giving the two rooms |R1| and |R2| +which the door is found in: + += +parse_node *RTDoors::found_in_for_2_sided(instance *I, instance *R1, instance *R2) { + package_request *PR = + Hierarchy::package_within(INLINE_PROPERTIES_HAP, RTInstances::package(I)); + inter_name *S = Hierarchy::make_iname_in(INLINE_PROPERTY_HL, PR); + packaging_state save = EmitArrays::begin(S, K_value); + EmitArrays::iname_entry(RTInstances::value_iname(R1)); + EmitArrays::iname_entry(RTInstances::value_iname(R2)); + EmitArrays::end(save); + Produce::annotate_i(S, INLINE_ARRAY_IANN, 1); + return Rvalues::from_iname(S); +} diff --git a/inform7/runtime-module/Chapter 6/The Map.w b/inform7/runtime-module/Chapter 6/The Map.w new file mode 100644 index 000000000..7486ab0ff --- /dev/null +++ b/inform7/runtime-module/Chapter 6/The Map.w @@ -0,0 +1,72 @@ +[RTMap::] The Map. + +The runtime representation of the spatial map for works of interactive fiction: +that is, how the rooms and doors connect up. + +@ One of the few early breaks with I6 practice was that I7 stores the +map differently at run-time compared to earlier I6 games. + +The |Map_Storage| array consists only of the |exits| arrays written out +one after another. It looks wasteful of memory, since it is almost always +going to be filled mostly with |0| entries (meaning: no exit that way). But +the memory needs to be there because map connections can be added dynamically +at run-time, so we can't know now how many we will need. + += +int RTMap::compile_model_tables(void) { + inter_name *ndi = Hierarchy::find(NO_DIRECTIONS_HL); + Emit::numeric_constant(ndi, (inter_ti) Map::number_of_directions()); + Hierarchy::make_available(ndi); + + instance *I; + LOOP_OVER_INSTANCES(I, K_object) + RTInstances::value_iname(I); + inter_name *iname = Hierarchy::find(MAP_STORAGE_HL); + packaging_state save = EmitArrays::begin(iname, K_object); + int words_used = 0; + if (Task::wraps_existing_storyfile()) { + EmitArrays::divider(I"minimal, as there are no rooms"); + EmitArrays::iname_entry(NULL); + EmitArrays::iname_entry(NULL); + EmitArrays::iname_entry(NULL); + EmitArrays::iname_entry(NULL); + words_used = 4; + } else { + EmitArrays::divider(I"one row per room"); + instance *I; + LOOP_OVER_INSTANCES(I, K_object) + if (Spatial::object_is_a_room(I)) { + int N = Map::number_of_directions(); + for (int i=0; itask_functions[TEST_ATOM_TASK] = + Calculus::Schemas::new("(MapConnection(*2,%n) == *1)", ident); + bp->task_functions[NOW_ATOM_TRUE_TASK] = + Calculus::Schemas::new("AssertMapConnection(*2,%n,*1)", ident); + bp->task_functions[NOW_ATOM_FALSE_TASK] = + Calculus::Schemas::new("AssertMapUnconnection(*2,%n,*1)", ident); +} diff --git a/inform7/runtime-module/Chapter 7/The Map.w b/inform7/runtime-module/Chapter 7/The Map.w deleted file mode 100644 index 87f046545..000000000 --- a/inform7/runtime-module/Chapter 7/The Map.w +++ /dev/null @@ -1,263 +0,0 @@ -[RTMap::] The Map. - -@ - -= -inter_name *RTMap::new_direction_iname(void) { - package_request *PR = Hierarchy::synoptic_package(DIRECTIONS_HAP); - return Hierarchy::make_iname_in(DIRECTION_HL, PR); -} - -@ One of the few early breaks with I6 practice was that I7 stores the -map differently at run-time compared to earlier I6 games. - -= -int RTMap::compile_model_tables(void) { - @; - @; - return FALSE; -} - -@ = - inter_name *ndi = Hierarchy::find(NO_DIRECTIONS_HL); - Emit::numeric_constant(ndi, (inter_ti) Map::number_of_directions()); - Hierarchy::make_available(ndi); - - instance *I; - LOOP_OVER_INSTANCES(I, K_direction) - Emit::iname_constant(MAP_DATA(I)->direction_iname, K_object, - RTInstances::value_iname(I)); - -@ The |Map_Storage| array consists only of the |exits| arrays written out -one after another. It looks wasteful of memory, since it is almost always -going to be filled mostly with |0| entries (meaning: no exit that way). But -the memory needs to be there because map connections can be added dynamically -at run-time, so we can't know now how many we will need. - -@ = - instance *I; - LOOP_OVER_INSTANCES(I, K_object) - RTInstances::value_iname(I); - inter_name *iname = Hierarchy::find(MAP_STORAGE_HL); - packaging_state save = EmitArrays::begin(iname, K_object); - int words_used = 0; - if (Task::wraps_existing_storyfile()) { - EmitArrays::divider(I"minimal, as there are no rooms"); - EmitArrays::iname_entry(NULL); - EmitArrays::iname_entry(NULL); - EmitArrays::iname_entry(NULL); - EmitArrays::iname_entry(NULL); - words_used = 4; - } else { - EmitArrays::divider(I"one row per room"); - instance *I; - LOOP_OVER_INSTANCES(I, K_object) - if (Spatial::object_is_a_room(I)) { - int N = Map::number_of_directions(); - for (int i=0; iddn_iname = - Hierarchy::make_iname_in(TSD_DOOR_DIR_FN_HL, RTInstances::package(I)); - notice->door = I; - notice->R1 = R1; - notice->D1 = D1; - notice->D2 = D2; - return Rvalues::from_iname(notice->ddn_iname); -} - -parse_node *RTMap::door_to_for_2_sided(instance *I, instance *R1, instance *R2) { - door_to_notice *notice = CREATE(door_to_notice); - notice->dtn_iname = - Hierarchy::make_iname_in(TSD_DOOR_TO_FN_HL, RTInstances::package(I)); - notice->door = I; - notice->R1 = R1; - notice->R2 = R2; - return Rvalues::from_iname(notice->dtn_iname); -} - -parse_node *RTMap::found_in_for_2_sided(instance *I, instance *R1, instance *R2) { - package_request *PR = - Hierarchy::package_within(INLINE_PROPERTIES_HAP, RTInstances::package(I)); - inter_name *S = Hierarchy::make_iname_in(INLINE_PROPERTY_HL, PR); - packaging_state save = EmitArrays::begin(S, K_value); - EmitArrays::iname_entry(RTInstances::value_iname(R1)); - EmitArrays::iname_entry(RTInstances::value_iname(R2)); - EmitArrays::end(save); - Produce::annotate_i(S, INLINE_ARRAY_IANN, 1); - return Rvalues::from_iname(S); -} - -@ Redeeming those notices: - -= -void RTMap::write_door_dir_routines(void) { - door_dir_notice *notice; - LOOP_OVER(notice, door_dir_notice) { - packaging_state save = Functions::begin(notice->ddn_iname); - local_variable *loc = LocalVariables::new_internal_commented(I"loc", I"room of actor"); - inter_symbol *loc_s = LocalVariables::declare(loc); - EmitCode::inv(STORE_BIP); - EmitCode::down(); - EmitCode::ref_symbol(K_value, loc_s); - EmitCode::val_iname(K_value, Hierarchy::find(LOCATION_HL)); - EmitCode::up(); - - EmitCode::inv(IF_BIP); - EmitCode::down(); - EmitCode::inv(EQ_BIP); - EmitCode::down(); - EmitCode::val_symbol(K_value, loc_s); - EmitCode::val_iname(K_value, Hierarchy::find(THEDARK_HL)); - EmitCode::up(); - EmitCode::code(); - EmitCode::down(); - EmitCode::inv(STORE_BIP); - EmitCode::down(); - EmitCode::ref_symbol(K_value, loc_s); - EmitCode::val_iname(K_value, Hierarchy::find(REAL_LOCATION_HL)); - EmitCode::up(); - EmitCode::up(); - EmitCode::up(); - - EmitCode::inv(IF_BIP); - EmitCode::down(); - EmitCode::inv(EQ_BIP); - EmitCode::down(); - EmitCode::val_symbol(K_value, loc_s); - EmitCode::val_iname(K_value, RTInstances::value_iname(notice->R1)); - EmitCode::up(); - EmitCode::code(); - EmitCode::down(); - EmitCode::inv(RETURN_BIP); - EmitCode::down(); - EmitCode::val_iname(K_value, - RTInstances::value_iname(Map::get_value_of_opposite_property(notice->D1))); - EmitCode::up(); - EmitCode::up(); - EmitCode::up(); - - EmitCode::inv(RETURN_BIP); - EmitCode::down(); - EmitCode::val_iname(K_value, - RTInstances::value_iname(Map::get_value_of_opposite_property(notice->D2))); - EmitCode::up(); - - Functions::end(save); - } -} - -void RTMap::write_door_to_routines(void) { - door_to_notice *notice; - LOOP_OVER(notice, door_to_notice) { - packaging_state save = Functions::begin(notice->dtn_iname); - local_variable *loc = LocalVariables::new_internal_commented(I"loc", I"room of actor"); - inter_symbol *loc_s = LocalVariables::declare(loc); - EmitCode::inv(STORE_BIP); - EmitCode::down(); - EmitCode::ref_symbol(K_value, loc_s); - EmitCode::val_iname(K_value, Hierarchy::find(LOCATION_HL)); - EmitCode::up(); - - EmitCode::inv(IF_BIP); - EmitCode::down(); - EmitCode::inv(EQ_BIP); - EmitCode::down(); - EmitCode::val_symbol(K_value, loc_s); - EmitCode::val_iname(K_value, Hierarchy::find(THEDARK_HL)); - EmitCode::up(); - EmitCode::code(); - EmitCode::down(); - EmitCode::inv(STORE_BIP); - EmitCode::down(); - EmitCode::ref_symbol(K_value, loc_s); - EmitCode::val_iname(K_value, Hierarchy::find(REAL_LOCATION_HL)); - EmitCode::up(); - EmitCode::up(); - EmitCode::up(); - - EmitCode::inv(IF_BIP); - EmitCode::down(); - EmitCode::inv(EQ_BIP); - EmitCode::down(); - EmitCode::val_symbol(K_value, loc_s); - EmitCode::val_iname(K_value, RTInstances::value_iname(notice->R1)); - EmitCode::up(); - EmitCode::code(); - EmitCode::down(); - EmitCode::inv(RETURN_BIP); - EmitCode::down(); - EmitCode::val_iname(K_value, RTInstances::value_iname(notice->R2)); - EmitCode::up(); - EmitCode::up(); - EmitCode::up(); - - EmitCode::inv(RETURN_BIP); - EmitCode::down(); - EmitCode::val_iname(K_value, RTInstances::value_iname(notice->R1)); - EmitCode::up(); - - Functions::end(save); - } -} - -@ |ident| is an identifier name for the direction instance. It seems redundant -here because surely if we know |I|, we know its runtime representation; but -that's not true -- we need to call this function at a time when the final -identifier names for instance have not yet been settled. - -= -void RTMap::set_map_schemas(binary_predicate *bp, instance *I) { - inter_name *ident = MAP_DATA(I)->direction_iname; - bp->task_functions[TEST_ATOM_TASK] = - Calculus::Schemas::new("(MapConnection(*2,%n) == *1)", ident); - bp->task_functions[NOW_ATOM_TRUE_TASK] = - Calculus::Schemas::new("AssertMapConnection(*2,%n,*1)", ident); - bp->task_functions[NOW_ATOM_FALSE_TASK] = - Calculus::Schemas::new("AssertMapUnconnection(*2,%n,*1)", ident); -} diff --git a/inform7/runtime-module/Contents.w b/inform7/runtime-module/Contents.w index be60a7f2f..d29417e44 100644 --- a/inform7/runtime-module/Contents.w +++ b/inform7/runtime-module/Contents.w @@ -51,6 +51,7 @@ Chapter 5: Provision Submodules Equations Instances Backdrop Instances + Door Instances Region Instances Multimedia Tables @@ -69,9 +70,9 @@ Chapter 5: Provision Submodules Chapter 6: Completion Resources Bibliographic Data The Player + The Map Chapter 7: Still Unsorted - The Map Scenes Emit Property Values Instance Counting