Free Hero Mesh

Check-in [f7d9c45b1e]
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:Start to implement arrays (there is no way to use them yet, and the converter does not yet handle arrays).
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: f7d9c45b1e1f80a6aa4caa11a316625e3070541f
User & Date: user on 2021-02-24 07:12:56
Other Links: manifest | tags
Context
2021-02-25
03:28
Implement the {append} macro; also start to implement arrays in the conversion check-in: c4bb0e3270 user: user tags: trunk
2021-02-24
07:12
Start to implement arrays (there is no way to use them yet, and the converter does not yet handle arrays). check-in: f7d9c45b1e user: user tags: trunk
2021-02-23
04:10
Add an indication of win/lose. check-in: e838ccc089 user: user tags: trunk
Changes

Modified class.c from [48cf31f9d9] to [88b2dee7a7].

45
46
47
48
49
50
51

52
53
54
55
56
57
58
int max_animation=32;
Sint32 max_volume=10000;
Uint8 back_color=1;
Uint8 inv_back_color=9;
char**stringpool;
AnimationSlot anim_slot[8];
Uint8 keymask[256/8];


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







>







45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
int max_animation=32;
Sint32 max_volume=10000;
Uint8 back_color=1;
Uint8 inv_back_color=9;
char**stringpool;
AnimationSlot anim_slot[8];
Uint8 keymask[256/8];
Uint16 array_size;

#define HASH_SIZE 8888
#define LOCAL_HASH_SIZE 5555
typedef struct {
  Uint16 id;
  char*txt;
} Hash;
871
872
873
874
875
876
877















878
879
880
881
882
883
884
      case OP_STRING: return UVALUE(pool_string(tokenstr),TY_STRING);
      case OP_BITCONSTANT ... OP_BITCONSTANT_LAST: return NVALUE(1<<(tokenv&31));
      case 0xC000 ... 0xFFFF: return MVALUE(tokenv-0xBF00);
    }
  }
  ParseError("Constant value expected\n");
}
















static void begin_label_stack(void) {
  labelstack=0;
  labelptr=malloc(0x8000*sizeof(Uint16));
  if(!labelptr) fatal("Allocation failed\n");
  memset(labelptr,255,0x8000*sizeof(Uint16));
  *labelptr=0x8001;







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







872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
      case OP_STRING: return UVALUE(pool_string(tokenstr),TY_STRING);
      case OP_BITCONSTANT ... OP_BITCONSTANT_LAST: return NVALUE(1<<(tokenv&31));
      case 0xC000 ... 0xFFFF: return MVALUE(tokenv-0xBF00);
    }
  }
  ParseError("Constant value expected\n");
}

static Uint32 parse_array(void) {
  Uint32 x,y,z;
  nxttok();
  if(tokent!=TF_INT) ParseError("Number expected\n");
  x=tokenv;
  nxttok();
  if(tokent!=TF_INT) ParseError("Number expected\n");
  y=tokenv;
  if(x<1 || x>64 || y<1 || y>255) ParseError("Array dimension out of range\n");
  z=array_size;
  if(z+x*y>0xFFFE) ParseError("Out of array memory\n");
  array_size+=x*y;
  return z|(y<<16)|(x<<24);
}

static void begin_label_stack(void) {
  labelstack=0;
  labelptr=malloc(0x8000*sizeof(Uint16));
  if(!labelptr) fatal("Allocation failed\n");
  memset(labelptr,255,0x8000*sizeof(Uint16));
  *labelptr=0x8001;
1638
1639
1640
1641
1642
1643
1644




1645

1646
1647
1648
1649
1650
1651
1652
          gloptr=parse_instructions(0,gloptr,glolocalhash,0);
          end_label_stack(classes[0]->codes,glolocalhash);
          break;
        case 0x2800 ... 0x2FFF: // Define initial values of global variables
          i=tokenv-0x2800;
          nxttok();
          if(tokent==TF_CLOSE) break;




          initglobals[i]=parse_constant_value();

          nxttok();
          if(tokent!=TF_CLOSE) ParseError("Expected close parenthesis\n");
          break;
        case OP_BACKGROUND:
          nxttok();
          if(tokent!=TF_INT) ParseError("Number expected\n");
          if(tokenv&~255) ParseError("Background color out of range\n");







>
>
>
>
|
>







1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
          gloptr=parse_instructions(0,gloptr,glolocalhash,0);
          end_label_stack(classes[0]->codes,glolocalhash);
          break;
        case 0x2800 ... 0x2FFF: // Define initial values of global variables
          i=tokenv-0x2800;
          nxttok();
          if(tokent==TF_CLOSE) break;
          if(Tokenf(TF_NAME) && tokenv==OP_ARRAY) {
            initglobals[i].t=TY_ARRAY;
            initglobals[i].u=parse_array();
          } else {
            initglobals[i]=parse_constant_value();
          }
          nxttok();
          if(tokent!=TF_CLOSE) ParseError("Expected close parenthesis\n");
          break;
        case OP_BACKGROUND:
          nxttok();
          if(tokent!=TF_INT) ParseError("Number expected\n");
          if(tokenv&~255) ParseError("Background color out of range\n");
1722
1723
1724
1725
1726
1727
1728




1729
1730
    }
  }
  if(vst) sqlite3_finalize(vst);
  free(glohash);
  for(i=1;i<undef_class;i++) if(classes[i] && (classes[i]->cflags&CF_NOCLASS1)) fatal("Class $%s mentioned but not defined\n",classes[i]->name);
  if(macros) for(i=0;i<MAX_MACRO;i++) if(macros[i]) free_macro(macros[i]);
  free(macros);




  fprintf(stderr,"Done\n");
}







>
>
>
>


1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
    }
  }
  if(vst) sqlite3_finalize(vst);
  free(glohash);
  for(i=1;i<undef_class;i++) if(classes[i] && (classes[i]->cflags&CF_NOCLASS1)) fatal("Class $%s mentioned but not defined\n",classes[i]->name);
  if(macros) for(i=0;i<MAX_MACRO;i++) if(macros[i]) free_macro(macros[i]);
  free(macros);
  if(array_size) {
    array_data=malloc(array_size*sizeof(Value));
    if(!array_data) fatal("Array allocation failed\n");
  }
  fprintf(stderr,"Done\n");
}

Modified class.doc from [3a9f5e183b] to [30af8774af].

209
210
211
212
213
214
215






216
217
218
219
220
221
222
  between two other objects. The default value is 10000.

($<name> <definitions...>)
  Define a class. See the section about class definitions for details.

(@<name> <value>)
  Define a global variable and its initial value.







(<message> <code...>)
  Defines a default message code for all classes which do not specify
  their own code for this message.


=== Class definitions ===







>
>
>
>
>
>







209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
  between two other objects. The default value is 10000.

($<name> <definitions...>)
  Define a class. See the section about class definitions for details.

(@<name> <value>)
  Define a global variable and its initial value.

(@<name> Array <columns> <rows>)
  Define a global variable whose value is a reference to a new array, with
  the specified dimensions. The maximum number of columns is 64, and the
  maximum number of rows is 255, and he maximum number of cells in all
  arrays in total is 65534.

(<message> <code...>)
  Defines a default message code for all classes which do not specify
  their own code for this message.


=== Class definitions ===

Modified exec.c from [21d410450b] to [68326341a7].

32
33
34
35
36
37
38

39
40
41
42
43
44
45
Uint8 generation_number_inc;
Uint32 move_number;
unsigned char*quiz_text;
Inventory*inventory;
Uint32 ninventory;
char**levelstrings;
Uint16 nlevelstrings;


typedef struct {
  Uint16 msg;
  Uint32 from;
  Value arg1,arg2,arg3;
} MessageVars;








>







32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
Uint8 generation_number_inc;
Uint32 move_number;
unsigned char*quiz_text;
Inventory*inventory;
Uint32 ninventory;
char**levelstrings;
Uint16 nlevelstrings;
Value*array_data;

typedef struct {
  Uint16 msg;
  Uint32 from;
  Value arg1,arg2,arg3;
} MessageVars;

Modified fileform1.txt from [3531e0b394] to [810ca18dc0].

280
281
282
283
284
285
286


287
288
289
290
291
292
293
[36] ObjBelow

[38/2*] 0=ObjTopAt, 1=ObjBottomAt, 2=VolumeAt, 3=HeightAt, 4=Delta

[39*] Self

[40/3*] ObjClassAt



[48*] Key

[49*] Animation constant: 0=STOP, 1=ONCE, 2=LOOP, 8=OSC

[50*] Keyboard constant: See section about key codes.








>
>







280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
[36] ObjBelow

[38/2*] 0=ObjTopAt, 1=ObjBottomAt, 2=VolumeAt, 3=HeightAt, 4=Delta

[39*] Self

[40/3*] ObjClassAt

[47*] Array reference; next word is the array address.

[48*] Key

[49*] Animation constant: 0=STOP, 1=ONCE, 2=LOOP, 8=OSC

[50*] Keyboard constant: See section about key codes.

Modified heromesh.h from [2279de3f22] to [6692b185fe].

12
13
14
15
16
17
18

19
20
21
22
23
24
25
#define TY_MESSAGE 2
#define TY_LEVELSTRING 3
#define TY_STRING 4
#define TY_SOUND 5
#define TY_USOUND 6
#define TY_FOR 7
#define TY_MARK 8

#define TY_MAXTYPE 15
// The level file format requires type codes 0 to 3 to be as is; other codes may change.

typedef struct {
  union {
    Sint32 s;
    Uint32 u;







>







12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#define TY_MESSAGE 2
#define TY_LEVELSTRING 3
#define TY_STRING 4
#define TY_SOUND 5
#define TY_USOUND 6
#define TY_FOR 7
#define TY_MARK 8
#define TY_ARRAY 9
#define TY_MAXTYPE 15
// The level file format requires type codes 0 to 3 to be as is; other codes may change.

typedef struct {
  union {
    Sint32 s;
    Uint32 u;
163
164
165
166
167
168
169

170
171
172
173
174
175
176
extern Uint16 functions[0x4000];
extern int max_animation; // max steps in animation queue (default 32)
extern Sint32 max_volume; // max total volume to allow moving diagonally (default 10000)
extern Uint8 back_color,inv_back_color;
extern char**stringpool;
extern AnimationSlot anim_slot[8];
extern Uint8 keymask[256/8];


Uint16 get_message_ptr(int c,int m);
void load_classes(void);

// == bindings ==

typedef struct {







>







164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
extern Uint16 functions[0x4000];
extern int max_animation; // max steps in animation queue (default 32)
extern Sint32 max_volume; // max total volume to allow moving diagonally (default 10000)
extern Uint8 back_color,inv_back_color;
extern char**stringpool;
extern AnimationSlot anim_slot[8];
extern Uint8 keymask[256/8];
extern Uint16 array_size;

Uint16 get_message_ptr(int c,int m);
void load_classes(void);

// == bindings ==

typedef struct {
247
248
249
250
251
252
253

254
255
256
257
258
259
260
extern Uint8 generation_number_inc;
extern Uint32 move_number;
extern unsigned char*quiz_text;
extern Inventory*inventory;
extern Uint32 ninventory;
extern char**levelstrings;
extern Uint16 nlevelstrings;


const char*value_string_ptr(Value v);
void pfunlink(Uint32 n);
void pflink(Uint32 n);
Uint32 objalloc(Uint16 c);
void objtrash(Uint32 n);
void annihilate(void);







>







249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
extern Uint8 generation_number_inc;
extern Uint32 move_number;
extern unsigned char*quiz_text;
extern Inventory*inventory;
extern Uint32 ninventory;
extern char**levelstrings;
extern Uint16 nlevelstrings;
extern Value*array_data;

const char*value_string_ptr(Value v);
void pfunlink(Uint32 n);
void pflink(Uint32 n);
Uint32 objalloc(Uint16 c);
void objtrash(Uint32 n);
void annihilate(void);

Modified instruc from [e7d465050e] to [530d389594].

251
252
253
254
255
256
257






258
259
260
261
262
263
264
; Operations with marks
mark "_"
tmark
in
nin
-mbegin







; Specials
*Function
*Local
*Label
*String
*Int16
*Int32







>
>
>
>
>
>







251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
; Operations with marks
mark "_"
tmark
in
nin
-mbegin

; Arrays
-Array
,GetArray
InitArray
,SetArray

; Specials
*Function
*Local
*Label
*String
*Int16
*Int32

Modified instruc.h from [a43f3b2833] to [68f9f64e2e].

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
#define OP_YDIR 32945
#define OP_YDIR_C 34993
#define OP_MARK 32946
#define OP_TMARK 32947
#define OP_IN 32948
#define OP_NIN 32949
#define OP_MBEGIN 32950






#define OP_FUNCTION 32951
#define OP_LOCAL 32952
#define OP_LABEL 32953
#define OP_STRING 32954
#define OP_INT16 32955
#define OP_INT32 32956
#define OP_DISPATCH 32957
#ifdef HEROMESH_CLASS
static const Op_Names op_names[]={
{"*",8486936},
{"+",8421398},
{"-",8421399},
{"-rot",8421382},
{".",10518528},
{"/",8486937},
{"ANHH",8389394},
{"ARRIVED",8389124},
{"Animate",8421505},
{"Arg1",8552563},
{"Arg2",8552564},
{"Arg3",8552565},

{"Arrivals",8618081},
{"Arrived",8618079},
{"Assassinate",8487042},
{"B",9437196},
{"BANG",8389380},
{"BEDOINGNG",8389406},
{"BEEDEEP",8389404},







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














>







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
#define OP_YDIR 32945
#define OP_YDIR_C 34993
#define OP_MARK 32946
#define OP_TMARK 32947
#define OP_IN 32948
#define OP_NIN 32949
#define OP_MBEGIN 32950
#define OP_ARRAY 32951
#define OP_GETARRAY 32952
#define OP_GETARRAY_C 35000
#define OP_INITARRAY 32953
#define OP_SETARRAY 32954
#define OP_SETARRAY_C 35002
#define OP_FUNCTION 32955
#define OP_LOCAL 32956
#define OP_LABEL 32957
#define OP_STRING 32958
#define OP_INT16 32959
#define OP_INT32 32960
#define OP_DISPATCH 32961
#ifdef HEROMESH_CLASS
static const Op_Names op_names[]={
{"*",8486936},
{"+",8421398},
{"-",8421399},
{"-rot",8421382},
{".",10518528},
{"/",8486937},
{"ANHH",8389394},
{"ARRIVED",8389124},
{"Animate",8421505},
{"Arg1",8552563},
{"Arg2",8552564},
{"Arg3",8552565},
{"Array",8683703},
{"Arrivals",8618081},
{"Arrived",8618079},
{"Assassinate",8487042},
{"B",9437196},
{"BANG",8389380},
{"BEDOINGNG",8389406},
{"BEEDEEP",8389404},
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
{"FLOATED",8389132},
{"FROG",8389383},
{"FlushClass",8421516},
{"FlushObj",8487053},
{"From",8421490},
{"GLASS",8389379},
{"GLISSANT",8389419},

{"GetInventory",8421518},
{"HAWK",8389425},
{"HEARTBEAT",8389407},
{"HIT",8389134},
{"HITBY",8389135},
{"Hard",8618061},
{"Height",9142343},
{"HeightAt",8421519},
{"Help",8683646},
{"INIT",8389120},
{"IgnoreKey",8421520},
{"Image",8618044},
{"InPlace",8683644},
{"Inertia",9142333},

{"Input",8683642},
{"IntMove",10584209},
{"Invisible",8618084},
{"JAYAYAYNG",8389416},
{"JUMPED",8389128},
{"JumpTo",10584210},
{"KEWEL",8389422},







>














>







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
{"FLOATED",8389132},
{"FROG",8389383},
{"FlushClass",8421516},
{"FlushObj",8487053},
{"From",8421490},
{"GLASS",8389379},
{"GLISSANT",8389419},
{"GetArray",8487096},
{"GetInventory",8421518},
{"HAWK",8389425},
{"HEARTBEAT",8389407},
{"HIT",8389134},
{"HITBY",8389135},
{"Hard",8618061},
{"Height",9142343},
{"HeightAt",8421519},
{"Help",8683646},
{"INIT",8389120},
{"IgnoreKey",8421520},
{"Image",8618044},
{"InPlace",8683644},
{"Inertia",9142333},
{"InitArray",8421561},
{"Input",8683642},
{"IntMove",10584209},
{"Invisible",8618084},
{"JAYAYAYNG",8389416},
{"JUMPED",8389128},
{"JumpTo",10584210},
{"KEWEL",8389422},
545
546
547
548
549
550
551

552
553
554
555
556
557
558
{"STOP",8388608},
{"SUBS",8683648},
{"SUNK",8389131},
{"SW",9437189},
{"Self",8421488},
{"Send",10584231},
{"SendEx",10584232},

{"SetInventory",8421545},
{"Shape",8618040},
{"ShapeDir",8618063},
{"Sharp",8618062},
{"Shovable",8618064},
{"Sound",8421546},
{"Stealthy",8618089},







>







554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
{"STOP",8388608},
{"SUBS",8683648},
{"SUNK",8389131},
{"SW",9437189},
{"Self",8421488},
{"Send",10584231},
{"SendEx",10584232},
{"SetArray",8487098},
{"SetInventory",8421545},
{"Shape",8618040},
{"ShapeDir",8618063},
{"Sharp",8618062},
{"Shovable",8618064},
{"Sound",8421546},
{"Stealthy",8618089},
663
664
665
666
667
668
669
670
671
{"swap",8421378},
{"then",8683530},
{"tmark",8421555},
{"tuck",8421380},
{"until",8683534},
{"while",8683535},
};
#define N_OP_NAMES 290
#endif







|

673
674
675
676
677
678
679
680
681
{"swap",8421378},
{"then",8683530},
{"tmark",8421555},
{"tuck",8421380},
{"until",8683534},
{"while",8683535},
};
#define N_OP_NAMES 294
#endif