Free Hero Mesh

Diff
Login
This is a mirror of the main repository for Free Hero Mesh. New tickets and changes will not be accepted at this mirror.

Differences From Artifact [9d616d2335]:

To Artifact [e07c9a379a]:


23
24
25
26
27
28
29

30
31
32
33
34
35
36

SDL_Surface*screen;
Uint16 picture_size;
int left_margin;

static SDL_Surface*picts;
static Uint8*curpic;


static const char default_palette[]=
  "C020FF "
  "000000 222222 333333 444444 555555 666666 777777 888888 999999 AAAAAA BBBBBB CCCCCC DDDDDD EEEEEE FFFFFF "
  "281400 412300 5F3200 842100 A05000 C35F14 E1731E FF8232 FF9141 FFA050 FFAF5F FFBE73 FFD282 FFE191 FFF0A0 "
  "321E1E 412220 5F2830 823040 A03A4C BE4658 E15464 FF6670 FF7F7B FF8E7F FF9F7F FFAF7F FFBF7F FFCF7F FFDF7F "
  "280D0D 401515 602020 802A2A A03535 C04040 E04A4A FF5555 FF6764 FF6F64 FF7584 FF849D FF94B7 FF9FD1 FFAEEA "







>







23
24
25
26
27
28
29
30
31
32
33
34
35
36
37

SDL_Surface*screen;
Uint16 picture_size;
int left_margin;

static SDL_Surface*picts;
static Uint8*curpic;
static const unsigned char*fontdata;

static const char default_palette[]=
  "C020FF "
  "000000 222222 333333 444444 555555 666666 777777 888888 999999 AAAAAA BBBBBB CCCCCC DDDDDD EEEEEE FFFFFF "
  "281400 412300 5F3200 842100 A05000 C35F14 E1731E FF8232 FF9141 FFA050 FFAF5F FFBE73 FFD282 FFE191 FFF0A0 "
  "321E1E 412220 5F2830 823040 A03A4C BE4658 E15464 FF6670 FF7F7B FF8E7F FF9F7F FFAF7F FFBF7F FFCF7F FFDF7F "
  "280D0D 401515 602020 802A2A A03535 C04040 E04A4A FF5555 FF6764 FF6F64 FF7584 FF849D FF94B7 FF9FD1 FFAEEA "
749
750
751
752
753
754
755

756
757
758
759
760
761
762
  fprintf(stderr,"Done\n");
}

void init_screen(void) {
  const char*v;
  int w,h,i;
  if(main_options['x']) return;

  optionquery[1]=Q_screenWidth;
  w=strtol(xrm_get_resource(resourcedb,optionquery,optionquery,2)?:"800",0,10);
  optionquery[1]=Q_screenHeight;
  h=strtol(xrm_get_resource(resourcedb,optionquery,optionquery,2)?:"600",0,10);
  optionquery[1]=Q_screenFlags;
  v=xrm_get_resource(resourcedb,optionquery,optionquery,2)?:"";
  if(SDL_Init(SDL_INIT_VIDEO|(strchr(v,'z')?SDL_INIT_NOPARACHUTE:0)|SDL_INIT_TIMER)) fatal("Error initializing SDL: %s\n",SDL_GetError());







>







750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
  fprintf(stderr,"Done\n");
}

void init_screen(void) {
  const char*v;
  int w,h,i;
  if(main_options['x']) return;
  if(!fontdata) fontdata=pcfont;
  optionquery[1]=Q_screenWidth;
  w=strtol(xrm_get_resource(resourcedb,optionquery,optionquery,2)?:"800",0,10);
  optionquery[1]=Q_screenHeight;
  h=strtol(xrm_get_resource(resourcedb,optionquery,optionquery,2)?:"600",0,10);
  optionquery[1]=Q_screenFlags;
  v=xrm_get_resource(resourcedb,optionquery,optionquery,2)?:"";
  if(SDL_Init(SDL_INIT_VIDEO|(strchr(v,'z')?SDL_INIT_NOPARACHUTE:0)|SDL_INIT_TIMER)) fatal("Error initializing SDL: %s\n",SDL_GetError());
782
783
784
785
786
787
788










































































789
790
791
792
793
794
795
  } else {
    SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY,SDL_DEFAULT_REPEAT_INTERVAL);
  }
  SDL_EnableUNICODE(1);
  optionquery[1]=Q_margin;
  left_margin=strtol(xrm_get_resource(resourcedb,optionquery,optionquery,2)?:"65",0,10);
}











































































// Widgets

static void draw_scrollbar(int*cur,int page,int max,int x0,int y0,int x1,int y1) {
  Uint8*pix=screen->pixels;
  Uint16 pitch=screen->pitch;
  int x,y,m0,m1;







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







784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
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
  } else {
    SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY,SDL_DEFAULT_REPEAT_INTERVAL);
  }
  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) {
  int c,i,j,s;
  const char*v;
  unsigned char*d;
  Uint8 b[32];
  FILE*fp;
  if(!n) return;
  if(fontdata && fontdata!=pcfont) fatal("Multiple code page specifications\n");
  optionquery[1]=Q_codepage;
  v=xrm_get_resource(resourcedb,optionquery,optionquery,2);
  if(!v || !*v) {
    if(n==437) return;
    fatal("Cannot load code page %d; code page file is not configured\n",n);
  }
  fp=fopen(v,"r");
  if(!fp) {
    perror(0);
    fatal("Cannot open code page file\n");
  }
  fontdata=d=malloc(0x800);
  if(!d) fatal("Allocation failed\n");
  memcpy(d,pcfont,0x800);
  name:
  s=i=0;
  for(;;) {
    c=fgetc(fp);
    if(c<0) {
      if(n!=437) fatal("Cannot find code page %d\n",n);
      goto done;
    }
    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(s || i!=n) goto skip;
  i=fgetc(fp)<<16;
  i|=fgetc(fp)<<24;
  i|=fgetc(fp)<<0;
  i|=fgetc(fp)<<8;
  if(i==0x800) {
    fread(d,8,256,fp);
    goto done;
  } else if(i==0x400) {
    fread(d+0x400,8,128,fp);
  } else if(i<32 || i>0x800) {
    fatal("Unrecognized format of code page %d\n",n);
  } else {
    fread(b,32,1,fp);
    for(s=0;s<256;s++) if(!(b[s>>3]&(1<<(s&7)))) {
      if(c=fgetc(fp)) {
        i=fgetc(fp);
        if(i&~255) fatal("Error reading data for character %d in code page %d\n",s,n);
        if(i!=s) memcpy(d+s*8,d+i*8,8);
      }
      for(j=0;j<8;j++) if(!(c&(1<<j))) d[j+s*8]=fgetc(fp);
    }
  }
  memset(d,0,8);
  goto done;
  skip:
  i=fgetc(fp)<<16;
  i|=fgetc(fp)<<24;
  i|=fgetc(fp)<<0;
  i|=fgetc(fp)<<8;
  fseek(fp,i,SEEK_CUR);
  goto name;
  done:
  fclose(fp);
}

// Widgets

static void draw_scrollbar(int*cur,int page,int max,int x0,int y0,int x1,int y1) {
  Uint8*pix=screen->pixels;
  Uint16 pitch=screen->pitch;
  int x,y,m0,m1;