void RunEmulator() { Console.WriteLine("Starting emulator"); while (true) { try { speccy.DoIntructions(69888 * 50); Console.WriteLine("OnCycle"); var screen = speccy.GetScreenInUint(true); Console.WriteLine("Got screen"); //graphics.Clear(); for (int y = 0; y < 128; y++) { for (int x = 0; x < 128; x++) { graphics.DrawPixel(x, y, Color.FromUint(screen[(y * 256 * 2) + x * 2])); } } graphics.Show(); Console.WriteLine("Showing screen"); } catch (Exception ex) { Console.WriteLine(ex.Message); } } }
//uint[] screen = new uint[68672]; //Height * width (256+20+20)*(192+20+20) public async void Paint() { if (flashcounter == 0) { flashcounter = 16; flash = !flash; } else { flashcounter--; } var screen = speccy.GetScreenInUint(flash); //Allocate memory var gch = GCHandle.Alloc(screen, GCHandleType.Pinned); var pinned = gch.AddrOfPinnedObject(); var mono = JSRuntime as WebAssemblyJSRuntime; mono.InvokeUnmarshalled <IntPtr, string>("PaintCanvas", pinned); gch.Free(); }