EightBitNet/LR35902/LR35902.BlarggTest/Board.cs
Adrian Conlon ead54b0468 Wire up the LR35902 Blargg GameBoy test runner. Not working yet...
Signed-off-by: Adrian Conlon <Adrian.conlon@gmail.com>
2019-07-24 23:48:19 +01:00

45 lines
1.6 KiB
C#

// <copyright file="Board.cs" company="Adrian Conlon">
// Copyright (c) Adrian Conlon. All rights reserved.
// </copyright>
namespace LR35902.BlarggTest
{
public class Board : EightBit.GameBoy.Bus
{
private readonly Configuration configuration;
private readonly EightBit.GameBoy.Disassembler disassembler;
public Board(Configuration configuration)
{
this.configuration = configuration;
this.disassembler = new EightBit.GameBoy.Disassembler(this);
}
public override void Initialize()
{
//this.DisableGameRom();
this.WrittenByte += this.Board_WrittenByte;
if (this.configuration.DebugMode)
{
this.CPU.ExecutingInstruction += this.CPU_ExecutingInstruction_Debug;
}
this.LoadBootRom(this.configuration.RomDirectory + "/DMG_ROM.bin");
}
public void Plug(string path) => this.LoadGameRom(this.configuration.RomDirectory + "/" + path);
private void Board_WrittenByte(object sender, System.EventArgs e)
{
switch (this.Address.Word)
{
case EightBit.GameBoy.IoRegisters.BASE + EightBit.GameBoy.IoRegisters.SB:
System.Console.Out.Write(this.Data);
break;
}
}
private void CPU_ExecutingInstruction_Debug(object sender, System.EventArgs e) => System.Console.Error.WriteLine($"{EightBit.GameBoy.Disassembler.State(this.CPU)}\t{this.disassembler.Disassemble(this.CPU)}");
}
}