GLK: FROTZ: Implement os_beep method
I instantiate a PCSpeaker instance in the main engine just for beeps, because I don't know any simpler way. But hey, it works.
This commit is contained in:
parent
8393faf036
commit
4c708dc97f
6 changed files with 118 additions and 1 deletions
|
@ -322,6 +322,7 @@ void GlkInterface::os_stop_sample(int a) {
|
|||
}
|
||||
|
||||
void GlkInterface::os_beep(int volume) {
|
||||
beep();
|
||||
}
|
||||
|
||||
bool GlkInterface::os_picture_data(int picture, uint *height, uint *width) {
|
||||
|
|
|
@ -48,7 +48,7 @@ GlkEngine::GlkEngine(OSystem *syst, const GlkGameDescription &gameDesc) :
|
|||
_clipboard(nullptr), _conf(nullptr), _events(nullptr), _pictures(nullptr),
|
||||
_screen(nullptr), _selection(nullptr), _sounds(nullptr), _windows(nullptr),
|
||||
_copySelect(false), _terminated(false), gli_unregister_obj(nullptr),
|
||||
gli_register_arr(nullptr), gli_unregister_arr(nullptr) {
|
||||
_pcSpeaker(nullptr), gli_register_arr(nullptr), gli_unregister_arr(nullptr) {
|
||||
g_vm = this;
|
||||
}
|
||||
|
||||
|
@ -57,6 +57,7 @@ GlkEngine::~GlkEngine() {
|
|||
delete _clipboard;
|
||||
delete _conf;
|
||||
delete _events;
|
||||
delete _pcSpeaker;
|
||||
delete _pictures;
|
||||
delete _screen;
|
||||
delete _selection;
|
||||
|
@ -79,6 +80,7 @@ void GlkEngine::initialize() {
|
|||
_screen->initialize();
|
||||
_clipboard = new Clipboard();
|
||||
_events = new Events();
|
||||
_pcSpeaker = new PCSpeaker(_mixer);
|
||||
_pictures = new Pictures();
|
||||
_selection = new Selection();
|
||||
_sounds = new Sounds();
|
||||
|
@ -199,4 +201,8 @@ Common::Error GlkEngine::saveGameState(int slot, const Common::String &desc) {
|
|||
return result;
|
||||
}
|
||||
|
||||
void GlkEngine::beep() {
|
||||
_pcSpeaker->speakerOn(50, 50);
|
||||
}
|
||||
|
||||
} // End of namespace Glk
|
||||
|
|
|
@ -30,6 +30,7 @@
|
|||
#include "engines/engine.h"
|
||||
#include "glk/glk_types.h"
|
||||
#include "glk/streams.h"
|
||||
#include "glk/pc_speaker.h"
|
||||
|
||||
namespace Glk {
|
||||
|
||||
|
@ -77,6 +78,7 @@ protected:
|
|||
Common::RandomSource _random;
|
||||
int _loadSaveSlot;
|
||||
Common::File _gameFile;
|
||||
PCSpeaker *_pcSpeaker;
|
||||
|
||||
// Engine APIs
|
||||
virtual Common::Error run();
|
||||
|
@ -213,6 +215,11 @@ public:
|
|||
* Save the game to the passed file
|
||||
*/
|
||||
virtual Common::Error saveGameData(strid_t file, const Common::String &desc) = 0;
|
||||
|
||||
/**
|
||||
* Generate a beep
|
||||
*/
|
||||
void beep();
|
||||
};
|
||||
|
||||
extern GlkEngine *g_vm;
|
||||
|
|
|
@ -8,6 +8,7 @@ MODULE_OBJS := \
|
|||
fonts.o \
|
||||
glk.o \
|
||||
glk_api.o \
|
||||
pc_speaker.o \
|
||||
picture.o \
|
||||
raw_decoder.o \
|
||||
screen.o \
|
||||
|
|
52
engines/glk/pc_speaker.cpp
Normal file
52
engines/glk/pc_speaker.cpp
Normal file
|
@ -0,0 +1,52 @@
|
|||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "audio/softsynth/pcspk.h"
|
||||
#include "glk/pc_speaker.h"
|
||||
|
||||
namespace Glk {
|
||||
|
||||
PCSpeaker::PCSpeaker(Audio::Mixer *mixer) : _mixer(mixer) {
|
||||
_stream = new Audio::PCSpeaker(_mixer->getOutputRate());
|
||||
_mixer->playStream(Audio::Mixer::kSFXSoundType,
|
||||
&_handle, _stream, -1, 50, 0, DisposeAfterUse::NO, true);
|
||||
}
|
||||
|
||||
PCSpeaker::~PCSpeaker() {
|
||||
_mixer->stopHandle(_handle);
|
||||
delete _stream;
|
||||
}
|
||||
|
||||
void PCSpeaker::speakerOn(int16 frequency, int32 length) {
|
||||
_stream->play(Audio::PCSpeaker::kWaveFormSquare, frequency, length);
|
||||
}
|
||||
|
||||
void PCSpeaker::speakerOff() {
|
||||
_stream->stop();
|
||||
}
|
||||
|
||||
void PCSpeaker::onUpdate(uint32 millis) {
|
||||
if (_stream->isPlaying())
|
||||
_stream->stop(millis);
|
||||
}
|
||||
|
||||
} // End of namespace Glk
|
50
engines/glk/pc_speaker.h
Normal file
50
engines/glk/pc_speaker.h
Normal file
|
@ -0,0 +1,50 @@
|
|||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef GLK_PC_SPEAKER_H
|
||||
#define GLK_PC_SPEAKER_H
|
||||
|
||||
#include "audio/mixer.h"
|
||||
|
||||
namespace Audio {
|
||||
class PCSpeaker;
|
||||
}
|
||||
|
||||
namespace Glk {
|
||||
|
||||
class PCSpeaker {
|
||||
private:
|
||||
Audio::Mixer *_mixer;
|
||||
Audio::PCSpeaker *_stream;
|
||||
Audio::SoundHandle _handle;
|
||||
public:
|
||||
PCSpeaker(Audio::Mixer *mixer);
|
||||
~PCSpeaker();
|
||||
|
||||
void speakerOn(int16 frequency, int32 length = -1);
|
||||
void speakerOff();
|
||||
void onUpdate(uint32 millis);
|
||||
};
|
||||
|
||||
} // End of namespace Glk
|
||||
|
||||
#endif
|
Loading…
Add table
Add a link
Reference in a new issue