Foam::DictionaryBase<IDLListType, T>::DictionaryBase(Istream& is)
    :
    IDLListType(is)
{
    addEntries();
}
Beispiel #2
0
uint8_t genMenu()
{
  uint8_t *p;
  uint16_t filecount = 0;

  // shut off TI cart bug
  disableBus();
  
  // open SD card
  rc = pf_mount(&sd_fs);
  if (rc)
    flash_error(1);

  rc = pf_opendir(&sd_dp, "");
  if (rc)
    flash_error(2);

  // add menu and browser code
  writeMenuCode();
  
  while (images_written < MAX_ENTRIES) {
    // get next item in directory
    rc = pf_readdir(&sd_dp, &sd_fno);
    if (rc)
      flash_error(3);
    if (sd_fno.fname[0] == 0)  // end of dir
      break;
    ++filecount;
    if (sd_fno.fattrib & AM_DIR)
      continue;  // skip directories

    // check if file ends in ".BIN"
    p = (uint8_t *)sd_fno.fname;
    while (*++p);
    if (p - (uint8_t *)sd_fno.fname < 5 ||
	*--p != 'N' || *--p != 'I' || *--p != 'B' || *--p != '.')
      continue;
    --p;  // p at last char of filename w/o extension

    // check image size
    if (sd_fno.fsize > 32768)
      continue;

#ifdef MULTI_FILE
    // check for multi-file image
    // - if file ends in C -> check how many banks
    // - if file ends in D, E, F -> check if C exists, then ignore
    uint8_t c;
    if (sd_fno.fsize == 8192 && *p == 'C') {
      for (c = 'D'; c <= 'F'; ++c) {
        *p = c;
        rc = pf_open(sd_fno.fname);
        if (rc)
          break;
      }
      *p = 'C';
    } else if (sd_fno.fsize == 8192 && (*p == 'D' || *p == 'E' || *p == 'F')) {
      c = *p;
      *p = 'C';
      rc = pf_open(sd_fno.fname);
      if (!rc)
        continue;  // current file covered by C file
      *p = c;  // actually not a multi-file image
    }
#endif

    // create entry
    if (addEntries(sd_fno.fname))
      ++files_written;
  }

  // if only one image found, load file directly
  if (files_written == 1)
    return 1;

  // close menu and browser items
  closeEntries();

  // bring cartridge online
  enableBus();

  return 0;
}