diff options
author | Alexey Yakovenko <wakeroid@gmail.com> | 2010-07-26 10:04:43 +0200 |
---|---|---|
committer | Alexey Yakovenko <wakeroid@gmail.com> | 2010-07-26 10:04:43 +0200 |
commit | fe3f99c92a8437a353ba12075d6c3273d04c4e3f (patch) | |
tree | 34d97babbe5696f21779866fafad217b60c2bead /plugins/adplug | |
parent | 4deca01c3a7edaf66374bd35e6fb50d4d9564b17 (diff) |
merged non-android-specific changes from android branch
Diffstat (limited to 'plugins/adplug')
96 files changed, 799 insertions, 755 deletions
diff --git a/plugins/adplug/Makefile.am b/plugins/adplug/Makefile.am index 0d4e2a5d..a75f38b5 100644 --- a/plugins/adplug/Makefile.am +++ b/plugins/adplug/Makefile.am @@ -40,8 +40,6 @@ adplug_la_SOURCES = adplug-db.cpp\ adplug/cff.h\ adplug/d00.cpp\ adplug/d00.h\ - adplug/database.cpp\ - adplug/database.h\ adplug/debug.c\ adplug/debug.h\ adplug/dfm.cpp\ @@ -133,5 +131,8 @@ adplug_la_SOURCES = adplug-db.cpp\ adplug/xsm.cpp\ adplug/xsm.h +# adplug/database.cpp +# adplug/database.h + adplug_la_LDFLAGS = -module endif diff --git a/plugins/adplug/adplug-db.cpp b/plugins/adplug/adplug-db.cpp index 3a3a683f..1ecb9c74 100644 --- a/plugins/adplug/adplug-db.cpp +++ b/plugins/adplug/adplug-db.cpp @@ -66,7 +66,7 @@ adplug_init (DB_fileinfo_t *_info, DB_playItem_t *it) { // return -1 on failure adplug_info_t *info = (adplug_info_t *)_info; - int samplerate = deadbeef->conf_get_int ("synth.samplerate", 48000); + int samplerate = deadbeef->conf_get_int ("synth.samplerate", 44100); int bps = deadbeef->get_output ()->bitspersample (); int channels = 2; info->opl = new CEmuopl (samplerate, true, channels == 2); @@ -79,7 +79,7 @@ adplug_init (DB_fileinfo_t *_info, DB_playItem_t *it) { info->subsong = it->tracknum; info->decoder->rewind (info->subsong); - info->totalsamples = info->decoder->songlength (info->subsong) * samplerate / 1000; + info->totalsamples = info->decoder->songlength (info->subsong) / 1000.f * samplerate; info->currentsample = 0; info->toadd = 0; @@ -90,7 +90,7 @@ adplug_init (DB_fileinfo_t *_info, DB_playItem_t *it) { _info->samplerate = samplerate; _info->readpos = 0; - trace ("adplug_init ok (duration=%f, totalsamples=%d)\n", deadbeef->pl_get_item_duration (it), totalsamples); + trace ("adplug_init ok (songlength=%d, duration=%f, totalsamples=%d)\n", info->decoder->songlength (info->subsong), deadbeef->pl_get_item_duration (it), info->totalsamples); return 0; } @@ -235,6 +235,8 @@ adplug_insert (DB_playItem_t *after, const char *fname) { // return track pointer on success // return NULL on failure + trace ("adplug: trying to insert %s\n", fname); + CSilentopl opl; CPlayer *p = CAdPlug::factory (fname, &opl, CAdPlug::players); if (!p) { @@ -252,18 +254,19 @@ adplug_insert (DB_playItem_t *after, const char *fname) { it->tracknum = i; deadbeef->pl_set_item_duration (it, p->songlength (i)/1000.f); // add metainfo - if (!p->gettitle().empty()) { - adplug_add_meta (it, "title", p->gettitle().c_str()); - } - else { - deadbeef->pl_add_meta (it, "title", NULL); - } - if (!p->getdesc().empty()) { - adplug_add_meta (it, "comment", p->getdesc().c_str()); - } - if (!p->getauthor().empty()) { - adplug_add_meta (it, "artist", p->getauthor().c_str()); - } +// if (p->gettitle()[0]) { +// adplug_add_meta (it, "title", p->gettitle()); +// } +// else { +// deadbeef->pl_add_meta (it, "title", NULL); +// } +// if (p->getdesc()[0]) { +// adplug_add_meta (it, "comment", p->getdesc()); +// } +// if (!p->getauthor()[0]) { +// adplug_add_meta (it, "artist", p->getauthor()); +// } + deadbeef->pl_add_meta (it, "title", NULL); // insert after = deadbeef->pl_insert_item (after, it); deadbeef->pl_item_unref (it); diff --git a/plugins/adplug/adplug/a2m.cpp b/plugins/adplug/adplug/a2m.cpp index d9d775e2..83940b68 100644 --- a/plugins/adplug/adplug/a2m.cpp +++ b/plugins/adplug/adplug/a2m.cpp @@ -29,7 +29,7 @@ * Following commands are ignored: Gxy, Hxy, Kxy - &xy */ -#include <cstring> +#include <string.h> #include "a2m.h" const unsigned int Ca2mLoader::MAXFREQ = 2000, @@ -59,7 +59,7 @@ CPlayer *Ca2mLoader::factory(Copl *newopl) return new Ca2mLoader(newopl); } -bool Ca2mLoader::load(const std::string &filename, const CFileProvider &fp) +bool Ca2mLoader::load(const char *filename, const CFileProvider &fp) { binistream *f = fp.open(filename); if(!f) return false; char id[10]; diff --git a/plugins/adplug/adplug/a2m.h b/plugins/adplug/adplug/a2m.h index 9e032f61..e21d1dff 100644 --- a/plugins/adplug/adplug/a2m.h +++ b/plugins/adplug/adplug/a2m.h @@ -32,19 +32,19 @@ public: Ca2mLoader(Copl *newopl): CmodPlayer(newopl) { } - bool load(const std::string &filename, const CFileProvider &fp); + bool load(const char *filename, const CFileProvider &fp); float getrefresh(); - std::string gettype() - { return std::string("AdLib Tracker 2"); } - std::string gettitle() - { if(*songname) return std::string(songname,1,*songname); else return std::string(); } - std::string getauthor() - { if(*author) return std::string(author,1,*author); else return std::string(); } + const char *gettype() + { return "AdLib Tracker 2"; } + const char *gettitle() + { if(*songname) return songname; else return ""; } + const char *getauthor() + { if(*author) return author; else return ""; } unsigned int getinstruments() { return 250; } - std::string getinstrument(unsigned int n) - { return std::string(instname[n],1,*instname[n]); } + const char *getinstrument(unsigned int n) + { return instname[n]; } private: diff --git a/plugins/adplug/adplug/adl.cpp b/plugins/adplug/adplug/adl.cpp index ae8c4e99..0ad196e9 100644 --- a/plugins/adplug/adplug/adl.cpp +++ b/plugins/adplug/adplug/adl.cpp @@ -48,10 +48,10 @@ * */ -#include <cstring> #include <inttypes.h> #include <stdarg.h> #include <assert.h> +#include <string.h> #include "adl.h" #include "debug.h" @@ -2321,7 +2321,7 @@ void CadlPlayer::play(uint8_t track) { // playSoundEffect(1); // } -bool CadlPlayer::load(const std::string &filename, const CFileProvider &fp) +bool CadlPlayer::load(const char *filename, const CFileProvider &fp) { binistream *f = fp.open(filename); diff --git a/plugins/adplug/adplug/adl.h b/plugins/adplug/adplug/adl.h index 203692b0..6a47a1a9 100644 --- a/plugins/adplug/adplug/adl.h +++ b/plugins/adplug/adplug/adl.h @@ -36,7 +36,7 @@ class CadlPlayer: public CPlayer CadlPlayer(Copl *newopl); ~CadlPlayer(); - bool load(const std::string &filename, const CFileProvider &fp); + bool load(const char *filename, const CFileProvider &fp); bool update(); void rewind(int subsong = -1); @@ -48,7 +48,7 @@ class CadlPlayer: public CPlayer unsigned int getsubsongs(); unsigned int getsubsong() { return cursubsong; } - std::string gettype() { return std::string("Westwood ADL"); } + const char *gettype() { return "Westwood ADL"; } private: int numsubsongs, cursubsong; diff --git a/plugins/adplug/adplug/adplug.cpp b/plugins/adplug/adplug/adplug.cpp index f4b8e729..ab5f7513 100644 --- a/plugins/adplug/adplug/adplug.cpp +++ b/plugins/adplug/adplug/adplug.cpp @@ -19,8 +19,7 @@ * adplug.cpp - CAdPlug utility class, by Simon Peter <dn.tlp@gmx.net> */ -#include <cstring> -#include <string> +#include <string.h> #include <binfile.h> #include "adplug.h" @@ -72,7 +71,7 @@ /***** CAdPlug *****/ // List of all players that come with the standard AdPlug distribution -const CPlayerDesc CAdPlug::allplayers[] = { +CPlayerDesc CAdPlug::allplayers[] = { CPlayerDesc(ChscPlayer::factory, "HSC-Tracker", ".hsc\0"), CPlayerDesc(CsngPlayer::factory, "SNGPlay", ".sng\0"), CPlayerDesc(CimfPlayer::factory, "Apogee IMF", ".imf\0.wlf\0.adlib\0"), @@ -116,7 +115,7 @@ const CPlayerDesc CAdPlug::allplayers[] = { CPlayerDesc() }; -const CPlayers &CAdPlug::init_players(const CPlayerDesc pd[]) +const CPlayers &CAdPlug::init_players(CPlayerDesc pd[]) { static CPlayers initplayers; unsigned int i; @@ -128,23 +127,23 @@ const CPlayers &CAdPlug::init_players(const CPlayerDesc pd[]) } const CPlayers CAdPlug::players = CAdPlug::init_players(CAdPlug::allplayers); -CAdPlugDatabase *CAdPlug::database = 0; +//CAdPlugDatabase *CAdPlug::database = 0; -CPlayer *CAdPlug::factory(const std::string &fn, Copl *opl, const CPlayers &pl, +CPlayer *CAdPlug::factory(const char *fn, Copl *opl, const CPlayers &pl, const CFileProvider &fp) { CPlayer *p; - CPlayers::const_iterator i; + CPlayerDesc *i; unsigned int j; - AdPlug_LogWrite("*** CAdPlug::factory(\"%s\",opl,fp) ***\n", fn.c_str()); + AdPlug_LogWrite("*** CAdPlug::factory(\"%s\",opl,fp) ***\n", fn); // Try a direct hit by file extension - for(i = pl.begin(); i != pl.end(); i++) - for(j = 0; (*i)->get_extension(j); j++) - if(fp.extension(fn, (*i)->get_extension(j))) { - AdPlug_LogWrite("Trying direct hit: %s\n", (*i)->filetype.c_str()); - if((p = (*i)->factory(opl))) { + for(i = pl.head; i; i = i->next) + for(j = 0; i->get_extension(j); j++) + if(fp.extension(fn, i->get_extension(j))) { + AdPlug_LogWrite("Trying direct hit: %s\n", i->filetype); + if((p = i->factory(opl))) { if(p->load(fn, fp)) { AdPlug_LogWrite("got it!\n"); AdPlug_LogWrite("--- CAdPlug::factory ---\n"); @@ -155,9 +154,9 @@ CPlayer *CAdPlug::factory(const std::string &fn, Copl *opl, const CPlayers &pl, } // Try all players, one by one - for(i = pl.begin(); i != pl.end(); i++) { - AdPlug_LogWrite("Trying: %s\n", (*i)->filetype.c_str()); - if((p = (*i)->factory(opl))) { + for(i = pl.head; i; i = i->next) { + AdPlug_LogWrite("Trying: %s\n", i->filetype); + if((p = i->factory(opl))) { if(p->load(fn, fp)) { AdPlug_LogWrite("got it!\n"); AdPlug_LogWrite("--- CAdPlug::factory ---\n"); @@ -173,18 +172,20 @@ CPlayer *CAdPlug::factory(const std::string &fn, Copl *opl, const CPlayers &pl, return 0; } +#if 0 void CAdPlug::set_database(CAdPlugDatabase *db) { database = db; } +#endif -std::string CAdPlug::get_version() +const char * CAdPlug::get_version() { - return std::string(VERSION); + return VERSION; } -void CAdPlug::debug_output(const std::string &filename) +void CAdPlug::debug_output(const char *filename) { - AdPlug_LogFile(filename.c_str()); - AdPlug_LogWrite("CAdPlug::debug_output(\"%s\"): Redirected.\n",filename.c_str()); + AdPlug_LogFile(filename); + AdPlug_LogWrite("CAdPlug::debug_output(\"%s\"): Redirected.\n",filename); } diff --git a/plugins/adplug/adplug/adplug.h b/plugins/adplug/adplug/adplug.h index e5aec896..f9d2117a 100644 --- a/plugins/adplug/adplug/adplug.h +++ b/plugins/adplug/adplug/adplug.h @@ -22,8 +22,6 @@ #ifndef H_ADPLUG_ADPLUG #define H_ADPLUG_ADPLUG -#include <string> - #include "player.h" #include "opl.h" #include "fprovide.h" @@ -37,19 +35,19 @@ class CAdPlug public: static const CPlayers players; - static CPlayer *factory(const std::string &fn, Copl *opl, + static CPlayer *factory(const char *fn, Copl *opl, const CPlayers &pl = players, const CFileProvider &fp = CProvider_Filesystem()); - static void set_database(CAdPlugDatabase *db); - static std::string get_version(); - static void debug_output(const std::string &filename); +// static void set_database(CAdPlugDatabase *db); + static const char *get_version(); + static void debug_output(const char *filename); private: - static CAdPlugDatabase *database; - static const CPlayerDesc allplayers[]; +// static CAdPlugDatabase *database; + static CPlayerDesc allplayers[]; - static const CPlayers &init_players(const CPlayerDesc pd[]); + static const CPlayers &init_players(CPlayerDesc pd[]); }; #endif diff --git a/plugins/adplug/adplug/adtrack.cpp b/plugins/adplug/adplug/adtrack.cpp index d3f3490a..54866a32 100644 --- a/plugins/adplug/adplug/adtrack.cpp +++ b/plugins/adplug/adplug/adtrack.cpp @@ -35,6 +35,10 @@ #include "adtrack.h" #include "debug.h" +#include <limits.h> +#ifndef PATH_MAX +#define PATH_MAX 1024 /* max # of characters in a path name */ +#endif /*** Public methods ***/ CPlayer *CadtrackLoader::factory(Copl *newopl) @@ -42,7 +46,7 @@ CPlayer *CadtrackLoader::factory(Copl *newopl) return new CadtrackLoader(newopl); } -bool CadtrackLoader::load(const std::string &filename, const CFileProvider &fp) +bool CadtrackLoader::load(const char * filename, const CFileProvider &fp) { binistream *f = fp.open(filename); if(!f) return false; binistream *instf; @@ -57,10 +61,21 @@ bool CadtrackLoader::load(const std::string &filename, const CFileProvider &fp) { fp.close(f); return false; } // check for instruments file - std::string instfilename(filename, 0, filename.find_last_of('.')); - instfilename += ".ins"; + 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 == '.') { + strcpy (pext, ".ins"); + } + else { + strcat (instfilename, ".ins"); + } AdPlug_LogWrite("CadtrackLoader::load(,\"%s\"): Checking for \"%s\"...\n", - filename.c_str(), instfilename.c_str()); + filename, instfilename); instf = fp.open(instfilename); if(!instf || fp.filesize(instf) != 468) { fp.close(f); return false; } diff --git a/plugins/adplug/adplug/adtrack.h b/plugins/adplug/adplug/adtrack.h index 289491ff..9515976c 100644 --- a/plugins/adplug/adplug/adtrack.h +++ b/plugins/adplug/adplug/adtrack.h @@ -30,11 +30,11 @@ public: : CmodPlayer(newopl) { }; - bool load(const std::string &filename, const CFileProvider &fp); + bool load(const char *filename, const CFileProvider &fp); float getrefresh(); - std::string gettype() - { return std::string("Adlib Tracker 1.0"); }; + const char * gettype() + { return "Adlib Tracker 1.0"; }; unsigned int getinstruments() { return 9; }; diff --git a/plugins/adplug/adplug/amd.cpp b/plugins/adplug/adplug/amd.cpp index 4f844227..4f05bb51 100644 --- a/plugins/adplug/adplug/amd.cpp +++ b/plugins/adplug/adplug/amd.cpp @@ -29,7 +29,7 @@ CPlayer *CamdLoader::factory(Copl *newopl) return new CamdLoader(newopl); } -bool CamdLoader::load(const std::string &filename, const CFileProvider &fp) +bool CamdLoader::load(const char *filename, const CFileProvider &fp) { binistream *f = fp.open(filename); if(!f) return false; struct { diff --git a/plugins/adplug/adplug/amd.h b/plugins/adplug/adplug/amd.h index daa630b6..847ac037 100644 --- a/plugins/adplug/adplug/amd.h +++ b/plugins/adplug/adplug/amd.h @@ -30,19 +30,19 @@ public: : CmodPlayer(newopl) { }; - bool load(const std::string &filename, const CFileProvider &fp); + bool load(const char *filename, const CFileProvider &fp); float getrefresh(); - std::string gettype() - { return std::string("AMUSIC Adlib Tracker"); }; - std::string gettitle() - { return std::string(songname,0,24); }; - std::string getauthor() - { return std::string(author,0,24); }; + const char *gettype() + { return "AMUSIC Adlib Tracker"; }; + const char *gettitle() + { return songname; }; + const char *getauthor() + { return author; }; unsigned int getinstruments() { return 26; }; - std::string getinstrument(unsigned int n) - { return std::string(instname[n],0,23); }; + const char *getinstrument(unsigned int n) + { return instname[n]; }; private: char songname[24],author[24],instname[26][23]; diff --git a/plugins/adplug/adplug/bam.cpp b/plugins/adplug/adplug/bam.cpp index ea1aca01..20ee4d8d 100644 --- a/plugins/adplug/adplug/bam.cpp +++ b/plugins/adplug/adplug/bam.cpp @@ -65,7 +65,7 @@ CPlayer *CbamPlayer::factory(Copl *newopl) return new CbamPlayer(newopl); } -bool CbamPlayer::load(const std::string &filename, const CFileProvider &fp) +bool CbamPlayer::load(const char *filename, const CFileProvider &fp) { binistream *f = fp.open(filename); if(!f) return false; char id[4]; diff --git a/plugins/adplug/adplug/bam.h b/plugins/adplug/adplug/bam.h index 53f321b2..329b9369 100644 --- a/plugins/adplug/adplug/bam.h +++ b/plugins/adplug/adplug/bam.h @@ -32,14 +32,14 @@ public: ~CbamPlayer() { if(song) delete [] song; }; - bool load(const std::string &filename, const CFileProvider &fp); + bool load(const char *filename, const CFileProvider &fp); bool update(); void rewind(int subsong); float getrefresh() { return 25.0f; }; - std::string gettype() - { return std::string("Bob's Adlib Music"); }; + const char *gettype() + { return "Bob's Adlib Music"; }; private: static const unsigned short freq[]; diff --git a/plugins/adplug/adplug/bmf.cpp b/plugins/adplug/adplug/bmf.cpp index 469fde43..b0ab9ef6 100644 --- a/plugins/adplug/adplug/bmf.cpp +++ b/plugins/adplug/adplug/bmf.cpp @@ -40,7 +40,7 @@ comment : inaccurate replaying, because constant outport; in original player it can be 380 or 382. */ -#include <cstring> +#include <string.h> #include "bmf.h" #include "debug.h" @@ -381,19 +381,19 @@ float CxadbmfPlayer::xadplayer_getrefresh() return bmf.timer; } -std::string CxadbmfPlayer::xadplayer_gettype() +const char * CxadbmfPlayer::xadplayer_gettype() { - return std::string("xad: BMF Adlib Tracker"); + return "xad: BMF Adlib Tracker"; } -std::string CxadbmfPlayer::xadplayer_gettitle() +const char * CxadbmfPlayer::xadplayer_gettitle() { - return std::string(bmf.title); + return bmf.title; } -std::string CxadbmfPlayer::xadplayer_getauthor() +const char * CxadbmfPlayer::xadplayer_getauthor() { - return std::string(bmf.author); + return bmf.author; } unsigned int CxadbmfPlayer::xadplayer_getinstruments() @@ -401,9 +401,9 @@ unsigned int CxadbmfPlayer::xadplayer_getinstruments() return 32; } -std::string CxadbmfPlayer::xadplayer_getinstrument(unsigned int i) +const char * CxadbmfPlayer::xadplayer_getinstrument(unsigned int i) { - return std::string(bmf.instruments[i].name); + return bmf.instruments[i].name; } /* -------- Internal Functions ---------------------------- */ diff --git a/plugins/adplug/adplug/bmf.h b/plugins/adplug/adplug/bmf.h index 12cbdfd3..6db543d6 100644 --- a/plugins/adplug/adplug/bmf.h +++ b/plugins/adplug/adplug/bmf.h @@ -75,10 +75,10 @@ protected: void xadplayer_rewind(int subsong); void xadplayer_update(); float xadplayer_getrefresh(); - std::string xadplayer_gettype(); - std::string xadplayer_gettitle(); - std::string xadplayer_getauthor(); - std::string xadplayer_getinstrument(unsigned int i); + const char * xadplayer_gettype(); + const char * xadplayer_gettitle(); + const char * xadplayer_getauthor(); + const char * xadplayer_getinstrument(unsigned int i); unsigned int xadplayer_getinstruments(); // private: diff --git a/plugins/adplug/adplug/cff.cpp b/plugins/adplug/adplug/cff.cpp index 68a11692..0966a8d7 100644 --- a/plugins/adplug/adplug/cff.cpp +++ b/plugins/adplug/adplug/cff.cpp @@ -24,7 +24,6 @@ slides use previous effect data instead of current. */ -#include <cstring> #include <stdlib.h> #include <string.h> @@ -37,7 +36,7 @@ CPlayer *CcffLoader::factory(Copl *newopl) return new CcffLoader(newopl); } -bool CcffLoader::load(const std::string &filename, const CFileProvider &fp) +bool CcffLoader::load(const char *filename, const CFileProvider &fp) { binistream *f = fp.open(filename); if(!f) return false; const unsigned char conv_inst[11] = { 2,1,10,9,4,3,6,5,0,8,7 }; @@ -275,27 +274,27 @@ void CcffLoader::rewind(int subsong) } } -std::string CcffLoader::gettype() +const char * CcffLoader::gettype() { if (header.packed) - return std::string("BoomTracker 4, packed"); + return "BoomTracker 4, packed"; else - return std::string("BoomTracker 4"); + return "BoomTracker 4"; } -std::string CcffLoader::gettitle() +const char * CcffLoader::gettitle() { - return std::string(song_title,20); + return song_title; } -std::string CcffLoader::getauthor() +const char * CcffLoader::getauthor() { - return std::string(song_author,20); + return song_author; } -std::string CcffLoader::getinstrument(unsigned int n) +const char * CcffLoader::getinstrument(unsigned int n) { - return std::string(instruments[n].name); + return instruments[n].name; } unsigned int CcffLoader::getinstruments() diff --git a/plugins/adplug/adplug/cff.h b/plugins/adplug/adplug/cff.h index 04ead8bb..08f11315 100644 --- a/plugins/adplug/adplug/cff.h +++ b/plugins/adplug/adplug/cff.h @@ -28,13 +28,13 @@ class CcffLoader: public CmodPlayer CcffLoader(Copl *newopl) : CmodPlayer(newopl) { }; - bool load(const std::string &filename, const CFileProvider &fp); + bool load(const char * filename, const CFileProvider &fp); void rewind(int subsong); - std::string gettype(); - std::string gettitle(); - std::string getauthor(); - std::string getinstrument(unsigned int n); + const char * gettype(); + const char * gettitle(); + const char * getauthor(); + const char * getinstrument(unsigned int n); unsigned int getinstruments(); private: diff --git a/plugins/adplug/adplug/d00.cpp b/plugins/adplug/adplug/d00.cpp index 0644b84b..2f5aca1a 100644 --- a/plugins/adplug/adplug/d00.cpp +++ b/plugins/adplug/adplug/d00.cpp @@ -53,7 +53,7 @@ CPlayer *Cd00Player::factory(Copl *newopl) return new Cd00Player(newopl); } -bool Cd00Player::load(const std::string &filename, const CFileProvider &fp) +bool Cd00Player::load(const char * filename, const CFileProvider &fp) { binistream *f = fp.open(filename); if(!f) return false; d00header *checkhead; @@ -82,7 +82,7 @@ bool Cd00Player::load(const std::string &filename, const CFileProvider &fp) delete checkhead; AdPlug_LogWrite("Cd00Player::load(f,\"%s\"): %s format D00 file detected!\n", - filename.c_str(), ver1 ? "Old" : "New"); + filename, ver1 ? "Old" : "New"); // load section filesize = fp.filesize(f); f->seek(0); @@ -448,12 +448,10 @@ void Cd00Player::rewind(int subsong) cursubsong = subsong; } -std::string Cd00Player::gettype() +const char * Cd00Player::gettype() { - char tmpstr[40]; - sprintf(tmpstr,"EdLib packed (version %d)",version > 1 ? header->version : header1->version); - return std::string(tmpstr); + return tmpstr; } float Cd00Player::getrefresh() diff --git a/plugins/adplug/adplug/d00.h b/plugins/adplug/adplug/d00.h index d0bf4b24..8c6339e1 100644 --- a/plugins/adplug/adplug/d00.h +++ b/plugins/adplug/adplug/d00.h @@ -35,18 +35,18 @@ class Cd00Player: public CPlayer ~Cd00Player() { if(filedata) delete [] filedata; }; - bool load(const std::string &filename, const CFileProvider &fp); + bool load(const char *filename, const CFileProvider &fp); bool update(); void rewind(int subsong); float getrefresh(); - std::string gettype(); - std::string gettitle() - { if(version > 1) return std::string(header->songname); else return std::string(); }; - std::string getauthor() - { if(version > 1) return std::string(header->author); else return std::string(); }; - std::string getdesc() - { if(*datainfo) return std::string(datainfo); else return std::string(); }; + const char * gettype(); + const char * gettitle() + { if(version > 1) return header->songname; else return ""; }; + const char * getauthor() + { if(version > 1) return header->author; else return ""; }; + const char * getdesc() + { if(*datainfo) return datainfo; else return ""; }; unsigned int getsubsongs(); protected: @@ -97,6 +97,7 @@ class Cd00Player: public CPlayer d00header *header; d00header1 *header1; char *filedata; + char tmpstr[40]; private: void setvolume(unsigned char chan); diff --git a/plugins/adplug/adplug/database.cpp b/plugins/adplug/adplug/database.cpp index 0a2abdad..de5cad3c 100644 --- a/plugins/adplug/adplug/database.cpp +++ b/plugins/adplug/adplug/database.cpp @@ -286,27 +286,27 @@ void CAdPlugDatabase::CRecord::write(binostream &out) write_own(out); } -bool CAdPlugDatabase::CRecord::user_read(std::istream &in, std::ostream &out) -{ - return user_read_own(in, out); -} - -bool CAdPlugDatabase::CRecord::user_write(std::ostream &out) -{ - out << "Record type: "; - switch(type) { - case Plain: out << "Plain"; break; - case SongInfo: out << "SongInfo"; break; - case ClockSpeed: out << "ClockSpeed"; break; - default: out << "*** Unknown ***"; break; - } - out << std::endl; - out << "Key: " << std::hex << key.crc16 << ":" << key.crc32 << std::dec << std::endl; - out << "File type: " << filetype << std::endl; - out << "Comment: " << comment << std::endl; - - return user_write_own(out); -} +//bool CAdPlugDatabase::CRecord::user_read(std::istream &in, std::ostream &out) +//{ +// return user_read_own(in, out); +//} + +//bool CAdPlugDatabase::CRecord::user_write(std::ostream &out) +//{ +// out << "Record type: "; +// switch(type) { +// case Plain: out << "Plain"; break; +// case SongInfo: out << "SongInfo"; break; +// case ClockSpeed: out << "ClockSpeed"; break; +// default: out << "*** Unknown ***"; break; +// } +// out << std::endl; +// out << "Key: " << std::hex << key.crc16 << ":" << key.crc32 << std::dec << std::endl; +// out << "File type: " << filetype << std::endl; +// out << "Comment: " << comment << std::endl; +// +// return user_write_own(out); +//} /***** CAdPlugDatabase::CRecord::CKey *****/ diff --git a/plugins/adplug/adplug/database.h b/plugins/adplug/adplug/database.h index 050e8959..aba5b776 100644 --- a/plugins/adplug/adplug/database.h +++ b/plugins/adplug/adplug/database.h @@ -24,8 +24,7 @@ #ifndef H_ADPLUG_DATABASE #define H_ADPLUG_DATABASE -#include <iostream> -#include <string> +#if 0 #include <binio.h> class CAdPlugDatabase @@ -53,7 +52,7 @@ public: RecordType type; CKey key; - std::string filetype, comment; + char *filetype, comment; static CRecord *factory(RecordType type); static CRecord *factory(binistream &in); @@ -63,8 +62,8 @@ public: void write(binostream &out); - bool user_read(std::istream &in, std::ostream &out); - bool user_write(std::ostream &out); + //bool user_read(std::istream &in, std::ostream &out); + //bool user_write(std::ostream &out); protected: virtual void read_own(binistream &in) = 0; @@ -167,3 +166,5 @@ protected: }; #endif + +#endif diff --git a/plugins/adplug/adplug/dfm.cpp b/plugins/adplug/adplug/dfm.cpp index 4a70a032..66a47bed 100644 --- a/plugins/adplug/adplug/dfm.cpp +++ b/plugins/adplug/adplug/dfm.cpp @@ -30,7 +30,7 @@ CPlayer *CdfmLoader::factory(Copl *newopl) return new CdfmLoader(newopl); } -bool CdfmLoader::load(const std::string &filename, const CFileProvider &fp) +bool CdfmLoader::load(const char *filename, const CFileProvider &fp) { binistream *f = fp.open(filename); if(!f) return false; unsigned char npats,n,note,fx,c,r,param; @@ -101,12 +101,10 @@ bool CdfmLoader::load(const std::string &filename, const CFileProvider &fp) return true; } -std::string CdfmLoader::gettype() +const char * CdfmLoader::gettype() { - char tmpstr[20]; - sprintf(tmpstr,"Digital-FM %d.%d",header.hiver,header.lover); - return std::string(tmpstr); + return tmpstr; } float CdfmLoader::getrefresh() diff --git a/plugins/adplug/adplug/dfm.h b/plugins/adplug/adplug/dfm.h index 4212b2fe..3877d9d8 100644 --- a/plugins/adplug/adplug/dfm.h +++ b/plugins/adplug/adplug/dfm.h @@ -30,16 +30,16 @@ public: : CmodPlayer(newopl) { }; - bool load(const std::string &filename, const CFileProvider &fp); + bool load(const char *filename, const CFileProvider &fp); float getrefresh(); - std::string gettype(); + const char * gettype(); unsigned int getinstruments() { return 32; }; - std::string getinstrument(unsigned int n) - { if(*instname[n]) return std::string(instname[n],1,*instname[n]); else return std::string(); }; - std::string getdesc() - { return std::string(songinfo,1,*songinfo); }; + const char * getinstrument(unsigned int n) + { return instname[n]; }; + const char * getdesc() + { return songinfo; }; private: struct { @@ -49,4 +49,5 @@ private: char songinfo[33]; char instname[32][12]; + char tmpstr[20]; }; diff --git a/plugins/adplug/adplug/diskopl.cpp b/plugins/adplug/adplug/diskopl.cpp index 3296c0a1..94dd1bf3 100644 --- a/plugins/adplug/adplug/diskopl.cpp +++ b/plugins/adplug/adplug/diskopl.cpp @@ -24,13 +24,13 @@ //static const unsigned short note_table[12] = {363,385,408,432,458,485,514,544,577,611,647,686}; const unsigned char CDiskopl::op_table[9] = {0x00, 0x01, 0x02, 0x08, 0x09, 0x0a, 0x10, 0x11, 0x12}; -CDiskopl::CDiskopl(std::string filename) +CDiskopl::CDiskopl(const char * filename) : old_freq(0.0f), del(1), nowrite(false) { unsigned short clock = 0xffff; currType = TYPE_OPL3; - f = fopen(filename.c_str(),"wb"); + f = fopen(filename,"wb"); fwrite("RAWADATA",8,1,f); fwrite(&clock,sizeof(clock),1,f); } diff --git a/plugins/adplug/adplug/diskopl.h b/plugins/adplug/adplug/diskopl.h index 929f2906..14d3c13e 100644 --- a/plugins/adplug/adplug/diskopl.h +++ b/plugins/adplug/adplug/diskopl.h @@ -19,7 +19,7 @@ * diskopl.h - Disk Writer OPL, by Simon Peter <dn.tlp@gmx.net> */ -#include <string> +#include <string.h> #include <stdio.h> #include "opl.h" #include "player.h" @@ -27,7 +27,7 @@ class CDiskopl: public Copl { public: - CDiskopl(std::string filename); + CDiskopl(const char * filename); virtual ~CDiskopl(); void update(CPlayer *p); // write to file diff --git a/plugins/adplug/adplug/dmo.cpp b/plugins/adplug/adplug/dmo.cpp index c25293c4..8a3d8e24 100644 --- a/plugins/adplug/adplug/dmo.cpp +++ b/plugins/adplug/adplug/dmo.cpp @@ -49,7 +49,7 @@ CPlayer *CdmoLoader::factory(Copl *newopl) return new CdmoLoader(newopl); } -bool CdmoLoader::load(const std::string &filename, const CFileProvider &fp) +bool CdmoLoader::load(const char *filename, const CFileProvider &fp) { int i,j; binistream *f; @@ -209,19 +209,19 @@ bool CdmoLoader::load(const std::string &filename, const CFileProvider &fp) return true; } -std::string CdmoLoader::gettype() +const char * CdmoLoader::gettype() { - return std::string("TwinTeam (packed S3M)"); + return "TwinTeam (packed S3M)"; } -std::string CdmoLoader::getauthor() +const char * CdmoLoader::getauthor() { /* All available .DMO modules written by one composer. And because all .DMO stuff was lost due to hd crash (TwinTeam guys said this), there are never(?) be another. */ - return std::string("Benjamin GERARDIN"); + return "Benjamin GERARDIN"; } /* -------- Private Methods ------------------------------- */ diff --git a/plugins/adplug/adplug/dmo.h b/plugins/adplug/adplug/dmo.h index 8591cfcc..5996c112 100644 --- a/plugins/adplug/adplug/dmo.h +++ b/plugins/adplug/adplug/dmo.h @@ -28,10 +28,10 @@ class CdmoLoader: public Cs3mPlayer CdmoLoader(Copl *newopl) : Cs3mPlayer(newopl) { }; - bool load(const std::string &filename, const CFileProvider &fp); + bool load(const char *filename, const CFileProvider &fp); - std::string gettype(); - std::string getauthor(); + const char * gettype(); + const char * getauthor(); private: diff --git a/plugins/adplug/adplug/dro.cpp b/plugins/adplug/adplug/dro.cpp index 8342fe89..1d7d5f8e 100644 --- a/plugins/adplug/adplug/dro.cpp +++ b/plugins/adplug/adplug/dro.cpp @@ -23,7 +23,7 @@ * NOTES: 3-oct-04: the DRO format is not yet finalized. beware. */ -#include <cstring> +#include <string.h> #include <stdio.h> #include "dro.h" @@ -44,7 +44,7 @@ CdroPlayer::CdroPlayer(Copl *newopl) opl3_mode = 1; } -bool CdroPlayer::load(const std::string &filename, const CFileProvider &fp) +bool CdroPlayer::load(const char *filename, const CFileProvider &fp) { binistream *f = fp.open(filename); if(!f) return false; char id[8]; diff --git a/plugins/adplug/adplug/dro.h b/plugins/adplug/adplug/dro.h index 995da6cc..9ecca105 100644 --- a/plugins/adplug/adplug/dro.h +++ b/plugins/adplug/adplug/dro.h @@ -33,14 +33,14 @@ class CdroPlayer: public CPlayer delete [] data; } - bool load(const std::string &filename, const CFileProvider &fp); + bool load(const char *filename, const CFileProvider &fp); bool update(); void rewind(int subsong); float getrefresh(); - std::string gettype() + const char * gettype() { - return std::string("DOSBox Raw OPL v0.1"); + return "DOSBox Raw OPL v0.1"; } protected: diff --git a/plugins/adplug/adplug/dro2.cpp b/plugins/adplug/adplug/dro2.cpp index e11196e7..7fd31548 100644 --- a/plugins/adplug/adplug/dro2.cpp +++ b/plugins/adplug/adplug/dro2.cpp @@ -19,7 +19,7 @@ * dro2.cpp - DOSBox Raw OPL v2.0 player by Adam Nielsen <malvineous@shikadi.net> */ -#include <cstring> +#include <string.h> #include <stdio.h> #include "dro2.h" @@ -42,7 +42,7 @@ Cdro2Player::~Cdro2Player() if (this->piConvTable) delete[] this->piConvTable; } -bool Cdro2Player::load(const std::string &filename, const CFileProvider &fp) +bool Cdro2Player::load(const char * filename, const CFileProvider &fp) { binistream *f = fp.open(filename); if (!f) return false; diff --git a/plugins/adplug/adplug/dro2.h b/plugins/adplug/adplug/dro2.h index fdd2f06d..82dc1fb1 100644 --- a/plugins/adplug/adplug/dro2.h +++ b/plugins/adplug/adplug/dro2.h @@ -41,14 +41,14 @@ class Cdro2Player: public CPlayer Cdro2Player(Copl *newopl); ~Cdro2Player(); - bool load(const std::string &filename, const CFileProvider &fp); + bool load(const char * filename, const CFileProvider &fp); bool update(); void rewind(int subsong); float getrefresh(); - std::string gettype() + const char * gettype() { - return std::string("DOSBox Raw OPL v2.0"); + return "DOSBox Raw OPL v2.0"; } protected: diff --git a/plugins/adplug/adplug/dtm.cpp b/plugins/adplug/adplug/dtm.cpp index 91ea837c..5869a8e3 100644 --- a/plugins/adplug/adplug/dtm.cpp +++ b/plugins/adplug/adplug/dtm.cpp @@ -22,7 +22,7 @@ NOTE: Panning (Ex) effect is ignored. */ -#include <cstring> +#include <string.h> #include "dtm.h" /* -------- Public Methods -------------------------------- */ @@ -32,7 +32,7 @@ CPlayer *CdtmLoader::factory(Copl *newopl) return new CdtmLoader(newopl); } -bool CdtmLoader::load(const std::string &filename, const CFileProvider &fp) +bool CdtmLoader::load(const char *filename, const CFileProvider &fp) { binistream *f = fp.open(filename); if(!f) return false; const unsigned char conv_inst[11] = { 2,1,10,9,4,3,6,5,0,8,7 }; @@ -251,29 +251,29 @@ float CdtmLoader::getrefresh() return 18.2f; } -std::string CdtmLoader::gettype() +const char * CdtmLoader::gettype() { - return std::string("DeFy Adlib Tracker"); + return "DeFy Adlib Tracker"; } -std::string CdtmLoader::gettitle() +const char * CdtmLoader::gettitle() { - return std::string(header.title); + return header.title; } -std::string CdtmLoader::getauthor() +const char * CdtmLoader::getauthor() { - return std::string(header.author); + return header.author; } -std::string CdtmLoader::getdesc() +const char * CdtmLoader::getdesc() { - return std::string(desc); + return desc; } -std::string CdtmLoader::getinstrument(unsigned int n) +const char * CdtmLoader::getinstrument(unsigned int n) { - return std::string(instruments[n].name); + return instruments[n].name; } unsigned int CdtmLoader::getinstruments() diff --git a/plugins/adplug/adplug/dtm.h b/plugins/adplug/adplug/dtm.h index 8429bc4f..d5b10f2d 100644 --- a/plugins/adplug/adplug/dtm.h +++ b/plugins/adplug/adplug/dtm.h @@ -28,15 +28,15 @@ class CdtmLoader: public CmodPlayer CdtmLoader(Copl *newopl) : CmodPlayer(newopl) { }; - bool load(const std::string &filename, const CFileProvider &fp); + bool load(const char *filename, const CFileProvider &fp); void rewind(int subsong); float getrefresh(); - std::string gettype(); - std::string gettitle(); - std::string getauthor(); - std::string getdesc(); - std::string getinstrument(unsigned int n); + const char * gettype(); + const char * gettitle(); + const char * getauthor(); + const char * getdesc(); + const char * getinstrument(unsigned int n); unsigned int getinstruments(); private: diff --git a/plugins/adplug/adplug/flash.cpp b/plugins/adplug/adplug/flash.cpp index a6bf511c..8fc8f333 100644 --- a/plugins/adplug/adplug/flash.cpp +++ b/plugins/adplug/adplug/flash.cpp @@ -219,9 +219,9 @@ float CxadflashPlayer::xadplayer_getrefresh() return 17.5f; } -std::string CxadflashPlayer::xadplayer_gettype() +const char * CxadflashPlayer::xadplayer_gettype() { - return std::string("xad: flash player"); + return "xad: flash player"; } unsigned int CxadflashPlayer::xadplayer_getinstruments() diff --git a/plugins/adplug/adplug/flash.h b/plugins/adplug/adplug/flash.h index a3471df4..d448e042 100644 --- a/plugins/adplug/adplug/flash.h +++ b/plugins/adplug/adplug/flash.h @@ -46,7 +46,7 @@ protected: void xadplayer_rewind(int subsong); void xadplayer_update(); float xadplayer_getrefresh(); - std::string xadplayer_gettype(); + const char * xadplayer_gettype(); unsigned int xadplayer_getinstruments(); private: diff --git a/plugins/adplug/adplug/fmc.cpp b/plugins/adplug/adplug/fmc.cpp index 75cd99a7..bf9911e3 100644 --- a/plugins/adplug/adplug/fmc.cpp +++ b/plugins/adplug/adplug/fmc.cpp @@ -19,7 +19,7 @@ fmc.cpp - FMC Loader by Riven the Mage <riven@ok.ru> */ -#include <cstring> +#include <string.h> #include "fmc.h" /* -------- Public Methods -------------------------------- */ @@ -29,7 +29,7 @@ CPlayer *CfmcLoader::factory(Copl *newopl) return new CfmcLoader(newopl); } -bool CfmcLoader::load(const std::string &filename, const CFileProvider &fp) +bool CfmcLoader::load(const char *filename, const CFileProvider &fp) { binistream *f = fp.open(filename); if(!f) return false; const unsigned char conv_fx[16] = {0,1,2,3,4,8,255,255,255,255,26,11,12,13,14,15}; @@ -168,19 +168,19 @@ float CfmcLoader::getrefresh() return 50.0f; } -std::string CfmcLoader::gettype() +const char * CfmcLoader::gettype() { - return std::string("Faust Music Creator"); + return "Faust Music Creator"; } -std::string CfmcLoader::gettitle() +const char * CfmcLoader::gettitle() { - return std::string(header.title); + return header.title; } -std::string CfmcLoader::getinstrument(unsigned int n) +const char * CfmcLoader::getinstrument(unsigned int n) { - return std::string(instruments[n].name); + return instruments[n].name; } unsigned int CfmcLoader::getinstruments() diff --git a/plugins/adplug/adplug/fmc.h b/plugins/adplug/adplug/fmc.h index ae7d5c5b..0be93a4e 100644 --- a/plugins/adplug/adplug/fmc.h +++ b/plugins/adplug/adplug/fmc.h @@ -28,12 +28,12 @@ class CfmcLoader: public CmodPlayer CfmcLoader(Copl *newopl) : CmodPlayer(newopl) { }; - bool load(const std::string &filename, const CFileProvider &fp); + bool load(const char *filename, const CFileProvider &fp); float getrefresh(); - std::string gettype(); - std::string gettitle(); - std::string getinstrument(unsigned int n); + const char * gettype(); + const char * gettitle(); + const char * getinstrument(unsigned int n); unsigned int getinstruments(); private: diff --git a/plugins/adplug/adplug/fprovide.cpp b/plugins/adplug/adplug/fprovide.cpp index cbe94e2f..12424431 100644 --- a/plugins/adplug/adplug/fprovide.cpp +++ b/plugins/adplug/adplug/fprovide.cpp @@ -27,10 +27,10 @@ /***** CFileProvider *****/ -bool CFileProvider::extension(const std::string &filename, - const std::string &extension) +bool CFileProvider::extension(const char *filename, + const char *extension) { - const char *fname = filename.c_str(), *ext = extension.c_str(); + const char *fname = filename, *ext = extension; if(strlen(fname) < strlen(ext) || stricmp(fname + strlen(fname) - strlen(ext), ext)) @@ -52,7 +52,7 @@ unsigned long CFileProvider::filesize(binistream *f) /***** CProvider_Filesystem *****/ -binistream *CProvider_Filesystem::open(std::string filename) const +binistream *CProvider_Filesystem::open(const char * filename) const { binifstream *f = new binifstream(filename); diff --git a/plugins/adplug/adplug/fprovide.h b/plugins/adplug/adplug/fprovide.h index 572f28ac..0029bd3e 100644 --- a/plugins/adplug/adplug/fprovide.h +++ b/plugins/adplug/adplug/fprovide.h @@ -22,7 +22,6 @@ #ifndef H_ADPLUG_FILEPROVIDER #define H_ADPLUG_FILEPROVIDER -#include <string> #include <binio.h> class CFileProvider @@ -32,18 +31,18 @@ public: { } - virtual binistream *open(std::string) const = 0; + virtual binistream *open(const char *) const = 0; virtual void close(binistream *) const = 0; - static bool extension(const std::string &filename, - const std::string &extension); + static bool extension(const char *filename, + const char *extension); static unsigned long filesize(binistream *f); }; class CProvider_Filesystem: public CFileProvider { public: - virtual binistream *open(std::string filename) const; + virtual binistream *open(const char *filename) const; virtual void close(binistream *f) const; }; diff --git a/plugins/adplug/adplug/hsc.cpp b/plugins/adplug/adplug/hsc.cpp index 1a912ff1..0fdefc3f 100644 --- a/plugins/adplug/adplug/hsc.cpp +++ b/plugins/adplug/adplug/hsc.cpp @@ -31,14 +31,14 @@ CPlayer *ChscPlayer::factory(Copl *newopl) return new ChscPlayer(newopl); } -bool ChscPlayer::load(const std::string &filename, const CFileProvider &fp) +bool ChscPlayer::load(const char *filename, const CFileProvider &fp) { binistream *f = fp.open(filename); int i; // file validation section if(!f || !fp.extension(filename, ".hsc") || fp.filesize(f) > 59187) { - AdPlug_LogWrite("ChscPlayer::load(\"%s\"): Not a HSC file!\n", filename.c_str()); + AdPlug_LogWrite("ChscPlayer::load(\"%s\"): Not a HSC file!\n", filename); fp.close(f); return false; } diff --git a/plugins/adplug/adplug/hsc.h b/plugins/adplug/adplug/hsc.h index 4a9e2d27..e57cdb47 100644 --- a/plugins/adplug/adplug/hsc.h +++ b/plugins/adplug/adplug/hsc.h @@ -31,12 +31,12 @@ class ChscPlayer: public CPlayer ChscPlayer(Copl *newopl): CPlayer(newopl), mtkmode(0) {} - bool load(const std::string &filename, const CFileProvider &fp); + bool load(const char *filename, const CFileProvider &fp); bool update(); void rewind(int subsong); float getrefresh() { return 18.2f; }; // refresh rate is fixed at 18.2Hz - std::string gettype() { return std::string("HSC Adlib Composer / HSC-Tracker"); } + const char * gettype() { return "HSC Adlib Composer / HSC-Tracker"; } unsigned int getpatterns(); unsigned int getpattern() { return song[songpos]; } unsigned int getorders(); diff --git a/plugins/adplug/adplug/hsp.cpp b/plugins/adplug/adplug/hsp.cpp index 0430f6d7..73a697af 100644 --- a/plugins/adplug/adplug/hsp.cpp +++ b/plugins/adplug/adplug/hsp.cpp @@ -28,7 +28,7 @@ CPlayer *ChspLoader::factory(Copl *newopl) return new ChspLoader(newopl); } -bool ChspLoader::load(const std::string &filename, const CFileProvider &fp) +bool ChspLoader::load(const char *filename, const CFileProvider &fp) { binistream *f = fp.open(filename); if(!f) return false; unsigned long i, j, orgsize, filesize; diff --git a/plugins/adplug/adplug/hsp.h b/plugins/adplug/adplug/hsp.h index 86fa9d69..e0505fc2 100644 --- a/plugins/adplug/adplug/hsp.h +++ b/plugins/adplug/adplug/hsp.h @@ -33,7 +33,7 @@ public: : ChscPlayer(newopl) {}; - bool load(const std::string &filename, const CFileProvider &fp); + bool load(const char *filename, const CFileProvider &fp); }; #endif diff --git a/plugins/adplug/adplug/hybrid.cpp b/plugins/adplug/adplug/hybrid.cpp index cff08c88..2e545ba1 100644 --- a/plugins/adplug/adplug/hybrid.cpp +++ b/plugins/adplug/adplug/hybrid.cpp @@ -232,14 +232,14 @@ float CxadhybridPlayer::xadplayer_getrefresh() return 50.0f; } -std::string CxadhybridPlayer::xadplayer_gettype() +const char * CxadhybridPlayer::xadplayer_gettype() { - return (std::string("xad: hybrid player")); + return "xad: hybrid player"; } -std::string CxadhybridPlayer::xadplayer_getinstrument(unsigned int i) +const char * CxadhybridPlayer::xadplayer_getinstrument(unsigned int i) { - return (std::string(hyb.inst[i].name,7)); + return hyb.inst[i].name; } unsigned int CxadhybridPlayer::xadplayer_getinstruments() diff --git a/plugins/adplug/adplug/hybrid.h b/plugins/adplug/adplug/hybrid.h index 65d39d34..d727b84d 100644 --- a/plugins/adplug/adplug/hybrid.h +++ b/plugins/adplug/adplug/hybrid.h @@ -69,8 +69,8 @@ protected: void xadplayer_rewind(int subsong); void xadplayer_update(); float xadplayer_getrefresh(); - std::string xadplayer_gettype(); - std::string xadplayer_getinstrument(unsigned int i); + const char * xadplayer_gettype(); + const char * xadplayer_getinstrument(unsigned int i); unsigned int xadplayer_getinstruments(); private: diff --git a/plugins/adplug/adplug/hyp.cpp b/plugins/adplug/adplug/hyp.cpp index 7ed3a315..724f07a9 100644 --- a/plugins/adplug/adplug/hyp.cpp +++ b/plugins/adplug/adplug/hyp.cpp @@ -119,7 +119,7 @@ float CxadhypPlayer::xadplayer_getrefresh() return 60.0f; } -std::string CxadhypPlayer::xadplayer_gettype() +const char * CxadhypPlayer::xadplayer_gettype() { - return std::string("xad: hypnosis player"); + return "xad: hypnosis player"; } diff --git a/plugins/adplug/adplug/hyp.h b/plugins/adplug/adplug/hyp.h index e2a5bf5a..634cdd3c 100644 --- a/plugins/adplug/adplug/hyp.h +++ b/plugins/adplug/adplug/hyp.h @@ -45,7 +45,7 @@ protected: void xadplayer_rewind(int subsong); void xadplayer_update(); float xadplayer_getrefresh(); - std::string xadplayer_gettype(); + const char * xadplayer_gettype(); private: static const unsigned char hyp_adlib_registers[99]; diff --git a/plugins/adplug/adplug/imf.cpp b/plugins/adplug/adplug/imf.cpp index c525ac8b..06602b9f 100644 --- a/plugins/adplug/adplug/imf.cpp +++ b/plugins/adplug/adplug/imf.cpp @@ -42,6 +42,7 @@ */ #include <string.h> +#include <stdio.h> #include "imf.h" #include "database.h" @@ -53,7 +54,7 @@ CPlayer *CimfPlayer::factory(Copl *newopl) return new CimfPlayer(newopl); } -bool CimfPlayer::load(const std::string &filename, const CFileProvider &fp) +bool CimfPlayer::load(const char *filename, const CFileProvider &fp) { binistream *f = fp.open(filename); if(!f) return false; unsigned long fsize, flsize, mfsize = 0; @@ -76,8 +77,8 @@ bool CimfPlayer::load(const std::string &filename, const CFileProvider &fp) f->seek(0); // It's a normal IMF file } else { // It's a IMF file with header - track_name = f->readString('\0'); - game_name = f->readString('\0'); + f->readString(track_name, sizeof (track_name), '\0'); + f->readString(game_name, sizeof (game_name), '\0'); f->ignore(1); mfsize = f->pos() + 2; } @@ -108,9 +109,9 @@ bool CimfPlayer::load(const std::string &filename, const CFileProvider &fp) if(fsize && (fsize < flsize - 2 - mfsize)) { if(f->readInt(1) == 0x1a) { // Adam Nielsen's footer format - track_name = f->readString(); - author_name = f->readString(); - remarks = f->readString(); + f->readString(track_name, sizeof (track_name)); + f->readString(author_name, sizeof (author_name)); + f->readString(remarks, sizeof (remarks)); } else { // Generic footer unsigned long footerlen = flsize - fsize - 2 - mfsize; @@ -150,45 +151,48 @@ void CimfPlayer::rewind(int subsong) opl->init(); opl->write(1,32); // go to OPL2 mode } -std::string CimfPlayer::gettitle() +const char * CimfPlayer::gettitle() { - std::string title; - - title = track_name; - - if(!track_name.empty() && !game_name.empty()) - title += " - "; - - title += game_name; + title[0] = 0; + if(track_name[0] && game_name[0]) { + snprintf (title, sizeof (title), "%s - %s", game_name, track_name); + } + else if (track_name[0]) { + strcpy (title, track_name); + } + else if (game_name[0]) { + strcpy (title, game_name); + } - return title; + return title; } -std::string CimfPlayer::getdesc() +const char * CimfPlayer::getdesc() { - std::string desc; - + desc[0] = 0; if(footer) - desc = std::string(footer); + strcpy (desc, footer); - if(!remarks.empty() && footer) - desc += "\n\n"; - - desc += remarks; + if(remarks[0] && footer) { + strcat (desc, "\n\n"); + strcat (desc, remarks); + } return desc; } /*** private methods *************************************/ -float CimfPlayer::getrate(const std::string &filename, const CFileProvider &fp, binistream *f) +float CimfPlayer::getrate(const char *filename, const CFileProvider &fp, binistream *f) { +#if 0 if(db) { // Database available f->seek(0, binio::Set); CClockRecord *record = (CClockRecord *)db->search(CAdPlugDatabase::CKey(*f)); if (record && record->type == CAdPlugDatabase::CRecord::ClockSpeed) return record->clock; } +#endif // Otherwise the database is either unavailable, or there's no entry for this file if (fp.extension(filename, ".imf")) return 560.0f; diff --git a/plugins/adplug/adplug/imf.h b/plugins/adplug/adplug/imf.h index 4c7d0daf..9969958c 100644 --- a/plugins/adplug/adplug/imf.h +++ b/plugins/adplug/adplug/imf.h @@ -35,18 +35,18 @@ public: ~CimfPlayer() { if(data) delete [] data; if(footer) delete [] footer; }; - bool load(const std::string &filename, const CFileProvider &fp); + bool load(const char *filename, const CFileProvider &fp); bool update(); void rewind(int subsong); float getrefresh() { return timer; }; - std::string gettype() - { return std::string("IMF File Format"); } - std::string gettitle(); - std::string getauthor() + const char * gettype() + { return "IMF File Format"; } + const char * gettitle(); + const char * getauthor() { return author_name; } - std::string getdesc(); + const char * getdesc(); protected: unsigned long pos, size; @@ -54,7 +54,9 @@ protected: bool songend; float rate, timer; char *footer; - std::string track_name, game_name, author_name, remarks; + char track_name[100], game_name[100], author_name[100], remarks[100]; + char title[100]; + char desc[100]; struct Sdata { unsigned char reg, val; @@ -62,7 +64,7 @@ protected: } *data; private: - float getrate(const std::string &filename, const CFileProvider &fp, binistream *f); + float getrate(const char *filename, const CFileProvider &fp, binistream *f); }; #endif diff --git a/plugins/adplug/adplug/jbm.cpp b/plugins/adplug/adplug/jbm.cpp index 0990001b..1fd33b40 100644 --- a/plugins/adplug/adplug/jbm.cpp +++ b/plugins/adplug/adplug/jbm.cpp @@ -63,7 +63,7 @@ CPlayer *CjbmPlayer::factory(Copl *newopl) return new CjbmPlayer(newopl); } -bool CjbmPlayer::load(const std::string &filename, const CFileProvider &fp) +bool CjbmPlayer::load(const char *filename, const CFileProvider &fp) { binistream *f = fp.open(filename); if(!f) return false; int filelen = fp.filesize(f); diff --git a/plugins/adplug/adplug/jbm.h b/plugins/adplug/adplug/jbm.h index 3f95b03f..1d8572c4 100644 --- a/plugins/adplug/adplug/jbm.h +++ b/plugins/adplug/adplug/jbm.h @@ -32,22 +32,22 @@ class CjbmPlayer: public CPlayer CjbmPlayer(Copl *newopl) : CPlayer(newopl), m(0) { } ~CjbmPlayer() - { if(m != NULL) delete [] m; } + { delete [] m; } - bool load(const std::string &filename, const CFileProvider &fp); + bool load(const char *filename, const CFileProvider &fp); bool update(); void rewind(int subsong); float getrefresh() { return timer; } - std::string gettype() + const char * gettype() { - return std::string(flags&1 ? "JBM Adlib Music [rhythm mode]" : - "JBM Adlib Music"); + return flags&1 ? "JBM Adlib Music [rhythm mode]" : + "JBM Adlib Music"; } - std::string getauthor() - { return std::string("Johannes Bjerregaard"); } + const char * getauthor() + { return "Johannes Bjerregaard"; } protected: diff --git a/plugins/adplug/adplug/ksm.cpp b/plugins/adplug/adplug/ksm.cpp index c12f3d8f..b93b52f7 100644 --- a/plugins/adplug/adplug/ksm.cpp +++ b/plugins/adplug/adplug/ksm.cpp @@ -40,22 +40,22 @@ CPlayer *CksmPlayer::factory(Copl *newopl) return new CksmPlayer(newopl); } -bool CksmPlayer::load(const std::string &filename, const CFileProvider &fp) +bool CksmPlayer::load(const char *filename, const CFileProvider &fp) { binistream *f; int i; - char *fn = new char[filename.length() + 9]; + char *fn = new char[strlen (filename) + 9]; // file validation section if(!fp.extension(filename, ".ksm")) { AdPlug_LogWrite("CksmPlayer::load(,\"%s\"): File doesn't have '.ksm' " - "extension! Rejected!\n", filename.c_str()); + "extension! Rejected!\n", filename); return false; } - AdPlug_LogWrite("*** CksmPlayer::load(,\"%s\") ***\n", filename.c_str()); + AdPlug_LogWrite("*** CksmPlayer::load(,\"%s\") ***\n", filename); // Load instruments from 'insts.dat' - strcpy(fn, filename.c_str()); + strcpy(fn, filename); for(i = strlen(fn) - 1; i >= 0; i--) if(fn[i] == '/' || fn[i] == '\\') break; @@ -289,12 +289,12 @@ void CksmPlayer::rewind(int subsong) nownote = 0; } -std::string CksmPlayer::getinstrument(unsigned int n) +const char * CksmPlayer::getinstrument(unsigned int n) { if(trchan[n]) - return std::string(instname[trinst[n]]); + return instname[trinst[n]]; else - return std::string(); + return ""; } /*** private methods *************************************/ diff --git a/plugins/adplug/adplug/ksm.h b/plugins/adplug/adplug/ksm.h index 98d643ea..85f19a31 100644 --- a/plugins/adplug/adplug/ksm.h +++ b/plugins/adplug/adplug/ksm.h @@ -32,17 +32,17 @@ public: ~CksmPlayer() { if(note) delete [] note; }; - bool load(const std::string &filename, const CFileProvider &fp); + bool load(const char *filename, const CFileProvider &fp); bool update(); void rewind(int subsong); float getrefresh() { return 240.0f; }; - std::string gettype() - { return std::string("Ken Silverman's Music Format"); }; + const char * gettype() + { return "Ken Silverman's Music Format"; }; unsigned int getinstruments() { return 16; }; - std::string getinstrument(unsigned int n); + const char * getinstrument(unsigned int n); private: static const unsigned int adlibfreq[63]; diff --git a/plugins/adplug/adplug/lds.cpp b/plugins/adplug/adplug/lds.cpp index fb70a067..81bae44c 100644 --- a/plugins/adplug/adplug/lds.cpp +++ b/plugins/adplug/adplug/lds.cpp @@ -83,7 +83,7 @@ CldsPlayer::~CldsPlayer() if(patterns) delete [] patterns; } -bool CldsPlayer::load(const std::string &filename, const CFileProvider &fp) +bool CldsPlayer::load(const char *filename, const CFileProvider &fp) { binistream *f; unsigned int i, j; @@ -142,7 +142,7 @@ bool CldsPlayer::load(const std::string &filename, const CFileProvider &fp) AdPlug_LogWrite("CldsPlayer::load(\"%s\",fp): loading LOUDNESS file: mode = " "%d, pattlen = %d, numpatch = %d, numposi = %d\n", - filename.c_str(), mode, pattlen, numpatch, numposi); + filename, mode, pattlen, numpatch, numposi); // load patterns f->ignore(2); // ignore # of digital sounds (not played by this player) diff --git a/plugins/adplug/adplug/lds.h b/plugins/adplug/adplug/lds.h index 95f59606..2642a6a9 100644 --- a/plugins/adplug/adplug/lds.h +++ b/plugins/adplug/adplug/lds.h @@ -29,12 +29,12 @@ class CldsPlayer: public CPlayer CldsPlayer(Copl *newopl); virtual ~CldsPlayer(); - bool load(const std::string &filename, const CFileProvider &fp); + bool load(const char *filename, const CFileProvider &fp); virtual bool update(); virtual void rewind(int subsong = -1); float getrefresh() { return 70.0f; } - std::string gettype() { return std::string("LOUDNESS Sound System"); } + const char * gettype() { return "LOUDNESS Sound System"; } unsigned int getorders() { return numposi; } unsigned int getorder() { return posplay; } unsigned int getrow() { return pattplay; } diff --git a/plugins/adplug/adplug/mad.cpp b/plugins/adplug/adplug/mad.cpp index b8cb527d..76e694c5 100644 --- a/plugins/adplug/adplug/mad.cpp +++ b/plugins/adplug/adplug/mad.cpp @@ -19,7 +19,7 @@ mad.cpp - MAD loader by Riven the Mage <riven@ok.ru> */ -#include <cstring> +#include <string.h> #include "mad.h" /* -------- Public Methods -------------------------------- */ @@ -29,7 +29,7 @@ CPlayer *CmadLoader::factory(Copl *newopl) return new CmadLoader(newopl); } -bool CmadLoader::load(const std::string &filename, const CFileProvider &fp) +bool CmadLoader::load(const char *filename, const CFileProvider &fp) { binistream *f = fp.open(filename); if(!f) return false; const unsigned char conv_inst[10] = { 2,1,10,9,4,3,6,5,8,7 }; @@ -111,14 +111,14 @@ float CmadLoader::getrefresh() return (float)timer; } -std::string CmadLoader::gettype() +const char * CmadLoader::gettype() { - return std::string("Mlat Adlib Tracker"); + return "Mlat Adlib Tracker"; } -std::string CmadLoader::getinstrument(unsigned int n) +const char * CmadLoader::getinstrument(unsigned int n) { - return std::string(instruments[n].name,8); + return instruments[n].name; } unsigned int CmadLoader::getinstruments() diff --git a/plugins/adplug/adplug/mad.h b/plugins/adplug/adplug/mad.h index 98d2a445..c9272924 100644 --- a/plugins/adplug/adplug/mad.h +++ b/plugins/adplug/adplug/mad.h @@ -28,12 +28,12 @@ public: CmadLoader(Copl *newopl) : CmodPlayer(newopl) { }; - bool load(const std::string &filename, const CFileProvider &fp); + bool load(const char *filename, const CFileProvider &fp); void rewind(int subsong); float getrefresh(); - std::string gettype(); - std::string getinstrument(unsigned int n); + const char * gettype(); + const char * getinstrument(unsigned int n); unsigned int getinstruments(); private: diff --git a/plugins/adplug/adplug/mid.cpp b/plugins/adplug/adplug/mid.cpp index 03a2d84a..5c13b144 100644 --- a/plugins/adplug/adplug/mid.cpp +++ b/plugins/adplug/adplug/mid.cpp @@ -178,15 +178,15 @@ unsigned long CmidPlayer::getval() return(v); } -bool CmidPlayer::load_sierra_ins(const std::string &fname, const CFileProvider &fp) +bool CmidPlayer::load_sierra_ins(const char *fname, const CFileProvider &fp) { long i,j,k,l; unsigned char ins[28]; char *pfilename; binistream *f; - pfilename = (char *)malloc(fname.length()+9); - strcpy(pfilename,fname.c_str()); + pfilename = (char *)malloc(strlen (fname)+9); + strcpy(pfilename,fname); j=0; for(i=strlen(pfilename)-1; i >= 0; i--) if(pfilename[i] == '/' || pfilename[i] == '\\') { @@ -281,7 +281,7 @@ void CmidPlayer::sierra_next_section() doing=1; } -bool CmidPlayer::load(const std::string &filename, const CFileProvider &fp) +bool CmidPlayer::load(const char *filename, const CFileProvider &fp) { binistream *f = fp.open(filename); if(!f) return false; int good; @@ -1089,22 +1089,22 @@ void CmidPlayer::rewind(int subsong) midi_fm_reset(); } -std::string CmidPlayer::gettype() +const char * CmidPlayer::gettype() { switch(type) { case FILE_LUCAS: - return std::string("LucasArts AdLib MIDI"); + return "LucasArts AdLib MIDI"; case FILE_MIDI: - return std::string("General MIDI"); + return "General MIDI"; case FILE_CMF: - return std::string("Creative Music Format (CMF MIDI)"); + return "Creative Music Format (CMF MIDI)"; case FILE_OLDLUCAS: - return std::string("Lucasfilm Adlib MIDI"); + return "Lucasfilm Adlib MIDI"; case FILE_ADVSIERRA: - return std::string("Sierra On-Line VGA MIDI"); + return "Sierra On-Line VGA MIDI"; case FILE_SIERRA: - return std::string("Sierra On-Line EGA MIDI"); + return "Sierra On-Line EGA MIDI"; default: - return std::string("MIDI unknown"); + return "MIDI unknown"; } } diff --git a/plugins/adplug/adplug/mid.h b/plugins/adplug/adplug/mid.h index 5dfe9e76..d5fac624 100644 --- a/plugins/adplug/adplug/mid.h +++ b/plugins/adplug/adplug/mid.h @@ -30,18 +30,18 @@ public: ~CmidPlayer() { if(data) delete [] data; } - bool load(const std::string &filename, const CFileProvider &fp); + bool load(const char *filename, const CFileProvider &fp); bool update(); void rewind(int subsong); float getrefresh(); - std::string gettype(); - std::string gettitle() - { return std::string(title); } - std::string getauthor() - { return std::string(author); } - std::string getdesc() - { return std::string(remarks); } + const char * gettype(); + const char * gettitle() + { return title; } + const char * getauthor() + { return author; } + const char * getdesc() + { return remarks; } unsigned int getinstruments() { return tins; } unsigned int getsubsongs() @@ -95,7 +95,7 @@ public: int type,tins,stins; private: - bool load_sierra_ins(const std::string &fname, const CFileProvider &fp); + bool load_sierra_ins(const char *fname, const CFileProvider &fp); void midiprintf(const char *format, ...); unsigned char datalook(long pos); unsigned long getnexti(unsigned long num); diff --git a/plugins/adplug/adplug/mkj.cpp b/plugins/adplug/adplug/mkj.cpp index 38c1c082..4d18a0f8 100644 --- a/plugins/adplug/adplug/mkj.cpp +++ b/plugins/adplug/adplug/mkj.cpp @@ -19,7 +19,7 @@ * mkj.cpp - MKJamz Player, by Simon Peter <dn.tlp@gmx.net> */ -#include <cstring> +#include <string.h> #include <assert.h> #include "mkj.h" @@ -30,7 +30,7 @@ CPlayer *CmkjPlayer::factory(Copl *newopl) return new CmkjPlayer(newopl); } -bool CmkjPlayer::load(const std::string &filename, const CFileProvider &fp) +bool CmkjPlayer::load(const char *filename, const CFileProvider &fp) { binistream *f = fp.open(filename); if(!f) return false; char id[6]; @@ -65,7 +65,7 @@ bool CmkjPlayer::load(const std::string &filename, const CFileProvider &fp) songbuf[i] = f->readInt(2); AdPlug_LogWrite("CmkjPlayer::load(\"%s\"): loaded file ver %.2f, %d channels," - " %d notes/channel.\n", filename.c_str(), ver, maxchannel, + " %d notes/channel.\n", filename, ver, maxchannel, maxnotes); fp.close(f); rewind(0); diff --git a/plugins/adplug/adplug/mkj.h b/plugins/adplug/adplug/mkj.h index a7a2ffad..b82d33fe 100644 --- a/plugins/adplug/adplug/mkj.h +++ b/plugins/adplug/adplug/mkj.h @@ -32,13 +32,13 @@ public: ~CmkjPlayer() { if(songbuf) delete [] songbuf; } - bool load(const std::string &filename, const CFileProvider &fp); + bool load(const char * filename, const CFileProvider &fp); bool update(); void rewind(int subsong); float getrefresh(); - std::string gettype() - { return std::string("MKJamz Audio File"); } + const char * gettype() + { return "MKJamz Audio File"; } private: short maxchannel,maxnotes,*songbuf; diff --git a/plugins/adplug/adplug/msc.cpp b/plugins/adplug/adplug/msc.cpp index c9eade06..ae613e48 100644 --- a/plugins/adplug/adplug/msc.cpp +++ b/plugins/adplug/adplug/msc.cpp @@ -19,7 +19,7 @@ * msc.c - MSC Player by Lubomir Bulej (pallas@kadan.cz) */ -#include <cstring> +#include <string.h> #include <stdio.h> #include "msc.h" @@ -63,7 +63,7 @@ CmscPlayer::~CmscPlayer() delete [] desc; } -bool CmscPlayer::load(const std::string & filename, const CFileProvider & fp) +bool CmscPlayer::load(const char * filename, const CFileProvider & fp) { binistream * bf; msc_header hdr; @@ -172,12 +172,10 @@ float CmscPlayer::getrefresh() return 1193180 / (float) (timer_div ? timer_div : 0xffff); } -std::string CmscPlayer::gettype() +const char * CmscPlayer::gettype() { - char vstr [40]; - sprintf(vstr, "AdLib MSCplay (version %d)", version); - return std::string (vstr); + return vstr; } /*** private methods *************************************/ diff --git a/plugins/adplug/adplug/msc.h b/plugins/adplug/adplug/msc.h index a42ec750..0cca2933 100644 --- a/plugins/adplug/adplug/msc.h +++ b/plugins/adplug/adplug/msc.h @@ -32,12 +32,12 @@ class CmscPlayer: public CPlayer CmscPlayer(Copl * newopl); ~CmscPlayer(); - bool load(const std::string &filename, const CFileProvider &fp); + bool load(const char *filename, const CFileProvider &fp); bool update(); void rewind(int subsong); float getrefresh(); - std::string gettype (); + const char * gettype (); protected: typedef unsigned char u8; @@ -81,6 +81,8 @@ class CmscPlayer: public CPlayer private: static const u8 msc_signature [MSC_SIGN_LEN]; + char vstr [40]; + bool load_header (binistream * bf, msc_header * hdr); bool decode_octet (u8 * output); diff --git a/plugins/adplug/adplug/mtk.cpp b/plugins/adplug/adplug/mtk.cpp index 6bafc853..c9631121 100644 --- a/plugins/adplug/adplug/mtk.cpp +++ b/plugins/adplug/adplug/mtk.cpp @@ -19,7 +19,7 @@ * mtk.cpp - MPU-401 Trakker Loader by Simon Peter (dn.tlp@gmx.net) */ -#include <cstring> +#include <string.h> #include "mtk.h" /*** public methods **************************************/ @@ -29,7 +29,7 @@ CPlayer *CmtkLoader::factory(Copl *newopl) return new CmtkLoader(newopl); } -bool CmtkLoader::load(const std::string &filename, const CFileProvider &fp) +bool CmtkLoader::load(const char *filename, const CFileProvider &fp) { binistream *f = fp.open(filename); if(!f) return false; struct { diff --git a/plugins/adplug/adplug/mtk.h b/plugins/adplug/adplug/mtk.h index 175576a2..37328e0f 100644 --- a/plugins/adplug/adplug/mtk.h +++ b/plugins/adplug/adplug/mtk.h @@ -32,18 +32,18 @@ class CmtkLoader: public ChscPlayer mtkmode = 1; }; - bool load(const std::string &filename, const CFileProvider &fp); + bool load(const char *filename, const CFileProvider &fp); - std::string gettype() - { return std::string("MPU-401 Trakker"); }; - std::string gettitle() - { return std::string(title); }; - std::string getauthor() - { return std::string(composer); }; + const char * gettype() + { return "MPU-401 Trakker"; }; + const char * gettitle() + { return title; }; + const char * getauthor() + { return composer; }; unsigned int getinstruments() { return 128; }; - std::string getinstrument(unsigned int n) - { return std::string(instname[n]); }; + const char * getinstrument(unsigned int n) + { return instname[n]; }; private: char title[34],composer[34],instname[0x80][34]; diff --git a/plugins/adplug/adplug/player.cpp b/plugins/adplug/adplug/player.cpp index 9a0061af..03d26902 100644 --- a/plugins/adplug/adplug/player.cpp +++ b/plugins/adplug/adplug/player.cpp @@ -32,8 +32,10 @@ const unsigned char CPlayer::op_table[9] = {0x00, 0x01, 0x02, 0x08, 0x09, 0x0a, 0x10, 0x11, 0x12}; CPlayer::CPlayer(Copl *newopl) - : opl(newopl), db(CAdPlug::database) +// : opl(newopl) + //, db(CAdPlug::database) { + opl = newopl; } CPlayer::~CPlayer() diff --git a/plugins/adplug/adplug/player.h b/plugins/adplug/adplug/player.h index 8c474daa..c83eda79 100644 --- a/plugins/adplug/adplug/player.h +++ b/plugins/adplug/adplug/player.h @@ -22,8 +22,6 @@ #ifndef H_ADPLUG_PLAYER #define H_ADPLUG_PLAYER -#include <string> - #include "fprovide.h" #include "opl.h" #include "database.h" @@ -37,7 +35,7 @@ public: /***** Operational methods *****/ void seek(unsigned long ms); - virtual bool load(const std::string &filename, // loads file + virtual bool load(const char *filename, // loads file const CFileProvider &fp = CProvider_Filesystem()) = 0; virtual bool update() = 0; // executes replay code for 1 tick virtual void rewind(int subsong = -1) = 0; // rewinds to specified subsong @@ -46,13 +44,13 @@ public: /***** Informational methods *****/ unsigned long songlength(int subsong = -1); - virtual std::string gettype() = 0; // returns file type - virtual std::string gettitle() // returns song title - { return std::string(); } - virtual std::string getauthor() // returns song author name - { return std::string(); } - virtual std::string getdesc() // returns song description - { return std::string(); } + virtual const char *gettype() = 0; // returns file type + virtual const char *gettitle() // returns song title + { return ""; } + virtual const char *getauthor() // returns song author name + { return ""; } + virtual const char *getdesc() // returns song description + { return ""; } virtual unsigned int getpatterns() // returns number of patterns { return 0; } virtual unsigned int getpattern() // returns currently playing pattern @@ -71,12 +69,12 @@ public: { return 0; } virtual unsigned int getinstruments() // returns number of instruments { return 0; } - virtual std::string getinstrument(unsigned int n) // returns n-th instrument name - { return std::string(); } + virtual const char *getinstrument(unsigned int n) // returns n-th instrument name + { return ""; } protected: Copl *opl; // our OPL chip - CAdPlugDatabase *db; // AdPlug Database + //CAdPlugDatabase *db; // AdPlug Database static const unsigned short note_table[12]; // standard adlib note table static const unsigned char op_table[9]; // the 9 operators as expected by the OPL diff --git a/plugins/adplug/adplug/players.cpp b/plugins/adplug/adplug/players.cpp index 09c32b73..c8884fcd 100644 --- a/plugins/adplug/adplug/players.cpp +++ b/plugins/adplug/adplug/players.cpp @@ -32,8 +32,9 @@ CPlayerDesc::CPlayerDesc() } CPlayerDesc::CPlayerDesc(const CPlayerDesc &pd) - : factory(pd.factory), filetype(pd.filetype), extlength(pd.extlength) + : factory(pd.factory), extlength(pd.extlength) { + memcpy (filetype, pd.filetype, sizeof (filetype)); if(pd.extensions) { extensions = (char *)malloc(extlength); memcpy(extensions, pd.extensions, extlength); @@ -41,9 +42,10 @@ CPlayerDesc::CPlayerDesc(const CPlayerDesc &pd) extensions = 0; } -CPlayerDesc::CPlayerDesc(Factory f, const std::string &type, const char *ext) - : factory(f), filetype(type), extensions(0) +CPlayerDesc::CPlayerDesc(Factory f, const char *type, const char *ext) + : factory(f), extensions(0) { + strcpy (filetype, type); const char *i = ext; // Determine length of passed extensions list @@ -80,26 +82,25 @@ const char *CPlayerDesc::get_extension(unsigned int n) const /***** CPlayers *****/ -const CPlayerDesc *CPlayers::lookup_filetype(const std::string &ftype) const +const CPlayerDesc *CPlayers::lookup_filetype(const char *ftype) const { - const_iterator i; - - for(i = begin(); i != end(); i++) - if((*i)->filetype == ftype) - return *i; + for (const CPlayerDesc *i = head; i; i = i->next) { + if(!strcmp (i->filetype, ftype)) + return i; + } return 0; } -const CPlayerDesc *CPlayers::lookup_extension(const std::string &extension) const +const CPlayerDesc *CPlayers::lookup_extension(const char *extension) const { - const_iterator i; - unsigned int j; - - for(i = begin(); i != end(); i++) - for(j = 0; (*i)->get_extension(j); j++) - if(!stricmp(extension.c_str(), (*i)->get_extension(j))) - return *i; + for (const CPlayerDesc *i = head; i; i = i->next) { + for(int j = 0; i->get_extension(j); j++) { + if(!strcmp (i->get_extension (j), extension)) { + return i; + } + } + } return 0; } diff --git a/plugins/adplug/adplug/players.h b/plugins/adplug/adplug/players.h index 9d686aef..82a8f3e0 100644 --- a/plugins/adplug/adplug/players.h +++ b/plugins/adplug/adplug/players.h @@ -22,9 +22,6 @@ #ifndef H_ADPLUG_PLAYERS #define H_ADPLUG_PLAYERS -#include <string> -#include <list> - #include "opl.h" #include "player.h" @@ -34,27 +31,47 @@ public: typedef CPlayer *(*Factory)(Copl *); Factory factory; - std::string filetype; + char filetype[50]; CPlayerDesc(); CPlayerDesc(const CPlayerDesc &pd); - CPlayerDesc(Factory f, const std::string &type, const char *ext); + CPlayerDesc(Factory f, const char *type, const char *ext); ~CPlayerDesc(); void add_extension(const char *ext); const char *get_extension(unsigned int n) const; + CPlayerDesc *next; + private: char *extensions; unsigned long extlength; }; -class CPlayers: public std::list<const CPlayerDesc *> +class CPlayers { public: - const CPlayerDesc *lookup_filetype(const std::string &ftype) const; - const CPlayerDesc *lookup_extension(const std::string &extension) const; + CPlayerDesc *head; + CPlayerDesc *tail; + CPlayers() { + head = 0; + tail = 0; + } + const CPlayerDesc *lookup_filetype(const char *ftype) const; + const CPlayerDesc *lookup_extension(const char *extension) const; + + void push_back (CPlayerDesc *ply) { + ply->next = 0; + if (tail) { + tail->next = ply; + } + tail = ply; + if (!head) { + head = ply; + } + } + }; #endif diff --git a/plugins/adplug/adplug/protrack.cpp b/plugins/adplug/adplug/protrack.cpp index ebb1570b..bd56e6bc 100644 --- a/plugins/adplug/adplug/protrack.cpp +++ b/plugins/adplug/adplug/protrack.cpp @@ -25,7 +25,7 @@ * Protracker-like format, this is most certainly the player you want to use. */ -#include <cstring> +#include <string.h> #include "protrack.h" #include "debug.h" diff --git a/plugins/adplug/adplug/psi.cpp b/plugins/adplug/adplug/psi.cpp index 00184526..64e5e891 100644 --- a/plugins/adplug/adplug/psi.cpp +++ b/plugins/adplug/adplug/psi.cpp @@ -166,9 +166,9 @@ float CxadpsiPlayer::xadplayer_getrefresh() return 70.0f; } -std::string CxadpsiPlayer::xadplayer_gettype() +const char * CxadpsiPlayer::xadplayer_gettype() { - return std::string("xad: psi player"); + return "xad: psi player"; } unsigned int CxadpsiPlayer::xadplayer_getinstruments() diff --git a/plugins/adplug/adplug/psi.h b/plugins/adplug/adplug/psi.h index 9714ed12..10f5dd3a 100644 --- a/plugins/adplug/adplug/psi.h +++ b/plugins/adplug/adplug/psi.h @@ -55,7 +55,7 @@ protected: void xadplayer_rewind(int subsong); void xadplayer_update(); float xadplayer_getrefresh(); - std::string xadplayer_gettype(); + const char * xadplayer_gettype(); unsigned int xadplayer_getinstruments(); private: diff --git a/plugins/adplug/adplug/rad.cpp b/plugins/adplug/adplug/rad.cpp index 7996d9ae..5985a98c 100644 --- a/plugins/adplug/adplug/rad.cpp +++ b/plugins/adplug/adplug/rad.cpp @@ -22,7 +22,7 @@ * some volumes are dropped out */ -#include <cstring> +#include <string.h> #include "rad.h" CPlayer *CradLoader::factory(Copl *newopl) @@ -30,7 +30,7 @@ CPlayer *CradLoader::factory(Copl *newopl) return new CradLoader(newopl); } -bool CradLoader::load(const std::string &filename, const CFileProvider &fp) +bool CradLoader::load(const char *filename, const CFileProvider &fp) { binistream *f = fp.open(filename); if(!f) return false; char id[16]; diff --git a/plugins/adplug/adplug/rad.h b/plugins/adplug/adplug/rad.h index 07814b8a..f93d28d7 100644 --- a/plugins/adplug/adplug/rad.h +++ b/plugins/adplug/adplug/rad.h @@ -30,13 +30,13 @@ public: : CmodPlayer(newopl) { *desc = '\0'; }; - bool load(const std::string &filename, const CFileProvider &fp); + bool load(const char *filename, const CFileProvider &fp); float getrefresh(); - std::string gettype() - { return std::string("Reality ADlib Tracker"); }; - std::string getdesc() - { return std::string(desc); }; + const char * gettype() + { return "Reality ADlib Tracker"; }; + const char * getdesc() + { return desc; }; private: unsigned char version,radflags; diff --git a/plugins/adplug/adplug/rat.cpp b/plugins/adplug/adplug/rat.cpp index 34f97cb6..c20780fd 100644 --- a/plugins/adplug/adplug/rat.cpp +++ b/plugins/adplug/adplug/rat.cpp @@ -29,7 +29,7 @@ comment : there are bug in original replayer's adlib_init(): wrong frequency registers. */ -#include <cstring> +#include <string.h> #include "rat.h" #include "debug.h" @@ -254,14 +254,14 @@ float CxadratPlayer::xadplayer_getrefresh() return 60.0f; } -std::string CxadratPlayer::xadplayer_gettype() +const char * CxadratPlayer::xadplayer_gettype() { - return (std::string("xad: rat player")); + return "xad: rat player"; } -std::string CxadratPlayer::xadplayer_gettitle() +const char * CxadratPlayer::xadplayer_gettitle() { - return (std::string(rat.hdr.title,32)); + return rat.hdr.title; } unsigned int CxadratPlayer::xadplayer_getinstruments() diff --git a/plugins/adplug/adplug/rat.h b/plugins/adplug/adplug/rat.h index cc9ddf71..b57b7221 100644 --- a/plugins/adplug/adplug/rat.h +++ b/plugins/adplug/adplug/rat.h @@ -109,8 +109,8 @@ protected: void xadplayer_rewind(int subsong); void xadplayer_update(); float xadplayer_getrefresh(); - std::string xadplayer_gettype(); - std::string xadplayer_gettitle(); + const char * xadplayer_gettype(); + const char * xadplayer_gettitle(); unsigned int xadplayer_getinstruments(); // private: diff --git a/plugins/adplug/adplug/raw.cpp b/plugins/adplug/adplug/raw.cpp index 0ca3f36b..3041ea05 100644 --- a/plugins/adplug/adplug/raw.cpp +++ b/plugins/adplug/adplug/raw.cpp @@ -19,7 +19,7 @@ * raw.c - RAW Player by Simon Peter <dn.tlp@gmx.net> */ -#include <cstring> +#include <string.h> #include "raw.h" /*** public methods *************************************/ @@ -29,7 +29,7 @@ CPlayer *CrawPlayer::factory(Copl *newopl) return new CrawPlayer(newopl); } -bool CrawPlayer::load(const std::string &filename, const CFileProvider &fp) +bool CrawPlayer::load(const char *filename, const CFileProvider &fp) { binistream *f = fp.open(filename); if(!f) return false; char id[8]; diff --git a/plugins/adplug/adplug/raw.h b/plugins/adplug/adplug/raw.h index e05f1fe7..f36ea9f7 100644 --- a/plugins/adplug/adplug/raw.h +++ b/plugins/adplug/adplug/raw.h @@ -32,13 +32,13 @@ public: ~CrawPlayer() { if(data) delete [] data; }; - bool load(const std::string &filename, const CFileProvider &fp); + bool load(const char *filename, const CFileProvider &fp); bool update(); void rewind(int subsong); float getrefresh(); - std::string gettype() - { return std::string("RdosPlay RAW"); }; + const char * gettype() + { return "RdosPlay RAW"; }; protected: struct Tdata { diff --git a/plugins/adplug/adplug/rix.cpp b/plugins/adplug/adplug/rix.cpp index 5cd69bd1..8b788ec6 100644 --- a/plugins/adplug/adplug/rix.cpp +++ b/plugins/adplug/adplug/rix.cpp @@ -20,7 +20,7 @@ * BSPAL <BSPAL.ys168.com> */ -#include <cstring> +#include <string.h> #include "rix.h" #include "debug.h" @@ -64,13 +64,16 @@ CrixPlayer::~CrixPlayer() delete [] file_buffer; } -bool CrixPlayer::load(const std::string &filename, const CFileProvider &fp) +bool CrixPlayer::load(const char *filename, const CFileProvider &fp) { binistream *f = fp.open(filename); if(!f) return false; unsigned long i=0; - if(stricmp(filename.substr(filename.length()-4,4).c_str(),".mkf")==0) - { + const char *pext = filename + strlen (filename); + while (pext > filename && *pext != '.') { + pext--; + } + if (*pext == '.' && !stricmp (pext+1, ".mkf")) { flag_mkf=1; f->seek(0); int offset=f->readInt(4); diff --git a/plugins/adplug/adplug/rix.h b/plugins/adplug/adplug/rix.h index 68e08c8b..b0748b0f 100644 --- a/plugins/adplug/adplug/rix.h +++ b/plugins/adplug/adplug/rix.h @@ -30,14 +30,14 @@ class CrixPlayer: public CPlayer CrixPlayer(Copl *newopl); ~CrixPlayer(); - bool load(const std::string &filename, const CFileProvider &fp); + bool load(const char *filename, const CFileProvider &fp); bool update(); void rewind(int subsong); float getrefresh(); unsigned int getsubsongs(); - std::string gettype() - { return std::string("Softstar RIX OPL Music Format"); }; + const char * gettype() + { return "Softstar RIX OPL Music Format"; }; protected: typedef struct { diff --git a/plugins/adplug/adplug/rol.cpp b/plugins/adplug/adplug/rol.cpp index a2a88fe8..d0d25f7d 100644 --- a/plugins/adplug/adplug/rol.cpp +++ b/plugins/adplug/adplug/rol.cpp @@ -20,12 +20,11 @@ * * Visit: http://tenacity.hispeed.com/aomit/oplx/ */ -#include <cstring> -#include <algorithm> - +#include <string.h> #include "rol.h" #include "debug.h" + int const CrolPlayer::kSizeofDataRecord = 30; int const CrolPlayer::kMaxTickBeat = 60; int const CrolPlayer::kSilenceNote = -12; @@ -65,16 +64,23 @@ CPlayer *CrolPlayer::factory(Copl *newopl) } //--------------------------------------------------------- CrolPlayer::CrolPlayer(Copl *newopl) -: CPlayer ( newopl ) +: CPlayer ( newopl ) ,rol_header ( NULL ) ,mNextTempoEvent ( 0 ) ,mCurrTick ( 0 ) ,mTimeOfLastNote ( 0 ) ,mRefresh ( kDefaultUpdateTme ) ,bdRegister ( 0 ) + ,n_voice_data(0) + ,n_tempo_events(0) + ,n_used_ins(0) { int n; + mTempoEvents = 0; + voice_data = 0; + ins_list = 0; + memset(bxRegister, 0, sizeof(bxRegister) ); memset(volumeCache, 0, sizeof(volumeCache) ); memset(freqCache, 0, sizeof(freqCache) ); @@ -90,25 +96,31 @@ CrolPlayer::~CrolPlayer() delete rol_header; rol_header=NULL; } + + delete[] mTempoEvents; + delete[] voice_data; + delete[] ins_list; } //--------------------------------------------------------- -bool CrolPlayer::load(const std::string &filename, const CFileProvider &fp) +bool CrolPlayer::load(const char *filename, const CFileProvider &fp) { binistream *f = fp.open(filename); if(!f) return false; - char *fn = new char[filename.length()+12]; + char fn[strlen(filename)+12]; int i; - std::string bnk_filename; - - AdPlug_LogWrite("*** CrolPlayer::load(f, \"%s\") ***\n", filename.c_str()); - strcpy(fn,filename.data()); - for (i=strlen(fn)-1; i>=0; i--) - if (fn[i] == '/' || fn[i] == '\\') - break; + const char * bnk_filename; + + AdPlug_LogWrite("*** CrolPlayer::load(f, \"%s\") ***\n", filename); + strcpy(fn,filename); + int len = strlen(fn)-1; + for (i=len; i>=0; i--) { + if (fn[i] == '/' || fn[i] == '\\') { + break; + } + } strcpy(fn+i+1,"standard.bnk"); bnk_filename = fn; - delete [] fn; - AdPlug_LogWrite("bnk_filename = \"%s\"\n",bnk_filename.c_str()); + AdPlug_LogWrite("bnk_filename = \"%s\"\n",bnk_filename); rol_header = new SRolHeader; memset( rol_header, 0, sizeof(SRolHeader) ); @@ -157,27 +169,27 @@ bool CrolPlayer::load(const std::string &filename, const CFileProvider &fp) rewind( 0 ); AdPlug_LogWrite("--- CrolPlayer::load ---\n"); + return true; } //--------------------------------------------------------- bool CrolPlayer::update() { - if( mNextTempoEvent < mTempoEvents.size() && + if( mNextTempoEvent < n_tempo_events && mTempoEvents[mNextTempoEvent].time == mCurrTick ) { SetRefresh( mTempoEvents[mNextTempoEvent].multiplier ); ++mNextTempoEvent; } - TVoiceData::iterator curr = voice_data.begin(); - TVoiceData::iterator end = voice_data.end(); - int voice = 0; - while( curr != end ) + int curr = 0; + int end = n_voice_data; + + while( curr < end ) { - UpdateVoice( voice, *curr ); + UpdateVoice( curr, voice_data[curr] ); ++curr; - ++voice; } ++mCurrTick; @@ -193,12 +205,10 @@ bool CrolPlayer::update() //--------------------------------------------------------- void CrolPlayer::rewind( int subsong ) { - TVoiceData::iterator curr = voice_data.begin(); - TVoiceData::iterator end = voice_data.end(); - - while( curr != end ) + int curr = 0; + while( curr < n_voice_data ) { - CVoiceData &voice = *curr; + CVoiceData &voice = voice_data[curr]; voice.Reset(); ++curr; @@ -246,23 +256,17 @@ float CrolPlayer::getrefresh() //--------------------------------------------------------- void CrolPlayer::UpdateVoice( int const voice, CVoiceData &voiceData ) { - TNoteEvents const &nEvents = voiceData.note_events; - - if( nEvents.empty() || voiceData.mEventStatus & CVoiceData::kES_NoteEnd ) + if( !voiceData.n_note_events || (voiceData.mEventStatus & CVoiceData::kES_NoteEnd) ) { return; // no note data to process, don't bother doing anything. } - TInstrumentEvents &iEvents = voiceData.instrument_events; - TVolumeEvents &vEvents = voiceData.volume_events; - TPitchEvents &pEvents = voiceData.pitch_events; - if( !(voiceData.mEventStatus & CVoiceData::kES_InstrEnd ) && - iEvents[voiceData.next_instrument_event].time == mCurrTick ) + voiceData.instrument_events[voiceData.next_instrument_event].time == mCurrTick ) { - if( voiceData.next_instrument_event < iEvents.size() ) + if( voiceData.next_instrument_event < voiceData.n_instrument_events ) { - send_ins_data_to_chip( voice, iEvents[voiceData.next_instrument_event].ins_index ); + send_ins_data_to_chip( voice, voiceData.instrument_events[voiceData.next_instrument_event].ins_index ); ++voiceData.next_instrument_event; } else @@ -272,11 +276,11 @@ void CrolPlayer::UpdateVoice( int const voice, CVoiceData &voiceData ) } if( !(voiceData.mEventStatus & CVoiceData::kES_VolumeEnd ) && - vEvents[voiceData.next_volume_event].time == mCurrTick ) + voiceData.volume_events[voiceData.next_volume_event].time == mCurrTick ) { - SVolumeEvent const &volumeEvent = vEvents[voiceData.next_volume_event]; + SVolumeEvent const &volumeEvent = voiceData.volume_events[voiceData.next_volume_event]; - if( voiceData.next_volume_event < vEvents.size() ) + if( voiceData.next_volume_event < voiceData.n_volume_events ) { int const volume = (int)(63.0f*(1.0f - volumeEvent.multiplier)); @@ -297,9 +301,9 @@ void CrolPlayer::UpdateVoice( int const voice, CVoiceData &voiceData ) ++voiceData.current_note; } - if( voiceData.current_note < nEvents.size() ) + if( voiceData.current_note < voiceData.n_note_events ) { - SNoteEvent const ¬eEvent = nEvents[voiceData.current_note]; + SNoteEvent const ¬eEvent = voiceData.note_events[voiceData.current_note]; SetNote( voice, noteEvent.number ); voiceData.current_note_duration = 0; @@ -315,11 +319,11 @@ void CrolPlayer::UpdateVoice( int const voice, CVoiceData &voiceData ) } if( !(voiceData.mEventStatus & CVoiceData::kES_PitchEnd ) && - pEvents[voiceData.next_pitch_event].time == mCurrTick ) + voiceData.pitch_events[voiceData.next_pitch_event].time == mCurrTick ) { - if( voiceData.next_pitch_event < pEvents.size() ) + if( voiceData.next_pitch_event < voiceData.n_pitch_events ) { - SetPitch(voice,pEvents[voiceData.next_pitch_event].variation); + SetPitch(voice,voiceData.pitch_events[voiceData.next_pitch_event].variation); ++voiceData.next_pitch_event; } else @@ -454,7 +458,8 @@ void CrolPlayer::load_tempo_events( binistream *f ) { int16 const num_tempo_events = f->readInt( 2 ); - mTempoEvents.reserve( num_tempo_events ); + mTempoEvents = new STempoEvent[num_tempo_events]; + memset (mTempoEvents, 0, sizeof (STempoEvent) * num_tempo_events); for(int i=0; i<num_tempo_events; ++i) { @@ -462,35 +467,36 @@ void CrolPlayer::load_tempo_events( binistream *f ) event.time = f->readInt( 2 ); event.multiplier = f->readFloat( binio::Single ); - mTempoEvents.push_back( event ); + mTempoEvents[n_tempo_events++] = event; } } //--------------------------------------------------------- -bool CrolPlayer::load_voice_data( binistream *f, std::string const &bnk_filename, const CFileProvider &fp ) +bool CrolPlayer::load_voice_data( binistream *f, const char *bnk_filename, const CFileProvider &fp ) { SBnkHeader bnk_header; - binistream *bnk_file = fp.open( bnk_filename.c_str() ); + memset (&bnk_header, 0, sizeof (bnk_header)); + binistream *bnk_file = fp.open( bnk_filename); if( bnk_file ) { load_bnk_info( bnk_file, bnk_header ); int const numVoices = rol_header->mode ? kNumMelodicVoices : kNumPercussiveVoices; + voice_data = new CVoiceData[numVoices]; - voice_data.reserve( numVoices ); for(int i=0; i<numVoices; ++i) { - CVoiceData voice; + CVoiceData &voice = voice_data[n_voice_data++]; load_note_events( f, voice ); load_instrument_events( f, voice, bnk_file, bnk_header ); load_volume_events( f, voice ); load_pitch_events( f, voice ); - voice_data.push_back( voice ); } fp.close(bnk_file); + delete[] bnk_header.ins_name_list; return true; } @@ -506,20 +512,17 @@ void CrolPlayer::load_note_events( binistream *f, CVoiceData &voice ) if( time_of_last_note != 0 ) { - TNoteEvents ¬e_events = voice.note_events; int16 total_duration = 0; do { - SNoteEvent event; + SNoteEvent &event = voice.note_events[voice.n_note_events++]; event.number = f->readInt( 2 ); event.duration = f->readInt( 2 ); event.number += kSilenceNote; // adding -12 - note_events.push_back( event ); - total_duration += event.duration; } while( total_duration < time_of_last_note ); @@ -536,22 +539,18 @@ void CrolPlayer::load_instrument_events( binistream *f, CVoiceData &voice, binistream *bnk_file, SBnkHeader const &bnk_header ) { int16 const number_of_instrument_events = f->readInt( 2 ); - - TInstrumentEvents &instrument_events = voice.instrument_events; - - instrument_events.reserve( number_of_instrument_events ); + voice.instrument_events = new SInstrumentEvent[number_of_instrument_events]; + memset (voice.instrument_events, 0, sizeof (SInstrumentEvent) * number_of_instrument_events); for(int i=0; i<number_of_instrument_events; ++i) { - SInstrumentEvent event; + SInstrumentEvent &event = voice.instrument_events[voice.n_instrument_events++]; event.time = f->readInt( 2 ); f->readString( event.name, 9 ); - std::string event_name = event.name; + const char * event_name = event.name; event.ins_index = load_rol_instrument( bnk_file, bnk_header, event_name ); - instrument_events.push_back( event ); - f->seek( 1+2, binio::Add ); } @@ -561,18 +560,14 @@ void CrolPlayer::load_instrument_events( binistream *f, CVoiceData &voice, void CrolPlayer::load_volume_events( binistream *f, CVoiceData &voice ) { int16 const number_of_volume_events = f->readInt( 2 ); - - TVolumeEvents &volume_events = voice.volume_events; - - volume_events.reserve( number_of_volume_events ); + voice.volume_events = new SVolumeEvent[number_of_volume_events]; + memset (voice.volume_events, 0, sizeof (SVolumeEvent) * number_of_volume_events); for(int i=0; i<number_of_volume_events; ++i) { - SVolumeEvent event; + SVolumeEvent &event = voice.volume_events[voice.n_volume_events++]; event.time = f->readInt( 2 ); event.multiplier = f->readFloat( binio::Single ); - - volume_events.push_back( event ); } f->seek( 15, binio::Add ); @@ -581,18 +576,14 @@ void CrolPlayer::load_volume_events( binistream *f, CVoiceData &voice ) void CrolPlayer::load_pitch_events( binistream *f, CVoiceData &voice ) { int16 const number_of_pitch_events = f->readInt( 2 ); - - TPitchEvents &pitch_events = voice.pitch_events; - - pitch_events.reserve( number_of_pitch_events ); + voice.pitch_events = new SPitchEvent[number_of_pitch_events]; + memset (voice.pitch_events, 0, sizeof (SPitchEvent) * number_of_pitch_events); for(int i=0; i<number_of_pitch_events; ++i) { - SPitchEvent event; + SPitchEvent &event = voice.pitch_events[voice.n_pitch_events++]; event.time = f->readInt( 2 ); event.variation = f->readFloat( binio::Single ); - - pitch_events.push_back( event ); } } //--------------------------------------------------------- @@ -610,31 +601,27 @@ bool CrolPlayer::load_bnk_info( binistream *f, SBnkHeader &header ) f->seek( header.abs_offset_of_name_list, binio::Set ); - TInstrumentNames &ins_name_list = header.ins_name_list; - ins_name_list.reserve( header.number_of_list_entries_used ); + header.ins_name_list = new SInstrumentName[header.number_of_list_entries_used]; + memset (header.ins_name_list, 0, sizeof (SInstrumentName) * header.number_of_list_entries_used); for(int i=0; i<header.number_of_list_entries_used; ++i) { - SInstrumentName instrument; + SInstrumentName &instrument = header.ins_name_list[header.n_ins_names++]; instrument.index = f->readInt( 2 ); instrument.record_used = f->readInt(1); f->readString( instrument.name, 9 ); - - // printf("%s = #%d\n", instrument.name, i ); - - ins_name_list.push_back( instrument ); } - //std::sort( ins_name_list.begin(), ins_name_list.end(), StringCompare() ); + // preallocate space for instruments + ins_list = new SUsedList[header.number_of_list_entries_used * 2]; + memset (ins_list, 0, sizeof (SUsedList) * header.number_of_list_entries_used * 2); return true; } //--------------------------------------------------------- -int CrolPlayer::load_rol_instrument( binistream *f, SBnkHeader const &header, std::string &name ) +int CrolPlayer::load_rol_instrument( binistream *f, SBnkHeader const &header, const char * name ) { - TInstrumentNames const &ins_name_list = header.ins_name_list; - int const ins_index = get_ins_index( name ); if( ins_index != -1 ) @@ -642,42 +629,41 @@ int CrolPlayer::load_rol_instrument( binistream *f, SBnkHeader const &header, st return ins_index; } - typedef TInstrumentNames::const_iterator TInsIter; - typedef std::pair<TInsIter, TInsIter> TInsIterPair; - - TInsIterPair range = std::equal_range( ins_name_list.begin(), - ins_name_list.end(), - name, - StringCompare() ); + if (n_used_ins >= header.n_ins_names * 2) { + AdPlug_LogWrite("*** CrolPlayer::load_rol_instrument out of memory***\n"); + return -1; + } - if( range.first != range.second ) - { - int const seekOffs = header.abs_offset_of_data + (range.first->index*kSizeofDataRecord); + // find instrument struct by name to get file pos + int ipos; + for (ipos = 0; ipos < header.n_ins_names; ipos++) { + if (!stricmp (name, header.ins_name_list[ipos].name)) { + break; + } + } + if (ipos < header.n_ins_names && ipos >= 0) { + int const seekOffs = header.abs_offset_of_data + (header.ins_name_list[ipos].index*kSizeofDataRecord); f->seek( seekOffs, binio::Set ); } - SUsedList usedIns; - usedIns.name = name; + SUsedList &usedIns = ins_list[n_used_ins++]; + usedIns.name = name; // no strdup, pointing to SInstrumentEvent name - if( range.first != range.second ) - { + if (ipos < header.n_ins_names && ipos >= 0) { read_rol_instrument( f, usedIns.instrument ); } - else - { + else { // set up default instrument data here memset( &usedIns.instrument, 0, sizeof(SRolInstrument) ); } - ins_list.push_back( usedIns ); - - return ins_list.size()-1; + return n_used_ins-1; } //--------------------------------------------------------- -int CrolPlayer::get_ins_index( std::string const &name ) const +int CrolPlayer::get_ins_index( const char * const &name ) const { - for(unsigned int i=0; i<ins_list.size(); ++i) + for(unsigned int i=0; i<n_used_ins; ++i) { - if( stricmp(ins_list[i].name.c_str(), name.c_str()) == 0 ) + if( stricmp(ins_list[i].name, name) == 0 ) { return i; } diff --git a/plugins/adplug/adplug/rol.h b/plugins/adplug/adplug/rol.h index 82337adf..a7f936b7 100644 --- a/plugins/adplug/adplug/rol.h +++ b/plugins/adplug/adplug/rol.h @@ -23,10 +23,6 @@ #ifndef H_ROLPLAYER #define H_ROLPLAYER -#include <vector> -#include <string> -#include <strings.h> - #include "player.h" class CrolPlayer: public CPlayer @@ -38,12 +34,12 @@ public: ~CrolPlayer(); - bool load (const std::string &filename, const CFileProvider &fp); + bool load (const char *filename, const CFileProvider &fp); bool update (); void rewind (int subsong); // rewinds to specified subsong float getrefresh(); // returns needed timer refresh rate - std::string gettype() { return std::string("Adlib Visual Composer"); } + const char * gettype() { return "Adlib Visual Composer"; } private: typedef unsigned short uint16; @@ -103,10 +99,9 @@ private: real32 variation; } SPitchEvent; - typedef std::vector<SNoteEvent> TNoteEvents; - typedef std::vector<SInstrumentEvent> TInstrumentEvents; - typedef std::vector<SVolumeEvent> TVolumeEvents; - typedef std::vector<SPitchEvent> TPitchEvents; + enum { + MAX_NOTE_EVENTS = 2000, + }; #define bit_pos( pos ) (1<<pos) @@ -132,7 +127,21 @@ private: ,next_instrument_event( 0 ) ,next_volume_event ( 0 ) ,next_pitch_event ( 0 ) + ,n_note_events (0) + ,n_instrument_events(0) + ,n_volume_events(0) + ,n_pitch_events(0) { + memset (note_events, 0, sizeof (note_events)); + instrument_events = 0; + volume_events = 0; + pitch_events = 0; + } + + ~CVoiceData () { + delete[] instrument_events; + delete[] volume_events; + delete[] pitch_events; } void Reset() @@ -147,10 +156,14 @@ private: next_pitch_event = 0; } - TNoteEvents note_events; - TInstrumentEvents instrument_events; - TVolumeEvents volume_events; - TPitchEvents pitch_events; + SNoteEvent note_events[MAX_NOTE_EVENTS]; + int n_note_events; + SInstrumentEvent *instrument_events; + int n_instrument_events; + SVolumeEvent *volume_events; + int n_volume_events; + SPitchEvent *pitch_events; + int n_pitch_events; bool mForceNote : 1; int mEventStatus; @@ -169,8 +182,6 @@ private: char name[9]; } SInstrumentName; - typedef std::vector<SInstrumentName> TInstrumentNames; - typedef struct { char version_major; @@ -181,7 +192,8 @@ private: int32 abs_offset_of_name_list; int32 abs_offset_of_data; - TInstrumentNames ins_name_list; + SInstrumentName *ins_name_list; + int n_ins_names; } SBnkHeader; typedef struct @@ -221,12 +233,12 @@ private: typedef struct { - std::string name; + const char * name; SRolInstrument instrument; } SUsedList; void load_tempo_events ( binistream *f ); - bool load_voice_data ( binistream *f, std::string const &bnk_filename, const CFileProvider &fp ); + bool load_voice_data ( binistream *f, const char *bnk_filename, const CFileProvider &fp ); void load_note_events ( binistream *f, CVoiceData &voice ); void load_instrument_events( binistream *f, CVoiceData &voice, binistream *bnk_file, SBnkHeader const &bnk_header ); @@ -234,10 +246,10 @@ private: void load_pitch_events ( binistream *f, CVoiceData &voice ); bool load_bnk_info ( binistream *f, SBnkHeader &header ); - int load_rol_instrument ( binistream *f, SBnkHeader const &header, std::string &name ); + int load_rol_instrument ( binistream *f, SBnkHeader const &header, const char *name ); void read_rol_instrument ( binistream *f, SRolInstrument &ins ); void read_fm_operator ( binistream *f, SOPL2Op &opl2_op ); - int get_ins_index( std::string const &name ) const; + int get_ins_index( const char * const &name ) const; void UpdateVoice( int const voice, CVoiceData &voiceData ); void SetNote( int const voice, int const note ); @@ -250,36 +262,13 @@ private: void send_ins_data_to_chip( int const voice, int const ins_index ); void send_operator( int const voice, SOPL2Op const &modulator, SOPL2Op const &carrier ); - class StringCompare - { - public: - bool operator()( SInstrumentName const &lhs, SInstrumentName const &rhs ) const - { - return keyLess(lhs.name, rhs.name); - } - - bool operator()( SInstrumentName const &lhs, std::string const &rhs ) const - { - return keyLess(lhs.name, rhs.c_str()); - } - - bool operator()( std::string const &lhs, SInstrumentName const &rhs ) const - { - return keyLess(lhs.c_str(), rhs.name); - } - private: - bool keyLess( const char *const lhs, const char *const rhs ) const - { - return stricmp(lhs, rhs) < 0; - } - }; - - typedef std::vector<CVoiceData> TVoiceData; - SRolHeader *rol_header; - std::vector<STempoEvent> mTempoEvents; - TVoiceData voice_data; - std::vector<SUsedList> ins_list; + STempoEvent *mTempoEvents; + int n_tempo_events; + CVoiceData *voice_data; + int n_voice_data; + SUsedList *ins_list; + int n_used_ins; unsigned int mNextTempoEvent; int mCurrTick; diff --git a/plugins/adplug/adplug/s3m.cpp b/plugins/adplug/adplug/s3m.cpp index ff0baa35..173a7563 100644 --- a/plugins/adplug/adplug/s3m.cpp +++ b/plugins/adplug/adplug/s3m.cpp @@ -22,7 +22,8 @@ * Extra Fine Slides (EEx, FEx) & Fine Vibrato (Uxy) are inaccurate */ -#include <cstring> +#include <stdio.h> +#include <string.h> #include "s3m.h" const char Cs3mPlayer::chnresolv[] = // S3M -> adlib channel conversion @@ -56,97 +57,109 @@ Cs3mPlayer::Cs3mPlayer(Copl *newopl): CPlayer(newopl) } } -bool Cs3mPlayer::load(const std::string &filename, const CFileProvider &fp) +bool Cs3mPlayer::load(const char *filename, const CFileProvider &fp) { - binistream *f = fp.open(filename); if(!f) return false; - unsigned short insptr[99],pattptr[99]; - int i,row; - unsigned char bufval,bufval2; - unsigned short ppatlen; - s3mheader *checkhead; - bool adlibins=false; - - // file validation section - checkhead = new s3mheader; - load_header(f, checkhead); - if(checkhead->kennung != 0x1a || checkhead->typ != 16 - || checkhead->insnum > 99) { - delete checkhead; fp.close(f); return false; - } else - if(strncmp(checkhead->scrm,"SCRM",4)) { - delete checkhead; fp.close(f); return false; - } else { // is an adlib module? - f->seek(checkhead->ordnum, binio::Add); - for(i = 0; i < checkhead->insnum; i++) - insptr[i] = f->readInt(2); - for(i=0;i<checkhead->insnum;i++) { - f->seek(insptr[i]*16); - if(f->readInt(1) >= 2) { - adlibins = true; - break; - } - } - delete checkhead; - if(!adlibins) { fp.close(f); return false; } + binistream *f = fp.open(filename); + if(!f) { + return false; + } + unsigned short insptr[99],pattptr[99]; + int i,row; + unsigned char bufval,bufval2; + unsigned short ppatlen; + s3mheader *checkhead; + bool adlibins=false; + + // file validation section + checkhead = new s3mheader; + load_header(f, checkhead); + if(checkhead->kennung != 0x1a || checkhead->typ != 16 + || checkhead->insnum > 99) { + delete checkhead; + fp.close(f); + return false; + } else + if(strncmp(checkhead->scrm,"SCRM",4)) { + delete checkhead; + fp.close(f); + return false; + } else { // is an adlib module? + f->seek(checkhead->ordnum, binio::Add); + for(i = 0; i < checkhead->insnum; i++) { + insptr[i] = f->readInt(2); + } + for(i=0;i<checkhead->insnum;i++) { + f->seek(insptr[i]*16); + int n = f->readInt(1); + if(n >= 2) { + adlibins = true; + break; + } + } + delete checkhead; + if(!adlibins) { + fp.close(f); + return false; + } + } + + // load section + f->seek(0); // rewind for load + load_header(f, &header); // read header + + // security check + if(header.ordnum > 256 || header.insnum > 99 || header.patnum > 99) { + fp.close(f); + return false; } - // load section - f->seek(0); // rewind for load - load_header(f, &header); // read header - - // security check - if(header.ordnum > 256 || header.insnum > 99 || header.patnum > 99) { - fp.close(f); - return false; - } - - for(i = 0; i < header.ordnum; i++) orders[i] = f->readInt(1); // read orders - for(i = 0; i < header.insnum; i++) insptr[i] = f->readInt(2); // instrument parapointers - for(i = 0; i < header.patnum; i++) pattptr[i] = f->readInt(2); // pattern parapointers - - for(i=0;i<header.insnum;i++) { // load instruments - f->seek(insptr[i]*16); - inst[i].type = f->readInt(1); - f->readString(inst[i].filename, 15); - inst[i].d00 = f->readInt(1); inst[i].d01 = f->readInt(1); - inst[i].d02 = f->readInt(1); inst[i].d03 = f->readInt(1); - inst[i].d04 = f->readInt(1); inst[i].d05 = f->readInt(1); - inst[i].d06 = f->readInt(1); inst[i].d07 = f->readInt(1); - inst[i].d08 = f->readInt(1); inst[i].d09 = f->readInt(1); - inst[i].d0a = f->readInt(1); inst[i].d0b = f->readInt(1); - inst[i].volume = f->readInt(1); inst[i].dsk = f->readInt(1); - f->ignore(2); - inst[i].c2spd = f->readInt(4); - f->ignore(12); - f->readString(inst[i].name, 28); - f->readString(inst[i].scri, 4); - } + for(i = 0; i < header.ordnum; i++) orders[i] = f->readInt(1); // read orders + for(i = 0; i < header.insnum; i++) insptr[i] = f->readInt(2); // instrument parapointers + for(i = 0; i < header.patnum; i++) pattptr[i] = f->readInt(2); // pattern parapointers + + for(i=0;i<header.insnum;i++) { // load instruments + f->seek(insptr[i]*16); + inst[i].type = f->readInt(1); + f->readString(inst[i].filename, 15); + inst[i].d00 = f->readInt(1); inst[i].d01 = f->readInt(1); + inst[i].d02 = f->readInt(1); inst[i].d03 = f->readInt(1); + inst[i].d04 = f->readInt(1); inst[i].d05 = f->readInt(1); + inst[i].d06 = f->readInt(1); inst[i].d07 = f->readInt(1); + inst[i].d08 = f->readInt(1); inst[i].d09 = f->readInt(1); + inst[i].d0a = f->readInt(1); inst[i].d0b = f->readInt(1); + inst[i].volume = f->readInt(1); inst[i].dsk = f->readInt(1); + f->ignore(2); + inst[i].c2spd = f->readInt(4); + f->ignore(12); + f->readString(inst[i].name, 28); + f->readString(inst[i].scri, 4); + } - for(i=0;i<header.patnum;i++) { // depack patterns - f->seek(pattptr[i]*16); - ppatlen = f->readInt(2); - unsigned long pattpos = f->pos(); - for(row=0;(row<64) && (pattpos-pattptr[i]*16<=ppatlen);row++) - do { - bufval = f->readInt(1); - if(bufval & 32) { - bufval2 = f->readInt(1); - pattern[i][row][bufval & 31].note = bufval2 & 15; - pattern[i][row][bufval & 31].oct = (bufval2 & 240) >> 4; - pattern[i][row][bufval & 31].instrument = f->readInt(1); - } - if(bufval & 64) - pattern[i][row][bufval & 31].volume = f->readInt(1); - if(bufval & 128) { - pattern[i][row][bufval & 31].command = f->readInt(1); - pattern[i][row][bufval & 31].info = f->readInt(1); - } - } while(bufval); - } + for(i=0;i<header.patnum;i++) { // depack patterns + f->seek(pattptr[i]*16); + ppatlen = f->readInt(2); + unsigned long pattpos = f->pos(); + for(row=0;(row<64) && (pattpos-pattptr[i]*16<=ppatlen);row++) + do { + bufval = f->readInt(1); + if(bufval & 32) { + bufval2 = f->readInt(1); + pattern[i][row][bufval & 31].note = bufval2 & 15; + pattern[i][row][bufval & 31].oct = (bufval2 & 240) >> 4; + pattern[i][row][bufval & 31].instrument = f->readInt(1); + } + if(bufval & 64) + pattern[i][row][bufval & 31].volume = f->readInt(1); + if(bufval & 128) { + pattern[i][row][bufval & 31].command = f->readInt(1); + pattern[i][row][bufval & 31].info = f->readInt(1); + } + } while(bufval); + } - fp.close(f); - rewind(0); - return true; // done + fp.close(f); + rewind(0); + return true; // done } bool Cs3mPlayer::update() @@ -404,7 +417,7 @@ void Cs3mPlayer::rewind(int subsong) opl->write(1,32); // Go to ym3812 mode } -std::string Cs3mPlayer::gettype() +const char * Cs3mPlayer::gettype() { char filever[5]; @@ -416,7 +429,8 @@ std::string Cs3mPlayer::gettype() default: strcpy(filever,"3.??"); } - return (std::string("Scream Tracker ") + filever); + snprintf (filetype, sizeof (filetype), "Scream Tracker %s", filever); + return filetype; } float Cs3mPlayer::getrefresh() diff --git a/plugins/adplug/adplug/s3m.h b/plugins/adplug/adplug/s3m.h index aefc492e..cf58c44b 100644 --- a/plugins/adplug/adplug/s3m.h +++ b/plugins/adplug/adplug/s3m.h @@ -31,14 +31,14 @@ class Cs3mPlayer: public CPlayer Cs3mPlayer(Copl *newopl); - bool load(const std::string &filename, const CFileProvider &fp); + bool load(const char *filename, const CFileProvider &fp); bool update(); void rewind(int subsong); float getrefresh(); - std::string gettype(); - std::string gettitle() - { return std::string(header.name); }; + const char * gettype(); + const char * gettitle() + { return header.name; }; unsigned int getpatterns() { return header.patnum; }; @@ -54,8 +54,8 @@ class Cs3mPlayer: public CPlayer { return speed; }; unsigned int getinstruments() { return header.insnum; }; - std::string getinstrument(unsigned int n) - { return std::string(inst[n].name); }; + const char * getinstrument(unsigned int n) + { return inst[n].name; }; protected: struct s3mheader { @@ -89,6 +89,8 @@ class Cs3mPlayer: public CPlayer unsigned char orders[256]; unsigned char crow,ord,speed,tempo,del,songend,loopstart,loopcnt; + char filetype[30]; + private: static const char chnresolv[]; static const unsigned short notetable[12]; diff --git a/plugins/adplug/adplug/sa2.cpp b/plugins/adplug/adplug/sa2.cpp index 8d81e9c1..bdf1b22c 100644 --- a/plugins/adplug/adplug/sa2.cpp +++ b/plugins/adplug/adplug/sa2.cpp @@ -20,7 +20,6 @@ * SAdT Loader by Mamiya <mamiya@users.sourceforge.net> */ -#include <cstring> #include <stdio.h> #include <string.h> @@ -32,7 +31,7 @@ CPlayer *Csa2Loader::factory(Copl *newopl) return new Csa2Loader(newopl); } -bool Csa2Loader::load(const std::string &filename, const CFileProvider &fp) +bool Csa2Loader::load(const char *filename, const CFileProvider &fp) { binistream *f = fp.open(filename); if(!f) return false; struct { @@ -161,7 +160,7 @@ bool Csa2Loader::load(const std::string &filename, const CFileProvider &fp) AdPlug_LogWrite("Csa2Loader::load(\"%s\"): sat_type = %x, nop = %d, " "length = %d, restartpos = %d, activechan = %x, bpm = %d\n", - filename.c_str(), sat_type, nop, length, restartpos, activechan, bpm); + filename, sat_type, nop, length, restartpos, activechan, bpm); // track data if(sat_type & HAS_OLDPATTERNS) { @@ -227,15 +226,13 @@ bool Csa2Loader::load(const std::string &filename, const CFileProvider &fp) return true; } -std::string Csa2Loader::gettype() +const char * Csa2Loader::gettype() { - char tmpstr[40]; - - sprintf(tmpstr,"Surprise! Adlib Tracker 2 (version %d)",header.version); - return std::string(tmpstr); + snprintf(filetype,sizeof(filetype),"Surprise! Adlib Tracker 2 (version %d)",header.version); + return filetype; } -std::string Csa2Loader::gettitle() +const char * Csa2Loader::gettitle() { char bufinst[29*17],buf[18]; int i,ptr; @@ -256,8 +253,12 @@ std::string Csa2Loader::gettitle() strcat(bufinst,buf); } - if(strchr(bufinst,'"')) - return std::string(bufinst,strchr(bufinst,'"')-bufinst+1,strrchr(bufinst,'"')-strchr(bufinst,'"')-1); - else - return std::string(); + if(strchr(bufinst,'"')) { + const char *pos = strchr(bufinst,'"')+1; + int len = strrchr(bufinst,'"')-pos; + memcpy (title,pos,len); + title[len] = 0; + return title; + } + return ""; } diff --git a/plugins/adplug/adplug/sa2.h b/plugins/adplug/adplug/sa2.h index ed904f0d..369d7730 100644 --- a/plugins/adplug/adplug/sa2.h +++ b/plugins/adplug/adplug/sa2.h @@ -31,18 +31,18 @@ public: : CmodPlayer(newopl) { } - bool load(const std::string &filename, const CFileProvider &fp); + bool load(const char *filename, const CFileProvider &fp); - std::string gettype(); - std::string gettitle(); + const char * gettype(); + const char * gettitle(); unsigned int getinstruments() { return 31; } - std::string getinstrument(unsigned int n) + const char * getinstrument(unsigned int n) { if(n < 29) - return std::string(instname[n],1,16); + return instname[n]; else - return std::string("-broken-"); + return "-broken-"; } private: @@ -52,4 +52,6 @@ private: } header; char instname[29][17]; + char filetype[40]; + char title[200]; }; diff --git a/plugins/adplug/adplug/sng.cpp b/plugins/adplug/adplug/sng.cpp index 5e8b6af4..02afb60b 100644 --- a/plugins/adplug/adplug/sng.cpp +++ b/plugins/adplug/adplug/sng.cpp @@ -19,7 +19,7 @@ * sng.cpp - SNG Player by Simon Peter <dn.tlp@gmx.net> */ -#include <cstring> +#include <string.h> #include "sng.h" CPlayer *CsngPlayer::factory(Copl *newopl) @@ -27,7 +27,7 @@ CPlayer *CsngPlayer::factory(Copl *newopl) return new CsngPlayer(newopl); } -bool CsngPlayer::load(const std::string &filename, const CFileProvider &fp) +bool CsngPlayer::load(const char *filename, const CFileProvider &fp) { binistream *f = fp.open(filename); if(!f) return false; int i; diff --git a/plugins/adplug/adplug/sng.h b/plugins/adplug/adplug/sng.h index 6eef98de..e144e60b 100644 --- a/plugins/adplug/adplug/sng.h +++ b/plugins/adplug/adplug/sng.h @@ -35,14 +35,14 @@ public: ~CsngPlayer() { if(data) delete [] data; }; - bool load(const std::string &filename, const CFileProvider &fp); + bool load(const char *filename, const CFileProvider &fp); bool update(); void rewind(int subsong); float getrefresh() { return 70.0f; }; - std::string gettype() - { return std::string("SNG File Format"); }; + const char * gettype() + { return "SNG File Format"; }; protected: struct { diff --git a/plugins/adplug/adplug/u6m.cpp b/plugins/adplug/adplug/u6m.cpp index d34f6fc2..565d0820 100644 --- a/plugins/adplug/adplug/u6m.cpp +++ b/plugins/adplug/adplug/u6m.cpp @@ -34,7 +34,7 @@ CPlayer *Cu6mPlayer::factory(Copl *newopl) return new Cu6mPlayer(newopl); } -bool Cu6mPlayer::load(const std::string &filename, const CFileProvider &fp) +bool Cu6mPlayer::load(const char *filename, const CFileProvider &fp) { // file validation section // this section only checks a few *necessary* conditions @@ -178,8 +178,7 @@ void Cu6mPlayer::rewind(int subsong) carrier_mf_mod_delay[i] = 0; } - while (!subsong_stack.empty()) // empty subsong stack - subsong_stack.pop(); + subsong_stack_sz = 0; opl->init(); out_adlib(1,32); // go to OPL2 mode @@ -201,6 +200,8 @@ float Cu6mPlayer::getrefresh() // ============================================================================================ +#define ROOT_STACK_SIZE 200 + // decompress from memory to memory bool Cu6mPlayer::lzw_decompress(Cu6mPlayer::data_block source, Cu6mPlayer::data_block dest) { @@ -210,7 +211,11 @@ bool Cu6mPlayer::lzw_decompress(Cu6mPlayer::data_block source, Cu6mPlayer::data_ int next_free_codeword = 0x102; int dictionary_size = 0x200; MyDict dictionary = MyDict(); - std::stack<unsigned char> root_stack; + + unsigned char root_stack[ROOT_STACK_SIZE]; + int root_stack_size = 0; + +// std::stack<unsigned char> root_stack; long bytes_written = 0; @@ -241,13 +246,13 @@ bool Cu6mPlayer::lzw_decompress(Cu6mPlayer::data_block source, Cu6mPlayer::data_ if (cW < next_free_codeword) // codeword is already in the dictionary { // create the string associated with cW (on the stack) - get_string(cW,dictionary,root_stack); - C = root_stack.top(); + get_string(cW,dictionary,root_stack,root_stack_size); + C = root_stack[root_stack_size-1]; // output the string represented by cW - while (!root_stack.empty()) + while (root_stack_size>0) { - SAVE_OUTPUT_ROOT(root_stack.top(), dest, bytes_written); - root_stack.pop(); + SAVE_OUTPUT_ROOT(root_stack[root_stack_size-1], dest, bytes_written); + root_stack_size--; } // add pW+C to the dictionary dictionary.add(C,pW); @@ -265,13 +270,13 @@ bool Cu6mPlayer::lzw_decompress(Cu6mPlayer::data_block source, Cu6mPlayer::data_ else // codeword is not yet defined { // create the string associated with pW (on the stack) - get_string(pW,dictionary,root_stack); - C = root_stack.top(); + get_string(pW,dictionary,root_stack,root_stack_size); + C = root_stack[root_stack_size-1]; // output the string represented by pW - while (!root_stack.empty()) + while (root_stack_size>0) { - SAVE_OUTPUT_ROOT(root_stack.top(), dest, bytes_written); - root_stack.pop(); + SAVE_OUTPUT_ROOT(root_stack[root_stack_size-1], dest, bytes_written); + root_stack_size--; } // output the char C SAVE_OUTPUT_ROOT(C, dest, bytes_written); @@ -357,7 +362,8 @@ void Cu6mPlayer::output_root(unsigned char root, unsigned char *destination, lon // output the string represented by a codeword -void Cu6mPlayer::get_string(int codeword, Cu6mPlayer::MyDict& dictionary, std::stack<unsigned char>& root_stack) +//void Cu6mPlayer::get_string(int codeword, Cu6mPlayer::MyDict& dictionary, std::stack<unsigned char>& root_stack) +void Cu6mPlayer::get_string(int codeword, Cu6mPlayer::MyDict& dictionary, unsigned char *root_stack, int &root_stack_size) { unsigned char root; int current_codeword; @@ -368,11 +374,11 @@ void Cu6mPlayer::get_string(int codeword, Cu6mPlayer::MyDict& dictionary, std::s { root = dictionary.get_root(current_codeword); current_codeword = dictionary.get_codeword(current_codeword); - root_stack.push(root); + root_stack[root_stack_size++]=root; } // push the root at the leaf - root_stack.push((unsigned char)current_codeword); + root_stack[root_stack_size++]= (unsigned char)current_codeword; } @@ -583,7 +589,7 @@ void Cu6mPlayer::command_81() new_ss_info.subsong_start = read_song_byte(); new_ss_info.subsong_start += read_song_byte() << 8; new_ss_info.continue_pos = song_pos; - subsong_stack.push(new_ss_info); + subsong_stack[subsong_stack_sz++] = new_ss_info; song_pos = new_ss_info.subsong_start; } @@ -662,10 +668,10 @@ void Cu6mPlayer::command_E() // --------------------------- void Cu6mPlayer::command_F() { - if (!subsong_stack.empty()) + if (subsong_stack_sz) { - subsong_info temp = subsong_stack.top(); - subsong_stack.pop(); + subsong_info temp = subsong_stack[subsong_stack_sz-1]; + subsong_stack_sz--; temp.subsong_repetitions--; if (temp.subsong_repetitions==0) { @@ -674,7 +680,7 @@ void Cu6mPlayer::command_F() else { song_pos = temp.subsong_start; - subsong_stack.push(temp); + subsong_stack[subsong_stack_sz++] = temp; } } else diff --git a/plugins/adplug/adplug/u6m.h b/plugins/adplug/adplug/u6m.h index 30e7f3b5..f09d0211 100644 --- a/plugins/adplug/adplug/u6m.h +++ b/plugins/adplug/adplug/u6m.h @@ -20,8 +20,7 @@ * This code extends the Adlib Winamp plug-in by Simon Peter <dn.tlp@gmx.net> */ -#include <stack> - +#include <string.h> #include "player.h" #define default_dict_size 4096 // because maximum codeword size == 12 bits @@ -32,7 +31,7 @@ class Cu6mPlayer: public CPlayer public: static CPlayer *factory(Copl *newopl); - Cu6mPlayer(Copl *newopl) : CPlayer(newopl), song_data(0) + Cu6mPlayer(Copl *newopl) : CPlayer(newopl), song_data(0), subsong_stack_sz(0) { }; @@ -42,14 +41,14 @@ class Cu6mPlayer: public CPlayer if(song_data) delete[] song_data; }; - bool load(const std::string &filename, const CFileProvider &fp); + bool load(const char *filename, const CFileProvider &fp); bool update(); void rewind(int subsong); float getrefresh(); - std::string gettype() + const char * gettype() { - return std::string("Ultima 6 Music"); + return "Ultima 6 Music"; }; protected: @@ -109,7 +108,9 @@ class Cu6mPlayer: public CPlayer int song_pos; // current offset within the song int loop_position; // position of the loop point int read_delay; // delay (in timer ticks) before further song data is read - std::stack<subsong_info> subsong_stack; + enum {MAX_SUBSONG_STACK = 100}; + subsong_info subsong_stack[MAX_SUBSONG_STACK]; + int subsong_stack_sz; int instrument_offsets[9]; // offsets of the adlib instrument data // vibrato ("vb") @@ -163,6 +164,7 @@ class Cu6mPlayer: public CPlayer bool lzw_decompress(data_block source, data_block dest); int get_next_codeword (long& bits_read, unsigned char *source, int codeword_size); void output_root(unsigned char root, unsigned char *destination, long& position); - void get_string(int codeword, MyDict& dictionary, std::stack<unsigned char>& root_stack); + //void get_string(int codeword, MyDict& dictionary, std::stack<unsigned char>& root_stack); + void get_string(int codeword, MyDict& dictionary, unsigned char *root_stack, int &root_stack_size); }; diff --git a/plugins/adplug/adplug/xad.cpp b/plugins/adplug/adplug/xad.cpp index 81c7c0a7..6b4f2cbf 100644 --- a/plugins/adplug/adplug/xad.cpp +++ b/plugins/adplug/adplug/xad.cpp @@ -35,7 +35,7 @@ CxadPlayer::~CxadPlayer() delete [] tune; } -bool CxadPlayer::load(const std::string &filename, const CFileProvider &fp) +bool CxadPlayer::load(const char *filename, const CFileProvider &fp) { binistream *f = fp.open(filename); if(!f) return false; bool ret = false; @@ -103,22 +103,22 @@ float CxadPlayer::getrefresh() return xadplayer_getrefresh(); } -std::string CxadPlayer::gettype() +const char * CxadPlayer::gettype() { return xadplayer_gettype(); } -std::string CxadPlayer::gettitle() +const char * CxadPlayer::gettitle() { return xadplayer_gettitle(); } -std::string CxadPlayer::getauthor() +const char * CxadPlayer::getauthor() { return xadplayer_getauthor(); } -std::string CxadPlayer::getinstrument(unsigned int i) +const char * CxadPlayer::getinstrument(unsigned int i) { return xadplayer_getinstrument(i); } diff --git a/plugins/adplug/adplug/xad.h b/plugins/adplug/adplug/xad.h index 16872558..8a999b5e 100644 --- a/plugins/adplug/adplug/xad.h +++ b/plugins/adplug/adplug/xad.h @@ -32,15 +32,15 @@ public: CxadPlayer(Copl * newopl); ~CxadPlayer(); - bool load(const std::string &filename, const CFileProvider &fp); + bool load(const char *filename, const CFileProvider &fp); bool update(); void rewind(int subsong); float getrefresh(); - std::string gettype(); - std::string gettitle(); - std::string getauthor(); - std::string getinstrument(unsigned int i); + const char * gettype(); + const char * gettitle(); + const char * getauthor(); + const char * getinstrument(unsigned int i); unsigned int getinstruments(); protected: @@ -48,18 +48,18 @@ protected: virtual bool xadplayer_load() = 0; virtual void xadplayer_update() = 0; virtual float xadplayer_getrefresh() = 0; - virtual std::string xadplayer_gettype() = 0; - virtual std::string xadplayer_gettitle() + virtual const char * xadplayer_gettype() = 0; + virtual const char * xadplayer_gettitle() { - return std::string(xad.title); + return xad.title; } - virtual std::string xadplayer_getauthor() + virtual const char *xadplayer_getauthor() { - return std::string(xad.author); + return xad.author; } - virtual std::string xadplayer_getinstrument(unsigned int i) + virtual const char *xadplayer_getinstrument(unsigned int i) { - return std::string(""); + return ""; } virtual unsigned int xadplayer_getinstruments() { diff --git a/plugins/adplug/adplug/xsm.cpp b/plugins/adplug/adplug/xsm.cpp index 3c97de04..016add11 100644 --- a/plugins/adplug/adplug/xsm.cpp +++ b/plugins/adplug/adplug/xsm.cpp @@ -33,7 +33,7 @@ CxsmPlayer::~CxsmPlayer() if(music) delete [] music; } -bool CxsmPlayer::load(const std::string &filename, const CFileProvider &fp) +bool CxsmPlayer::load(const char *filename, const CFileProvider &fp) { binistream *f = fp.open(filename); if(!f) return false; char id[6]; diff --git a/plugins/adplug/adplug/xsm.h b/plugins/adplug/adplug/xsm.h index 0e844afc..2ea118f5 100644 --- a/plugins/adplug/adplug/xsm.h +++ b/plugins/adplug/adplug/xsm.h @@ -29,12 +29,12 @@ public: CxsmPlayer(Copl *newopl); ~CxsmPlayer(); - bool load(const std::string &filename, const CFileProvider &fp); + bool load(const char *filename, const CFileProvider &fp); bool update(); void rewind(int subsong); float getrefresh(); - std::string gettype() { return std::string("eXtra Simple Music"); } + const char * gettype() { return "eXtra Simple Music"; } private: unsigned short songlen; diff --git a/plugins/adplug/libbinio/binio.h b/plugins/adplug/libbinio/binio.h index 31bcfac6..b527f023 100644 --- a/plugins/adplug/libbinio/binio.h +++ b/plugins/adplug/libbinio/binio.h @@ -26,13 +26,13 @@ // // Set to 1 to build std::string supporting methods. You need the STL to // do this. -#define BINIO_ENABLE_STRING 1 +#define BINIO_ENABLE_STRING 0 // BINIO_ENABLE_IOSTREAM - Build iostream wrapper classes // // Set to 1 to build the iostream wrapper classes. You need the standard // C++ library to do this. -#define BINIO_ENABLE_IOSTREAM 1 +#define BINIO_ENABLE_IOSTREAM 0 // BINIO_ISO_STDLIB - Build with ISO C++ standard library compliance // |