Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed RegisterBitRes #412

Merged
merged 3 commits into from
May 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 16 additions & 2 deletions BreaksAPU/APUSim/common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,14 @@ namespace APUSim

void RegisterBitRes::sim(TriState ACLK1, TriState Enable, TriState Value, TriState Res)
{
transp_latch.set(AND(MUX(ACLK1, MUX(Enable, TriState::Z, Value), NOT(transp_latch.nget())), NOT(Res)), TriState::One);
TriState d =
MUX(ACLK1,
MUX(Enable, TriState::Z, Value),
NOT(transp_latch.nget()));
if (Res == TriState::One) {
d = TriState::Zero;
}
transp_latch.set(d, TriState::One);
}

TriState RegisterBitRes::get()
Expand All @@ -48,7 +55,14 @@ namespace APUSim

void RegisterBitRes2::sim(TriState ACLK1, TriState Enable, TriState Value, TriState Res1, TriState Res2)
{
transp_latch.set(AND(MUX(ACLK1, MUX(Enable, TriState::Z, Value), NOT(transp_latch.nget())), NOT(OR(Res1, Res2))), TriState::One);
TriState d =
MUX(ACLK1,
MUX(Enable, TriState::Z, Value),
NOT(transp_latch.nget()));
if (OR(Res1, Res2) == TriState::One) {
d = TriState::Zero;
}
transp_latch.set(d, TriState::One);
}

TriState RegisterBitRes2::get()
Expand Down
4 changes: 2 additions & 2 deletions BreaksAPU/APUSim/dpcm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,10 +106,10 @@ namespace APUSim
run_latch2.set(run_latch1.nget(), ACLK1);
TriState start_set = NOR3(NAND(RnW, NOT(PHI1)), nDMCEnableDelay, NOT(nDMAStop));
start_ff.set(NOR4(NOR(start_ff.get(), start_set), nDMCEnableDelay, RES, NOT(nDMAStop)));
rdy_ff.set(NOR(NOR(rdy_ff.get(), AND(run_latch1.get(), ACLK1)), ACLK2));
rdy_ff.set(NOR(AND(run_latch1.get(), ACLK1), NOR(rdy_ff.get(), ACLK2)));

apu->wire.RUNDMC = run_latch2.nget();
apu->wire.n_DMC_AB = rdy_ff.nget();
apu->wire.n_DMC_AB = rdy_ff.get();
apu->wire.DMCRDY = NOR(start_ff.get(), rdy_ff.get());
}

Expand Down
6 changes: 5 additions & 1 deletion BreaksAPU/NSFPlayer/FormMain.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ public partial class FormMain : Form
public FormMain()
{
InitializeComponent();
//AllocConsole();
}

private void FormMain_Load(object sender, EventArgs e)
Expand All @@ -62,6 +61,11 @@ private void FormMain_Load(object sender, EventArgs e)
OutputDC = settings.DC;
BreaksCore.Visual2A03Mapping = settings.Visual2A03Mapping;

if (settings.AllocConsole)
{
AllocConsole();
}

SetPaused(true);

backgroundWorker1.RunWorkerAsync();
Expand Down
6 changes: 6 additions & 0 deletions BreaksAPU/NSFPlayer/FormSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ static APUPlayerSettings SetDefaultSettings()
settings.AuxSampleRate = 3579544; // 0.5 PHI for 2A03
settings.DC = 0.0f;
settings.Visual2A03Mapping = false;
settings.AllocConsole = false;

SaveSettings(settings);

Expand Down Expand Up @@ -137,6 +138,11 @@ public class APUPlayerSettings
[Category("Debug")]
[Description("Enable the signal names from Visual2A03 instead of the Breaks names.")]
public bool Visual2A03Mapping { get; set; }

[XmlElement]
[Category("Debug")]
[Description("Open the console for debug output.")]
public bool AllocConsole { get; set; }
}

// https://stackoverflow.com/questions/24503462/how-to-show-drop-down-control-in-property-grid
Expand Down
16 changes: 12 additions & 4 deletions Common/BaseBoardLib/RegDumpProcessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,19 @@ namespace BaseBoard

if (dump_regops) {

if (RnW == TriState::One) {
printf("%x read 0x%x\n", current->clkDelta, *addr_bus);
if (dump_4015_writes_only) {
if (RnW == TriState::Zero && *addr_bus == 0x4015) {
printf("%x write 4015 = 0x%02x\n", current->clkDelta, *data_bus);
}
}
else {
printf("%x write 0x%x = 0x%02x\n", current->clkDelta, *addr_bus, *data_bus);
else
{
if (RnW == TriState::One) {
printf("%x read 0x%x\n", current->clkDelta, *addr_bus);
}
else {
printf("%x write 0x%x = 0x%02x\n", current->clkDelta, *addr_bus, *data_bus);
}
}
}

Expand Down
2 changes: 2 additions & 0 deletions Common/BaseBoardLib/RegDumpProcessor.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ namespace BaseBoard

const bool dump_regops = false; // Enable debug output of register operations

const bool dump_4015_writes_only = false; // The most interesting

public:
RegDumpProcessor(uint16_t regs_base, uint8_t regs_mask);
~RegDumpProcessor();
Expand Down