Skip to content

Commit

Permalink
Covox on PPU I/O Port A
Browse files Browse the repository at this point in the history
  • Loading branch information
nzeemin committed Feb 12, 2024
1 parent 46fa0ac commit 628048c
Show file tree
Hide file tree
Showing 9 changed files with 45 additions and 12 deletions.
5 changes: 5 additions & 0 deletions emulator/Emulator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -461,6 +461,11 @@ void Emulator_SetSoundAY(bool soundAYOnOff)
g_pBoard->SetSoundAY(soundAYOnOff);
}

void Emulator_SetSoundCovox(bool soundCovoxOnOff)
{
g_pBoard->SetSoundCovox(soundCovoxOnOff);
}

void Emulator_SetMouse(bool mouseOnOff)
{
g_pBoard->SetMouse(mouseOnOff);
Expand Down
1 change: 1 addition & 0 deletions emulator/Emulator.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ void Emulator_RemoveAllBreakpoints(bool okCpuPpu);

void Emulator_SetSound(bool soundOnOff);
void Emulator_SetSoundAY(bool soundAYOnOff);
void Emulator_SetSoundCovox(bool soundCovoxOnOff);
void Emulator_SetMouse(bool mouseOnOff);
bool Emulator_SetSerial(bool serialOnOff, LPCTSTR serialPort);
void Emulator_SetParallel(bool parallelOnOff);
Expand Down
2 changes: 2 additions & 0 deletions emulator/Main.h
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,8 @@ BOOL Settings_GetSound();
void Settings_SetSoundVolume(WORD value);
BOOL Settings_GetSoundAY();
void Settings_SetSoundAY(BOOL flag);
BOOL Settings_GetSoundCovox();
void Settings_SetSoundCovox(BOOL flag);
WORD Settings_GetSoundVolume();
BOOL Settings_GetMouse();
void Settings_SetMouse(BOOL flag);
Expand Down
14 changes: 14 additions & 0 deletions emulator/MainWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ void MainWindow_DoEmulatorReset();
void MainWindow_DoEmulatorSpeed(WORD speed);
void MainWindow_DoEmulatorSound();
void MainWindow_DoEmulatorSoundAY();
void MainWindow_DoEmulatorSoundCovox();
void MainWindow_DoEmulatorMouse();
void MainWindow_DoEmulatorSerial();
void MainWindow_DoEmulatorParallel();
Expand Down Expand Up @@ -873,6 +874,7 @@ void MainWindow_UpdateMenu()
CheckMenuItem(hMenu, ID_EMULATOR_SOUND, (Settings_GetSound() ? MF_CHECKED : MF_UNCHECKED));
MainWindow_SetToolbarImage(ID_EMULATOR_SOUND, (Settings_GetSound() ? ToolbarImageSoundOn : ToolbarImageSoundOff));
CheckMenuItem(hMenu, ID_EMULATOR_SOUNDAY, (Settings_GetSoundAY() ? MF_CHECKED : MF_UNCHECKED));
CheckMenuItem(hMenu, ID_EMULATOR_SOUNDCOVOX, (Settings_GetSoundCovox() ? MF_CHECKED : MF_UNCHECKED));
CheckMenuItem(hMenu, ID_EMULATOR_MOUSE, (Settings_GetMouse() ? MF_CHECKED : MF_UNCHECKED));
CheckMenuItem(hMenu, ID_EMULATOR_SERIAL, (Settings_GetSerial() ? MF_CHECKED : MF_UNCHECKED));
SendMessage(m_hwndToolbar, TB_CHECKBUTTON, ID_EMULATOR_SERIAL, (Settings_GetSerial() ? 1 : 0));
Expand Down Expand Up @@ -1045,6 +1047,9 @@ bool MainWindow_DoCommand(int commandId)
case ID_EMULATOR_SOUNDAY:
MainWindow_DoEmulatorSoundAY();
break;
case ID_EMULATOR_SOUNDCOVOX:
MainWindow_DoEmulatorSoundCovox();
break;
case ID_EMULATOR_MOUSE:
MainWindow_DoEmulatorMouse();
break;
Expand Down Expand Up @@ -1311,6 +1316,15 @@ void MainWindow_DoEmulatorSoundAY()
MainWindow_UpdateMenu();
}

void MainWindow_DoEmulatorSoundCovox()
{
Settings_SetSoundCovox(!Settings_GetSoundCovox());

Emulator_SetSoundCovox(Settings_GetSoundCovox() != 0);

MainWindow_UpdateMenu();
}

void MainWindow_DoEmulatorMouse()
{
Settings_SetMouse(!Settings_GetMouse());
Expand Down
1 change: 1 addition & 0 deletions emulator/Settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,7 @@ SETTINGS_GETSET_DWORD(RealSpeed, _T("RealSpeed"), WORD, 1);
SETTINGS_GETSET_DWORD(Sound, _T("Sound"), BOOL, FALSE);
SETTINGS_GETSET_DWORD(SoundVolume, _T("SoundVolume"), WORD, 0x3fff);
SETTINGS_GETSET_DWORD(SoundAY, _T("SoundAY"), BOOL, FALSE);
SETTINGS_GETSET_DWORD(SoundCovox, _T("SoundCovox"), BOOL, FALSE);

SETTINGS_GETSET_DWORD(Mouse, _T("Mouse"), BOOL, FALSE);

Expand Down
28 changes: 17 additions & 11 deletions emulator/emubase/Board.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -825,15 +825,15 @@ bool CMotherboard::SystemFrame()
if (m_TapeReadCallback != nullptr) // Tape reading
{
bool tapeBit = (*m_TapeReadCallback)(1);
CSecondMemoryController* pMemCtl = static_cast<CSecondMemoryController*>(m_pSecondMemCtl);
CSecondMemoryController* pMemCtl = dynamic_cast<CSecondMemoryController*>(m_pSecondMemCtl);
if (pMemCtl->TapeInput(tapeBit))
{
m_timerflags |= 040; // Set bit 5 of timer state: external event ready to read
}
}
else if (m_TapeWriteCallback != nullptr) // Tape writing
{
CSecondMemoryController* pMemCtl = static_cast<CSecondMemoryController*>(m_pSecondMemCtl);
CSecondMemoryController* pMemCtl = dynamic_cast<CSecondMemoryController*>(m_pSecondMemCtl);
unsigned int value = pMemCtl->TapeOutput() ? 0xffffffff : 0;
(*m_TapeWriteCallback)(value, 1);
}
Expand All @@ -842,7 +842,7 @@ bool CMotherboard::SystemFrame()

if (m_SerialInCallback != nullptr && frameticks % 416 == 0)
{
CFirstMemoryController* pMemCtl = static_cast<CFirstMemoryController*>(m_pFirstMemCtl);
CFirstMemoryController* pMemCtl = dynamic_cast<CFirstMemoryController*>(m_pFirstMemCtl);
if ((pMemCtl->m_Port176574 & 004) == 0) // Not loopback?
{
uint8_t b;
Expand All @@ -855,7 +855,7 @@ bool CMotherboard::SystemFrame()
}
if (m_SerialOutCallback != nullptr && frameticks % serialOutTicks == 0)
{
CFirstMemoryController* pMemCtl = static_cast<CFirstMemoryController*>(m_pFirstMemCtl);
CFirstMemoryController* pMemCtl = dynamic_cast<CFirstMemoryController*>(m_pFirstMemCtl);
if (serialTxCount > 0)
{
serialTxCount--;
Expand All @@ -881,7 +881,7 @@ bool CMotherboard::SystemFrame()

if (m_NetworkInCallback != nullptr && frameticks % 64 == 0)
{
CFirstMemoryController* pMemCtl = static_cast<CFirstMemoryController*>(m_pFirstMemCtl);
CFirstMemoryController* pMemCtl = dynamic_cast<CFirstMemoryController*>(m_pFirstMemCtl);
if ((pMemCtl->m_Port176564 & 004) == 0) // Not loopback?
{
uint8_t b;
Expand All @@ -897,7 +897,7 @@ bool CMotherboard::SystemFrame()
}
if (m_NetworkOutCallback != nullptr && frameticks % networkOutTicks == 0)
{
CFirstMemoryController* pMemCtl = static_cast<CFirstMemoryController*>(m_pFirstMemCtl);
CFirstMemoryController* pMemCtl = dynamic_cast<CFirstMemoryController*>(m_pFirstMemCtl);
if (networkTxCount > 0)
{
networkTxCount--;
Expand All @@ -924,9 +924,9 @@ bool CMotherboard::SystemFrame()
}
}

if (m_ParallelOutCallback != nullptr)
if (m_ParallelOutCallback != nullptr && !m_okSoundCovox)
{
CSecondMemoryController* pMemCtl = static_cast<CSecondMemoryController*>(m_pSecondMemCtl);
CSecondMemoryController* pMemCtl = dynamic_cast<CSecondMemoryController*>(m_pSecondMemCtl);
if ((pMemCtl->m_Port177102 & 0x80) == 0x80 && (pMemCtl->m_Port177101 & 0x80) == 0x80)
{
// Strobe set, Printer Ack set => reset Printer Ack
Expand Down Expand Up @@ -1495,8 +1495,6 @@ uint16_t CMotherboard::GetKeyboardRegister(void)

void CMotherboard::DoSound(void)
{
int global;

freq_out[0] = (m_timer >> 3) & 1; //8000
if (m_multiply >= 4)
freq_out[0] = 0;
Expand All @@ -1506,7 +1504,7 @@ void CMotherboard::DoSound(void)
freq_out[3] = (m_timer >> 8) & 1; //250
freq_out[4] = (m_timer >> 10) & 1; //60

global = !(freq_out[0] & freq_enable[0]) & ! (freq_out[1] & freq_enable[1]) & !(freq_out[2] & freq_enable[2]) & !(freq_out[3] & freq_enable[3]) & !(freq_out[4] & freq_enable[4]);
int global = !(freq_out[0] & freq_enable[0]) & ! (freq_out[1] & freq_enable[1]) & !(freq_out[2] & freq_enable[2]) & !(freq_out[3] & freq_enable[3]) & !(freq_out[4] & freq_enable[4]);
if (freq_enable[5] == 0)
global = 0;
else
Expand All @@ -1532,6 +1530,14 @@ void CMotherboard::DoSound(void)
value |= valueay << 7;
}

if (m_okSoundCovox)
{
// Get byte from printer port output register, inverted, and merge it with the channel data
CSecondMemoryController* pSecondMemCtl = dynamic_cast<CSecondMemoryController*>(m_pSecondMemCtl);
uint8_t valuecovox = pSecondMemCtl->m_Port177100 ^ 0xff;
value |= valuecovox << 7;
}

if (m_SoundGenCallback != nullptr)
(*m_SoundGenCallback)(value, value);
}
Expand Down
2 changes: 2 additions & 0 deletions emulator/emubase/Board.h
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,7 @@ class CMotherboard

void SetSound(uint16_t val);
void SetSoundAY(bool onoff) { m_okSoundAY = onoff; }
void SetSoundCovox(bool onoff) { m_okSoundCovox = onoff; }
void SetMouse(bool onoff);
private: // Timing
uint16_t m_multiply;
Expand Down Expand Up @@ -322,6 +323,7 @@ class CMotherboard

bool m_okSoundAY;
uint8_t m_nSoundAYReg[3]; ///< AY current register
bool m_okSoundCovox;

private:
TAPEREADCALLBACK m_TapeReadCallback;
Expand Down
3 changes: 2 additions & 1 deletion emulator/res/Resource.h
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,8 @@
#define ID_EMULATOR_SOUND 32831
#define ID_EMULATOR_SOUNDAY 32832
#define ID_EMULATOR_MOUSE 32833
#define ID_VIEW_ONSCREENDISPLAY 32834
#define ID_EMULATOR_SOUNDCOVOX 32834
#define ID_VIEW_ONSCREENDISPLAY 32836
#define ID_VIEW_RENDERMODE 32847
#define ID_VIEW_RENDERMODE1 32848
#define ID_VIEW_RENDERMODE2 32849
Expand Down
1 change: 1 addition & 0 deletions emulator/res/UKNCBTL.rc
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ BEGIN
MENUITEM MFT_SEPARATOR
MENUITEM "Sound", ID_EMULATOR_SOUND,MFT_STRING,MFS_ENABLED
MENUITEM "AY Device on PPU", ID_EMULATOR_SOUNDAY
MENUITEM "Covox on PPU I/O Port A", ID_EMULATOR_SOUNDCOVOX
MENUITEM MFT_SEPARATOR
MENUITEM "Speed 25%", ID_EMULATOR_SPEED25
MENUITEM "Speed 50%", ID_EMULATOR_SPEED50,MFT_STRING,MFS_ENABLED
Expand Down

0 comments on commit 628048c

Please sign in to comment.