示例#1
0
        public bool ParseJumpCallToAnAddressValue(FormCpu i_form, bool i_justParse = false)
        {
            try
            {
                UInt16 detectedJumpAddress = ConvertRadix.ConvertNumberWithPrefix(i_form.textBoxJumpToAnAddress.Text);
                if (detectedJumpAddress > 0xFFFF)
                {
                    Locator.Resolve <IUserMessage>().Error("Value for jump to an address is too big...\n\nMaximum is 2 bytes(0xFFFF).");
                    i_form.textBoxJumpToAnAddress.Focus();
                }
                else
                {
                    _detectingJumpToAddress = detectedJumpAddress;
                }
            }
            catch (CommandParseException)
            {
                if (!i_justParse)
                {
                    Locator.Resolve <IUserMessage>().Error("Incorrect number in field for jump to an address..");
                    i_form.textBoxJumpToAnAddress.Focus();
                }
                return(false);
            }

            return(true);
        }
示例#2
0
        public static byte[] GetBytesFromBitmap(BitmapGrid i_bitmapGridView)
        {
            byte[] i_arrOut = new byte[(i_bitmapGridView.getGridWidth() / 8) * i_bitmapGridView.getGridHeight()];
            //for (int byteCounter = 0; byteCounter < i_arrOut.Length; )
            int byteCounter = 0;

            //byte actByte = 0;
            {
                for (int actHeight = 0; actHeight < i_bitmapGridView.getGridHeight(); actHeight++)
                {
                    for (int actLineBit = 0; actLineBit < i_bitmapGridView.getGridWidth(); actLineBit++)
                    {
                        if (actLineBit != 0 && actLineBit % 8 == 0)
                        {
                            byteCounter++; //next byte in out arr
                        }
                        bool bitValue = i_bitmapGridView.getGridBitValue(actLineBit, actHeight);
                        if (bitValue)
                        {
                            ConvertRadix.setBitInByteRightToLeft(ref i_arrOut[byteCounter], (byte)(actLineBit % 8));
                        }
                    }
                    byteCounter++; //next byte in out arr
                }
            }

            return(i_arrOut);
        }
示例#3
0
        public bool ParseTracedOpcode(FormCpu i_form, bool i_justParse = false)
        {
            try
            {
                UInt16 opcode = ConvertRadix.ConvertNumberWithPrefix(i_form.textBoxOpcode.Text);
                if (opcode > 0xFF) //ToDo: only one byte for traced opcode
                {
                    SetTracedOpcode((byte)(opcode % 256));
                }
                else
                {
                    SetTracedOpcode((byte)opcode);
                }
            }
            catch (CommandParseException)
            {
                if (!i_justParse)
                {
                    Locator.Resolve <IUserMessage>().Error("Incorrect opcode number...");
                    i_form.textBoxOpcode.Focus();
                }
                return(false);
            }

            return(true);
        }
示例#4
0
文件: TcpHelper.cs 项目: zxmak/ZXMAK2
        public static bool SetProxyPort(string i_newPort)
        {
            int proxyAdept = ConvertRadix.ParseUInt16(i_newPort, 10);

            if (proxyAdept > 0xFFFF)
            {
                return(false);
            }
            _proxyPort = i_newPort;
            return(true);
        }
示例#5
0
        //overload
        public static byte[] GetBytesFromBitmap(Bitmap i_bitmapBase)
        {
            int width = i_bitmapBase.Width / 8;

            if (i_bitmapBase.Width % 8 != 0)
            {
                width++;
            }
            int height = i_bitmapBase.Height;

            byte[] i_arrOut    = new byte[width * height];
            int    byteCounter = 0;

            {
                for (int actHeight = 0; actHeight < height; actHeight++)
                {
                    for (int actLineBit = 0; actLineBit < width * 8; actLineBit++)
                    {
                        if (actLineBit != 0 && actLineBit % 8 == 0)
                        {
                            byteCounter++;
                        }
                        bool bitValue;
                        if (actLineBit > i_bitmapBase.Width - 1)
                        {
                            bitValue = false; //fills rest of toke pixels to not set
                        }
                        else
                        {
                            bitValue = i_bitmapBase.GetPixel(actLineBit, actHeight).Name != "ffffffff";
                        }
                        if (bitValue)
                        {
                            ConvertRadix.setBitInByteRightToLeft(ref i_arrOut[byteCounter], (byte)(actLineBit % 8));
                        }

                        //Logger.Debug(String.Format("X:{0} Y:{1} Color:{2}", actLineBit, actHeight, i_bitmapBase.GetPixel(actLineBit, actHeight).Name));
                    }
                    byteCounter++;
                }
            }

            return(i_arrOut);
        }
示例#6
0
文件: Compiler.cs 项目: zxmak/ZXMAK2
        public static Dictionary <string, ushort> ParseSymbols(string i_symbols)
        {
            if (i_symbols == null || i_symbols == String.Empty)
            {
                return(null);
            }

            Dictionary <string, ushort> out_ParsedSymbols = new Dictionary <string, ushort>();

            string[] lines = i_symbols.Split('\n');
            foreach (string line in lines)
            {
                string[] lineParsed = Regex.Split(line, @"\s+");
                if (lineParsed.Length == 3)
                {
                    ushort symbolAddr = ConvertRadix.ConvertNumberWithPrefix(lineParsed[2]);
                    out_ParsedSymbols.Add(lineParsed[0], symbolAddr);
                }
            }

            return(out_ParsedSymbols);
        }
示例#7
0
        public int Compare(object x, object y)
        {
            //!!! designed for ListView<string, ushort> only for now.... !!!
            //Link: https://msdn.microsoft.com/en-us/library/ms996467.aspx
            int returnVal = -1;
            var column1   = ((ListViewItem)x);
            var column2   = ((ListViewItem)y);

            //get value to compare
            if (col == 1) // second column is ushort
            {
                //set values
                ushort value1 = ConvertRadix.ConvertNumberWithPrefix(column1.Tag.ToString());
                ushort value2 = ConvertRadix.ConvertNumberWithPrefix(column2.Tag.ToString());
                if (value1 == value2)
                {
                    returnVal = 0;
                }
                else
                {
                    returnVal = value1 > value2 ? 1 : -1;
                }
            }
            else
            {
                returnVal = String.Compare(((ListViewItem)x).Text, ((ListViewItem)y).Text);
            }

            // Determine whether the sort order is descending.
            if (order == SortOrder.Descending)
            {
                // Invert the value returned by String.Compare.
                returnVal *= -1;
            }
            return(returnVal);
        }
示例#8
0
        public Boolean manualCrop(ref PictureBox i_pcbxZXScreen, string i_strCoordinates, bool i_hexValues)
        {
            // Parameter checks
            if (i_strCoordinates == String.Empty || i_strCoordinates == null || i_strCoordinates == "")
            {
                return(false);
            }

            i_pcbxZXScreen.Invalidate();
            //i_pcbxZXScreen.Refresh();

            //Prepare a new Bitmap on which the cropped image will be drawn
            Bitmap   sourceBitmap = new Bitmap(i_pcbxZXScreen.Image, i_pcbxZXScreen.Width, i_pcbxZXScreen.Height);
            Graphics g            = i_pcbxZXScreen.CreateGraphics();

            //Checks if the co-rdinates check-box is checked. If yes, then Selection is based on co-rdinates mentioned in the textbox
            //logic to retrieve co-rdinates from comma-separated string values

            string[] cordinates = i_strCoordinates.Split(',');
            int      cordX, cordY, cordWidth, cordHeight;

            try
            {
                cordX = i_hexValues ? ConvertRadix.ParseUInt16(cordinates[0], 16) : Convert.ToInt32(cordinates[0]);
                if (cordX > GraphicsTools.MAX_X_PIXEL)
                {
                    cordX = GraphicsTools.MAX_X_PIXEL * 2;
                }
                else
                {
                    cordX *= 2;
                }

                cordY = i_hexValues ? ConvertRadix.ParseUInt16(cordinates[1], 16) : Convert.ToInt32(cordinates[1]);
                if (cordY > GraphicsTools.MAX_Y_PIXEL)
                {
                    cordY = GraphicsTools.MAX_Y_PIXEL * 2;
                }
                else
                {
                    cordY *= 2;
                }

                cordWidth = i_hexValues ? ConvertRadix.ParseUInt16(cordinates[2], 16) : Convert.ToInt32(cordinates[2]);
                if (cordWidth > GraphicsTools.MAX_X_PIXEL)
                {
                    cordWidth = GraphicsTools.MAX_X_PIXEL * 2;
                }
                else
                {
                    cordWidth *= 2;
                }

                cordHeight = i_hexValues ? ConvertRadix.ParseUInt16(cordinates[3], 16) : Convert.ToInt32(cordinates[3]);
                if (cordHeight > GraphicsTools.MAX_Y_PIXEL)
                {
                    cordHeight = GraphicsTools.MAX_Y_PIXEL * 2;
                }
                else
                {
                    cordHeight *= 2;
                }
            }
            catch (Exception)
            {
                Locator.Resolve <IUserMessage>().Error("Error parsing coordinates for selection area...\n\nCorrection needed !");
                return(false);
            }

            m_rectCropArea = new Rectangle(cordX, cordY, cordWidth, cordHeight);

            //Draw the image on the Graphics object with the new dimensions
            g.DrawImage(sourceBitmap, new Rectangle(0, 0, i_pcbxZXScreen.Width, i_pcbxZXScreen.Height),
                        m_rectCropArea, GraphicsUnit.Pixel);

            sourceBitmap.Dispose();

            return(true);
        }