Skip to content

Commit

Permalink
Merge pull request #399 from ogamespec/main
Browse files Browse the repository at this point in the history
Minor improvements
  • Loading branch information
ogamespec authored May 11, 2023
2 parents ea46b82 + 6ed87d8 commit 781b1c5
Show file tree
Hide file tree
Showing 6 changed files with 53 additions and 17 deletions.
18 changes: 12 additions & 6 deletions Breaknes/Breaknes/FormMain.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ private void loadROMDumpToolStripMenuItem_Click(object sender, EventArgs e)
if (openFileDialog1.ShowDialog() == DialogResult.OK)
{
string filename = openFileDialog1.FileName;
board.Paused = true;
board.EjectCartridge();
if (board.InsertCartridge(filename) < 0)
{
Expand Down Expand Up @@ -78,12 +79,17 @@ private void settingsToolStripMenuItem_Click(object sender, EventArgs e)

private void Settings_FormClosed(object? sender, FormClosedEventArgs e)
{
board.Paused = true;
board.EjectCartridge();
board.DisposeBoard();
var settings = FormSettings.LoadSettings();
board.CreateBoard(BoardDescriptionLoader.Load(), settings.MainBoard);
Text = original_title;
FormSettings form_settings = (FormSettings)sender;

if (form_settings.PurgeBoard)
{
board.Paused = true;
board.EjectCartridge();
board.DisposeBoard();
var settings = FormSettings.LoadSettings();
board.CreateBoard(BoardDescriptionLoader.Load(), settings.MainBoard);
Text = original_title;
}
}

private void openDebuggerToolStripMenuItem_Click(object sender, EventArgs e)
Expand Down
11 changes: 9 additions & 2 deletions Breaknes/Breaknes/FormSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ namespace Breaknes
{
public partial class FormSettings : Form
{
public bool PurgeBoard = false;
private string prev_board;

public FormSettings()
{
InitializeComponent();
Expand Down Expand Up @@ -59,13 +62,17 @@ static BreaknesSettings SetDefaultSettings()

private void FormSettings_Load(object sender, EventArgs e)
{
propertyGrid1.SelectedObject = LoadSettings();
var settings = LoadSettings();
prev_board = settings.MainBoard;
propertyGrid1.SelectedObject = settings;
}

private void button1_Click(object sender, EventArgs e)
{
SaveSettings((BreaknesSettings)propertyGrid1.SelectedObject);
BreaknesSettings settings = (BreaknesSettings)propertyGrid1.SelectedObject;
SaveSettings(settings);
Close();
PurgeBoard = settings.MainBoard != prev_board;
}

private void FormSettings_KeyDown(object sender, KeyEventArgs e)
Expand Down
4 changes: 4 additions & 0 deletions Breaknes/Breaknes/VideoProcessing.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ public class VideoRender
private OnRenderField? onRenderField = null;
public delegate void OnRenderField();

private long field_counter = 0;

public VideoRender(OnRenderField _onRender)
{
onRenderField = _onRender;
Expand Down Expand Up @@ -146,6 +148,8 @@ void VisualizeField()
}
gr.Dispose();

field_counter++;

onRenderField?.Invoke();
}
}
Expand Down
2 changes: 2 additions & 0 deletions BreaksAPU/APUSim/Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

APU simulator at the gate level.

Note: In the Breaks project, the term APU refers to the entire CPU chip (2A03/2A07), which includes the 6502 core and the APU itself. Therefore, here APU and CPU are synonymous.

## Simulation Approaches

In general, all approaches are tried on the M6502Core, in terms of APU nothing particularly new. We take the circuit and repeat its work in C++. In the beginning somehow, and then we try to optimize it.
Expand Down
17 changes: 17 additions & 0 deletions UnitTest/Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,20 @@ Each emulated chip class contains a friendly class that has access to all intern
- M6502Core: M6502CoreUnitTest::UnitTest
- APUSim: APUSimUnitTest::UnitTest
- PPUSim: PPUSimUnitTest::UnitTest

## MegaCycles

Right now there are three tests that are not running successfully. They are used to measure the performance of the 6502 Core, APU and PPU.

Current performance:

```
Core executed 1789772 cycles in real 2282 msec
You're 2.28 times slower :(
APU+Core executed 21477272 cycles in real 18297 msec
You're 18.30 times slower :(
PPU executed 21477272 cycles in real 21828 msec
You're 21.83 times slower :(
```
18 changes: 9 additions & 9 deletions UnitTest/UnitTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,9 @@ namespace UnitTest
Assert::IsTrue(ut.DumpDecoder());
}

BEGIN_TEST_METHOD_ATTRIBUTE(TestCoreMegaCycles)
TEST_IGNORE()
END_TEST_METHOD_ATTRIBUTE()
//BEGIN_TEST_METHOD_ATTRIBUTE(TestCoreMegaCycles)
// TEST_IGNORE()
//END_TEST_METHOD_ATTRIBUTE()
TEST_METHOD(TestCoreMegaCycles)
{
M6502CoreUnitTest::UnitTest ut;
Expand Down Expand Up @@ -146,9 +146,9 @@ namespace UnitTest
Assert::IsTrue(ut.TestOAM_DMA());
}

BEGIN_TEST_METHOD_ATTRIBUTE(TestApuMegaCycles)
TEST_IGNORE()
END_TEST_METHOD_ATTRIBUTE()
//BEGIN_TEST_METHOD_ATTRIBUTE(TestApuMegaCycles)
// TEST_IGNORE()
//END_TEST_METHOD_ATTRIBUTE()
TEST_METHOD(TestApuMegaCycles)
{
APUSimUnitTest::UnitTest ut(APUSim::Revision::RP2A03G);
Expand Down Expand Up @@ -294,9 +294,9 @@ namespace UnitTest
ut.Dump_2C04_0003_ColorSpace();
}

BEGIN_TEST_METHOD_ATTRIBUTE(TestPpuMegaCycles)
TEST_IGNORE()
END_TEST_METHOD_ATTRIBUTE()
//BEGIN_TEST_METHOD_ATTRIBUTE(TestPpuMegaCycles)
// TEST_IGNORE()
//END_TEST_METHOD_ATTRIBUTE()
TEST_METHOD(TestPpuMegaCycles)
{
PPUSimUnitTest::UnitTest ut(PPUSim::Revision::RP2C02G);
Expand Down

0 comments on commit 781b1c5

Please sign in to comment.