Ejemplo n.º 1
0
        /// <summary>
        /// Screen View type
        /// </summary>
        public void setZXScreenView()
        {
            if (_spectrum == null || m_instance == null)
            {
                return;
            }

            pictureZXDisplay.Width  = ZX_SCREEN_WIDTH;
            pictureZXDisplay.Height = ZX_SCREEN_HEIGHT;

            bmpZXMonochromatic = new Bitmap(ZX_SCREEN_WIDTH / 2, ZX_SCREEN_HEIGHT / 2);
            ushort screenPointer = (ushort)numericUpDownActualAddress.Value;

            //Screen View
            for (int segments = 0; segments < 3; segments++)
            {
                for (int eightLines = 0; eightLines < 8; eightLines++)
                {
                    //Cycle: Fill 8 lines in one segment
                    for (int linesInSegment = 0; linesInSegment < 64; linesInSegment += 8)
                    {
                        // Cycle: all attributes in 1 line
                        for (int attributes = 0; attributes < 32; attributes++)
                        {
                            byte blockByte = _spectrum.ReadMemory(screenPointer++);

                            BitArray spriteBits = GraphicsTools.getAttributePixels(blockByte, m_instance.checkBoxMirror.Checked);
                            if (spriteBits == null)
                            {
                                return;
                            }

                            // Cycle: fill 8 pixels for 1 attribute
                            for (int pixels = 0; pixels < 8; pixels++)
                            {
                                if (spriteBits[pixels])
                                {
                                    bmpZXMonochromatic.SetPixel(pixels + (attributes * 8), linesInSegment + eightLines + (segments * 64), Color.Black);
                                }
                                else
                                {
                                    bmpZXMonochromatic.SetPixel(pixels + (attributes * 8), linesInSegment + eightLines + (segments * 64), Color.White);
                                }
                            }
                        }
                    }
                }
            } // 3 segments of the ZX Screen

            //Size newSize = new Size((int)(pictureZXDisplay.Width), (int)(pictureZXDisplay.Height));

            /*pictureZXDisplay.Image = bmpZXMonochromatic;
             * pictureZXDisplay.Width = ZX_SCREEN_WIDTH;
             * pictureZXDisplay.Height = ZX_SCREEN_HEIGHT;*/
            Image resizedImage = bmpZXMonochromatic.GetThumbnailImage(ZX_SCREEN_WIDTH, ZX_SCREEN_HEIGHT, null, IntPtr.Zero);

            pictureZXDisplay.Image    = resizedImage;
            pictureZXDisplay.SizeMode = PictureBoxSizeMode.StretchImage;
        }
Ejemplo n.º 2
0
        public void setBitmapBits(IDebuggable i_spectrum, ushort i_startAddress)
        {
            int gridBytes = X_BIT_COUNT / 8 * Y_BIT_COUNT;

            _gridBits = new BitArray[gridBytes];

            for (int counter = 0; counter < gridBytes; counter++)
            {
                byte blockByte = i_spectrum.ReadMemory(i_startAddress++);
                _gridBits[counter] = GraphicsTools.getAttributePixels(blockByte, false);
            }
        }
Ejemplo n.º 3
0
        private Image getTileViewImage()
        {
            byte spriteWidth = Convert.ToByte(comboSpriteWidth.SelectedItem);
            //byte spriteHeight;
            ushort screenPointer = (ushort)numericUpDownActualAddress.Value;

            if (_spectrum == null || m_instance == null)
            {
                return(null);
            }

            Bitmap bmpSpriteView = new Bitmap(spriteWidth, ZX_SCREEN_HEIGHT);

            for (int YPointerShift = 0; YPointerShift < ZX_SCREEN_HEIGHT; YPointerShift += 8)
            {
                for (int XPointerShift = 0; XPointerShift < spriteWidth; XPointerShift += 8)
                {
                    //draw one tile
                    for (int line = 0; line < 8; line++)
                    {
                        BitArray spriteBits = GraphicsTools.getAttributePixels(_spectrum.ReadMemory(screenPointer++), m_instance.checkBoxMirror.Checked);
                        if (spriteBits == null)
                        {
                            return(null);
                        }

                        // Cycle: fill 8 pixels for 1 attribute
                        for (int pixelBit = 7; pixelBit > -1; pixelBit--)
                        {
                            if (spriteBits[pixelBit])
                            {
                                bmpSpriteView.SetPixel(pixelBit + XPointerShift, line + YPointerShift, Color.Black);
                            }
                            else
                            {
                                bmpSpriteView.SetPixel(pixelBit + XPointerShift, line + YPointerShift, Color.White);
                            }
                        }
                    }
                }
            }

            byte  spriteZoomFactor = Convert.ToByte(numericUpDownZoomFactor.Value);
            Image resizedImage     = bmpSpriteView.GetThumbnailImage(spriteWidth * spriteZoomFactor, (spriteWidth * spriteZoomFactor * bmpSpriteView.Height) /
                                                                     bmpSpriteView.Width, null, IntPtr.Zero);

            return(resizedImage);
        }