Exemple #1
0
        private void Cpu_AfterInstructionExecution(object sender, InstructionEventArgs e)
        {
            if (cycleStartTime == null && prevValue == (outputLatch.Value & SpeakerBit))
            {
                prevValue = outputLatch.Value & SpeakerBit;
                return;
            }
            prevValue = outputLatch.Value & SpeakerBit;

            if (cycleStartTime == null)
            {
                StartCycle();
            }

            instructionCount++;
            outputLatchHistory.Add(outputLatch.Value);

            var elapsedMs = (systemTime.Now - cycleStartTime.Value).TotalMilliseconds;

            if (elapsedMs > targetCycleLengthMs)
            {
                new Thread(() => { GenerateSound(elapsedMs, outputLatchHistory); }).Start();
                cycleStartTime = null;//wait for next transition
            }
        }
Exemple #2
0
        protected virtual void OnInstruction(Instruction instruction)
        {
            CpuEventHandler <InstructionEventArgs> handler = Instruction;

            if (handler != null)
            {
                InstructionEventArgs args = new InstructionEventArgs
                {
                    OpCode = instruction.OpCode,
                    Cycles = instruction.Cycles
                };

                handler(this, args);
            }
        }