Exemple #1
0
        protected override LaunchResponse HandleLaunchRequest(LaunchArguments arguments)
        {
            var romPath  = (string)arguments.ConfigurationProperties["rom"];
            var sramPath = (string)arguments.ConfigurationProperties["sram"];
            var mapPath  = (string)arguments.ConfigurationProperties["map"];

            Host.LoadGame(romPath);
            var sram = new Sram(Host, sramPath);

            sram.Load();
            DebugMap      = new DebugMap(mapPath);
            HostWindowCTS = new CancellationTokenSource();

            HostTask = Task.Run(
                () =>
            {
                using (var w = new MegaDriveWindow())
                {
                    w.Run(sram, Host, HostWindowCTS.Token);
                }
                Protocol.SendEvent(new TerminatedEvent());
                Protocol.SendEvent(new ExitedEvent(0));
            });

            Protocol.SendEvent(new InitializedEvent());
            return(new LaunchResponse());
        }
Exemple #2
0
        protected override EvaluateResponse HandleEvaluateRequest(EvaluateArguments arguments)
        {
            var expression    = arguments.Expression;
            var symbolAddress = DebugMap?.GetSymbolAddress(expression.Trim());

            if (symbolAddress.HasValue)
            {
                expression = $"[{symbolAddress.Value}]";
            }

            var result = Controller.Evaluate(expression);

            if (result != null)
            {
                return(new EvaluateResponse()
                {
                    Result = result
                });
            }
            else
            {
                return(new EvaluateResponse()
                {
                    Result = "<unknown symbol>",
                    PresentationHint = new VariablePresentationHint()
                    {
                        Attributes = VariablePresentationHint.AttributesValue.FailedEvaluation
                    }
                });
            }
        }
Exemple #3
0
    void Awake()
    {
        tetrominoGravity      = new GameObject().AddComponent <Gravity>();
        tetrominoGravity.name = "TetrominoGravity";

        gridGravity      = new GameObject().AddComponent <Gravity>();
        gridGravity.name = "GridGravity";


        scaleFactor           = 16;
        scaleVector           = Vector3Int.one * (scaleFactor - 1);
        transform.localScale += scaleVector;

        transform.position = new Vector3Int(1, -10 * scaleFactor, 0);

        mainCamera = GameObject.Find("Main Camera").GetComponent <Camera>();
        mainCamera.orthographicSize = 12 * scaleFactor;

        basePosition = Vector3Utils.ToVector3Int(transform.position) + new Vector3Int(scaleFactor, scaleFactor, 0);

        tetrominoSpawner = Instantiate(tetrominoSpawnerPrefab).GetComponent <TetrominoSpawner>();
        tetrominoSpawner.Initialize(this);

        pistonSpawner = Instantiate(pistonSpawnerPrefab).GetComponent <PistonSpawner>();
        pistonSpawner.Initialize(this);

        pistonMask = GameObject.Find("PistonMask");
        pistonMask.transform.position    = transform.position + scaleFactor * new Vector3(5.5f, 10.5f, 0);
        pistonMask.transform.localScale += scaleVector;

        debugMap = GameObject.Find("DebugMap").GetComponent <DebugMap>();
        debugMap.transform.position    = scaleFactor * debugMap.transform.position;
        debugMap.transform.localScale += scaleVector;

        grid = new Transform[gridWidth, gridHeight];

        gridUtils.Initialize(grid);

        //rowSlider = new GameObject().AddComponent<RowSlider>();
        //rowSlider.name = "RowSlider";
        //rowSlider.Initialize(this);

        SpawnNextTetromino();

        rowPosition = new Vector3[Map.gridHeight];
        ResetRowPosition();

        currentTetromino.ImmediateFall(playerPrefab);
    }
Exemple #4
0
        protected override StackTraceResponse HandleStackTraceRequest(StackTraceArguments arguments)
        {
            var stackFrames = new List <StackFrame>();

            var frames = Controller.CallStack.ToArray();

            if (frames.Length > 0)
            {
                PushStackFrame(Controller.PC, frames[0].SubroutineAddress);
            }
            for (int i = 1; i < frames.Length; i++)
            {
                PushStackFrame(frames[i - 1].ReturnAddress, frames[i].SubroutineAddress);
            }

            return(new StackTraceResponse()
            {
                StackFrames = stackFrames,
                TotalFrames = stackFrames.Count
            });

            void PushStackFrame(uint address, uint subroutine)
            {
                var frame   = new StackFrame();
                var mapping = DebugMap?.GetMapping(address);

                if (mapping.HasValue)
                {
                    frame.Line   = mapping.Value.Line;
                    frame.Name   = DebugMap.FindNearestLabel(subroutine) ?? "???";
                    frame.Source = new Source()
                    {
                        Path = mapping.Value.Path
                    };
                }
                else
                {
                    frame.Name = "???";
                }
                stackFrames.Add(frame);
            }
        }
Exemple #5
0
        protected override SetBreakpointsResponse HandleSetBreakpointsRequest(SetBreakpointsArguments arguments)
        {
            var breakpoints = new List <Breakpoint>();
            var addresses   = new List <uint>();

            foreach (var bp in arguments.Breakpoints)
            {
                bool foundLine = false;
                for (int i = 0; i < 4; i++)
                {
                    var mapping = DebugMap?.GetMapping(arguments.Source.Path, bp.Line + i);
                    if (mapping.HasValue)
                    {
                        foundLine = true;
                        breakpoints.Add(new Breakpoint()
                        {
                            Line     = mapping.Value.Line,
                            Verified = true
                        });
                        addresses.Add(mapping.Value.Address);
                        break;
                    }
                }
                if (!foundLine)
                {
                    breakpoints.Add(new Breakpoint()
                    {
                        Line     = bp.Line,
                        Verified = false
                    });
                }
            }

            Controller.Breakpoints = addresses.ToImmutableArray();

            return(new SetBreakpointsResponse(breakpoints));
        }