Esempio n. 1
0
        public static byte[] LoadGammaCorrection(BasicMemory VKY)
        {
            // Read the color lookup tables
            int gamAddress = MemoryMap.GAMMA_BASE_ADDR - MemoryMap.VICKY_BASE_ADDR;

            //
            byte[] result = new byte[3 * 256];
            FoenixSystem.Current.MemoryManager.Copy(gamAddress, result, 0, 3 * 256);
            return(result);
        }
Esempio n. 2
0
        private FoenixSystem()
        {
            gpu = new Gpu();

            MemoryManager = new MemoryManager();


            //RAM = new BasicMemory("Ram", MemoryMap.RAM_START, MemoryMap.RAM_SIZE);   // 2MB RAM - extensible to 4MB
            //MemoryManager.AddDevice(RAM);
            //VICKY = new BasicMemory("Vicky", MemoryMap.VICKY_START, MemoryMap.VICKY_SIZE);   // 60K
            //MemoryManager.AddDevice(VICKY);
            //VIDEO = new BasicMemory("Video", MemoryMap.VIDEO_START, MemoryMap.VIDEO_SIZE - 1); // 4MB Video
            //MemoryManager.AddDevice(VIDEO);
            FLASH = new BasicMemory("Flash", MemoryMap.FLASH_START, MemoryMap.FLASH_SIZE);         // 8MB RAM
            MemoryManager.AddDevice(FLASH);
            BEATRIX = new BasicMemory("Beatrix", MemoryMap.BEATRIX_START, MemoryMap.BEATRIX_SIZE); // 4K
            MemoryManager.AddDevice(BEATRIX);

            // Special devices
            MATH = new MathCoproRegisters(MemoryMap.MATH_START);
            MemoryManager.AddDevice(MATH); // 47 bytes

            // This register is only a single byte but we allow writing a word
            CODEC = new Codec(MemoryMap.CODEC_START);
            MemoryManager.AddDevice(CODEC);     // 4 bytes
            KEYBOARD = new KeyboardRegister(MemoryMap.KBD_DATA_BUF);
            MemoryManager.AddDevice(KEYBOARD);  // 5 bytes
            SDCARD = new SDCardRegister(MemoryMap.SDCARD_DATA);
            MemoryManager.AddDevice(SDCARD);    // 2 bytes
            INTERRUPT = new InterruptController(MemoryMap.INT_PENDING_REG0);
            MemoryManager.AddDevice(INTERRUPT); // 3 bytes
            UART1 = new UART(1, MemoryMap.UART1_REGISTERS);
            MemoryManager.AddDevice(UART1);     // 8 bytes
            UART2 = new UART(2, MemoryMap.UART2_REGISTERS);
            MemoryManager.AddDevice(UART2);     // 8 bytes
            OPL2 = new OPL2(MemoryMap.OPL2_S_BASE);
            //MemoryManager.AddDevice(OPL2); // 256 bytes
            MPU401 = new MPU401(MemoryMap.MPU401_REGISTERS);
            MemoryManager.AddDevice(MPU401); // 2 bytes

            this.CPU = new CPU(MemoryManager);
            this.CPU.SimulatorCommand += CPU_SimulatorCommand;

            //gpu.VRAM = VIDEO;
            //gpu.RAM = RAM;
            //gpu.VICKY = VICKY;

            // This fontset is loaded just in case the kernel doesn't provide one.
            gpu.LoadFontSet("Foenix", @"Resources\Bm437_PhoenixEGA_8x8.bin", 0, CharacterSet.CharTypeCodes.ASCII_PET, CharacterSet.SizeCodes.Size8x8);
        }
Esempio n. 3
0
        /// <summary>
        /// Load a character set from disk
        /// </summary>
        /// <param name="Filename">data file with character glyphs</param>
        /// <param name="Vram">array to store glyph data</param>
        /// <param name="StartAddress">starting address in array</param>
        /// <param name="newCharSize">Size of glyhphs (8x8 or 8x16)</param>
        public void Load(string Filename, int Offset, BasicMemory Vram, int StartAddress, SizeCodes newCharSize)
        {
            this.StartAddress  = StartAddress;
            this.CharSize      = newCharSize;
            this.CharacterData = Vram;

            try
            {
                byte[] d = global::System.IO.File.ReadAllBytes(Filename);
                Vram.Load(d, Offset, StartAddress, d.Length - Offset);
            }
            catch (Exception ex)
            {
                SystemLog.WriteLine(SystemLog.SeverityCodes.Recoverable, "Error in CharacteSet.Load\r\n" + ex.Message + "Filename:" + Filename);
            }
        }
Esempio n. 4
0
        public static int[] LoadLUT(BasicMemory VKY)
        {
            // Read the color lookup tables
            int lutAddress   = MemoryMap.GRP_LUT_BASE_ADDR - MemoryMap.VICKY_BASE_ADDR;
            int lookupTables = 4;

            int[] result = new int[lookupTables * 256];


            for (int c = 0; c < lookupTables * 256; c++)
            {
                byte blue  = VKY.ReadByte(lutAddress++);
                byte green = VKY.ReadByte(lutAddress++);
                byte red   = VKY.ReadByte(lutAddress++);
                lutAddress++;
                result[c] = (0xFF << 24) + (red << 16) + (green << 8) + blue;
            }
            return(result);
        }
Esempio n. 5
0
        private void SendBinaryButton_Click(object sender, EventArgs e)
        {
            SendBinaryButton.Enabled = false;
            DisconnectButton.Enabled = false;

            int transmissionSize = GetTransmissionSize();

            UploadProgressBar.Maximum = transmissionSize;
            UploadProgressBar.Value   = 0;
            UploadProgressBar.Visible = true;

            if (SendFileRadio.Checked)
            {
                if (Path.GetExtension(FileNameTextBox.Text).ToUpper().Equals(".BIN"))
                {
                    //byte[] DataBuffer = new byte[transmissionSize];  // Maximum 2 MB, example from $0 to $1F:FFFF.
                    // Read the bytes and put them in the buffer
                    byte[] DataBuffer    = System.IO.File.ReadAllBytes(FileNameTextBox.Text);
                    int    FnxAddressPtr = int.Parse(C256DestAddress.Text.Replace(":", ""), System.Globalization.NumberStyles.AllowHexSpecifier);
                    Console.WriteLine("Starting Address: " + FnxAddressPtr);
                    Console.WriteLine("Size of File: " + transmissionSize);
                    SendData(DataBuffer, FnxAddressPtr, transmissionSize, DebugModeCheckbox.Checked);
                }
                else
                {
                    if (serial.IsOpen)
                    {
                        // Get into Debug mode (Reset the CPU and keep it in that state and Gavin will take control of the bus)
                        if (DebugModeCheckbox.Checked)
                        {
                            GetFnxInDebugMode();
                        }

                        // If send HEX files, each time we encounter a "bank" change - record 04 - send a new data block
                        string[] lines       = System.IO.File.ReadAllLines(FileNameTextBox.Text);
                        int      bank        = 0;
                        int      address     = 0;
                        byte[]   pageFF      = new byte[256];
                        bool     resetVector = false;
                        foreach (string l in lines)
                        {
                            if (l.StartsWith(":"))
                            {
                                string mark     = l.Substring(0, 1);
                                string reclen   = l.Substring(1, 2);
                                string offset   = l.Substring(3, 4);
                                string rectype  = l.Substring(7, 2);
                                string data     = l.Substring(9, l.Length - 11);
                                string checksum = l.Substring(l.Length - 2);

                                switch (rectype)
                                {
                                case "00":
                                    int    length     = Convert.ToInt32(reclen, 16);
                                    byte[] DataBuffer = new byte[length];
                                    address = HexFile.GetByte(offset, 0, 2);
                                    for (int i = 0; i < data.Length; i += 2)
                                    {
                                        DataBuffer[i / 2] = (byte)HexFile.GetByte(data, i, 1);
                                    }
                                    PreparePacket2Write(DataBuffer, bank + address, 0, length);
                                    if (bank + address >= 0xFF00 && (bank + address) < 0xFFFF)
                                    {
                                        int pageFFLen = length - ((bank + address + length) - 0x1_0000);
                                        if (pageFFLen > length)
                                        {
                                            pageFFLen = length;
                                        }
                                        Array.Copy(DataBuffer, 0, pageFF, bank + address - 0xFF00, pageFFLen);
                                        resetVector = true;
                                    }
                                    else if (bank + address >= 0x18_FF00 && (bank + address) < 0x18_FFFF)
                                    {
                                        int pageFFLen = length - ((bank + address + length) - 0x19_0000);
                                        if (pageFFLen > length)
                                        {
                                            pageFFLen = length;
                                        }
                                        Array.Copy(DataBuffer, 0, pageFF, bank + address - 0x18_FF00, length);
                                        resetVector = true;
                                    }
                                    UploadProgressBar.Increment(length);

                                    break;

                                case "04":
                                    bank = HexFile.GetByte(data, 0, 2) << 16;
                                    break;
                                }
                            }
                        }

                        if (DebugModeCheckbox.Checked)
                        {
                            // Update the Reset Vectors from the Binary Files Considering that the Files Keeps the Vector @ $00:FF00
                            if (resetVector)
                            {
                                PreparePacket2Write(pageFF, 0x00FF00, 0, 256);
                            }
                            // The Loading of the File is Done, Reset the FNX and Get out of Debug Mode
                            ExitFnxDebugMode();
                        }
                        MessageBox.Show("Transfer Done! System Reset!", "Send Binary Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                }
            }
            else if (BlockSendRadio.Checked)
            {
                int blockAddress = Convert.ToInt32(EmuSrcAddress.Text.Replace(":", ""), 16);
                // Read the data directly from emulator memory
                int    offset        = 0;
                int    FnxAddressPtr = int.Parse(C256DestAddress.Text.Replace(":", ""), System.Globalization.NumberStyles.AllowHexSpecifier);
                byte[] DataBuffer    = new byte[transmissionSize]; // Maximum 2 MB, example from $0 to $1F:FFFF.
                for (int start = blockAddress; start < blockAddress + transmissionSize; start++)
                {
                    DataBuffer[offset++] = Memory.ReadByte(start);
                }
                SendData(DataBuffer, FnxAddressPtr, transmissionSize, DebugModeCheckbox.Checked);
            }
            else
            {
                int    blockAddress = Convert.ToInt32(C256SrcAddress.Text.Replace(":", ""), 16);
                byte[] DataBuffer   = new byte[transmissionSize]; // Maximum 2 MB, example from $0 to $1F:FFFF.
                if (FetchData(DataBuffer, blockAddress, transmissionSize, DebugModeCheckbox.Checked))
                {
                    BasicMemory mem = new BasicMemory("tempbuffer", blockAddress, transmissionSize);
                    mem.Load(DataBuffer, 0, 0, transmissionSize);
                    MemoryWindow tempMem = new MemoryWindow
                    {
                        Memory = mem,
                        Text   = "C256 Memory from " + blockAddress.ToString("X6") +
                                 " to " + (blockAddress + transmissionSize - 1).ToString("X6")
                    };
                    tempMem.GotoAddress(blockAddress);
                    tempMem.Show();
                }
            }

            UploadProgressBar.Visible = false;
            SendBinaryButton.Enabled  = true;
            DisconnectButton.Enabled  = true;
        }