示例#1
0
        public Dispatcher(MainWindow opener)
        {
            // References to Frontend and Backend objects
            _opener  = opener;
            _input   = new Input(this);
            _timer   = new EventLoop(this);
            _output  = new Draw(this);
            _toolbox = new Toolbox(this, "images/terrain_atlas.png", new System.Drawing.Rectangle(_opener.ClientRectangle.Width - 325, 60, 320, _opener.ClientRectangle.Height - 130));
            _map     = new Backend.Map(this, "start");
            if (_map.Width < 1)
            {
                _map = new Backend.Map(this, 10, 10, false);
            }
            _attachedImagePos = new System.Drawing.Rectangle();


            // Hook up Delegates
            Refresh  += _output.Refresh;
            Move     += _input.Move;
            Click    += _input.Click;
            Keyboard += _input.Keyboard;
            Repaint();

            // Generate lists for interaction objects
            _buttons = new List <Crawler.Frontend.Button>();
            _mapview = new MapTiles(this);

            _buttons.Add(new Frontend.Button("Map-Level", ToggleMap, 120, -1, -1, _opener.ClientRectangle.Height - 28));
            _buttons.Add(new Frontend.Button("Quit", Quit, -1, 5, _opener.ClientRectangle.Width - 5, -1));
            //  _buttons.Add(new Frontend.Button("Edit", Edit, -1, 5, _opener.ClientRectangle.Width - 64, -1));
            _buttons.Add(new Frontend.Button("Save", Save, -1, 5, _opener.ClientRectangle.Width - 114, -1));
            // _buttons.Add(new Frontend.Button("File", File, -1, 5, _opener.ClientRectangle.Width - 177, -1));

            _buttons.Add(new Frontend.Button("+", ZoomPageIn, -1, -1, _opener.ClientRectangle.Width - 130, _opener.ClientRectangle.Height - 28));
            _buttons.Add(new Frontend.Button("-", ZoomPageOut, -1, -1, _opener.ClientRectangle.Width - 105, _opener.ClientRectangle.Height - 28));

            _buttons.Add(new Frontend.Button("+", ZoomMapIn, 55, -1, -1, _opener.ClientRectangle.Height - 28));
            _buttons.Add(new Frontend.Button("-", ZoomMapOut, 29, -1, -1, _opener.ClientRectangle.Height - 28));


            _buttons.Add(new Frontend.Button("<", PrevPage, -1, -1, _opener.ClientRectangle.Width - 50, _opener.ClientRectangle.Height - 28));
            _buttons.Add(new Frontend.Button(">", NextPage, -1, -1, _opener.ClientRectangle.Width - 17, _opener.ClientRectangle.Height - 28));
        }
示例#2
0
        public Dispatcher(MainWindow opener)
        {
            // References to Frontend and Backend objects
            _opener = opener;
            _input = new Input(this);
            _timer = new EventLoop(this);
            _output = new Draw(this);
            _toolbox = new Toolbox(this, "images/terrain_atlas.png", new System.Drawing.Rectangle(_opener.ClientRectangle.Width - 325, 60, 320, _opener.ClientRectangle.Height - 130));
            _map = new Backend.Map(this, "start");
            if (_map.Width < 1)
            {
                _map = new Backend.Map(this, 10, 10, false);
            }
            _attachedImagePos = new System.Drawing.Rectangle();

            // Hook up Delegates
            Refresh += _output.Refresh;
            Move += _input.Move;
            Click += _input.Click;
            Keyboard += _input.Keyboard;
            Repaint();

            // Generate lists for interaction objects
            _buttons = new List<Crawler.Frontend.Button>();
            _mapview = new MapTiles(this);

            _buttons.Add(new Frontend.Button("Map-Level", ToggleMap, 120, -1, -1, _opener.ClientRectangle.Height - 28));
            _buttons.Add(new Frontend.Button("Quit", Quit, -1, 5, _opener.ClientRectangle.Width - 5, -1));
            //  _buttons.Add(new Frontend.Button("Edit", Edit, -1, 5, _opener.ClientRectangle.Width - 64, -1));
            _buttons.Add(new Frontend.Button("Save", Save, -1, 5, _opener.ClientRectangle.Width - 114, -1));
            // _buttons.Add(new Frontend.Button("File", File, -1, 5, _opener.ClientRectangle.Width - 177, -1));

            _buttons.Add(new Frontend.Button("+", ZoomPageIn, -1, -1, _opener.ClientRectangle.Width - 130, _opener.ClientRectangle.Height - 28));
            _buttons.Add(new Frontend.Button("-", ZoomPageOut, -1, -1, _opener.ClientRectangle.Width - 105, _opener.ClientRectangle.Height - 28));

            _buttons.Add(new Frontend.Button("+", ZoomMapIn, 55, -1, -1, _opener.ClientRectangle.Height - 28));
            _buttons.Add(new Frontend.Button("-", ZoomMapOut, 29, -1, -1, _opener.ClientRectangle.Height - 28));

            _buttons.Add(new Frontend.Button("<", PrevPage, -1, -1, _opener.ClientRectangle.Width - 50, _opener.ClientRectangle.Height - 28));
            _buttons.Add(new Frontend.Button(">", NextPage, -1, -1, _opener.ClientRectangle.Width - 17, _opener.ClientRectangle.Height - 28));
        }
        public ZXSpectrumComputer()
        {
            // -- Initialize components --

            // System clock
            Clock = new _Clock(Clock.FREQ_3_5MHZ);
            // Init CPU
            CPU = new _Z80CPU();
            // Reset button
            ResetButton = new Button(SignalState.HIGH);

            // ZX Spectrum memory map
            /// NB : in the real machine, there is also a multiplexed address bus for each device :
            /// select row (7 bits) then select colum (7bits).
            /// Row and column address strobe - RAS/CAS - signals must therefore be generated.
            /// We do not simulate theses details here, as they are complex to understand
            /// and can be ignored without losing any fildelity to the behavior of the machine.

            // 16K ROM
            // 0 - 16383 : ROM Program
            ROM = new _ROM();
            // 16K RAM
            // 16384 - 23295 : Video display memory (6910 bytes)
            // 23296 -  : System variables
            // User programs
            RAM16K = new _DualAccessMemoryMappedChip(Memory.BYTES_16K, 0x4000);
            // 32K RAM (only in 48K models)
            RAM32K = new _MemoryMappedChip(Memory.BYTES_32K, 0x8000);

            // Initialize ULA :
            //   Video generator
            //   CPU clock generator
            //   Memory access governor
            //   Keyboard controller
            //   Tape I/O controller
            //   Speaker controller
            ULA = new _ULA();

            // Initialize peripherals
            Keyboard     = new _Keyboard();
            Screen       = new _Screen();
            Speaker      = new _Speaker();
            TapeRecorder = new _TapeRecorder();

            // Initialize Sinclair joysticks
            Joystick1 = new Joystick(true, Keyboard);
            Joystick2 = new Joystick(false, Keyboard);

            // -- Initialize and connect system buses --

            // CPU buses
            AddressBus = new Bus <ushort>();
            DataBus    = new Bus <byte>();
            CPU.Address.ConnectTo(AddressBus);
            CPU.Data.ConnectTo(DataBus);
            ROM.Address.ConnectTo(AddressBus);
            ROM.Data.ConnectTo(DataBus);
            RAM16K.AddressInput1.ConnectTo(AddressBus);
            RAM16K.DataInput1.ConnectTo(DataBus);
            RAM32K.Address.ConnectTo(AddressBus);
            RAM32K.Data.ConnectTo(DataBus);
            ULA.Address.ConnectTo(AddressBus);
            ULA.Data.ConnectTo(DataBus);

            // Dedicated video buses : firect Video Memory Access for the ULA
            VideoAddressBus = new Bus <ushort>();
            VideoDataBus    = new Bus <byte>();
            ULA.VideoAddress.ConnectTo(VideoAddressBus);
            ULA.VideoData.ConnectTo(VideoDataBus);
            RAM16K.AddressInput2.ConnectTo(VideoAddressBus);
            RAM16K.DataInput2.ConnectTo(VideoDataBus);

            // Connect Keyboard to the ULA
            KeyboardDataBus = new Bus <byte>();
            ULA.KeyboardData.ConnectTo(KeyboardDataBus);
            Keyboard.Address.ConnectTo(AddressBus);
            Keyboard.Data.ConnectTo(KeyboardDataBus);

            // Connect ULA analog video signal to screen
            ULA.ColorSignal.ConnectTo(Screen.ColorSignal);

            // Connect tape recorder sound output to ULA
            TapeRecorder.SoundSignal.ConnectTo(ULA.TapeInputSignal);

            // Connect ULA sound output to the speaker
            ULA.SpeakerSoundSignal.ConnectTo(Speaker.SoundSignal);

            // -- Connect individual PINs --

            ((_Clock)Clock).ConnectTo(ULA, Screen, TapeRecorder);
            ((_Z80CPU)CPU).ConnectTo(ResetButton, ULA, ROM, RAM16K, RAM32K);
            ((_ROM)ROM).ConnectTo(CPU);
            ((_DualAccessMemoryMappedChip)RAM16K).ConnectTo(CPU, ULA);
            ((_MemoryMappedChip)RAM32K).ConnectTo(CPU);
            ((_ULA)ULA).ConnectTo(Clock, CPU, RAM16K, Keyboard, Screen, Speaker);
            ((_Keyboard)Keyboard).ConnectTo(ULA);
            ((_Screen)Screen).ConnectTo(ULA);
            ((_Speaker)Speaker).ConnectTo(ULA);
            ((_TapeRecorder)TapeRecorder).ConnectTo(Clock);
        }
        public ZXSpectrumComputer()
        {
            // -- Initialize components --

            // System clock
            Clock = new _Clock(Clock.FREQ_3_5MHZ);
            // Init CPU
            CPU = new _Z80CPU();
            // Reset button
            ResetButton = new Button(SignalState.HIGH);

            // ZX Spectrum memory map
            /// NB : in the real machine, there is also a multiplexed address bus for each device :
            /// select row (7 bits) then select colum (7bits).
            /// Row and column address strobe - RAS/CAS - signals must therefore be generated.
            /// We do not simulate theses details here, as they are complex to understand
            /// and can be ignored without losing any fildelity to the behavior of the machine.

            // 16K ROM
            // 0 - 16383 : ROM Program
            ROM = new _ROM();
            // 16K RAM
            // 16384 - 23295 : Video display memory (6910 bytes)
            // 23296 -  : System variables
            // User programs
            RAM16K = new _DualAccessMemoryMappedChip(Memory.BYTES_16K, 0x4000);
            // 32K RAM (only in 48K models)
            RAM32K = new _MemoryMappedChip(Memory.BYTES_32K, 0x8000);

            // Initialize ULA :
            //   Video generator
            //   CPU clock generator
            //   Memory access governor
            //   Keyboard controller
            //   Tape I/O controller
            //   Speaker controller
            ULA = new _ULA();

            // Initialize peripherals
            Keyboard = new _Keyboard();
            Screen = new _Screen();
            Speaker = new _Speaker();
            TapeRecorder = new _TapeRecorder();

            // Initialize Sinclair joysticks
            Joystick1 = new Joystick(true, Keyboard);
            Joystick2 = new Joystick(false, Keyboard);

            // -- Initialize and connect system buses --

            // CPU buses
            AddressBus = new Bus<ushort>();
            DataBus = new Bus<byte>();
            CPU.Address.ConnectTo(AddressBus);
            CPU.Data.ConnectTo(DataBus);
            ROM.Address.ConnectTo(AddressBus);
            ROM.Data.ConnectTo(DataBus);
            RAM16K.AddressInput1.ConnectTo(AddressBus);
            RAM16K.DataInput1.ConnectTo(DataBus);
            RAM32K.Address.ConnectTo(AddressBus);
            RAM32K.Data.ConnectTo(DataBus);
            ULA.Address.ConnectTo(AddressBus);
            ULA.Data.ConnectTo(DataBus);

            // Dedicated video buses : firect Video Memory Access for the ULA
            VideoAddressBus = new Bus<ushort>();
            VideoDataBus = new Bus<byte>();
            ULA.VideoAddress.ConnectTo(VideoAddressBus);
            ULA.VideoData.ConnectTo(VideoDataBus);
            RAM16K.AddressInput2.ConnectTo(VideoAddressBus);
            RAM16K.DataInput2.ConnectTo(VideoDataBus);

            // Connect Keyboard to the ULA
            KeyboardDataBus = new Bus<byte>();
            ULA.KeyboardData.ConnectTo(KeyboardDataBus);
            Keyboard.Address.ConnectTo(AddressBus);
            Keyboard.Data.ConnectTo(KeyboardDataBus);

             // Connect ULA analog video signal to screen
            ULA.ColorSignal.ConnectTo(Screen.ColorSignal);

            // Connect tape recorder sound output to ULA
            TapeRecorder.SoundSignal.ConnectTo(ULA.TapeInputSignal);

            // Connect ULA sound output to the speaker
            ULA.SpeakerSoundSignal.ConnectTo(Speaker.SoundSignal);

            // -- Connect individual PINs --

            ((_Clock)Clock).ConnectTo(ULA, Screen, TapeRecorder);
            ((_Z80CPU)CPU).ConnectTo(ResetButton, ULA, ROM, RAM16K, RAM32K);
            ((_ROM)ROM).ConnectTo(CPU);
            ((_DualAccessMemoryMappedChip)RAM16K).ConnectTo(CPU, ULA);
            ((_MemoryMappedChip)RAM32K).ConnectTo(CPU);
            ((_ULA)ULA).ConnectTo(Clock, CPU, RAM16K, Keyboard, Screen, Speaker);
            ((_Keyboard)Keyboard).ConnectTo(ULA);
            ((_Screen)Screen).ConnectTo(ULA);
            ((_Speaker)Speaker).ConnectTo(ULA);
            ((_TapeRecorder)TapeRecorder).ConnectTo(Clock);
        }
示例#5
0
 public HookGlobal(HookPlugin plugin)
 {
     this.plugin = plugin;
     Keyboard    = new _Keyboard(this.plugin);
     Mouse       = new _Mouse(this.plugin);
 }