changeset 703:cae46214b8bf trunk

[svn] - rework AdPlug to use VFS properly see http://sacredspiral.co.uk/~nenolod/adplug-vfs-ng.diff for a diff.
author nenolod
date Fri, 23 Feb 2007 20:23:34 -0800
parents d25b51e90542
children 94b22cc75eb8
files ChangeLog src/adplug/adplug-xmms.cc src/adplug/core/README.audacious src/adplug/core/a2m.cxx src/adplug/core/a2m.h src/adplug/core/adl.cxx src/adplug/core/adl.h src/adplug/core/adplug.cxx src/adplug/core/adplug.h src/adplug/core/adtrack.cxx src/adplug/core/adtrack.h src/adplug/core/amd.cxx src/adplug/core/amd.h src/adplug/core/bam.cxx src/adplug/core/bam.h src/adplug/core/binio_virtual.h src/adplug/core/cff.cxx src/adplug/core/cff.h src/adplug/core/d00.cxx src/adplug/core/d00.h src/adplug/core/dfm.cxx src/adplug/core/dfm.h src/adplug/core/dmo.cxx src/adplug/core/dmo.h src/adplug/core/dro.cxx src/adplug/core/dro.h src/adplug/core/dtm.cxx src/adplug/core/dtm.h src/adplug/core/fmc.cxx src/adplug/core/fmc.h src/adplug/core/fprovide.cxx src/adplug/core/fprovide.h src/adplug/core/hsc.cxx src/adplug/core/hsc.h src/adplug/core/hsp.cxx src/adplug/core/hsp.h src/adplug/core/imf.cxx src/adplug/core/imf.h src/adplug/core/ksm.cxx src/adplug/core/ksm.h src/adplug/core/lds.cxx src/adplug/core/lds.h src/adplug/core/mad.cxx src/adplug/core/mad.h src/adplug/core/mid.cxx src/adplug/core/mid.h src/adplug/core/mkj.cxx src/adplug/core/mkj.h src/adplug/core/msc.cxx src/adplug/core/msc.h src/adplug/core/mtk.cxx src/adplug/core/mtk.h src/adplug/core/player.h src/adplug/core/rad.cxx src/adplug/core/rad.h src/adplug/core/raw.cxx src/adplug/core/raw.h src/adplug/core/rix.cxx src/adplug/core/rix.h src/adplug/core/rol.cxx src/adplug/core/rol.h src/adplug/core/s3m.cxx src/adplug/core/s3m.h src/adplug/core/sa2.cxx src/adplug/core/sa2.h src/adplug/core/sng.cxx src/adplug/core/sng.h src/adplug/core/u6m.cxx src/adplug/core/u6m.h src/adplug/core/xad.cxx src/adplug/core/xad.h src/adplug/core/xsm.cxx src/adplug/core/xsm.h
diffstat 73 files changed, 218 insertions(+), 139 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Thu Feb 22 07:19:39 2007 -0800
+++ b/ChangeLog	Fri Feb 23 20:23:34 2007 -0800
@@ -1,3 +1,11 @@
+2007-02-22 15:19:39 +0000  William Pitcock <nenolod@sacredspiral.co.uk>
+  revision [1490]
+  - remove %expect 37
+  
+  trunk/src/rovascope/libcalc/parser.y |    3 ---
+  1 file changed, 3 deletions(-)
+
+
 2007-02-21 12:41:29 +0000  Yoshiki Yazawa <yaz@cc.rim.or.jp>
   revision [1488]
   - remove workaround.
--- a/src/adplug/adplug-xmms.cc	Thu Feb 22 07:19:39 2007 -0800
+++ b/src/adplug/adplug-xmms.cc	Fri Feb 23 20:23:34 2007 -0800
@@ -88,6 +88,9 @@
 
 static InputPlayback *playback;
 
+// XXX: this function is not in the public API yet.
+extern "C" VFSFile *vfs_buffered_file_new_from_uri(gchar *uri);
+
 /***** Debugging *****/
 
 #ifdef DEBUG
@@ -396,12 +399,12 @@
   g_free(rowstr[0]); g_free(rowstr[1]);
 }
 
-static CPlayer *factory(const std::string &filename, Copl *newopl)
+static CPlayer *factory(VFSFile *fd, Copl *newopl)
 {
   CPlayers::const_iterator	i;
 
-  dbg_printf("factory(\"%s\",opl): ", filename.c_str());
-  return CAdPlug::factory(filename, newopl, cfg.players);
+  dbg_printf("factory(%p<%s>,opl): ", fd, fd->uri != NULL ? fd->uri : "unknown");
+  return CAdPlug::factory(fd, newopl, cfg.players);
 }
 
 static void adplug_stop(InputPlayback *data);
@@ -429,8 +432,12 @@
 static void adplug_info_box(char *filename)
 {
   CSilentopl tmpopl;
+  VFSFile *fd = vfs_buffered_file_new_from_uri(filename);
+
+  if (!fd) return;
+
   CPlayer *p = (strcmp(filename, plr.filename) || !plr.p) ?
-    factory(filename, &tmpopl) : plr.p;
+    factory(fd, &tmpopl) : plr.p;
 
   if(!p) return; // bail out if no player could be created
   if(p == plr.p && plr.infodlg) return; // only one info box for active song
@@ -592,7 +599,7 @@
 /* Main playback thread. Takes the filename to play as argument. */
 {
   InputPlayback *playback = (InputPlayback *) data;
-  char *filename = (char *) playback->data;
+  char *filename = (char *) playback->filename;
   dbg_printf("play_loop(\"%s\"): ", filename);
   CEmuopl opl(cfg.freq, cfg.bit16, cfg.stereo);
   long toadd = 0, i, towrite;
@@ -602,9 +609,16 @@
     stereo = cfg.stereo;	// the user changes it while we're playing.
   unsigned long freq = cfg.freq;
 
+  // we use VfsBufferedFile class here because adplug does a lot of
+  // probing. a short delay before probing begins is better than
+  // a lot of delay during probing.
+  VFSFile *fd = vfs_buffered_file_new_from_uri(playback->filename);
+
+  if (!fd) { plr.playing = false; g_thread_exit(NULL); }
+
   // Try to load module
   dbg_printf("factory, ");
-  if(!(plr.p = factory(filename, &opl))) {
+  if(!(plr.p = factory(fd, &opl))) {
     dbg_printf("error!\n");
    // MessageBox("AdPlug :: Error", "File could not be opened!", "Ok");
     plr.playing = false;
@@ -703,6 +717,7 @@
   free(sndbuf);
   plr.playing = false; // important! XMMS won't get a self-ended song without it.
   dbg_printf(".\n");
+  vfs_fclose(fd);
   g_thread_exit(NULL);
   return(NULL);
 }
@@ -712,10 +727,30 @@
 
 /***** Informational *****/
 
+static int adplug_is_our_fd(gchar *filename, VFSFile *fd)
+{
+  CSilentopl tmpopl;
+
+  CPlayer *p = factory(fd,&tmpopl);
+
+  dbg_printf("adplug_is_our_file(\"%s\"): returned ",filename);
+
+  if(p) {
+    delete p;
+    dbg_printf("TRUE\n");
+    return TRUE;
+  }
+
+  dbg_printf("FALSE\n");
+  return FALSE;
+}
+
 static int adplug_is_our_file(char *filename)
 {
   CSilentopl tmpopl;
-  CPlayer *p = factory(filename,&tmpopl);
+  VFSFile *fd = vfs_buffered_file_new_from_uri(filename); if (!fd) return FALSE;
+
+  CPlayer *p = factory(fd,&tmpopl);
 
   dbg_printf("adplug_is_our_file(\"%s\"): returned ",filename);
 
@@ -739,7 +774,11 @@
 static void adplug_song_info(char *filename, char **title, int *length)
 {
   CSilentopl tmpopl;
-  CPlayer *p = factory(filename, &tmpopl);
+  VFSFile *fd = vfs_buffered_file_new_from_uri(filename);
+
+  if (!fd) return;
+
+  CPlayer *p = factory(fd, &tmpopl);
 
   dbg_printf("adplug_song_info(\"%s\", \"%s\", %d): ", filename, *title, *length);
 
@@ -929,7 +968,12 @@
     NULL,                       // set_info_text (filled by XMMS)
     adplug_song_info,
     adplug_info_box,            // adplug_info_box was here (but it used deprecated GTK+ functions)
-    NULL                        // output plugin (filled by XMMS)
+    NULL,                       // output plugin (filled by XMMS)
+    NULL,
+    NULL,
+    NULL,
+    adplug_is_our_fd,
+    NULL,
   };
 
 extern "C" InputPlugin *get_iplugin_info(void)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/adplug/core/README.audacious	Fri Feb 23 20:23:34 2007 -0800
@@ -0,0 +1,10 @@
+This is a summary of changes made to the AdPlug core in the plugin for
+Audacious:
+
+- every replayer is now passed a VFS fd
+- there is a binio virtual which is now used to wrap the VFS in a way 
+  that is non-intrusive
+- some blatantly bad coding practices have been corrected
+
+--
+William Pitcock <nenolod -at- sacredspiral.co.uk>
--- a/src/adplug/core/a2m.cxx	Thu Feb 22 07:19:39 2007 -0800
+++ b/src/adplug/core/a2m.cxx	Fri Feb 23 20:23:34 2007 -0800
@@ -60,9 +60,9 @@
   return new Ca2mLoader(newopl);
 }
 
-bool Ca2mLoader::load(const std::string &filename, const CFileProvider &fp)
+bool Ca2mLoader::load(VFSFile *fd, const CFileProvider &fp)
 {
-  binistream *f = fp.open(filename); if(!f) return false;
+  binistream *f = fp.open(fd); if(!f) return false;
   struct {
     char id[10];
     unsigned long crc;
--- a/src/adplug/core/a2m.h	Thu Feb 22 07:19:39 2007 -0800
+++ b/src/adplug/core/a2m.h	Fri Feb 23 20:23:34 2007 -0800
@@ -30,7 +30,7 @@
 		: CmodPlayer(newopl)
 	{ };
 
-	bool load(const std::string &filename, const CFileProvider &fp);
+	bool load(VFSFile *fd, const CFileProvider &fp);
 	float getrefresh();
 
 	std::string gettype()
--- a/src/adplug/core/adl.cxx	Thu Feb 22 07:19:39 2007 -0800
+++ b/src/adplug/core/adl.cxx	Fri Feb 23 20:23:34 2007 -0800
@@ -2317,9 +2317,10 @@
 // 	playSoundEffect(1);
 // }
 
-bool CadlPlayer::load(const std::string &filename, const CFileProvider &fp)
+bool CadlPlayer::load(VFSFile *fd, const CFileProvider &fp)
 {
-  binistream	*f = fp.open(filename);
+  binistream	*f = fp.open(fd);
+  std::string   filename(fd->uri);
 
   // file validation section
   if(!f || !fp.extension(filename, ".adl")) {
--- a/src/adplug/core/adl.h	Thu Feb 22 07:19:39 2007 -0800
+++ b/src/adplug/core/adl.h	Fri Feb 23 20:23:34 2007 -0800
@@ -22,7 +22,7 @@
   CadlPlayer(Copl *newopl);
   ~CadlPlayer();
 
-  bool load(const std::string &filename, const CFileProvider &fp);
+  bool load(VFSFile *fd, const CFileProvider &fp);
   bool update();
   void rewind(int subsong);
 
--- a/src/adplug/core/adplug.cxx	Thu Feb 22 07:19:39 2007 -0800
+++ b/src/adplug/core/adplug.cxx	Fri Feb 23 20:23:34 2007 -0800
@@ -127,22 +127,21 @@
 const CPlayers CAdPlug::players = CAdPlug::init_players(CAdPlug::allplayers);
 CAdPlugDatabase *CAdPlug::database = 0;
 
-CPlayer *CAdPlug::factory(const std::string &fn, Copl *opl, const CPlayers &pl,
+CPlayer *CAdPlug::factory(VFSFile *fd, Copl *opl, const CPlayers &pl,
 			  const CFileProvider &fp)
 {
   CPlayer			*p;
   CPlayers::const_iterator	i;
   unsigned int			j;
 
-  AdPlug_LogWrite("*** CAdPlug::factory(\"%s\",opl,fp) ***\n", fn.c_str());
-
   // 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))) {
+      if(fp.extension(fd->uri, (*i)->get_extension(j))) {
 	AdPlug_LogWrite("Trying direct hit: %s\n", (*i)->filetype.c_str());
+        vfs_rewind(fd);
 	if((p = (*i)->factory(opl)))
-	  if(p->load(fn, fp)) {
+	  if(p->load(fd, fp)) {
 	    AdPlug_LogWrite("got it!\n");
 	    AdPlug_LogWrite("--- CAdPlug::factory ---\n");
 	    return p;
@@ -154,7 +153,7 @@
   for(i = pl.begin(); i != pl.end(); i++) {
     AdPlug_LogWrite("Trying: %s\n", (*i)->filetype.c_str());
     if((p = (*i)->factory(opl)))
-      if(p->load(fn, fp)) {
+      if(p->load(fd, fp)) {
         AdPlug_LogWrite("got it!\n");
         AdPlug_LogWrite("--- CAdPlug::factory ---\n");
 	return p;
--- a/src/adplug/core/adplug.h	Thu Feb 22 07:19:39 2007 -0800
+++ b/src/adplug/core/adplug.h	Fri Feb 23 20:23:34 2007 -0800
@@ -37,7 +37,7 @@
 public:
   static const CPlayers players;
 
-  static CPlayer *factory(const std::string &fn, Copl *opl,
+  static CPlayer *factory(VFSFile *fd, Copl *opl,
 			  const CPlayers &pl = players,
 			  const CFileProvider &fp = CProvider_Filesystem());
 
--- a/src/adplug/core/adtrack.cxx	Thu Feb 22 07:19:39 2007 -0800
+++ b/src/adplug/core/adtrack.cxx	Fri Feb 23 20:23:34 2007 -0800
@@ -42,15 +42,16 @@
   return new CadtrackLoader(newopl);
 }
 
-bool CadtrackLoader::load(const std::string &filename, const CFileProvider &fp)
+bool CadtrackLoader::load(VFSFile *fd, const CFileProvider &fp)
 {
-  binistream *f = fp.open(filename); if(!f) return false;
+  binistream *f = fp.open(fd); if(!f) return false;
   binistream *instf;
   char note[2];
   unsigned short rwp;
   unsigned char chp, octave, pnote = 0;
   int i,j;
   AdTrackInst myinst;
+  std::string filename(fd->uri);
 
   // file validation
   if(!fp.extension(filename, ".sng") || fp.filesize(f) != 36000)
@@ -61,8 +62,10 @@
   instfilename += ".ins";
   AdPlug_LogWrite("CadtrackLoader::load(,\"%s\"): Checking for \"%s\"...\n",
 		  filename.c_str(), instfilename.c_str());
-  instf = fp.open(instfilename);
-  if(!instf || fp.filesize(instf) != 468) { fp.close(f); return false; }
+
+  VFSFile *instfd = vfs_fopen(instfilename.c_str(), "rb");
+  instf = fp.open(instfd);
+  if(!instf || fp.filesize(instf) != 468) { fp.close(f); vfs_fclose(instfd); return false; }
 
   // give CmodPlayer a hint on what we're up to
   realloc_patterns(1,1000,9); realloc_instruments(9); realloc_order(1);
--- a/src/adplug/core/adtrack.h	Thu Feb 22 07:19:39 2007 -0800
+++ b/src/adplug/core/adtrack.h	Fri Feb 23 20:23:34 2007 -0800
@@ -30,7 +30,7 @@
 		: CmodPlayer(newopl)
 	{ };
 
-	bool load(const std::string &filename, const CFileProvider &fp);
+	bool load(VFSFile *fd, const CFileProvider &fp);
 	float getrefresh();
 
 	std::string gettype()
--- a/src/adplug/core/amd.cxx	Thu Feb 22 07:19:39 2007 -0800
+++ b/src/adplug/core/amd.cxx	Fri Feb 23 20:23:34 2007 -0800
@@ -29,9 +29,9 @@
   return new CamdLoader(newopl);
 }
 
-bool CamdLoader::load(const std::string &filename, const CFileProvider &fp)
+bool CamdLoader::load(VFSFile *fd, const CFileProvider &fp)
 {
-        binistream *f = fp.open(filename); if(!f) return false;
+        binistream *f = fp.open(fd); if(!f) return false;
 	struct {
 		char id[9];
 		unsigned char version;
--- a/src/adplug/core/amd.h	Thu Feb 22 07:19:39 2007 -0800
+++ b/src/adplug/core/amd.h	Fri Feb 23 20:23:34 2007 -0800
@@ -30,7 +30,7 @@
 		: CmodPlayer(newopl)
 	{ };
 
-	bool load(const std::string &filename, const CFileProvider &fp);
+	bool load(VFSFile *fd, const CFileProvider &fp);
 	float getrefresh();
 
 	std::string gettype()
--- a/src/adplug/core/bam.cxx	Thu Feb 22 07:19:39 2007 -0800
+++ b/src/adplug/core/bam.cxx	Fri Feb 23 20:23:34 2007 -0800
@@ -65,9 +65,9 @@
   return new CbamPlayer(newopl);
 }
 
-bool CbamPlayer::load(const std::string &filename, const CFileProvider &fp)
+bool CbamPlayer::load(VFSFile *fd, const CFileProvider &fp)
 {
-        binistream *f = fp.open(filename); if(!f) return false;
+        binistream *f = fp.open(fd); if(!f) return false;
 	char id[4];
 	unsigned int i;
 
--- a/src/adplug/core/bam.h	Thu Feb 22 07:19:39 2007 -0800
+++ b/src/adplug/core/bam.h	Fri Feb 23 20:23:34 2007 -0800
@@ -32,7 +32,7 @@
 	~CbamPlayer()
 	{ if(song) delete [] song; };
 
-	bool load(const std::string &filename, const CFileProvider &fp);
+	bool load(VFSFile *fd, const CFileProvider &fp);
 	bool update();
 	void rewind(int subsong);
 	float getrefresh()
--- a/src/adplug/core/binio_virtual.h	Thu Feb 22 07:19:39 2007 -0800
+++ b/src/adplug/core/binio_virtual.h	Fri Feb 23 20:23:34 2007 -0800
@@ -20,6 +20,11 @@
 
 public:
 	vfsistream() {};
+	~vfsistream() {};
+
+	vfsistream(VFSFile *fd) {
+		this->fd = fd;
+	};
 
 	vfsistream(const char *file) {
 		this->fd = vfs_fopen(file, "rb");
@@ -29,11 +34,6 @@
 		this->fd = vfs_fopen(file.c_str(), "rb");
 	};
 
-	~vfsistream() {
-		if (this->fd != NULL)
-			vfs_fclose(this->fd);
-	};
-
 	void open(const char *file) {
 		this->fd = vfs_fopen(file, "rb");
 	};
@@ -80,6 +80,11 @@
 
 public:
 	vfsostream() {};
+	~vfsostream() {};
+
+	vfsostream(VFSFile *fd) {
+		this->fd = fd;
+	};
 
 	vfsostream(const char *file) {
 		this->fd = vfs_fopen(file, "wb");
@@ -89,11 +94,6 @@
 		this->fd = vfs_fopen(file.c_str(), "wb");
 	};
 
-	~vfsostream() {
-		if (this->fd != NULL)
-			vfs_fclose(this->fd);
-	};
-
 	void open(const char *file) {
 		this->fd = vfs_fopen(file, "wb");
 	};
--- a/src/adplug/core/cff.cxx	Thu Feb 22 07:19:39 2007 -0800
+++ b/src/adplug/core/cff.cxx	Fri Feb 23 20:23:34 2007 -0800
@@ -35,9 +35,9 @@
   return new CcffLoader(newopl);
 }
 
-bool CcffLoader::load(const std::string &filename, const CFileProvider &fp)
+bool CcffLoader::load(VFSFile *fd, const CFileProvider &fp)
 {
-        binistream *f = fp.open(filename); if(!f) return false;
+        binistream *f = fp.open(fd); if(!f) return false;
 	const unsigned char conv_inst[11] = { 2,1,10,9,4,3,6,5,0,8,7 };
 	const unsigned short conv_note[12] = { 0x16B, 0x181, 0x198, 0x1B0, 0x1CA, 0x1E5, 0x202, 0x220, 0x241, 0x263, 0x287, 0x2AE };
 
--- a/src/adplug/core/cff.h	Thu Feb 22 07:19:39 2007 -0800
+++ b/src/adplug/core/cff.h	Fri Feb 23 20:23:34 2007 -0800
@@ -28,7 +28,7 @@
 
 		CcffLoader(Copl *newopl) : CmodPlayer(newopl) { };
 
-		bool	load(const std::string &filename, const CFileProvider &fp);
+		bool	load(VFSFile *fd, const CFileProvider &fp);
 		void	rewind(int subsong);
 
 		std::string		gettype();
--- a/src/adplug/core/d00.cxx	Thu Feb 22 07:19:39 2007 -0800
+++ b/src/adplug/core/d00.cxx	Fri Feb 23 20:23:34 2007 -0800
@@ -53,14 +53,15 @@
   return new Cd00Player(newopl);
 }
 
-bool Cd00Player::load(const std::string &filename, const CFileProvider &fp)
+bool Cd00Player::load(VFSFile *fd, const CFileProvider &fp)
 {
-  binistream	*f = fp.open(filename); if(!f) return false;
+  binistream	*f = fp.open(fd); if(!f) return false;
   d00header	*checkhead;
   d00header1	*ch;
   unsigned long	filesize;
   int		i,ver1=0;
   char		*str;
+  std::string   filename(fd->uri);
 
   // file validation section
   checkhead = new d00header;
--- a/src/adplug/core/d00.h	Thu Feb 22 07:19:39 2007 -0800
+++ b/src/adplug/core/d00.h	Fri Feb 23 20:23:34 2007 -0800
@@ -35,7 +35,7 @@
 	~Cd00Player()
 	{ if(filedata) delete [] filedata; };
 
-	bool load(const std::string &filename, const CFileProvider &fp);
+	bool load(VFSFile *fd, const CFileProvider &fp);
 	bool update();
 	void rewind(int subsong);
 	float getrefresh();
--- a/src/adplug/core/dfm.cxx	Thu Feb 22 07:19:39 2007 -0800
+++ b/src/adplug/core/dfm.cxx	Fri Feb 23 20:23:34 2007 -0800
@@ -30,9 +30,9 @@
   return new CdfmLoader(newopl);
 }
 
-bool CdfmLoader::load(const std::string &filename, const CFileProvider &fp)
+bool CdfmLoader::load(VFSFile *fd, const CFileProvider &fp)
 {
-  binistream *f = fp.open(filename); if(!f) return false;
+  binistream *f = fp.open(fd); if(!f) return false;
   unsigned char		npats,n,note,fx,c,r,param;
   unsigned int		i;
   const unsigned char	convfx[8] = {255,255,17,19,23,24,255,13};
--- a/src/adplug/core/dfm.h	Thu Feb 22 07:19:39 2007 -0800
+++ b/src/adplug/core/dfm.h	Fri Feb 23 20:23:34 2007 -0800
@@ -30,7 +30,7 @@
 		: CmodPlayer(newopl)
 	{ };
 
-	bool load(const std::string &filename, const CFileProvider &fp);
+	bool load(VFSFile *fd, const CFileProvider &fp);
 	float getrefresh();
 
 	std::string gettype();
--- a/src/adplug/core/dmo.cxx	Thu Feb 22 07:19:39 2007 -0800
+++ b/src/adplug/core/dmo.cxx	Fri Feb 23 20:23:34 2007 -0800
@@ -49,17 +49,18 @@
   return new CdmoLoader(newopl);
 }
 
-bool CdmoLoader::load(const std::string &filename, const CFileProvider &fp)
+bool CdmoLoader::load(VFSFile *fd, const CFileProvider &fp)
 {
   int i,j;
   binistream *f;
+  std::string filename(fd->uri);
 
   // check header
   dmo_unpacker *unpacker = new dmo_unpacker;
   unsigned char chkhdr[16];
 
+  f = fp.open(fd); if(!f) return false;
   if(!fp.extension(filename, ".dmo")) return false;
-  f = fp.open(filename); if(!f) return false;
 
   f->readString((char *)chkhdr, 16);
 
--- a/src/adplug/core/dmo.h	Thu Feb 22 07:19:39 2007 -0800
+++ b/src/adplug/core/dmo.h	Fri Feb 23 20:23:34 2007 -0800
@@ -28,7 +28,7 @@
 
   CdmoLoader(Copl *newopl) : Cs3mPlayer(newopl) { };
 
-  bool	load(const std::string &filename, const CFileProvider &fp);
+  bool	load(VFSFile *fd, const CFileProvider &fp);
 
   std::string	gettype();
   std::string	getauthor();
--- a/src/adplug/core/dro.cxx	Thu Feb 22 07:19:39 2007 -0800
+++ b/src/adplug/core/dro.cxx	Fri Feb 23 20:23:34 2007 -0800
@@ -43,9 +43,9 @@
     opl3_mode = 1;
 }
 
-bool CdroPlayer::load(const std::string &filename, const CFileProvider &fp)
+bool CdroPlayer::load(VFSFile *fd, const CFileProvider &fp)
 {
-  binistream *f = fp.open(filename); if(!f) return false;
+  binistream *f = fp.open(fd); if(!f) return false;
   char id[8];
   unsigned long i;
 
--- a/src/adplug/core/dro.h	Thu Feb 22 07:19:39 2007 -0800
+++ b/src/adplug/core/dro.h	Fri Feb 23 20:23:34 2007 -0800
@@ -33,7 +33,7 @@
 	delete [] data;
     }
 
-  bool load(const std::string &filename, const CFileProvider &fp);
+  bool load(VFSFile *fd, const CFileProvider &fp);
   bool update();
   void rewind(int subsong);
   float getrefresh();
--- a/src/adplug/core/dtm.cxx	Thu Feb 22 07:19:39 2007 -0800
+++ b/src/adplug/core/dtm.cxx	Fri Feb 23 20:23:34 2007 -0800
@@ -31,9 +31,9 @@
   return new CdtmLoader(newopl);
 }
 
-bool CdtmLoader::load(const std::string &filename, const CFileProvider &fp)
+bool CdtmLoader::load(VFSFile *fd, const CFileProvider &fp)
 {
-        binistream *f = fp.open(filename); if(!f) return false;
+        binistream *f = fp.open(fd); if(!f) return false;
 	const unsigned char conv_inst[11] = { 2,1,10,9,4,3,6,5,0,8,7 };
 	const unsigned short conv_note[12] = { 0x16B, 0x181, 0x198, 0x1B0, 0x1CA, 0x1E5, 0x202, 0x220, 0x241, 0x263, 0x287, 0x2AE };
 
--- a/src/adplug/core/dtm.h	Thu Feb 22 07:19:39 2007 -0800
+++ b/src/adplug/core/dtm.h	Fri Feb 23 20:23:34 2007 -0800
@@ -28,7 +28,7 @@
 
 		CdtmLoader(Copl *newopl) : CmodPlayer(newopl) { };
 
-		bool	load(const std::string &filename, const CFileProvider &fp);
+		bool	load(VFSFile *fd, const CFileProvider &fp);
 		void	rewind(int subsong);
 		float	getrefresh();
 
--- a/src/adplug/core/fmc.cxx	Thu Feb 22 07:19:39 2007 -0800
+++ b/src/adplug/core/fmc.cxx	Fri Feb 23 20:23:34 2007 -0800
@@ -28,9 +28,9 @@
   return new CfmcLoader(newopl);
 }
 
-bool CfmcLoader::load(const std::string &filename, const CFileProvider &fp)
+bool CfmcLoader::load(VFSFile *fd, const CFileProvider &fp)
 {
-        binistream *f = fp.open(filename); if(!f) return false;
+        binistream *f = fp.open(fd); 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};
 
 	int i,j,k,t=0;
--- a/src/adplug/core/fmc.h	Thu Feb 22 07:19:39 2007 -0800
+++ b/src/adplug/core/fmc.h	Fri Feb 23 20:23:34 2007 -0800
@@ -28,7 +28,7 @@
 
 		CfmcLoader(Copl *newopl) : CmodPlayer(newopl) { };
 
-		bool	load(const std::string &filename, const CFileProvider &fp);
+		bool	load(VFSFile *fd, const CFileProvider &fp);
 		float	getrefresh();
 
 		std::string	gettype();
--- a/src/adplug/core/fprovide.cxx	Thu Feb 22 07:19:39 2007 -0800
+++ b/src/adplug/core/fprovide.cxx	Fri Feb 23 20:23:34 2007 -0800
@@ -52,9 +52,9 @@
 
 /***** CProvider_Filesystem *****/
 
-binistream *CProvider_Filesystem::open(std::string filename) const
+binistream *CProvider_Filesystem::open(VFSFile *fd) const
 {
-  vfsistream *f = new vfsistream(filename);
+  vfsistream *f = new vfsistream(fd);
 
   if(!f) return 0;
   if(f->error()) { delete f; return 0; }
--- a/src/adplug/core/fprovide.h	Thu Feb 22 07:19:39 2007 -0800
+++ b/src/adplug/core/fprovide.h	Fri Feb 23 20:23:34 2007 -0800
@@ -32,7 +32,7 @@
     {
     }
 
-  virtual binistream *open(std::string) const = 0;
+  virtual binistream *open(VFSFile *) const = 0;
   virtual void close(binistream *) const = 0;
 
   static bool extension(const std::string &filename,
@@ -43,7 +43,7 @@
 class CProvider_Filesystem: public CFileProvider
 {
 public:
-  virtual binistream *open(std::string filename) const;
+  virtual binistream *open(VFSFile *) const;
   virtual void close(binistream *f) const;
 };
 
--- a/src/adplug/core/hsc.cxx	Thu Feb 22 07:19:39 2007 -0800
+++ b/src/adplug/core/hsc.cxx	Fri Feb 23 20:23:34 2007 -0800
@@ -31,14 +31,14 @@
   return new ChscPlayer(newopl);
 }
 
-bool ChscPlayer::load(const std::string &filename, const CFileProvider &fp)
+bool ChscPlayer::load(VFSFile *fd, const CFileProvider &fp)
 {
-  binistream	*f = fp.open(filename);
+  binistream	*f = fp.open(fd);
   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());
+  if(!f || !fp.extension(fd->uri, ".hsc") || fp.filesize(f) > 59187) {
+    AdPlug_LogWrite("ChscPlayer::load(\"%s\"): Not a HSC file!\n", fd->uri);
     fp.close(f);
     return false;
   }
--- a/src/adplug/core/hsc.h	Thu Feb 22 07:19:39 2007 -0800
+++ b/src/adplug/core/hsc.h	Fri Feb 23 20:23:34 2007 -0800
@@ -31,7 +31,7 @@
 
   ChscPlayer(Copl *newopl): CPlayer(newopl), mtkmode(0) {}
 
-  bool load(const std::string &filename, const CFileProvider &fp);
+  bool load(VFSFile *fd, const CFileProvider &fp);
   bool update();
   void rewind(int subsong);
   float getrefresh() { return 18.2f; };	// refresh rate is fixed at 18.2Hz
--- a/src/adplug/core/hsp.cxx	Thu Feb 22 07:19:39 2007 -0800
+++ b/src/adplug/core/hsp.cxx	Fri Feb 23 20:23:34 2007 -0800
@@ -28,11 +28,12 @@
   return new ChspLoader(newopl);
 }
 
-bool ChspLoader::load(const std::string &filename, const CFileProvider &fp)
+bool ChspLoader::load(VFSFile *fd, const CFileProvider &fp)
 {
-  binistream	*f = fp.open(filename); if(!f) return false;
+  binistream	*f = fp.open(fd); if(!f) return false;
   unsigned long	i, j, orgsize, filesize;
   unsigned char	*cmp, *org;
+  std::string   filename(fd->uri);
 
   // file validation section
   if(!fp.extension(filename, ".hsp")) { fp.close(f); return false; }
--- a/src/adplug/core/hsp.h	Thu Feb 22 07:19:39 2007 -0800
+++ b/src/adplug/core/hsp.h	Fri Feb 23 20:23:34 2007 -0800
@@ -33,7 +33,7 @@
 		: ChscPlayer(newopl)
 	{};
 
-	bool load(const std::string &filename, const CFileProvider &fp);
+	bool load(VFSFile *fd, const CFileProvider &fp);
 };
 
 #endif
--- a/src/adplug/core/imf.cxx	Thu Feb 22 07:19:39 2007 -0800
+++ b/src/adplug/core/imf.cxx	Fri Feb 23 20:23:34 2007 -0800
@@ -53,9 +53,9 @@
   return new CimfPlayer(newopl);
 }
 
-bool CimfPlayer::load(const std::string &filename, const CFileProvider &fp)
+bool CimfPlayer::load(VFSFile *fd, const CFileProvider &fp)
 {
-  binistream *f = fp.open(filename); if(!f) return false;
+  binistream *f = fp.open(fd); if(!f) return false;
   unsigned long fsize, flsize, mfsize = 0;
   unsigned int i;
 
@@ -68,7 +68,7 @@
     version = f->readInt(1);
 
     if(strncmp(header, "ADLIB", 5) || version != 1) {
-      if(!fp.extension(filename, ".imf") && !fp.extension(filename, ".wlf")) {
+      if(!fp.extension(fd->uri, ".imf") && !fp.extension(fd->uri, ".wlf")) {
 	// It's no IMF file at all
 	fp.close(f);
 	return false;
@@ -120,7 +120,7 @@
       footer[footerlen] = '\0';	// Make ASCIIZ string
     }
 
-  rate = getrate(filename, fp, f);
+  rate = getrate(fd->uri, fp, f);
   fp.close(f);
   rewind(0);
   return true;
--- a/src/adplug/core/imf.h	Thu Feb 22 07:19:39 2007 -0800
+++ b/src/adplug/core/imf.h	Fri Feb 23 20:23:34 2007 -0800
@@ -35,7 +35,7 @@
 	~CimfPlayer()
 	  { if(data) delete [] data; if(footer) delete [] footer; };
 
-	bool load(const std::string &filename, const CFileProvider &fp);
+	bool load(VFSFile *fd, const CFileProvider &fp);
 	bool update();
 	void rewind(int subsong);
 	float getrefresh()
--- a/src/adplug/core/ksm.cxx	Thu Feb 22 07:19:39 2007 -0800
+++ b/src/adplug/core/ksm.cxx	Fri Feb 23 20:23:34 2007 -0800
@@ -40,10 +40,11 @@
   return new CksmPlayer(newopl);
 }
 
-bool CksmPlayer::load(const std::string &filename, const CFileProvider &fp)
+bool CksmPlayer::load(VFSFile *fd, const CFileProvider &fp)
 {
   binistream	*f;
   int		i;
+  std::string   filename(fd->uri);
   char		*fn = new char[filename.length() + 9];
 
   // file validation section
@@ -61,7 +62,8 @@
       break;
   strcpy(fn + i + 1, "insts.dat");
   AdPlug_LogWrite("Instruments file: \"%s\"\n", fn);
-  f = fp.open(fn);
+  VFSFile *instfd = vfs_fopen(fn, "rb");
+  f = fp.open(instfd);
   delete [] fn;
   if(!f) {
     AdPlug_LogWrite("Couldn't open instruments file! Aborting!\n");
@@ -70,8 +72,9 @@
   }
   loadinsts(f);
   fp.close(f);
+  vfs_fclose(instfd);
 
-  f = fp.open(filename); if(!f) return false;
+  f = fp.open(fd); if(!f) return false;
   for(i = 0; i < 16; i++) trinst[i] = f->readInt(1);
   for(i = 0; i < 16; i++) trquant[i] = f->readInt(1);
   for(i = 0; i < 16; i++) trchan[i] = f->readInt(1);
--- a/src/adplug/core/ksm.h	Thu Feb 22 07:19:39 2007 -0800
+++ b/src/adplug/core/ksm.h	Fri Feb 23 20:23:34 2007 -0800
@@ -32,7 +32,7 @@
 	~CksmPlayer()
 	{ if(note) delete [] note; };
 
-	bool load(const std::string &filename, const CFileProvider &fp);
+	bool load(VFSFile *fd, const CFileProvider &fp);
 	bool update();
 	void rewind(int subsong);
 	float getrefresh()
--- a/src/adplug/core/lds.cxx	Thu Feb 22 07:19:39 2007 -0800
+++ b/src/adplug/core/lds.cxx	Fri Feb 23 20:23:34 2007 -0800
@@ -83,15 +83,16 @@
   if(patterns) delete [] patterns;
 }
 
-bool CldsPlayer::load(const std::string &filename, const CFileProvider &fp)
+bool CldsPlayer::load(VFSFile *fd, const CFileProvider &fp)
 {
   binistream	*f;
   unsigned int	i, j;
   SoundBank	*sb;
+  std::string   filename(fd->uri);
 
   // file validation section (actually just an extension check)
+  f = fp.open(fd); if(!f) return false;
   if(!fp.extension(filename, ".lds")) return false;
-  f = fp.open(filename); if(!f) return false;
 
   // file load section (header)
   mode = f->readInt(1);
--- a/src/adplug/core/lds.h	Thu Feb 22 07:19:39 2007 -0800
+++ b/src/adplug/core/lds.h	Fri Feb 23 20:23:34 2007 -0800
@@ -29,7 +29,7 @@
   CldsPlayer(Copl *newopl);
   virtual ~CldsPlayer();
 
-  bool load(const std::string &filename, const CFileProvider &fp);
+  bool load(VFSFile *fd, const CFileProvider &fp);
   virtual bool update();
   virtual void rewind(int subsong = -1);
   float getrefresh() { return 70.0f; }
--- a/src/adplug/core/mad.cxx	Thu Feb 22 07:19:39 2007 -0800
+++ b/src/adplug/core/mad.cxx	Fri Feb 23 20:23:34 2007 -0800
@@ -28,9 +28,9 @@
   return new CmadLoader(newopl);
 }
 
-bool CmadLoader::load(const std::string &filename, const CFileProvider &fp)
+bool CmadLoader::load(VFSFile *fd, const CFileProvider &fp)
 {
-  binistream *f = fp.open(filename); if(!f) return false;
+  binistream *f = fp.open(fd); if(!f) return false;
   const unsigned char conv_inst[10] = { 2,1,10,9,4,3,6,5,8,7 };
   unsigned int i, j, k, t = 0;
 
--- a/src/adplug/core/mad.h	Thu Feb 22 07:19:39 2007 -0800
+++ b/src/adplug/core/mad.h	Fri Feb 23 20:23:34 2007 -0800
@@ -28,7 +28,7 @@
 
 	CmadLoader(Copl *newopl) : CmodPlayer(newopl) { };
 
-	bool	load(const std::string &filename, const CFileProvider &fp);
+	bool	load(VFSFile *fd, const CFileProvider &fp);
 	void	rewind(int subsong);
 	float	getrefresh();
 
--- a/src/adplug/core/mid.cxx	Thu Feb 22 07:19:39 2007 -0800
+++ b/src/adplug/core/mid.cxx	Fri Feb 23 20:23:34 2007 -0800
@@ -194,9 +194,10 @@
       }
     sprintf(pfilename+j+3,"patch.003");
 
-    f = fp.open(pfilename);
+    VFSFile *instfd = vfs_fopen(pfilename, "rb");
+    f = fp.open(instfd);
     free(pfilename);
-    if(!f) return false;
+    if(!f) { vfs_fclose(instfd); return false; }
 
     f->ignore(2);
     stins = 0;
@@ -240,6 +241,7 @@
         }
 
     fp.close(f);
+    vfs_fclose(instfd);
     memcpy(smyinsbank, myinsbank, 128 * 16);
     return true;
 }
@@ -280,11 +282,12 @@
     doing=1;
 }
 
-bool CmidPlayer::load(const std::string &filename, const CFileProvider &fp)
+bool CmidPlayer::load(VFSFile *fd, const CFileProvider &fp)
 {
-    binistream *f = fp.open(filename); if(!f) return false;
+    binistream *f = fp.open(fd); if(!f) return false;
     int good;
     unsigned char s[6];
+    std::string filename(fd->uri);
 
     f->readString((char *)s, 6);
     good=0;
--- a/src/adplug/core/mid.h	Thu Feb 22 07:19:39 2007 -0800
+++ b/src/adplug/core/mid.h	Fri Feb 23 20:23:34 2007 -0800
@@ -30,7 +30,7 @@
   ~CmidPlayer()
     { if(data) delete [] data; }
 
-  bool load(const std::string &filename, const CFileProvider &fp);
+  bool load(VFSFile *fd, const CFileProvider &fp);
   bool update();
   void rewind(int subsong);
   float getrefresh();
--- a/src/adplug/core/mkj.cxx	Thu Feb 22 07:19:39 2007 -0800
+++ b/src/adplug/core/mkj.cxx	Fri Feb 23 20:23:34 2007 -0800
@@ -29,9 +29,9 @@
   return new CmkjPlayer(newopl);
 }
 
-bool CmkjPlayer::load(const std::string &filename, const CFileProvider &fp)
+bool CmkjPlayer::load(VFSFile *fd, const CFileProvider &fp)
 {
-  binistream *f = fp.open(filename); if(!f) return false;
+  binistream *f = fp.open(fd); if(!f) return false;
   char	id[6];
   float	ver;
   int	i, j;
@@ -64,7 +64,7 @@
     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", fd->uri, ver, maxchannel,
 		  maxnotes);
   fp.close(f);
   rewind(0);
--- a/src/adplug/core/mkj.h	Thu Feb 22 07:19:39 2007 -0800
+++ b/src/adplug/core/mkj.h	Fri Feb 23 20:23:34 2007 -0800
@@ -32,7 +32,7 @@
 	~CmkjPlayer()
 	{ if(songbuf) delete [] songbuf; }
 
-	bool load(const std::string &filename, const CFileProvider &fp);
+	bool load(VFSFile *fd, const CFileProvider &fp);
 	bool update();
 	void rewind(int subsong);
 	float getrefresh();
--- a/src/adplug/core/msc.cxx	Thu Feb 22 07:19:39 2007 -0800
+++ b/src/adplug/core/msc.cxx	Fri Feb 23 20:23:34 2007 -0800
@@ -62,13 +62,13 @@
 		delete [] desc;
 }
 
-bool CmscPlayer::load(const std::string & filename, const CFileProvider & fp)
+bool CmscPlayer::load(VFSFile * fd, const CFileProvider & fp)
 {
 	binistream * 	bf;
 	msc_header	hdr;
 
 	// open and validate the file
-	bf = fp.open (filename);
+	bf = fp.open (fd);
 	if (! bf)
 		return false;
 	
--- a/src/adplug/core/msc.h	Thu Feb 22 07:19:39 2007 -0800
+++ b/src/adplug/core/msc.h	Fri Feb 23 20:23:34 2007 -0800
@@ -32,7 +32,7 @@
 	CmscPlayer (Copl * newopl);
 	~CmscPlayer ();
 	
-	bool load (const std::string &filename, const CFileProvider &fp);
+	bool load (VFSFile *fd, const CFileProvider &fp);
 	bool update ();
 	void rewind (int subsong);
 	float getrefresh ();
--- a/src/adplug/core/mtk.cxx	Thu Feb 22 07:19:39 2007 -0800
+++ b/src/adplug/core/mtk.cxx	Fri Feb 23 20:23:34 2007 -0800
@@ -28,9 +28,9 @@
   return new CmtkLoader(newopl);
 }
 
-bool CmtkLoader::load(const std::string &filename, const CFileProvider &fp)
+bool CmtkLoader::load(VFSFile *fd, const CFileProvider &fp)
 {
-        binistream *f = fp.open(filename); if(!f) return false;
+        binistream *f = fp.open(fd); if(!f) return false;
 	struct {
 		char id[18];
 		unsigned short crc,size;
--- a/src/adplug/core/mtk.h	Thu Feb 22 07:19:39 2007 -0800
+++ b/src/adplug/core/mtk.h	Fri Feb 23 20:23:34 2007 -0800
@@ -32,7 +32,7 @@
 		mtkmode = 1;
 	};
 
-	bool load(const std::string &filename, const CFileProvider &fp);
+	bool load(VFSFile *fd, const CFileProvider &fp);
 
 	std::string gettype()
 	{ return std::string("MPU-401 Trakker"); };
--- a/src/adplug/core/player.h	Thu Feb 22 07:19:39 2007 -0800
+++ b/src/adplug/core/player.h	Fri Feb 23 20:23:34 2007 -0800
@@ -37,7 +37,7 @@
 /***** Operational methods *****/
 	void seek(unsigned long ms);
 
-	virtual bool load(const std::string &filename,	// loads file
+	virtual bool load(VFSFile *fd,	// 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
--- a/src/adplug/core/rad.cxx	Thu Feb 22 07:19:39 2007 -0800
+++ b/src/adplug/core/rad.cxx	Fri Feb 23 20:23:34 2007 -0800
@@ -29,9 +29,9 @@
   return new CradLoader(newopl);
 }
 
-bool CradLoader::load(const std::string &filename, const CFileProvider &fp)
+bool CradLoader::load(VFSFile *fd, const CFileProvider &fp)
 {
-        binistream *f = fp.open(filename); if(!f) return false;
+        binistream *f = fp.open(fd); if(!f) return false;
 	char id[16];
 	unsigned char buf,ch,c,b,inp;
 	char bufstr[2] = "\0";
--- a/src/adplug/core/rad.h	Thu Feb 22 07:19:39 2007 -0800
+++ b/src/adplug/core/rad.h	Fri Feb 23 20:23:34 2007 -0800
@@ -30,7 +30,7 @@
 		: CmodPlayer(newopl)
 	{ *desc = '\0'; };
 
-	bool load(const std::string &filename, const CFileProvider &fp);
+	bool load(VFSFile *fd, const CFileProvider &fp);
 	float getrefresh();
 
 	std::string gettype()
--- a/src/adplug/core/raw.cxx	Thu Feb 22 07:19:39 2007 -0800
+++ b/src/adplug/core/raw.cxx	Fri Feb 23 20:23:34 2007 -0800
@@ -28,9 +28,9 @@
   return new CrawPlayer(newopl);
 }
 
-bool CrawPlayer::load(const std::string &filename, const CFileProvider &fp)
+bool CrawPlayer::load(VFSFile *fd, const CFileProvider &fp)
 {
-  binistream *f = fp.open(filename); if(!f) return false;
+  binistream *f = fp.open(fd); if(!f) return false;
   char id[8];
   unsigned long i;
 
--- a/src/adplug/core/raw.h	Thu Feb 22 07:19:39 2007 -0800
+++ b/src/adplug/core/raw.h	Fri Feb 23 20:23:34 2007 -0800
@@ -32,7 +32,7 @@
 	~CrawPlayer()
 	{ if(data) delete [] data; };
 
-	bool load(const std::string &filename, const CFileProvider &fp);
+	bool load(VFSFile *fd, const CFileProvider &fp);
 	bool update();
 	void rewind(int subsong);
 	float getrefresh();
--- a/src/adplug/core/rix.cxx	Thu Feb 22 07:19:39 2007 -0800
+++ b/src/adplug/core/rix.cxx	Fri Feb 23 20:23:34 2007 -0800
@@ -63,10 +63,11 @@
     delete [] file_buffer;
 }
 
-bool CrixPlayer::load(const std::string &filename, const CFileProvider &fp)
+bool CrixPlayer::load(VFSFile *fd, const CFileProvider &fp)
 {
-  binistream *f = fp.open(filename); if(!f) return false;
+  binistream *f = fp.open(fd); if(!f) return false;
   unsigned long i=0;
+  std::string filename(fd->uri);
 
   if(stricmp(filename.substr(filename.length()-4,4).c_str(),".mkf")==0)
   {
--- a/src/adplug/core/rix.h	Thu Feb 22 07:19:39 2007 -0800
+++ b/src/adplug/core/rix.h	Fri Feb 23 20:23:34 2007 -0800
@@ -30,7 +30,7 @@
   CrixPlayer(Copl *newopl);
   ~CrixPlayer();
 
-  bool load(const std::string &filename, const CFileProvider &fp);
+  bool load(VFSFile *fd, const CFileProvider &fp);
   bool update();
   void rewind(int subsong);
   float getrefresh();
--- a/src/adplug/core/rol.cxx	Thu Feb 22 07:19:39 2007 -0800
+++ b/src/adplug/core/rol.cxx	Fri Feb 23 20:23:34 2007 -0800
@@ -91,9 +91,10 @@
     }
 }
 //---------------------------------------------------------
-bool CrolPlayer::load(const std::string &filename, const CFileProvider &fp)
+bool CrolPlayer::load(VFSFile *fd, const CFileProvider &fp)
 {
-    binistream *f = fp.open(filename); if(!f) return false;
+    binistream *f = fp.open(fd); if(!f) return false;
+    std::string filename(fd->uri);
 
     char *fn = new char[filename.length()+12];
     int i;
@@ -468,7 +469,8 @@
 bool CrolPlayer::load_voice_data( binistream *f, std::string const &bnk_filename, const CFileProvider &fp )
 {
     SBnkHeader bnk_header;
-    binistream *bnk_file = fp.open( bnk_filename.c_str() );
+    VFSFile *fd = vfs_fopen(bnk_filename.c_str(), "rb");
+    binistream *bnk_file = fp.open(fd);
 
     if( bnk_file )
     {
@@ -490,6 +492,7 @@
         }
 
         fp.close(bnk_file);
+        vfs_fclose(fd);
 
         return true;
     }
--- a/src/adplug/core/rol.h	Thu Feb 22 07:19:39 2007 -0800
+++ b/src/adplug/core/rol.h	Fri Feb 23 20:23:34 2007 -0800
@@ -37,7 +37,7 @@
 
     ~CrolPlayer();
 
-    bool  load      (const std::string &filename, const CFileProvider &fp);
+    bool  load      (VFSFile *fd, const CFileProvider &fp);
     bool  update    ();
     void  rewind    (int subsong);	// rewinds to specified subsong
     float getrefresh();			// returns needed timer refresh rate
--- a/src/adplug/core/s3m.cxx	Thu Feb 22 07:19:39 2007 -0800
+++ b/src/adplug/core/s3m.cxx	Fri Feb 23 20:23:34 2007 -0800
@@ -55,9 +55,9 @@
 			}
 }
 
-bool Cs3mPlayer::load(const std::string &filename, const CFileProvider &fp)
+bool Cs3mPlayer::load(VFSFile *fd, const CFileProvider &fp)
 {
-        binistream *f = fp.open(filename); if(!f) return false;
+        binistream *f = fp.open(fd); if(!f) return false;
 	unsigned short	insptr[99],pattptr[99];
 	int		i,row;
 	unsigned char	bufval,bufval2;
--- a/src/adplug/core/s3m.h	Thu Feb 22 07:19:39 2007 -0800
+++ b/src/adplug/core/s3m.h	Fri Feb 23 20:23:34 2007 -0800
@@ -31,7 +31,7 @@
 
 	Cs3mPlayer(Copl *newopl);
 
-	bool load(const std::string &filename, const CFileProvider &fp);
+	bool load(VFSFile *fd, const CFileProvider &fp);
 	bool update();
 	void rewind(int subsong);
 	float getrefresh();
--- a/src/adplug/core/sa2.cxx	Thu Feb 22 07:19:39 2007 -0800
+++ b/src/adplug/core/sa2.cxx	Fri Feb 23 20:23:34 2007 -0800
@@ -30,9 +30,9 @@
   return new Csa2Loader(newopl);
 }
 
-bool Csa2Loader::load(const std::string &filename, const CFileProvider &fp)
+bool Csa2Loader::load(VFSFile *fd, const CFileProvider &fp)
 {
-        binistream *f = fp.open(filename); if(!f) return false;
+        binistream *f = fp.open(fd); if(!f) return false;
 	struct {
 		unsigned char data[11],arpstart,arpspeed,arppos,arpspdcnt;
 	} insts;
@@ -161,7 +161,7 @@
 
         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);
+		 fd->uri, sat_type, nop, length, restartpos, activechan, bpm);
 
 	// track data
 	if(sat_type & HAS_OLDPATTERNS) {
--- a/src/adplug/core/sa2.h	Thu Feb 22 07:19:39 2007 -0800
+++ b/src/adplug/core/sa2.h	Fri Feb 23 20:23:34 2007 -0800
@@ -31,7 +31,7 @@
 		: CmodPlayer(newopl)
 	{ }
 
-	bool load(const std::string &filename, const CFileProvider &fp);
+	bool load(VFSFile *fd, const CFileProvider &fp);
 
 	std::string gettype();
 	std::string gettitle();
--- a/src/adplug/core/sng.cxx	Thu Feb 22 07:19:39 2007 -0800
+++ b/src/adplug/core/sng.cxx	Fri Feb 23 20:23:34 2007 -0800
@@ -26,9 +26,9 @@
   return new CsngPlayer(newopl);
 }
 
-bool CsngPlayer::load(const std::string &filename, const CFileProvider &fp)
+bool CsngPlayer::load(VFSFile *fd, const CFileProvider &fp)
 {
-  binistream *f = fp.open(filename); if(!f) return false;
+  binistream *f = fp.open(fd); if(!f) return false;
   int i;
 
   // load header
--- a/src/adplug/core/sng.h	Thu Feb 22 07:19:39 2007 -0800
+++ b/src/adplug/core/sng.h	Fri Feb 23 20:23:34 2007 -0800
@@ -35,7 +35,7 @@
 	~CsngPlayer()
 	{ if(data) delete [] data; };
 
-	bool load(const std::string &filename, const CFileProvider &fp);
+	bool load(VFSFile *fd, const CFileProvider &fp);
 	bool update();
 	void rewind(int subsong);
 	float getrefresh()
--- a/src/adplug/core/u6m.cxx	Thu Feb 22 07:19:39 2007 -0800
+++ b/src/adplug/core/u6m.cxx	Fri Feb 23 20:23:34 2007 -0800
@@ -34,14 +34,14 @@
   return new Cu6mPlayer(newopl);
 }
 
-bool Cu6mPlayer::load(const std::string &filename, const CFileProvider &fp)
+bool Cu6mPlayer::load(VFSFile *fd, const CFileProvider &fp)
 {
     // file validation section
     // this section only checks a few *necessary* conditions
     unsigned long filesize, decompressed_filesize;
     binistream *f;
 
-    f = fp.open(filename); if(!f) return false;
+    f = fp.open(fd); if(!f) return false;
     filesize = fp.filesize(f);
 
     if (filesize >= 6)
--- a/src/adplug/core/u6m.h	Thu Feb 22 07:19:39 2007 -0800
+++ b/src/adplug/core/u6m.h	Fri Feb 23 20:23:34 2007 -0800
@@ -42,7 +42,7 @@
         if(song_data) delete[] song_data;
     };
 
-	bool load(const std::string &filename, const CFileProvider &fp);
+	bool load(VFSFile *fd, const CFileProvider &fp);
 	bool update();
 	void rewind(int subsong);
 	float getrefresh();
--- a/src/adplug/core/xad.cxx	Thu Feb 22 07:19:39 2007 -0800
+++ b/src/adplug/core/xad.cxx	Fri Feb 23 20:23:34 2007 -0800
@@ -35,9 +35,9 @@
     delete [] tune;
 }
 
-bool CxadPlayer::load(const std::string &filename, const CFileProvider &fp)
+bool CxadPlayer::load(VFSFile *fd, const CFileProvider &fp)
 {
-  binistream *f = fp.open(filename); if(!f) return false;
+  binistream *f = fp.open(fd); if(!f) return false;
   bool ret = false;
 
   // load header
--- a/src/adplug/core/xad.h	Thu Feb 22 07:19:39 2007 -0800
+++ b/src/adplug/core/xad.h	Fri Feb 23 20:23:34 2007 -0800
@@ -32,7 +32,7 @@
         CxadPlayer(Copl * newopl);
         ~CxadPlayer();
 
-        bool	load(const std::string &filename, const CFileProvider &fp);
+        bool	load(VFSFile *fd, const CFileProvider &fp);
         bool	update();
         void	rewind(int subsong);
         float	getrefresh();
--- a/src/adplug/core/xsm.cxx	Thu Feb 22 07:19:39 2007 -0800
+++ b/src/adplug/core/xsm.cxx	Fri Feb 23 20:23:34 2007 -0800
@@ -33,9 +33,9 @@
   if(music) delete [] music;
 }
 
-bool CxsmPlayer::load(const std::string &filename, const CFileProvider &fp)
+bool CxsmPlayer::load(VFSFile *fd, const CFileProvider &fp)
 {
-  binistream *f = fp.open(filename); if(!f) return false;
+  binistream *f = fp.open(fd); if(!f) return false;
   char			id[6];
   int			i, j;
 
--- a/src/adplug/core/xsm.h	Thu Feb 22 07:19:39 2007 -0800
+++ b/src/adplug/core/xsm.h	Fri Feb 23 20:23:34 2007 -0800
@@ -29,7 +29,7 @@
   CxsmPlayer(Copl *newopl);
   ~CxsmPlayer();
 
-  bool load(const std::string &filename, const CFileProvider &fp);
+  bool load(VFSFile *fd, const CFileProvider &fp);
   bool update();
   void rewind(int subsong);
   float getrefresh();