/[projet1]/public/pc/tools/osdk/main/FloppyBuilder/Floppy.cpp
Defence Force logotype

Diff of /public/pc/tools/osdk/main/FloppyBuilder/Floppy.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1328 by dbug, Fri May 29 18:07:19 2015 UTC revision 1329 by dbug, Sat Oct 24 20:40:51 2015 UTC
# Line 446  bool Floppy::WriteSector(const char *fil Line 446  bool Floppy::WriteSector(const char *fil
446      printf("Boot sector '%s' installed, %u free bytes remaining in this sector.\n",filteredFileName.c_str(),(unsigned int)(256-bufferSize));      printf("Boot sector '%s' installed, %u free bytes remaining in this sector.\n",filteredFileName.c_str(),(unsigned int)(256-bufferSize));
447    
448      MoveToNextSector();      MoveToNextSector();
449        free(buffer);
450    }    }
451    else    else
452    {    {
# Line 648  bool Floppy::WriteFile(const char *fileN Line 649  bool Floppy::WriteFile(const char *fileN
649    
650    m_FileEntries.push_back(fileEntry);    m_FileEntries.push_back(fileEntry);
651    
652      return true;
653    }
654    
655    
656    
657    bool Floppy::ReserveSectors(int sectorCount,int fillValue,const std::map<std::string,std::string>& metadata)
658    {
659      FileEntry fileEntry;
660      fileEntry.m_FloppyNumber=0;     // 0 for a single floppy program
661    
662      if (m_CurrentTrack>41) // face 2
663      {
664        fileEntry.m_StartSide=1;
665      }
666      else
667      {
668        fileEntry.m_StartSide=0;
669      }
670    
671      fileEntry.m_StartTrack =m_CurrentTrack;           // 0 to 42 (80...)
672      fileEntry.m_StartSector=m_CurrentSector;          // 1 to 17 (or 16 or 18...)
673      fileEntry.m_LoadAddress=0;
674      fileEntry.m_StoredFileSize=sectorCount*256;
675      fileEntry.m_FinalFileSize =sectorCount*256;
676      fileEntry.m_SectorCount=sectorCount;
677      fileEntry.m_FilePath   ="Reserved sectors";
678      fileEntry.m_CompressionMode=e_CompressionNone;
679    
680      if (!metadata.empty())
681      {
682        fileEntry.m_Metadata = metadata;
683        m_LastFileWithMetadata=m_FileEntries.size();
684      }
685    
686      for (auto metadataIt(metadata.begin());metadataIt!=metadata.end();++metadataIt)
687      {
688        m_MetadataCategories.insert(metadataIt->first);
689      }
690    
691      //
692      // Finally write the data to the disk structure
693      //
694      while (sectorCount--)
695      {
696        unsigned int offset=SetPosition(m_CurrentTrack,m_CurrentSector);
697    
698        MarkCurrentSectorUsed();
699        memset((char*)m_Buffer+offset,fillValue,256);
700    
701        if (!MoveToNextSector())
702        {
703          ShowError("Floppy disk is full, not enough space to reserve %u more sectors.\n",sectorCount);
704        }
705      }
706    
707      m_FileEntries.push_back(fileEntry);
708    
709    return true;    return true;
710  }  }
711    

Legend:
Removed from v.1328  
changed lines
  Added in v.1329

  ViewVC Help
Powered by ViewVC 1.1.26