Пример #1
0
        protected void OnPixelSet(ChipInstruction inst)
        {
            m_VRegs[0xF] = 0;
            byte x    = m_VRegs[inst.X];
            byte y    = m_VRegs[inst.Y];
            byte read = 0;

            if (inst.N > 0)
            {
                // Loop through the sprite bytes by N
                for (byte i = 0; i < inst.N; i++)
                {
                    // Get the next byte of the sprite data
                    read = Memory.ReadByte((int)(m_IReg + i));

                    // Sprite is always 8 in width, loop through each bit
                    for (byte j = 0; j < 8; j++)
                    {
                        // If we hit an on bit then Set a pixel at X, Y
                        if ((read & (0x80 >> j)) != 0)
                        {
                            // If we colliude, set VF
                            if (VideoInterface.SetPixel((x + j), (y + i)))
                            {
                                m_VRegs[0xF] = 1;
                            }
                        }
                    }
                }
            }
            else
            {
                for (int k = 0; k < 0x10; k++)
                {
                    ushort data = Tools.Create16(Memory.ReadByte((int)(m_IReg + (k << 1))),
                                                 Memory.ReadByte((int)(m_IReg + (k << 1) + 1)));

                    for (int m = 0; m < 0x10; m++)
                    {
                        if ((data & (((int)0x8000) >> m)) != 0)
                        {
                            if (VideoInterface.SetPixel((x + m), (y + k)))
                            {
                                m_VRegs[0xF] = 1;
                            }
                        }
                    }
                }
            }

            if (m_VRegs[0xF] == 1 && m_AntiFlickerHack)
            {
                return;
            }

            VideoInterface.RenderWait();
        }