Free Hero Mesh

Check-in [f833310c79]
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:Add shell script to compile everything; support $CFLAGS and $EXE environment variables
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: f833310c7907ca9da825cfe3da5c20f0dc461ea4
User & Date: user on 2018-05-19 22:31:04
Other Links: manifest | tags
Context
2018-05-27
22:33
More class loading code check-in: 9d448767e4 user: user tags: trunk
2018-05-19
22:31
Add shell script to compile everything; support $CFLAGS and $EXE environment variables check-in: f833310c79 user: user tags: trunk
19:23
More parsing of .class file check-in: e049e8ed33 user: user tags: trunk
Changes

Modified bindings.c from [4c842f9721] to [faaaf44809].

1
2

3
4
5
6
7
8
9
1

2
3
4
5
6
7
8
9

-
+







#if 0
gcc -s -O2 -c -Wno-unused-result bindings.c `sdl-config --cflags`
gcc ${CFLAGS:--s -O2} -c -Wno-unused-result bindings.c `sdl-config --cflags`
exit
#endif

/*
  This program is part of Free Hero Mesh and is public domain.
*/

Modified class.c from [aa9b29b498] to [8167e45e03].

1
2

3
4
5
6
7
8
9
1

2
3
4
5
6
7
8
9

-
+







#if 0
gcc -s -O2 -c -Wno-unused-result class.c `sdl-config --cflags`
gcc ${CFLAGS:--s -O2} -c -Wno-unused-result class.c `sdl-config --cflags`
exit
#endif

/*
  This program is part of Free Hero Mesh and is public domain.
*/

815
816
817
818
819
820
821





822
823
824
825
826
827
828
829
830
831
832
833
834
835




























836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852

853
854
855
856
857
858
859
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839

840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883

884
885
886
887
888
889
890
891







+
+
+
+
+













-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
















-
+







  }
  ParseError("Constant value expected\n");
}

#define AddInst(x) (cl->codes[ptr++]=(x),prflag=0)
#define AddInst2(x,y) (cl->codes[ptr++]=(x),cl->codes[ptr++]=(y),prflag=0,peep=ptr)
#define AddInstF(x,y) (cl->codes[ptr++]=(x),prflag=(y))
#define ChangeInst(x) (cl->codes[ptr-1]x,prflag=0)
#define InstFlag(x) (peep<ptr && (prflag&(x)))
#define Inst7bit() (peep<ptr && cl->codes[ptr-1]<0x0080)
#define Inst8bit() (peep<ptr && cl->codes[ptr-1]<0x0100)
#define AbbrevOp(x,y) case x: if(Inst7bit()) ChangeInst(+=0x1000|((y)<<4)); else AddInstF(x,tokent); break
static int parse_instructions(int cla,int ptr,Hash*hash) {
  int peep=ptr;
  int prflag=0;
  Class*cl=classes[cla];
  cl->codes=realloc(cl->codes,0x10000*sizeof(Uint16));
  if(!cl->codes) fatal("Allocation failed\n");
  for(;;) {
    nxttok();
    if(Tokenf(TF_MACRO)) ParseError("Unexpected macro\n");
    if(Tokenf(TF_INT)) {
      
    } else if(Tokenf(TF_NAME)) {
      switch(tokenv) {
        
        AbbrevOp(OP_ADD,0x00);
        AbbrevOp(OP_SUB,0x08);
        AbbrevOp(OP_MUL,0x10);
        AbbrevOp(OP_DIV,0x18);
        AbbrevOp(OP_MOD,0x20);
        AbbrevOp(OP_MUL_C,0x28);
        AbbrevOp(OP_DIV_C,0x30);
        AbbrevOp(OP_MOD_C,0x38);
        AbbrevOp(OP_BAND,0x40);
        AbbrevOp(OP_BOR,0x48);
        AbbrevOp(OP_BXOR,0x50);
        AbbrevOp(OP_LSH,0x58);
        AbbrevOp(OP_RSH,0x60);
        AbbrevOp(OP_RSH_C,0x68);
        AbbrevOp(OP_EQ,0x70);
        AbbrevOp(OP_NE,0x78);
        AbbrevOp(OP_LT,0x80);
        AbbrevOp(OP_GT,0x88);
        AbbrevOp(OP_LE,0x90);
        AbbrevOp(OP_GE,0x98);
        AbbrevOp(OP_LT_C,0xA0);
        AbbrevOp(OP_GT_C,0xA8);
        AbbrevOp(OP_LE_C,0xB0);
        AbbrevOp(OP_GE_C,0xB8);
        case OP_DROP:
          if(InstFlag(TF_DROP)) ChangeInst(+=0x2000);
          else AddInst(OP_DROP);
          break;
        default:
          if(Tokenf(TF_ABNORMAL)) ParseError("Invalid instruction token\n");
          AddInstF(tokenv,tokent);
      }
    } else if(Tokenf(TF_FUNCTION)) {
      AddInst2(OP_FUNCTION,tokenv&0x3FFF);
    } else if(tokent==TF_OPEN) {
      nxttok();
      if(Tokenf(TF_MACRO) || !Tokenf(TF_NAME)) ParseError("Invalid parenthesized instruction\n");
      switch(tokenv) {
        
        default:
          ParseError("Invalid parenthesized instruction\n");
      }
    } else if(tokent==TF_CLOSE) {
      
      if(peep<ptr && cl->codes[ptr-1]<0x0100) cl->codes[ptr-1]+=0x1E00;
      if(Inst8bit()) ChangeInst(+=0x1E00);
      else AddInst(OP_RET);
      break;
    } else {
      ParseError("Invalid instruction token\n");
    }
    if(ptr>=0xFFEF) ParseError("Out of code space\n");
  }

Added compile version [ab1f577adf].
















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#!/bin/bash --
test "x$EXE" = "x" && EXE=~/bin/heromesh
test instruc -nt instruc.h && node instruc.js > instruc.h
test instruc.js -nt instruc.h && node instruc.js > instruc.h
test names.js -nt names.h && node names.js > names.h
test quarks -nt quarks.h && node quarks.js > quarks.h
test quarks.js -nt quarks.h && node quarks.js > quarks.h
test heromesh.h -nt "$EXE" && rm bindings.o class.o picture.o
test instruc.h -nt "$EXE" && rm class.o
test pcfont.h -nt "$EXE" && rm picture.o
test quarks.h -nt "$EXE" && rm bindings.o picture.o
test bindings.c -nt bindings.o && bash bindings.c
test class.c -nt class.o && bash class.c
test picture.c -nt picture.o && bash picture.c
bash main.c

Modified main.c from [2e8581e7e0] to [00241b77ff].

1
2

3
4
5
6
7
8
9
1

2
3
4
5
6
7
8
9

-
+







#if 0
gcc -s -O2 -o ~/bin/heromesh main.c class.o picture.o bindings.o smallxrm.o sqlite3.o `sdl-config --cflags --libs` -ldl -lpthread
gcc ${CFLAGS:--s -O2} -o ${EXE:-~/bin/heromesh} main.c class.o picture.o bindings.o smallxrm.o sqlite3.o `sdl-config --cflags --libs` -ldl -lpthread
exit
#endif

/*
  This program is part of Free Hero Mesh and is public domain.
*/

Modified names.h from [dbba9433ad] to [9957cbf76e].

16
17
18
19
20
21
22


23
24
25
26
27
28
29
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31







+
+







#define MSG_HIT 14
#define MSG_HITBY 15
#define MSG_DESTROYED 16
#define MSG_CREATED 17
#define MSG_POSTINIT 18
#define MSG_END_TURN 19
#define MSG_CLEANUP 20
#define MSG_COLLIDING 21
#define MSG_COLLIDE 22
const char*const standard_message_names[]={
 "INIT",
 "CREATE",
 "DESTROY",
 "BEGIN_TURN",
 "ARRIVED",
 "DEPARTED",
38
39
40
41
42
43
44


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







+
+







 "HIT",
 "HITBY",
 "DESTROYED",
 "CREATED",
 "POSTINIT",
 "END_TURN",
 "CLEANUP",
 "COLLIDING",
 "COLLIDE",
};
#define SND_SPLASH 0
#define SND_POUR 1
#define SND_DOOR 2
#define SND_GLASS 3
#define SND_BANG 4
#define SND_UNHH 5

Modified picture.c from [bddcfb3e17] to [2270c225a7].

1
2

3
4
5
6
7
8
9
1

2
3
4
5
6
7
8
9

-
+







#if 0
gcc -s -O2 -c -Wno-unused-result picture.c `sdl-config --cflags`
gcc ${CFLAGS:--s -O2} -c -Wno-unused-result picture.c `sdl-config --cflags`
exit
#endif

/*
  This program is part of Free Hero Mesh and is public domain.
*/

Modified quarks.h from [3e75134810] to [1c8a2f470a].

169
170
171
172
173
174
175

176
177
178
179
180
181
182
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183







+







#define Q_sqlInit 170
#define Q_sqlExtensions 171
#define Q_sqlMemStatus 172
#define Q_sqlSmallAllocations 173
#define Q_sqlCoveringIndexScan 174
#define Q_sqlPowerSafe 175
#define Q_level 176
#define Q_tracePrefix 177
static const char*const global_quarks[]={
  "screenWidth",
  "screenHeight",
  "palette",
  "popupColors",
  "imageSize",
  "altImage",
345
346
347
348
349
350
351

352
353
354
355
356
357
358
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360







+







  "sqlInit",
  "sqlExtensions",
  "sqlMemStatus",
  "sqlSmallAllocations",
  "sqlCoveringIndexScan",
  "sqlPowerSafe",
  "level",
  "tracePrefix",
0};
#ifdef HEROMESH_BINDINGS
static const SDLKey quark_to_key[Q_undo+1-Q_backspace]={
SDLK_BACKSPACE,
SDLK_TAB,
SDLK_CLEAR,
SDLK_RETURN,