Exemplo n.º 1
0
//// UploadKickstart() ////
char UploadKickstart(char *name)
{
  int keysize=0;
  char filename[12];

  strncpy(filename, name, 8); // copy base name
  strcpy(&filename[8], "ROM"); // add extension

  BootPrint("Checking for Amiga Forever key file:");
  if(FileOpen(&file,"ROM     KEY")) {
    keysize=file.size;
    if(file.size<sizeof(romkey)) {
      int c=0;
      while(c<keysize) {
        FileRead(&file, &romkey[c]);
        c+=512;
        FileNextSector(&file);
      }
      BootPrint("Loaded Amiga Forever key file");
    } else {
      BootPrint("Amiga Forever keyfile is too large!");
    }
  }
  BootPrint("Loading file: ");
  BootPrint(filename);

  if (RAOpen(&romfile, filename)) {
    if (romfile.size == 0x100000) {
      // 1MB Kickstart ROM
      BootPrint("Uploading 1MB Kickstart ...");
      SendFileV2(&romfile, NULL, 0, 0xe00000, romfile.size>>10);
      SendFileV2(&romfile, NULL, 0, 0xf80000, romfile.size>>10);
      return(1);
    } else if(romfile.size == 0x80000) {
Exemplo n.º 2
0
//// UploadKickstart() ////
char UploadKickstart(char *name)
{
  int keysize=0;
  char filename[12];

  strncpy(filename, name, 8); // copy base name
  strcpy(&filename[8], "ROM"); // add extension

  BootPrint("Checking for Amiga Forever key file:");
  if(FileOpen(&file,"ROM     KEY")) {
    keysize=file.size;
    if(file.size<sizeof(romkey)) {
      int c=0;
      while(c<keysize) {
        FileRead(&file, &romkey[c]);
        c+=512;
        FileNextSector(&file);
      }
      BootPrint("Loaded Amiga Forever key file");
    } else {
      BootPrint("Amiga Forever keyfile is too large!");
    }
  }
  BootPrint("Loading file: ");
  BootPrint(filename);

  if(minimig_v1()) {
    if (RAOpen(&romfile, filename)) {
      if (romfile.size == 0x80000) {
        // 512KB Kickstart ROM
        BootPrint("Uploading 512 KB Kickstart...");
        PrepareBootUpload(0xF8, 0x08);
        SendFile(&romfile);
        return(1);
      } else if ((romfile.size == 0x8000b) && keysize) {
        // 512KB Kickstart ROM
        BootPrint("Uploading 512 KB Kickstart (Probably Amiga Forever encrypted...)");
        PrepareBootUpload(0xF8, 0x08);
        SendFileEncrypted(&romfile,romkey,keysize);
        return(1);
      } else if (romfile.size == 0x40000) {
        // 256KB Kickstart ROM
        BootPrint("Uploading 256 KB Kickstart...");
        PrepareBootUpload(0xF8, 0x04);
        SendFile(&romfile);
        return(1);
      } else if ((romfile.size == 0x4000b) && keysize) {
        // 256KB Kickstart ROM
        BootPrint("Uploading 256 KB Kickstart (Probably Amiga Forever encrypted...");
        PrepareBootUpload(0xF8, 0x04);
        SendFileEncrypted(&romfile,romkey,keysize);
        return(1);
      } else {
        BootPrint("Unsupported ROM file size!");
      }
    } else {
      siprintf(s, "No \"%s\" file!", filename);
      BootPrint(s);
    }
  } else {
    if (RAOpen(&romfile, filename)) {
      int i,j;
      unsigned int adr, size, base=0x180000, offset=0xc00000, data;
      puts("Uploading 512KB Kickstart ...");
      size = ((romfile.file.size)+511)>>9;
      iprintf("File size: %d.%01dkB\r", romfile.file.size>>10, romfile.file.size&0x3ff);
      iprintf("[");
      for (i=0; i<size; i++) {
        if (!(i&31)) iprintf("*");
        RARead(&romfile,sector_buffer,512);
        EnableOsd();
        adr = 0xf80000 + i*512;
        SPI(OSD_CMD_WR);
        SPIN(); SPIN(); SPIN(); SPIN();
        SPI(adr&0xff); adr = adr>>8;
        SPI(adr&0xff); adr = adr>>8;
        SPIN(); SPIN(); SPIN(); SPIN();
        SPI(adr&0xff); adr = adr>>8;
        SPI(adr&0xff); adr = adr>>8;
        SPIN(); SPIN(); SPIN(); SPIN();
        for (j=0; j<512; j=j+4) {
          SPI(sector_buffer[j+0]);
          SPI(sector_buffer[j+1]);
          SPIN(); SPIN(); SPIN(); SPIN(); SPIN(); SPIN(); SPIN(); SPIN();
          SPI(sector_buffer[j+2]);
          SPI(sector_buffer[j+3]);
          SPIN(); SPIN(); SPIN(); SPIN(); SPIN(); SPIN(); SPIN(); SPIN();
        }
        DisableOsd();
      }
      iprintf("]\r");
      return(1);
    }
  }
Exemplo n.º 3
0
//// ini_parse() ////
void ini_parse(const ini_cfg_t* cfg)
{
  char line[INI_LINE_SIZE] = {0};
  int section = INI_SECTION_INVALID_ID;
  int line_status;

  // open ini file
  #ifdef INI_PARSER_TEST
  if ((ini_fp = fopen(cfg->filename, "rb")) == NULL) { 
  #else
  if (!RAOpen(&ini_file, cfg->filename)) {
  #endif
    ini_parser_debugf("Can't open file %s !", cfg->filename);
    return;
  }

  #ifdef INI_PARSER_TEST
  // save size
  fseek(ini_fp, 0L, SEEK_END);
  ini_size = ftell(ini_fp);
  fseek(ini_fp, 0L, SEEK_SET);
  #endif

  #ifdef INI_PARSER_TEST
  ini_parser_debugf("Opened file %s with size %d bytes.", cfg->filename, ini_size);
  #else
  ini_parser_debugf("Opened file %s with size %d bytes.", cfg->filename, ini_file.file.size);
  #endif

  // preload buffer
  #ifdef INI_PARSER_TEST
  fread(sector_buffer, sizeof(char), INI_BUF_SIZE, ini_fp);
  #else
  RARead(&ini_file, sector_buffer, INI_BUF_SIZE);
  #endif

  // parse ini
  while (1) {
    // get line
    line_status = ini_getline(line);
    // if valid line
    if (line_status != 1) {
      if (line[0] == INI_SECTION_START) {
        // if first char in line is INI_SECTION_START, get section
        section = ini_get_section(cfg, line);
      } else {
        // otherwise this is a variable, get it
        ini_get_var(cfg, section, line);
      }
    }
    // if end of file, stop
    if (line_status == INI_EOT) break;
  }

  #ifdef INI_PARSER_TEST
  // close file
  fclose(ini_fp);
  #endif
}


//// ini_save() ////
void ini_save(const ini_cfg_t* cfg)
{
  int section, var, ini_pt;
  char line[INI_LINE_SIZE] = {0};

  // open ini file
  #ifdef INI_PARSER_TEST
  if ((ini_fp = fopen(cfg->filename, "wb")) == NULL) {
  #else
  { //#error
  #endif
    ini_parser_debugf("Can't open file %s !", cfg->filename);
    return;
  }

  // loop over sections
  for (section=0; section<cfg->nsections; section++) {
    ini_parser_debugf("writing section %s ...", cfg->sections[section].name);
    siprintf(line, "[%s]\n", cfg->sections[section].name);
    ini_pt = ini_putline(line);
    // loop over vars
    for (var=0; var<cfg->nvars; var++) {
      if (cfg->vars[var].section_id == cfg->sections[section].id) {
        ini_parser_debugf("writing var %s", cfg->vars[var].name);
        switch (cfg->vars[var].type) {
          case UINT8:
          case UINT16:
          case UINT32:
            siprintf(line, "%s=%u\n", cfg->vars[var].name, *(uint32_t*)(cfg->vars[var].var));
            break;
          case INT8:
          case INT16:
          case INT32:
            siprintf(line, "%s=%d\n", cfg->vars[var].name, *(int32_t*)(cfg->vars[var].var));
            break;
          #ifdef INI_ENABLE_FLOAT
          case FLOAT:
            siprintf(line, "%s=%f\n", cfg->vars[var].name, *(float*)(cfg->vars[var].var));
            break;
          #endif
          case STRING:
            siprintf(line, "%s=\"%s\"\n", cfg->vars[var].name, (char*)(cfg->vars[var].var));
            break;
        }
        ini_pt = ini_putline(line);
      }
    }
  }

  // in case the buffer is not written yet, write it now
  if (ini_pt) {
    #ifdef INI_PARSER_TEST
    fwrite(sector_buffer, sizeof(char), ini_pt, ini_fp);
    #else
    //#error
    #endif
  }
}