public MainForm() { InitializeComponent(); this.spinningTriangleControl.Size = GetControlSize(); chip8 = new Chip8(); // Create an emulator renderer control that will be displayed when a ROM is loaded this.emulatorRendererControl = new Chip8Emulator.GraphicsControls.EmulatorRendererControl(chip8); this.emulatorRendererControl.Location = new System.Drawing.Point(0, 24); this.emulatorRendererControl.Margin = new Padding(0); this.emulatorRendererControl.Name = "emulatorRendererControl"; this.emulatorRendererControl.TabIndex = 1; this.emulatorRendererControl.Text = "Emulator renderer control"; // Attaching the key listeners to the renderer control this.emulatorRendererControl.KeyUp += new KeyEventHandler(KeyUpHandler); this.emulatorRendererControl.KeyDown += new KeyEventHandler(KeyDownHandler); // Loading a soundplayer and a sound file System.Reflection.Assembly a = System.Reflection.Assembly.GetExecutingAssembly(); String[] hurr = a.GetManifestResourceNames(); System.IO.Stream s = a.GetManifestResourceStream("Chip8Emulator.Resources.durr_quiet.wav"); player = new SoundPlayer(s); sw = Stopwatch.StartNew(); // Setting the timer to tick 60 times per second // the timer is started when loading applications and stopped unloading //refreshTimer = new Timer(); //refreshTimer.Interval = 1000 / 60; //refreshTimer.Tick += delegate { this.UpdateScreen(); }; }
public Screen(Chip8 chip8) { _cpu = chip8.Cpu; _width = InternalWidth * Pixel.PixelWidth; _height = InternalHeight * Pixel.PixelHeight; _pixels = new Pixel[InternalWidth][]; for (int i = 0; i < InternalWidth; i++) _pixels[i] = new Pixel[InternalHeight]; }
private bool _waitForInput; // Utilisé par FX0A afin d'attendre une entrée clavier #endregion Fields #region Constructors public Cpu(Chip8 chip8) { this._memory = new byte[SharpChip8.Core.Memory.MemorySize]; this._V = new byte[16]; this._I = 0; this._stack = new Stack<ushort>(16); this._stackSize = 0; this._delayTimer = 0; this._soundTimer = 0; this._Pc = SharpChip8.Core.Memory.StartAddress; this._hp48 = new ushort[8]; this._opcode = Opcode.GetOpcodeTable(); this._input = new Input(); this._chip8 = chip8; this._running = false; // Le processeur n'est pas démarré à la création this._waitForInput = false; this._currentOpcode = 0x0; ResetMemory(); Reset(); }
public BaseCommand(Chip8 chip) { Chip = chip; }
public x8XY5(ushort opcode, Chip8 chip) : base(chip) { X = (opcode & 0x0F00) >> 8; Y = (opcode & 0x00F0) >> 4; }
public x3XNN(ushort opcode, Chip8 chip) : base(chip) { X = (opcode & 0x0F00) >> 8; NN = (opcode & 0x00FF); }
public OpcodeParser(Chip8 chip8Device) { this._chip8Device = chip8Device; this._instructionResolver = new InstructionResolver(); }
public xBNNN(ushort opcode, Chip8 chip) : base(chip) { NNN = (ushort)(opcode & 0x0FFF); }
public void Execute(Chip8 chip8Device, Opcode opcode) { byte registerX = (byte)((opcode.Value & 0x0F00) >> 8); chip8Device.SoundTimer = chip8Device.RegisterBank.V[registerX]; }
static void Main(string[] args) { if (args.Length == 0) { Console.WriteLine("Error no ROM file specified"); return; } else { bool debugMode = false; int filePathIndex = 0; if (args[0].ToUpper() == "-DEBUG") { debugMode = true; filePathIndex = 1; } if (!File.Exists(args[filePathIndex])) { Console.WriteLine($"Error ROM file ({args[filePathIndex]}) not found."); } else { audio = new Audio(); input = new Input(); graphics = new Graphics(); chp8 = new Chip8(graphics, audio, input); //byte[] rom = LoadROMFile(@"/home/chippy/src/dotnet/core-chip8/chip8.roms/PONG"); byte[] rom = LoadROMFile(args[filePathIndex]); //LoadROM chp8.LoadROM(rom); try { Gtk.Application.Init(); emulatorWindow = new EmulatorWindow("Core Chip8"); emulatorWindow.DeleteEvent += delegate { KILL_EMULATION = true; Gtk.Application.Quit(); }; if (debugMode) { LoadDebugEnvironment(); } emulatorWindow.KeyPressEvent += new KeyPressEventHandler(input.KeyPressEventHandler); emulatorWindow.ShowAll(); Thread t = new Thread(new ThreadStart(BackgroundTick)); t.Start(); Gtk.Application.Run(); } catch (Exception e) { Console.WriteLine(e); throw; } } } }
// Use this for initialization void Start() { chip = GetComponent <Chip8>(); startEmulation(txt.bytes); }
public void Execute(Chip8 chip8Device, Opcode opcode) { ushort address = (ushort)(opcode.Value & 0x0FFF); chip8Device.RegisterBank.I = address; }
public Disassembler(Chip8 chip8) { _chip8 = chip8; asmWithoutLineNumber = String.Empty; asmWithLineNumber = String.Empty; }
public void Execute(Chip8 chip8Device, Opcode opcode) { byte registerX = (byte)((opcode.Value & 0x0F00) >> 8); chip8Device.RegisterBank.I = (ushort)(chip8Device.RegisterBank.V[registerX] * 5); }
protected override void OnLoad() { base.OnLoad(); GL.Enable(EnableCap.DebugOutput); DebugProc openGLDebugDelegate = new DebugProc(OpenGLDebugCallback); GL.DebugMessageCallback(openGLDebugDelegate, IntPtr.Zero); // Create shader shader = new Shader("Shaders/shader.vert", "Shaders/shader.frag"); shader.Use(); // Create target texture textureHandle = GL.GenTexture(); GL.BindTexture(TextureTarget.Texture2D, textureHandle); GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureWrapS, (int)TextureWrapMode.Repeat); GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureWrapT, (int)TextureWrapMode.Repeat); GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMinFilter, (int)TextureMinFilter.Nearest); GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMagFilter, (int)TextureMagFilter.Nearest); Random random = new Random(); byte[] pixels = new byte[64 * 32]; for (int i = 0; i < 64 * 32; i++) { pixels[i] = (byte)(random.NextDouble() * 255.0f); } GL.TexImage2D(TextureTarget.Texture2D, 0, PixelInternalFormat.R8, 64, 32, 0, PixelFormat.Red, PixelType.UnsignedByte, pixels); // Create mesh float[] vertices = new float[] { // vec2 position // vec2 texCoord // Top left triangle -1, -1, 0, 1, 1, -1, 1, 1, -1, 1, 0, 0, // Bottom right triangle 1, -1, 1, 1, 1, 1, 1, 0, -1, 1, 0, 0, }; vboHandle = GL.GenBuffer(); vaoHandle = GL.GenVertexArray(); GL.BindVertexArray(vaoHandle); GL.BindBuffer(BufferTarget.ArrayBuffer, vboHandle); GL.EnableVertexAttribArray(0); GL.VertexAttribPointer(0, 2, VertexAttribPointerType.Float, false, 4 * sizeof(float), 0 * sizeof(float)); GL.EnableVertexAttribArray(1); GL.VertexAttribPointer(1, 2, VertexAttribPointerType.Float, false, 4 * sizeof(float), 2 * sizeof(float)); GL.BindVertexArray(vaoHandle); GL.BufferData(BufferTarget.ArrayBuffer, vertices.Length * sizeof(float), vertices, BufferUsageHint.StreamDraw); // Load program byte[] fileBytes = File.ReadAllBytes("Roms/life.ch8"); // Create emulator ushort[] instructions = new ushort[] { 0x00E0, 0xF029, 0xD115, 0x7001, 0x1200 }; chip8 = new Chip8(fileBytes); //chip8 = new Chip8(instructions); chip8.DumpMemory(); }
public void Execute(Chip8 chip8Device, Opcode opcode) { chip8Device.RegisterBank.I += (chip8Device.RegisterBank.V[((opcode.Value & 0x0F00) >> 8)]); int i = 0; }
public x00E0(Chip8 chip) : base(chip) { }
public void Setup() { chip8 = new Chip8(); chip8.Initalize(); }
public xFX18(ushort opcode, Chip8 chip) : base(chip) { X = (opcode & 0x0F00) >> 8; }
public x2NNN(ushort opcode, Chip8 chip) : base(chip) { address = (ushort)(opcode & 0x0FFF); }
public Disassembler(Chip8 chip8) { _chip8 = chip8; asmWithoutLineNumber = String.Empty; asmWithLineNumber = String.Empty; }
public void Execute(Chip8 chip8Device, Opcode opcode) { chip8Device.RegisterBank.PC = chip8Device.Cpu.Stack.Pop(); }