From 1d3c48c602e8316cda80607e581c5e6a21b2e37e Mon Sep 17 00:00:00 2001 From: Washi Date: Sun, 13 Aug 2017 23:12:39 +0200 Subject: [PATCH] Disassembler read directly from field --- Emux.GameBoy/Cpu/Z80Disassembler.cs | 15 ++++++++------- Emux.GameBoy/Graphics/GameBoyGpu.cs | 2 +- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/Emux.GameBoy/Cpu/Z80Disassembler.cs b/Emux.GameBoy/Cpu/Z80Disassembler.cs index 6a2a553..aa3b449 100644 --- a/Emux.GameBoy/Cpu/Z80Disassembler.cs +++ b/Emux.GameBoy/Cpu/Z80Disassembler.cs @@ -8,6 +8,7 @@ namespace Emux.GameBoy.Cpu public class Z80Disassembler { private readonly GameBoyMemory _memory; + private ushort _position; public Z80Disassembler(GameBoyMemory memory) { @@ -19,8 +20,8 @@ namespace Emux.GameBoy.Cpu /// public ushort Position { - get; - set; + get { return _position; } + set { _position = value; } } /// @@ -29,15 +30,15 @@ namespace Emux.GameBoy.Cpu /// The disassembled instruction. public Z80Instruction ReadNextInstruction() { - ushort offset = Position; - byte code = _memory.ReadByte(Position++); + ushort offset = _position; + byte code = _memory.ReadByte(_position++); var opcode = code != 0xCB ? Z80OpCodes.SingleByteOpCodes[code] - : Z80OpCodes.PrefixedOpCodes[_memory.ReadByte(Position++)]; + : Z80OpCodes.PrefixedOpCodes[_memory.ReadByte(_position++)]; - byte[] operand = _memory.ReadBytes(Position, opcode.OperandLength); - Position += (ushort) operand.Length; + byte[] operand = _memory.ReadBytes(_position, opcode.OperandLength); + _position += (ushort) operand.Length; var instruction = new Z80Instruction(offset, opcode, operand); return instruction; diff --git a/Emux.GameBoy/Graphics/GameBoyGpu.cs b/Emux.GameBoy/Graphics/GameBoyGpu.cs index 0f2fc5e..2eec7e4 100644 --- a/Emux.GameBoy/Graphics/GameBoyGpu.cs +++ b/Emux.GameBoy/Graphics/GameBoyGpu.cs @@ -86,7 +86,7 @@ namespace Emux.GameBoy.Graphics public byte ObjP1; public byte WY; public byte WX; - + public GameBoyGpu(GameBoy device) { if (device == null)