Exemplo n.º 1
0
        public byte[] LoadTextFile(List <string> strlTextFile)
        {
            // Load file to byte array
            if (strlTextFile.Count > 0)
            {
                // Initialize buffers
                //m_ylMemoryImage = new List<byte> (m_kiInitialImageSize); // Limit to 8k until there's a reason to expand
                //for (int iIdx = 0; iIdx < m_ylMemoryImage.Capacity; iIdx++)
                //{
                //    m_ylMemoryImage.Add (0x00);
                //}
                //m_yaEndCard = new byte[m_kiEndCardImageSize];

                // Initialize boundary markers
                m_iLowAddressMI  = m_kiInitialImageSize;
                m_iHighAddressMI = 0;
                m_iLowAddressEC  = m_kiEndCardImageSize;
                m_iHighAddressEC = 0;

                foreach (string str in strlTextFile)
                {
                    if (str[0] == 'T')
                    {
                        byte[] yaTextBinary = ReadTextCard(str);
                        //PrintStringList (BinaryToDump (yaTextBinary));

                        for (int iIdx = yaTextBinary[0] + 1, iTargetIdx = yaTextBinary[1] * 0x0100 + yaTextBinary[2];
                             iIdx > 0;
                             iIdx--, iTargetIdx--)
                        {
                            //m_ylMemoryImage[iTargetIdx] = yaTextBinary[iIdx + 2];
                            m_yaMainMemory[iTargetIdx] = yaTextBinary[iIdx + 2];

                            if (iTargetIdx < m_iLowAddressMI)
                            {
                                m_iLowAddressMI = iTargetIdx;
                            }

                            if (iTargetIdx > m_iHighAddressMI)
                            {
                                m_iHighAddressMI = iTargetIdx;
                            }
                        }

                        //PrintStringList (BinaryToDump (m_laMemoryImage, m_iLowAddressMI, m_iHighAddressMI));
                    }
                    else if (str[0] == 'E')
                    {
                        byte[] yaTextBinary = ReadTextCard(str);
                        //PrintStringList (BinaryToDump (yaTextBinary));
                        m_iEndCardLoadAddress = yaTextBinary[0x00] << 8 | yaTextBinary[0x01];

                        for (int iIdx = 0x00, iTargetIdx = 0x17;
                             iIdx < 0x41;
                             iIdx++, iTargetIdx++)
                        {
                            //m_yaEndCard[iTargetIdx] = yaTextBinary[iIdx];
                            m_yaMainMemory[iTargetIdx] = yaTextBinary[iIdx];

                            if (iTargetIdx < m_iLowAddressEC)
                            {
                                m_iLowAddressEC = iTargetIdx;
                            }

                            //if (iTargetIdx > m_iHighAddressEC && m_yaEndCard[iTargetIdx] > 0x00)
                            //if (iTargetIdx > m_iHighAddressEC)
                            if (iTargetIdx > m_iHighAddressEC &&
                                //m_yaEndCard[iTargetIdx] > 0)
                                m_yaMainMemory[iTargetIdx] > 0)
                            {
                                m_iHighAddressEC = iTargetIdx;
                            }

                            //PrintStringList (BinaryToDump (m_yaEndCard, m_iLowAddressEC, m_iHighAddressEC));
                        }

                        //int iMainEntryPoint = m_yaEndCard[17] << 8 + m_yaEndCard[18];
                        int iMainEntryPoint = m_yaMainMemory[17] << 8 + m_yaMainMemory[18];
                        if (m_iEntryPointMI == 0x0000 &&
                            iMainEntryPoint >= m_iLowAddressMI &&
                            iMainEntryPoint < m_iHighAddressMI)
                        {
                            m_iEntryPointMI = iMainEntryPoint;
                        }

                        if (m_iHighAddressEC < 0x0055)
                        {
                            ++m_iHighAddressEC;
                        }
                    }
                }
            }

            //m_sdDCP[m_iLowAddressMI]  = new CDasmControlPoint (m_iLowAddressMI,  ENotationType.NOTE_Begin, "Low address");
            //m_sdDCP[m_iHighAddressMI] = new CDasmControlPoint (m_iHighAddressMI, ENotationType.NOTE_End,   "High address");
            m_sdDCP[m_iLowAddressMI]  = new CDasmControlPoint(m_iLowAddressMI, 0, 0, true, EControlPointType.POINT_Begin, "Low address");
            m_sdDCP[m_iHighAddressMI] = new CDasmControlPoint(m_iHighAddressMI, 0, 0, true, EControlPointType.POINT_End, "High address");

            DumpListDCP();

            //return m_ylMemoryImage.GetRange (0x0000, m_iHighAddressMI).ToArray ();

            byte[] yaReturn = new byte[m_iHighAddressMI + 1];
            for (int iIdx = 0; iIdx <= m_iHighAddressMI; ++iIdx)
            {
                yaReturn[iIdx] = m_yaMainMemory[iIdx];
            }
            return(yaReturn);
        }
Exemplo n.º 2
0
        public List <byte> LoadTextFile(List <string> strlTextFile)
        {
            // Load file to byte array
            if (strlTextFile.Count > 0)
            {
                // Initialize buffers
                m_ylMemoryImage = new List <byte> (m_kiInitialImageSize); // Limit to 8k until there's a reason to expand
                for (int iIdx = 0; iIdx < m_ylMemoryImage.Capacity; iIdx++)
                {
                    m_ylMemoryImage.Add(0x00);
                }
                m_yaEndCard = new byte[m_kiEndCardImageSize];

                // Initialize boundary markers
                m_iLowAddressMI  = m_kiInitialImageSize;
                m_iHighAddressMI = 0;
                m_iLowAddressEC  = m_kiEndCardImageSize;
                m_iHighAddressEC = 0;

                foreach (string str in strlTextFile)
                {
                    if (str[0] == 'T')
                    {
                        byte[] yaTextBinary = ReadTextCard(str);
                        //PrintStringList (BinaryToDump (yaTextBinary));

                        for (int iIdx = yaTextBinary[0] + 1, iTargetIdx = yaTextBinary[1] * 0x0100 + yaTextBinary[2];
                             iIdx > 0;
                             iIdx--, iTargetIdx--)
                        {
                            m_ylMemoryImage[iTargetIdx] = yaTextBinary[iIdx + 2];

                            if (iTargetIdx < m_iLowAddressMI)
                            {
                                m_iLowAddressMI = iTargetIdx;
                            }

                            if (iTargetIdx > m_iHighAddressMI)
                            {
                                m_iHighAddressMI = iTargetIdx;
                            }
                        }

                        //PrintStringList (BinaryToDump (m_laMemoryImage, m_iLowAddressMI, m_iHighAddressMI));
                    }
                    else if (str[0] == 'E')
                    {
                        byte[] yaTextBinary = ReadTextCard(str);
                        //PrintStringList (BinaryToDump (yaTextBinary));

                        for (int iIdx = 0x02, iTargetIdx = 0x19;
                             iIdx < 0x41;
                             iIdx++, iTargetIdx++)
                        {
                            m_yaEndCard[iTargetIdx] = yaTextBinary[iIdx];

                            if (iTargetIdx < m_iLowAddressEC)
                            {
                                m_iLowAddressEC = iTargetIdx;
                            }

                            //if (iTargetIdx > m_iHighAddressEC && m_yaEndCard[iTargetIdx] > 0x00)
                            if (iTargetIdx > m_iHighAddressEC)
                            {
                                m_iHighAddressEC = iTargetIdx;
                            }

                            //PrintStringList (BinaryToDump (m_yaEndCard, m_iLowAddressEC, m_iHighAddressEC));
                        }
                    }
                }
            }

            m_sdDCP[m_iLowAddressMI]  = new CDasmControlPoint(m_iLowAddressMI, ENotationType.NOTE_Begin, "Low address");
            m_sdDCP[m_iHighAddressMI] = new CDasmControlPoint(m_iHighAddressMI, ENotationType.NOTE_End, "High address");

            DumpListDCP();

            return(m_ylMemoryImage);
        }