public OricProgram LoadFile() { OricProgram oricProgram = new OricProgram(); oricProgram.New(); if (MediaType == ConstantsAndEnums.MediaType.TapeFile) { OricTape oricTape = new OricTape(); oricProgram = oricTape.Load(Path.Combine(Folder, ParentName), ProgramName, ProgramIndex); } else { OricDisk oricDisk = new OricDisk(); oricDisk.LoadDisk(ParentName); switch (oricDisk.DOSFormat()) { case OricDisk.DOSFormats.OricDOS: { OricDos oricDisc = new OricDos(); oricProgram = oricDisc.LoadFile(ParentName, this); } break; case OricDisk.DOSFormats.SedOric: { SedOric oricDisc = new SedOric(); oricProgram = oricDisc.LoadFile(ParentName, this); } break; case OricDisk.DOSFormats.StratSed: { StratSed oricDisc = new StratSed(); oricProgram = oricDisc.LoadFile(ParentName, this); } break; case OricDisk.DOSFormats.TDOS: { FTDos oricDisc = new FTDos(); oricProgram = oricDisc.LoadFile(ParentName, this); } break; default: break; } } return(oricProgram); }
public Byte[] ReadSector(Byte track, Byte sector) { // Load the disk into memory OricDisk oricDisk = new OricDisk(); oricDisk.LoadDisk(fullName); // Read the requested sector Byte[] sectorData = oricDisk.ReadSector(track, sector); // Return the sector data return(sectorData); }
//protected override bool IsInputKey(Keys keyData) //{ // // Make sure we get arrow keys // switch(keyData) // { // case Keys.Up: // case Keys.Left: // case Keys.Down: // case Keys.Right: // return true; // } // // The rest can be determined by the base class // return base.IsInputKey(keyData); //} //protected override void OnKeyUp(KeyEventArgs e) //{ // base.OnKeyDown(e); // //MessageBox.Show("raw key:" + e.KeyCode.ToString(), "debug"); // //MessageBox.Show("Keys.KeyCode:" + Keys.KeyCode.ToString(), "debug"); // //MessageBox.Show("e.KeyCode:" + e.KeyCode.ToString(), "debug"); // switch(Keys.KeyCode & e.KeyCode) // { // case Keys.Up: // if(iScrnRow > 0) // iScrnRow--; // break; // case Keys.Down: // if(iScrnRow < 28) // iScrnRow++; // break; // case Keys.Left: // if(iScrnCol > 0) // iScrnCol--; // break; // case Keys.Right: // if(iScrnCol < 39) // iScrnCol++; // break; // } // NewDrawTextPreview(); // pictureBox1.Image = screenImage; //} public TextScreenEditorForm() { InitializeComponent(); m_ui16DataLength = 0; m_ui16StartAddress = 0; scrnCol = 0; scrnRow = 0; cScrnPaper = 0; cScrnInk = 7; bScrnUpdated = false; // Load the standard character set BuildCharSet(); labelSelectedPaperColour.BackColor = Color.Black; labelSelectedPaperColour.Tag = 0; labelSelectedInkColour.BackColor = Color.White; labelSelectedInkColour.Tag = 7; radioButtonSingle.Checked = true; radioButtonSteady.Checked = true; screenImage = new Bitmap(pictureBoxEditor.Width, pictureBoxEditor.Height); fileInfo = new OricFileInfo(); oricDisk = new OricDisk(); oricTape = new OricTape(); loadedProgram = new OricProgram(); bShowGrid = true; bShowAttrIndicator = true; m_bFlash = true; _ZoomFactor = 2; radioButtonColourMode.Checked = true; editMode = EditingMode.COLOUR_MODE; }
public bool SaveFile(string diskName, string fileName, OricProgram program, OricDisk disk) { bool fileSaved = false; LoadDisk(diskName); // Check if disk has been loaded if (DiskLoaded()) { diskInfo = new OricDiskInfo(diskName); //ArrayList dir<String, OricFileInfo> // Check if file already exists OricFileInfo[] diskDirectory = ReadOricDosDirectory(); int dirIndex = 0; bool fileMatched = false; while (dirIndex < diskDirectory.Length && !fileMatched) { if (diskDirectory[dirIndex].ProgramName.Equals(fileName)) { fileMatched = true; } dirIndex++; } if (!fileMatched) { nextAvailableTrack = diskInfo.nextAvailableTrack; nextAvailableSector = diskInfo.nextAvailableSector; int noOfSectors; if (program.ProgramLength < 245) { noOfSectors = 1; } else { int remaining = program.ProgramLength - 245; noOfSectors = remaining / 253; } sectorsFree = (ushort)(diskInfo.SectorsFree - noOfSectors); sectorsUsed = (ushort)(diskInfo.SectorsUsed + noOfSectors); // Write program data WriteProgramData(program); // Update disk directory AddDirectoryEntry(fileName, (ushort)noOfSectors, (byte)nextAvailableTrack, (byte)nextAvailableSector, program.Protection); // Update System sector (free sectors etc) UpdateSystemSector(); if (WriteDisk()) { MessageBox.Show("Program saved."); } else { MessageBox.Show("Failed to save program"); } } } return(fileSaved); }
public OricDiskInfo(String diskPathName) { fullName = diskPathName; oricDisk = new OricDisk(); oricDisk.LoadDisk(fullName); dosFormat = oricDisk.DOSFormat(); dosVersion = oricDisk.DOSVersion(); switch (dosFormat) { case OricDisk.DOSFormats.OricDOS: { OricDos oricDisc = new OricDos(); oricDisc.GetDiskInfo(fullName); nextAvailableSector = (ushort)oricDisc.nextAvailableSector; nextAvailableTrack = (ushort)oricDisc.nextAvailableTrack; diskName = oricDisc.diskName; diskType = oricDisc.diskType; sectors = oricDisc.sectors; freeSectors = oricDisc.sectorsFree; usedSectors = oricDisc.sectorsUsed; noOfSides = oricDisc.sides; tracksPerSide = oricDisc.tracksPerSide; sectorsPerTrack = oricDisc.sectorsPerTrack; fileCount = oricDisc.fileCount; } break; case OricDisk.DOSFormats.SedOric: { SedOric oricDisc = new SedOric(); oricDisc.GetDiskInfo(fullName); diskName = oricDisc.diskName; diskType = oricDisc.diskType; sectors = oricDisc.sectors; freeSectors = oricDisc.sectorsFree; usedSectors = oricDisc.sectorsUsed; noOfSides = oricDisc.sides; tracksPerSide = oricDisc.tracksPerSide; sectorsPerTrack = oricDisc.sectorsPerTrack; fileCount = oricDisc.noOfFiles; } break; case OricDisk.DOSFormats.StratSed: { SedOric oricDisc = new SedOric(); oricDisc.GetDiskInfo(fullName); diskName = oricDisc.diskName; diskType = oricDisc.diskType; sectors = oricDisc.sectors; freeSectors = oricDisc.sectorsFree; usedSectors = oricDisc.sectorsUsed; noOfSides = oricDisc.sides; tracksPerSide = oricDisc.tracksPerSide; sectorsPerTrack = oricDisc.sectorsPerTrack; fileCount = oricDisc.noOfFiles; } break; case OricDisk.DOSFormats.TDOS: { FTDos oricDisc = new FTDos(); oricDisc.GetDiskInfo(fullName); diskName = oricDisc.diskName; diskType = oricDisc.diskType; sectors = oricDisc.sectors; freeSectors = oricDisc.sectorsFree; usedSectors = oricDisc.sectorsUsed; noOfSides = oricDisc.sides; tracksPerSide = oricDisc.tracksPerSide; sectorsPerTrack = oricDisc.sectorsPerTrack; fileCount = oricDisc.noOfFiles; } break; default: break; } creationTime = File.GetCreationTime(diskPathName); lastAccessTime = File.GetLastAccessTime(diskPathName); lastWriteTime = File.GetLastWriteTime(diskPathName); }
public OricDiskInfo(string diskPathName) { FullName = diskPathName; oricDisk = new OricDisk(); oricDisk.LoadDisk(FullName); DOSFormat = oricDisk.DOSFormat(); DOSVersion = oricDisk.DOSVersion(); switch (DOSFormat) { case OricDisk.DOSFormats.OricDOS: { OricDos oricDisc = new OricDos(); oricDisc.GetDiskInfo(FullName); nextAvailableSector = (ushort)oricDisc.nextAvailableSector; nextAvailableTrack = (ushort)oricDisc.nextAvailableTrack; DiskName = oricDisc.diskName; DiskType = oricDisc.diskType; Sectors = oricDisc.sectors; SectorsFree = oricDisc.sectorsFree; SectorsUsed = oricDisc.sectorsUsed; Sides = oricDisc.sides; TracksPerSide = oricDisc.tracksPerSide; SectorsPerTrack = oricDisc.sectorsPerTrack; FileCount = oricDisc.fileCount; } break; case OricDisk.DOSFormats.SedOric: { SedOric oricDisc = new SedOric(); oricDisc.GetDiskInfo(FullName); DiskName = oricDisc.diskName; DiskType = oricDisc.diskType; Sectors = oricDisc.sectors; SectorsFree = oricDisc.sectorsFree; SectorsUsed = oricDisc.sectorsUsed; Sides = oricDisc.sides; TracksPerSide = oricDisc.tracksPerSide; SectorsPerTrack = oricDisc.sectorsPerTrack; FileCount = oricDisc.noOfFiles; } break; case OricDisk.DOSFormats.StratSed: { SedOric oricDisc = new SedOric(); oricDisc.GetDiskInfo(FullName); DiskName = oricDisc.diskName; DiskType = oricDisc.diskType; Sectors = oricDisc.sectors; SectorsFree = oricDisc.sectorsFree; SectorsUsed = oricDisc.sectorsUsed; Sides = oricDisc.sides; TracksPerSide = oricDisc.tracksPerSide; SectorsPerTrack = oricDisc.sectorsPerTrack; FileCount = oricDisc.noOfFiles; } break; case OricDisk.DOSFormats.TDOS: { FTDos oricDisc = new FTDos(); oricDisc.GetDiskInfo(FullName); DiskName = oricDisc.diskName; DiskType = oricDisc.diskType; Sectors = oricDisc.sectors; SectorsFree = oricDisc.sectorsFree; SectorsUsed = oricDisc.sectorsUsed; Sides = oricDisc.sides; TracksPerSide = oricDisc.tracksPerSide; SectorsPerTrack = oricDisc.sectorsPerTrack; FileCount = oricDisc.noOfFiles; } break; default: break; } if (this.GetFiles() == null) { DOSFormat = OricDisk.DOSFormats.Unknown; } CreationTime = File.GetCreationTime(diskPathName); LastAccessTime = File.GetLastAccessTime(diskPathName); LastWriteTime = File.GetLastWriteTime(diskPathName); }