Example #1
0
//-------------------------------------------------------------------------
static void thread_state_snapshot(uint8_t index, uint8_t * filename)
{
    MYFILE *fp;
    uint8_t threadsize;
    uint16_t threadramsize;
    uint8_t *internal_ram_start;
    threadsize = sizeof(struct thread);
    threadramsize =
        (uint16_t) ((uint8_t *) thread_table[index].ramend -
                    (uint8_t *) thread_table[index].ramstart + 1);
    internal_ram_start = (uint8_t *) thread_table[index].ramstart;
    fp = fsopen((char *)filename, "w");
    fwrite2(fp, &thread_table[index], threadsize);
    fseek2(fp, threadsize, 1);
    fwrite2(fp, internal_ram_start, threadramsize);
    fclose2(fp);
}
Example #2
0
void savemappack(void)
  {
  int count;
  int version;
  int changeddir;

  changeddir=chdir("level");

  if ((fp=fopen(mappack.filename,"wb"))!=NULL)
    {
    version=1;
    fwrite2(&version,4,1,fp);

    fwrite2(&mappack.numoflevels,4,1,fp);
    fwrite2(mappack.name,1,32,fp);
    for (count=0;count<64;count++)
      {
      fwrite2(mappack.level[count],1,32,fp);
      fwrite2(mappack.levelname[count],1,32,fp);
      fwrite2(mappack.levelmusic[count],1,32,fp);
      }
    for (count=0;count<16;count++)
      fwrite2(mappack.ending[count],1,64,fp);

    fclose(fp);
    }

  if (changeddir==0)
    chdir("..");
  }
Example #3
0
void savescores(void)
  {
  int count,count2;
  int version;
  FILE *fp;
  char path[PATH_MAX];

  if ((fp=fopen(userpath(path,NULL,"gish.his"),"wb"))!=NULL)
    {
    version=2;
    fwrite2(&version,4,1,fp);
    for (count=0;count<32;count++)
    for (count2=0;count2<16;count2++)
      {
      fwrite2(&highscore[count][count2].time,4,1,fp);
      fwrite2(highscore[count][count2].name,1,32,fp);
      }
    fclose(fp);
    }
  }
Example #4
0
void saveplayers(void)
  {
  int count;
  int version;

  if ((fp=fopen("gish.pla","wb"))!=NULL)
    {
    version=3;
    fwrite2(&version,4,1,fp);
    for (count=0;count<8;count++)
      {
      fwrite2(player[count].name,1,32,fp);
      fwrite2(&player[count].levelnum,4,1,fp);
      fwrite2(&player[count].numoflives,4,1,fp);
      fwrite2(&player[count].totalscore,4,1,fp);
      fwrite2(&player[count].difficulty,4,1,fp);
      fwrite2(&player[count].gamepassed,4,1,fp);
      fwrite2(&player[count].highscore,4,1,fp);
      fwrite2(player[count].unlock,4,16,fp);
      }
    fclose(fp);
    }
  }
Example #5
0
//-------------------------------------------------------------------------
void reply_cp_fromPCtoNode_type2(uint8_t * receivebuffer)
{
    uint16_t SyncNum;

    if (receivebuffer[3] == 0xff)
    {
        //now this is a sync
        SyncNum = ((uint16_t) receivebuffer[4]) * 256 + receivebuffer[5];
        if (SyncNum > expectNextNum - 1)
        {
            reply[0] = 7;
            reply[1] = 122;
            reply[2] = nodeid;
            reply[3] = 15;
            reply[4] = 15;
            reply[5] = (expectNextNum - 1) / 256;
            reply[6] = (expectNextNum - 1) % 256;
            StandardSocketSend(0xefef, 0xffff, 32, reply);
        }
        else
        {
            reply[0] = 7;
            reply[1] = 122;
            reply[2] = nodeid;
            reply[3] = 15;
            reply[4] = 15;
            reply[5] = 0;
            reply[6] = 0;
            StandardSocketSend(0xefef, 0xffff, 32, reply);
        }
        return;
    }
    chunksequencenum = ((uint16_t) receivebuffer[4]) * 256 + receivebuffer[5];
    if (chunksequencenum != expectNextNum)
    {
        return;
    }
    fwrite2(openedfile, &receivebuffer[7], receivebuffer[6]);
    fseek2(openedfile, receivebuffer[6], 1);
    expectNextNum++;
    // printStringN(reply,32);      
    //StandardSocketSend(0xefef, 0xffff, 32, reply);
}
Example #6
0
void saveplayermappack(void)
  {
  int count;
  int version;
  int changeddir;
  char filename[32];

  changeddir=chdir("player");

  count=0;
  while (count<24 && mappack.filename[count]!='.')
    {
    filename[count]=mappack.filename[count];
    count++;
    }
  filename[count]=0;

  strcat(filename,".gpp");

  if ((fp=fopen(filename,"wb"))!=NULL)
    {
    version=1;
    fwrite2(&version,4,1,fp);
    for (count=0;count<8;count++)
      {
      fwrite2(&playermappack[count].levelnum,4,1,fp);
      fwrite2(&playermappack[count].numoflives,4,1,fp);
      fwrite2(&playermappack[count].totalscore,4,1,fp);
      fwrite2(&playermappack[count].difficulty,4,1,fp);
      fwrite2(&player[count].highscore,4,1,fp);
      }
    fclose(fp);
    }

  if (changeddir==0)
    chdir("..");
  }