public void Set(byte opcode, Func <int> handler) { Asserts.Null( this.impl_[opcode], $"Expected instruction '{ByteFormatter.ToHex8(opcode)}' to not be defined yet."); this.impl_[opcode] = handler; }
public int Call(byte opcode) { var handler = this.impl_[opcode]; if (handler == null) { Asserts.Fail( $"Expected instruction '{ByteFormatter.ToHex8(opcode)}' to be defined."); } return(handler !()); }
private void RenderForOrthographicCamera_( RenderForOrthographicCameraTickEvent evt) { var g = evt.Graphics; this.RenderLcd_(g); g.Primitives.VertexColor(Color.White); var registers = this.mmu_.Registers; var memoryMap = this.mmu_.MemoryMap; var ioAddresses = memoryMap.IoAddresses; var lX = 202; var bY = 145; var t = g.Text; var i = 0; t.Draw(lX, 20 * i++, 16, 16, "pc: " + ByteFormatter.ToHex16(registers.Pc.Value)); i++; t.Draw(lX, 20 * i++, 16, 16, "af: " + ByteFormatter.ToHex16(registers.Af.Value)); t.Draw(lX, 20 * i++, 16, 16, "bc: " + ByteFormatter.ToHex16(registers.Bc.Value)); t.Draw(lX, 20 * i++, 16, 16, "de: " + ByteFormatter.ToHex16(registers.De.Value)); t.Draw(lX, 20 * i++, 16, 16, "hl: " + ByteFormatter.ToHex16(registers.Hl.Value)); i++; lX = 320; i = 0; t.Draw(lX, 20 * i++, 16, 16, "ppu: " + ByteFormatter.ToHex8((byte)this.cpu_.PpuMode)); t.Draw(lX, 20 * i++, 16, 16, "ly: " + ByteFormatter.ToHex8(this.mmu_.MemoryMap.IoAddresses.Ly.Value)); t.Draw(lX, 20 * i++, 16, 16, "dma: " + ByteFormatter.ToHex16(this.mmu_.MemoryMap.IoAddresses .LastDmaAddress)); t.Draw(lX, 20 * i++, 16, 16, ByteFormatter.ToHex8(ioAddresses.Lcdc.Value)); t.Draw(lX, 20 * i++, 16, 16, ByteFormatter.ToHex8(this.cpu_.ScanlineLcdc)); var oam = memoryMap.Oam; for (i = 0; i < 40; i++) { var oamAddress = (ushort)(i * 4); var y = (byte)(oam[oamAddress] - 16); var x = (byte)(oam[(ushort)(oamAddress + 1)] - 8); var nPerRow = 7; var c = i % nPerRow; var r = (i - c) / nPerRow; t.Draw(c * 90, bY + r * 20, 16, 16, "(" + ByteFormatter.ToHex8(x) + ", " + ByteFormatter.ToHex8(y) + ")"); } }