/// <summary> /// Updates the key state. /// </summary> /// <param name="memory">The memory.</param> internal void Update(GbMemory memory) { if (((GetJoypad(this.prevKeys) & 0xF) == 0xF) && (GetJoypad(this.keys) & 0xF) != 0xF) { memory.IF |= 0x10; } }
/// <summary> /// Initializes a new instance of the <see cref="Lcd"/> class. /// </summary> /// <param name="memory">The memory.</param> public Lcd(GbMemory memory) { for (int i = 0; i < this.displayMemory.Length; i++) { this.displayMemory[i] = WHITE; } this.mem = memory; }
public static void CopyRom(byte[] bootRom, byte[] cartRom, GbMemory mem) { Buffer.BlockCopy(bootRom, 0, mem.BootRom, 0, 0x100); if (mem.Rom.Length < cartRom.Length) { Logger.LogError("Given rom is bigger than it says it should be."); throw new InvalidOperationException(); } Buffer.BlockCopy(cartRom, 0, mem.Rom, 0, cartRom.Length); // Buffer copy because I guess it might be faster? if (mem.Rom.Length > cartRom.Length) { Logger.LogWarning("Given rom is shorter than it says it is, 0xFF filling leftover space."); for (int i = cartRom.Length; i < mem.Rom.Length; i++) { mem.Rom[i] = 0xFF; } } }
/// <summary> /// Invokes the <see cref="function"/> of this instance with the given arguments. /// </summary> /// <param name="memory">The memory.</param> public int Invoke(GbMemory memory) => this.function(this, memory);
/// <summary> /// Initializes a new instance of the <see cref="Cpu"/> class. /// </summary> /// <remarks> /// This constructor should be used when the ability to freely check the memory is needed, IE tests. /// </remarks> /// <param name="memory">The memory.</param> public Cpu(GbMemory memory) => this.memory = memory;