public NESContext( ICPU cpu, RicohRP2C02 ppu, PixelMuxer pixelMuxer, InputHandler inputHandler, ScrollHandler scrollHandler, PaletteHandler paletteHandler, BackgroundHandler backgroundHandler) { this.CPU = cpu; this.PPU = ppu; this.PixelMuxer = pixelMuxer; this.InputHandler = inputHandler; this.ScrollHandler = scrollHandler; this.PaletteHandler = paletteHandler; this.BackgroundHandler = backgroundHandler; if (File.Exists(Constants.DebugFile)) { File.Delete(Constants.DebugFile); } Log.Logger = new LoggerConfiguration() .MinimumLevel.Verbose() .WriteTo.File ( Constants.DebugFile, outputTemplate: "{Message}{NewLine}", restrictedToMinimumLevel: LogEventLevel.Verbose, flushToDiskInterval: TimeSpan.FromSeconds(10.0) ) .Destructure.ByTransforming <Registers>(Registers.DestructureForLog) .CreateLogger(); }
public void Awake() { this.palette = new PaletteHandler(); this.rend = this.GetComponent <Renderer>(); this.texture = new Texture2D(256, 240, TextureFormat.ARGB32, mipmap: false); this.rend.material.mainTexture = texture; this.ioc = new StandardKernel(new NintendoModule()); this.nes = this.ioc.Get <NES>(); var cartridge = NESLoader.CreateCartridge(@"C:\emulators\nes\games\Super Mario Bros.nes"); this.nes.LoadCartridge(cartridge); this.nes.PowerOn(); this.nesThread = new Thread(NESStep); this.nesThread.Start(); }
public RicohRP2C02( IPPUMemoryMap memoryMap, PPURegisters registers, PPUInternalRegisters internalRegisters, ScrollHandler scrollHandler, PaletteHandler paletteHandler, BackgroundHandler backgroundHandler, PixelMuxer pixelMuxer, SpriteHandler spriteHandler) { this.InternalRegisters = internalRegisters; this.Registers = registers; this.MemoryMap = (PPURawMemoryMap)memoryMap; this.ScrollHandler = scrollHandler; this.PaletteHandler = paletteHandler; this.BackgroundHandler = backgroundHandler; this.SpriteHandler = spriteHandler; this.PixelMuxer = pixelMuxer; }
private void OnGUI() { scroll = GUILayout.BeginScrollView(scroll); { if (!workingTexture || !displayTexture) { Generate(); } if (GUILayout.Button("Save Image")) { string path = EditorUtility.SaveFilePanel("Save Palette", "Textures", "newPalette.png", "png"); File.WriteAllBytes(path, workingTexture.EncodeToPNG()); AssetDatabase.Refresh(); autoTestTex = null; autoTestPalette = null; autoTestEnabled = false; } Texture2D loadTex = (Texture2D)EditorGUILayout.ObjectField("Assign to Load Texture", null, typeof(Texture2D), allowSceneObjects: false); if (loadTex) { FromTexture(loadTex); autoTestTex = null; autoTestPalette = null; autoTestEnabled = false; } EditorGUI.BeginChangeCheck(); GUILayout.Label("Background", EditorStyles.boldLabel); bg = EditorGUILayout.ColorField("Background", bg); bg.a = 1; GUILayout.Space(10); GUILayout.Label("Platforms", EditorStyles.boldLabel); p1 = EditorGUILayout.ColorField("Platform 1", p1); p1.a = 1; p2 = EditorGUILayout.ColorField("Platform 2", p2); p2.a = 1; p3 = EditorGUILayout.ColorField("Platform 3", p3); p3.a = 1; p4 = EditorGUILayout.ColorField("Platform 4", p4); p4.a = 1; al = EditorGUILayout.ColorField("Light Accent", al); al.a = 1; ad = EditorGUILayout.ColorField("Dark Accent", ad); ad.a = 1; GUILayout.Space(10); GUILayout.Label("Player", EditorStyles.boldLabel); pi = EditorGUILayout.ColorField("Player Inside", pi); pi.a = 1; po = EditorGUILayout.ColorField("Player Outline", po); po.a = 1; GUILayout.Space(10); GUILayout.Label("FX", EditorStyles.boldLabel); st = EditorGUILayout.ColorField("Stars", st); st.a = 1; f1 = EditorGUILayout.ColorField("Comet 1", f1); f1.a = 1; f2 = EditorGUILayout.ColorField("Comet 2", f2); f2.a = 1; f3 = EditorGUILayout.ColorField("Comet 3", f3); f3.a = 1; GUILayout.Space(10); GUILayout.Label("UI", EditorStyles.boldLabel); tx = EditorGUILayout.ColorField("HUD Text", tx); tx.a = 1; mt = EditorGUILayout.ColorField("Menu Text", mt); mt.a = 1; hb = EditorGUILayout.ColorField("Hud Background", hb); hb.a = 1; GUILayout.Space(10); GUILayout.Label("REALTIME TESTING", EditorStyles.boldLabel); GUILayout.BeginHorizontal(); autoTestTex = (Texture2D)EditorGUILayout.ObjectField(autoTestTex, typeof(Texture2D), allowSceneObjects: false); autoTestPalette = (Palette)EditorGUILayout.ObjectField(autoTestPalette, typeof(Palette), allowSceneObjects: false); autoTestEnabled = GUILayout.Toggle(autoTestEnabled && Application.isPlaying, "Enable Auto Test (Dangerous)"); GUILayout.EndHorizontal(); bool changed = EditorGUI.EndChangeCheck(); if (changed) { DrawTex(); } GUILayout.Box(displayTexture, GUILayout.Width(400), GUILayout.Height(400)); if (changed && autoTestEnabled && autoTestTex && autoTestPalette) { if (Application.isPlaying) { Graphics.CopyTexture(workingTexture, autoTestTex); autoTestTex.Apply(); autoTestPalette.SetColorsFromPalette(); PaletteHandler.ApplyPalette(autoTestPalette); } } } GUILayout.EndScrollView(); }