Free Hero Mesh

Check-in [df0935b0a3]
Login
This is a mirror of the main repository for Free Hero Mesh. New tickets and changes will not be accepted at this mirror.
Overview
Comment:More (still incomplete) implementation of (Order) block; also make a correction for the user flag blocks.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: df0935b0a3a1a1a23197ad1f28ec8ec70dfa515e
User & Date: user on 2021-10-08 04:26:30
Other Links: manifest | tags
Context
2021-10-10
00:08
More working in sound implementation (still incomplete, and some details are subject to being changed in future) check-in: 9692a28768 user: user tags: trunk
2021-10-08
04:26
More (still incomplete) implementation of (Order) block; also make a correction for the user flag blocks. check-in: df0935b0a3 user: user tags: trunk
02:27
Begin implementation of (Order) block (currently incomplete and doesn't work). check-in: a50cf8eac3 user: user tags: trunk
Changes

Modified class.c from [5acd447fb3] to [459caf781d].

2108
2109
2110
2111
2112
2113
2114

2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129

2130
2131
2132
2133
2134
2135
2136
2137
2138
}

static void parse_order_block(void) {
  // OP_MISC1, OP_MISC1_C, etc = properties (_C=reverse)
  // 0x1000...0x10FF = Have flag
  // OP_RET = end of block
  Uint16 beg,ptr;

  orders=malloc(0x4000*sizeof(Uint16));
  if(!orders) fatal("Allocation failed\n");
  nxttok();
  if(tokent==TF_INT) {
    if(tokenv<1 || tokenv>254) ParseError("Order number out of range\n");
    beg=ptr=tokenv;
    nxttok();
  } else {
    beg=ptr=128;
  }
  while(tokent!=TF_CLOSE) {
    if(tokent!=TF_OPEN) ParseError("Open or close parenthesis expected\n");
    if(ptr>=0x3FFD) ParseError("Out of order memory\n");
    nxttok();
    if(Tokenf(TF_MACRO|TF_COMMA|TF_EQUAL) || !Tokenf(TF_NAME)) ParseError("Unexpected token in (Order) block\n");

    if(norders==beg) ParseError("Too many orders\n");
    orders[norders++]=ptr;
    switch(tokenv) {
      case OP_INPUT: case OP_PLAYER:
        orders[ptr++]=tokenv;
        break;
      case OP_USERFLAG:
        tokenv=look_hash(glohash,HASH_SIZE,0x1000,0x10FF,0,"user flags");
        if(!tokenv) ParseError("User flag ^%s not defined\n",tokenstr);







>















>

<







2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132

2133
2134
2135
2136
2137
2138
2139
}

static void parse_order_block(void) {
  // OP_MISC1, OP_MISC1_C, etc = properties (_C=reverse)
  // 0x1000...0x10FF = Have flag
  // OP_RET = end of block
  Uint16 beg,ptr;
  ParseError("(Not implemented yet)\n"); //TODO: remove this when it is implemented in exec.c too
  orders=malloc(0x4000*sizeof(Uint16));
  if(!orders) fatal("Allocation failed\n");
  nxttok();
  if(tokent==TF_INT) {
    if(tokenv<1 || tokenv>254) ParseError("Order number out of range\n");
    beg=ptr=tokenv;
    nxttok();
  } else {
    beg=ptr=128;
  }
  while(tokent!=TF_CLOSE) {
    if(tokent!=TF_OPEN) ParseError("Open or close parenthesis expected\n");
    if(ptr>=0x3FFD) ParseError("Out of order memory\n");
    nxttok();
    if(Tokenf(TF_MACRO|TF_COMMA|TF_EQUAL) || !Tokenf(TF_NAME)) ParseError("Unexpected token in (Order) block\n");
    orders[++norders]=ptr;
    if(norders==beg) ParseError("Too many orders\n");

    switch(tokenv) {
      case OP_INPUT: case OP_PLAYER:
        orders[ptr++]=tokenv;
        break;
      case OP_USERFLAG:
        tokenv=look_hash(glohash,HASH_SIZE,0x1000,0x10FF,0,"user flags");
        if(!tokenv) ParseError("User flag ^%s not defined\n",tokenstr);
2165
2166
2167
2168
2169
2170
2171
2172

















2173
2174
2175
2176
2177
2178
2179
    orders[ptr++]=OP_RET;
  }
  if(!norders) ParseError("Empty (Order) block\n");
  orders=realloc(orders,ptr*sizeof(Uint16))?:orders;
}

static void set_class_orders(void) {
  //TODO

















}

void load_classes(void) {
  int i;
  int gloptr=0;
  Hash*glolocalhash;
  char*nam=sqlite3_mprintf("%s.class",basefilename);







<
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







2166
2167
2168
2169
2170
2171
2172

2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
    orders[ptr++]=OP_RET;
  }
  if(!norders) ParseError("Empty (Order) block\n");
  orders=realloc(orders,ptr*sizeof(Uint16))?:orders;
}

static void set_class_orders(void) {

  int i,j,k;
  for(i=1;i<undef_class;i++) if(classes[i] && !(classes[i]->cflags&(CF_GROUP|CF_NOCLASS2))) {
    for(j=1;j<norders;j++) {
      k=orders[orders[j]];
      switch(k) {
        case 0x1000 ... 0x101F: if(classes[i]->misc4&(1UL<<(k&0x1F))) goto found; break;
        case 0x1020 ... 0x103F: if(classes[i]->misc5&(1UL<<(k&0x1F))) goto found; break;
        case 0x1040 ... 0x105F: if(classes[i]->misc6&(1UL<<(k&0x1F))) goto found; break;
        case 0x1060 ... 0x107F: if(classes[i]->misc7&(1UL<<(k&0x1F))) goto found; break;
        case 0x1080 ... 0x1087: if(classes[i]->collisionLayers&(1L<<(k&0x07))) goto found; break;
        case OP_PLAYER: if(classes[i]->cflags&CF_PLAYER) goto found; break;
        case OP_INPUT: if(classes[i]->cflags&CF_INPUT) goto found; break;
      }
      continue;
      found: classes[i]->order=j; break;
    }
  }
}

void load_classes(void) {
  int i;
  int gloptr=0;
  Hash*glolocalhash;
  char*nam=sqlite3_mprintf("%s.class",basefilename);
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
          nxttok();
          if(tokent!=TF_CLOSE) ParseError("Expected close parenthesis\n");
          break;
        case OP_MISC4: define_user_flags(0x1000,0x101F); break;
        case OP_MISC5: define_user_flags(0x1020,0x103F); break;
        case OP_MISC6: define_user_flags(0x1040,0x105F); break;
        case OP_MISC7: define_user_flags(0x1060,0x107F); break;
        case OP_COLLISIONLAYERS: define_user_flags(0x1C80,0x1C87); break;
        case OP_CODEPAGE:
          nxttok();
          if(tokent!=TF_INT || tokenv<1 || tokenv>65535) ParseError("Number from 1 to 65535 expected\n");
          set_code_page(tokenv);
          nxttok();
          if(tokent!=TF_CLOSE) ParseError("Expected close parenthesis\n");
          break;







|







2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
          nxttok();
          if(tokent!=TF_CLOSE) ParseError("Expected close parenthesis\n");
          break;
        case OP_MISC4: define_user_flags(0x1000,0x101F); break;
        case OP_MISC5: define_user_flags(0x1020,0x103F); break;
        case OP_MISC6: define_user_flags(0x1040,0x105F); break;
        case OP_MISC7: define_user_flags(0x1060,0x107F); break;
        case OP_COLLISIONLAYERS: define_user_flags(0x1080,0x1087); break;
        case OP_CODEPAGE:
          nxttok();
          if(tokent!=TF_INT || tokenv<1 || tokenv>65535) ParseError("Number from 1 to 65535 expected\n");
          set_code_page(tokenv);
          nxttok();
          if(tokent!=TF_CLOSE) ParseError("Expected close parenthesis\n");
          break;

Modified class.doc from [4e7a27a3af] to [985a0314d5].

284
285
286
287
288
289
290



291
292
293
294
295
296
297
  Define user flags as Misc6 bits; the first defined flag is bit0. Up to
  32 flags can be defined in this way.

(Misc7 <userflags...>)
  Define user flags as Misc7 bits; the first defined flag is bit0. Up to
  32 flags can be defined in this way.




(Synchronize <slot> <length> <speed>)
  Define an animation slot for synchronized animation. The slot number can
  be 0 to 7, the length is the number of images in the sequence, and the
  speed is the number of centiseconds between frames.

(Volume <number>)
  Define the maximum allowed volume for an object to move diagonally







>
>
>







284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
  Define user flags as Misc6 bits; the first defined flag is bit0. Up to
  32 flags can be defined in this way.

(Misc7 <userflags...>)
  Define user flags as Misc7 bits; the first defined flag is bit0. Up to
  32 flags can be defined in this way.

(Order <orders...>)
  (Not fully implemented yet.)

(Synchronize <slot> <length> <speed>)
  Define an animation slot for synchronized animation. The slot number can
  be 0 to 7, the length is the number of images in the sequence, and the
  speed is the number of centiseconds between frames.

(Volume <number>)
  Define the maximum allowed volume for an object to move diagonally
2462
2463
2464
2465
2466
2467
2468





























2469
2470
2471
2472
2473
2474
2475

then
  Ends a block started with begin or if.

Trace
  Used for debugging.































=== Compatibility ===

Compatible objects have the following differences from the default:

* VisualOnly implies Stealthy.








>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507

then
  Ends a block started with begin or if.

Trace
  Used for debugging.


=== Order of execution ===

(The below describes a feature that is not implemented yet; currently
only the syntax is implemented. When it is completed, this note will be
removed and further descriptions will be added below.)

You can specify the order of execution of objects by class by a global
(Order) block. Inside of this block is a list of sub-lists; each sub-list
is delimited by parentheses.

Each sub-list starts with a flag name, which may be a user flag, or Input,
or Player. This matches only classes that have that flag (changing that
flag at run time has no effect on order of execution). The remaining
elements are optional; if they are present, they are used to break ties.
First, the second item breaks ties if there is one, and then if there is
still a tie then the third item breaks ties, etc. These extra elements
can be one of the following, with or without a comma: Misc1, Misc2, Misc3,
Misc4, Misc5, Misc6, Misc7, Temperature, Density, Xloc, Yloc, Image. If
there is no comma, they are lowest to highest, but a comma reverses the
order to be highest to lowest instead. These values are treated as signed,
and the values after INIT or CREATE message returns is used. If any of
the values is not a number, then it is an error.

The order of execution is then first all objects not listed in the (Order)
block, and then for each sub-list in the (Order) block, the objects that
meet that criteria, in that order. (If it meets multiple criteria, only
the first one that meets that criteria is used.)


=== Compatibility ===

Compatible objects have the following differences from the default:

* VisualOnly implies Stealthy.