Beispiel #1
0
        private static void MachineOperator_OnPaused(MachineOperator mo, PausedEventArgs e)
        {
            string saveStateFile = @"s:\source\repos\Robotron_2084\VirtuRoC\tmp\save_state.bin";

            if (e.BreakpointRCP == _workbench.AsmService.GetAddress("doneAtari"))
            {
                _machineOperator.Machine.SaveStateToFile(saveStateFile);
                try {
                    Cpu cpu = _machineOperator.Machine.Cpu;

                    int divideAX = _workbench.AsmService.GetAddress("divideAX");
                    int rts      = _workbench.AsmService.GetAddress("divideAX_RTS");

                    long min = 10000;
                    long max = 0;

                    for (int A = 0; A <= 255; A++)
                    {
                        for (int X = 1; X <= 255; X++)
                        {
                            cpu.RPC = divideAX;
                            long cycles = Execute4C00(cpu, divideAX, rts, A, X, A / X, A % X);
                            min = cycles < min ? cycles : min;
                            max = cycles > max ? cycles : max;
                        }
                    }

                    Trace.WriteLine($"min={min}, max={max}");
                } finally {
                    _machineOperator.LoadStateFromFile(saveStateFile);
                }
            }
        }
        public void mo_OnPause(MachineOperator mo, PausedEventArgs e)
        {
            FlushLog();

            _mo.MainPage.StateText = SafeGetLabel(e.BreakpointRCP);

            switch (e.PausedReason)
            {
            case PausedReason.Breakpoint:
                _sm.Fire(_breakpointTrigger, e);
                break;

            case PausedReason.Keypress:
                // do nothing
                // it doesn't help to see a partial log, better execute until next breakpoint
                break;
            }
        }
Beispiel #3
0
        private void mo_OnPause(MachineOperator mo, PausedEventArgs e)
        {
            _script.mo_OnPause(mo, e);

            TraceLine($"executed: {_executed}, reads: {_reads}, writes: {_writes}");

            using (var writer = new StreamWriter(@"s:\source\repos\Robotron_2084\VirtuRoC\tmp\MemoryOperations.csv"))
                using (var csv = new CsvWriter(writer, Thread.CurrentThread.CurrentCulture)) {
                    csv.WriteRecords(RecordedOperations.MemoryOperations);
                }

            using (var writer = new StreamWriter(@"s:\source\repos\Robotron_2084\VirtuRoC\tmp\ExecutedOperations.csv"))
                using (var csv = new CsvWriter(writer, Thread.CurrentThread.CurrentCulture)) {
                    csv.WriteRecords(RecordedOperations.ExecutedOperations);
                }

            _window1.ScrollToAddress(e.BreakpointRCP);

            // TODO: Warum brauchen wir hier auch ein MainPage.Focus() ?
            _mo.MainPage.Focus();
        }
        private void sm_OnEntry_YouDrawn(PausedEventArgs e)
        {
            // TODO: check for correct breakpoint, if not then exit script

            SortedDictionary <int, int> counts = new SortedDictionary <int, int>();


            foreach (Tuple <string, int, int> tuple in _calls)
            {
                (string opcode, int opcodeRPC, int rpc) = tuple;

                switch (opcode)
                {
                case "JSR":
                    WriteLog($"{SafeGetLabel(opcodeRPC)}: JSR {SafeGetLabel(rpc)}");
                    IndentLog();

                    counts[rpc] = (counts.ContainsKey(rpc) ? counts[rpc] : 0) + 1;
                    break;

                case "RTS":
                    UnindentLog();
                    break;
                }
            }


            foreach (KeyValuePair <int, int> pair in counts)
            {
                string addr = SafeGetLabel(pair.Key);
                Trace.WriteLine($"{addr}: {pair.Value}");
            }

            _calls.Clear();

            _stackTracker.DumpStack();
            _stackTracker.DumpJsrInfoList();
            _stackTracker.StopTracking();
        }