Mercurial > audlegacy
annotate Plugins/Input/adplug/core/adplug.cpp @ 395:0923a41170bb trunk
[svn] Add S3M support back after receiving a convincing testcase.
| author | chainsaw |
|---|---|
| date | Sat, 07 Jan 2006 06:18:13 -0800 |
| parents | aeb6aa8ae8d1 |
| children | 451d2dc68ba8 |
| rev | line source |
|---|---|
| 359 | 1 /* |
| 2 * Adplug - Replayer for many OPL2/OPL3 audio file formats. | |
| 3 * Copyright (C) 1999 - 2005 Simon Peter <dn.tlp@gmx.net>, et al. | |
| 4 * | |
| 5 * This library is free software; you can redistribute it and/or | |
| 6 * modify it under the terms of the GNU Lesser General Public | |
| 7 * License as published by the Free Software Foundation; either | |
| 8 * version 2.1 of the License, or (at your option) any later version. | |
| 9 * | |
| 10 * This library is distributed in the hope that it will be useful, | |
| 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
| 13 * Lesser General Public License for more details. | |
| 14 * | |
| 15 * You should have received a copy of the GNU Lesser General Public | |
| 16 * License along with this library; if not, write to the Free Software | |
| 17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
| 18 * | |
| 19 * adplug.cpp - CAdPlug utility class, by Simon Peter <dn.tlp@gmx.net> | |
| 20 */ | |
| 21 | |
| 22 #include <string> | |
|
387
7f0e78f42032
[svn] Disable adplug if the includes are missing (or in a very lame place). Stop blowing holes in my ship.
chainsaw
parents:
379
diff
changeset
|
23 #include <binfile.h> |
| 359 | 24 |
| 25 #include "adplug.h" | |
| 26 #include "debug.h" | |
| 27 | |
| 28 /***** Replayer includes *****/ | |
| 29 | |
| 30 #include "hsc.h" | |
| 31 #include "amd.h" | |
| 32 #include "a2m.h" | |
| 33 #include "imf.h" | |
| 34 #include "sng.h" | |
| 35 #include "adtrack.h" | |
| 36 #include "bam.h" | |
| 37 #include "d00.h" | |
| 38 #include "dfm.h" | |
| 39 #include "hsp.h" | |
| 40 #include "ksm.h" | |
| 41 #include "mad.h" | |
| 42 #include "mkj.h" | |
| 43 #include "cff.h" | |
|
395
0923a41170bb
[svn] Add S3M support back after receiving a convincing testcase.
chainsaw
parents:
391
diff
changeset
|
44 #include "dmo.h" |
|
0923a41170bb
[svn] Add S3M support back after receiving a convincing testcase.
chainsaw
parents:
391
diff
changeset
|
45 #include "s3m.h" |
| 359 | 46 #include "dtm.h" |
| 47 #include "fmc.h" | |
| 48 #include "mtk.h" | |
| 49 #include "rad.h" | |
| 50 #include "raw.h" | |
| 51 #include "sa2.h" | |
| 52 #include "bmf.h" | |
| 53 #include "flash.h" | |
| 54 #include "hybrid.h" | |
| 55 #include "hyp.h" | |
| 56 #include "psi.h" | |
| 57 #include "rat.h" | |
| 58 #include "lds.h" | |
| 59 #include "u6m.h" | |
| 60 #include "rol.h" | |
| 61 #include "xsm.h" | |
| 62 #include "dro.h" | |
| 63 | |
| 64 /***** Defines *****/ | |
| 65 | |
| 66 #define VERSION "1.5.1" // AdPlug library version string | |
| 67 | |
| 68 /***** CAdPlug *****/ | |
| 69 | |
| 70 // List of all players that come with the standard AdPlug distribution | |
| 71 const CPlayerDesc CAdPlug::allplayers[] = { | |
| 72 CPlayerDesc(ChscPlayer::factory, "HSC-Tracker", ".hsc\0"), | |
| 73 CPlayerDesc(CsngPlayer::factory, "SNGPlay", ".sng\0"), | |
| 74 CPlayerDesc(CimfPlayer::factory, "Apogee IMF", ".imf\0.wlf\0.adlib\0"), | |
| 75 CPlayerDesc(Ca2mLoader::factory, "Adlib Tracker 2", ".a2m\0"), | |
| 76 CPlayerDesc(CadtrackLoader::factory, "Adlib Tracker", ".sng\0"), | |
| 77 CPlayerDesc(CamdLoader::factory, "AMUSIC", ".amd\0"), | |
| 78 CPlayerDesc(CbamPlayer::factory, "Bob's Adlib Music", ".bam\0"), | |
| 79 CPlayerDesc(Cd00Player::factory, "Packed EdLib", ".d00\0"), | |
| 80 CPlayerDesc(CdfmLoader::factory, "Digital-FM", ".dfm\0"), | |
| 81 CPlayerDesc(ChspLoader::factory, "HSC Packed", ".hsp\0"), | |
| 82 CPlayerDesc(CksmPlayer::factory, "Ken Silverman Music", ".ksm\0"), | |
| 83 CPlayerDesc(CmadLoader::factory, "Mlat Adlib Tracker", ".mad\0"), | |
| 84 CPlayerDesc(CmkjPlayer::factory, "MKJamz", ".mkj\0"), | |
| 85 CPlayerDesc(CcffLoader::factory, "Boomtracker", ".cff\0"), | |
|
395
0923a41170bb
[svn] Add S3M support back after receiving a convincing testcase.
chainsaw
parents:
391
diff
changeset
|
86 CPlayerDesc(CdmoLoader::factory, "TwinTeam", ".dmo\0"), |
|
0923a41170bb
[svn] Add S3M support back after receiving a convincing testcase.
chainsaw
parents:
391
diff
changeset
|
87 CPlayerDesc(Cs3mPlayer::factory, "Scream Tracker 3", ".s3m\0"), |
| 359 | 88 CPlayerDesc(CdtmLoader::factory, "DeFy Adlib Tracker", ".dtm\0"), |
| 89 CPlayerDesc(CfmcLoader::factory, "Faust Music Creator", ".sng\0"), | |
| 90 CPlayerDesc(CmtkLoader::factory, "MPU-401 Trakker", ".mtk\0"), | |
| 91 CPlayerDesc(CradLoader::factory, "Reality Adlib Tracker", ".rad\0"), | |
| 92 CPlayerDesc(CrawPlayer::factory, "RdosPlay RAW", ".raw\0"), | |
| 93 CPlayerDesc(Csa2Loader::factory, "Surprise! Adlib Tracker", ".sat\0.sa2\0"), | |
| 94 CPlayerDesc(CxadbmfPlayer::factory, "BMF Adlib Tracker", ".xad\0"), | |
| 95 CPlayerDesc(CxadflashPlayer::factory, "Flash", ".xad\0"), | |
| 96 CPlayerDesc(CxadhybridPlayer::factory, "Hybrid", ".xad\0"), | |
| 97 CPlayerDesc(CxadhypPlayer::factory, "Hypnosis", ".xad\0"), | |
| 98 CPlayerDesc(CxadpsiPlayer::factory, "PSI", ".xad\0"), | |
| 99 CPlayerDesc(CxadratPlayer::factory, "rat", ".xad\0"), | |
| 100 CPlayerDesc(CldsPlayer::factory, "LOUDNESS Sound System", ".lds\0"), | |
| 101 CPlayerDesc(Cu6mPlayer::factory, "Ultima 6 Music", ".m\0"), | |
| 102 CPlayerDesc(CrolPlayer::factory, "Adlib Visual Composer", ".rol\0"), | |
| 103 CPlayerDesc(CxsmPlayer::factory, "eXtra Simple Music", ".xsm\0"), | |
| 104 CPlayerDesc(CdroPlayer::factory, "DOSBox Raw OPL", ".dro\0"), | |
| 105 CPlayerDesc() | |
| 106 }; | |
| 107 | |
| 108 const CPlayers &CAdPlug::init_players(const CPlayerDesc pd[]) | |
| 109 { | |
| 110 static CPlayers initplayers; | |
| 111 unsigned int i; | |
| 112 | |
| 113 for(i = 0; pd[i].factory; i++) | |
| 114 initplayers.push_back(&pd[i]); | |
| 115 | |
| 116 return initplayers; | |
| 117 } | |
| 118 | |
| 119 const CPlayers CAdPlug::players = CAdPlug::init_players(CAdPlug::allplayers); | |
| 120 CAdPlugDatabase *CAdPlug::database = 0; | |
| 121 | |
| 122 CPlayer *CAdPlug::factory(const std::string &fn, Copl *opl, const CPlayers &pl, | |
| 123 const CFileProvider &fp) | |
| 124 { | |
| 125 CPlayer *p; | |
| 126 CPlayers::const_iterator i; | |
| 127 unsigned int j; | |
| 128 | |
| 129 AdPlug_LogWrite("*** CAdPlug::factory(\"%s\",opl,fp) ***\n", fn.c_str()); | |
| 130 | |
| 131 // Try a direct hit by file extension | |
| 132 for(i = pl.begin(); i != pl.end(); i++) | |
| 133 for(j = 0; (*i)->get_extension(j); j++) | |
| 134 if(fp.extension(fn, (*i)->get_extension(j))) { | |
| 135 AdPlug_LogWrite("Trying direct hit: %s\n", (*i)->filetype.c_str()); | |
| 136 if((p = (*i)->factory(opl))) | |
| 137 if(p->load(fn, fp)) { | |
| 138 AdPlug_LogWrite("got it!\n"); | |
| 139 AdPlug_LogWrite("--- CAdPlug::factory ---\n"); | |
| 140 return p; | |
| 141 } else | |
| 142 delete p; | |
| 143 } | |
| 144 | |
| 145 // Try all players, one by one | |
| 146 for(i = pl.begin(); i != pl.end(); i++) { | |
| 147 AdPlug_LogWrite("Trying: %s\n", (*i)->filetype.c_str()); | |
| 148 if((p = (*i)->factory(opl))) | |
| 149 if(p->load(fn, fp)) { | |
| 150 AdPlug_LogWrite("got it!\n"); | |
| 151 AdPlug_LogWrite("--- CAdPlug::factory ---\n"); | |
| 152 return p; | |
| 153 } else | |
| 154 delete p; | |
| 155 } | |
| 156 | |
| 157 // Unknown file | |
| 158 AdPlug_LogWrite("End of list!\n"); | |
| 159 AdPlug_LogWrite("--- CAdPlug::factory ---\n"); | |
| 160 return 0; | |
| 161 } | |
| 162 | |
| 163 void CAdPlug::set_database(CAdPlugDatabase *db) | |
| 164 { | |
| 165 database = db; | |
| 166 } | |
| 167 | |
| 168 std::string CAdPlug::get_version() | |
| 169 { | |
| 170 return std::string(VERSION); | |
| 171 } | |
| 172 | |
| 173 void CAdPlug::debug_output(const std::string &filename) | |
| 174 { | |
| 175 AdPlug_LogFile(filename.c_str()); | |
| 176 AdPlug_LogWrite("CAdPlug::debug_output(\"%s\"): Redirected.\n",filename.c_str()); | |
| 177 } |
