MOVED sample rate selection from menu to audio core settings dialog

Code cleanup
This commit is contained in:
spacy51 2008-09-04 12:28:31 +00:00
parent ecc0ec3f43
commit 4e35f820a4
9 changed files with 67 additions and 93 deletions

View File

@ -36,28 +36,26 @@ typedef union {
u16 W;
} gbRegister;
extern bool gbLoadRom(const char *);
extern void gbEmulate(int);
extern void gbWriteMemory(register u16, register u8);
extern void gbDrawLine();
extern bool gbIsGameboyRom(const char *);
extern void gbSoundReset();
extern void gbSoundSetQuality(int);
extern void gbGetHardwareType();
extern void gbReset();
extern void gbCleanUp();
extern void gbCPUInit(const char *,bool);
extern bool gbWriteBatteryFile(const char *);
extern bool gbWriteBatteryFile(const char *, bool);
extern bool gbReadBatteryFile(const char *);
extern bool gbWriteSaveState(const char *);
extern bool gbWriteMemSaveState(char *, int);
extern bool gbReadSaveState(const char *);
extern bool gbReadMemSaveState(char *, int);
extern void gbSgbRenderBorder();
extern bool gbWritePNGFile(const char *);
extern bool gbWriteBMPFile(const char *);
extern bool gbReadGSASnapshot(const char *);
bool gbLoadRom(const char *);
void gbEmulate(int);
void gbWriteMemory(register u16, register u8);
void gbDrawLine();
bool gbIsGameboyRom(const char *);
void gbGetHardwareType();
void gbReset();
void gbCleanUp();
void gbCPUInit(const char *,bool);
bool gbWriteBatteryFile(const char *);
bool gbWriteBatteryFile(const char *, bool);
bool gbReadBatteryFile(const char *);
bool gbWriteSaveState(const char *);
bool gbWriteMemSaveState(char *, int);
bool gbReadSaveState(const char *);
bool gbReadMemSaveState(char *, int);
void gbSgbRenderBorder();
bool gbWritePNGFile(const char *);
bool gbWriteBMPFile(const char *);
bool gbReadGSASnapshot(const char *);
extern struct EmulatedSystem GBSystem;

View File

@ -18,6 +18,7 @@ AudioCoreSettingsDlg::AudioCoreSettingsDlg(CWnd* pParent /*=NULL*/)
, m_stereo( 0.0f )
, m_volume( 0.0f )
, m_sound_filtering( 0.0f )
, m_sample_rate( 0 )
, toolTip( NULL )
{
}
@ -39,6 +40,7 @@ void AudioCoreSettingsDlg::DoDataExchange(CDataExchange* pDX)
DDX_Control(pDX, IDC_DECLICKING, declicking);
DDX_Control(pDX, IDC_SOUND_INTERPOLATION, sound_interpolation);
DDX_Control(pDX, IDC_SOUND_FILTERING, sound_filtering);
DDX_Control(pDX, IDC_SAMPLE_RATE, sample_rate);
if( pDX->m_bSaveAndValidate == TRUE ) {
m_enabled = BST_CHECKED == enhance_sound.GetCheck();
@ -49,6 +51,7 @@ void AudioCoreSettingsDlg::DoDataExchange(CDataExchange* pDX)
m_stereo = (float)stereo.GetPos() / 100.0f;
m_volume = (float)volume.GetPos() / 100.0f;
m_sound_filtering = (float)sound_filtering.GetPos() / 100.0f;
m_sample_rate = (unsigned int)sample_rate.GetItemData( sample_rate.GetCurSel() );
}
}
@ -153,6 +156,18 @@ BOOL AudioCoreSettingsDlg::OnInitDialog()
volume.SetRange( (int)( MIN_VOLUME * 100.0f ), (int)( MAX_VOLUME * 100.0f ) );
volume.SetPos( (int)( m_volume * 100.0f ) );
unsigned int rate = 44100;
CString temp;
for( int i = 0 ; i <= 2 ; i++ ) {
temp.Format( _T("%u Hz"), rate );
int id = sample_rate.AddString( temp.GetString() );
sample_rate.SetItemData( id, rate );
if( rate == m_sample_rate ) {
sample_rate.SetCurSel( id );
}
rate /= 2;
}
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}

View File

@ -20,6 +20,7 @@ public:
float m_stereo;
float m_volume;
float m_sound_filtering;
unsigned int m_sample_rate;
AudioCoreSettingsDlg(CWnd* pParent = NULL); // standard constructor
virtual ~AudioCoreSettingsDlg();
@ -47,4 +48,5 @@ private:
CSliderCtrl volume;
CSliderCtrl sound_filtering;
CToolTipCtrl *toolTip;
CComboBox sample_rate;
};

View File

@ -147,9 +147,6 @@ struct {
{ "OptionsSoundChannel4", ID_OPTIONS_SOUND_CHANNEL4 },
{ "OptionsSoundDirectSoundA", ID_OPTIONS_SOUND_DIRECTSOUNDA },
{ "OptionsSoundDirectSoundB", ID_OPTIONS_SOUND_DIRECTSOUNDB },
{ "OptionsSound11Khz", ID_OPTIONS_SOUND_11KHZ },
{ "OptionsSound22Khz", ID_OPTIONS_SOUND_22KHZ },
{ "OptionsSound44Khz", ID_OPTIONS_SOUND_44KHZ },
{ "OptionsGameboyBorder", ID_OPTIONS_GAMEBOY_BORDER },
{ "OptionsGameboyBorderAutomatic", ID_OPTIONS_GAMEBOY_BORDERAUTOMATIC },
{ "OptionsGameboyColors", ID_OPTIONS_GAMEBOY_COLORS },

View File

@ -39,6 +39,7 @@
#include "../Flash.h"
#include "../Globals.h"
#include "../dmg/GB.h"
#include "../dmg/gbSound.h"
#include "../dmg/gbCheats.h"
#include "../dmg/gbGlobals.h"
#include "../RTC.h"
@ -204,12 +205,6 @@ BEGIN_MESSAGE_MAP(MainWnd, CWnd)
ON_UPDATE_COMMAND_UI(ID_OPTIONS_EMULATOR_PNGFORMAT, OnUpdateOptionsEmulatorPngformat)
ON_COMMAND(ID_OPTIONS_EMULATOR_BMPFORMAT, OnOptionsEmulatorBmpformat)
ON_UPDATE_COMMAND_UI(ID_OPTIONS_EMULATOR_BMPFORMAT, OnUpdateOptionsEmulatorBmpformat)
ON_COMMAND(ID_OPTIONS_SOUND_11KHZ, OnOptionsSound11khz)
ON_UPDATE_COMMAND_UI(ID_OPTIONS_SOUND_11KHZ, OnUpdateOptionsSound11khz)
ON_COMMAND(ID_OPTIONS_SOUND_22KHZ, OnOptionsSound22khz)
ON_UPDATE_COMMAND_UI(ID_OPTIONS_SOUND_22KHZ, OnUpdateOptionsSound22khz)
ON_COMMAND(ID_OPTIONS_SOUND_44KHZ, OnOptionsSound44khz)
ON_UPDATE_COMMAND_UI(ID_OPTIONS_SOUND_44KHZ, OnUpdateOptionsSound44khz)
ON_COMMAND(ID_OPTIONS_SOUND_CHANNEL1, OnOptionsSoundChannel1)
ON_UPDATE_COMMAND_UI(ID_OPTIONS_SOUND_CHANNEL1, OnUpdateOptionsSoundChannel1)
ON_COMMAND(ID_OPTIONS_SOUND_CHANNEL2, OnOptionsSoundChannel2)
@ -422,6 +417,7 @@ BEGIN_MESSAGE_MAP(MainWnd, CWnd)
ON_UPDATE_COMMAND_UI(ID_OUTPUTAPI_XAUDIO2CONFIG, &MainWnd::OnUpdateOutputapiXaudio2config)
ON_WM_ENTERSIZEMOVE()
ON_COMMAND(ID_AUDIO_CORE_SETTINGS, &MainWnd::OnAudioCoreSettings)
ON_UPDATE_COMMAND_UI(ID_AUDIO_CORE_SETTINGS, &MainWnd::OnUpdateAudioCoreSettings)
END_MESSAGE_MAP()

View File

@ -49,6 +49,10 @@ public:
void winSaveCheatList(const char *name);
void winSaveCheatListDefault();
DECLARE_MESSAGE_MAP()
protected:
virtual BOOL PreTranslateMessage(MSG* pMsg);
afx_msg LRESULT OnMySysCommand(WPARAM, LPARAM);
@ -203,12 +207,6 @@ public:
afx_msg void OnUpdateOptionsEmulatorPngformat(CCmdUI* pCmdUI);
afx_msg void OnOptionsEmulatorBmpformat();
afx_msg void OnUpdateOptionsEmulatorBmpformat(CCmdUI* pCmdUI);
afx_msg void OnOptionsSound11khz();
afx_msg void OnUpdateOptionsSound11khz(CCmdUI* pCmdUI);
afx_msg void OnOptionsSound22khz();
afx_msg void OnUpdateOptionsSound22khz(CCmdUI* pCmdUI);
afx_msg void OnOptionsSound44khz();
afx_msg void OnUpdateOptionsSound44khz(CCmdUI* pCmdUI);
afx_msg void OnOptionsSoundChannel1();
afx_msg void OnUpdateOptionsSoundChannel1(CCmdUI* pCmdUI);
afx_msg void OnOptionsSoundChannel2();
@ -384,7 +382,8 @@ public:
afx_msg void OnLoadgameDonotchangebatterysave();
afx_msg void OnUpdateLoadgameDonotchangebatterysave(CCmdUI *pCmdUI);
DECLARE_MESSAGE_MAP()
afx_msg void OnEnterSizeMove();
afx_msg void OnAudioCoreSettings();
afx_msg void OnUpdateAudioCoreSettings(CCmdUI *pCmdUI);
};

View File

@ -812,6 +812,7 @@ void MainWnd::OnAudioCoreSettings()
dlg.m_declicking = gbSoundGetDeclicking();
dlg.m_sound_interpolation = soundInterpolation;
dlg.m_sound_filtering = soundFiltering;
dlg.m_sample_rate = 44100 / soundQuality;
if( IDOK == dlg.DoModal() ) {
gb_effects_config_t _new;
@ -830,49 +831,18 @@ void MainWnd::OnAudioCoreSettings()
soundInterpolation = dlg.m_sound_interpolation;
soundFiltering = dlg.m_sound_filtering;
if( theApp.cartridgeType == IMAGE_GBA ) {
soundSetQuality( 44100 / dlg.m_sample_rate );
} else if( theApp.cartridgeType == IMAGE_GB ) {
gbSoundSetQuality( 44100 / dlg.m_sample_rate );
}
}
}
void MainWnd::OnOptionsSound11khz()
void MainWnd::OnUpdateAudioCoreSettings(CCmdUI *pCmdUI)
{
if(theApp.cartridgeType == 0)
soundSetQuality(4);
else
gbSoundSetQuality(4);
}
void MainWnd::OnUpdateOptionsSound11khz(CCmdUI* pCmdUI)
{
pCmdUI->SetCheck(soundQuality == 4);
pCmdUI->Enable(!theApp.aviRecording && !theApp.soundRecording);
}
void MainWnd::OnOptionsSound22khz()
{
if(theApp.cartridgeType == 0)
soundSetQuality(2);
else
gbSoundSetQuality(2);
}
void MainWnd::OnUpdateOptionsSound22khz(CCmdUI* pCmdUI)
{
pCmdUI->SetCheck(soundQuality == 2);
pCmdUI->Enable(!theApp.aviRecording && !theApp.soundRecording);
}
void MainWnd::OnOptionsSound44khz()
{
if(theApp.cartridgeType == 0)
soundSetQuality(1);
else
gbSoundSetQuality(1);
}
void MainWnd::OnUpdateOptionsSound44khz(CCmdUI* pCmdUI)
{
pCmdUI->SetCheck(soundQuality == 1);
pCmdUI->Enable(!theApp.aviRecording && !theApp.soundRecording);
pCmdUI->Enable( ( !theApp.aviRecording && !theApp.soundRecording ) ? TRUE : FALSE );
}
void MainWnd::updateSoundChannels(UINT id)

View File

@ -1185,11 +1185,11 @@ BEGIN
CONTROL "",IDC_STEREO,"msctls_trackbar32",TBS_BOTH | TBS_NOTICKS | TBS_TOOLTIPS | WS_TABSTOP,192,109,120,12
LTEXT "Center",IDC_STATIC,192,120,36,8,SS_CENTERIMAGE
RTEXT "Left/Right",IDC_STATIC,276,120,36,8,SS_CENTERIMAGE
GROUPBOX "Volume",IDC_STATIC,6,6,156,42
CONTROL "",IDC_VOLUME,"msctls_trackbar32",TBS_BOTH | TBS_NOTICKS | TBS_TOOLTIPS | WS_TABSTOP,12,18,144,12
LTEXT "Mute",IDC_STATIC,12,30,48,12,SS_CENTERIMAGE
RTEXT "Maximum",IDC_STATIC,108,30,48,12,SS_CENTERIMAGE
PUSHBUTTON "Default",IDC_DEFAULT_VOLUME,66,30,36,12,BS_NOTIFY
GROUPBOX "Shared",IDC_STATIC,6,6,156,66
CONTROL "",IDC_VOLUME,"msctls_trackbar32",TBS_BOTH | TBS_NOTICKS | TBS_TOOLTIPS | WS_TABSTOP,42,18,114,12
LTEXT "Mute",IDC_STATIC,42,30,36,12,SS_CENTERIMAGE
RTEXT "Maximum",IDC_STATIC,120,30,36,12,SS_CENTERIMAGE
PUSHBUTTON "Default",IDC_DEFAULT_VOLUME,78,30,42,12,BS_NOTIFY
CONTROL "Declicking",IDC_DECLICKING,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,174,18,47,10
GROUPBOX "Game Boy Advance only",IDC_STATIC,6,78,156,66
CONTROL "Sound interpolation",IDC_SOUND_INTERPOLATION,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,90,78,10
@ -1197,6 +1197,9 @@ BEGIN
CONTROL "",IDC_SOUND_FILTERING,"msctls_trackbar32",TBS_BOTH | TBS_NOTICKS | TBS_TOOLTIPS | WS_TABSTOP,18,115,132,12
LTEXT "None",IDC_STATIC,18,126,36,8,SS_CENTERIMAGE
RTEXT "Maximum",IDC_STATIC,114,126,36,8,SS_CENTERIMAGE
LTEXT "Volume:",IDC_STATIC,12,18,30,12,SS_CENTERIMAGE
LTEXT "Sample rate:",IDC_STATIC,12,54,48,12,SS_CENTERIMAGE
COMBOBOX IDC_SAMPLE_RATE,66,54,66,12,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
END
@ -1774,26 +1777,19 @@ BEGIN
BEGIN
POPUP "Output API"
BEGIN
MENUITEM "DirectSound", ID_OUTPUTAPI_DIRECTSOUND
MENUITEM SEPARATOR
MENUITEM "XAudio2", ID_OUTPUTAPI_XAUDIO2
MENUITEM " Configuration...", ID_OUTPUTAPI_XAUDIO2CONFIG
MENUITEM SEPARATOR
MENUITEM "OpenAL", ID_OUTPUTAPI_OPENAL
MENUITEM " Configuration...", ID_OUTPUTAPI_OALCONFIGURATION
MENUITEM SEPARATOR
MENUITEM "DirectSound", ID_OUTPUTAPI_DIRECTSOUND
MENUITEM SEPARATOR
MENUITEM "&Sync game to audio", ID_OPTIONS_EMULATOR_SYNCHRONIZE
END
MENUITEM SEPARATOR
MENUITEM "Core Settings...", ID_AUDIO_CORE_SETTINGS
MENUITEM SEPARATOR
POPUP "Sampling Rate"
BEGIN
MENUITEM "&11025 Hz", ID_OPTIONS_SOUND_11KHZ
MENUITEM "&22050 Hz", ID_OPTIONS_SOUND_22KHZ
MENUITEM "&44100 Hz", ID_OPTIONS_SOUND_44KHZ
END
MENUITEM SEPARATOR
POPUP "Sound Channels"
BEGIN
MENUITEM "Channel &1", ID_OPTIONS_SOUND_CHANNEL1, CHECKED

View File

@ -50,7 +50,6 @@
#define IDS_TOOLTIP_ENHANCE_SOUND 43
#define IDS_TOOLTIP_SURROUND 44
#define IDS_TOOLTIP_DECLICKING 45
#define IDS_TOOLTIP_SOUND_INTERPOLATION 46
#define IDI_MAINICON 101
#define IDD_REGISTERS 102
#define IDD_DEBUG 103
@ -555,6 +554,8 @@
#define IDC_DEFAULT_VOLUME 1292
#define IDC_DECLICKING 1293
#define IDC_SOUND_FILTERING 1294
#define IDC_COMBO1 1296
#define IDC_SAMPLE_RATE 1296
#define IDS_OAL_NODEVICE 2000
#define IDS_OAL_NODLL 2001
#define IDS_AVI_CANNOT_CREATE_AVI 2002
@ -872,7 +873,7 @@
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 165
#define _APS_NEXT_COMMAND_VALUE 40366
#define _APS_NEXT_CONTROL_VALUE 1296
#define _APS_NEXT_CONTROL_VALUE 1297
#define _APS_NEXT_SYMED_VALUE 103
#endif
#endif