Example #1
0
        // CONSTRUCTOR

        public Computer(IScreen Screen, ISound Sound, ITimer Timer, ISettings Settings, IDialogs Dialogs)
        {
            ulong ticksPerSoundSample = Clock.TICKS_PER_SECOND / (ulong)Sound.SampleRate;

            HasRunYet = false;

            screen   = Screen;
            settings = Settings;
            dialogs  = Dialogs;
            sound    = Sound;

            Storage.Initialize(settings, dialogs);

            memory    = new Memory();
            intMgr    = new InterruptManager(this);
            this.tape = new Tape(this);
            ports     = new PortSet(this);
            cpu       = new Z80.Z80(this);
            printer   = new Printer();

            if (sound.Stopped)
            {
                sound = new SoundNull();
            }
            else
            {
                sound.SampleCallback = ports.CassetteOut;
            }

            clock = new Clock(this,
                              cpu,
                              Timer,
                              intMgr,
                              ticksPerSoundSample,
                              Sound.Sample);

            clock.SpeedChanged += () => Sound.Mute = clock.ClockSpeed != ClockSpeed.Normal;

            DiskUserEnabled = Settings.DiskEnabled;

            floppyController = new FloppyController(this, ports, clock, intMgr, Sound, DiskUserEnabled);

            intMgr.Initialize(ports, this.tape);
            this.tape.Initialize(clock, intMgr);
            ports.Initialize(floppyController, intMgr, this.tape, printer);

            for (byte i = 0; i < 4; i++)
            {
                LoadFloppy(i);
            }

            var tape = Storage.LastTapeFile;

            if (tape.Length > 0 && File.Exists(tape))
            {
                TapeLoad(tape);
            }

            DriveNoise   = Settings.DriveNoise;
            BreakPoint   = Settings.Breakpoint;
            BreakPointOn = Settings.BreakpointOn;
            SoundOn      = Settings.SoundOn;
            ClockSpeed   = Settings.ClockSpeed;
            Ready        = true;
        }
Example #2
0
 public void Initialize(PortSet Ports, Tape Tape)
 {
     ports = Ports;
     tape  = Tape;
 }