Index: heromesh.h ================================================================== --- heromesh.h +++ heromesh.h @@ -16,5 +16,45 @@ void draw_picture(int x,int y,Uint16 img); void draw_text(int x,int y,const unsigned char*t,int bg,int fg); void load_pictures(void); +// class.c + +#define CF_PLAYER 0x01 +#define CF_INPUT 0x02 +#define CF_COMPATIBLE 0x04 +#define CF_QUIZ 0x08 +#define CF_NOCLASS1 0x40 // if only the name has been loaded so far, from the .class file +#define CF_NOCLASS2 0x80 // if only the name has been loaded so far, from the CLASS.DEF lump + +#define OF_INVISIBLE 0x0001 +#define OF_VISUALONLY 0x0002 +#define OF_STEALTHY 0x0004 +#define OF_BUSY 0x0008 +#define OF_USERSTATE 0x0010 +#define OF_USERSIGNAL 0x0020 +#define OF_MOVED 0x0040 +#define OF_DONE 0x0080 +#define OF_KEYCLEARED 0x0100 +#define OF_DESTROYED 0x0200 + +typedef struct { + const char*name; + const char*edithelp; + const char*gamehelp; + Uint16*codes; + Uint16*messages; // use 0xFFFF if no such message block + Uint16*images; // high bit is set if available to editor + Sint32 height,weight,climb,density,volume,strength,arrivals,departures; + Sint32 temperature,misc4,misc5,misc6,misc7; + Uint16 uservars,oflags; + Uint16 sharp[4]; + Uint16 hard[4]; + Uint8 cflags,shape,shovable; +} Class; + +extern Class*classes[0x4000]; // 0 isn't used +extern const char*messages[0x4000]; +extern int max_animation; +extern Sint32 max_volume; + Index: main.c ================================================================== --- main.c +++ main.c @@ -295,12 +295,9 @@ } load_options(); if(argc>2) read_options(argc-2,argv+2); *optionquery=xrm_make_quark(globalclassname,0)?:xrm_anyq; init_sql(); - - //set_cursor(XC_arrow); - - //atexit(SDL_Quit); + init_screen(); return 0; } DELETED notes Index: notes ================================================================== --- notes +++ notes @@ -1,52 +0,0 @@ -Some notes - - -=== File formats === - -Each puzzle set in Free Hero Mesh is stored as four files: -*.xclass (Hamster archive) - Pictures and user sounds -*.class (Text) - Class definitions (attributes and codes) -*.level (Hamster archive) - Levels -*.solution (Hamster archive) - Solutions to levels - -An idea is to use either Hamster archive or SQLite for the .level and -.solution files. I decided to use Hamster archive, but here are some of -the advantages and disadvantages of each approach: - -Advantages of using Hamster archive: -* It is a simple file format. -* You can use the "har" program to extract and alter lumps. -* There will be less bugs because it is simpler than SQLite. - -Disadvantages of using Hamster archive: -* It is necessary to rewrite the entire file when it changes. -* It is necessary to read the entire file to find the lumps. - -Advantages of using SQLite: -* You can read parts of the file at a time. -* You can alter records without having to rewrite everything. -* SQL can now be used for user queries and user scripts. -* You can use sqlite3 command shell to deal with the file. - -Disadvantages of using SQLite: -* There will be extra overhead due to b-trees and other stuff. -* It may be necessary to deal with untrusted database schemas (unsure). -* Now SQLite must be included in this program. - -Another way would be a hybrid approach. Another file containing the user -session data is a SQLite database, which is recreated if it was deleted or -if the level or solution file is newer than it, and stores an index. - -Advantages of hybrid: -* It is only necessary to create an index once. -* SQL can now be used for user queries and user scripts. -* User session data can be recorded. - -Disadvantages of hybrid: -* SQLite must be included in this program. -* Level/solution files must still be rewritten entirely when it changes. - -Hero Mesh will rewrite the puzzle set file only on exit, so it is possible -to do the similar thing in this case, by using the session database. A way -of incrementally storing and then "vacuuming" the file may also work. - Index: picture.c ================================================================== --- picture.c +++ picture.c @@ -159,37 +159,49 @@ *p++=c; } } static void load_one_picture(FILE*fp,Uint16 img,int alt) { - int i,j,k,pitch,which,meth,size; + int h,i,j,k,pitch,which,meth,size,psize,zoom; Uint8 buf[32]; Uint8*pix; *buf=fgetc(fp); j=*buf&15; fread(buf+1,1,j+(j>>1),fp); k=0; + zoom=1; for(i=1;i<=j;i++) if(buf[i]==picture_size) ++k; + if(k) { + psize=picture_size; + } else { + for(zoom=2;zoom<=picture_size;zoom++) if(!(picture_size%zoom)) { + psize=picture_size/zoom; + for(i=1;i<=j;i++) if(buf[i]==psize) ++k; + if(k) break; + } + } alt%=k; - for(i=1;i<=j;i++) if(buf[i]==picture_size && !alt--) break; + for(i=1;i<=j;i++) if(buf[i]==psize && !alt--) break; which=i; i=1; while(which--) load_one_picture_sub(fp,size=buf[i],meth=(i==1?*buf>>4:buf[(*buf&15)+1+((i-2)>>1)]>>(i&1?4:0))&15),i++; if(meth==5 || meth==6) meth^=3; + if(meth==15) meth=0; SDL_LockSurface(picts); pitch=picts->pitch; pix=picts->pixels+((img&15)+pitch*(img>>4))*picture_size; - if(meth==15) meth=0; for(i=0;i