1 /*
2  * This file is part of libsidplayfp, a SID player engine.
3  *
4  * Copyright 2012-2015 Leandro Nini <drfiemost@users.sourceforge.net>
5  *
6  *  This program is free software; you can redistribute it and/or modify
7  *  it under the terms of the GNU General Public License as published by
8  *  the Free Software Foundation; either version 2 of the License, or
9  *  (at your option) any later version.
10  *
11  *  This program is distributed in the hope that it will be useful,
12  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  *  GNU General Public License for more details.
15  *
16  *  You should have received a copy of the GNU General Public License
17  *  along with this program; if not, write to the Free Software
18  *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
19  */
20 
21 #ifndef MUS_H
22 #define MUS_H
23 
24 #include <stdint.h>
25 
26 #include "SidTuneBase.h"
27 
28 #include "sidcxx11.h"
29 
30 namespace libsidplayfp
31 {
32 
33 class MUS final : public SidTuneBase
34 {
35 private:
36     /// Needed for MUS/STR player installation.
37     uint_least16_t musDataLen;
38 
39 private:
40     bool mergeParts(buffer_t& musBuf, buffer_t& strBuf);
41 
42     void tryLoad(buffer_t& musBuf,
43                     buffer_t& strBuf,
44                     uint_least32_t fileOffset,
45                     uint_least32_t voice3Index,
46                     bool init);
47 
48 protected:
MUS()49     MUS() {}
50 
51     void installPlayer(sidmemory& mem);
52 
53     void setPlayerAddress();
54 
55     virtual void acceptSidTune(const char* dataFileName, const char* infoFileName,
56                                 buffer_t& buf, bool isSlashedFileName) override;
57 
58 public:
~MUS()59     virtual ~MUS() {}
60 
61     static SidTuneBase* load(buffer_t& dataBuf, bool init = false);
62     static SidTuneBase* load(buffer_t& musBuf,
63                                 buffer_t& strBuf,
64                                 uint_least32_t fileOffset,
65                                 bool init = false);
66 
67     virtual void placeSidTuneInC64mem(sidmemory& mem) override;
68 
69 private:
70     // prevent copying
71     MUS(const MUS&);
72     MUS& operator=(MUS&);
73 };
74 
75 }
76 
77 #endif // MUS_H
78