Skip to content

Commit

Permalink
Merge pull request #199 from ogamespec/main
Browse files Browse the repository at this point in the history
Preliminary RGB PPU support
  • Loading branch information
ogamespec authored Jun 20, 2022
2 parents 802349c + e7156a1 commit af74ed2
Show file tree
Hide file tree
Showing 8 changed files with 391 additions and 46 deletions.
4 changes: 3 additions & 1 deletion BreaksPPU/PPUPlayer/FormColorSpace.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,11 @@ namespace PPUPlayer
{
public partial class FormColorSpace : Form
{
public FormColorSpace()
public FormColorSpace(string ppu_rev)
{
InitializeComponent();

this.Text += " - " + ppu_rev;
}

private void FormColorSpace_Load(object sender, EventArgs e)
Expand Down
3 changes: 2 additions & 1 deletion BreaksPPU/PPUPlayer/FormMain.cs
Original file line number Diff line number Diff line change
Expand Up @@ -747,7 +747,8 @@ private void checkForUpdatesToolStripMenuItem_Click(object sender, EventArgs e)

private void pPUColorSpaceToolStripMenuItem_Click(object sender, EventArgs e)
{
FormColorSpace formColorSpace = new();
FormSettings.PPUPlayerSettings settings = FormSettings.LoadSettings();
FormColorSpace formColorSpace = new FormColorSpace(settings.PPU_Revision);
formColorSpace.Show();
}

Expand Down
34 changes: 34 additions & 0 deletions BreaksPPU/PPUSim/oam.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,22 @@ namespace PPUSim
/// The OFETCH signal must be applied before the Sprite Eval simulation.
/// </summary>
void OAM::sim_OFETCH()
{
switch (ppu->rev)
{
// TBD: Find out how the rest of the RGB PPUs are doing

case Revision::RP2C04_0003:
sim_OFETCH_RGB_PPU();
break;

default:
sim_OFETCH_Default();
break;
}
}

void OAM::sim_OFETCH_Default()
{
TriState PCLK = ppu->wire.PCLK;
TriState n_PCLK = ppu->wire.n_PCLK;
Expand All @@ -127,6 +143,24 @@ namespace PPUSim
OFETCH_FF.set(MUX(PCLK, NOT(NOT(OFETCH_FF.get())), NOR(W4_Enable, W4_FF.get())));
}

void OAM::sim_OFETCH_RGB_PPU()
{
TriState PCLK = ppu->wire.PCLK;
TriState n_PCLK = ppu->wire.n_PCLK;
TriState n_W4 = ppu->wire.n_W4;
TriState n_DBE = ppu->wire.n_DBE;
auto W4_Enable = NOR(n_W4, n_DBE);

// The number of latches is 2 less. W4_FF is missing.

latch[2].set(OFETCH_FF.nget(), n_PCLK);
latch[3].set(latch[2].nget(), PCLK);

ppu->wire.OFETCH = NOR(OFETCH_FF.nget(), latch[3].get());

OFETCH_FF.set(MUX(PCLK, NOT(NOT(OFETCH_FF.get())), W4_Enable));
}

void OAM::sim_OB(OAMLane* lane)
{
TriState n_WE = ppu->wire.n_WE;
Expand Down
3 changes: 3 additions & 0 deletions BreaksPPU/PPUSim/oam.h
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,9 @@ namespace PPUSim

OAMDecayBehavior decay_behav = OAMDecayBehavior::Keep;

void sim_OFETCH_Default();
void sim_OFETCH_RGB_PPU();

public:
OAM(PPU* parent);
~OAM();
Expand Down
5 changes: 5 additions & 0 deletions BreaksPPU/PPUSim/ppu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -353,4 +353,9 @@ namespace PPUSim
{
oam->SetOamDecayBehavior(behavior);
}

bool PPU::IsComposite()
{
return vid_out->IsComposite();
}
}
5 changes: 5 additions & 0 deletions BreaksPPU/PPUSim/ppu.h
Original file line number Diff line number Diff line change
Expand Up @@ -459,6 +459,11 @@ namespace PPUSim
/// </summary>
void SetOamDecayBehavior(OAMDecayBehavior behavior);

/// <summary>
/// Returns the nature of the PPU - composite or RGB.
/// </summary>
bool IsComposite();

uint8_t Dbg_OAMReadByte(size_t addr);
uint8_t Dbg_TempOAMReadByte(size_t addr);
void Dbg_OAMWriteByte(size_t addr, uint8_t val);
Expand Down
Loading

0 comments on commit af74ed2

Please sign in to comment.