コード例 #1
0
        private void AddSIDIHelper(SIDICollection m_collection, string shortdescr, string symbol, string info, int address)
        {
            SIDIHelper h = new SIDIHelper();

            //h.Value = value;
            h.Symbol      = shortdescr;
            h.T7Symbol    = symbol;
            h.Info        = info;
            h.AddressSRAM = address;
            m_collection.Add(h);
        }
コード例 #2
0
ファイル: frmMain.cs プロジェクト: mattiasclaesson/T7Suite
        private static SIDICollection GetSidCollectionFromBinary(string m_currentfile)
        {
            SIDICollection m_sidcollection = new SIDICollection();
            FileStream stream = new FileStream(m_currentfile, FileMode.Open, FileAccess.Read);
            stream.Position = 0L;
            long num2 = 0L;
            bool flag = false;
            byte[] buffer = new byte[] { 0x41, 100, 0x70, 0x4e, 0, 0, 0 };
            do
            {
                if (((byte)stream.ReadByte()) == buffer[0])
                {
                    long position = stream.Position;
                    if (((byte)stream.ReadByte()) == buffer[1])
                    {
                        if ((((((byte)stream.ReadByte()) == buffer[2]) && (((byte)stream.ReadByte()) == buffer[3])) && ((((byte)stream.ReadByte()) == buffer[4]) && (((byte)stream.ReadByte()) == buffer[5]))) && (((byte)stream.ReadByte()) == buffer[6]))
                        {
                            flag = true;
                            num2 = stream.Position - 7L;
                        }
                    }
                    else
                    {
                        stream.Position = position;
                    }
                }
            }
            while (!flag && (stream.Position != 0x80000));
            if (!flag)
            {
                frmInfoBox info = new frmInfoBox("This T7 file is not compatible with the SIDI function in T7Suite!");
                return m_sidcollection;
            }
            stream.Position -= 7L;

            long start_pos = stream.Position;
            byte[] bytes = new byte[12];
            uint num4 = 0x53;           //?? fixed length?
            //int num5 = 0;
            for (int i = 0; i <= num4; i++)
            {
                //logger.Debug("*****" + i.ToString());
                /*if (i == 65)
                {
                    logger.Debug("65");
                }*/
                for (int j = 0; j <= 3; j++)
                {
                    bytes[j] = (byte)stream.ReadByte();
                }
                // set text
                SIDIHelper sidihelper = new SIDIHelper();
                sidihelper.Symbol = Encoding.Default.GetString(bytes, 0, 4);
                sidihelper.Symbol = sidihelper.Symbol.Replace((char)0x00, (char)0x20);
                //logger.Debug(i.ToString() + " = " + Encoding.Default.GetString(bytes, 0, 4));
                stream.Position += 3L;
                for (int k = 0; k <= 2; k++)
                {
                    bytes[k] = (byte)stream.ReadByte();
                }
                sidihelper.AddressSRAM = Convert.ToInt32(BitConverter.ToString(bytes, 0, 3).Replace("-", ""), 16);
                for (int m = 0; m <= 0; m++)
                {
                    bytes[m] = (byte)stream.ReadByte();
                }
                sidihelper.Value = BitConverter.ToString(bytes, 0, 1).Replace("-", "");
                m_sidcollection.Add(sidihelper);
                stream.Position += 1L; // skip one
            }
            if (stream != null)
            {
                stream.Close();
            }
            return m_sidcollection;
        }
コード例 #3
0
ファイル: frmMain.cs プロジェクト: mattiasclaesson/T7Suite
        /// <summary>
        /// TODO: make this work with manually added symbol (user description in stead of varname
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Actions_SIDInformation_ItemClick(object sender, ItemClickEventArgs e)
        {
            // show SID information table from this bin and give the user the option to alter the settings from this table
            SIDInformationTable sidinfotab = new SIDInformationTable();
            SIDICollection entiresidcollection = sidinfotab.GetSIDInformation();
            SIDICollection currentsidcollection = new SIDICollection();
            SIDTranslator sidtrans = new SIDTranslator();

            // so, now get the current settings from the binary
            T7SidEdit t7SidEdit = new T7SidEdit();
            if (!t7SidEdit.init(m_currentfile))
            {
                frmInfoBox info = new frmInfoBox("File not compatible!");
            }
            else
            {
                bool first = true;
                for (int i = 0; i < t7SidEdit.getDataArrayAll().Length; i += 3)
                {
                    if (i + 2 < t7SidEdit.getDataArrayAll().Length)
                    {
                        SIDIHelper sidh = new SIDIHelper();
                        sidh.Symbol = t7SidEdit.getDataArrayAll()[i];
                        sidh.Symbol = sidh.Symbol.Replace((char)0x00, (char)0x20);
                        sidh.AddressSRAM = Convert.ToInt32(t7SidEdit.getDataArrayAll()[i + 1], 16);
                        //if (sidh.AddressSRAM < 0xF00000) sidh.AddressSRAM += 0xef02f0;
                        sidh.Value = t7SidEdit.getDataArrayAll()[i + 2];
                        sidh.IsReadOnly = first;
                        first = false;
                        sidh.Mode = 99;
                        sidtrans.GetSidDescription(sidh);
                        foreach (SymbolHelper sh in m_symbols)
                        {
                            // try to match it to a symbol in the binary file
                            if (sh.Flash_start_address == sidh.AddressSRAM)
                            {

                                sidh.FoundT7Symbol = sh.Varname;
                                if (sidh.FoundT7Symbol.StartsWith("Symbolnumber") && sh.Userdescription != "")
                                {
                                    // <GS-12102010>
                                    sidh.FoundT7Symbol = sh.Userdescription;
                                }
                                break;
                            }
                        }

                        currentsidcollection.Add(sidh);
                    }
                    //logger.Debug("ALL: " + t7SidEdit.getDataArrayAll()[i]);
                }
                if (t7SidEdit.getFileType() == 1)
                {
                    int mode = 0;
                    int modcount = 0;
                    first = true;
                    for (int j = 0; j < t7SidEdit.getDataArrayNew().Length; j += 3)
                    {
                        if (j + 2 < t7SidEdit.getDataArrayNew().Length)
                        {
                            SIDIHelper sidh = new SIDIHelper();
                            sidh.Symbol = t7SidEdit.getDataArrayNew()[j];
                            sidh.Symbol = sidh.Symbol.Replace((char)0x00, (char)0x20);
                            sidh.AddressSRAM = Convert.ToInt32(t7SidEdit.getDataArrayNew()[j + 1], 16);
                            //if (sidh.AddressSRAM < 0xF00000) sidh.AddressSRAM += 0xef02f0;
                            sidh.Value = t7SidEdit.getDataArrayNew()[j + 2];
                            sidh.IsReadOnly = first;
                            first = false;
                            sidtrans.GetSidDescription(sidh);
                            foreach (SymbolHelper sh in m_symbols)
                            {
                                // try to match it to a symbol in the binary file
                                if (sh.Flash_start_address == sidh.AddressSRAM)
                                {
                                    sidh.FoundT7Symbol = sh.Varname;
                                    if (sidh.FoundT7Symbol.StartsWith("Symbolnumber") && sh.Userdescription != "")
                                    {
                                        // <GS-12102010>
                                        sidh.FoundT7Symbol = sh.Userdescription;
                                    }
                                    break;
                                }
                            }

                            sidh.Mode = mode;//Convert.ToInt32(sh.Value);
                            modcount++;
                            if ((modcount % 12) == 0) mode++;
                            currentsidcollection.Add(sidh);
                        }
                        //logger.Debug("NEW: " + t7SidEdit.getDataArrayNew()[j]);
                    }
                }
                frmSIDInformation frmsid = new frmSIDInformation();
                frmsid.ApplicationLanguage = m_appSettings.ApplicationLanguage;
                frmsid.ShowAddressesInHex = m_appSettings.ShowAddressesInHex;

                frmsid.Sidcollection = currentsidcollection;
                frmsid.Entiresidcollection = entiresidcollection;
                frmsid.Symbols = m_symbols;
                if (frmsid.ShowDialog() == DialogResult.OK)
                {
                    string[] outputarray = new string[frmsid.Get99ModeCount() * 3];
                    int cnt = 0;
                    foreach (SIDIHelper sh in frmsid.Sidcollection)
                    {
                        if (sh.Mode == 99)
                        {
                            outputarray.SetValue(sh.Symbol, cnt++);
                            outputarray.SetValue(sh.AddressSRAM.ToString("X6"), cnt++);
                            outputarray.SetValue(sh.Value.ToString(), cnt++);
                        }
                    }
                    t7SidEdit.setDataArrayAll(outputarray);
                    if (t7SidEdit.getFileType() == 1)
                    {
                        outputarray = new string[frmsid.GetNewModeCount() * 3];
                        cnt = 0;
                        foreach (SIDIHelper sh in frmsid.Sidcollection)
                        {
                            if (sh.Mode != 99)
                            {
                                outputarray.SetValue(sh.Symbol, cnt++);
                                outputarray.SetValue(sh.AddressSRAM.ToString("X6"), cnt++);
                                outputarray.SetValue(sh.Value.ToString(), cnt++);
                            }
                        }
                        t7SidEdit.setDataArrayNew(outputarray);
                    }
                    t7SidEdit.saveFile();
                    UpdateChecksum(m_currentfile);
                    //SaveSidCollectionToBinary(m_currentfile, frmsid.Sidcollection);
                }
            }

            /*
                        SIDICollection currentsidcollection = GetSidCollectionFromBinary(m_currentfile);
                        //logger.Debug("Fetched: " + currentsidcollection.Count.ToString() + " SIDI symbols");
                        int mode = 0;
                        int modcount = 0;

                        foreach (SIDIHelper sh in currentsidcollection)
                        {
                            //logger.Debug("Found: " + sh.Symbol + " at " + sh.AddressSRAM.ToString("X6") + " type " + sh.Value);
                            //Console.Write(Environment.NewLine);
                            for (int t = 0; t < sh.Symbol.Length; t++)
                            {
                                byte b = (byte)sh.Symbol[t];
                                Console.Write(b.ToString("X2") + " " );
                            }
                            Console.Write(Environment.NewLine);
                            sidtrans.GetSidDescription(sh);
                            sh.Mode = mode;//Convert.ToInt32(sh.Value);
                            modcount++;
                            if ((modcount % 12) == 0) mode++;
                        }
                        frmSIDInformation frmsid = new frmSIDInformation();
                        frmsid.Sidcollection = currentsidcollection;
                        frmsid.Entiresidcollection = entiresidcollection;
                        if (frmsid.ShowDialog() == DialogResult.OK)
                        {
                            SaveSidCollectionToBinary(m_currentfile, frmsid.Sidcollection);
                        }*/
        }
コード例 #4
0
        private void importSIDiSettingsToolStripMenuItem_Click(object sender, EventArgs e)
        {
            // import symbols from .sid file (must be same length)
            try
            {
                OpenFileDialog ofd = new OpenFileDialog();
                ofd.Multiselect = false;
                SIDICollection _current            = (SIDICollection)gridControl1.DataSource;
                SIDICollection _importedCollection = new SIDICollection();
                ofd.Filter = "SIDi files|*.sid";
                if (ofd.ShowDialog() == DialogResult.OK)
                {
                    string Line = string.Empty;
                    char[] sep  = new char[1];
                    sep.SetValue('|', 0);
                    char[] sep2 = new char[1];
                    sep2.SetValue('+', 0);
                    string[] lines = File.ReadAllLines(ofd.FileName);
                    if (lines.Length != _current.Count)
                    {
                        MessageBox.Show("Unable to import SIDi settings with a different length!");
                    }
                    else
                    {
                        using (StreamReader sr = new StreamReader(ofd.FileName))
                        {
                            // read all lines in the file
                            while ((Line = sr.ReadLine()) != null)
                            {
                                try
                                {
                                    string[]   values = Line.Split(sep);
                                    SIDIHelper sh     = new SIDIHelper();

                                    sh.FoundT7Symbol = (string)values.GetValue(0);
                                    sh.Info          = (string)values.GetValue(1);
                                    sh.Mode          = Convert.ToInt32((string)values.GetValue(2));
                                    sh.ModeDescr     = (string)values.GetValue(3);
                                    sh.Symbol        = (string)values.GetValue(4);
                                    sh.T7Symbol      = (string)values.GetValue(5);
                                    if (sh.T7Symbol == sh.Symbol)
                                    {
                                        sh.T7Symbol = sh.FoundT7Symbol;
                                    }
                                    sh.Value = (string)values.GetValue(6);

                                    sh.AddressSRAM = Convert.ToInt32((string)values.GetValue(7));
                                    int oriAddress = Convert.ToInt32((string)values.GetValue(8));
                                    sh.IsReadOnly = Convert.ToBoolean((string)values.GetValue(9));
                                    int sramdiff = 0;
                                    if (oriAddress != 0)
                                    {
                                        sramdiff = sh.AddressSRAM - oriAddress;
                                    }
                                    else
                                    {
                                        //logger.Debug("Ori address = 0 " + sh.Symbol + " " + sh.T7Symbol);
                                    }
                                    if (sh.T7Symbol == string.Empty)
                                    {
                                        sh.T7Symbol = GetDescriptionFromCollection(Entiresidcollection, sh.Symbol);
                                    }
                                    // split by +
                                    string[] symbolvalues = sh.T7Symbol.Split(sep2);
                                    if (symbolvalues.Length > 1)
                                    {
                                        // dan corrigeren
                                        try
                                        {
                                            sramdiff      += Convert.ToInt32(symbolvalues.GetValue(1));
                                            sh.AddressSRAM = GetSymbolAddressSRAM(symbolvalues.GetValue(0).ToString()) + sramdiff;
                                        }
                                        catch (Exception E)
                                        {
                                            logger.Debug(E.Message);
                                        }
                                    }
                                    else
                                    {
                                        sh.AddressSRAM = GetSymbolAddressSRAM(sh.T7Symbol) + sramdiff;
                                    }

                                    _importedCollection.Add(sh);
                                }
                                catch (Exception E)
                                {
                                    logger.Debug(E.Message);
                                }
                            }
                        }
                        gridControl1.DataSource = _importedCollection;
                        m_sidcollection         = (SIDICollection)gridControl1.DataSource;
                    }
                }
            }
            catch (Exception E)
            {
                logger.Debug(E.Message);
            }
        }
コード例 #5
0
        private void importSIDiSettingsToolStripMenuItem_Click(object sender, EventArgs e)
        {
            // import symbols from .sid file (must be same length)
            try
            {
                OpenFileDialog ofd = new OpenFileDialog();
                ofd.Multiselect = false;
                SIDICollection _current = (SIDICollection)gridControl1.DataSource;
                SIDICollection _importedCollection = new SIDICollection();
                ofd.Filter = "SIDi files|*.sid";
                if (ofd.ShowDialog() == DialogResult.OK)
                {
                    string Line = string.Empty;
                    char[] sep = new char[1];
                    sep.SetValue('|', 0);
                    char[] sep2 = new char[1];
                    sep2.SetValue('+', 0);
                    string[] lines = File.ReadAllLines(ofd.FileName);
                    if (lines.Length != _current.Count)
                    {
                        MessageBox.Show("Unable to import SIDi settings with a different length!");
                    }
                    else
                    {

                        using (StreamReader sr = new StreamReader(ofd.FileName))
                        {
                            // read all lines in the file
                            while ((Line = sr.ReadLine()) != null)
                            {
                                try
                                {
                                    string[] values = Line.Split(sep);
                                    SIDIHelper sh = new SIDIHelper();

                                    sh.FoundT7Symbol = (string)values.GetValue(0);
                                    sh.Info = (string)values.GetValue(1);
                                    sh.Mode = Convert.ToInt32((string)values.GetValue(2));
                                    sh.ModeDescr = (string)values.GetValue(3);
                                    sh.Symbol = (string)values.GetValue(4);
                                    sh.T7Symbol = (string)values.GetValue(5);
                                    if (sh.T7Symbol == sh.Symbol) sh.T7Symbol = sh.FoundT7Symbol;
                                    sh.Value = (string)values.GetValue(6);

                                    sh.AddressSRAM = Convert.ToInt32((string)values.GetValue(7));
                                    int oriAddress = Convert.ToInt32((string)values.GetValue(8));
                                    sh.IsReadOnly = Convert.ToBoolean((string)values.GetValue(9));
                                    int sramdiff = 0;
                                    if (oriAddress != 0)
                                    {
                                        sramdiff = sh.AddressSRAM - oriAddress;
                                    }
                                    else
                                    {
                                        //logger.Debug("Ori address = 0 " + sh.Symbol + " " + sh.T7Symbol);
                                    }
                                    if (sh.T7Symbol == string.Empty)
                                    {
                                        sh.T7Symbol = GetDescriptionFromCollection(Entiresidcollection, sh.Symbol);
                                    }
                                    // split by +
                                    string[] symbolvalues = sh.T7Symbol.Split(sep2);
                                    if (symbolvalues.Length > 1)
                                    {
                                        // dan corrigeren
                                        try
                                        {
                                            sramdiff += Convert.ToInt32(symbolvalues.GetValue(1));
                                            sh.AddressSRAM = GetSymbolAddressSRAM(symbolvalues.GetValue(0).ToString()) + sramdiff;
                                        }
                                        catch (Exception)
                                        {

                                        }
                                    }
                                    else
                                    {
                                        sh.AddressSRAM = GetSymbolAddressSRAM(sh.T7Symbol) + sramdiff;
                                    }

                                    _importedCollection.Add(sh);
                                }
                                catch (Exception E)
                                {
                                    logger.Debug(E.Message);
                                }

                            }
                        }
                        gridControl1.DataSource = _importedCollection;
                        m_sidcollection = (SIDICollection)gridControl1.DataSource;
                    }
                }
            }
            catch (Exception E)
            {
                logger.Debug(E.Message);
            }
        }
コード例 #6
0
 private void AddSIDIHelper(SIDICollection m_collection, string shortdescr, string symbol, string info, int address)
 {
     SIDIHelper h = new SIDIHelper();
     //h.Value = value;
     h.Symbol = shortdescr;
     h.T7Symbol = symbol;
     h.Info = info;
     h.AddressSRAM = address;
     m_collection.Add(h);
 }