| SidTune.h | | SidTune.h | |
| | | | |
| skipping to change at line 36 | | skipping to change at line 36 | |
| #include <stdint.h> | | #include <stdint.h> | |
| #include <memory> | | #include <memory> | |
| | | | |
| #include "sidplayfp/siddefs.h" | | #include "sidplayfp/siddefs.h" | |
| | | | |
| class SidTuneInfo; | | class SidTuneInfo; | |
| class SidTuneBase; | | class SidTuneBase; | |
| class sidmemory; | | class sidmemory; | |
| | | | |
| /** | | /** | |
|
| * SidTune | | * SidTune | |
| */ | | */ | |
| class SID_EXTERN SidTune | | class SID_EXTERN SidTune | |
| { | | { | |
| public: | | public: | |
| static const int MD5_LENGTH = 32; | | static const int MD5_LENGTH = 32; | |
| | | | |
| private: | | private: | |
| /// Filename extensions to append for various file types. | | /// Filename extensions to append for various file types. | |
| static const char** fileNameExtensions; | | static const char** fileNameExtensions; | |
| | | | |
| private: // ------------------------------------------------------------- | | private: // ------------------------------------------------------------- | |
| std::auto_ptr<SidTuneBase> tune; | | std::auto_ptr<SidTuneBase> tune; | |
| | | | |
| const char* m_statusString; | | const char* m_statusString; | |
| | | | |
| bool m_status; | | bool m_status; | |
| | | | |
| public: // ---------------------------------------------------------------
- | | public: // ---------------------------------------------------------------
- | |
| | | | |
| /** | | /** | |
|
| * Load a sidtune from a file. | | * Load a sidtune from a file. | |
| * | | * | |
| * To retrieve data from standard input pass in filename "-". | | * To retrieve data from standard input pass in filename "-". | |
| * If you want to override the default filename extensions use this | | * If you want to override the default filename extensions use this | |
| * contructor. Please note, that if the specified "fileName" | | * contructor. Please note, that if the specified "fileName" | |
| * does exist and the loader is able to determine its file format, | | * does exist and the loader is able to determine its file format, | |
| * this function does not try to append any file name extension. | | * this function does not try to append any file name extension. | |
| * See "SidTune.cpp" for the default list of file name extensions. | | * See "SidTune.cpp" for the default list of file name extensions. | |
| * You can specify "fileName = 0", if you do not want to | | * You can specify "fileName = 0", if you do not want to | |
| * load a sidtune. You can later load one with open(). | | * load a sidtune. You can later load one with open(). | |
| * | | * | |
| * @param fileName | | * @param fileName | |
| * @param fileNameExt | | * @param fileNameExt | |
| * @param separatorIsSlash | | * @param separatorIsSlash | |
| */ | | */ | |
| SidTune(const char* fileName, const char **fileNameExt = 0, | | SidTune(const char* fileName, const char **fileNameExt = 0, | |
| bool separatorIsSlash = false); | | bool separatorIsSlash = false); | |
| | | | |
| /** | | /** | |
|
| * Load a single-file sidtune from a memory buffer. | | * Load a single-file sidtune from a memory buffer. | |
| * Currently supported: PSID format. | | * Currently supported: PSID format. | |
| * | | * | |
| * @param oneFileFormatSidtune the buffer that contains song data | | * @param oneFileFormatSidtune the buffer that contains song data | |
| * @param sidtuneLength length of the buffer | | * @param sidtuneLength length of the buffer | |
| */ | | */ | |
| SidTune(const uint_least8_t* oneFileFormatSidtune, uint_least32_t sidtu
neLength); | | SidTune(const uint_least8_t* oneFileFormatSidtune, uint_least32_t sidtu
neLength); | |
| | | | |
| virtual ~SidTune() {} | | virtual ~SidTune() {} | |
| | | | |
| /** | | /** | |
|
| * The SidTune class does not copy the list of file name extensions, | | * The SidTune class does not copy the list of file name extensions, | |
| * so make sure you keep it. If the provided pointer is 0, the | | * so make sure you keep it. If the provided pointer is 0, the | |
| * default list will be activated. This is a static list which | | * default list will be activated. This is a static list which | |
| * is used by all SidTune objects. | | * is used by all SidTune objects. | |
| * | | * | |
| * @param fileNameExt | | * @param fileNameExt | |
| */ | | */ | |
| void setFileNameExtensions(const char **fileNameExt); | | void setFileNameExtensions(const char **fileNameExt); | |
| | | | |
| /** | | /** | |
|
| * Load a sidtune into an existing object from a file. | | * Load a sidtune into an existing object from a file. | |
| * | | * | |
| * @param fileName | | * @param fileName | |
| * @param separatorIsSlash | | * @param separatorIsSlash | |
| */ | | */ | |
| void load(const char* fileName, bool separatorIsSlash = false); | | void load(const char* fileName, bool separatorIsSlash = false); | |
| | | | |
| /** | | /** | |
|
| * Load a sidtune into an existing object from a buffer. | | * Load a sidtune into an existing object from a buffer. | |
| * | | * | |
| * @param sourceBuffer the buffer that contains song data | | * @param sourceBuffer the buffer that contains song data | |
| * @param bufferLen length of the buffer | | * @param bufferLen length of the buffer | |
| */ | | */ | |
| void read(const uint_least8_t* sourceBuffer, uint_least32_t bufferLen); | | void read(const uint_least8_t* sourceBuffer, uint_least32_t bufferLen); | |
| | | | |
| /** | | /** | |
|
| * Select sub-song. | | * Select sub-song. | |
| * | | * | |
| * @param songNum the selected song (0 = default starting song) | | * @param songNum the selected song (0 = default starting song) | |
| * @return active song number, 0 if no tune is loaded. | | * @return active song number, 0 if no tune is loaded. | |
| */ | | */ | |
| unsigned int selectSong(unsigned int songNum); | | unsigned int selectSong(unsigned int songNum); | |
| | | | |
| /** | | /** | |
|
| * Retrieve current active sub-song specific information. | | * Retrieve current active sub-song specific information. | |
| * | | * | |
| * @return a pointer to #SidTuneInfo, 0 if no tune is loaded. The pointe | | * @return a pointer to #SidTuneInfo, 0 if no tune is loaded. The point | |
| r must not be deleted. | | er must not be deleted. | |
| */ | | */ | |
| const SidTuneInfo* getInfo() const; | | const SidTuneInfo* getInfo() const; | |
| | | | |
| /** | | /** | |
|
| * Select sub-song and retrieve information. | | * Select sub-song and retrieve information. | |
| * | | * | |
| * @param songNum the selected song (0 = default starting song) | | * @param songNum the selected song (0 = default starting song) | |
| * @return a pointer to #SidTuneInfo, 0 if no tune is loaded. The pointe | | * @return a pointer to #SidTuneInfo, 0 if no tune is loaded. The point | |
| r must not be deleted. | | er must not be deleted. | |
| */ | | */ | |
| const SidTuneInfo* getInfo(unsigned int songNum); | | const SidTuneInfo* getInfo(unsigned int songNum); | |
| | | | |
| /** | | /** | |
|
| * Determine current state of object. | | * Determine current state of object. | |
| * Upon error condition use #statusString to get a descriptive | | * Upon error condition use #statusString to get a descriptive | |
| * text string. | | * text string. | |
| * | | * | |
| * @return current state (true = okay, false = error) | | * @return current state (true = okay, false = error) | |
| */ | | */ | |
| bool getStatus() const; | | bool getStatus() const; | |
| | | | |
| /** | | /** | |
|
| * Error/status message of last operation | | * Error/status message of last operation. | |
| */ | | */ | |
| const char* statusString() const; | | const char* statusString() const; | |
| | | | |
| /** | | /** | |
|
| * Copy sidtune into C64 memory (64 KB). | | * Copy sidtune into C64 memory (64 KB). | |
| */ | | */ | |
| bool placeSidTuneInC64mem(sidmemory* mem); | | bool placeSidTuneInC64mem(sidmemory* mem); | |
| | | | |
| /** | | /** | |
|
| * Calculates the MD5 hash of the tune. | | * Calculates the MD5 hash of the tune. | |
| * Not providing an md5 buffer will cause the internal one to be used. | | * Not providing an md5 buffer will cause the internal one to be used. | |
| * If provided, buffer must be MD5_LENGTH + 1 | | * If provided, buffer must be MD5_LENGTH + 1 | |
| * | | * | |
| * @return a pointer to the buffer containing the md5 string, 0 if no tu | | * @return a pointer to the buffer containing the md5 string, 0 if no t | |
| ne is loaded. | | une is loaded. | |
| */ | | */ | |
| const char *createMD5(char *md5 = 0); | | const char *createMD5(char *md5 = 0); | |
| | | | |
| private: // prevent copying | | private: // prevent copying | |
| SidTune(const SidTune&); | | SidTune(const SidTune&); | |
| SidTune& operator=(SidTune&); | | SidTune& operator=(SidTune&); | |
| }; | | }; | |
| | | | |
| #endif /* SIDTUNE_H */ | | #endif /* SIDTUNE_H */ | |
| | | | |
End of changes. 13 change blocks. |
| 73 lines changed or deleted | | 73 lines changed or added | |
|
| SidTuneInfo.h | | SidTuneInfo.h | |
| | | | |
| skipping to change at line 29 | | skipping to change at line 29 | |
| * along with this program; if not, write to the Free Software | | * along with this program; if not, write to the Free Software | |
| * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-13
01 USA | | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-13
01 USA | |
| */ | | */ | |
| | | | |
| #ifndef SIDTUNEINFO_H | | #ifndef SIDTUNEINFO_H | |
| #define SIDTUNEINFO_H | | #define SIDTUNEINFO_H | |
| | | | |
| #include <stdint.h> | | #include <stdint.h> | |
| | | | |
| /** | | /** | |
|
| * This interface is used to get values from SidTune objects. | | * This interface is used to get values from SidTune objects. | |
| * | | * | |
| * You must read (i.e. activate) sub-song specific information | | * You must read (i.e. activate) sub-song specific information | |
| * via: | | * via: | |
| * const SidTuneInfo* tuneInfo = SidTune.getInfo(); | | * const SidTuneInfo* tuneInfo = SidTune.getInfo(); | |
| * const SidTuneInfo* tuneInfo = SidTune.getInfo(songNumber); | | * const SidTuneInfo* tuneInfo = SidTune.getInfo(songNumber); | |
| */ | | */ | |
| class SidTuneInfo | | class SidTuneInfo | |
| { | | { | |
| public: | | public: | |
| typedef enum { | | typedef enum { | |
| CLOCK_UNKNOWN, | | CLOCK_UNKNOWN, | |
| CLOCK_PAL, | | CLOCK_PAL, | |
| CLOCK_NTSC, | | CLOCK_NTSC, | |
| CLOCK_ANY | | CLOCK_ANY | |
| } clock_t; | | } clock_t; | |
| | | | |
| | | | |
| skipping to change at line 68 | | skipping to change at line 68 | |
| } compatibility_t; | | } compatibility_t; | |
| | | | |
| public: | | public: | |
| /// Vertical-Blanking-Interrupt | | /// Vertical-Blanking-Interrupt | |
| static const int SPEED_VBI = 0; | | static const int SPEED_VBI = 0; | |
| | | | |
| /// CIA 1 Timer A | | /// CIA 1 Timer A | |
| static const int SPEED_CIA_1A = 60; | | static const int SPEED_CIA_1A = 60; | |
| | | | |
| public: | | public: | |
|
| /// Load Address | | /** | |
| | | * Load Address. | |
| | | */ | |
| virtual uint_least16_t loadAddr() const =0; | | virtual uint_least16_t loadAddr() const =0; | |
| | | | |
|
| /// Init Address | | /** | |
| | | * Init Address. | |
| | | */ | |
| virtual uint_least16_t initAddr() const =0; | | virtual uint_least16_t initAddr() const =0; | |
| | | | |
|
| /// Play Address | | /** | |
| | | * Play Address. | |
| | | */ | |
| virtual uint_least16_t playAddr() const =0; | | virtual uint_least16_t playAddr() const =0; | |
| | | | |
| /** | | /** | |
|
| * The number of songs. | | * The number of songs. | |
| */ | | */ | |
| virtual unsigned int songs() const =0; | | virtual unsigned int songs() const =0; | |
| | | | |
| /** | | /** | |
|
| * The default starting song. | | * The default starting song. | |
| */ | | */ | |
| virtual unsigned int startSong() const =0; | | virtual unsigned int startSong() const =0; | |
| | | | |
| /** | | /** | |
|
| * The tune that has been initialized. | | * The tune that has been initialized. | |
| */ | | */ | |
| virtual unsigned int currentSong() const =0; | | virtual unsigned int currentSong() const =0; | |
| | | | |
| /** | | /** | |
|
| * @name Base addresses | | * @name Base addresses | |
| * The SID chip base address(es) used by the sidtune. | | * The SID chip base address(es) used by the sidtune. | |
| */ | | */ | |
| //@{ | | //@{ | |
| virtual uint_least16_t sidChipBase1() const =0; ///< 0xD400 (normal,
1st SID) | | virtual uint_least16_t sidChipBase1() const =0; ///< 0xD400 (normal,
1st SID) | |
| virtual uint_least16_t sidChipBase2() const =0; ///< 0xD?00 (2nd SID
) or 0 (no 2nd SID) | | virtual uint_least16_t sidChipBase2() const =0; ///< 0xD?00 (2nd SID
) or 0 (no 2nd SID) | |
| //@} | | //@} | |
| | | | |
| /** | | /** | |
|
| * Whether sidtune uses two SID chips. | | * Whether sidtune uses two SID chips. | |
| */ | | */ | |
| virtual bool isStereo() const=0; | | virtual bool isStereo() const=0; | |
| | | | |
| /** | | /** | |
|
| * Intended speed. | | * Intended speed. | |
| */ | | */ | |
| virtual int songSpeed() const =0; | | virtual int songSpeed() const =0; | |
| | | | |
| /** | | /** | |
|
| * First available page for relocation. | | * First available page for relocation. | |
| */ | | */ | |
| virtual uint_least8_t relocStartPage() const =0; | | virtual uint_least8_t relocStartPage() const =0; | |
| | | | |
| /** | | /** | |
|
| * Number of pages available for relocation. | | * Number of pages available for relocation. | |
| */ | | */ | |
| virtual uint_least8_t relocPages() const =0; | | virtual uint_least8_t relocPages() const =0; | |
| | | | |
| /** | | /** | |
| * @name SID model | | * @name SID model | |
| * The SID chip model(s) requested by the sidtune. | | * The SID chip model(s) requested by the sidtune. | |
| */ | | */ | |
| //@{ | | //@{ | |
| virtual model_t sidModel1() const =0; ///< first SID | | virtual model_t sidModel1() const =0; ///< first SID | |
| virtual model_t sidModel2() const =0; ///< second SID | | virtual model_t sidModel2() const =0; ///< second SID | |
| //@} | | //@} | |
| | | | |
| /** | | /** | |
|
| * Compatibility requirements. | | * Compatibility requirements. | |
| */ | | */ | |
| virtual compatibility_t compatibility() const =0; | | virtual compatibility_t compatibility() const =0; | |
| | | | |
| /** | | /** | |
|
| * @name Tune infos | | * @name Tune infos | |
| * Song title, credits, ... | | * Song title, credits, ... | |
| * - 0 = Title | | * - 0 = Title | |
| * - 1 = Author | | * - 1 = Author | |
| * - 2 = Released | | * - 2 = Released | |
| */ | | */ | |
| //@{ | | //@{ | |
| virtual unsigned int numberOfInfoStrings() const =0; ///< the numbe
r of available text info lines | | virtual unsigned int numberOfInfoStrings() const =0; ///< the numbe
r of available text info lines | |
| virtual const char* infoString(unsigned int i) const =0; ///< text info
from the format headers etc. | | virtual const char* infoString(unsigned int i) const =0; ///< text info
from the format headers etc. | |
| //@} | | //@} | |
| | | | |
| /** | | /** | |
|
| * @name Tune comments | | * @name Tune comments | |
| * MUS comments. | | * MUS comments. | |
| */ | | */ | |
| //@{ | | //@{ | |
| virtual unsigned int numberOfCommentStrings() const =0; ///< Number
of comments | | virtual unsigned int numberOfCommentStrings() const =0; ///< Number
of comments | |
| virtual const char* commentString(unsigned int i) const =0; ///< Used
to stash the MUS comment somewhere. | | virtual const char* commentString(unsigned int i) const =0; ///< Used
to stash the MUS comment somewhere. | |
| //@} | | //@} | |
| | | | |
| /** | | /** | |
|
| * Length of single-file sidtune file. | | * Length of single-file sidtune file. | |
| */ | | */ | |
| virtual uint_least32_t dataFileLen() const =0; | | virtual uint_least32_t dataFileLen() const =0; | |
| | | | |
| /** | | /** | |
|
| * Length of raw C64 data without load address. | | * Length of raw C64 data without load address. | |
| */ | | */ | |
| virtual uint_least32_t c64dataLen() const =0; | | virtual uint_least32_t c64dataLen() const =0; | |
| | | | |
| /** | | /** | |
|
| * The tune clock speed. | | * The tune clock speed. | |
| */ | | */ | |
| virtual clock_t clockSpeed() const =0; | | virtual clock_t clockSpeed() const =0; | |
| | | | |
| /** | | /** | |
|
| * The name of the identified file format. | | * The name of the identified file format. | |
| */ | | */ | |
| virtual const char* formatString() const =0; | | virtual const char* formatString() const =0; | |
| | | | |
| /** | | /** | |
|
| * Whether load address might be duplicate. | | * Whether load address might be duplicate. | |
| */ | | */ | |
| virtual bool fixLoad() const =0; | | virtual bool fixLoad() const =0; | |
| | | | |
| /** | | /** | |
|
| * Path to sidtune files. | | * Path to sidtune files. | |
| */ | | */ | |
| virtual const char* path() const =0; | | virtual const char* path() const =0; | |
| | | | |
| /** | | /** | |
|
| * A first file: e.g. "foo.sid" or "foo.mus". | | * A first file: e.g. "foo.sid" or "foo.mus". | |
| */ | | */ | |
| virtual const char* dataFileName() const =0; | | virtual const char* dataFileName() const =0; | |
| | | | |
| /** | | /** | |
|
| * A second file: e.g. "foo.str". | | * A second file: e.g. "foo.str". | |
| * Returns 0 if none. | | * Returns 0 if none. | |
| */ | | */ | |
| virtual const char* infoFileName() const =0; | | virtual const char* infoFileName() const =0; | |
| | | | |
| protected: | | protected: | |
| ~SidTuneInfo() {} | | ~SidTuneInfo() {} | |
| }; | | }; | |
| | | | |
| #endif /* SIDTUNEINFO_H */ | | #endif /* SIDTUNEINFO_H */ | |
| | | | |
End of changes. 23 change blocks. |
| 55 lines changed or deleted | | 61 lines changed or added | |
|
| event.h | | event.h | |
| | | | |
| skipping to change at line 33 | | skipping to change at line 33 | |
| #ifndef EVENT_H | | #ifndef EVENT_H | |
| #define EVENT_H | | #define EVENT_H | |
| | | | |
| #include <stdint.h> | | #include <stdint.h> | |
| | | | |
| #include "sidplayfp/siddefs.h" | | #include "sidplayfp/siddefs.h" | |
| | | | |
| typedef int_fast64_t event_clock_t; | | typedef int_fast64_t event_clock_t; | |
| | | | |
| /** | | /** | |
|
| * C64 system runs actions at system clock high and low | | * C64 system runs actions at system clock high and low | |
| * states. The PHI1 corresponds to the auxiliary chip activity | | * states. The PHI1 corresponds to the auxiliary chip activity | |
| * and PHI2 to CPU activity. For any clock, PHI1s are before | | * and PHI2 to CPU activity. For any clock, PHI1s are before | |
| * PHI2s. | | * PHI2s. | |
| */ | | */ | |
| typedef enum {EVENT_CLOCK_PHI1 = 0, EVENT_CLOCK_PHI2 = 1} event_phase_t; | | typedef enum {EVENT_CLOCK_PHI1 = 0, EVENT_CLOCK_PHI2 = 1} event_phase_t; | |
| | | | |
| /** | | /** | |
|
| * Event scheduler (based on alarm from Vice). Created in 2001 by Simon A. | | * Event scheduler (based on alarm from Vice). Created in 2001 by Simon A. | |
| * White. | | * White. | |
| * | | * | |
| * Optimized EventScheduler and corresponding Event class by Antti S. Lankil | | * Optimized EventScheduler and corresponding Event class by Antti S. Lanki | |
| a | | la | |
| * in 2009. | | * in 2009. | |
| * | | * | |
| * @author Antti Lankila | | * @author Antti Lankila | |
| */ | | */ | |
| class SID_EXTERN Event | | class SID_EXTERN Event | |
| { | | { | |
| friend class EventScheduler; | | friend class EventScheduler; | |
| | | | |
| private: | | private: | |
|
| /** Describe event for humans. */ | | /** | |
| | | * Describe event for humans. | |
| | | */ | |
| const char * const m_name; | | const char * const m_name; | |
| | | | |
|
| /** The clock this event fires */ | | /** | |
| | | * The clock this event fires. | |
| | | */ | |
| event_clock_t triggerTime; | | event_clock_t triggerTime; | |
| | | | |
|
| /** The next event in sequence */ | | /** | |
| | | * The next event in sequence. | |
| | | */ | |
| Event *next; | | Event *next; | |
| | | | |
| public: | | public: | |
| /** | | /** | |
|
| * Events are used for delayed execution. Name is | | * Events are used for delayed execution. Name is | |
| * not used by code, but is useful for debugging. | | * not used by code, but is useful for debugging. | |
| * | | * | |
| * @param name Descriptive string of the event. | | * @param name Descriptive string of the event. | |
| */ | | */ | |
| Event(const char * const name) : | | Event(const char * const name) : | |
| m_name(name) {} | | m_name(name) {} | |
| | | | |
| /** | | /** | |
|
| * Event code to be executed. Events are allowed to safely | | * Event code to be executed. Events are allowed to safely | |
| * reschedule themselves with the EventScheduler during | | * reschedule themselves with the EventScheduler during | |
| * invocations. | | * invocations. | |
| */ | | */ | |
| virtual void event() = 0; | | virtual void event() = 0; | |
| | | | |
| protected: | | protected: | |
| ~Event() {} | | ~Event() {} | |
| }; | | }; | |
| | | | |
| /** | | /** | |
|
| * Fast EventScheduler, which maintains a linked list of Events. | | * Fast EventScheduler, which maintains a linked list of Events. | |
| * This scheduler takes neglible time even when it is used to | | * This scheduler takes neglible time even when it is used to | |
| * schedule events for nearly every clock. | | * schedule events for nearly every clock. | |
| * | | * | |
| * Events occur on an internal clock which is 2x the visible clock. | | * Events occur on an internal clock which is 2x the visible clock. | |
| * The visible clock is divided to two phases called phi1 and phi2. | | * The visible clock is divided to two phases called phi1 and phi2. | |
| * | | * | |
| * The phi1 clocks are used by VIC and CIA chips, phi2 clocks by CPU. | | * The phi1 clocks are used by VIC and CIA chips, phi2 clocks by CPU. | |
| * | | * | |
| * Scheduling an event for a phi1 clock when system is in phi2 causes the | | * Scheduling an event for a phi1 clock when system is in phi2 causes the | |
| * event to be moved to the next phi1 cycle. Correspondingly, requesting | | * event to be moved to the next phi1 cycle. Correspondingly, requesting | |
| * a phi1 time when system is in phi2 returns the value of the next phi1. | | * a phi1 time when system is in phi2 returns the value of the next phi1. | |
| * | | * | |
| * @author Antti S. Lankila | | * @author Antti S. Lankila | |
| */ | | */ | |
| class EventContext | | class EventContext | |
| { | | { | |
| public: | | public: | |
| /** | | /** | |
|
| * Cancel the specified event. | | * Cancel the specified event. | |
| * | | * | |
| * @param event the event to cancel | | * @param event the event to cancel | |
| */ | | */ | |
| virtual void cancel(Event &event) = 0; | | virtual void cancel(Event &event) = 0; | |
| | | | |
| /** | | /** | |
|
| * Add event to pending queue. | | * Add event to pending queue. | |
| * | | * | |
| * At PHI2, specify cycles=0 and Phase=PHI1 to fire on the very next PHI | | * At PHI2, specify cycles=0 and Phase=PHI1 to fire on the very next PH | |
| 1. | | I1. | |
| * | | * | |
| * @param event the event to add | | * @param event the event to add | |
| * @param cycles how many cycles from now to fire | | * @param cycles how many cycles from now to fire | |
| * @param phase the phase when to fire the event | | * @param phase the phase when to fire the event | |
| */ | | */ | |
| virtual void schedule(Event &event, event_clock_t cycles, | | virtual void schedule(Event &event, event_clock_t cycles, | |
| event_phase_t phase) = 0; | | event_phase_t phase) = 0; | |
| | | | |
| /** | | /** | |
|
| * Add event to pending queue in the same phase as current event. | | * Add event to pending queue in the same phase as current event. | |
| * | | * | |
| * @param event the event to add | | * @param event the event to add | |
| * @param cycles how many cycles from now to fire | | * @param cycles how many cycles from now to fire | |
| */ | | */ | |
| virtual void schedule(Event &event, event_clock_t cycles) = 0; | | virtual void schedule(Event &event, event_clock_t cycles) = 0; | |
| | | | |
| /** | | /** | |
|
| * Is the event pending in this scheduler? | | * Is the event pending in this scheduler? | |
| * | | * | |
| * @param event the event | | * @param event the event | |
| * @return true when pending | | * @return true when pending | |
| */ | | */ | |
| virtual bool isPending(Event &event) const = 0; | | virtual bool isPending(Event &event) const = 0; | |
| | | | |
| /** | | /** | |
|
| * Get time with respect to a specific clock phase. | | * Get time with respect to a specific clock phase. | |
| * | | * | |
| * @param phase the phase | | * @param phase the phase | |
| * @return the time according to specified phase. | | * @return the time according to specified phase. | |
| */ | | */ | |
| virtual event_clock_t getTime(event_phase_t phase) const = 0; | | virtual event_clock_t getTime(event_phase_t phase) const = 0; | |
| | | | |
| /** | | /** | |
|
| * Get clocks since specified clock in given phase. | | * Get clocks since specified clock in given phase. | |
| * | | * | |
| * @param clock the time to compare to | | * @param clock the time to compare to | |
| * @param phase the phase to comapre to | | * @param phase the phase to comapre to | |
| * @return the time between specified clock and now | | * @return the time between specified clock and now | |
| */ | | */ | |
| virtual event_clock_t getTime(event_clock_t clock, event_phase_t phase)
const = 0; | | virtual event_clock_t getTime(event_clock_t clock, event_phase_t phase)
const = 0; | |
| | | | |
| /** | | /** | |
|
| * Return current clock phase. | | * Return current clock phase. | |
| * | | * | |
| * @return The current phase | | * @return The current phase | |
| */ | | */ | |
| virtual event_phase_t phase() const = 0; | | virtual event_phase_t phase() const = 0; | |
| | | | |
| protected: | | protected: | |
| ~EventContext() {} | | ~EventContext() {} | |
| }; | | }; | |
| | | | |
| #endif // EVENT_H | | #endif // EVENT_H | |
| | | | |
End of changes. 15 change blocks. |
| 79 lines changed or deleted | | 85 lines changed or added | |
|
| sidplayfp.h | | sidplayfp.h | |
| | | | |
| skipping to change at line 44 | | skipping to change at line 44 | |
| class SidInfo; | | class SidInfo; | |
| class EventContext; | | class EventContext; | |
| | | | |
| // Private Sidplayer | | // Private Sidplayer | |
| namespace SIDPLAYFP_NAMESPACE | | namespace SIDPLAYFP_NAMESPACE | |
| { | | { | |
| class Player; | | class Player; | |
| } | | } | |
| | | | |
| /** | | /** | |
|
| * sidplayfp | | * sidplayfp | |
| */ | | */ | |
| class SID_EXTERN sidplayfp | | class SID_EXTERN sidplayfp | |
| { | | { | |
| private: | | private: | |
| SIDPLAYFP_NAMESPACE::Player &sidplayer; | | SIDPLAYFP_NAMESPACE::Player &sidplayer; | |
| | | | |
| public: | | public: | |
| sidplayfp(); | | sidplayfp(); | |
| ~sidplayfp(); | | ~sidplayfp(); | |
| | | | |
| /** | | /** | |
|
| * Get the current engine configuration. | | * Get the current engine configuration. | |
| * | | * | |
| * @return a const reference to the current configuration. | | * @return a const reference to the current configuration. | |
| */ | | */ | |
| const SidConfig &config() const; | | const SidConfig &config() const; | |
| | | | |
| /** | | /** | |
|
| * Get the current player informations. | | * Get the current player informations. | |
| * | | * | |
| * @return a const reference to the current info. | | * @return a const reference to the current info. | |
| */ | | */ | |
| const SidInfo &info() const; | | const SidInfo &info() const; | |
| | | | |
| /** | | /** | |
|
| * Configure the engine. | | * Configure the engine. | |
| * Check #error for detailed message if something goes wrong. | | * Check #error for detailed message if something goes wrong. | |
| * | | * | |
| * @param cfg the new configuration | | * @param cfg the new configuration | |
| * @return true on success, false otherwise. | | * @return true on success, false otherwise. | |
| */ | | */ | |
| bool config(const SidConfig &cfg); | | bool config(const SidConfig &cfg); | |
| | | | |
| /** | | /** | |
|
| * Error message. | | * Error message. | |
| * | | * | |
| * @return string error message. | | * @return string error message. | |
| */ | | */ | |
| const char *error() const; | | const char *error() const; | |
| | | | |
| /** | | /** | |
|
| * Set the fast-forward factor. | | * Set the fast-forward factor. | |
| * | | * | |
| * @param percent | | * @param percent | |
| */ | | */ | |
| bool fastForward(unsigned int percent); | | bool fastForward(unsigned int percent); | |
| | | | |
| /** | | /** | |
|
| * Load a tune. | | * Load a tune. | |
| * Check #error for detailed message if something goes wrong. | | * Check #error for detailed message if something goes wrong. | |
| * | | * | |
| * @param tune the SidTune to load, 0 unloads current tune. | | * @param tune the SidTune to load, 0 unloads current tune. | |
| * @return true on sucess, false otherwise. | | * @return true on sucess, false otherwise. | |
| */ | | */ | |
| bool load(SidTune *tune); | | bool load(SidTune *tune); | |
| | | | |
| /** | | /** | |
|
| * Produce samples to play. | | * Produce samples to play. | |
| * | | * | |
| * @param buffer pointer to the buffer to fill with samples. | | * @param buffer pointer to the buffer to fill with samples. | |
| * @param count the size of the buffer measured in 16 bit samples. | | * @param count the size of the buffer measured in 16 bit samples. | |
| * @return the number of produced samples. | | * @return the number of produced samples. | |
| */ | | */ | |
| uint_least32_t play(short *buffer, uint_least32_t count); | | uint_least32_t play(short *buffer, uint_least32_t count); | |
| | | | |
| /** | | /** | |
|
| * Check if the engine is playing or stopped. | | * Check if the engine is playing or stopped. | |
| * | | * | |
| * @return true if playing, false otherwise. | | * @return true if playing, false otherwise. | |
| */ | | */ | |
| bool isPlaying() const; | | bool isPlaying() const; | |
| | | | |
|
| /** | | /** Stop the engine. */ | |
| * Stop the engine. | | | |
| */ | | | |
| void stop(); | | void stop(); | |
| | | | |
| /** | | /** | |
|
| * Control debugging. | | * Control debugging. | |
| * Only has effect if library have been compiled | | * Only has effect if library have been compiled | |
| * with the --enable-debug option. | | * with the --enable-debug option. | |
| * | | * | |
| * @param enable enable/disable debugging. | | * @param enable enable/disable debugging. | |
| * @param out the file where to redirect the debug info. | | * @param out the file where to redirect the debug info. | |
| */ | | */ | |
| void debug(bool enable, FILE *out); | | void debug(bool enable, FILE *out); | |
| | | | |
| /** | | /** | |
|
| * Mute/unmute a SID channel. | | * Mute/unmute a SID channel. | |
| * | | * | |
| * @param sidNum the SID chip, 0 for the first one, 1 for the second. | | * @param sidNum the SID chip, 0 for the first one, 1 for the second. | |
| * @param voice the channel to mute/unmute. | | * @param voice the channel to mute/unmute. | |
| * @param enable true unmutes the channel, false mutes it. | | * @param enable true unmutes the channel, false mutes it. | |
| */ | | */ | |
| void mute(unsigned int sidNum, unsigned int voice, bool enable); | | void mute(unsigned int sidNum, unsigned int voice, bool enable); | |
| | | | |
| /** | | /** | |
|
| * Get the current playing time with respect to resolution returned by t | | * Get the current playing time with respect to resolution returned by | |
| imebase. | | timebase. | |
| * | | * | |
| * @return the current playing time. | | * @return the current playing time. | |
| */ | | */ | |
| uint_least32_t time() const; | | uint_least32_t time() const; | |
| | | | |
| /** | | /** | |
|
| * Set ROMs. | | * Set ROMs. | |
| * The ROMs are validate against known ones. | | * The ROMs are validate against known ones. | |
| * | | * | |
| * @param kernal pointer to Kernal ROM. | | * @param kernal pointer to Kernal ROM. | |
| * @param basic pointer to Basic ROM, generally needed only for BASIC tu | | * @param basic pointer to Basic ROM, generally needed only for BASIC t | |
| nes. | | unes. | |
| * @param character pointer to character generator ROM. | | * @param character pointer to character generator ROM. | |
| */ | | */ | |
| void setRoms(const uint8_t* kernal, const uint8_t* basic=0, const uint8
_t* character=0); | | void setRoms(const uint8_t* kernal, const uint8_t* basic=0, const uint8
_t* character=0); | |
| | | | |
| /** | | /** | |
|
| * Get the event scheduler. | | * Get the event scheduler. | |
| * | | * | |
| * @return pointer to the scheduler. | | * @return pointer to the scheduler. | |
| */ | | */ | |
| EventContext *getEventContext(); | | EventContext *getEventContext(); | |
| | | | |
| /** | | /** | |
|
| * Get the CIA 1 Timer A programmed value. | | * Get the CIA 1 Timer A programmed value. | |
| */ | | */ | |
| uint_least16_t getCia1TimerA() const; | | uint_least16_t getCia1TimerA() const; | |
| }; | | }; | |
| | | | |
| #endif // SIDPLAYFP_H | | #endif // SIDPLAYFP_H | |
| | | | |
End of changes. 16 change blocks. |
| 75 lines changed or deleted | | 73 lines changed or added | |
|
| stil.h | | stil.h | |
| | | | |
| skipping to change at line 33 | | skipping to change at line 33 | |
| #define STIL_H | | #define STIL_H | |
| | | | |
| #include <string> | | #include <string> | |
| #include <algorithm> | | #include <algorithm> | |
| #include <map> | | #include <map> | |
| #include <iosfwd> | | #include <iosfwd> | |
| | | | |
| #include "stildefs.h" | | #include "stildefs.h" | |
| | | | |
| /** | | /** | |
|
| * STIL class | | * STIL class | |
| * | | * | |
| * @author LaLa <LaLa@C64.org> | | * @author LaLa <LaLa@C64.org> | |
| * @copyright 1998, 2002 by LaLa | | * @copyright 1998, 2002 by LaLa | |
| * | | * | |
| * | | * | |
| * Given the location of HVSC this class can extract STIL information for a | | * Given the location of HVSC this class can extract STIL information for a | |
| * given tune of a given SID file. (Sounds simple, huh?) | | * given tune of a given SID file. (Sounds simple, huh?) | |
| * | | * | |
| * PLEASE, READ THE ACCOMPANYING README.TXT FILE BEFORE PROCEEDING!!!! | | * PLEASE, READ THE ACCOMPANYING README.TXT FILE BEFORE PROCEEDING!!!! | |
| */ | | */ | |
| class STIL_EXTERN STIL | | class STIL_EXTERN STIL | |
| { | | { | |
| public: | | public: | |
| | | | |
| /// Enum to use for asking for specific fields. | | /// Enum to use for asking for specific fields. | |
| enum STILField | | enum STILField | |
| { | | { | |
| all, | | all, | |
| name, | | name, | |
| author, | | author, | |
| | | | |
| skipping to change at line 82 | | skipping to change at line 82 | |
| NO_STIL_DIRS, ///< Failed to get sections (subdirs) when pars
ing STIL.txt. | | NO_STIL_DIRS, ///< Failed to get sections (subdirs) when pars
ing STIL.txt. | |
| NO_BUG_DIRS ///< Failed to get sections (subdirs) when pars
ing BUGlist.txt. | | NO_BUG_DIRS ///< Failed to get sections (subdirs) when pars
ing BUGlist.txt. | |
| }; | | }; | |
| | | | |
| /// To turn debug output on | | /// To turn debug output on | |
| bool STIL_DEBUG; | | bool STIL_DEBUG; | |
| | | | |
| //----// | | //----// | |
| | | | |
| /** | | /** | |
|
| * Allocates necessary memory. | | * Allocates necessary memory. | |
| * | | * | |
| * @param stilPath relative path to STIL file | | * @param stilPath relative path to STIL file | |
| * @param bugsPath relative path to BUG file | | * @param bugsPath relative path to BUG file | |
| */ | | */ | |
| STIL(const char *stilPath = DEFAULT_PATH_TO_STIL, const char *bugsPath
= DEFAULT_PATH_TO_BUGLIST); | | STIL(const char *stilPath = DEFAULT_PATH_TO_STIL, const char *bugsPath
= DEFAULT_PATH_TO_BUGLIST); | |
| | | | |
| /** | | /** | |
|
| * Returns a formatted string telling what the version | | * Returns a formatted string telling what the version | |
| * number is for the STIL class and other info. | | * number is for the STIL class and other info. | |
| * If it is called after setBaseDir(), the string also | | * If it is called after setBaseDir(), the string also | |
| * has the STIL.txt file's version number in it. | | * has the STIL.txt file's version number in it. | |
| * | | * | |
| * @return | | * @return | |
| * printable formatted string with version and copyright | | * printable formatted string with version and copyright | |
| * info | | * info | |
| * (It's kinda dangerous to return a pointer that points | | * (It's kinda dangerous to return a pointer that points | |
| * to an internal structure, but I trust you. :) | | * to an internal structure, but I trust you. :) | |
| */ | | */ | |
| const char *getVersion(); | | const char *getVersion(); | |
| | | | |
| /** | | /** | |
|
| * Returns a floating number telling what the version | | * Returns a floating number telling what the version | |
| * number is of this STIL class. | | * number is of this STIL class. | |
| * | | * | |
| * @return | | * @return | |
| * version number | | * version number | |
| */ | | */ | |
| float getVersionNo(); | | float getVersionNo(); | |
| | | | |
| /** | | /** | |
|
| * Tell the object where the HVSC base directory is - it | | * Tell the object where the HVSC base directory is - it | |
| * figures that the STIL should be in /DOCUMENTS/STIL.txt | | * figures that the STIL should be in /DOCUMENTS/STIL.txt | |
| * and that the BUGlist should be in /DOCUMENTS/BUGlist.txt. | | * and that the BUGlist should be in /DOCUMENTS/BUGlist.txt. | |
| * It should not matter whether the path is given in UNIX, | | * It should not matter whether the path is given in UNIX, | |
| * WinDOS, or Mac format (ie. '\' vs. '/' vs. ':') | | * WinDOS, or Mac format (ie. '\' vs. '/' vs. ':') | |
| * | | * | |
| * @param pathToHVSC = HVSC base directory in your machine's format | | * @param pathToHVSC = HVSC base directory in your machine's format | |
| * @return | | * @return | |
| * - false - Problem opening or parsing STIL/BUGlist | | * - false - Problem opening or parsing STIL/BUGlist | |
| * - true - All okay | | * - true - All okay | |
| */ | | */ | |
| bool setBaseDir(const char *pathToHVSC); | | bool setBaseDir(const char *pathToHVSC); | |
| | | | |
| /** | | /** | |
|
| * Returns a floating number telling what the version | | * Returns a floating number telling what the version | |
| * number is of the STIL.txt file. | | * number is of the STIL.txt file. | |
| * To be called only after setBaseDir()! | | * To be called only after setBaseDir()! | |
| * | | * | |
| * @return | | * @return | |
| * version number (0.0 if setBaseDir() was not called, yet) | | * version number (0.0 if setBaseDir() was not called, yet) | |
| */ | | */ | |
| float getSTILVersionNo(); | | float getSTILVersionNo(); | |
| | | | |
| /** | | /** | |
|
| * Given an HVSC pathname, a tune number and a | | * Given an HVSC pathname, a tune number and a | |
| * field designation, it returns a formatted string that | | * field designation, it returns a formatted string that | |
| * contains the STIL field for the tune number (if exists). | | * contains the STIL field for the tune number (if exists). | |
| * If it doesn't exist, returns a NULL. | | * If it doesn't exist, returns a NULL. | |
| * | | * | |
| * @param relPathToEntry = relative to the HVSC base dir, starting with | | * @param relPathToEntry = relative to the HVSC base dir, starting with | |
| * a slash | | * a slash | |
| * @param tuneNo = song number within the song (default=0). | | * @param tuneNo = song number within the song (default=0). | |
| * @param field = which field to retrieve (default=all). | | * @param field = which field to retrieve (default=all). | |
| * | | * | |
| * What the possible combinations of tuneNo and field represent: | | * What the possible combinations of tuneNo and field represent: | |
| * | | * | |
| * - tuneNo = 0, field = all : all of the STIL entry is returned. | | * - tuneNo = 0, field = all : all of the STIL entry is returned. | |
| * - tuneNo = 0, field = comment : the file-global comment is returned. | | * - tuneNo = 0, field = comment : the file-global comment is returned. | |
| * (For single-tune entries, this returns nothing!) | | * (For single-tune entries, this returns nothing!) | |
| * - tuneNo = 0, field = <other> : INVALID! (NULL is returned) | | * - tuneNo = 0, field = <other> : INVALID! (NULL is returned) | |
| * - tuneNo != 0, field = all : all fields of the STIL entry for the | | * - tuneNo != 0, field = all : all fields of the STIL entry for the | |
| * given tune number are returned. (For single-tune entries, this is | | * given tune number are returned. (For single-tune entries, this is | |
| * equivalent to saying tuneNo = 0, field = all.) | | * equivalent to saying tuneNo = 0, field = all.) | |
| * However, the file-global comment is *NOT* returned with it any | | * However, the file-global comment is *NOT* returned with it any | |
| * more! (Unlike in versions before v2.00.) It led to confusions: | | * more! (Unlike in versions before v2.00.) It led to confusions: | |
| * eg. when a comment was asked for tune #3, it returned the | | * eg. when a comment was asked for tune #3, it returned the | |
| * file-global comment even if there was no specific entry for tune #3 | | * file-global comment even if there was no specific entry for tune # | |
| ! | | 3! | |
| * - tuneNo != 0, field = <other> : the specific field of the specific | | * - tuneNo != 0, field = <other> : the specific field of the specific | |
| * tune number is returned. If the tune number doesn't exist (eg. if | | * tune number is returned. If the tune number doesn't exist (eg. if | |
| * tuneNo=2 for single-tune entries, or if tuneNo=2 when there's no | | * tuneNo=2 for single-tune entries, or if tuneNo=2 when there's no | |
| * STIL entry for tune #2 in a multitune entry), returns NULL. | | * STIL entry for tune #2 in a multitune entry), returns NULL. | |
| * | | * | |
| * NOTE: For older versions of STIL (older than v2.59) the tuneNo and | | * NOTE: For older versions of STIL (older than v2.59) the tuneNo and | |
| * field parameters are ignored and are assumed to be tuneNo=0 and | | * field parameters are ignored and are assumed to be tuneNo=0 and | |
| * field=all to maintain backwards compatibility. | | * field=all to maintain backwards compatibility. | |
| * | | * | |
| * @return | | * @return | |
| * - pointer to a printable formatted string containing | | * - pointer to a printable formatted string containing | |
| * the STIL entry | | * the STIL entry | |
| * (It's kinda dangerous to return a pointer that points | | * (It's kinda dangerous to return a pointer that points | |
| * to an internal structure, but I trust you. :) | | * to an internal structure, but I trust you. :) | |
| * - NULL if there's absolutely no STIL entry for the tune | | * - NULL if there's absolutely no STIL entry for the tune | |
| */ | | */ | |
| const char *getEntry(const char *relPathToEntry, int tuneNo = 0, STILFi
eld field = all); | | const char *getEntry(const char *relPathToEntry, int tuneNo = 0, STILFi
eld field = all); | |
| | | | |
| /** | | /** | |
|
| * Same as #getEntry, but with an absolute path given | | * Same as #getEntry, but with an absolute path given | |
| * given in your machine's format. | | * given in your machine's format. | |
| */ | | */ | |
| const char *getAbsEntry(const char *absPathToEntry, int tuneNo = 0, STI
LField field = all); | | const char *getAbsEntry(const char *absPathToEntry, int tuneNo = 0, STI
LField field = all); | |
| | | | |
| /** | | /** | |
|
| * Given an HVSC pathname and tune number it returns a | | * Given an HVSC pathname and tune number it returns a | |
| * formatted string that contains the section-global | | * formatted string that contains the section-global | |
| * comment for the tune number (if it exists). If it | | * comment for the tune number (if it exists). If it | |
| * doesn't exist, returns a NULL. | | * doesn't exist, returns a NULL. | |
| * | | * | |
| * @param relPathToEntry = relative to the HVSC base dir starting with | | * @param relPathToEntry = relative to the HVSC base dir starting with | |
| * a slash | | * a slash | |
| * @return | | * @return | |
| * - pointer to a printable formatted string containing | | * - pointer to a printable formatted string containing | |
| * the section-global comment | | * the section-global comment | |
| * (It's kinda dangerous to return a pointer that points | | * (It's kinda dangerous to return a pointer that points | |
| * to an internal structure, but I trust you. :) | | * to an internal structure, but I trust you. :) | |
| * - NULL if there's absolutely no section-global comment | | * - NULL if there's absolutely no section-global comment | |
| * for the tune | | * for the tune | |
| */ | | */ | |
| const char *getGlobalComment(const char *relPathToEntry); | | const char *getGlobalComment(const char *relPathToEntry); | |
| | | | |
| /** | | /** | |
|
| * Same as #getGlobalComment, but with an absolute path | | * Same as #getGlobalComment, but with an absolute path | |
| * given in your machine's format. | | * given in your machine's format. | |
| */ | | */ | |
| const char *getAbsGlobalComment(const char *absPathToEntry); | | const char *getAbsGlobalComment(const char *absPathToEntry); | |
| | | | |
| /** | | /** | |
|
| * Given an HVSC pathname and tune number it returns a | | * Given an HVSC pathname and tune number it returns a | |
| * formatted string that contains the BUG entry for the | | * formatted string that contains the BUG entry for the | |
| * tune number (if exists). If it doesn't exist, returns | | * tune number (if exists). If it doesn't exist, returns | |
| * a NULL. | | * a NULL. | |
| * | | * | |
| * @param relPathToEntry = relative to the HVSC base dir starting with | | * @param relPathToEntry = relative to the HVSC base dir starting with | |
| * a slash | | * a slash | |
| * @param tuneNo = song number within the song (default=0) | | * @param tuneNo = song number within the song (default=0) | |
| * If tuneNo=0, returns all of the BUG entry. | | * If tuneNo=0, returns all of the BUG entry. | |
| * | | * | |
| * NOTE: For older versions of STIL (older than v2.59) tuneNo is | | * NOTE: For older versions of STIL (older than v2.59) tuneNo is | |
| * ignored and is assumed to be 0 to maintain backwards | | * ignored and is assumed to be 0 to maintain backwards | |
| * compatibility. | | * compatibility. | |
| * | | * | |
| * @return | | * @return | |
| * - pointer to a printable formatted string containing | | * - pointer to a printable formatted string containing | |
| * the BUG entry | | * the BUG entry | |
| * (It's kinda dangerous to return a pointer that points | | * (It's kinda dangerous to return a pointer that points | |
| * to an internal structure, but I trust you. :) | | * to an internal structure, but I trust you. :) | |
| * - NULL if there's absolutely no BUG entry for the tune | | * - NULL if there's absolutely no BUG entry for the tune | |
| */ | | */ | |
| const char *getBug(const char *relPathToEntry, int tuneNo = 0); | | const char *getBug(const char *relPathToEntry, int tuneNo = 0); | |
| | | | |
| /** | | /** | |
|
| * Same as #getBug, but with an absolute path | | * Same as #getBug, but with an absolute path | |
| * given in your machine's format. | | * given in your machine's format. | |
| */ | | */ | |
| const char *getAbsBug(const char *absPathToEntry, int tuneNo = 0); | | const char *getAbsBug(const char *absPathToEntry, int tuneNo = 0); | |
| | | | |
| /** | | /** | |
|
| * Returns a specific error number identifying the problem | | * Returns a specific error number identifying the problem | |
| * that happened at the last invoked public method. | | * that happened at the last invoked public method. | |
| * | | * | |
| * @return | | * @return | |
| * STILerror - an enumerated error value | | * STILerror - an enumerated error value | |
| */ | | */ | |
| inline STILerror getError() const {return (lastError);} | | inline STILerror getError() const {return (lastError);} | |
| | | | |
| /** | | /** | |
|
| * Returns true if the last error encountered was critical | | * Returns true if the last error encountered was critical | |
| * (ie. not one that the STIL class can recover from). | | * (ie. not one that the STIL class can recover from). | |
| * | | * | |
| * @return | | * @return | |
| * true if the last error encountered was critical | | * true if the last error encountered was critical | |
| */ | | */ | |
| inline bool hasCriticalError() const | | inline bool hasCriticalError() const | |
| { | | { | |
| return ((lastError >= CRITICAL_STIL_ERROR) ? true : false); | | return ((lastError >= CRITICAL_STIL_ERROR) ? true : false); | |
| } | | } | |
| | | | |
| /** | | /** | |
|
| * Returns an ASCII error string containing the | | * Returns an ASCII error string containing the | |
| * description of the error that happened at the last | | * description of the error that happened at the last | |
| * invoked public method. | | * invoked public method. | |
| * | | * | |
| * @return | | * @return | |
| * pointer to string with the error description | | * pointer to string with the error description | |
| */ | | */ | |
| inline const char *getErrorStr() const {return (STIL_ERROR_STR[lastErro
r]);} | | inline const char *getErrorStr() const {return (STIL_ERROR_STR[lastErro
r]);} | |
| | | | |
| private: | | private: | |
| typedef std::map<std::string, std::streampos> dirList; | | typedef std::map<std::string, std::streampos> dirList; | |
| | | | |
| /// Path to STIL. | | /// Path to STIL. | |
| const char *PATH_TO_STIL; | | const char *PATH_TO_STIL; | |
| | | | |
| /// Path to BUGlist. | | /// Path to BUGlist. | |
| const char *PATH_TO_BUGLIST; | | const char *PATH_TO_BUGLIST; | |
| | | | |
| /// Version number/copyright string | | /// Version number/copyright string | |
| std::string versionString; | | std::string versionString; | |
| | | | |
| /// STIL.txt's version number | | /// STIL.txt's version number | |
| float STILVersion; | | float STILVersion; | |
| | | | |
| /// Base dir | | /// Base dir | |
| std::string baseDir; | | std::string baseDir; | |
| | | | |
|
| /** | | /// Maps of sections (subdirs) for easier positioning. | |
| * Maps of sections (subdirs) for easier positioning. | | | |
| */ | | | |
| //@{ | | //@{ | |
| dirList stilDirs; | | dirList stilDirs; | |
| dirList bugDirs; | | dirList bugDirs; | |
| //@} | | //@} | |
| | | | |
| /** | | /** | |
|
| * This tells us what the line delimiter is in STIL.txt. | | * This tells us what the line delimiter is in STIL.txt. | |
| * (It may be two chars!) | | * (It may be two chars!) | |
| */ | | */ | |
| char STIL_EOL; | | char STIL_EOL; | |
| char STIL_EOL2; | | char STIL_EOL2; | |
| | | | |
| /// Error number of the last error that happened. | | /// Error number of the last error that happened. | |
| STILerror lastError; | | STILerror lastError; | |
| | | | |
| /// Error strings containing the description of the possible errors in
STIL. | | /// Error strings containing the description of the possible errors in
STIL. | |
| static const char *STIL_ERROR_STR[]; | | static const char *STIL_ERROR_STR[]; | |
| | | | |
| //////////////// | | //////////////// | |
| | | | |
| skipping to change at line 328 | | skipping to change at line 326 | |
| | | | |
| /// Buffers to hold the resulting strings | | /// Buffers to hold the resulting strings | |
| std::string resultEntry; | | std::string resultEntry; | |
| std::string resultBug; | | std::string resultBug; | |
| | | | |
| //////////////// | | //////////////// | |
| | | | |
| void setVersionString(); | | void setVersionString(); | |
| | | | |
| /** | | /** | |
|
| * Determines what the EOL char is (or are) from STIL.txt. | | * Determines what the EOL char is (or are) from STIL.txt. | |
| * It is assumed that BUGlist.txt will use the same EOL. | | * It is assumed that BUGlist.txt will use the same EOL. | |
| * | | * | |
| * @return | | * @return | |
| * - false - something went wrong | | * - false - something went wrong | |
| * - true - everything is okay | | * - true - everything is okay | |
| */ | | */ | |
| bool determineEOL(std::ifstream &stilFile); | | bool determineEOL(std::ifstream &stilFile); | |
| | | | |
| /** | | /** | |
|
| * Populates the given dirList array with the directories | | * Populates the given dirList array with the directories | |
| * obtained from 'inFile' for faster positioning within | | * obtained from 'inFile' for faster positioning within | |
| * 'inFile'. | | * 'inFile'. | |
| * | | * | |
| * @param inFile - where to read the directories from | | * @param inFile - where to read the directories from | |
| * @param dirs - the dirList array that should be populated with the | | * @param dirs - the dirList array that should be populated with the | |
| * directory list | | * directory list | |
| * @param isSTILFile - is this the STIL or the BUGlist we are parsing | | * @param isSTILFile - is this the STIL or the BUGlist we are parsing | |
| * @return | | * @return | |
| * - false - No entries were found or otherwise failed to process | | * - false - No entries were found or otherwise failed to process | |
| * inFile | | * inFile | |
| * - true - everything is okay | | * - true - everything is okay | |
| */ | | */ | |
| bool getDirs(std::ifstream &inFile, dirList &dirs, bool isSTILFile); | | bool getDirs(std::ifstream &inFile, dirList &dirs, bool isSTILFile); | |
| | | | |
| /** | | /** | |
|
| * Positions the file pointer to the given entry in 'inFile' | | * Positions the file pointer to the given entry in 'inFile' | |
| * using the 'dirs' dirList for faster positioning. | | * using the 'dirs' dirList for faster positioning. | |
| * | | * | |
| * @param entryStr - the entry to position to | | * @param entryStr - the entry to position to | |
| * @param inFile - position the file pointer in this file | | * @param inFile - position the file pointer in this file | |
| * @param dirs - the list of dirs in inFile for easier positioning | | * @param dirs - the list of dirs in inFile for easier positioning | |
| * @return | | * @return | |
| * - true - if successful | | * - true - if successful | |
| * - false - otherwise | | * - false - otherwise | |
| */ | | */ | |
| bool positionToEntry(const char *entryStr, std::ifstream &inFile, dirLi
st &dirs); | | bool positionToEntry(const char *entryStr, std::ifstream &inFile, dirLi
st &dirs); | |
| | | | |
| /** | | /** | |
|
| * Reads the entry from 'inFile' into 'buffer'. 'inFile' should | | * Reads the entry from 'inFile' into 'buffer'. 'inFile' should | |
| * already be positioned to the entry to be read. | | * already be positioned to the entry to be read. | |
| * | | * | |
| * @param inFile - filehandle of file to read from | | * @param inFile - filehandle of file to read from | |
| * @param entryStr - the entry needed to be read | | * @param entryStr - the entry needed to be read | |
| * @param buffer - where to put the result to | | * @param buffer - where to put the result to | |
| */ | | */ | |
| void readEntry(std::ifstream &inFile, std::string &buffer); | | void readEntry(std::ifstream &inFile, std::string &buffer); | |
| | | | |
| /** | | /** | |
|
| * Given a STIL formatted entry in 'buffer', a tune number, | | * Given a STIL formatted entry in 'buffer', a tune number, | |
| * and a field designation, it returns the requested | | * and a field designation, it returns the requested | |
| * STIL field into 'result'. | | * STIL field into 'result'. | |
| * If field=all, it also puts the file-global comment (if it exists) | | * If field=all, it also puts the file-global comment (if it exists) | |
| * as the first field into 'result'. | | * as the first field into 'result'. | |
| * | | * | |
| * @param result - where to put the resulting string to (if any) | | * @param result - where to put the resulting string to (if any) | |
| * @param buffer - pointer to the first char of what to search for | | * @param buffer - pointer to the first char of what to search for | |
| * the field. Should be a buffer in standard STIL | | * the field. Should be a buffer in standard STIL | |
| * format. | | * format. | |
| * @param tuneNo - song number within the song (default=0) | | * @param tuneNo - song number within the song (default=0) | |
| * @param field - which field to retrieve (default=all). | | * @param field - which field to retrieve (default=all). | |
| * @return | | * @return | |
| * - false - if nothing was put into 'result' | | * - false - if nothing was put into 'result' | |
| * - true - 'result' has the resulting field | | * - true - 'result' has the resulting field | |
| */ | | */ | |
| bool getField(std::string &result, const char *buffer, int tuneNo = 0,
STILField field = all); | | bool getField(std::string &result, const char *buffer, int tuneNo = 0,
STILField field = all); | |
| | | | |
| /** | | /** | |
|
| * @param result - where to put the resulting string to (if any) | | * @param result - where to put the resulting string to (if any) | |
| * @param start - pointer to the first char of what to search for | | * @param start - pointer to the first char of what to search for | |
| * the field. Should be a buffer in standard STIL | | * the field. Should be a buffer in standard STIL | |
| * format. | | * format. | |
| * @param end - pointer to the last+1 char of what to search for | | * @param end - pointer to the last+1 char of what to search for | |
| * the field. ('end-1' should be a '\n'!) | | * the field. ('end-1' should be a '\n'!) | |
| * @param field - which specific field to retrieve | | * @param field - which specific field to retrieve | |
| * @return | | * @return | |
| * - false - if nothing was put into 'result' | | * - false - if nothing was put into 'result' | |
| * - true - 'result' has the resulting field | | * - true - 'result' has the resulting field | |
| */ | | */ | |
| bool getOneField(std::string &result, const char *start, const char *en
d, STILField field); | | bool getOneField(std::string &result, const char *start, const char *en
d, STILField field); | |
| | | | |
| /** | | /** | |
|
| * Extracts one line from 'infile' to 'line[]'. The end of | | * Extracts one line from 'infile' to 'line[]'. The end of | |
| * the line is marked by endOfLineChar. Also eats up | | * the line is marked by endOfLineChar. Also eats up | |
| * additional EOL-like chars. | | * additional EOL-like chars. | |
| * | | * | |
| * @param infile - filehandle (streampos should already be positioned | | * @param infile - filehandle (streampos should already be positioned | |
| * to the start of the desired line) | | * to the start of the desired line) | |
| * @param line - char array to put the line into | | * @param line - char array to put the line into | |
| */ | | */ | |
| void getStilLine(std::ifstream &infile, std::string &line); | | void getStilLine(std::ifstream &infile, std::string &line); | |
| | | | |
| private: | | private: | |
| /** | | /** | |
|
| * Converts slashes to the one the OS uses to access files. | | * Converts slashes to the one the OS uses to access files. | |
| * | | * | |
| * @param | | * @param | |
| * str - what to convert | | * str - what to convert | |
| */ | | */ | |
| static void convertSlashes(std::string &str) { std::replace(str.begin()
, str.end(), '/', SLASH); } | | static void convertSlashes(std::string &str) { std::replace(str.begin()
, str.end(), '/', SLASH); } | |
| | | | |
| /** | | /** | |
|
| * Converts OS specific dir separators to slashes. | | * Converts OS specific dir separators to slashes. | |
| * | | * | |
| * @param | | * @param | |
| * str - what to convert | | * str - what to convert | |
| */ | | */ | |
| static void convertToSlashes(std::string &str) { std::replace(str.begin
(), str.end(), SLASH, '/'); } | | static void convertToSlashes(std::string &str) { std::replace(str.begin
(), str.end(), SLASH, '/'); } | |
| }; | | }; | |
| | | | |
| #endif // STIL_H | | #endif // STIL_H | |
| | | | |
End of changes. 26 change blocks. |
| 243 lines changed or deleted | | 241 lines changed or added | |
|