示例#1
0
 public SysDriver(FantasyConsole fc)
 {
     _fc                   = fc;
     _drivers              = new List <Driver>();
     _drivers.Add(FS       = new FileSystemDriver());
     _drivers.Add(Input    = new InputDriver(_fc.Mem.InputBuffer));
     _drivers.Add(Console  = new ConsoleDriver(_fc.Mem.TextBuffer));
     _drivers.Add(Graphics = new GraphicsDriver(_fc.Mem));
     _drivers.Add(Menu     = new MenuDriver(Input, Console));
     _drivers.Add(Game     = new GameDriver(this, _fc.Mem));
 }
示例#2
0
        public ActionResult PutGameCode(
            [FromServices] FantasyConsole fc,
            GameCodeDto gameCodeDto)
        {
            if (!IsGetGameAvailable(fc))
            {
                return(NotFound());
            }

            fc.Mem.CodeBuffer = gameCodeDto.Data;
            fc.Sys.Game.Save();

            return(Redirect(GetGameCodeLink().Href));
        }
示例#3
0
        public ActionResult <GameSpriteDto> GetGameSprite(int i, [FromServices] FantasyConsole fc)
        {
            if (!IsGetGameAvailable(fc))
            {
                return(NotFound());
            }

            return(Ok(new GameSpriteDto(
                          fc.Mem.SpriteBuffer[(byte)i].Select(b => (int)b).ToArray(),
                          new Dictionary <string, LinkDto>
            {
                { "parent", GetAllGameSpritesLink() },
                { "self", GetGameSpriteLink(i.ToString()) }
            })));
        }
示例#4
0
        public ActionResult <GameCodeDto> GetGameCode([FromServices] FantasyConsole fc)
        {
            if (!IsGetGameAvailable(fc))
            {
                return(NotFound());
            }

            return(Ok(new GameCodeDto(
                          fc.Mem.CodeBuffer,
                          new Dictionary <string, LinkDto>
            {
                { "parent", GetGameLink() },
                { "self", GetGameCodeLink() },
            })));
        }
示例#5
0
        public ActionResult <AppDto> GetApp([FromServices] FantasyConsole fc)
        {
            var links = new Dictionary <string, LinkDto>
            {
                { "self", GetRootLink() },
            };

            if (GameController.IsGetGameAvailable(fc))
            {
                links.Add("game", GameController.GetGameLink());
            }

            return(Ok(new AppDto(
                          links
                          )));
        }
示例#6
0
        public ActionResult <AllGameSpritesDto> GetAllGameSprites([FromServices] FantasyConsole fc)
        {
            if (!IsGetGameAvailable(fc))
            {
                return(NotFound());
            }

            return(Ok(new AllGameSpritesDto(
                          fc.Mem.SpriteBuffer.Sprites.Select(s => s.Select(b => (int)b).ToArray()).ToArray(),
                          new Dictionary <string, LinkDto>
            {
                { "parent", GetGameLink() },
                { "self", GetAllGameSpritesLink() },
                { "sprite[i]", GetGameSpriteLink(":i") },
            })));
        }
示例#7
0
        public ActionResult <GameDto> GetGame([FromServices] FantasyConsole fc)
        {
            if (!IsGetGameAvailable(fc))
            {
                return(NotFound());
            }

            var gameName = fc.Mem.ActiveGameName;

            return(Ok(new GameDto(
                          gameName,
                          new Dictionary <string, LinkDto>
            {
                { "parent", FC360Controller.GetRootLink() },
                { "self", GetGameLink() },
                { "game.sprites", GetAllGameSpritesLink() },
                { "game.code", GetGameCodeLink() },
            })));
        }
示例#8
0
        protected override void Initialize()
        {
            base.Initialize();

            _fc = new FantasyConsole();
            _fc.PowerOn();

            _vpa = new ViewportAdapter(
                Window,
                GraphicsDevice,
                _fc.Mem.DisplayBuffer.Width,
                _fc.Mem.DisplayBuffer.Height);

            _renderTarget = new Texture2D(GraphicsDevice,
                                          _fc.Mem.DisplayBuffer.Width,
                                          _fc.Mem.DisplayBuffer.Height);

            _pixelData = new Color[_fc.Mem.DisplayBuffer.Width * _fc.Mem.DisplayBuffer.Height];

            Window.TextInput += Window_TextInput;

            var url = "http://localhost:8080";

            Host.CreateDefaultBuilder(new string[] { })
            .ConfigureWebHostDefaults(webBuilder =>
            {
                webBuilder.UseStartup <Startup>();
                webBuilder.UseUrls(url);
                webBuilder.ConfigureServices(s =>
                {
                    s.AddSingleton(_ => _fc);
                });
            })
            .RunConsoleAsync();

            // Testing implementation, TODO: delete
            //_fc.Mem.DisplayBuffer[20, 20] = 7;
            //_fc.Mem.DisplayBuffer[10, 10] = 15;
        }
示例#9
0
        public static bool IsGetGameAvailable(FantasyConsole fc)
        {
            var gameName = fc.Mem.ActiveGameName;

            return(!string.IsNullOrEmpty(gameName));
        }
示例#10
0
        public ActionResult <GameSpriteDto> PutGameSprite(int i, [FromBody] GameSpriteDto dto, [FromServices] FantasyConsole fc)
        {
            if (!IsGetGameAvailable(fc))
            {
                return(NotFound());
            }

            fc.Mem.SpriteBuffer[(byte)i] = new Sprite(dto.Data.Select(i => (byte)i).ToArray());
            fc.Sys.Game.Save();

            return(Redirect(GetGameSpriteLink(i.ToString()).Href));
        }