Esempio n. 1
0
void loadconfig(void)
  {
  int count,count2;
  char tempstr[32];

  config.resolutionx=800;
  config.resolutiony=600;
  config.bitsperpixel=32;
  config.depthbits=24;
  config.stencilbits=8;
  config.fullscreen=0;
  config.sound=1;
  config.music=1;
  config.joystick=1;

  option.sound=1;
  option.music=1;
  option.soundvolume=1.0f;
  option.musicvolume=1.0f;

  control[0].key[0]=SCAN_LEFT;
  control[0].key[1]=SCAN_RIGHT;
  control[0].key[2]=SCAN_DOWN;
  control[0].key[3]=SCAN_UP;
  control[0].key[4]=SCAN_A;
  control[0].key[5]=SCAN_SPACE;
  control[0].key[6]=SCAN_S;
  control[0].key[7]=SCAN_D;
  control[0].joysticknum=0;
  control[0].axis[0]=0;
  control[0].axis[1]=1;
  for (count=0;count<4;count++)
    control[0].button[count]=-1;
  for (count=0;count<4;count++)
    control[0].button[count+4]=count;
  control[0].button[8]=5;

  control[1].joysticknum=-1;
  control[1].axis[0]=0;
  control[1].axis[1]=1;
  for (count=0;count<4;count++)
    control[1].button[count]=-1;
  for (count=0;count<4;count++)
    control[1].button[count+4]=count;

  control[2].joysticknum=-1;
  control[2].axis[0]=0;
  control[2].axis[1]=1;
  for (count=0;count<4;count++)
    control[2].button[count]=-1;
  for (count=0;count<4;count++)
    control[2].button[count+4]=count;

  control[3].joysticknum=-1;
  control[3].axis[0]=0;
  control[3].axis[1]=1;
  for (count=0;count<4;count++)
    control[3].button[count]=-1;
  for (count=0;count<4;count++)
    control[3].button[count+4]=count;

  loadtextfile("config.txt");
  optionreadint(&config.resolutionx,"screenwidth=");
  optionreadint(&config.resolutiony,"screenheight=");
  optionreadint(&config.bitsperpixel,"bitsperpixel=");
  optionreadint(&config.depthbits,"depthbits=");
  optionreadint(&config.stencilbits,"stencilbits=");
  optionreadint(&config.fullscreen,"fullscreen=");
  optionreadint(&config.sound,"sound=");
  optionreadint(&config.music,"music=");
  optionreadint(&config.joystick,"joystick=");

  optionreadint(&option.sound,"soundon=");
  optionreadint(&option.music,"musicon=");
  count=-1;
  optionreadint(&count,"soundvolume=");
  if (count!=-1)
    option.soundvolume=(float)count/100.0f;
  count=-1;
  optionreadint(&count,"musicvolume=");
  if (count!=-1)
    option.musicvolume=(float)count/100.0f;

  for (count=0;count<4;count++)
    {
    for (count2=0;count2<16;count2++)
      {
      sprintf(tempstr,"player%dkey%d=",count+1,count2+1);
      optionreadint(&control[count].key[count2],tempstr);
      }

    sprintf(tempstr,"player%djoysticknum=",count+1);
    optionreadint(&control[count].joysticknum,tempstr);

    for (count2=0;count2<4;count2++)
      {
      sprintf(tempstr,"player%daxis%d=",count+1,count2+1);
      optionreadint(&control[count].axis[count2],tempstr);
      }
    for (count2=0;count2<16;count2++)
      {
      sprintf(tempstr,"player%dbutton%d=",count+1,count2+1);
      optionreadint(&control[count].button[count2],tempstr);
      }
    }

  windowinfo.resolutionx=config.resolutionx;
  windowinfo.resolutiony=config.resolutiony;
  windowinfo.bitsperpixel=config.bitsperpixel;
  windowinfo.depthbits=config.depthbits;
  windowinfo.stencilbits=config.stencilbits;
  windowinfo.fullscreen=config.fullscreen;
  }
Esempio n. 2
0
void makeboot(section *s, char *outfile)
{
    int fd;
    void *rawdata[BOOTDIR_MAX_ENTRIES];
    int rawsize[BOOTDIR_MAX_ENTRIES];
    char fill[4096];
    boot_dir bdir;
    int i,c;
    int nextpage = 0; /* page rel offset of next loaded object */
	long outlen = 0;

    memset(fill,0,4096);

    memset(&bdir, 0, sizeof(bdir));
    for(i=0;i<BOOTDIR_MAX_ENTRIES;i++){
        rawdata[i] = NULL;
        rawsize[i] = 0;
    }

    c = 1;

    bdir.bd_entry[0].be_type = fix(BE_TYPE_DIRECTORY);
    bdir.bd_entry[0].be_size = fix(sizeof(bdir)/4096);
    bdir.bd_entry[0].be_vsize = fix(sizeof(bdir));
    rawdata[0] = (void *) &bdir;
    rawsize[0] = sizeof(bdir);
	nextpage += sizeof(bdir)/4096;

    strcpy(bdir.bd_entry[0].be_name,"SBBB/Directory");
	printf("directory size %d\n", rawsize[0]);

    while(s){
        char *type = getvaldef(s,"type","NONE");
        char *file = getval(s,"file");

        if(!type) die("section %s has no type",s->name);

        strncpy(centry.be_name,s->name,BOOTDIR_NAMELEN);
        centry.be_name[BOOTDIR_NAMELEN-1] = 0;

        if(!file) die("section %s has no file",s->name);

        if(!strcmp(type, "elf32") || !strcmp(type, "elf64"))
        	rawdata[c] = loadstripfile(file,&rawsize[c]);
        else if(!strcmp(type, "text"))
        	rawdata[c] = loadtextfile(file,&rawsize[c]);
        else
        	rawdata[c] = loadfile(file,&rawsize[c]);

        if(!rawdata[c])
           die("cannot load \"%s\"",file);

        centry.be_size = rawsize[c] / 4096 + (rawsize[c] % 4096 ? 1 : 0);
		centry.be_vsize = rawsize[c];

        centry.be_offset = nextpage;
        nextpage += centry.be_size;

        centry.be_size = fix(centry.be_size);
        centry.be_vsize = fix(centry.be_vsize);
        centry.be_offset = fix(centry.be_offset);

        if(!strcmp(type,"boot")){
            centry.be_type = fix(BE_TYPE_BOOTSTRAP);
            centry.be_code_vaddr = fix(atoi(getvaldef(s,"vaddr","0")));
            centry.be_code_ventr = fix(atoi(getvaldef(s,"ventry","0")));
        }
        if(!strcmp(type,"code")){
            centry.be_type = fix(BE_TYPE_CODE);
            centry.be_code_vaddr = fix(atoi(getvaldef(s,"vaddr","0")));
            centry.be_code_ventr = fix(atoi(getvaldef(s,"ventry","0")));
        }
        if(!strcmp(type,"data") || !strcmp(type,"text")){
            centry.be_type = fix(BE_TYPE_DATA);
        }
        if(!strcmp(type,"elf32")){
            centry.be_type = fix(BE_TYPE_ELF32);
            centry.be_code_vaddr = 0;
            centry.be_code_ventr = fix(elf32_find_entry(rawdata[c], rawsize[c]));
        }
        if(!strcmp(type,"elf64")){
            centry.be_type = fix(BE_TYPE_ELF64);
            centry.be_code_vaddr = 0;
            centry.be_code_ventr = fix(elf64_find_entry(rawdata[c], rawsize[c]));
        }

        if(centry.be_type == BE_TYPE_NONE){
            die("unrecognized section type \"%s\"",type);
        }

		printf(" %8s %8d %s\n", type, fix(centry.be_vsize), centry.be_name);
		
        c++;
        s = s->next;

        if(c==BOOTDIR_MAX_ENTRIES) die("too many sections (>128)",NULL);
    }

    if((fd = open(outfile, O_BINARY|O_WRONLY|O_CREAT|O_TRUNC, 0666)) < 0) {
        die("cannot write to \"%s\"",outfile);
    }

    if(make_sparcboot) {
        writesparcbootblock(fd, nextpage+1);
    }

    for(i=0;i<c;i++){
        write(fd, rawdata[i], rawsize[i]);
		outlen += rawsize[i];
        if(rawsize[i]%4096) {
            write(fd, fill, 4096 - (rawsize[i]%4096));
			outlen += 4096 - (rawsize[i]%4096);
		}
    }
    close(fd);
	printf("wrote %ld bytes to output file %s\n", outlen, outfile);
}