private void displayImageInfo(OricProgram oricProgram)
        {
            labelImageCount.Text = String.Format("{0} of {1}", imageIndex + 1, imageList.Count());

            Text = String.Format("Image Viewer - {0}", oricProgram.ProgramName);

            labelFilename.Text = oricProgram.ProgramName;

            if (oricProgram.Format == OricProgram.ProgramFormat.HiresScreen)
            {
                labelFormat.Text = "HIRES Screen";
            }
            else if (oricProgram.Format == OricProgram.ProgramFormat.TextScreen)
            {
                labelFormat.Text = "TEXT Screen";
            }
            else if (oricProgram.Format == OricProgram.ProgramFormat.HelpFile)
            {
                labelFormat.Text = "TEXT Screen";
            }
            else
            {
                labelFormat.Text = "Unknown";
            }

            labelStartAddress.Text = String.Format("{0}", oricProgram.StartAddress);
            labelEndAddress.Text   = String.Format("{0}", oricProgram.EndAddress);

            labelStartAddressHex.Text = String.Format("${0:X4}", oricProgram.StartAddress);
            labelEndAddressHex.Text   = String.Format("${0:X4}", oricProgram.EndAddress);

            labelLength.Text = String.Format("{0:N0} bytes ({1:N1} KB)", oricProgram.ProgramLength, (float)oricProgram.ProgramLength / 1024);

            labelRowCount.Text = String.Format("{0:N0} Rows", (float)(oricProgram.ProgramLength / 40));
        }
        public ImportTextFileForm()
        {
            InitializeComponent();

            program = new OricProgram();
            program.New();

            basicTokens = new BasicTokens(BasicTokens.ROMVersion.V1_1);
        }
        public ScreenViewerForm()
        {
            InitializeComponent();

            oricScreenImage = new ScreenImage();

            oricFileInfo = new OricFileInfo();
            oricProgram  = new OricProgram();
        }
        public SequentialFileViewer()
        {
            InitializeComponent();
            Dock = DockStyle.Fill;

            FileInformation = new Label();
            ProgramInfo     = new OricFileInfo();
            ProgramData     = new OricProgram();
        }
        public ctlDataFileViewer()
        {
            InitializeComponent();

            this.Dock = DockStyle.Fill;

            FileInformation = new Label();
            ProgramInfo     = new OricFileInfo();
            ProgramData     = new OricProgram();
            ProgramData.New();
        }
Beispiel #6
0
        public frmDataViewer(OricFileInfo fileInfo, OricProgram programData)
        {
            InitializeComponent();

            dataViewerControl             = new ctlDataViewerControl();
            dataViewerControl.ProgramInfo = fileInfo;
            dataViewerControl.ProgramData = programData;
            dataViewerControl.InitialiseView();

            this.Controls.Add(dataViewerControl);
            this.Size = new Size(dataViewerControl.Width + 15, dataViewerControl.Height + 40);

            this.Text = string.Format("Data Viewer - {0} ({1})", fileInfo.ProgramName, Path.GetFileName(fileInfo.ParentName));
        }
        private void displayImage(int imageIndex)
        {
            OricFileInfo fileInfo    = (OricFileInfo)imageList[imageIndex];
            OricProgram  oricProgram = fileInfo.LoadFile();

            oricScreenImage.m_ui16StartAddress = oricProgram.StartAddress;
            oricScreenImage.m_ui16DataLength   = oricProgram.ProgramLength;
            oricScreenImage.bScrnData          = oricProgram.m_programData;
            oricScreenImage.m_bFlash           = !oricScreenImage.m_bFlash;

            if (oricProgram.Format == OricProgram.ProgramFormat.HiresScreen)
            {
                screenImageFormat = ScreenImage.ScreenImageFormat.IMAGE_FORMAT_HIRES;
            }
            else
            {
                screenImageFormat = ScreenImage.ScreenImageFormat.IMAGE_FORMAT_TEXT;
            }

            oricScreenImage.DrawScreenImage(ScreenImage.ScreenImageSize.IMAGE_SIZE_ENLARGED, screenImageFormat);
            pictureBoxScreenImage.Image = oricScreenImage.screenImageData;

            displayImageInfo(fileInfo);

            if (!slideshowRunning)
            {
                // Display thumbnail of current image
                foreach (Control control in flowLayoutPanelThumbnails.Controls)
                {
                    if (control is Panel)
                    {
                        Panel panel = (Panel)control;
                        panel.BackColor = Color.FromArgb(200, 200, 200);
                    }
                }

                Control[] imagePanel = flowLayoutPanelThumbnails.Controls.Find(string.Format("panel_{0}", imageIndex), true);

                if (imagePanel.Count() == 1)
                {
                    Panel panel = (Panel)imagePanel[0];
                    panel.BackColor = Color.FromArgb(150, 150, 150);
                    panel.Focus();
                }
            }

            enableDisableControls();
        }
        private void displayImage(int imageIndex)
        {
            OricProgram oricProgram = imageList[imageIndex].LoadFile();

            oricScreenImage.m_ui16StartAddress = oricProgram.StartAddress;
            oricScreenImage.m_ui16DataLength   = oricProgram.ProgramLength;
            oricScreenImage.bScrnData          = oricProgram.m_programData;

            if (oricProgram.Format == OricProgram.ProgramFormat.HiresScreen)
            {
                screenImageFormat = ScreenImage.ScreenImageFormat.IMAGE_FORMAT_HIRES;
            }
            else if (oricProgram.Format == OricProgram.ProgramFormat.TextScreen || oricProgram.Format == OricProgram.ProgramFormat.HelpFile)
            {
                screenImageFormat = ScreenImage.ScreenImageFormat.IMAGE_FORMAT_TEXT;
            }

            oricScreenImage.DrawScreenImage(ScreenImage.ScreenImageSize.IMAGE_SIZE_ENLARGED, screenImageFormat);
            pictureBoxScreenImage.Image = oricScreenImage.screenImageData;

            displayImageInfo(oricProgram);

            enableDisableControls();
        }
        private void generateThumbnails()
        {
            // Remove any images
            flowLayoutPanelThumbnails.Controls.Clear();

            for (int imageIndex = 0; imageIndex < imageList.Count(); imageIndex++)
            {
                Panel imagePanel = new Panel();
                imagePanel.Name        = string.Format("panel_{0}", imageIndex);
                imagePanel.Size        = new Size(170, 175);
                imagePanel.BorderStyle = BorderStyle.FixedSingle;
                imagePanel.BackColor   = Color.FromArgb(200, 200, 200);

                Label imageLabel = new Label();
                imageLabel.Name      = string.Format("label_{0}", imageIndex);
                imageLabel.Size      = new Size(160, 18);
                imageLabel.Font      = new Font("Segoe UI", 8);
                imageLabel.TextAlign = ContentAlignment.MiddleCenter;
                imageLabel.Text      = imageList[imageIndex].ProgramName;
                imageLabel.Left      = 5;
                imageLabel.Top       = 154;

                PictureBox screenImage = new PictureBox();

                screenImage.Name        = string.Format("{0}", imageIndex);
                screenImage.Size        = new Size(160, 150);
                screenImage.BackColor   = Color.White;
                screenImage.BorderStyle = BorderStyle.None;
                screenImage.SizeMode    = PictureBoxSizeMode.Zoom;
                screenImage.Cursor      = System.Windows.Forms.Cursors.Hand;
                screenImage.Top         = 5;
                screenImage.Left        = 5;

                toolTip1 = new ToolTip();
                toolTip1.ToolTipTitle = "Image Information";
                toolTip1.SetToolTip(screenImage, string.Format("Name : {0}\nFormat : {1}", imageList[imageIndex].ProgramName, imageList[imageIndex].FormatToString()));
                toolTip1.Popup += toolTip1_Popup;

                screenImage.Click += new System.EventHandler(screenImage_Click);

                OricProgram oricProgram = imageList[imageIndex].LoadFile();

                ScreenImage thumbnailImage = new ScreenImage();
                thumbnailImage.m_ui16StartAddress = oricProgram.StartAddress;
                thumbnailImage.m_ui16DataLength   = oricProgram.ProgramLength;
                thumbnailImage.bScrnData          = oricProgram.m_programData;

                if (oricProgram.Format == OricProgram.ProgramFormat.HiresScreen)
                {
                    screenImageFormat = ScreenImage.ScreenImageFormat.IMAGE_FORMAT_HIRES;
                }
                else
                {
                    screenImageFormat = ScreenImage.ScreenImageFormat.IMAGE_FORMAT_TEXT;
                }

                thumbnailImage.DrawScreenImage(ScreenImage.ScreenImageSize.IMAGE_SIZE_NORMAL, screenImageFormat);

                screenImage.Image = thumbnailImage.screenImageData;

                imagePanel.Controls.Add(screenImage);
                imagePanel.Controls.Add(imageLabel);

                flowLayoutPanelThumbnails.Controls.Add(imagePanel);
            }
        }
Beispiel #10
0
        private void btnImport_Click(object sender, EventArgs e)
        {
            OricProgram program = new OricProgram();

            if (txtProgramName.TextLength == 0)
            {
                program.ProgramName = "NoName";
            }
            else if (txtProgramName.TextLength > 16)
            {
                program.ProgramName = txtProgramName.Text.Substring(0, 16);
            }
            else
            {
                program.ProgramName = txtProgramName.Text;
            }

            program.Format  = OricProgram.ProgramFormat.BasicProgram;
            program.AutoRun = (chkAutoRun.Checked ? OricProgram.AutoRunFlag.Enabled : OricProgram.AutoRunFlag.Disabled);

            txtStartAddress.Text = txtStartAddress.Text.Replace("$", "0x");
            program.StartAddress = Convert.ToUInt16(txtStartAddress.Text, 16);

            // Load text file
            string[] sourceCode = File.ReadAllLines(txtFileToImport.Text);

            if (!ConvertTextToBASIC(sourceCode, ref program))
            {
                MessageBox.Show("Error converting file. It is not an Atmos BASIC file.", "Import Atmos BASIC File", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else
            {
                try
                {
                    // initialize the tape
                    OricTape oricTape = new OricTape();
                    oricTape.TapeName = txtDestinationFile.Text;

                    if (optNewTape.Checked)
                    {
                        // add the program and save file
                        oricTape.SaveFile(program);
                    }
                    else
                    {
                        // read the actual tape catalog
                        FileInfo       fileInfo    = new FileInfo(txtDestinationFile.Text);
                        OricFileInfo[] tapeCatalog = oricTape.Catalog(fileInfo);

                        // read the programs already on the tape
                        ArrayList programList = new ArrayList();
                        for (int i = 0; i < tapeCatalog.Length; i++)
                        {
                            programList.Add(oricTape.Load(oricTape.TapeName, "", (ushort)i));
                        }

                        // add the new program to the liste
                        programList.Add(program);

                        // write the program list
                        oricTape.WriteFiles(programList, FileMode.Create);
                    }

                    // file converted successfully
                    MessageBox.Show("Atmos BASIC file converted successfully", "Import Atmos BASIC File", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    Close();
                }
                catch (Exception ex)
                {
                    MessageBox.Show($"Error saving tape file.\r\n\r\n{ex.Message}", "Import Atmos BASIC File", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
Beispiel #11
0
        private bool ConvertTextToBASIC(string[] textBuffer, ref OricProgram program)
        {
            try
            {
                bool bREM    = false;
                bool bDATA   = false;
                bool bString = false;

                ushort ui16CurrentAddress = program.StartAddress;

                int iProgramIdx = 0;
                int iBufferIdx  = 0;
                int iAddressIdx = 0;

                // Initialise the program buffer
                program.ProgramData = new byte[0xFFFF];
                program.ProgramData.Initialize();

                for (int iLoop = 0; iLoop < textBuffer.Length; iLoop++)
                {
                    if (textBuffer[iLoop].Length > 0)
                    {
                        bREM    = false;
                        bDATA   = false;
                        bString = false;

                        // Find first character
                        iBufferIdx = 0;
                        iBufferIdx = FindNextNonSpaceChar(textBuffer[iLoop], iBufferIdx);

                        string lineno = "";

                        // Get line no.
                        while (char.IsNumber(GetNextChar(textBuffer[iLoop], iBufferIdx)))
                        {
                            lineno += textBuffer[iLoop].Substring(iBufferIdx, 1);

                            iBufferIdx++;
                        }

                        ushort ui16LineNo = Convert.ToUInt16(lineno, 10);

                        if (ui16LineNo < 0 || ui16LineNo > 0xFFFF)
                        {
                            MessageBox.Show("Invalid line no. specified.", "Import Atmos BASIC File", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            return(false);
                        }

                        iAddressIdx = iProgramIdx;

                        program.ProgramData[iProgramIdx] = 0xFF;
                        iProgramIdx++;

                        program.ProgramData[iProgramIdx] = 0xFE;
                        iProgramIdx++;

                        program.ProgramData[iProgramIdx] = (byte)(ui16LineNo & 0xFF);

                        iProgramIdx++;

                        program.ProgramData[iProgramIdx] = (byte)(ui16LineNo >> 8);

                        iProgramIdx++;

                        iBufferIdx = FindNextNonSpaceChar(textBuffer[iLoop], iBufferIdx);

                        bool bEndOfLine = false;

                        while (!bEndOfLine)
                        {
                            if (bREM)
                            {
                                program.ProgramData[iProgramIdx] = Convert.ToByte(textBuffer[iLoop][iBufferIdx]);
                                iBufferIdx++;
                            }
                            else if (bString)
                            {
                                if (textBuffer[iLoop][iBufferIdx] == '"')
                                {
                                    bString = false;
                                }

                                program.ProgramData[iProgramIdx] = Convert.ToByte(textBuffer[iLoop][iBufferIdx]);
                                iBufferIdx++;
                            }
                            else if (bDATA)
                            {
                                if (textBuffer[iLoop][iBufferIdx] == ':')
                                {
                                    bDATA = false;
                                }

                                program.ProgramData[iProgramIdx] = Convert.ToByte(textBuffer[iLoop][iBufferIdx]);
                                iBufferIdx++;
                            }
                            else
                            {
                                int iToken = MatchKeyword(textBuffer[iLoop], iBufferIdx);

                                if (iToken == 0x9D) // || textBuffer[iLoop][iBufferIdx] == '\'')
                                {
                                    bREM = true;
                                }

                                if (iToken == 0x91)
                                {
                                    bDATA = true;
                                }

                                if (textBuffer[iLoop][iBufferIdx] == '"')
                                {
                                    bString = true;
                                }

                                if (iToken == 0)
                                {
                                    program.ProgramData[iProgramIdx] = Convert.ToByte(textBuffer[iLoop][iBufferIdx]);
                                    iBufferIdx++;
                                }
                                else
                                {
                                    program.ProgramData[iProgramIdx] = Convert.ToByte(iToken);

                                    string token = basicTokens.GetBasicToken((byte)(iToken - 0x80));
                                    iBufferIdx += token.Length;
                                }
                            }

                            ui16CurrentAddress++;

                            iProgramIdx++;

                            if (iBufferIdx >= textBuffer[iLoop].Length)
                            {
                                ui16CurrentAddress += 5;

                                program.ProgramData[iAddressIdx] = (byte)(ui16CurrentAddress & 0xFF);
                                iAddressIdx++;

                                program.ProgramData[iAddressIdx] = (byte)(ui16CurrentAddress >> 8);

                                program.ProgramData[iProgramIdx] = 0x00;
                                iProgramIdx++;

                                bEndOfLine = true;
                            }
                        }
                    }
                }

                program.ProgramData[iProgramIdx] = 0x00;
                iProgramIdx++;
                program.ProgramData[iProgramIdx] = 0x00;
                program.EndAddress = (ushort)(program.StartAddress + iProgramIdx);

                return(true);
            }
            catch (Exception)
            {
                return(false);
            }
        }
Beispiel #12
0
        private void lvDirectory_MouseClick(object sender, MouseEventArgs e)
        {
            int iSelectedCount = lvDirectory.SelectedItems.Count;

            if (iSelectedCount > 0)
            {
                ListViewItem lvSelected = lvDirectory.SelectedItems[0];

                int iIndex = Convert.ToInt16(lvSelected.Tag);

                bSelectedIndex = Convert.ToByte(iIndex);
                bSelectedIndex++;

                OricProgram programInfo = (OricProgram)diskDirectory[iIndex];

                //Byte bTrack = programInfo.FirstTrack;
                //Byte bSector = programInfo.FirstSector;
                Byte bTrack  = 0x01;
                Byte bSector = 0x01;

                if ((bTrack & 0x80) == 0x80)
                {
                    // Track is on Side 1
                    if (tabSides.SelectedIndex != 1)
                    {
                        tabSides.SelectedIndex = 1;
                    }
                }
                else
                {
                    // Track is on Side 0
                    if (tabSides.SelectedIndex != 0)
                    {
                        tabSides.SelectedIndex = 0;
                    }
                }

                // Redraw the Sector maps
                DrawSectorMap(0);
                pbSectorMapSide0.Image = imageSectorMap0;

                // Only redraw Side 2 if double sided disk
                if (diskInfo.Sides == 2)
                {
                    DrawSectorMap(1);
                    pbSectorMapSide1.Image = imageSectorMap1;
                }

                int iMapIndex = 0;

                if ((bTrack & 0x80) == 0x80)
                {
                    bTrack    = (Byte)(bTrack & 0x7F);
                    iMapIndex = ((bTrack + diskInfo.Tracks) * diskInfo.Sectors) + bSector;
                }
                else
                {
                    iMapIndex = (bTrack * diskInfo.Sectors) + bSector;
                }

                currentTrack  = bTrack;
                currentSector = bSector;
                UpdateDisplay();
            }
        }