2 Adplug - Replayer for many OPL2/OPL3 audio file formats.
3 Copyright (C) 1999 - 2003 Simon Peter, <dn.tlp@gmx.net>, et al.
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public
16 License along with this library; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 xad.cpp - XAD shell player by Riven the Mage <riven@ok.ru>
25 /* -------- Public Methods -------------------------------- */
27 CxadPlayer::CxadPlayer(Copl * newopl) : CPlayer(newopl)
32 CxadPlayer::~CxadPlayer()
38 bool CxadPlayer::load(const std::string &filename, const CFileProvider &fp)
40 binistream *f = fp.open(filename); if(!f) return false;
44 xad.id = f->readInt(4);
45 f->readString(xad.title, 36);
46 f->readString(xad.author, 36);
47 xad.fmt = f->readInt(2);
48 xad.speed = f->readInt(1);
49 xad.reserved_a = f->readInt(1);
52 if(xad.id != 0x21444158) { fp.close(f); return false; }
55 tune_size = fp.filesize(f) - 80;
58 tune = new unsigned char [tune_size];
59 f->readString((char *)tune, tune_size);
62 ret = xadplayer_load();
70 void CxadPlayer::rewind(int subsong)
74 plr.speed = xad.speed;
75 plr.speed_counter = 1;
80 xadplayer_rewind(subsong);
83 AdPlug_LogWrite("-----------\n");
87 bool CxadPlayer::update()
89 if (--plr.speed_counter)
92 plr.speed_counter = plr.speed;
98 return (plr.playing && (!plr.looping));
101 float CxadPlayer::getrefresh()
103 return xadplayer_getrefresh();
106 std::string CxadPlayer::gettype()
108 return xadplayer_gettype();
111 std::string CxadPlayer::gettitle()
113 return xadplayer_gettitle();
116 std::string CxadPlayer::getauthor()
118 return xadplayer_getauthor();
121 std::string CxadPlayer::getinstrument(unsigned int i)
123 return xadplayer_getinstrument(i);
126 unsigned int CxadPlayer::getinstruments()
128 return xadplayer_getinstruments();
131 /* -------- Protected Methods ------------------------------- */
133 void CxadPlayer::opl_write(int reg, int val)
137 AdPlug_LogWrite("[ %02X ] = %02X\n",reg,val);