mirror of
https://github.com/SourMesen/Mesen2.git
synced 2024-06-22 22:22:51 -04:00
GB: Fixed power on state for OAM DMA register
This commit is contained in:
parent
458464357c
commit
7569f58b4a
|
@ -13,6 +13,7 @@ void GbDmaController::Init(Gameboy* gameboy, GbMemoryManager* memoryManager, GbP
|
|||
_ppu = ppu;
|
||||
_cpu = cpu;
|
||||
_state = {};
|
||||
_state.OamDmaSource = 0xFF;
|
||||
}
|
||||
|
||||
GbDmaControllerState GbDmaController::GetState()
|
||||
|
|
|
@ -136,7 +136,7 @@ void RecordedRomTest::Record(string filename, bool reset)
|
|||
//Start recording movie alongside with screenshots
|
||||
RecordMovieOptions options;
|
||||
string movieFilename = FolderUtilities::CombinePath(FolderUtilities::GetFolderName(filename), FolderUtilities::GetFilename(filename, false) + ".mmo");
|
||||
memcpy(options.Filename, movieFilename.c_str(), std::max(1000, (int)movieFilename.size()));
|
||||
memcpy(options.Filename, movieFilename.c_str(), std::min(1000, (int)movieFilename.size()));
|
||||
options.RecordFrom = reset ? RecordMovieFrom::StartWithSaveData : RecordMovieFrom::CurrentState;
|
||||
_emu->GetMovieManager()->Record(options);
|
||||
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#include "Common.h"
|
||||
#include "Core/Shared/RecordedRomTest.h"
|
||||
#include "Core/Shared/Emulator.h"
|
||||
#include "Core/Shared/EmuSettings.h"
|
||||
|
||||
extern unique_ptr<Emulator> _emu;
|
||||
shared_ptr<RecordedRomTest> _recordedRomTest;
|
||||
|
@ -12,6 +13,7 @@ extern "C"
|
|||
if(inBackground) {
|
||||
unique_ptr<Emulator> emu(new Emulator());
|
||||
emu->Initialize();
|
||||
emu->GetSettings()->SetFlag(EmulationFlags::ConsoleMode);
|
||||
shared_ptr<RecordedRomTest> romTest(new RecordedRomTest(emu.get(), true));
|
||||
return romTest->Run(filename);
|
||||
} else {
|
||||
|
@ -20,6 +22,28 @@ extern "C"
|
|||
}
|
||||
}
|
||||
|
||||
DllExport uint32_t __stdcall RunTest(char* filename)
|
||||
{
|
||||
unique_ptr<Emulator> emu(new Emulator());
|
||||
emu->Initialize();
|
||||
emu->GetSettings()->SetFlag(EmulationFlags::ConsoleMode);
|
||||
emu->GetSettings()->GetGameboyConfig().Model = GameboyModel::Gameboy;
|
||||
emu->GetSettings()->GetGameboyConfig().RamPowerOnState = RamState::AllZeros;
|
||||
emu->LoadRom((VirtualFile)filename, VirtualFile());
|
||||
emu->GetSettings()->SetFlag(EmulationFlags::MaximumSpeed);
|
||||
|
||||
while(emu->GetFrameCount() < 500) {
|
||||
std::this_thread::sleep_for(std::chrono::duration<int, std::milli>(50));
|
||||
}
|
||||
|
||||
uint8_t result = ((uint8_t*)emu->GetMemory(MemoryType::GbHighRam).Memory)[2];
|
||||
|
||||
emu->Stop(false);
|
||||
emu->Release();
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
DllExport void __stdcall RomTestRecord(char* filename, bool reset)
|
||||
{
|
||||
_recordedRomTest.reset(new RecordedRomTest(_emu.get(), false));
|
||||
|
|
|
@ -12,6 +12,7 @@ namespace Mesen.Interop
|
|||
private const string DllPath = EmuApi.DllName;
|
||||
|
||||
[DllImport(DllPath)] public static extern RomTestResult RunRecordedTest([MarshalAs(UnmanagedType.LPUTF8Str)]string filename, [MarshalAs(UnmanagedType.I1)]bool inBackground);
|
||||
[DllImport(DllPath)] public static extern UInt32 RunTest([MarshalAs(UnmanagedType.LPUTF8Str)]string filename);
|
||||
[DllImport(DllPath)] public static extern void RomTestRecord([MarshalAs(UnmanagedType.LPUTF8Str)]string filename, [MarshalAs(UnmanagedType.I1)]bool reset);
|
||||
[DllImport(DllPath)] public static extern void RomTestStop();
|
||||
[DllImport(DllPath)] [return: MarshalAs(UnmanagedType.I1)] public static extern bool RomTestRecording();
|
||||
|
|
|
@ -43,7 +43,7 @@ namespace Mesen.Utilities
|
|||
ConcurrentDictionary<string, RomTestResult> results = new();
|
||||
|
||||
List<string> testFiles = Directory.EnumerateFiles(ConfigManager.TestFolder, "*.mtp", SearchOption.AllDirectories).ToList();
|
||||
Parallel.ForEach(testFiles, new ParallelOptions() { MaxDegreeOfParallelism = 6 }, (string testFile) => {
|
||||
Parallel.ForEach(testFiles, new ParallelOptions() { MaxDegreeOfParallelism = Environment.ProcessorCount - 2 }, (string testFile) => {
|
||||
string entryName = testFile.Substring(ConfigManager.TestFolder.Length);
|
||||
results[entryName] = TestApi.RunRecordedTest(testFile, true);
|
||||
});
|
||||
|
@ -68,11 +68,64 @@ namespace Mesen.Utilities
|
|||
|
||||
EmuApi.WriteLogEntry("==================");
|
||||
if(failedTests.Count > 0) {
|
||||
EmuApi.WriteLogEntry("Tests passed: " + (testFiles.Count - failedTests.Count));
|
||||
EmuApi.WriteLogEntry("Tests failed: " + failedTests.Count);
|
||||
foreach(string failedTest in failedTests) {
|
||||
EmuApi.WriteLogEntry(" Failed: " + failedTest);
|
||||
}
|
||||
EmuApi.WriteLogEntry("==================");
|
||||
EmuApi.WriteLogEntry("Tests passed: " + (testFiles.Count - failedTests.Count));
|
||||
EmuApi.WriteLogEntry("Tests failed: " + failedTests.Count);
|
||||
} else {
|
||||
EmuApi.WriteLogEntry("All " + testFiles.Count + " tests passed!");
|
||||
}
|
||||
EmuApi.WriteLogEntry("==================");
|
||||
|
||||
Dispatcher.UIThread.Post(() => {
|
||||
ApplicationHelper.GetOrCreateUniqueWindow<LogWindow>(null, () => new LogWindow());
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
public static void RunGbMicroTests(bool all)
|
||||
{
|
||||
Task.Run(() => {
|
||||
ConcurrentDictionary<string, UInt32> results = new();
|
||||
|
||||
List<string> testFiles = Directory.EnumerateFiles(@"C:\Code\gbmicrotest-main\bin" + (all ? "" : "\\pass"), "*.gb", SearchOption.AllDirectories).ToList();
|
||||
Parallel.ForEach(testFiles, new ParallelOptions() { MaxDegreeOfParallelism = Environment.ProcessorCount - 2 }, (string testFile) => {
|
||||
string entryName = Path.GetFileName(testFile);
|
||||
results[entryName] = TestApi.RunTest(testFile);
|
||||
});
|
||||
|
||||
EmuApi.WriteLogEntry("==================");
|
||||
List<string> failedTests = new List<string>();
|
||||
List<string> entries = results.Keys.ToList();
|
||||
entries.Sort();
|
||||
|
||||
foreach(var entry in entries) {
|
||||
UInt32 result = results[entry];
|
||||
string msg = "[Test] ";
|
||||
switch(result) {
|
||||
case 1: msg += "Pass"; break;
|
||||
case 0xFF: msg += "FAIL"; break;
|
||||
default: msg += "UNKNOWN"; break;
|
||||
}
|
||||
msg += ": " + entry;
|
||||
|
||||
EmuApi.WriteLogEntry(msg);
|
||||
|
||||
if(result == 0xFF) {
|
||||
failedTests.Add(entry);
|
||||
}
|
||||
}
|
||||
|
||||
EmuApi.WriteLogEntry("==================");
|
||||
if(failedTests.Count > 0) {
|
||||
foreach(string failedTest in failedTests) {
|
||||
EmuApi.WriteLogEntry(" Failed: " + failedTest);
|
||||
}
|
||||
EmuApi.WriteLogEntry("==================");
|
||||
EmuApi.WriteLogEntry("Tests passed: " + (testFiles.Count - failedTests.Count));
|
||||
EmuApi.WriteLogEntry("Tests failed: " + failedTests.Count);
|
||||
} else {
|
||||
EmuApi.WriteLogEntry("All " + testFiles.Count + " tests passed!");
|
||||
}
|
||||
|
|
|
@ -537,6 +537,12 @@ namespace Mesen.Windows
|
|||
} else if(key == Key.F3) {
|
||||
RomTestHelper.RunAllTests();
|
||||
return true;
|
||||
} else if(key == Key.F7) {
|
||||
RomTestHelper.RunGbMicroTests(false);
|
||||
return true;
|
||||
} else if(key == Key.F8) {
|
||||
RomTestHelper.RunGbMicroTests(true);
|
||||
return true;
|
||||
} else if(key == Key.F6) {
|
||||
//For testing purposes (to test for memory leaks)
|
||||
Task.Run(() => {
|
||||
|
|
Loading…
Reference in a new issue