EPSG $4016 addressing, EPSG ui checkbox

Added support for $4016 addressing for the EPSG
Added ui element to enable EPSG, remains to be implemented
This commit is contained in:
Perkka2 2021-01-28 14:25:01 +01:00
parent 945b63f696
commit 7de782b486
9 changed files with 68 additions and 4 deletions

View file

@ -1,9 +1,21 @@
#pragma once
#include "stdafx.h"
#include "BaseMapper.h"
#include "CPU.h"
#include "EPSGAudio.h"
using AudioClass = EPSGAudio;
class AXROM : public BaseMapper
{
public:
unique_ptr<AudioClass> _audio;
void ProcessCpuClock() override
{
_audio->Clock();
}
protected:
virtual uint16_t GetPRGPageSize() override { return 0x8000; }
virtual uint16_t GetCHRPageSize() override { return 0x2000; }
@ -12,8 +24,16 @@ class AXROM : public BaseMapper
{
SelectCHRPage(0, 0);
WriteRegister(0, GetPowerOnByte());
_audio.reset(new AudioClass(_console));
}
virtual void StreamState(bool saving) override
{
BaseMapper::StreamState(saving);
SnapshotInfo audio{ _audio.get() };
Stream(audio);
}
bool HasBusConflicts() override { return _romInfo.SubMapperID == 2; }
void WriteRegister(uint16_t addr, uint8_t value) override
@ -22,4 +42,12 @@ class AXROM : public BaseMapper
SetMirroringType(((value & 0x10) == 0x10) ? MirroringType::ScreenBOnly : MirroringType::ScreenAOnly);
}
void WriteEPSG(uint16_t addr, uint8_t value) override
{
switch (addr & 0x4016) {
case 0x4016:
_audio->WriteRegister(addr, value);
break;
}
}
};

View file

@ -13,6 +13,7 @@
#include "EmulationSettings.h"
void BaseMapper::WriteRegister(uint16_t addr, uint8_t value) { }
void BaseMapper::WriteEPSG(uint16_t addr, uint8_t value) { }
uint8_t BaseMapper::ReadRegister(uint16_t addr) { return 0; }
void BaseMapper::InitMapper(RomData &romData) { }
void BaseMapper::Reset(bool softReset) { }
@ -778,6 +779,7 @@ uint8_t BaseMapper::DebugReadRAM(uint16_t addr)
void BaseMapper::WriteRAM(uint16_t addr, uint8_t value)
{
if(addr == 0x4016){ WriteEPSG(addr, value); }
if(_isWriteRegisterAddr[addr]) {
if(_hasBusConflicts) {
uint8_t prgValue = _prgPages[addr >> 8][(uint8_t)addr];

View file

@ -104,6 +104,7 @@ protected:
uint8_t InternalReadRam(uint16_t addr);
virtual void WriteRegister(uint16_t addr, uint8_t value);
virtual void WriteEPSG(uint16_t addr, uint8_t value);
virtual uint8_t ReadRegister(uint16_t addr);
void SelectPrgPage4x(uint16_t slot, uint16_t page, PrgMemoryType memoryType = PrgMemoryType::PrgRom);

View file

@ -285,10 +285,14 @@ public:
_audio->WriteRegister(addr, value);
break;
}
}
void WriteEPSG(uint16_t addr, uint8_t value) override
{
switch (addr & 0x4016) {
case 0x4016:
_audio->WriteRegister(addr, value);
break;
case 0x4016:
_audio->WriteRegister(addr, value);
break;
}
}

View file

@ -133,6 +133,9 @@ void MemoryManager::Write(uint16_t addr, uint8_t value, MemoryOperationType oper
{
if(_console->DebugProcessRamOperation(operationType, addr, value)) {
_ramWriteHandlers[addr]->WriteRAM(addr, value);
if (addr == 0x4016) {
_ramWriteHandlers[0xE000]->WriteRAM(addr, value);
}
}
}

View file

@ -81,6 +81,15 @@ protected:
SetCpuMemoryMapping(0x6000, 0x7FFF, _workRamValue & 0x3F, PrgMemoryType::PrgRom);
}
}
void WriteEPSG(uint16_t addr, uint8_t value) override
{
switch (addr & 0x4016) {
case 0x4016:
_audio->WriteRegister(addr, value);
break;
}
}
void WriteRegister(uint16_t addr, uint8_t value) override
{

View file

@ -6,6 +6,7 @@ namespace Mesen.GUI.Config
{
public string AudioDevice = "";
public bool EnableAudio = true;
public bool EnableEPSG = true;
public bool DisableDynamicSampleRate = false;

View file

@ -48,6 +48,7 @@ namespace Mesen.GUI.Forms.Config
this.tableLayoutPanel2 = new System.Windows.Forms.TableLayoutPanel();
this.lblVolumeReductionSettings = new System.Windows.Forms.Label();
this.chkEnableAudio = new System.Windows.Forms.CheckBox();
this.chkEnableEPSG = new System.Windows.Forms.CheckBox();
this.lblSampleRate = new System.Windows.Forms.Label();
this.lblAudioLatency = new System.Windows.Forms.Label();
this.cboSampleRate = new System.Windows.Forms.ComboBox();
@ -450,6 +451,7 @@ namespace Mesen.GUI.Forms.Config
this.tableLayoutPanel2.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle());
this.tableLayoutPanel2.Controls.Add(this.lblVolumeReductionSettings, 0, 4);
this.tableLayoutPanel2.Controls.Add(this.chkEnableAudio, 0, 0);
this.tableLayoutPanel2.Controls.Add(this.chkEnableEPSG, 0, 0);
this.tableLayoutPanel2.Controls.Add(this.lblSampleRate, 0, 2);
this.tableLayoutPanel2.Controls.Add(this.lblAudioLatency, 0, 3);
this.tableLayoutPanel2.Controls.Add(this.cboSampleRate, 1, 2);
@ -491,7 +493,7 @@ namespace Mesen.GUI.Forms.Config
//
this.chkEnableAudio.AutoSize = true;
this.tableLayoutPanel2.SetColumnSpan(this.chkEnableAudio, 2);
this.chkEnableAudio.Location = new System.Drawing.Point(6, 6);
this.chkEnableAudio.Location = new System.Drawing.Point(6, 32);
this.chkEnableAudio.Margin = new System.Windows.Forms.Padding(6, 6, 6, 3);
this.chkEnableAudio.Name = "chkEnableAudio";
this.chkEnableAudio.Size = new System.Drawing.Size(89, 17);
@ -499,6 +501,18 @@ namespace Mesen.GUI.Forms.Config
this.chkEnableAudio.Text = "Enable Audio";
this.chkEnableAudio.UseVisualStyleBackColor = true;
//
// chkEnableEPSG
//
this.chkEnableEPSG.AutoSize = true;
this.tableLayoutPanel2.SetColumnSpan(this.chkEnableEPSG, 2);
this.chkEnableEPSG.Location = new System.Drawing.Point(6, 6);
this.chkEnableEPSG.Margin = new System.Windows.Forms.Padding(6, 6, 6, 3);
this.chkEnableEPSG.Name = "chkEnableEPSG";
this.chkEnableEPSG.Size = new System.Drawing.Size(91, 17);
this.chkEnableEPSG.TabIndex = 3;
this.chkEnableEPSG.Text = "Enable EPSG";
this.chkEnableEPSG.UseVisualStyleBackColor = true;
//
// lblSampleRate
//
this.lblSampleRate.Anchor = System.Windows.Forms.AnchorStyles.Left;
@ -2129,6 +2143,7 @@ namespace Mesen.GUI.Forms.Config
private System.Windows.Forms.GroupBox grpVolume;
private System.Windows.Forms.TableLayoutPanel tableLayoutPanel2;
private System.Windows.Forms.CheckBox chkEnableAudio;
private System.Windows.Forms.CheckBox chkEnableEPSG;
private System.Windows.Forms.Label lblAudioLatency;
private MesenNumericUpDown nudLatency;
private System.Windows.Forms.Label lblLatencyMs;

View file

@ -31,6 +31,7 @@ namespace Mesen.GUI.Forms.Config
cboAudioDevice.Items.AddRange(InteropEmu.GetAudioDevices().ToArray());
AddBinding("EnableAudio", chkEnableAudio);
AddBinding("EnableEPSG", chkEnableEPSG);
AddBinding("MasterVolume", trkMaster);
AddBinding("Square1Volume", trkSquare1Vol);
AddBinding("Square2Volume", trkSquare2Vol);