Free Hero Mesh

Check-in [b39b71353a]
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 (untested and incomplete) MBCS character substitutions in popups in exec.c.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: b39b71353a408e2870a8ef009ef8a3a845549e94
User & Date: user on 2023-05-09 20:06:46
Other Links: manifest | tags
Context
2023-05-12
06:43
Add WARPED message. check-in: 1ba87a8fa2 user: user tags: trunk
2023-05-09
20:06
Implement (untested and incomplete) MBCS character substitutions in popups in exec.c. check-in: b39b71353a user: user tags: trunk
2023-04-28
18:02
Begin to implement multibyte character codes (it is not enough to be used, so far) check-in: 9087ab7896 user: user tags: trunk
Changes

Modified class.doc from [9c6147b27a] to [bd7b7d4360].

2302
2303
2304
2305
2306
2307
2308





2309
2310
2311
2312
2313
2314
2315
%R
  Display a roman number.

%s
  Display a string. If the value is not a string, it will display it as
  whatever type it is.






%u
  Display a unsigned decimal number.

%x
  Display a unsigned hexadecimal number in lowercase.

%X







>
>
>
>
>







2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
%R
  Display a roman number.

%s
  Display a string. If the value is not a string, it will display it as
  whatever type it is.

%T
  Only valid if this puzzle set uses MBCS. This is like %c but uses all of
  the bits to make a TRON-32 character code. If the code is less than 256
  then this is the same as %c. (This is not fully implemented or tested.)

%u
  Display a unsigned decimal number.

%x
  Display a unsigned hexadecimal number in lowercase.

%X

Modified exec.c from [95d75eb122] to [4959314432].

2096
2097
2098
2099
2100
2101
2102

2103
2104
2105
2106
2107
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
      Throw("Type mismatch");
    }
  }
  return NVALUE(r);
}

static void v_set_popup(Uint32 from,int argc) {

  const unsigned char*t;
  const unsigned char*u;
  sqlite3_str*s;
  Value v;
  int argi=1;
  const unsigned char*at=0;
  int ax;
  Value av;
  if(argc>32 || argc<0) Throw("Too many arguments");
  vstackptr-=argc;
  v=Pop();
  if(quiz_text) return;
  if(argc) {
    argc++;
    if(v.t!=TY_STRING && v.t!=TY_LEVELSTRING) Throw("Type mismatch");
    s=sqlite3_str_new(userdb);
    t=value_string_ptr(v);



    while(*t) {
      if(u=strchr(t,'%')) {
        sqlite3_str_append(s,t,u-t);
        t=u+2;



        switch(u[1]) {
          case 0:
            t=u+1;
            break;
          case 'c':
            if(argi==argc) break;
            v=vstack[vstackptr+argi++];
            if(v.t==TY_NUMBER) {

              sqlite3_str_appendchar(s,1,31);
              sqlite3_str_appendchar(s,1,v.u&255?:255);
            }
            break;
          case 'C':
            if(argi==argc) break;
            v=vstack[vstackptr+argi++];







>

















>
>
>

|


>
>
>








>







2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
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
2140
2141
2142
2143
2144
2145
2146
      Throw("Type mismatch");
    }
  }
  return NVALUE(r);
}

static void v_set_popup(Uint32 from,int argc) {
  unsigned char y='%';
  const unsigned char*t;
  const unsigned char*u;
  sqlite3_str*s;
  Value v;
  int argi=1;
  const unsigned char*at=0;
  int ax;
  Value av;
  if(argc>32 || argc<0) Throw("Too many arguments");
  vstackptr-=argc;
  v=Pop();
  if(quiz_text) return;
  if(argc) {
    argc++;
    if(v.t!=TY_STRING && v.t!=TY_LEVELSTRING) Throw("Type mismatch");
    s=sqlite3_str_new(userdb);
    t=value_string_ptr(v);
#ifndef CONFIG_OMIT_MBCS
    if(has_mbcs && *t==0xFE) y=0x7F;
#endif
    while(*t) {
      if(u=strchr(t,y)) {
        sqlite3_str_append(s,t,u-t);
        t=u+2;
#ifndef CONFIG_OMIT_MBCS
        if(y==0x7F) sqlite3_str_appendchar(s,1,0xFF);
#endif
        switch(u[1]) {
          case 0:
            t=u+1;
            break;
          case 'c':
            if(argi==argc) break;
            v=vstack[vstackptr+argi++];
            if(v.t==TY_NUMBER) {
              ascii:
              sqlite3_str_appendchar(s,1,31);
              sqlite3_str_appendchar(s,1,v.u&255?:255);
            }
            break;
          case 'C':
            if(argi==argc) break;
            v=vstack[vstackptr+argi++];
2183
2184
2185
2186
2187
2188
2189
















2190
2191
2192
2193
2194
2195
2196
                sqlite3_str_appendf(s,"%s",classes[v.u]->name);
                break;
              case TY_MESSAGE:
                sqlite3_str_appendf(s,"%s",v.u<256?standard_message_names[v.u]:messages[v.u-256]);
                break;
            }
            break;
















          case 'u':
            if(argi==argc) break;
            v=vstack[vstackptr+argi++];
            if(v.t==TY_NUMBER) sqlite3_str_appendf(s,"%u",(unsigned int)v.u);
            break;
          case 'x':
            if(argi==argc) break;







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







2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
                sqlite3_str_appendf(s,"%s",classes[v.u]->name);
                break;
              case TY_MESSAGE:
                sqlite3_str_appendf(s,"%s",v.u<256?standard_message_names[v.u]:messages[v.u-256]);
                break;
            }
            break;
#ifndef CONFIG_OMIT_MBCS
          case 'T':
            if(argi==argc) break;
            v=vstack[vstackptr+argi++];
            if(v.t==TY_NUMBER) {
              if(v.u<256) goto ascii;
              if(((v.u>>16)&0xFF)<0x21 || ((v.u>>16)&0xFF)==0x7F || ((v.u>>16)&0xFF)>0xFD) break;
              if(((v.u>>8)&0xFF)<0x21 || ((v.u>>8)&0xFF)==0x7F || ((v.u>>8)&0xFF)>0xFD) break;
              if(((v.u>>0)&0xFF)<0x21 || ((v.u>>0)&0xFF)==0x7F || ((v.u>>0)&0xFF)>0xFD) break;
              sqlite3_str_appendchar(s,((v.u)>>24)+1,0xFE);
              sqlite3_str_appendchar(s,1,v.u>>16);
              sqlite3_str_appendchar(s,1,v.u>>8);
              sqlite3_str_appendchar(s,1,v.u>>0);
            }
            break;
#endif
          case 'u':
            if(argi==argc) break;
            v=vstack[vstackptr+argi++];
            if(v.t==TY_NUMBER) sqlite3_str_appendf(s,"%u",(unsigned int)v.u);
            break;
          case 'x':
            if(argi==argc) break;

Modified internals.doc from [3a19f06428] to [a66f2d8183].

128
129
130
131
132
133
134
135
136
137
138
139
140
141







142
143
144
145
146
147
148
1-8 (\0-\7) = Colours
10 (\n) = Line break
11 (\l) = Left
12 (\c) = Centre
14 (\i) = Icon
15 (\b) = Horizontal rule
16 (\q) = Quiz button
27 (\T) = Multibyte character escape; used only during parsing
30 (\d) = Data
31 (\x) = Next byte is a character to display as graphic

Codes 32-255 are displayed as is, but characters 1-31 cannot be displayed
as a graphic unless a \x escape is present.









=== User state data ===

The user state data for levels in the user cache database can be in the
old format or the new format.

The old format is:







<






>
>
>
>
>
>
>







128
129
130
131
132
133
134

135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
1-8 (\0-\7) = Colours
10 (\n) = Line break
11 (\l) = Left
12 (\c) = Centre
14 (\i) = Icon
15 (\b) = Horizontal rule
16 (\q) = Quiz button

30 (\d) = Data
31 (\x) = Next byte is a character to display as graphic

Codes 32-255 are displayed as is, but characters 1-31 cannot be displayed
as a graphic unless a \x escape is present.

A few additional codes are only used in MBCS mode:

27 (\T) = Multibyte character escape; used only during parsing
127 = Internal representation of %
254 = Plane shift
255 = Switch to ASCII until the next plane shift (internal only)


=== User state data ===

The user state data for levels in the user cache database can be in the
old format or the new format.

The old format is: