mirror of
https://github.com/MoleskiCoder/EightBitNet.git
synced 2025-02-10 04:30:38 +00:00
Wire up the LR35902 Blargg GameBoy test runner. Not working yet...
Signed-off-by: Adrian Conlon <Adrian.conlon@gmail.com>
This commit is contained in:
parent
f44b7b90d4
commit
ead54b0468
44
LR35902/LR35902.BlarggTest/Board.cs
Normal file
44
LR35902/LR35902.BlarggTest/Board.cs
Normal file
@ -0,0 +1,44 @@
|
||||
// <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)}");
|
||||
}
|
||||
}
|
40
LR35902/LR35902.BlarggTest/Computer.cs
Normal file
40
LR35902/LR35902.BlarggTest/Computer.cs
Normal file
@ -0,0 +1,40 @@
|
||||
// <copyright file="Computer.cs" company="Adrian Conlon">
|
||||
// Copyright (c) Adrian Conlon. All rights reserved.
|
||||
// </copyright>
|
||||
|
||||
namespace LR35902.BlarggTest
|
||||
{
|
||||
public class Computer
|
||||
{
|
||||
private readonly Configuration configuration;
|
||||
private readonly Board board;
|
||||
|
||||
public Computer(Configuration configuration)
|
||||
{
|
||||
this.configuration = configuration;
|
||||
this.board = new Board(configuration);
|
||||
}
|
||||
|
||||
public void Run()
|
||||
{
|
||||
var cycles = 0;
|
||||
var cpu = this.board.CPU;
|
||||
while (cpu.Powered)
|
||||
{
|
||||
cycles += EightBit.GameBoy.Bus.CyclesPerFrame;
|
||||
cycles -= this.board.RunRasterLines();
|
||||
cycles -= this.board.RunVerticalBlankLines();
|
||||
}
|
||||
}
|
||||
|
||||
public void Plug(string path) => this.board.Plug(path);
|
||||
|
||||
public void RaisePOWER()
|
||||
{
|
||||
this.board.RaisePOWER();
|
||||
this.board.Initialize();
|
||||
}
|
||||
|
||||
public void LowerPOWER() => this.board.LowerPOWER();
|
||||
}
|
||||
}
|
13
LR35902/LR35902.BlarggTest/Configuration.cs
Normal file
13
LR35902/LR35902.BlarggTest/Configuration.cs
Normal file
@ -0,0 +1,13 @@
|
||||
// <copyright file="Configuration.cs" company="Adrian Conlon">
|
||||
// Copyright (c) Adrian Conlon. All rights reserved.
|
||||
// </copyright>
|
||||
|
||||
namespace LR35902.BlarggTest
|
||||
{
|
||||
public class Configuration
|
||||
{
|
||||
public bool DebugMode { get; set; } = false;
|
||||
|
||||
public string RomDirectory { get; set; } = "roms";
|
||||
}
|
||||
}
|
@ -46,6 +46,9 @@
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Board.cs" />
|
||||
<Compile Include="Computer.cs" />
|
||||
<Compile Include="Configuration.cs" />
|
||||
<Compile Include="Program.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
</ItemGroup>
|
||||
@ -58,5 +61,15 @@
|
||||
<Analyzer Include="..\..\packages\StyleCop.Analyzers.1.1.118\analyzers\dotnet\cs\StyleCop.Analyzers.CodeFixes.dll" />
|
||||
<Analyzer Include="..\..\packages\StyleCop.Analyzers.1.1.118\analyzers\dotnet\cs\StyleCop.Analyzers.dll" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\EightBit\EightBit.csproj">
|
||||
<Project>{6ebf8857-62a3-4ef4-af21-c1844031d7e4}</Project>
|
||||
<Name>EightBit</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\LR35902.csproj">
|
||||
<Project>{01f61a1d-cb4a-4ea3-96ef-222f831df483}</Project>
|
||||
<Name>LR35902</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
</Project>
|
@ -1,15 +1,39 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
// <copyright file="Program.cs" company="Adrian Conlon">
|
||||
// Copyright (c) Adrian Conlon. All rights reserved.
|
||||
// </copyright>
|
||||
|
||||
namespace LR35902.BlarggTest
|
||||
{
|
||||
class Program
|
||||
public static class Program
|
||||
{
|
||||
static void Main(string[] args)
|
||||
public static void Main(string[] args)
|
||||
{
|
||||
var configuration = new Configuration();
|
||||
|
||||
#if DEBUG
|
||||
configuration.DebugMode = true;
|
||||
#endif
|
||||
|
||||
var computer = new Computer(configuration);
|
||||
|
||||
computer.Plug("blargg/cpu_instrs.gb"); // Passed
|
||||
////computer.plug("blargg/01-special.gb"); // Passed
|
||||
////computer.plug("blargg/02-interrupts.gb"); // Passed
|
||||
////computer.plug("blargg/03-op sp,hl.gb"); // Passed
|
||||
////computer.plug("blargg/04-op r,imm.gb"); // Passed
|
||||
////computer.plug("blargg/05-op rp.gb"); // Passed
|
||||
////computer.plug("blargg/06-ld r,r.gb"); // Passed
|
||||
////computer.plug("blargg/07-jr,jp,call,ret,rst.gb"); // Passed
|
||||
////computer.plug("blargg/08-misc instrs.gb"); // Passed
|
||||
////computer.plug("blargg/09-op r,r.gb"); // Passed
|
||||
////computer.plug("blargg/10-bit ops.gb"); // Passed
|
||||
////computer.plug("blargg/11-op a,(hl).gb"); // Passed
|
||||
|
||||
////computer.plug("blargg/instr_timing.gb"); // Failed #255
|
||||
////computer.plug("blargg/interrupt_time.gb"); // Failed
|
||||
|
||||
computer.RaisePOWER();
|
||||
computer.Run();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user