[Scummvm-git-logs] scummvm master -> 4c708dc97f5c515ba01aee0d5610489fa43fa1f9
dreammaster
paulfgilbert at gmail.com
Sun Mar 3 05:44:21 CET 2019
This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
4c708dc97f GLK: FROTZ: Implement os_beep method
Commit: 4c708dc97f5c515ba01aee0d5610489fa43fa1f9
https://github.com/scummvm/scummvm/commit/4c708dc97f5c515ba01aee0d5610489fa43fa1f9
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2019-03-02T20:43:19-08:00
Commit Message:
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.
Changed paths:
A engines/glk/pc_speaker.cpp
A engines/glk/pc_speaker.h
engines/glk/frotz/glk_interface.cpp
engines/glk/glk.cpp
engines/glk/glk.h
engines/glk/module.mk
diff --git a/engines/glk/frotz/glk_interface.cpp b/engines/glk/frotz/glk_interface.cpp
index 7e14e40..69b1dc5 100644
--- a/engines/glk/frotz/glk_interface.cpp
+++ b/engines/glk/frotz/glk_interface.cpp
@@ -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) {
diff --git a/engines/glk/glk.cpp b/engines/glk/glk.cpp
index f39ef6a..13f185d 100644
--- a/engines/glk/glk.cpp
+++ b/engines/glk/glk.cpp
@@ -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
diff --git a/engines/glk/glk.h b/engines/glk/glk.h
index 17ee356..9064105 100644
--- a/engines/glk/glk.h
+++ b/engines/glk/glk.h
@@ -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;
diff --git a/engines/glk/module.mk b/engines/glk/module.mk
index a51fb7e..a38750e 100644
--- a/engines/glk/module.mk
+++ b/engines/glk/module.mk
@@ -8,6 +8,7 @@ MODULE_OBJS := \
fonts.o \
glk.o \
glk_api.o \
+ pc_speaker.o \
picture.o \
raw_decoder.o \
screen.o \
diff --git a/engines/glk/pc_speaker.cpp b/engines/glk/pc_speaker.cpp
new file mode 100644
index 0000000..cbfce3e
--- /dev/null
+++ b/engines/glk/pc_speaker.cpp
@@ -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
diff --git a/engines/glk/pc_speaker.h b/engines/glk/pc_speaker.h
new file mode 100644
index 0000000..8c3d1ad
--- /dev/null
+++ b/engines/glk/pc_speaker.h
@@ -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
More information about the Scummvm-git-logs
mailing list