Free Hero Mesh

Check-in [a9cc459c7a]
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:Implement the \d escape for embedding data in strings. The ability to use this data is not implemented yet.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: a9cc459c7a05967e33f2fc66226773ab35d35af4
User & Date: user on 2021-05-26 05:03:53
Other Links: manifest | tags
Context
2021-05-27
02:17
Implement the "Data" instruction to read string data. check-in: 21abf7afd3 user: user tags: trunk
2021-05-26
05:03
Implement the \d escape for embedding data in strings. The ability to use this data is not implemented yet. check-in: a9cc459c7a user: user tags: trunk
2021-05-24
05:06
Implement the {edit} macro. check-in: c343f9952a user: user tags: trunk
Changes

Modified TODO from [a0fc23867b] to [123e22dc1f].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
* Sound effects
  * Wave sounds
    * Standard sounds
    * User sounds
  * MML sounds
  * Numeric sounds (?)
* Game engine features
  * Multiple connected objects moving as a unit
  * Bizarro world
  * Testing the deferred movement
  * String data (?)
  * A ,PopUp command to use a popup with arguments starting from a mark
  * "Goto message" instruction (?)
  * Returning a class from COLLIDE/COLLIDEBY to transform
* Editor
  * Mouse dragging
  * Level index editor
  * Bizarro world










|







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
* Sound effects
  * Wave sounds
    * Standard sounds
    * User sounds
  * MML sounds
  * Numeric sounds (?)
* Game engine features
  * Multiple connected objects moving as a unit
  * Bizarro world
  * Testing the deferred movement
  * String data
  * A ,PopUp command to use a popup with arguments starting from a mark
  * "Goto message" instruction (?)
  * Returning a class from COLLIDE/COLLIDEBY to transform
* Editor
  * Mouse dragging
  * Level index editor
  * Bizarro world

Modified class.c from [3ce0307661] to [85b9587edc].

199
200
201
202
203
204
205

206
207
208
209
210
211
212
        isimg=0;
        tokenstr[i++]=c;
      } else switch(c=fgetc(classfp)) {
        case '"': case '\\': tokenstr[i++]=c; break;
        case '0' ... '7': tokenstr[i++]=c+1-'0'; break;
        case 'b': tokenstr[i++]=15; break;
        case 'c': tokenstr[i++]=12; break;

        case 'i': tokenstr[i++]=14; isimg=1; break;
        case 'l': tokenstr[i++]=11; break;
        case 'n': tokenstr[i++]=10; break;
        case 'q': tokenstr[i++]=16; break;
        case 'x':
          c=fgetc(classfp);
          if(c>='0' && c<='9') n=c-'0';







>







199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
        isimg=0;
        tokenstr[i++]=c;
      } else switch(c=fgetc(classfp)) {
        case '"': case '\\': tokenstr[i++]=c; break;
        case '0' ... '7': tokenstr[i++]=c+1-'0'; break;
        case 'b': tokenstr[i++]=15; break;
        case 'c': tokenstr[i++]=12; break;
        case 'd': tokenstr[i++]=30; isimg=1; break;
        case 'i': tokenstr[i++]=14; isimg=1; break;
        case 'l': tokenstr[i++]=11; break;
        case 'n': tokenstr[i++]=10; break;
        case 'q': tokenstr[i++]=16; break;
        case 'x':
          c=fgetc(classfp);
          if(c>='0' && c<='9') n=c-'0';

Modified class.doc from [e830fb8c52] to [b18e2bc6a7].

78
79
80
81
82
83
84






85
86
87
88
89
90
91

\b
  Draws a horizontal rule.

\c
  Makes further text centred.







\iCLASS:NUMBER\
  Displays a picture. Give the class name (without $ at first) and a
  colon and the zero-based index number of the picture in that class.
  This is then followed by another backslash. The picture may span
  multiple lines; it will automatically move the text to make room.

\l







>
>
>
>
>
>







78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97

\b
  Draws a horizontal rule.

\c
  Makes further text centred.

\dDATA\
  Includes inline data in the string. The data is not displayed, but
  can be read by class codes, or used in level titles to provide data
  and delimieters for the auto-generated table of contents. Data items
  are separated by semicolons. (Not fully implemented yet)

\iCLASS:NUMBER\
  Displays a picture. Give the class name (without $ at first) and a
  colon and the zero-based index number of the picture in that class.
  This is then followed by another backslash. The picture may span
  multiple lines; it will automatically move the text to make room.

\l

Modified edit.c from [597bb9c9cc] to [70b9d7bc21].

749
750
751
752
753
754
755

756
757
758
759
760
761
762
    case 1 ... 8: fprintf(fp,"\\%c",c+'0'-1); break;
    case 10: fprintf(fp,"\\n"); break;
    case 11: fprintf(fp,"\\l"); break;
    case 12: fprintf(fp,"\\c"); break;
    case 14: fprintf(fp,"\\i"); isimg=1; break;
    case 15: fprintf(fp,"\\b"); break;
    case 16: fprintf(fp,"\\q"); break;

    case 31:
      if(!*t) break;
      fprintf(fp,"\\x%02X",*t++);
      break;
    case 32 ... 127:
      if(c=='\\') {
        if(isimg) isimg=0; else fputc(c,fp);







>







749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
    case 1 ... 8: fprintf(fp,"\\%c",c+'0'-1); break;
    case 10: fprintf(fp,"\\n"); break;
    case 11: fprintf(fp,"\\l"); break;
    case 12: fprintf(fp,"\\c"); break;
    case 14: fprintf(fp,"\\i"); isimg=1; break;
    case 15: fprintf(fp,"\\b"); break;
    case 16: fprintf(fp,"\\q"); break;
    case 30: fprintf(fp,"\\d"); isimg=1; break;
    case 31:
      if(!*t) break;
      fprintf(fp,"\\x%02X",*t++);
      break;
    case 32 ... 127:
      if(c=='\\') {
        if(isimg) isimg=0; else fputc(c,fp);
885
886
887
888
889
890
891

892
893
894
895
896
897
898
        isimg=0;
        *q++='\\';
      } else {
        switch(*p) {
          case '0' ... '7': *q++=*p+1-'0'; break;
          case 'b': *q++=15; break;
          case 'c': *q++=12; break;

          case 'i': *q++=14; isimg=1; break;
          case 'l': *q++=11; break;
          case 'n': *q++=10; break;
          case 'q': *q++=16; break;
          case 'x':
            *q++=31;
            *q=0;







>







886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
        isimg=0;
        *q++='\\';
      } else {
        switch(*p) {
          case '0' ... '7': *q++=*p+1-'0'; break;
          case 'b': *q++=15; break;
          case 'c': *q++=12; break;
          case 'd': *q++=30; isimg=1; break;
          case 'i': *q++=14; isimg=1; break;
          case 'l': *q++=11; break;
          case 'n': *q++=10; break;
          case 'q': *q++=16; break;
          case 'x':
            *q++=31;
            *q=0;
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
    draw_text(0,16," Title: ",0xF9,0xFF);
  } else {
    snprintf(buf,19," String %d: ",(int)(ps-levelstrings));
    draw_text(0,16,buf,0xF9,0xFF);
  }
  draw_text(160,16,o?"OVR":"INS",0xF1,0xFE);
  draw_text(0,0,"<Esc> Cancel  <F1> Preview  <F2> Save  <\x18\x19\x1A\x1B> MoveCursor  <^P> InsertChar  <^Y> DelLine",0xF1,0xFB);
  draw_text(0,8,"ALT+  <0-7> Color  <B> Bar  <C> Center  <I> Image  <L> Left  <Q> Quiz",0xF1,0xFB);
  draw_text(0,24,"\x10",0xF0,0xF1);
  cp=0;
  for(i=j=n=0;s[i] && n<63;) {
    draw_text(0,(n+3)<<3,"\x10",0xF0,0xF1);
    i+=draw_text_line(8,(n+3)<<3,s+i,r==n?c:-1,&cp);
    if(j=(s[i]==10)) i++;
    sz=li[++n]=i;







|







1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
    draw_text(0,16," Title: ",0xF9,0xFF);
  } else {
    snprintf(buf,19," String %d: ",(int)(ps-levelstrings));
    draw_text(0,16,buf,0xF9,0xFF);
  }
  draw_text(160,16,o?"OVR":"INS",0xF1,0xFE);
  draw_text(0,0,"<Esc> Cancel  <F1> Preview  <F2> Save  <\x18\x19\x1A\x1B> MoveCursor  <^P> InsertChar  <^Y> DelLine",0xF1,0xFB);
  draw_text(0,8,"ALT+  <0-7> Color  <B> Bar  <C> Center  <D> Data  <I> Image  <L> Left  <Q> Quiz",0xF1,0xFB);
  draw_text(0,24,"\x10",0xF0,0xF1);
  cp=0;
  for(i=j=n=0;s[i] && n<63;) {
    draw_text(0,(n+3)<<3,"\x10",0xF0,0xF1);
    i+=draw_text_line(8,(n+3)<<3,s+i,r==n?c:-1,&cp);
    if(j=(s[i]==10)) i++;
    sz=li[++n]=i;
1237
1238
1239
1240
1241
1242
1243

1244
1245
1246
1247
1248
1249
1250
                case SDLK_3: i=4; goto addch;
                case SDLK_4: i=5; goto addch;
                case SDLK_5: i=6; goto addch;
                case SDLK_6: i=7; goto addch;
                case SDLK_7: i=8; goto addch;
                case SDLK_b: i=15; goto addch;
                case SDLK_c: i=12; goto addch;

                case SDLK_i: i=14; goto addch;
                case SDLK_l: i=11; goto addch;
                case SDLK_n: i=10; goto addch;
                case SDLK_q: i=16; goto addch;
              }
            }
            if(i<32) {







>







1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
                case SDLK_3: i=4; goto addch;
                case SDLK_4: i=5; goto addch;
                case SDLK_5: i=6; goto addch;
                case SDLK_6: i=7; goto addch;
                case SDLK_7: i=8; goto addch;
                case SDLK_b: i=15; goto addch;
                case SDLK_c: i=12; goto addch;
                case SDLK_d: i=30; goto addch;
                case SDLK_i: i=14; goto addch;
                case SDLK_l: i=11; goto addch;
                case SDLK_n: i=10; goto addch;
                case SDLK_q: i=16; goto addch;
              }
            }
            if(i<32) {

Modified function.c from [3f86e6b7e6] to [bc142b3500].

138
139
140
141
142
143
144

145
146
147
148
149
150
151
    case 1 ... 8: e[en++]='\\'; e[en++]=c+'0'-1; break;
    case 10: e[en++]='\\'; e[en++]='n'; break;
    case 11: e[en++]='\\'; e[en++]='l'; break;
    case 12: e[en++]='\\'; e[en++]='c'; break;
    case 14: e[en++]='\\'; e[en++]='i'; isimg=1; break;
    case 15: e[en++]='\\'; e[en++]='b'; break;
    case 16: e[en++]='\\'; e[en++]='q'; break;

    case 31:
      if(i==un) break;
      c=u[i++];
      e[en++]='\\';
      e[en++]='x';
      e[en++]=(c>>4)<10?(c>>4)+'0':(c>>4)+'A'-10;
      e[en++]=c<10?c+'0':c+'A'-10;







>







138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
    case 1 ... 8: e[en++]='\\'; e[en++]=c+'0'-1; break;
    case 10: e[en++]='\\'; e[en++]='n'; break;
    case 11: e[en++]='\\'; e[en++]='l'; break;
    case 12: e[en++]='\\'; e[en++]='c'; break;
    case 14: e[en++]='\\'; e[en++]='i'; isimg=1; break;
    case 15: e[en++]='\\'; e[en++]='b'; break;
    case 16: e[en++]='\\'; e[en++]='q'; break;
    case 30: e[en++]='\\'; e[en++]='d'; isimg=1; break;
    case 31:
      if(i==un) break;
      c=u[i++];
      e[en++]='\\';
      e[en++]='x';
      e[en++]=(c>>4)<10?(c>>4)+'0':(c>>4)+'A'-10;
      e[en++]=c<10?c+'0':c+'A'-10;
207
208
209
210
211
212
213

214
215
216
217
218
219
220
      if(isimg) {
        u[un++]=c;
        isimg=0;
      } else switch(c=*e++) {
        case '0' ... '7': u[un++]=c-'0'+1; break;
        case 'b': u[un++]=15; break;
        case 'c': u[un++]=12; break;

        case 'i': u[un++]=14; isimg=1; break;
        case 'l': u[un++]=11; break;
        case 'n': u[un++]=10; break;
        case 'q': u[un++]=16; break;
        case 'x':
          c=*e++;
          if(c>='0' && c<='9') n=c-'0';







>







208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
      if(isimg) {
        u[un++]=c;
        isimg=0;
      } else switch(c=*e++) {
        case '0' ... '7': u[un++]=c-'0'+1; break;
        case 'b': u[un++]=15; break;
        case 'c': u[un++]=12; break;
        case 'd': u[un++]=30; isimg=1; break;
        case 'i': u[un++]=14; isimg=1; break;
        case 'l': u[un++]=11; break;
        case 'n': u[un++]=10; break;
        case 'q': u[un++]=16; break;
        case 'x':
          c=*e++;
          if(c>='0' && c<='9') n=c-'0';

Modified picture.c from [bbecfebc55] to [67c348a827].

159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
      bg=0xF0,fg=0xF1;
      e=1;
    } else if(!*t) {
      f=fontdata+(254<<3);
      bg=0xF0,fg=0xF1;
      e=1;
    } else if(*t<31) {
      f=fontdata+(" 01234567?NLC#IBQ???????????????"[*t]<<3);
      if(*t==14) isimg=1;
      bg=0xF3,fg=0xF0;
    } else {
      if(*t==31 && t[1]) t++;
      f=fontdata+(*t<<3);
      bg=0xF0,fg=isimg?0xF2:0xF7;
    }
    if(!cur--) bg^=15,fg^=15;







|
|







159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
      bg=0xF0,fg=0xF1;
      e=1;
    } else if(!*t) {
      f=fontdata+(254<<3);
      bg=0xF0,fg=0xF1;
      e=1;
    } else if(*t<31) {
      f=fontdata+(" 01234567?NLC#IBQ?????????????D?"[*t]<<3);
      if(*t==14 || *t==30) isimg=1;
      bg=0xF3,fg=0xF0;
    } else {
      if(*t==31 && t[1]) t++;
      f=fontdata+(*t<<3);
      bg=0xF0,fg=isimg?0xF2:0xF7;
    }
    if(!cur--) bg^=15,fg^=15;
1081
1082
1083
1084
1085
1086
1087




1088
1089
1090
1091
1092
1093
1094
      if(ln<64) li[ln].a=li[ln-1].a;
      break;
    case 16:
      lw+=24;
      if(lh<16) lh=16;
      if(*p) p++;
      break;




    case 31:
      lw+=8;
      if(*p) p++;
      break;
    default:
      lw+=8;
  }







>
>
>
>







1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
      if(ln<64) li[ln].a=li[ln-1].a;
      break;
    case 16:
      lw+=24;
      if(lh<16) lh=16;
      if(*p) p++;
      break;
    case 30:
      p=strchr(p,'\\')?:"";
      if(*p) p++;
      break;
    case 31:
      lw+=8;
      if(*p) p++;
      break;
    default:
      lw+=8;
  }
1153
1154
1155
1156
1157
1158
1159




1160
1161
1162
1163
1164
1165
1166
      if(ln<64) x=li[ln].a?bx+(tw-li[ln].w)/2:bx;
      break;
    case 16:
      pop_quiz(x,y,li+ln,c,*p);
      if(*p) p++;
      x+=24;
      break;




    case 31:
      pop_char(x,y,li+ln,c,*p);
      if(*p) p++;
      x+=8;
      break;
    default:
      pop_char(x,y,li+ln,c,p[-1]);







>
>
>
>







1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
      if(ln<64) x=li[ln].a?bx+(tw-li[ln].w)/2:bx;
      break;
    case 16:
      pop_quiz(x,y,li+ln,c,*p);
      if(*p) p++;
      x+=24;
      break;
    case 30:
      p=strchr(p,'\\')?:"";
      if(*p) p++;
      break;
    case 31:
      pop_char(x,y,li+ln,c,*p);
      if(*p) p++;
      x+=8;
      break;
    default:
      pop_char(x,y,li+ln,c,p[-1]);