Free Hero Mesh

Check-in [02b262b608]
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 codes and testing in class codes parser
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 02b262b608ef322c50bc4731d727209f82aedb73
User & Date: user on 2018-04-27 20:25:35
Other Links: manifest | tags
Context
2018-05-05
23:58
Implement preprocessor, and add some more opcode names, and a few bug fixed check-in: 79caf678be user: user tags: trunk
2018-04-27
20:25
More codes and testing in class codes parser check-in: 02b262b608 user: user tags: trunk
2018-04-22
00:44
Further progress on writing the lexer check-in: c36edda367 user: user tags: trunk
Changes

Modified class.c from [c6330b030d] to [c8671ac4ba].

12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29

30
31
32
33
34
35
36
37
38
39
40

41
42







43
44
45
46
47
48
49
50



51
52
53
54
55
56
57
58



59
60
61
62
63
64
65
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "sqlite3.h"
#include "smallxrm.h"
#include "heromesh.h"

#define TF_COMMA 0x0001
#define TF_EQUAL 0x0002
#define TF_ABNORMAL 0x0004
#define TF_COMPAT 0x0008
#define TF_DIR 0x0010
#define TF_DROP 0x0020
#define TF_NAME 0x0080
#define TF_KEY 0x0100
#define TF_OPEN 0x0400
#define TF_CLOSE 0x0800
#define TF_INT 0x1000

#define TF_MACRO 0x4000
#define TF_EOF 0x8000
typedef struct {
  const char*txt;
  Uint32 num;
} Op_Names;
#include "instruc.h"
#define Tokenf(x) (tokent&(x))

Class*classes[0x4000];
const char*messages[0x4000];

int max_animation=32;
Sint32 max_volume=10000;








static FILE*classfp;
static Uint16 tokent;
static Uint32 tokenv;
static int linenum=1;
static char tokenstr[0x2000];
static int undef_class=1;
static int undef_message=0;




#define ParseError(a,...) fatal("On line %d: " a,linenum,##__VA_ARGS__)

static const unsigned char chkind[256]={
  ['$']=1, ['!']=1, ['\'']=1, ['#']=1, ['@']=1, ['%']=1, ['&']=1, [':']=1,
  ['0'...'9']=2, ['-']=2, ['+']=2,
  ['A'...'Z']=3, ['a'...'z']=3, ['_']=3, ['?']=3, ['.']=3, ['*']=3, ['/']=3,
};




static void read_quoted_string(void) {
  int c,i,n;
  int isimg=0;
  for(i=0;i<0x1FFD;) {
    c=fgetc(classfp);
    if(c==EOF) {







|
|
|
|
|
|
|
|
|
|
|
>
|
|









>


>
>
>
>
>
>
>








>
>
>








>
>
>







12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "sqlite3.h"
#include "smallxrm.h"
#include "heromesh.h"

#define TF_COMMA 0x0001 // has a comma modifier
#define TF_EQUAL 0x0002 // has an equal sign modifier
#define TF_ABNORMAL 0x0004 // with TF_NAME, not directly an opcode
#define TF_COMPAT 0x0008 // add 1 to opcode in compatibility mode
#define TF_DIR 0x0010 // token is a direction
#define TF_DROP 0x0020 // add 0x2000 to opcode if followed by OP_DROP
#define TF_NAME 0x0080 // token is a name or opcode
#define TF_KEY 0x0100 // token is a Hero Mesh key name
#define TF_OPEN 0x0400 // token is (
#define TF_CLOSE 0x0800 // token is )
#define TF_INT 0x1000 // token is a number
#define TF_FUNCTION 0x2000 // token is a user function
#define TF_MACRO 0x4000 // token is a macro; never returned by nxttok()
#define TF_EOF 0x8000 // end of file
typedef struct {
  const char*txt;
  Uint32 num;
} Op_Names;
#include "instruc.h"
#define Tokenf(x) (tokent&(x))

Class*classes[0x4000];
const char*messages[0x4000];
Uint16 functions[0x4000];
int max_animation=32;
Sint32 max_volume=10000;

#define HASH_SIZE 8888
#define LOCAL_HASH_SIZE 5555
typedef struct {
  Uint16 id;
  char*txt;
} Hash;

static FILE*classfp;
static Uint16 tokent;
static Uint32 tokenv;
static int linenum=1;
static char tokenstr[0x2000];
static int undef_class=1;
static int undef_message=0;
static int num_globals=0;
static int num_functions=0;
static Hash*glohash;

#define ParseError(a,...) fatal("On line %d: " a,linenum,##__VA_ARGS__)

static const unsigned char chkind[256]={
  ['$']=1, ['!']=1, ['\'']=1, ['#']=1, ['@']=1, ['%']=1, ['&']=1, [':']=1,
  ['0'...'9']=2, ['-']=2, ['+']=2,
  ['A'...'Z']=3, ['a'...'z']=3, ['_']=3, ['?']=3, ['.']=3, ['*']=3, ['/']=3,
};

#define MIN_VERSION 0
#define MAX_VERSION 0

static void read_quoted_string(void) {
  int c,i,n;
  int isimg=0;
  for(i=0;i<0x1FFD;) {
    c=fgetc(classfp);
    if(c==EOF) {
160
161
162
163
164
165
166
167


















168
169
170
171
172
173
174
175
176
177
178
179
180
  }
  if(u==0x4000) ParseError("Too many message names; cannot add #%s",tokenstr);
  if(u==undef_message) ++undef_message;
  messages[u]=strdup(tokenstr);
  if(!messages[u]) fatal("Allocation failed\n");
  return u;
}



















#define ReturnToken(x,y) do{ tokent=x; tokenv=y; return; }while(0)
static void nxttok(void) {
  int c,i;
  int fl=0;
  int n=0;
  int pr=0;
  tokent=tokenv=0;
  *tokenstr=0;
again:
  c=fgetc(classfp);
  while(c==' ' || c=='\t' || c=='\r' || c=='\n') {
    if(c=='\n') ++linenum;
    c=fgetc(classfp);








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


|
<
<
|







175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203


204
205
206
207
208
209
210
211
  }
  if(u==0x4000) ParseError("Too many message names; cannot add #%s",tokenstr);
  if(u==undef_message) ++undef_message;
  messages[u]=strdup(tokenstr);
  if(!messages[u]) fatal("Allocation failed\n");
  return u;
}

static Uint16 look_hash(Hash*tbl,int size,Uint16 minv,Uint16 maxv,Uint16 newv,const char*err) {
  int h,i,m;
  for(h=i=0;tokenstr[i];i++) h=(13*h+tokenstr[i])%size;
  m=h;
  for(;;) {
    if(tbl[h].id>=minv && tbl[h].id<=maxv && !strcmp(tokenstr,tbl[h].txt)) return tbl[h].id;
    if(!tbl[h].id) {
      if(newv>maxv) ParseError("Too many %s\n",err);
      tbl[h].txt=strdup(tokenstr);
      if(!tbl[h].txt) ParseError("Out of string space in hash table\n");
      tbl[h].id=newv;
      return 0;
    }
    h=(h+1)%size;
    if(h==m) ParseError("Hash table full\n");
  }
}

#define ReturnToken(x,y) do{ tokent=x; tokenv=y; return; }while(0)
static void nxttok(void) {
  int c,i,fl,n,pr;


  fl=n=pr=0;
  tokent=tokenv=0;
  *tokenstr=0;
again:
  c=fgetc(classfp);
  while(c==' ' || c=='\t' || c=='\r' || c=='\n') {
    if(c=='\n') ++linenum;
    c=fgetc(classfp);
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283


284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300














301









302
303
      // Just ignore sounds for now
      if(fl) ParseError("Invalid use of , and = in token\n");
      tokent=TF_NAME;
      tokenv=0x0400;
      break;
    case '%':
      if(fl&TF_COMMA) ParseError("Invalid use of , in token\n");
      tokent=TF_NAME|fl;
      tokenv=OP_LOCAL;
      break;
    case '@':
      if(fl&TF_COMMA) ParseError("Invalid use of , in token\n");
      tokent=TF_NAME|fl;
      
      break;
    case '#':
      if(fl) ParseError("Invalid use of , and = in token\n");
      tokent=TF_NAME;
      tokenv=look_message_name()+0xC000;
      break;
    case ':':
      tokent=TF_NAME|TF_ABNORMAL|fl;
      tokenv=OP_LABEL;
      break;
    case '&':
      


      break;
    case '\'':
      if(fl) ParseError("Invalid use of , and = in token\n");
      tokent=TF_NAME|TF_KEY;
      for(i=8;i<256;i++) {
        if(heromesh_key_names[i] && !strcmp(heromesh_key_names[i],tokenstr)) {
          tokenv=i;
          return;
        }
      }
      ParseError("Invalid Hero Mesh key name: %s\n",tokenstr);
      break;
  }
}

void load_classes(void) {
  int i;














  









  for(i=1;i<undef_class;i++) if(classes[i] && (classes[i]->cflags&CF_NOCLASS1)) fatal("Class $%s mentioned but not defined",classes[i]->name);
}







|





|











|
>
>

















>
>
>
>
>
>
>
>
>
>
>
>
>
>
|
>
>
>
>
>
>
>
>
>


289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
      // Just ignore sounds for now
      if(fl) ParseError("Invalid use of , and = in token\n");
      tokent=TF_NAME;
      tokenv=0x0400;
      break;
    case '%':
      if(fl&TF_COMMA) ParseError("Invalid use of , in token\n");
      tokent=TF_NAME|TF_ABNORMAL|fl;
      tokenv=OP_LOCAL;
      break;
    case '@':
      if(fl&TF_COMMA) ParseError("Invalid use of , in token\n");
      tokent=TF_NAME|fl;
      tokenv=look_hash(glohash,HASH_SIZE,0x2800,0x2FFF,num_globals+0x2800,"user global variables")?:(num_globals++)+0x2800;
      break;
    case '#':
      if(fl) ParseError("Invalid use of , and = in token\n");
      tokent=TF_NAME;
      tokenv=look_message_name()+0xC000;
      break;
    case ':':
      tokent=TF_NAME|TF_ABNORMAL|fl;
      tokenv=OP_LABEL;
      break;
    case '&':
      if(fl) ParseError("Invalid use of , and = in token\n");
      tokent=TF_FUNCTION|TF_ABNORMAL;
      tokenv=look_hash(glohash,HASH_SIZE,0x8000,0xBFFF,num_functions,"user functions")?:(num_functions++)+0x8000;
      break;
    case '\'':
      if(fl) ParseError("Invalid use of , and = in token\n");
      tokent=TF_NAME|TF_KEY;
      for(i=8;i<256;i++) {
        if(heromesh_key_names[i] && !strcmp(heromesh_key_names[i],tokenstr)) {
          tokenv=i;
          return;
        }
      }
      ParseError("Invalid Hero Mesh key name: %s\n",tokenstr);
      break;
  }
}

void load_classes(void) {
  int i;
  char*nam=sqlite3_mprintf("%s.class",basefilename);
  if(!nam) fatal("Allocation failed\n");
  classfp=fopen(nam,"r");
  sqlite3_free(nam);
  if(!classfp) fatal("Cannot open class file '%s': %m\n",nam);
  glohash=calloc(HASH_SIZE,sizeof(Hash));
  if(!glohash) fatal("Allocation failed\n");
  if(main_options['L']) {
    for(;;) {
      nxttok();
      printf("** %5d %04X %08X \"",linenum,tokent,tokenv);
      for(i=0;tokenstr[i];i++) {
        if(tokenstr[i]<32 || tokenstr[i]>126) printf("<%02X>",tokenstr[i]&255);
        else putchar(tokenstr[i]);
      }
      printf("\"\n");
      if(Tokenf(TF_EOF)) goto done;
    }
  }
  
  done:
  fclose(classfp);
  for(i=0;i<HASH_SIZE;i++) free(glohash[i].txt);
  free(glohash);
  for(i=1;i<undef_class;i++) if(classes[i] && (classes[i]->cflags&CF_NOCLASS1)) fatal("Class $%s mentioned but not defined",classes[i]->name);
}

Modified heromesh.h from [927413f183] to [0030d49afe].

29
30
31
32
33
34
35

36
37
38
39
40
41
42
extern const char*const heromesh_key_names[256];

extern sqlite3*userdb;
extern xrm_db*resourcedb;
extern const char*basefilename;
extern xrm_quark optionquery[16];
extern Uint32 generation_number;


void set_cursor(int id);

// == picture ==

extern SDL_Surface*screen;
extern Uint16 picture_size;







>







29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
extern const char*const heromesh_key_names[256];

extern sqlite3*userdb;
extern xrm_db*resourcedb;
extern const char*basefilename;
extern xrm_quark optionquery[16];
extern Uint32 generation_number;
extern char main_options[128];

void set_cursor(int id);

// == picture ==

extern SDL_Surface*screen;
extern Uint16 picture_size;

Modified instruc from [fbb7f15d4d] to [97418ba69b].

155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174

175
176
177
178
179
180
181
,=Busy
,=Invisible
,=KeyCleared
,=UserSignal
,=VisualOnly
,=Stealthy
,=Moved
,IsPlayer
,Compatible
Self
Msg
From
=Arg1
=Arg2
=Arg3
MoveNumber
Level
Key

; Class definitions

-Quiz
-InPlace
-DefaultImage
-Help
-EditorHelp
-SUBS








|












>







155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
,=Busy
,=Invisible
,=KeyCleared
,=UserSignal
,=VisualOnly
,=Stealthy
,=Moved
,Player
,Compatible
Self
Msg
From
=Arg1
=Arg2
=Arg3
MoveNumber
Level
Key

; Class definitions
-Input
-Quiz
-InPlace
-DefaultImage
-Help
-EditorHelp
-SUBS

Modified instruc.h from [be3608b2e3] to [2460412a09].

227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249

250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422

423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477

478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
#define OP_STEALTHY_C 34910
#define OP_STEALTHY_E 36958
#define OP_STEALTHY_EC 39006
#define OP_MOVED 32863
#define OP_MOVED_C 34911
#define OP_MOVED_E 36959
#define OP_MOVED_EC 39007
#define OP_ISPLAYER 32864
#define OP_ISPLAYER_C 34912
#define OP_COMPATIBLE 32865
#define OP_COMPATIBLE_C 34913
#define OP_SELF 32866
#define OP_MSG 32867
#define OP_FROM 32868
#define OP_ARG1 32869
#define OP_ARG1_E 36965
#define OP_ARG2 32870
#define OP_ARG2_E 36966
#define OP_ARG3 32871
#define OP_ARG3_E 36967
#define OP_MOVENUMBER 32872
#define OP_LEVEL 32873
#define OP_KEY 32874

#define OP_QUIZ 32875
#define OP_INPLACE 32876
#define OP_DEFAULTIMAGE 32877
#define OP_HELP 32878
#define OP_EDITORHELP 32879
#define OP_SUBS 32880
#define OP_ANIMATE 32881
#define OP_ASSASSINATE 32882
#define OP_ASSASSINATE_C 34930
#define OP_BROADCAST 32883
#define OP_BROADCAST_D 41075
#define OP_BROADCASTCLASS 32884
#define OP_BROADCASTEX 32885
#define OP_BROADCASTEX_D 41077
#define OP_BROADCASTSUM 32886
#define OP_BROADCASTSUMEX 32887
#define OP_CREATE 32888
#define OP_CREATE_D 41080
#define OP_DELINVENTORY 32889
#define OP_DELTA 32890
#define OP_DESTROY 32891
#define OP_DESTROY_C 34939
#define OP_DESTROY_D 41083
#define OP_DESTROY_CD 43131
#define OP_FLUSHCLASS 32892
#define OP_FLUSHOBJ 32893
#define OP_GETINVENTORY 32894
#define OP_HEIGHTAT 32895
#define OP_IGNOREKEY 32896
#define OP_INTMOVE 32897
#define OP_INTMOVE_C 34945
#define OP_INTMOVE_D 41089
#define OP_INTMOVE_CD 43137
#define OP_JUMPTO 32898
#define OP_JUMPTO_C 34946
#define OP_LOC 32899
#define OP_LOC_C 34947
#define OP_LOCATEME 32900
#define OP_LOSELEVEL 32901
#define OP_MAXINVENTORY 32902
#define OP_MOVE 32903
#define OP_MOVE_C 34951
#define OP_MOVE_D 41095
#define OP_MOVE_CD 43143
#define OP_MOVEPLUS 32904
#define OP_MOVEPLUS_C 34952
#define OP_MOVEPLUS_D 41096
#define OP_MOVEPLUS_CD 43144
#define OP_MOVETO 32905
#define OP_MOVETO_C 34953
#define OP_MOVETO_D 41097
#define OP_MOVETO_CD 43145
#define OP_NEWX 32906
#define OP_NEWY 32907
#define OP_OBJABOVE 32908
#define OP_OBJABOVE_C 34956
#define OP_OBJCLASSAT 32909
#define OP_OBJBELOW 32910
#define OP_OBJBELOW_C 34958
#define OP_OBJDIR 32911
#define OP_OBJDIR_C 34959
#define OP_POPUP 32912
#define OP_POPUPARGS 32913
#define OP_QUEUETURN 32914
#define OP_SEND 32915
#define OP_SEND_C 34963
#define OP_SEND_D 41107
#define OP_SEND_CD 43155
#define OP_SENDEX 32916
#define OP_SENDEX_C 34964
#define OP_SENDEX_D 41108
#define OP_SENDEX_CD 43156
#define OP_SETINVENTORY 32917
#define OP_SOUND 32918
#define OP_TRACE 32919
#define OP_VOLUMEAT 32920
#define OP_WINLEVEL 32921
#define OP_XDIR 32922
#define OP_XDIR_C 34970
#define OP_YDIR 32923
#define OP_YDIR_C 34971
#define OP_FUNCTION 32924
#define OP_LOCAL 32925
#define OP_LABEL 32926
#define OP_STRING 32927
#ifdef HEROMESH_CLASS
static const Op_Names op_names[]={
{"*",8486933},
{"+",8421395},
{"-",8421396},
{".",10518528},
{"/",8486934},
{"ANHH",8389394},
{"ARRIVED",8389124},
{"Animate",8421489},
{"Arg1",8552549},
{"Arg2",8552550},
{"Arg3",8552551},
{"Arrivals",8618071},
{"Arrived",8618069},
{"Assassinate",8487026},
{"B",9437196},
{"BANG",8389380},
{"BEDOINGNG",8389406},
{"BEEDEEP",8389404},
{"BEGIN_TURN",8389123},
{"BOOOM",8389410},
{"BOUNCE",8389415},
{"BRRREEET",8389396},
{"BRRRT",8389395},
{"BUZZER",8389420},
{"BWEEP",8389397},
{"Broadcast",10518643},
{"BroadcastEx",10518645},
{"BroadcastSum",8421494},
{"BroadcastSumEx",8421495},
{"Busy",8618073},
{"CHEEP",8389393},
{"CHYEW",8389392},
{"CLEANUP",8389140},
{"CLICK",8389388},
{"COLLIDE",8389142},
{"COLLIDING",8389141},
{"CREATE",8389121},
{"CREATED",8389137},
{"Class",8486955},
{"Climb",9142335},
{"Compatible",8487009},
{"Create",10518648},
{"DEEP_POP",8389417},
{"DEPARTED",8389125},
{"DESTROY",8389122},
{"DESTROYED",8389136},
{"DINK",8389390},
{"DOOR",8389378},
{"DRLRLRINK",8389398},
{"DYUPE",8389413},
{"DefaultImage",8683629},
{"DelInventory",8421497},
{"Delta",8421498},
{"Density",9142327},
{"Departed",8618070},
{"Departures",8618072},
{"Destroy",10584187},
{"Dir",8618033},
{"Distance",9142325},
{"E",9437184},
{"END_TURN",8389139},
{"EditorHelp",8683631},
{"F",9437192},
{"FAROUT",8389421},
{"FFFFTT",8389399},
{"FLOATED",8389132},
{"FROG",8389383},
{"FlushClass",8421500},
{"FlushObj",8421501},
{"From",8421476},
{"GLASS",8389379},
{"GLISSANT",8389419},
{"GetInventory",8421502},
{"HAWK",8389425},
{"HEARTBEAT",8389407},
{"HIT",8389134},
{"HITBY",8389135},
{"Hard",8618051},
{"Height",9142333},
{"HeightAt",8421503},
{"Help",8683630},
{"INIT",8389120},
{"IgnoreKey",8421504},
{"Image",8618034},
{"InPlace",8683628},
{"Inertia",9142323},

{"IntMove",10584193},
{"Invisible",8618074},
{"IsPlayer",8487008},
{"JAYAYAYNG",8389416},
{"JUMPED",8389128},
{"JumpTo",8487042},
{"KEWEL",8389422},
{"KEY",8389129},
{"KLECK",8389387},
{"KLINKK",8389385},
{"Key",8421482},
{"KeyCleared",8618075},
{"L",9437194},
{"LASTIMAGE",8389126},
{"LB",9437195},
{"LF",9437193},
{"LOCK",8389408},
{"LOOP",8388610},
{"Level",8421481},
{"Loc",8487043},
{"LocateMe",8421508},
{"LoseLevel",8421509},
{"MOVED",8389127},
{"MOVING",8389130},
{"MaxInventory",8421510},
{"Misc1",9142343},
{"Misc2",9142345},
{"Misc3",9142347},
{"Misc4",9142349},
{"Misc5",9142351},
{"Misc6",9142353},
{"Misc7",9142355},
{"Move",10584199},
{"Move+",10584200},
{"MoveNumber",8421480},
{"MoveTo",10584201},
{"Moved",8618079},
{"Msg",8421475},
{"N",9437186},
{"NE",9437185},
{"NW",9437187},
{"NewX",8421514},
{"NewY",8421515},
{"OLDPHONE",8389402},
{"ONCE",8388609},
{"OSC",8388616},
{"OSCLOOP",8388618},
{"ObjAbove",8487052},
{"ObjBelow",8487054},
{"ObjClassAt",8421517},
{"ObjDir",8487055},
{"PLAYERMOVING",8389133},
{"POSTINIT",8389138},
{"POUR",8389377},
{"POWER",8389386},

{"PopUp",8421520},
{"QueueTurn",8421522},
{"Quiz",8683627},
{"R",9437198},
{"RATCHET1",8389418},
{"RATCHET2",8389412},
{"RATTLE",8389403},
{"RB",9437197},
{"RF",9437199},
{"S",9437190},
{"SE",9437191},
{"SMALL_POP",8389389},
{"SPLASH",8389376},
{"STEAM",8389424},
{"STOP",8388608},
{"SUBS",8683632},
{"SUNK",8389131},
{"SW",9437189},
{"Self",8421474},
{"Send",10584211},
{"SendEx",10584212},
{"SetInventory",8421525},
{"Shape",8618030},
{"ShapeDir",8618053},
{"Sharp",8618052},
{"Shovable",8618054},
{"Sound",8421526},
{"Stealthy",8618078},
{"Strength",9142337},
{"TAHTASHH",8389409},
{"THMP_thmp",8389405},
{"THWIT",8389384},
{"TICK",8389391},
{"Temperature",9142316},
{"Trace",8421527},
{"UH_OH",8389382},
{"UNCORK",8389414},
{"UNHH",8389381},
{"UserSignal",8618076},
{"VACUUM",8389411},
{"VisualOnly",8618077},
{"Volume",9142329},
{"VolumeAt",8421528},
{"W",9437188},
{"WAHOO",8389400},
{"WHACK",8389423},
{"Weight",9142331},
{"WinLevel",8421529},
{"XDir",8487066},
{"Xloc",8486959},
{"YDir",8487067},
{"YEEHAW",8389401},
{"Yloc",8486960},
{"again",8683530},
{"band",8421403},
{"begin",8683529},
{"bit",8683551},
{"bit0",8388609},







|
|














>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|









|





|











|
|
|
|












|








|
|
|



|




|





|
|



|






|
|

|

|

>
|

<


|













|
|
|


|







|
|

|





|
|




|
|
|
|




>
|
|
|












|



|
|
|




|







|







|




|
|

|







227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426

427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
#define OP_STEALTHY_C 34910
#define OP_STEALTHY_E 36958
#define OP_STEALTHY_EC 39006
#define OP_MOVED 32863
#define OP_MOVED_C 34911
#define OP_MOVED_E 36959
#define OP_MOVED_EC 39007
#define OP_PLAYER 32864
#define OP_PLAYER_C 34912
#define OP_COMPATIBLE 32865
#define OP_COMPATIBLE_C 34913
#define OP_SELF 32866
#define OP_MSG 32867
#define OP_FROM 32868
#define OP_ARG1 32869
#define OP_ARG1_E 36965
#define OP_ARG2 32870
#define OP_ARG2_E 36966
#define OP_ARG3 32871
#define OP_ARG3_E 36967
#define OP_MOVENUMBER 32872
#define OP_LEVEL 32873
#define OP_KEY 32874
#define OP_INPUT 32875
#define OP_QUIZ 32876
#define OP_INPLACE 32877
#define OP_DEFAULTIMAGE 32878
#define OP_HELP 32879
#define OP_EDITORHELP 32880
#define OP_SUBS 32881
#define OP_ANIMATE 32882
#define OP_ASSASSINATE 32883
#define OP_ASSASSINATE_C 34931
#define OP_BROADCAST 32884
#define OP_BROADCAST_D 41076
#define OP_BROADCASTCLASS 32885
#define OP_BROADCASTEX 32886
#define OP_BROADCASTEX_D 41078
#define OP_BROADCASTSUM 32887
#define OP_BROADCASTSUMEX 32888
#define OP_CREATE 32889
#define OP_CREATE_D 41081
#define OP_DELINVENTORY 32890
#define OP_DELTA 32891
#define OP_DESTROY 32892
#define OP_DESTROY_C 34940
#define OP_DESTROY_D 41084
#define OP_DESTROY_CD 43132
#define OP_FLUSHCLASS 32893
#define OP_FLUSHOBJ 32894
#define OP_GETINVENTORY 32895
#define OP_HEIGHTAT 32896
#define OP_IGNOREKEY 32897
#define OP_INTMOVE 32898
#define OP_INTMOVE_C 34946
#define OP_INTMOVE_D 41090
#define OP_INTMOVE_CD 43138
#define OP_JUMPTO 32899
#define OP_JUMPTO_C 34947
#define OP_LOC 32900
#define OP_LOC_C 34948
#define OP_LOCATEME 32901
#define OP_LOSELEVEL 32902
#define OP_MAXINVENTORY 32903
#define OP_MOVE 32904
#define OP_MOVE_C 34952
#define OP_MOVE_D 41096
#define OP_MOVE_CD 43144
#define OP_MOVEPLUS 32905
#define OP_MOVEPLUS_C 34953
#define OP_MOVEPLUS_D 41097
#define OP_MOVEPLUS_CD 43145
#define OP_MOVETO 32906
#define OP_MOVETO_C 34954
#define OP_MOVETO_D 41098
#define OP_MOVETO_CD 43146
#define OP_NEWX 32907
#define OP_NEWY 32908
#define OP_OBJABOVE 32909
#define OP_OBJABOVE_C 34957
#define OP_OBJCLASSAT 32910
#define OP_OBJBELOW 32911
#define OP_OBJBELOW_C 34959
#define OP_OBJDIR 32912
#define OP_OBJDIR_C 34960
#define OP_POPUP 32913
#define OP_POPUPARGS 32914
#define OP_QUEUETURN 32915
#define OP_SEND 32916
#define OP_SEND_C 34964
#define OP_SEND_D 41108
#define OP_SEND_CD 43156
#define OP_SENDEX 32917
#define OP_SENDEX_C 34965
#define OP_SENDEX_D 41109
#define OP_SENDEX_CD 43157
#define OP_SETINVENTORY 32918
#define OP_SOUND 32919
#define OP_TRACE 32920
#define OP_VOLUMEAT 32921
#define OP_WINLEVEL 32922
#define OP_XDIR 32923
#define OP_XDIR_C 34971
#define OP_YDIR 32924
#define OP_YDIR_C 34972
#define OP_FUNCTION 32925
#define OP_LOCAL 32926
#define OP_LABEL 32927
#define OP_STRING 32928
#ifdef HEROMESH_CLASS
static const Op_Names op_names[]={
{"*",8486933},
{"+",8421395},
{"-",8421396},
{".",10518528},
{"/",8486934},
{"ANHH",8389394},
{"ARRIVED",8389124},
{"Animate",8421490},
{"Arg1",8552549},
{"Arg2",8552550},
{"Arg3",8552551},
{"Arrivals",8618071},
{"Arrived",8618069},
{"Assassinate",8487027},
{"B",9437196},
{"BANG",8389380},
{"BEDOINGNG",8389406},
{"BEEDEEP",8389404},
{"BEGIN_TURN",8389123},
{"BOOOM",8389410},
{"BOUNCE",8389415},
{"BRRREEET",8389396},
{"BRRRT",8389395},
{"BUZZER",8389420},
{"BWEEP",8389397},
{"Broadcast",10518644},
{"BroadcastEx",10518646},
{"BroadcastSum",8421495},
{"BroadcastSumEx",8421496},
{"Busy",8618073},
{"CHEEP",8389393},
{"CHYEW",8389392},
{"CLEANUP",8389140},
{"CLICK",8389388},
{"COLLIDE",8389142},
{"COLLIDING",8389141},
{"CREATE",8389121},
{"CREATED",8389137},
{"Class",8486955},
{"Climb",9142335},
{"Compatible",8487009},
{"Create",10518649},
{"DEEP_POP",8389417},
{"DEPARTED",8389125},
{"DESTROY",8389122},
{"DESTROYED",8389136},
{"DINK",8389390},
{"DOOR",8389378},
{"DRLRLRINK",8389398},
{"DYUPE",8389413},
{"DefaultImage",8683630},
{"DelInventory",8421498},
{"Delta",8421499},
{"Density",9142327},
{"Departed",8618070},
{"Departures",8618072},
{"Destroy",10584188},
{"Dir",8618033},
{"Distance",9142325},
{"E",9437184},
{"END_TURN",8389139},
{"EditorHelp",8683632},
{"F",9437192},
{"FAROUT",8389421},
{"FFFFTT",8389399},
{"FLOATED",8389132},
{"FROG",8389383},
{"FlushClass",8421501},
{"FlushObj",8421502},
{"From",8421476},
{"GLASS",8389379},
{"GLISSANT",8389419},
{"GetInventory",8421503},
{"HAWK",8389425},
{"HEARTBEAT",8389407},
{"HIT",8389134},
{"HITBY",8389135},
{"Hard",8618051},
{"Height",9142333},
{"HeightAt",8421504},
{"Help",8683631},
{"INIT",8389120},
{"IgnoreKey",8421505},
{"Image",8618034},
{"InPlace",8683629},
{"Inertia",9142323},
{"Input",8683627},
{"IntMove",10584194},
{"Invisible",8618074},

{"JAYAYAYNG",8389416},
{"JUMPED",8389128},
{"JumpTo",8487043},
{"KEWEL",8389422},
{"KEY",8389129},
{"KLECK",8389387},
{"KLINKK",8389385},
{"Key",8421482},
{"KeyCleared",8618075},
{"L",9437194},
{"LASTIMAGE",8389126},
{"LB",9437195},
{"LF",9437193},
{"LOCK",8389408},
{"LOOP",8388610},
{"Level",8421481},
{"Loc",8487044},
{"LocateMe",8421509},
{"LoseLevel",8421510},
{"MOVED",8389127},
{"MOVING",8389130},
{"MaxInventory",8421511},
{"Misc1",9142343},
{"Misc2",9142345},
{"Misc3",9142347},
{"Misc4",9142349},
{"Misc5",9142351},
{"Misc6",9142353},
{"Misc7",9142355},
{"Move",10584200},
{"Move+",10584201},
{"MoveNumber",8421480},
{"MoveTo",10584202},
{"Moved",8618079},
{"Msg",8421475},
{"N",9437186},
{"NE",9437185},
{"NW",9437187},
{"NewX",8421515},
{"NewY",8421516},
{"OLDPHONE",8389402},
{"ONCE",8388609},
{"OSC",8388616},
{"OSCLOOP",8388618},
{"ObjAbove",8487053},
{"ObjBelow",8487055},
{"ObjClassAt",8421518},
{"ObjDir",8487056},
{"PLAYERMOVING",8389133},
{"POSTINIT",8389138},
{"POUR",8389377},
{"POWER",8389386},
{"Player",8487008},
{"PopUp",8421521},
{"QueueTurn",8421523},
{"Quiz",8683628},
{"R",9437198},
{"RATCHET1",8389418},
{"RATCHET2",8389412},
{"RATTLE",8389403},
{"RB",9437197},
{"RF",9437199},
{"S",9437190},
{"SE",9437191},
{"SMALL_POP",8389389},
{"SPLASH",8389376},
{"STEAM",8389424},
{"STOP",8388608},
{"SUBS",8683633},
{"SUNK",8389131},
{"SW",9437189},
{"Self",8421474},
{"Send",10584212},
{"SendEx",10584213},
{"SetInventory",8421526},
{"Shape",8618030},
{"ShapeDir",8618053},
{"Sharp",8618052},
{"Shovable",8618054},
{"Sound",8421527},
{"Stealthy",8618078},
{"Strength",9142337},
{"TAHTASHH",8389409},
{"THMP_thmp",8389405},
{"THWIT",8389384},
{"TICK",8389391},
{"Temperature",9142316},
{"Trace",8421528},
{"UH_OH",8389382},
{"UNCORK",8389414},
{"UNHH",8389381},
{"UserSignal",8618076},
{"VACUUM",8389411},
{"VisualOnly",8618077},
{"Volume",9142329},
{"VolumeAt",8421529},
{"W",9437188},
{"WAHOO",8389400},
{"WHACK",8389423},
{"Weight",9142331},
{"WinLevel",8421530},
{"XDir",8487067},
{"Xloc",8486959},
{"YDir",8487068},
{"YEEHAW",8389401},
{"Yloc",8486960},
{"again",8683530},
{"band",8421403},
{"begin",8683529},
{"bit",8683551},
{"bit0",8388609},
593
594
595
596
597
598
599
600
601
{"rsh",8486938},
{"swap",8421378},
{"then",8683527},
{"tuck",8421380},
{"until",8683531},
{"while",8683532},
};
#define N_OP_NAMES 262
#endif







|

595
596
597
598
599
600
601
602
603
{"rsh",8486938},
{"swap",8421378},
{"then",8683527},
{"tuck",8421380},
{"until",8683531},
{"while",8683532},
};
#define N_OP_NAMES 263
#endif

Modified main.c from [752b28ab5b] to [03fb7ee697].

33
34
35
36
37
38
39

40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
;

sqlite3*userdb;
xrm_db*resourcedb;
const char*basefilename;
xrm_quark optionquery[16];
Uint32 generation_number;


static const char*globalclassname;
static SDL_Cursor*cursor[77];
static FILE*levelfp;
static FILE*solutionfp;
static FILE*hamarc_fp;
static long hamarc_pos;
static char main_options[128];

static void hamarc_begin(FILE*fp,const char*name) {
  while(*name) fputc(*name++,fp);
  fwrite("\0\0\0\0",1,5,hamarc_fp=fp);
  hamarc_pos=ftell(fp);
}








>







<







33
34
35
36
37
38
39
40
41
42
43
44
45
46
47

48
49
50
51
52
53
54
;

sqlite3*userdb;
xrm_db*resourcedb;
const char*basefilename;
xrm_quark optionquery[16];
Uint32 generation_number;
char main_options[128];

static const char*globalclassname;
static SDL_Cursor*cursor[77];
static FILE*levelfp;
static FILE*solutionfp;
static FILE*hamarc_fp;
static long hamarc_pos;


static void hamarc_begin(FILE*fp,const char*name) {
  while(*name) fputc(*name++,fp);
  fwrite("\0\0\0\0",1,5,hamarc_fp=fp);
  hamarc_pos=ftell(fp);
}

283
284
285
286
287
288
289

290
291
292
  load_key_bindings();
  init_screen();
  load_pictures();
  if(main_options['T']) {
    test_mode();
    return 0;
  }

  
  return 0;
}







>



283
284
285
286
287
288
289
290
291
292
293
  load_key_bindings();
  init_screen();
  load_pictures();
  if(main_options['T']) {
    test_mode();
    return 0;
  }
  load_classes();
  
  return 0;
}

Modified mbtofhm.c from [d589d1523d] to [12639d272e].

414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
#define PushFlowControl() do{ flowblock[flowptr]=ofs+2+(op[1]<<1)+(op[2]<<9); if(++flowptr==64) fatal("Too many nested flow controls\n"); len+=2; ind+=2; }while(0)

static void class_codes(FILE*fp,const unsigned char*op,int ofs,const unsigned char*lbl,int nlbl,const unsigned char*subs,int nsubs,unsigned char*vars) {
  static const char*const stdvars[256]={
    [0]="Class","Temperature","Shape",
    [4]="Xloc","Yloc","Dir","Image","Inertia","Misc1","Misc2","Misc3","Misc4","Misc5","Misc6","Misc7",
    [16]="Arrived","Departed","Arrivals","Departures",
    [32]="Busy","Invisible","UserSignal","UserState","KeyCleared","IsPlayer","Destroyed","Stealthy","VisualOnly",
    [48]="Msg","From","Arg1","Arg2",
    [64]="Density","Volume","Strength","Weight","Distance","Height","Climb",
    [72]="Hard","Hard","Hard","Hard","Sharp","Sharp","Sharp","Sharp","ShapeDir","ShapeDir","ShapeDir","ShapeDir",
    [84]="Shovable",
  };
  static const char*const direction[16]={"E","NE","N","NW","W","SW","S","SE","F","LF","L","LB","B","RB","R","RF"};
  int flowblock[64];







|







414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
#define PushFlowControl() do{ flowblock[flowptr]=ofs+2+(op[1]<<1)+(op[2]<<9); if(++flowptr==64) fatal("Too many nested flow controls\n"); len+=2; ind+=2; }while(0)

static void class_codes(FILE*fp,const unsigned char*op,int ofs,const unsigned char*lbl,int nlbl,const unsigned char*subs,int nsubs,unsigned char*vars) {
  static const char*const stdvars[256]={
    [0]="Class","Temperature","Shape",
    [4]="Xloc","Yloc","Dir","Image","Inertia","Misc1","Misc2","Misc3","Misc4","Misc5","Misc6","Misc7",
    [16]="Arrived","Departed","Arrivals","Departures",
    [32]="Busy","Invisible","UserSignal","UserState","KeyCleared","Player","Destroyed","Stealthy","VisualOnly",
    [48]="Msg","From","Arg1","Arg2",
    [64]="Density","Volume","Strength","Weight","Distance","Height","Climb",
    [72]="Hard","Hard","Hard","Hard","Sharp","Sharp","Sharp","Sharp","ShapeDir","ShapeDir","ShapeDir","ShapeDir",
    [84]="Shovable",
  };
  static const char*const direction[16]={"E","NE","N","NW","W","SW","S","SE","F","LF","L","LB","B","RB","R","RF"};
  int flowblock[64];