aboutsummaryrefslogtreecommitdiff
path: root/sound/softsynth/opl/mame.cpp
diff options
context:
space:
mode:
authorJohannes Schickel2009-05-05 21:47:12 +0000
committerJohannes Schickel2009-05-05 21:47:12 +0000
commit08581ed69811d50e20eab2a3b491a49b0a494d60 (patch)
tree51aee65255a47ba721aaee5f52770d0453fad2a2 /sound/softsynth/opl/mame.cpp
parentd9e0499a36004023dea3dfd95312b1d91eca5bbc (diff)
downloadscummvm-rg350-08581ed69811d50e20eab2a3b491a49b0a494d60.tar.gz
scummvm-rg350-08581ed69811d50e20eab2a3b491a49b0a494d60.tar.bz2
scummvm-rg350-08581ed69811d50e20eab2a3b491a49b0a494d60.zip
AdLib emulator changes part2:
- Add new OPL emulator API (and legacy access API) in sound/fmopl.h - Add DOSBox OPL emulator. - Update MAME OPL emulator for the API changes. svn-id: r40334
Diffstat (limited to 'sound/softsynth/opl/mame.cpp')
-rw-r--r--sound/softsynth/opl/mame.cpp46
1 files changed, 43 insertions, 3 deletions
diff --git a/sound/softsynth/opl/mame.cpp b/sound/softsynth/opl/mame.cpp
index 4834e586c3..6427469a59 100644
--- a/sound/softsynth/opl/mame.cpp
+++ b/sound/softsynth/opl/mame.cpp
@@ -31,12 +31,48 @@
#include <stdarg.h>
#include <math.h>
-#include "sound/fmopl.h"
+#include "mame.h"
#if defined (_WIN32_WCE) || defined (__SYMBIAN32__) || defined(PALMOS_MODE) || defined(__GP32__) || defined(GP2X) || defined (__MAEMO__) || defined(__DS__) || defined (__MINT__)
#include "common/config-manager.h"
#endif
+namespace OPL {
+namespace MAME {
+
+OPL_MAME::~OPL_MAME() {
+ MAME::OPLDestroy(_opl);
+ _opl = 0;
+}
+
+bool OPL_MAME::init(int rate) {
+ if (_opl)
+ MAME::OPLDestroy(_opl);
+
+ _opl = MAME::makeAdlibOPL(rate);
+ return (_opl != 0);
+}
+
+void OPL_MAME::reset() {
+ MAME::OPLResetChip(_opl);
+}
+
+void OPL_MAME::write(int a, int v) {
+ MAME::OPLWrite(_opl, a, v);
+}
+
+byte OPL_MAME::read(int a) {
+ return MAME::OPLRead(_opl, a);
+}
+
+void OPL_MAME::writeReg(int r, int v) {
+ MAME::OPLWriteReg(_opl, r, v);
+}
+
+void OPL_MAME::readBuffer(int16 *buffer, int length) {
+ MAME::YM3812UpdateOne(_opl, buffer, length);
+}
+
/* -------------------- preliminary define section --------------------- */
/* attack/decay rate time rate */
#define OPL_ARRATE 141280 /* RATE 4 = 2826.24ms @ 3.6MHz */
@@ -978,7 +1014,7 @@ static void OPL_UnLockTable(void) {
/*******************************************************************************/
/* ---------- update one of chip ----------- */
-void YM3812UpdateOne(FM_OPL *OPL, int16 *buffer, int length, int interleave) {
+void YM3812UpdateOne(FM_OPL *OPL, int16 *buffer, int length) {
int i;
int data;
int16 *buf = buffer;
@@ -1020,7 +1056,7 @@ void YM3812UpdateOne(FM_OPL *OPL, int16 *buffer, int length, int interleave) {
/* limit check */
data = CLIP(outd[0], OPL_MINOUT, OPL_MAXOUT);
/* store to sound buffer */
- buf[i << interleave] = data >> OPL_OUTSB;
+ buf[i] = data >> OPL_OUTSB;
}
OPL->amsCnt = amsCnt;
@@ -1189,3 +1225,7 @@ FM_OPL *makeAdlibOPL(int rate) {
OPLBuildTables(env_bits, eg_ent);
return OPLCreate(OPL_TYPE_YM3812, 3579545, rate);
}
+
+} // end of namespace MAME
+} // end of namespace OPL
+