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)); }
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)); }
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()) } }))); }
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() }, }))); }
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 ))); }
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") }, }))); }
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() }, }))); }
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; }
public static bool IsGetGameAvailable(FantasyConsole fc) { var gameName = fc.Mem.ActiveGameName; return(!string.IsNullOrEmpty(gameName)); }
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)); }