Skip to content

Commit

Permalink
Add option to disable YM2413 from game db
Browse files Browse the repository at this point in the history
  • Loading branch information
drhelius committed Dec 27, 2024
1 parent 666ff54 commit 2cc8716
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
4 changes: 3 additions & 1 deletion src/Audio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ Audio::Audio(Cartridge * pCartridge)
m_bYM2413Enabled = false;
m_bPSGEnabled = true;
m_bYM2413ForceDisabled = false;
m_bYM2413CartridgeNotSupported = false;
m_bMute = false;
}

Expand Down Expand Up @@ -78,6 +79,7 @@ void Audio::Reset(bool bPAL)
m_pBuffer->clock_rate(m_bPAL ? GS_MASTER_CLOCK_PAL : GS_MASTER_CLOCK_NTSC);
m_pYM2413->Reset(m_bPAL ? GS_MASTER_CLOCK_PAL : GS_MASTER_CLOCK_NTSC);
m_ElapsedCycles = 0;
m_bYM2413CartridgeNotSupported = (m_pCartridge->GetFeatures() & GS_DB_FEATURE_DISABLE_YM2413);
}

void Audio::Mute(bool bMute)
Expand Down Expand Up @@ -107,7 +109,7 @@ void Audio::EndFrame(s16* pSampleBuffer, int* pSampleCount)
if (!m_bMute)
{
pSampleBuffer[i] += m_bPSGEnabled ? m_pSampleBuffer[(i >= psg_count) ? psg_count-1 : i] : 0;
pSampleBuffer[i] += (m_bYM2413Enabled && !m_bYM2413ForceDisabled) ? m_pYM2413Buffer[i] * 4 : 0;
pSampleBuffer[i] += (m_bYM2413Enabled && !m_bYM2413ForceDisabled && !m_bYM2413CartridgeNotSupported) ? m_pYM2413Buffer[i] * 4 : 0;
}
}
}
Expand Down
5 changes: 3 additions & 2 deletions src/Audio.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ class Audio
bool m_bYM2413Enabled;
bool m_bPSGEnabled;
bool m_bYM2413ForceDisabled;
bool m_bYM2413CartridgeNotSupported;
Cartridge* m_pCartridge;
s16* m_pYM2413Buffer;
bool m_bMute;
Expand All @@ -81,7 +82,7 @@ inline void Audio::WriteGGStereoRegister(u8 value)

inline void Audio::YM2413Write(u8 port, u8 value)
{
if (m_bYM2413ForceDisabled)
if (m_bYM2413ForceDisabled || m_bYM2413CartridgeNotSupported)
return;

if (port == 0xF2)
Expand All @@ -106,7 +107,7 @@ inline void Audio::YM2413Write(u8 port, u8 value)

inline u8 Audio::YM2413Read(u8 port)
{
if (m_bYM2413ForceDisabled)
if (m_bYM2413ForceDisabled || m_bYM2413CartridgeNotSupported)
return 0xFF;
else
return m_pYM2413->Read(port);
Expand Down
5 changes: 5 additions & 0 deletions src/game_db.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
#define GS_DB_FEATURE_NO_BATTERY 0x04
#define GS_DB_FEATURE_YM2413 0x08
#define GS_DB_FEATURE_INITIAL_VINT 0x10
#define GS_DB_FEATURE_DISABLE_YM2413 0x20

struct GS_GameDBEntry
{
Expand Down Expand Up @@ -404,8 +405,12 @@ const GS_GameDBEntry kGameDatabase[] =
{0x7F667485, GS_DB_KOREAN_MD_FFF5_MAPPER, GS_DB_FEATURE_NONE, "Mega Mode Super Game 138"},
{0xC0AC6956, GS_DB_KOREAN_MD_FFF5_MAPPER, GS_DB_FEATURE_NONE, "Pigu-Wang 7 Hap - Jaemiiss-neun Game Mo-eumjip"},

// Requires vint flag on boot
{0xD9096263, GS_DB_DEFAULT_MAPPER, GS_DB_FEATURE_INITIAL_VINT, "Sonic's Edusoft [Proto]"},

// Does not work if YM2413 is enabled
{0x5359762D, GS_DB_DEFAULT_MAPPER, GS_DB_FEATURE_DISABLE_YM2413, "Wanted"},

{0, 0, 0, 0}
};

Expand Down

0 comments on commit 2cc8716

Please sign in to comment.