Пример #1
0
        /// <summary>
        /// Handle cartridge memory load UI event
        /// </summary>
        public void OnCartridgeMemoryLoad()
        {
            // only supported for the standard cartridge
            if (!(m_execution_manager.TVC.Cartridge is TVCCartridge))
            {
                return;
            }

            // Configure open file dialog box
            Microsoft.Win32.OpenFileDialog dlg = new Microsoft.Win32.OpenFileDialog
            {
                DefaultExt = ".crt",
                Filter     = "Cartridge file (*.crt)|*.CRT|Binary file (*.bin)|*.bin|ROM file (*.rom)|*.rom"
            };

            // Get cartridge file folder
            TVCConfigurationSettings settings = SettingsFile.Default.GetSettings <TVCConfigurationSettings>();

            if (settings != null && !string.IsNullOrEmpty(settings.CartridgeFileName))
            {
                dlg.InitialDirectory = Path.GetDirectoryName(settings.CartridgeFileName);
            }

            // Show open file dialog box
            bool?result = null;

            result = dlg.ShowDialog();

            // Process open file dialog box results
            if (result == true)
            {
                string file_name = dlg.FileName;

                // stop execution
                m_execution_manager.ChangeExecutionState(ExecutionManager.ExecutionStateRequest.Pause);

                try
                {
                    TVCCartridge cartridge = (TVCCartridge)m_execution_manager.TVC.Cartridge;
                    cartridge.ReadCartridgeFile(file_name);
                }
                catch
                {
                    CustomControls.CustomMessageBox msgbox = new CustomControls.CustomMessageBox(m_main_window);
                    msgbox.ShowMessageBoxFromResource("srError", "srFileLoadError", System.Windows.MessageBoxButton.OK, System.Windows.MessageBoxImage.Error);
                }

                // reset computer
                m_execution_manager.TVC.ColdReset();

                // restore execution state
                m_execution_manager.ChangeExecutionState(ExecutionManager.ExecutionStateRequest.Restore);

                // save cartidge file name
                settings.CartridgeActive   = true;
                settings.CartridgeFileName = file_name;
                SettingsFile.Default.SetSettings(settings);
                SettingsFile.Default.Save();
            }
        }
Пример #2
0
        /// <summary>
        /// Handles cartridge memory clean
        /// </summary>
        public void OnCartridgeMemoryClear()
        {
            // only supported for the standard cartridge
            if (!(m_execution_manager.TVC.Cartridge is TVCCartridge))
            {
                return;
            }

            // stop execution
            m_execution_manager.ChangeExecutionState(ExecutionManager.ExecutionStateRequest.Pause);

            // clear remaining memory
            ((TVCCartridge)m_execution_manager.TVC.Cartridge).ClearCartridge();

            // reset computer
            m_execution_manager.TVC.ColdReset();

            // restore execution state
            m_execution_manager.ChangeExecutionState(ExecutionManager.ExecutionStateRequest.Restore);

            // save cartidge file name
            TVCConfigurationSettings settings = SettingsFile.Default.GetSettings <TVCConfigurationSettings>();

            settings.CartridgeActive = false;
            SettingsFile.Default.SetSettings(settings);
            SettingsFile.Default.Save();
        }
Пример #3
0
        public TVCMemory(TVComputer in_tvc)
        {
            // load configuration
            m_settings = SettingsFile.Default.GetSettings <TVCConfigurationSettings>();

            m_tvc = in_tvc;

            m_page_reader = new PageReader[PageCount];
            m_page_writer = new PageWriter[PageCount];

            // reserve space for memories
            m_mem_sys = new byte[SysMemLength];
            m_mem_ext = new byte[ExtMemLength];

            m_mem_iomem = new byte[IOCardCount][];
            for (int i = 0; i < IOCardCount; i++)
            {
                m_mem_iomem[i] = new byte[IOMemSize];
            }

            m_mem_user  = new byte[PageCount * PageLength];
            m_mem_video = new byte[VideoPageCount * PageLength];

            // register port handlers
            m_tvc.Ports.AddPortWriter(0x02, PortWrite02H);
            m_tvc.Ports.AddPortWriter(0x03, PortWrite03H);
            m_tvc.Ports.AddPortReset(0x02, PortReset02H);
            m_tvc.Ports.AddPortReset(0x03, PortReset03H);

            LoadROM();
        }
Пример #4
0
        /// <summary>
        /// Updates settings
        /// </summary>
        /// <param name="in_restart_tvc">True - if TVC needs to be restarted</param>
        public void SettingsChanged(ref bool in_restart_tvc)
        {
            // load configuration
            m_settings = SettingsFile.Default.GetSettings <TVCConfigurationSettings>();

            // update configuration
            if (LoadROM())
            {
                in_restart_tvc = true;
            }
        }
Пример #5
0
        /// <summary>
        /// Initializes cartridge
        /// </summary>
        /// <param name="in_parent">TVC hardware class</param>
        public void Initialize(ITVComputer in_parent)
        {
            // allocate cartridge memory
            Memory = new byte[CartMemLength];

            // load cartridge content
            try
            {
                TVCConfigurationSettings settings = SettingsFile.Default.GetSettings <TVCConfigurationSettings>();

                if (settings != null && !string.IsNullOrEmpty(settings.CartridgeFileName) && settings.CartridgeActive)
                {
                    ReadCartridgeFile(settings.CartridgeFileName);
                }
            }
            catch
            {
                ClearCartridge();
            }
        }