summaryrefslogtreecommitdiff
path: root/plugins/adplug/adplug
diff options
context:
space:
mode:
authorGravatar waker <wakeroid@gmail.com>2012-03-27 21:42:03 +0200
committerGravatar waker <wakeroid@gmail.com>2012-03-27 21:42:03 +0200
commit9d543026987566abc992fcae3a57edbf1f3e5477 (patch)
treed7290849ca61c49801e948d1fa2d92448f968530 /plugins/adplug/adplug
parent001229a3b3d2c877c21e55b4511b73edb94fc748 (diff)
merge in adplug 2.2.1
Diffstat (limited to 'plugins/adplug/adplug')
-rw-r--r--plugins/adplug/adplug/adl.cpp2
-rw-r--r--plugins/adplug/adplug/adtrack.cpp7
-rw-r--r--plugins/adplug/adplug/cmf.cpp40
3 files changed, 26 insertions, 23 deletions
diff --git a/plugins/adplug/adplug/adl.cpp b/plugins/adplug/adplug/adl.cpp
index 6febbf87..1dd95ea8 100644
--- a/plugins/adplug/adplug/adl.cpp
+++ b/plugins/adplug/adplug/adl.cpp
@@ -2402,7 +2402,7 @@ bool CadlPlayer::load(const char *filename, const CFileProvider &fp)
// _soundFileLoaded = file;
// find last subsong
- for(int i = 119; i >= 0; i--) {
+ for(int i = 199; i >= 0; i--) {
if(_trackEntries[i] != 0xff) {
numsubsongs = i + 1;
break;
diff --git a/plugins/adplug/adplug/adtrack.cpp b/plugins/adplug/adplug/adtrack.cpp
index 54866a32..87d9629c 100644
--- a/plugins/adplug/adplug/adtrack.cpp
+++ b/plugins/adplug/adplug/adtrack.cpp
@@ -64,11 +64,8 @@ bool CadtrackLoader::load(const char * filename, const CFileProvider &fp)
char instfilename[PATH_MAX];
strncpy (instfilename, filename, sizeof (instfilename)-5);
instfilename[PATH_MAX-5] = 0;
- char *pext = instfilename + strlen (instfilename);
- while (pext > instfilename && *pext != '.') {
- pext--;
- }
- if (*pext == '.') {
+ char *pext = strrchr (instfilename, '.');
+ if (pext) {
strcpy (pext, ".ins");
}
else {
diff --git a/plugins/adplug/adplug/cmf.cpp b/plugins/adplug/adplug/cmf.cpp
index 580b6df3..1f6e6bf5 100644
--- a/plugins/adplug/adplug/cmf.cpp
+++ b/plugins/adplug/adplug/cmf.cpp
@@ -137,13 +137,20 @@ bool CcmfPlayer::load(const std::string &filename, const CFileProvider &fp)
this->cmfHeader.iTagOffsetComposer = f->readInt(2);
this->cmfHeader.iTagOffsetRemarks = f->readInt(2);
f->readString((char *)this->cmfHeader.iChannelsInUse, 16);
- this->cmfHeader.iNumInstruments = f->readInt(2);
- this->cmfHeader.iTempo = f->readInt(2);
+ if (iVer == 0x0100) {
+ this->cmfHeader.iNumInstruments = f->readInt(1);
+ this->cmfHeader.iTempo = 0;
+ } else { // 0x0101
+ this->cmfHeader.iNumInstruments = f->readInt(2);
+ this->cmfHeader.iTempo = f->readInt(2);
+ }
// Load the instruments
f->seek(this->cmfHeader.iInstrumentBlockOffset);
- this->pInstruments = new SBI[128]; // Always 128 available for use
+ this->pInstruments = new SBI[
+ (this->cmfHeader.iNumInstruments < 128) ? 128 : this->cmfHeader.iNumInstruments
+ ]; // Always at least 128 available for use
for (int i = 0; i < this->cmfHeader.iNumInstruments; i++) {
this->pInstruments[i].op[0].iCharMult = f->readInt(1);
@@ -280,20 +287,16 @@ bool CcmfPlayer::update()
// This will have read in the terminating EOX (0xF7) message too
break;
}
- case 0xF1: // MIDI Time Code Quarter Frame
- this->iPlayPointer++;
- //this->data[this->iPlayPointer++]; // message data (ignored)
- break;
- case 0xF2: // Song position pointer
- this->iPlayPointer++;
- this->iPlayPointer++;
-// this->data[this->iPlayPointer++]; // message data (ignored)
-// this->data[this->iPlayPointer++];
- break;
- case 0xF3: // Song select
- this->iPlayPointer++;
-// this->data[this->iPlayPointer++]; // message data (ignored)
- AdPlug_LogWrite("CMF: MIDI Song Select is not implemented.\n");
+ case 0xF1: // MIDI Time Code Quarter Frame
+ this->data[this->iPlayPointer++]; // message data (ignored)
+ break;
+ case 0xF2: // Song position pointer
+ this->data[this->iPlayPointer++]; // message data (ignored)
+ this->data[this->iPlayPointer++];
+ break;
+ case 0xF3: // Song select
+ this->data[this->iPlayPointer++]; // message data (ignored)
+ AdPlug_LogWrite("CMF: MIDI Song Select is not implemented.\n");
break;
case 0xF6: // Tune request
break;
@@ -360,6 +363,9 @@ void CcmfPlayer::rewind(int subsong)
// Apparently this enables nine-channel mode?
this->writeOPL(0x01, 0x20);
+ // Disable OPL3 mode (can be left enabled by a previous non-CMF song)
+ this->writeOPL(0x05, 0x00);
+
// Really make sure CSM+SEL are off (again, Creative's player...)
this->writeOPL(0x08, 0x00);