aboutsummaryrefslogtreecommitdiff
path: root/audio/softsynth/mt32.cpp
diff options
context:
space:
mode:
authorColin Snover2016-11-24 09:24:00 -0600
committerColin Snover2016-11-25 12:14:13 -0600
commitb4dbd6d3c275097b4be964b7da4478ff930cbaa7 (patch)
treebb9039cb088654fc93a7048eae799d53b06f3aa9 /audio/softsynth/mt32.cpp
parentb5b5c4f341530c41c73cc0d97e7ddae9cbc1d926 (diff)
downloadscummvm-rg350-b4dbd6d3c275097b4be964b7da4478ff930cbaa7.tar.gz
scummvm-rg350-b4dbd6d3c275097b4be964b7da4478ff930cbaa7.tar.bz2
scummvm-rg350-b4dbd6d3c275097b4be964b7da4478ff930cbaa7.zip
MT32: Update Munt to 2.0.0
This changeset also removes unnecessary direct modifications to Munt code to ease future updates. To update Munt in the future: 1. Replace all source files in the `softsynth/mt32` directory with new files from the upstream `mt32emu/src` directory; 2. Update `config.h` with the correct version number for the new version of Munt; 3. Update `module.mk` to match the list of sources given in `mt32emu/CMakeLists.txt libmt32emu_SOURCES`.
Diffstat (limited to 'audio/softsynth/mt32.cpp')
-rw-r--r--audio/softsynth/mt32.cpp66
1 files changed, 63 insertions, 3 deletions
diff --git a/audio/softsynth/mt32.cpp b/audio/softsynth/mt32.cpp
index aaf95b65da..8ed1e7cf71 100644
--- a/audio/softsynth/mt32.cpp
+++ b/audio/softsynth/mt32.cpp
@@ -20,6 +20,18 @@
*
*/
+#define FORBIDDEN_SYMBOL_EXCEPTION_FILE
+#define FORBIDDEN_SYMBOL_EXCEPTION_fclose
+#define FORBIDDEN_SYMBOL_EXCEPTION_fopen
+#define FORBIDDEN_SYMBOL_EXCEPTION_fprintf
+#define FORBIDDEN_SYMBOL_EXCEPTION_fread
+#define FORBIDDEN_SYMBOL_EXCEPTION_fseek
+#define FORBIDDEN_SYMBOL_EXCEPTION_fwrite
+#define FORBIDDEN_SYMBOL_EXCEPTION_printf
+#define FORBIDDEN_SYMBOL_EXCEPTION_vfprintf
+#define FORBIDDEN_SYMBOL_EXCEPTION_vprintf
+#define FORBIDDEN_SYMBOL_EXCEPTION_time_h
+
#include "common/scummsys.h"
#include "common/system.h"
@@ -27,6 +39,7 @@
#include "audio/softsynth/mt32/mt32emu.h"
#include "audio/softsynth/mt32/ROMInfo.h"
+#include "audio/softsynth/mt32/sha1/sha1.h"
#include "audio/softsynth/emumidi.h"
#include "audio/musicplugin.h"
@@ -54,6 +67,53 @@
namespace MT32Emu {
+class ScummVMFile : public MT32Emu::File {
+public:
+ ScummVMFile() {}
+
+ ~ScummVMFile() {
+ close();
+ }
+
+ bool open(const char *fileName) {
+ if (!_file.open(fileName)) {
+ return false;
+ }
+
+ _data = (Bit8u *)malloc(getSize());
+ _file.read(_data, getSize());
+
+ Bit8u rawHash[20];
+ sha1::calc(_data, getSize(), rawHash);
+ sha1::toHexString(rawHash, _digest);
+
+ return true;
+ }
+
+ size_t getSize() {
+ return _file.size();
+ }
+
+ const Bit8u *getData() {
+ return _data;
+ }
+
+ const SHA1Digest &getSHA1() {
+ return _digest;
+ }
+
+ virtual void close() {
+ delete _data;
+ _data = nullptr;
+ _file.close();
+ }
+
+private:
+ byte *_data;
+ Common::File _file;
+ SHA1Digest _digest;
+};
+
class ReportHandlerScummVM : public ReportHandler {
friend class Synth;
@@ -98,7 +158,7 @@ private:
MT32Emu::Synth *_synth;
MT32Emu::ReportHandlerScummVM *_reportHandler;
const MT32Emu::ROMImage *_controlROM, *_pcmROM;
- Common::File *_controlFile, *_pcmFile;
+ MT32Emu::ScummVMFile *_controlFile, *_pcmFile;
void deleteMuntStructures();
int _outputRate;
@@ -195,10 +255,10 @@ int MidiDriver_MT32::open() {
_initializing = true;
debug(4, _s("Initializing MT-32 Emulator"));
- _controlFile = new Common::File();
+ _controlFile = new MT32Emu::ScummVMFile();
if (!_controlFile->open("CM32L_CONTROL.ROM") && !_controlFile->open("MT32_CONTROL.ROM"))
error("Error opening MT32_CONTROL.ROM / CM32L_CONTROL.ROM");
- _pcmFile = new Common::File();
+ _pcmFile = new MT32Emu::ScummVMFile();
if (!_pcmFile->open("CM32L_PCM.ROM") && !_pcmFile->open("MT32_PCM.ROM"))
error("Error opening MT32_PCM.ROM / CM32L_PCM.ROM");
_controlROM = MT32Emu::ROMImage::makeROMImage(_controlFile);