示例#1
0
        private void LoadSNA(string path)
        {
            byte[]    snapshot = File.ReadAllBytes(path);
            Registers r        = _cpu.Registers;

            r.I = snapshot[0];

            r.ExchangeBCDEHL();
            r.HL = getWord(1);
            r.DE = getWord(3);
            r.BC = getWord(5);
            r.AF = getWord(7);

            r.ExchangeBCDEHL();
            r.HL = getWord(9);
            r.DE = getWord(11);
            r.BC = getWord(13);
            r.IY = getWord(15);
            r.IX = getWord(17);

            if (snapshot[19].GetBit(2))
            {
                _cpu.EnableInterrupts();
            }

            r.R = snapshot[20];
            r[WordRegister.AF] = getWord(21);
            r.SP = getWord(23);

            _cpu.SetInterruptMode((InterruptMode)snapshot[25]);
            _screen.SetBorderColour(DisplayColour.FromThreeBit(snapshot[26]));

            _cpu.Memory.Untimed.WriteBytesAt(16384, snapshot[27..]);
示例#2
0
        public void Fill(byte[] pixels, byte[] attributes)
        {
            for (byte y = 0; y < 192; y++)
            {
                ushort address = _screenLineAddresses[y]; // base address for this screen line
                for (byte x = 0; x < 32; x++)
                {
                    byte pixelData = pixels[address + x];
                    for (int i = 0; i < 8; i++)
                    {
                        _pixels[y, (x * 8) + i] = pixelData.GetBit(7 - i);
                    }
                }
            }

            int columnCounter = 0;
            int rowCounter    = 0;

            foreach (byte attribute in attributes)
            {
                // 32 x 24
                AttributeMap[rowCounter, columnCounter] = new DisplayAttribute()
                {
                    Ink    = DisplayColour.FromThreeBit(attribute.GetByteFromBits(0, 3)),
                    Paper  = DisplayColour.FromThreeBit(attribute.GetByteFromBits(3, 3)),
                    Bright = attribute.GetBit(6),
                    Flash  = attribute.GetBit(7)
                };

                columnCounter++;
                if (columnCounter == 32)
                {
                    columnCounter = 0;
                    rowCounter++;
                }
            }
        }