Index: class.c ================================================================== --- class.c +++ class.c @@ -2553,11 +2553,11 @@ case OP_MISC6: define_user_flags(0x1040,0x105F); break; case OP_MISC7: define_user_flags(0x1060,0x107F); break; case OP_COLLISIONLAYERS: define_user_flags(0x1080,0x1087); break; case OP_CODEPAGE: nxttok(); - if(tokent!=TF_INT || tokenv<1 || tokenv>65535) ParseError("Number from 1 to 65535 expected\n"); + if(tokent!=TF_INT || tokenv<1 || tokenv>0x7FFFFF) ParseError("Number from 1 to 8388607 expected\n"); set_code_page(tokenv); nxttok(); if(tokent!=TF_CLOSE) ParseError("Expected close parenthesis\n"); break; case OP_ORDER: Index: class.doc ================================================================== --- class.doc +++ class.doc @@ -266,11 +266,11 @@ Set the background colour, from 0 to 255. The default value is 1. You can optionally specify a second number, which is the background colour for the inventory; if not specified, uses the same colour for both. (CodePage ) - Define the code page, from 1 to 65535. If not specified, then the + Define the code page, from 1 to 8388607. If not specified, then the default code page is used. (Control ) Define the control class. The format is the same like other class definitions, except that Image and Abstract are not allowed. An Index: codepage.doc ================================================================== --- codepage.doc +++ codepage.doc @@ -1,33 +1,15 @@ === Code page numbers === Code page numbers are assigned according to the following: -* Code page numbers are 16-bit numbers. Numbers 0, 65534, and 65535 are -not used; they are reserved for internal use of the software. (TODO: -Maybe this should be changed to 23-bit code page numbers that I will -maintain a list of. The below will still apply for code page numbers -that fit in 16-bits, though.) - -* Mainly, IBM code page numbers are used. - -* If there is something from Microsoft or FreeDOS that does not already -have a IBM code page number and does not conflict with IBM assignments, -then they may also be used. - -* If a Microsoft code page extends a IBM code page and is otherwise 100% -backward compatible with it, and ahs the same number as the corresponding -IBM code page, then the extensions added by Microsoft will also apply to -that code page (only). - -Note that not all of the code page numbers according to the above are -actually used in Free Hero Mesh; Free Hero Mesh only uses ASCII-based -code pages with 8-bit characters (although the implementation may be -improved in future to allow multibyte code pages, but currently it -doesn't). The full set of code page numbers may still be useful for -other applications, though. +* Code page numbers are 23-bit numbers. Numbers 0, 65534, and 65535 are +not used; they are reserved for internal use of the software. + +* Mainly, IBM code page numbers are used. (Note, these are not all the +same as Microsoft code page numbers.) (Even if multibyte code pages are implemented in future (as well as the possibility of different font sizes than 8x8, and for narrow/wide characters), Shift-JIS is not suitable for Free Hero Mesh, because Free Hero Mesh uses a backslash for string escaping and a multibyte character Index: heromesh.h ================================================================== --- heromesh.h +++ heromesh.h @@ -96,15 +96,16 @@ // == picture == extern SDL_Surface*screen; extern Uint16 picture_size; extern int left_margin; +extern Uint32 codepage; void init_palette(void); void init_screen(void); void load_pictures(void); -void set_code_page(Uint16 n); +void set_code_page(Uint32 n); // Use only when screen is unlocked void draw_picture(int x,int y,Uint16 img); void draw_cell(int x,int y); Index: picture.c ================================================================== --- picture.c +++ picture.c @@ -22,10 +22,11 @@ #include "keyicons.xbm" SDL_Surface*screen; Uint16 picture_size; int left_margin; +Uint32 codepage; static SDL_Surface*picts; static Uint8*curpic; static const unsigned char*fontdata; @@ -815,11 +816,11 @@ SDL_EnableUNICODE(1); optionquery[1]=Q_margin; left_margin=strtol(xrm_get_resource(resourcedb,optionquery,optionquery,2)?:"65",0,10); } -void set_code_page(Uint16 n) { +void set_code_page(Uint32 n) { int c,i,j,s; const char*v; unsigned char*d; Uint8 b[32]; FILE*fp; @@ -851,11 +852,11 @@ if(!c) break; if(!s) { if(c<'0' || c>'9') s=1; else if(c=='0' && !i) s=1; else i=10*i+c-'0'; - if(i>65535) s=1; + if(i>0x7FFFFF) s=1; } } if(s || i!=n) goto skip; i=fgetc(fp)<<16; i|=fgetc(fp)<<24; @@ -887,10 +888,11 @@ i|=fgetc(fp)<<0; i|=fgetc(fp)<<8; fseek(fp,i,SEEK_CUR); goto name; done: + codepage=n; fclose(fp); } // Widgets