1 /*
2  * This file is part of libsidplayfp, a SID player engine.
3  *
4  *  Copyright 2011-2017 Leandro Nini
5  *  Copyright 2007-2010 Antti Lankila
6  *  Copyright 2000 Simon White
7  *
8  *  This program is free software; you can redistribute it and/or modify
9  *  it under the terms of the GNU General Public License as published by
10  *  the Free Software Foundation; either version 2 of the License, or
11  *  (at your option) any later version.
12  *
13  *  This program is distributed in the hope that it will be useful,
14  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
15  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16  *  GNU General Public License for more details.
17  *
18  *  You should have received a copy of the GNU General Public License
19  *  along with this program; if not, write to the Free Software
20  *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
21  */
22 
23 #ifndef SIDTUNEINFO_H
24 #define SIDTUNEINFO_H
25 
26 #include <stdint.h>
27 
28 #include "sidplayfp/siddefs.h"
29 
30 /**
31  * This interface is used to get values from SidTune objects.
32  *
33  * You must read (i.e. activate) sub-song specific information
34  * via:
35  *        const SidTuneInfo* tuneInfo = SidTune.getInfo();
36  *        const SidTuneInfo* tuneInfo = SidTune.getInfo(songNumber);
37  */
38 class SID_EXTERN SidTuneInfo
39 {
40 public:
41     typedef enum {
42         CLOCK_UNKNOWN,
43         CLOCK_PAL,
44         CLOCK_NTSC,
45         CLOCK_ANY
46     } clock_t;
47 
48     typedef enum {
49         SIDMODEL_UNKNOWN,
50         SIDMODEL_6581,
51         SIDMODEL_8580,
52         SIDMODEL_ANY
53     } model_t;
54 
55     typedef enum {
56         COMPATIBILITY_C64,   ///< File is C64 compatible
57         COMPATIBILITY_PSID,  ///< File is PSID specific
58         COMPATIBILITY_R64,   ///< File is Real C64 only
59         COMPATIBILITY_BASIC  ///< File requires C64 Basic
60     } compatibility_t;
61 
62 public:
63     /// Vertical-Blanking-Interrupt
64     static const int SPEED_VBI = 0;
65 
66     /// CIA 1 Timer A
67     static const int SPEED_CIA_1A = 60;
68 
69 public:
70     /**
71      * Load Address.
72      */
73     uint_least16_t loadAddr() const;
74 
75     /**
76      * Init Address.
77      */
78     uint_least16_t initAddr() const;
79 
80     /**
81      * Play Address.
82      */
83     uint_least16_t playAddr() const;
84 
85     /**
86      * The number of songs.
87      */
88     unsigned int songs() const;
89 
90     /**
91      * The default starting song.
92      */
93     unsigned int startSong() const;
94 
95     /**
96      * The tune that has been initialized.
97      */
98     unsigned int currentSong() const;
99 
100     /**
101      * @name Base addresses
102      * The SID chip base address(es) used by the sidtune.
103      * - 0xD400 for the 1st SID
104      * - 0 if the nth SID is not required
105      */
106     uint_least16_t sidChipBase(unsigned int i) const;
107 
108     /**
109      * The number of SID chips required by the tune.
110      */
111     int sidChips() const;
112 
113     /**
114      * Intended speed.
115      */
116     int songSpeed() const;
117 
118     /**
119      * First available page for relocation.
120      */
121     uint_least8_t relocStartPage() const;
122 
123     /**
124      * Number of pages available for relocation.
125      */
126     uint_least8_t relocPages() const;
127 
128     /**
129      * @name SID model
130      * The SID chip model(s) requested by the sidtune.
131      */
132     model_t sidModel(unsigned int i) const;
133 
134     /**
135      * Compatibility requirements.
136      */
137     compatibility_t compatibility() const;
138 
139     /**
140      * @name Tune infos
141      * Song title, credits, ...
142      * - 0 = Title
143      * - 1 = Author
144      * - 2 = Released
145      */
146     //@{
147     unsigned int numberOfInfoStrings() const;     ///< The number of available text info lines
148     const char* infoString(unsigned int i) const; ///< Text info from the format headers etc.
149     //@}
150 
151     /**
152      * @name Tune comments
153      * MUS comments.
154      */
155     //@{
156     unsigned int numberOfCommentStrings() const;     ///< Number of comments
157     const char* commentString(unsigned int i) const; ///< Used to stash the MUS comment somewhere
158     //@}
159 
160     /**
161      * Length of single-file sidtune file.
162      */
163     uint_least32_t dataFileLen() const;
164 
165     /**
166      * Length of raw C64 data without load address.
167      */
168     uint_least32_t c64dataLen() const;
169 
170     /**
171      * The tune clock speed.
172      */
173     clock_t clockSpeed() const;
174 
175     /**
176      * The name of the identified file format.
177      */
178     const char* formatString() const;
179 
180     /**
181      * Whether load address might be duplicate.
182      */
183     bool fixLoad() const;
184 
185     /**
186      * Path to sidtune files.
187      */
188     const char* path() const;
189 
190     /**
191      * A first file: e.g. "foo.sid" or "foo.mus".
192      */
193     const char* dataFileName() const;
194 
195     /**
196      * A second file: e.g. "foo.str".
197      * Returns 0 if none.
198      */
199     const char* infoFileName() const;
200 
201 private:
202     virtual uint_least16_t getLoadAddr() const =0;
203 
204     virtual uint_least16_t getInitAddr() const =0;
205 
206     virtual uint_least16_t getPlayAddr() const =0;
207 
208     virtual unsigned int getSongs() const =0;
209 
210     virtual unsigned int getStartSong() const =0;
211 
212     virtual unsigned int getCurrentSong() const =0;
213 
214     virtual uint_least16_t getSidChipBase(unsigned int i) const =0;
215 
216     virtual int getSidChips() const =0;
217 
218     virtual int getSongSpeed() const =0;
219 
220     virtual uint_least8_t getRelocStartPage() const =0;
221 
222     virtual uint_least8_t getRelocPages() const =0;
223 
224     virtual model_t getSidModel(unsigned int i) const =0;
225 
226     virtual compatibility_t getCompatibility() const =0;
227 
228     virtual unsigned int getNumberOfInfoStrings() const =0;
229     virtual const char* getInfoString(unsigned int i) const =0;
230 
231     virtual unsigned int getNumberOfCommentStrings() const =0;
232     virtual const char* getCommentString(unsigned int i) const =0;
233 
234     virtual uint_least32_t getDataFileLen() const =0;
235 
236     virtual uint_least32_t getC64dataLen() const =0;
237 
238     virtual clock_t getClockSpeed() const =0;
239 
240     virtual const char* getFormatString() const =0;
241 
242     virtual bool getFixLoad() const =0;
243 
244     virtual const char* getPath() const =0;
245 
246     virtual const char* getDataFileName() const =0;
247 
248     virtual const char* getInfoFileName() const =0;
249 
250 protected:
251     ~SidTuneInfo() {}
252 };
253 
254 #endif  /* SIDTUNEINFO_H */
255