📄 audiooptions.pas
字号:
//////////////////////////////////////////////////////////////////////
// //
// AudioOptions.pas: Audio Options Dialog //
// //
// The contents of this file are subject to the Bottled Light //
// Public License Version 1.0 (the "License"); you may not use this //
// file except in compliance with the License. You may obtain a //
// copy of the License at http://www.bottledlight.com/BLPL/ //
// //
// Software distributed under the License is distributed on an //
// "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or //
// implied. See the License for the specific language governing //
// rights and limitations under the License. //
// //
// The Original Code is the Mappy VM User Interface, released //
// April 1st, 2003. The Initial Developer of the Original Code is //
// Bottled Light, Inc. Portions created by Bottled Light, Inc. are //
// Copyright (C) 2001-2003 Bottled Light, Inc. All Rights Reserved. //
// //
// Author(s): //
// Michael Noland (joat), michael@bottledlight.com //
// //
// Changelog: //
// 1.0: First public release (April 1st, 2003) //
// //
// Notes: //
// None at present. //
// //
//////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////
unit AudioOptions; ///////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////
interface ////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms,
Dialogs, IniFiles, StdCtrls, CheckLst, ExtCtrls, CpuObservers,
console, nexus;
//////////////////////////////////////////////////////////////////////
type
TAudioOptionsDialog = class(TCpuObserver)
frequencies: TRadioGroup;
muteGroup: TGroupBox;
mutedChannels: TCheckListBox;
procedure FormCreate(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure changePlaybackFrequency(Sender: TObject);
procedure changeChannelMutes(Sender: TObject);
public
procedure UpdateObserver; override;
class function OCaption: string; override;
procedure LoadSettings(ini: TIniFile); override;
procedure SaveSettings(ini: TIniFile); override;
end;
//////////////////////////////////////////////////////////////////////
var
AudioOptionsDialog: TAudioOptionsDialog;
//////////////////////////////////////////////////////////////////////
procedure LoadAudioOptions(ini: TIniFile);
procedure SaveAudioOptions(ini: TIniFile);
//////////////////////////////////////////////////////////////////////
implementation ///////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////
uses
platformSound;
//////////////////////////////////////////////////////////////////////
{$R *.DFM}
//////////////////////////////////////////////////////////////////////
var
muteMask: integer;
//////////////////////////////////////////////////////////////////////
procedure SetChannelMutes;
begin
vmSetOption(PChar('enableGBC1'), muteMask and 1 = 0);
vmSetOption(PChar('enableGBC2'), muteMask and 2 = 0);
vmSetOption(PChar('enableGBC3'), muteMask and 4 = 0);
vmSetOption(PChar('enableGBC4'), muteMask and 8 = 0);
vmSetOption(PChar('enableDSA'), muteMask and 16 = 0);
vmSetOption(PChar('enableDSB'), muteMask and 32 = 0);
end;
//////////////////////////////////////////////////////////////////////
// TAudioOptionsDialog ///////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////
procedure TAudioOptionsDialog.FormCreate(Sender: TObject);
begin
HelpContext := LinkHelp('audio_options.html');
end;
//////////////////////////////////////////////////////////////////////
procedure TAudioOptionsDialog.FormShow(Sender: TObject);
begin
// Playback rate
case sysSound.frequency of
8000: frequencies.ItemIndex := 0;
11025: frequencies.ItemIndex := 1;
22050: frequencies.ItemIndex := 2;
44100: frequencies.ItemIndex := 3;
else
frequencies.ItemIndex := 4;
end;
// Muted channels
mutedChannels.Checked[0] := muteMask and 1 <> 0;
mutedChannels.Checked[1] := muteMask and 2 <> 0;
mutedChannels.Checked[2] := muteMask and 4 <> 0;
mutedChannels.Checked[3] := muteMask and 8 <> 0;
mutedChannels.Checked[4] := muteMask and 16 <> 0;
mutedChannels.Checked[5] := muteMask and 32 <> 0;
// Load the translation
LoadTranslation(self, translation);
end;
//////////////////////////////////////////////////////////////////////
procedure TAudioOptionsDialog.changePlaybackFrequency(Sender: TObject);
begin
case frequencies.ItemIndex of
0: sysSound.Frequency := 8000;
1: sysSound.Frequency := 11025;
2: sysSound.Frequency := 22050;
3: sysSound.Frequency := 44100;
end;
end;
//////////////////////////////////////////////////////////////////////
procedure TAudioOptionsDialog.changeChannelMutes(Sender: TObject);
var
i: integer;
begin
muteMask := 0;
for i := 0 to 5 do
if mutedChannels.Checked[i] then muteMask := muteMask or (1 shl i);
SetChannelMutes;
end;
//////////////////////////////////////////////////////////////////////
// Audio Preferences /////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////
procedure LoadAudioOptions(ini: TIniFile);
begin
muteMask := ini.ReadInteger('Sound', 'ChannelMutes', $0);
sysSound.Frequency := ini.ReadInteger('Sound', 'Frequency', 22050);
SetChannelMutes;
end;
//////////////////////////////////////////////////////////////////////
procedure SaveAudioOptions(ini: TIniFile);
begin
ini.WriteInteger('Sound', 'ChannelMutes', muteMask);
ini.WriteInteger('Sound', 'Frequency', sysSound.Frequency);
end;
//////////////////////////////////////////////////////////////////////
procedure TAudioOptionsDialog.LoadSettings(ini: TIniFile);
begin
inherited;
end;
//////////////////////////////////////////////////////////////////////
class function TAudioOptionsDialog.OCaption: string;
begin
Result := 'Audio Options'
end;
//////////////////////////////////////////////////////////////////////
procedure TAudioOptionsDialog.SaveSettings(ini: TIniFile);
begin
inherited;
end;
//////////////////////////////////////////////////////////////////////
procedure TAudioOptionsDialog.UpdateObserver;
begin
//
end;
//////////////////////////////////////////////////////////////////////
initialization
RegisterDialog(TAudioOptionsDialog);
end.
//////////////////////////////////////////////////////////////////////
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -